The core protocol of WoopChain
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
woop/rosetta/common/operations.go

125 lines
3.8 KiB

Rosetta Implementation - pt2 (Stage 3.2 of Node API Overhaul) (#3312) * [rosetta] Add server stop Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Make network naming consistent Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Correct common package name & add error enum Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Remove needless forward of network info to services * Implement /network/list Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Refactor errors & add operation statuses and types Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Implement NetworkOptions & update NetworkAPIService * Rename *_service.go files to remove the suffix * Update StartServers to use new operation types Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Impl NetworkStatus - Finish init impl of /network endpoint * Fix import structure for rosetta.go Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [test] Make explorer run as archival for localnet Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add unit tests * Force errors to remain the same with unit tests * Force operations to remain the same with unit tests * Ensure network checking works for all cases with unit tests Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add InvalidNetworkError and correct error codes Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add UnmarshalFromInterface for SubNetworkMetadata Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add network checking Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Nit fixes & add unit test for Peer Info * Make names consistent Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add BlockNotFoundError & TransactionNotFoundError Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Implement skeleton for block transactions Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add ReceiptNotFoundError Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add receipt to formatTransaction sig for contract fails Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add currency, ExpendGasOperation, & ContractCreationOperation * Add Error creator Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Init impl of plain transaction formatting Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Update network.go for new error constructor Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Implement stx formatter & refactor BlockTransaction * Updated todo comments & function formatting Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Impl Block & make currency non-ptr for easy copy with custom metadata Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix collect rewards amount on transaction fetch Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix block look-up edge case & add recovery middleware Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add bocks unit tests Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix checkPeerID unit test in network_test.go Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix staking tx amount for tx ops & update inline docs Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix lint Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Refactor getStakingOperations Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix undelegate value Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Nit - fix formatting for network.go Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [node] Move genesis allocation to core & remove unused ContractDeployerKey Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix precision error & add cx receipt hash on blk fetch * Add unit tests for supporting helper functions Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix fmt Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix cx receipt hashes for blocks * Print stack trace on panic recovery Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [node] Nit - fix comment for StopRosetta Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [node] Expose GetMaxPeerHeight Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add SyncStatus enum Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Nit - remove redundant 'service' name in services namespace Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
4 years ago
package common
import (
Rosetta Implementation - pt4 (Stage 3.4 of Node API Overhaul) (#3380) * [rosetta] Add /construct function framework Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add network ID check to all construct endpoints Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add UnsupportedCurveTypeError Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Implement ConstructionDerive & add ConstructAPI router Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Make recover middleware the outermost middleware Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Correct error for block not found Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rpc] Expose EstimateGas Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add InvalidTransactionConstructionError * Add GetValidConstructionOperations Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Make TransactionMetadata optional ptr * Add UnmarshalFromInterface for TransactionMetadata Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add InvalidTransactionConstructionError to network response Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add ConstructionPreprocess & ConstructionMetadata skeleton * Add Helper methods for said functions Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add GasPrice to ConstructMetadata Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Make suggested gas fee & price its own fn Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Nit - fix comment Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add To & From Account ID in tx metadata * remove getAmountFromUndelegateMessage * make contract address a valid account identifier * remove needless metadata in non-staking operations Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add error report for b32 error in newAccountIdentifier Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Simplify assertValidNetworkIdentifier Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Use sdk MapMarshall instead of rpc structured response * remove unused GetValidConstructionOperations * Add CurrencyHash Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Implement assertValidTransferOperationsAndGetTxAccounts * refactor usages of rpc structured response for sdk map marshall * add account identifier checks for transaction metadata Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Max related operation check more general for tx op check * refactor names for readability Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add & Expose OperationComponents * Remove txAccounts & add OperationComponents to metadata for quicker processing * Remove From & To acc ID from TransactionMetadata as it's in OperationComponents * Update tests for changes Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add tx type to OperationComponents Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add logs to TransactionMetadata * Enforce Operation type uniqueness invariant for each transaction Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add error for 3+ operations in getOperationComponents Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Expose GetOperationComponents Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add CrossShardTransactionOperationMetadata Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add staking operation medata type declaration Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Fix error messages & update comment Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Implement getCrossShardOperationComponents * rename txAccs to components for clarity Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Implement getContractCreationOperationComponents * Fix some edge case optional checks for operation validation Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [go.mod] Bump rosetta version to 0.4.4 & dependent libs * Update broken rosetta structs Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add ChainID to ConstructMetadata Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Rename PreStakingBlockRewardOperation Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Init operation_components.go & move respective code Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Refactor formatTransaction for clarity Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Move maxNumOfConstructionOps to operation_components.go * Clarify unsupported type err msg Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Implement framework for ConstructionPayloads * Remove currying OperationComponents in metadata as PublicKeys is now part of the request in the necessary endpoints * Add respective checks for added PublicKeys * Make getAddressFromPublicKey more general & update tests Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add getAddress and update respective functions Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Create transaction_construction.go & impl ConstructTransaction Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add unmarshal check for ConstructMetadata & ConstructMetadataOptions * Remove constructTransaction * Wrap unsigned transaction with UnsignedTransaction to include intended signer * Add framework for ConstructionParse Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add getSigningPayload method to construction Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [internal/commonm] Add MustGeneratePrivateKey Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Implement parseUnsignedTransaction * Add unpackWrappedTransactionFromHexString & refactor rlp encoding of transactions * Make getSigningPayload return a list Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add TestUnpackWrappedTransactionFromHexString Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Implement parseSignedTransaction * Move unpackWrappedTransactionFromHexString to ConstructionParse before parsing transactions bases on if it's signed or not Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Nit - fix WrappedTransaction comments Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add extra negative tests for unpackWrappedTransactionFromHexString Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Finish initial Construct implementation * Implement ConstructionCombine * Implement ConstructionHash * Implement ConstructionSubmit * Ensure RLPbytes & From is present in WrappedTransaction when unpackWrappedTransactionFromHexString is called Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Refactor construction into separate files * Move tests into appropriate files Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Implement construction_check_test.go * Update edge case for getSuggestedFeeAndPrice found during testing Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Implement construction_parse_test.go * Clarify names for construction_create_test.go Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Fix ConstructionParse to not use crypto.PubkeyToAddress Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Fix UnmarshalFromInterface for CrossShardTransactionOperationMetadata Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add operation_components_test.go * Implement TestGetContractCreationOperationComponents * Implement TestGetCrossShardOperationComponents Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Finish operation_components_test.go * Implement TestGetTransferOperationComponents * Implement TestGetOperationComponents Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Fix big number checks for getTransferOperationComponents Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Implement transaction_construction_test.go * Implement TestConstructPlainTransaction * Implement TestConstructCrossShardTransaction * Implement TestConstructContractCreationTransaction Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add shard ID checks for constructCrossShardTransaction Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add bad curve test for TestGetAddressFromPublicKey Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add nil error catches for Construction API * Fix nits in messages as seen during pass * Add DefaultGasLimit Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add trace message with version to all err msgs * Add NewError unit test Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add TestGetAddressFromKnownPublicKey Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [hmy] Fix possible nil ptr crash for GetBlockSigners Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Edge case bug fixes * Create empty TransactionMetdata if no metadata is provided in operations. Also update tests to correctly account for the behavior. * In pre-staking era make current block one less than the absolute latest to guarentee calculation of pres-taking eara block rewards. Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix unpackWrappedTransactionFromHexString * Rename function to unpackWrappedTransactionFromString * Update respective tests Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Make parsed transaction statuses empty Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Remove needles list initialization Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add SignatureType & SignedPayloadLength with checks Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Fix genesis network status crash Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Correct error message dumps for transaction_construction.go Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add OperationType to ConstructMetadataOptions Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Fix rosetta service rebase Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rpc] Fix estimate gas fail check Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add formatNegativeValue to ensure there's only 1 zero * Correct regression found in constructCrossShardTransaction Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add contract creation estimate gas hack Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add DefaultSenderAddress for transaction formatter * Update Construction API parser to reflect change Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix imports Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Address PR comments * Add GetCallStackInfo to internal utils * Add EstimateGas TODO in RPC package * Remove DefaultGasLimit to use param gas limit Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add checks to tx formatter for nil to addr * Remove needless block check for genesisBlock Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Remove EstimatedGasUsed from WrappedTransaction Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
4 years ago
"encoding/json"
"fmt"
Rosetta Implementation - pt2 (Stage 3.2 of Node API Overhaul) (#3312) * [rosetta] Add server stop Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Make network naming consistent Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Correct common package name & add error enum Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Remove needless forward of network info to services * Implement /network/list Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Refactor errors & add operation statuses and types Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Implement NetworkOptions & update NetworkAPIService * Rename *_service.go files to remove the suffix * Update StartServers to use new operation types Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Impl NetworkStatus - Finish init impl of /network endpoint * Fix import structure for rosetta.go Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [test] Make explorer run as archival for localnet Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add unit tests * Force errors to remain the same with unit tests * Force operations to remain the same with unit tests * Ensure network checking works for all cases with unit tests Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add InvalidNetworkError and correct error codes Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add UnmarshalFromInterface for SubNetworkMetadata Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add network checking Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Nit fixes & add unit test for Peer Info * Make names consistent Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add BlockNotFoundError & TransactionNotFoundError Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Implement skeleton for block transactions Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add ReceiptNotFoundError Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add receipt to formatTransaction sig for contract fails Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add currency, ExpendGasOperation, & ContractCreationOperation * Add Error creator Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Init impl of plain transaction formatting Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Update network.go for new error constructor Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Implement stx formatter & refactor BlockTransaction * Updated todo comments & function formatting Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Impl Block & make currency non-ptr for easy copy with custom metadata Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix collect rewards amount on transaction fetch Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix block look-up edge case & add recovery middleware Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add bocks unit tests Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix checkPeerID unit test in network_test.go Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix staking tx amount for tx ops & update inline docs Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix lint Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Refactor getStakingOperations Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix undelegate value Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Nit - fix formatting for network.go Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [node] Move genesis allocation to core & remove unused ContractDeployerKey Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix precision error & add cx receipt hash on blk fetch * Add unit tests for supporting helper functions Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix fmt Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix cx receipt hashes for blocks * Print stack trace on panic recovery Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [node] Nit - fix comment for StopRosetta Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [node] Expose GetMaxPeerHeight Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add SyncStatus enum Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Nit - remove redundant 'service' name in services namespace Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
4 years ago
"github.com/coinbase/rosetta-sdk-go/types"
Rosetta Implementation - pt4 (Stage 3.4 of Node API Overhaul) (#3380) * [rosetta] Add /construct function framework Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add network ID check to all construct endpoints Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add UnsupportedCurveTypeError Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Implement ConstructionDerive & add ConstructAPI router Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Make recover middleware the outermost middleware Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Correct error for block not found Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rpc] Expose EstimateGas Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add InvalidTransactionConstructionError * Add GetValidConstructionOperations Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Make TransactionMetadata optional ptr * Add UnmarshalFromInterface for TransactionMetadata Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add InvalidTransactionConstructionError to network response Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add ConstructionPreprocess & ConstructionMetadata skeleton * Add Helper methods for said functions Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add GasPrice to ConstructMetadata Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Make suggested gas fee & price its own fn Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Nit - fix comment Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add To & From Account ID in tx metadata * remove getAmountFromUndelegateMessage * make contract address a valid account identifier * remove needless metadata in non-staking operations Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add error report for b32 error in newAccountIdentifier Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Simplify assertValidNetworkIdentifier Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Use sdk MapMarshall instead of rpc structured response * remove unused GetValidConstructionOperations * Add CurrencyHash Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Implement assertValidTransferOperationsAndGetTxAccounts * refactor usages of rpc structured response for sdk map marshall * add account identifier checks for transaction metadata Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Max related operation check more general for tx op check * refactor names for readability Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add & Expose OperationComponents * Remove txAccounts & add OperationComponents to metadata for quicker processing * Remove From & To acc ID from TransactionMetadata as it's in OperationComponents * Update tests for changes Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add tx type to OperationComponents Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add logs to TransactionMetadata * Enforce Operation type uniqueness invariant for each transaction Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add error for 3+ operations in getOperationComponents Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Expose GetOperationComponents Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add CrossShardTransactionOperationMetadata Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add staking operation medata type declaration Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Fix error messages & update comment Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Implement getCrossShardOperationComponents * rename txAccs to components for clarity Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Implement getContractCreationOperationComponents * Fix some edge case optional checks for operation validation Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [go.mod] Bump rosetta version to 0.4.4 & dependent libs * Update broken rosetta structs Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add ChainID to ConstructMetadata Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Rename PreStakingBlockRewardOperation Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Init operation_components.go & move respective code Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Refactor formatTransaction for clarity Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Move maxNumOfConstructionOps to operation_components.go * Clarify unsupported type err msg Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Implement framework for ConstructionPayloads * Remove currying OperationComponents in metadata as PublicKeys is now part of the request in the necessary endpoints * Add respective checks for added PublicKeys * Make getAddressFromPublicKey more general & update tests Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add getAddress and update respective functions Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Create transaction_construction.go & impl ConstructTransaction Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add unmarshal check for ConstructMetadata & ConstructMetadataOptions * Remove constructTransaction * Wrap unsigned transaction with UnsignedTransaction to include intended signer * Add framework for ConstructionParse Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add getSigningPayload method to construction Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [internal/commonm] Add MustGeneratePrivateKey Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Implement parseUnsignedTransaction * Add unpackWrappedTransactionFromHexString & refactor rlp encoding of transactions * Make getSigningPayload return a list Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add TestUnpackWrappedTransactionFromHexString Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Implement parseSignedTransaction * Move unpackWrappedTransactionFromHexString to ConstructionParse before parsing transactions bases on if it's signed or not Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Nit - fix WrappedTransaction comments Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add extra negative tests for unpackWrappedTransactionFromHexString Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Finish initial Construct implementation * Implement ConstructionCombine * Implement ConstructionHash * Implement ConstructionSubmit * Ensure RLPbytes & From is present in WrappedTransaction when unpackWrappedTransactionFromHexString is called Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Refactor construction into separate files * Move tests into appropriate files Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Implement construction_check_test.go * Update edge case for getSuggestedFeeAndPrice found during testing Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Implement construction_parse_test.go * Clarify names for construction_create_test.go Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Fix ConstructionParse to not use crypto.PubkeyToAddress Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Fix UnmarshalFromInterface for CrossShardTransactionOperationMetadata Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add operation_components_test.go * Implement TestGetContractCreationOperationComponents * Implement TestGetCrossShardOperationComponents Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Finish operation_components_test.go * Implement TestGetTransferOperationComponents * Implement TestGetOperationComponents Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Fix big number checks for getTransferOperationComponents Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Implement transaction_construction_test.go * Implement TestConstructPlainTransaction * Implement TestConstructCrossShardTransaction * Implement TestConstructContractCreationTransaction Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add shard ID checks for constructCrossShardTransaction Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add bad curve test for TestGetAddressFromPublicKey Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add nil error catches for Construction API * Fix nits in messages as seen during pass * Add DefaultGasLimit Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add trace message with version to all err msgs * Add NewError unit test Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add TestGetAddressFromKnownPublicKey Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [hmy] Fix possible nil ptr crash for GetBlockSigners Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Edge case bug fixes * Create empty TransactionMetdata if no metadata is provided in operations. Also update tests to correctly account for the behavior. * In pre-staking era make current block one less than the absolute latest to guarentee calculation of pres-taking eara block rewards. Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix unpackWrappedTransactionFromHexString * Rename function to unpackWrappedTransactionFromString * Update respective tests Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Make parsed transaction statuses empty Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Remove needles list initialization Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add SignatureType & SignedPayloadLength with checks Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Fix genesis network status crash Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Correct error message dumps for transaction_construction.go Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add OperationType to ConstructMetadataOptions Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Fix rosetta service rebase Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rpc] Fix estimate gas fail check Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add formatNegativeValue to ensure there's only 1 zero * Correct regression found in constructCrossShardTransaction Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add contract creation estimate gas hack Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add DefaultSenderAddress for transaction formatter * Update Construction API parser to reflect change Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix imports Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Address PR comments * Add GetCallStackInfo to internal utils * Add EstimateGas TODO in RPC package * Remove DefaultGasLimit to use param gas limit Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add checks to tx formatter for nil to addr * Remove needless block check for genesisBlock Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Remove EstimatedGasUsed from WrappedTransaction Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
4 years ago
rpcV2 "github.com/harmony-one/harmony/rpc/v2"
Rosetta Implementation - pt2 (Stage 3.2 of Node API Overhaul) (#3312) * [rosetta] Add server stop Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Make network naming consistent Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Correct common package name & add error enum Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Remove needless forward of network info to services * Implement /network/list Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Refactor errors & add operation statuses and types Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Implement NetworkOptions & update NetworkAPIService * Rename *_service.go files to remove the suffix * Update StartServers to use new operation types Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Impl NetworkStatus - Finish init impl of /network endpoint * Fix import structure for rosetta.go Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [test] Make explorer run as archival for localnet Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add unit tests * Force errors to remain the same with unit tests * Force operations to remain the same with unit tests * Ensure network checking works for all cases with unit tests Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add InvalidNetworkError and correct error codes Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add UnmarshalFromInterface for SubNetworkMetadata Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add network checking Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Nit fixes & add unit test for Peer Info * Make names consistent Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add BlockNotFoundError & TransactionNotFoundError Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Implement skeleton for block transactions Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add ReceiptNotFoundError Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add receipt to formatTransaction sig for contract fails Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add currency, ExpendGasOperation, & ContractCreationOperation * Add Error creator Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Init impl of plain transaction formatting Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Update network.go for new error constructor Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Implement stx formatter & refactor BlockTransaction * Updated todo comments & function formatting Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Impl Block & make currency non-ptr for easy copy with custom metadata Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix collect rewards amount on transaction fetch Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix block look-up edge case & add recovery middleware Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add bocks unit tests Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix checkPeerID unit test in network_test.go Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix staking tx amount for tx ops & update inline docs Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix lint Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Refactor getStakingOperations Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix undelegate value Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Nit - fix formatting for network.go Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [node] Move genesis allocation to core & remove unused ContractDeployerKey Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix precision error & add cx receipt hash on blk fetch * Add unit tests for supporting helper functions Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix fmt Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix cx receipt hashes for blocks * Print stack trace on panic recovery Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [node] Nit - fix comment for StopRosetta Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [node] Expose GetMaxPeerHeight Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add SyncStatus enum Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Nit - remove redundant 'service' name in services namespace Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
4 years ago
staking "github.com/harmony-one/harmony/staking/types"
)
const (
Rosetta Implementation Cleanup (Stage 3 of Node API Overhaul) (#3390) * [core] Add FindLogsWithTopic & unit test Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [hmy] Add GetDetailedBlockSignerInfo Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [hmy] Add IsCommitteeSelectionBlock Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [test] Add test transaction creation helpers Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Refactor account.go & add tests * Move TestNewAccountIdentifier & TestGetAddress to account_test.go Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Move Operation & Tx formatting to own files * Move Respective unit tests to own files * Expose GetOperations & GetStakingOperations * Expose FormatTransaction, FormatCrossShardReceiverTransaction, FormatGenesisTransaction, FormatPreStakingRewardTransaction & FormatUndelegationPayoutTransaction Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Move TransactionMetadata to transaction_construction.go Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Update construction to use new helpers & formatters * Make docs consistent for mempool.go Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Move all special tx & blk handling to own file Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Remove all moved fns, methods & tests from block.go Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * Fix lint & imports Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Rename all tx related files for clarity Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Rename DefaultSenderAddress to FormatDefaultSenderAddress Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Rename Currency to NativeCurrency * This is in anticipation of HRC20 token support with rosetta * Rename various native operation functions accordingly * Add documentation to explain what a native token is Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix pre-staking block reward calculation * Move getPreStakingRewardTransactionIdentifiers to block_special.go * Add epoch to block metadata * Update unit tests Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * Add IsLastBlockInEpoch method to Block & Header * Refactor all uses of length check `ShardState` * [hmy] Refactor IsCommitteeSelectionBlock to use chain.IsCommitteeSelectionBlock * Address PR comments Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Update var names in preStakingRewardBlockTransaction Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
4 years ago
// ExpendGasOperation is an operation that only affects the native currency.
ExpendGasOperation = "Gas"
Rosetta Implementation - pt2 (Stage 3.2 of Node API Overhaul) (#3312) * [rosetta] Add server stop Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Make network naming consistent Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Correct common package name & add error enum Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Remove needless forward of network info to services * Implement /network/list Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Refactor errors & add operation statuses and types Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Implement NetworkOptions & update NetworkAPIService * Rename *_service.go files to remove the suffix * Update StartServers to use new operation types Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Impl NetworkStatus - Finish init impl of /network endpoint * Fix import structure for rosetta.go Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [test] Make explorer run as archival for localnet Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add unit tests * Force errors to remain the same with unit tests * Force operations to remain the same with unit tests * Ensure network checking works for all cases with unit tests Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add InvalidNetworkError and correct error codes Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add UnmarshalFromInterface for SubNetworkMetadata Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add network checking Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Nit fixes & add unit test for Peer Info * Make names consistent Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add BlockNotFoundError & TransactionNotFoundError Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Implement skeleton for block transactions Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add ReceiptNotFoundError Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add receipt to formatTransaction sig for contract fails Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add currency, ExpendGasOperation, & ContractCreationOperation * Add Error creator Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Init impl of plain transaction formatting Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Update network.go for new error constructor Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Implement stx formatter & refactor BlockTransaction * Updated todo comments & function formatting Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Impl Block & make currency non-ptr for easy copy with custom metadata Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix collect rewards amount on transaction fetch Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix block look-up edge case & add recovery middleware Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add bocks unit tests Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix checkPeerID unit test in network_test.go Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix staking tx amount for tx ops & update inline docs Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix lint Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Refactor getStakingOperations Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix undelegate value Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Nit - fix formatting for network.go Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [node] Move genesis allocation to core & remove unused ContractDeployerKey Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix precision error & add cx receipt hash on blk fetch * Add unit tests for supporting helper functions Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix fmt Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix cx receipt hashes for blocks * Print stack trace on panic recovery Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [node] Nit - fix comment for StopRosetta Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [node] Expose GetMaxPeerHeight Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add SyncStatus enum Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Nit - remove redundant 'service' name in services namespace Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
4 years ago
[Rosetta] Track internal transactions (#3475) * [rosetta] Refactor operations & prep for internal tx exposure * Remove gas op relation for tx operations. Gas is for submission & processing the tx, thus not really related to the amount being transferred * Make optional starting op a ptr to a uint to keep consistent * Reorg file for consistency of fn placement * Rename functions for clarity * Make getContractCreationNativeOperations consume getBasicTransferOperations for consistency * Remove invariant doc as it does not apply anymore Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add framework for parsing traced txs * Define ContractInfo struct for FormatTransaction * Add tx trace helper function defs & propagate type defs * Add a GetTransactionStatus helper fn for Operation formatting/creation * Add wrapper function, getContractTransferNativeOperations, to get internal operations Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Implement transaction tracer Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [tracer] Add CallerAddress & CodeAddress to tracer logs Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [tracer] Remove ptr to slice & map in StructLogRes Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Implement getContractInternalTransferNativeOperations * Add ContractAddress to ContractInfo for future usages (i.e: erc20 parsing) * Only check for contract address if there is tx data in BlockTransaction Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix status report for contract related txs Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [tracer] Expose contract address instead of code address Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add trace cache & update TODO * Trace any PLAIN transaction instead of only transactions with data. This is to account for fall back contract fn calls & ignore staking data. Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Make internal tx formatter not return err on nil exec result Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * Fix lint Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix tests Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add internal tx unit tests * Fix tx data len check for contract related transfers as a transaction with len 0 data can happen for a contract (and fail) due to fall back operations. Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Update invariant comment Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Expose mutually exclusive ops + update docs & tests Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix docs and err msgs Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
4 years ago
// ContractCreationOperation is an operation that only affects the native currency.
ContractCreationOperation = "ContractCreation"
// NativeTransferOperation is an operation that only affects the native currency.
NativeTransferOperation = "NativeTransfer"
Rosetta Implementation - pt2 (Stage 3.2 of Node API Overhaul) (#3312) * [rosetta] Add server stop Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Make network naming consistent Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Correct common package name & add error enum Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Remove needless forward of network info to services * Implement /network/list Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Refactor errors & add operation statuses and types Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Implement NetworkOptions & update NetworkAPIService * Rename *_service.go files to remove the suffix * Update StartServers to use new operation types Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Impl NetworkStatus - Finish init impl of /network endpoint * Fix import structure for rosetta.go Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [test] Make explorer run as archival for localnet Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add unit tests * Force errors to remain the same with unit tests * Force operations to remain the same with unit tests * Ensure network checking works for all cases with unit tests Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add InvalidNetworkError and correct error codes Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add UnmarshalFromInterface for SubNetworkMetadata Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add network checking Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Nit fixes & add unit test for Peer Info * Make names consistent Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add BlockNotFoundError & TransactionNotFoundError Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Implement skeleton for block transactions Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add ReceiptNotFoundError Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add receipt to formatTransaction sig for contract fails Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add currency, ExpendGasOperation, & ContractCreationOperation * Add Error creator Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Init impl of plain transaction formatting Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Update network.go for new error constructor Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Implement stx formatter & refactor BlockTransaction * Updated todo comments & function formatting Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Impl Block & make currency non-ptr for easy copy with custom metadata Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix collect rewards amount on transaction fetch Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix block look-up edge case & add recovery middleware Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add bocks unit tests Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix checkPeerID unit test in network_test.go Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix staking tx amount for tx ops & update inline docs Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix lint Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Refactor getStakingOperations Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix undelegate value Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Nit - fix formatting for network.go Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [node] Move genesis allocation to core & remove unused ContractDeployerKey Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix precision error & add cx receipt hash on blk fetch * Add unit tests for supporting helper functions Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix fmt Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix cx receipt hashes for blocks * Print stack trace on panic recovery Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [node] Nit - fix comment for StopRosetta Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [node] Expose GetMaxPeerHeight Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add SyncStatus enum Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Nit - remove redundant 'service' name in services namespace Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
4 years ago
// NativeCrossShardTransferOperation is an operation that only affects the native currency.
NativeCrossShardTransferOperation = "NativeCrossShardTransfer"
Rosetta Implementation - pt2 (Stage 3.2 of Node API Overhaul) (#3312) * [rosetta] Add server stop Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Make network naming consistent Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Correct common package name & add error enum Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Remove needless forward of network info to services * Implement /network/list Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Refactor errors & add operation statuses and types Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Implement NetworkOptions & update NetworkAPIService * Rename *_service.go files to remove the suffix * Update StartServers to use new operation types Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Impl NetworkStatus - Finish init impl of /network endpoint * Fix import structure for rosetta.go Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [test] Make explorer run as archival for localnet Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add unit tests * Force errors to remain the same with unit tests * Force operations to remain the same with unit tests * Ensure network checking works for all cases with unit tests Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add InvalidNetworkError and correct error codes Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add UnmarshalFromInterface for SubNetworkMetadata Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add network checking Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Nit fixes & add unit test for Peer Info * Make names consistent Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add BlockNotFoundError & TransactionNotFoundError Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Implement skeleton for block transactions Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add ReceiptNotFoundError Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add receipt to formatTransaction sig for contract fails Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add currency, ExpendGasOperation, & ContractCreationOperation * Add Error creator Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Init impl of plain transaction formatting Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Update network.go for new error constructor Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Implement stx formatter & refactor BlockTransaction * Updated todo comments & function formatting Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Impl Block & make currency non-ptr for easy copy with custom metadata Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix collect rewards amount on transaction fetch Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix block look-up edge case & add recovery middleware Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add bocks unit tests Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix checkPeerID unit test in network_test.go Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix staking tx amount for tx ops & update inline docs Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix lint Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Refactor getStakingOperations Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix undelegate value Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Nit - fix formatting for network.go Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [node] Move genesis allocation to core & remove unused ContractDeployerKey Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix precision error & add cx receipt hash on blk fetch * Add unit tests for supporting helper functions Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix fmt Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix cx receipt hashes for blocks * Print stack trace on panic recovery Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [node] Nit - fix comment for StopRosetta Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [node] Expose GetMaxPeerHeight Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add SyncStatus enum Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Nit - remove redundant 'service' name in services namespace Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
4 years ago
[Rosetta] Make all side effects one transaction (#3458) * [rosetta] Start refactor of side effect transactions * Rename special transactions to side effect transactions * Rename various variables for consistancy within context of side effect transasctions * Remove all individual transaction for side effects, instead start process of batching all side effects under one transaction. * Finish batching of genesis side effect transaction. Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add `getSideEffectTransaction` & refactor consumers This will hook in the logic to report all side effects under 1 transactions. Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Remove genesis logic path for special effect txs It is not integrated with the normal special effect logic Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Rename helper fns to use 'side effect' Replacing special case Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix special case operation index Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Consolidate side effect operation logic * Update tests for new side effect logic Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix import Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Update inline doc Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix comment for /block logic Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
4 years ago
// GenesisFundsOperation is a side effect operation for genesis block only.
Rosetta Implementation Cleanup (Stage 3 of Node API Overhaul) (#3390) * [core] Add FindLogsWithTopic & unit test Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [hmy] Add GetDetailedBlockSignerInfo Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [hmy] Add IsCommitteeSelectionBlock Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [test] Add test transaction creation helpers Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Refactor account.go & add tests * Move TestNewAccountIdentifier & TestGetAddress to account_test.go Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Move Operation & Tx formatting to own files * Move Respective unit tests to own files * Expose GetOperations & GetStakingOperations * Expose FormatTransaction, FormatCrossShardReceiverTransaction, FormatGenesisTransaction, FormatPreStakingRewardTransaction & FormatUndelegationPayoutTransaction Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Move TransactionMetadata to transaction_construction.go Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Update construction to use new helpers & formatters * Make docs consistent for mempool.go Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Move all special tx & blk handling to own file Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Remove all moved fns, methods & tests from block.go Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * Fix lint & imports Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Rename all tx related files for clarity Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Rename DefaultSenderAddress to FormatDefaultSenderAddress Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Rename Currency to NativeCurrency * This is in anticipation of HRC20 token support with rosetta * Rename various native operation functions accordingly * Add documentation to explain what a native token is Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix pre-staking block reward calculation * Move getPreStakingRewardTransactionIdentifiers to block_special.go * Add epoch to block metadata * Update unit tests Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * Add IsLastBlockInEpoch method to Block & Header * Refactor all uses of length check `ShardState` * [hmy] Refactor IsCommitteeSelectionBlock to use chain.IsCommitteeSelectionBlock * Address PR comments Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Update var names in preStakingRewardBlockTransaction Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
4 years ago
// Note that no transaction can be constructed with this operation.
Rosetta Implementation - pt2 FIX (Stage 3.2 of Node API Overhaul) (#3321) * [rosetta] Fix decimal precision on staking transactions Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add GenesisFundsOperation & PreStakingEraBlockRewardsOperation Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add special case transaction ID & refactor to use Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [hmy] Fix block signer mask creation Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [staking] Update docs for block reward Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Rename PreStakingEraBlockRewardOperation Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add pre-staking block reward txs & refactor special cases * Add getBlockSigner info * Rename vars named block to blk for pkg imports * Add unit tests for block reward formatting Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix lint Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add new line to rosetta start msg Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [go.mod] Correct go mod Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Make pre-staking block rewards calc same as AccumulateRewardsAndCountSigs * Change committee to signers for blockSignerInfo Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add sanity check for pre-staking block reward amount * Correct network chain for sync status Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Improve unpackSpecialCaseTransactionIdentifier unit test Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
4 years ago
GenesisFundsOperation = "Genesis"
[Rosetta] Make all side effects one transaction (#3458) * [rosetta] Start refactor of side effect transactions * Rename special transactions to side effect transactions * Rename various variables for consistancy within context of side effect transasctions * Remove all individual transaction for side effects, instead start process of batching all side effects under one transaction. * Finish batching of genesis side effect transaction. Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add `getSideEffectTransaction` & refactor consumers This will hook in the logic to report all side effects under 1 transactions. Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Remove genesis logic path for special effect txs It is not integrated with the normal special effect logic Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Rename helper fns to use 'side effect' Replacing special case Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix special case operation index Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Consolidate side effect operation logic * Update tests for new side effect logic Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix import Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Update inline doc Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix comment for /block logic Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
4 years ago
// PreStakingBlockRewardOperation is a side effect operation for pre-staking era only.
Rosetta Implementation Cleanup (Stage 3 of Node API Overhaul) (#3390) * [core] Add FindLogsWithTopic & unit test Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [hmy] Add GetDetailedBlockSignerInfo Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [hmy] Add IsCommitteeSelectionBlock Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [test] Add test transaction creation helpers Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Refactor account.go & add tests * Move TestNewAccountIdentifier & TestGetAddress to account_test.go Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Move Operation & Tx formatting to own files * Move Respective unit tests to own files * Expose GetOperations & GetStakingOperations * Expose FormatTransaction, FormatCrossShardReceiverTransaction, FormatGenesisTransaction, FormatPreStakingRewardTransaction & FormatUndelegationPayoutTransaction Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Move TransactionMetadata to transaction_construction.go Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Update construction to use new helpers & formatters * Make docs consistent for mempool.go Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Move all special tx & blk handling to own file Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Remove all moved fns, methods & tests from block.go Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * Fix lint & imports Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Rename all tx related files for clarity Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Rename DefaultSenderAddress to FormatDefaultSenderAddress Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Rename Currency to NativeCurrency * This is in anticipation of HRC20 token support with rosetta * Rename various native operation functions accordingly * Add documentation to explain what a native token is Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix pre-staking block reward calculation * Move getPreStakingRewardTransactionIdentifiers to block_special.go * Add epoch to block metadata * Update unit tests Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * Add IsLastBlockInEpoch method to Block & Header * Refactor all uses of length check `ShardState` * [hmy] Refactor IsCommitteeSelectionBlock to use chain.IsCommitteeSelectionBlock * Address PR comments Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Update var names in preStakingRewardBlockTransaction Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
4 years ago
// Note that no transaction can be constructed with this operation.
Rosetta Implementation - pt4 (Stage 3.4 of Node API Overhaul) (#3380) * [rosetta] Add /construct function framework Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add network ID check to all construct endpoints Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add UnsupportedCurveTypeError Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Implement ConstructionDerive & add ConstructAPI router Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Make recover middleware the outermost middleware Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Correct error for block not found Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rpc] Expose EstimateGas Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add InvalidTransactionConstructionError * Add GetValidConstructionOperations Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Make TransactionMetadata optional ptr * Add UnmarshalFromInterface for TransactionMetadata Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add InvalidTransactionConstructionError to network response Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add ConstructionPreprocess & ConstructionMetadata skeleton * Add Helper methods for said functions Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add GasPrice to ConstructMetadata Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Make suggested gas fee & price its own fn Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Nit - fix comment Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add To & From Account ID in tx metadata * remove getAmountFromUndelegateMessage * make contract address a valid account identifier * remove needless metadata in non-staking operations Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add error report for b32 error in newAccountIdentifier Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Simplify assertValidNetworkIdentifier Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Use sdk MapMarshall instead of rpc structured response * remove unused GetValidConstructionOperations * Add CurrencyHash Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Implement assertValidTransferOperationsAndGetTxAccounts * refactor usages of rpc structured response for sdk map marshall * add account identifier checks for transaction metadata Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Max related operation check more general for tx op check * refactor names for readability Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add & Expose OperationComponents * Remove txAccounts & add OperationComponents to metadata for quicker processing * Remove From & To acc ID from TransactionMetadata as it's in OperationComponents * Update tests for changes Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add tx type to OperationComponents Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add logs to TransactionMetadata * Enforce Operation type uniqueness invariant for each transaction Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add error for 3+ operations in getOperationComponents Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Expose GetOperationComponents Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add CrossShardTransactionOperationMetadata Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add staking operation medata type declaration Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Fix error messages & update comment Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Implement getCrossShardOperationComponents * rename txAccs to components for clarity Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Implement getContractCreationOperationComponents * Fix some edge case optional checks for operation validation Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [go.mod] Bump rosetta version to 0.4.4 & dependent libs * Update broken rosetta structs Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add ChainID to ConstructMetadata Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Rename PreStakingBlockRewardOperation Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Init operation_components.go & move respective code Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Refactor formatTransaction for clarity Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Move maxNumOfConstructionOps to operation_components.go * Clarify unsupported type err msg Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Implement framework for ConstructionPayloads * Remove currying OperationComponents in metadata as PublicKeys is now part of the request in the necessary endpoints * Add respective checks for added PublicKeys * Make getAddressFromPublicKey more general & update tests Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add getAddress and update respective functions Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Create transaction_construction.go & impl ConstructTransaction Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add unmarshal check for ConstructMetadata & ConstructMetadataOptions * Remove constructTransaction * Wrap unsigned transaction with UnsignedTransaction to include intended signer * Add framework for ConstructionParse Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add getSigningPayload method to construction Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [internal/commonm] Add MustGeneratePrivateKey Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Implement parseUnsignedTransaction * Add unpackWrappedTransactionFromHexString & refactor rlp encoding of transactions * Make getSigningPayload return a list Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add TestUnpackWrappedTransactionFromHexString Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Implement parseSignedTransaction * Move unpackWrappedTransactionFromHexString to ConstructionParse before parsing transactions bases on if it's signed or not Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Nit - fix WrappedTransaction comments Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add extra negative tests for unpackWrappedTransactionFromHexString Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Finish initial Construct implementation * Implement ConstructionCombine * Implement ConstructionHash * Implement ConstructionSubmit * Ensure RLPbytes & From is present in WrappedTransaction when unpackWrappedTransactionFromHexString is called Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Refactor construction into separate files * Move tests into appropriate files Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Implement construction_check_test.go * Update edge case for getSuggestedFeeAndPrice found during testing Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Implement construction_parse_test.go * Clarify names for construction_create_test.go Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Fix ConstructionParse to not use crypto.PubkeyToAddress Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Fix UnmarshalFromInterface for CrossShardTransactionOperationMetadata Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add operation_components_test.go * Implement TestGetContractCreationOperationComponents * Implement TestGetCrossShardOperationComponents Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Finish operation_components_test.go * Implement TestGetTransferOperationComponents * Implement TestGetOperationComponents Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Fix big number checks for getTransferOperationComponents Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Implement transaction_construction_test.go * Implement TestConstructPlainTransaction * Implement TestConstructCrossShardTransaction * Implement TestConstructContractCreationTransaction Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add shard ID checks for constructCrossShardTransaction Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add bad curve test for TestGetAddressFromPublicKey Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add nil error catches for Construction API * Fix nits in messages as seen during pass * Add DefaultGasLimit Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add trace message with version to all err msgs * Add NewError unit test Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add TestGetAddressFromKnownPublicKey Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [hmy] Fix possible nil ptr crash for GetBlockSigners Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Edge case bug fixes * Create empty TransactionMetdata if no metadata is provided in operations. Also update tests to correctly account for the behavior. * In pre-staking era make current block one less than the absolute latest to guarentee calculation of pres-taking eara block rewards. Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix unpackWrappedTransactionFromHexString * Rename function to unpackWrappedTransactionFromString * Update respective tests Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Make parsed transaction statuses empty Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Remove needles list initialization Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add SignatureType & SignedPayloadLength with checks Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Fix genesis network status crash Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Correct error message dumps for transaction_construction.go Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add OperationType to ConstructMetadataOptions Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Fix rosetta service rebase Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rpc] Fix estimate gas fail check Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add formatNegativeValue to ensure there's only 1 zero * Correct regression found in constructCrossShardTransaction Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add contract creation estimate gas hack Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add DefaultSenderAddress for transaction formatter * Update Construction API parser to reflect change Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix imports Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Address PR comments * Add GetCallStackInfo to internal utils * Add EstimateGas TODO in RPC package * Remove DefaultGasLimit to use param gas limit Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add checks to tx formatter for nil to addr * Remove needless block check for genesisBlock Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Remove EstimatedGasUsed from WrappedTransaction Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
4 years ago
PreStakingBlockRewardOperation = "PreStakingBlockReward"
Rosetta Implementation - pt2 FIX2 (Stage 3.2 of Node API Overhaul) (#3338) * [rosetta] Update staking operations to account for re-delegation Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [hmy] Add GetUndelegationChange Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [hmy] Add GetAllUndelegatedDelegators Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [hmy] Fix GetAllUndelegatedDelegators & add GetDelegationLockingPeriodInEpoch Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix block reward TX ID formatting Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [hmy] Remove unused GetUndelegationChange * Fix GetUndelegationPayouts * Add GetDelegationsByValidatorAtBlock * Keep beaconchain usage at a minimum Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [hmy] Remove debug print & update comments for GetUndelegationPayouts Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [core] Add last garbage collected number to blockchain.go Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add oldest block ID in net stat for non-archival nodes Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix network oldest block case when garb col blk unknown Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [core] Rename lastGarbCollectedBlkNum to maxGarbCollectedBlkNum Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [internal/chain] Refactor token lock period getter & expose * Use refactored token lock period getter Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [hmy] Add UndelegationPayouts type Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Improve NewError detail failure message * Add UndelegationPayoutOperation * Rename PreStakingEraBlockRewardOperation to UndelegationPayoutOperation Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Integrate Correct undelegation payout operations * Refactor special case transaction handeling & add helper functions for determanining when payouts should be calculated * Make getBlockSignerInfo a method of BlockAPI * Rename constants for clarity * Add unit tests for formatting Undelegation payout special transaction Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [hmy] Add caching to GetUndelegationPayouts Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [hmy] Nit - fix comment Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add block not found error Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Refactor special case txID to be for general Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix lint Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Nit - fix comment Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [hmy] Nit - Make GetUndelegationPayouts more readable Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
4 years ago
[Rosetta] Make all side effects one transaction (#3458) * [rosetta] Start refactor of side effect transactions * Rename special transactions to side effect transactions * Rename various variables for consistancy within context of side effect transasctions * Remove all individual transaction for side effects, instead start process of batching all side effects under one transaction. * Finish batching of genesis side effect transaction. Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add `getSideEffectTransaction` & refactor consumers This will hook in the logic to report all side effects under 1 transactions. Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Remove genesis logic path for special effect txs It is not integrated with the normal special effect logic Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Rename helper fns to use 'side effect' Replacing special case Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix special case operation index Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Consolidate side effect operation logic * Update tests for new side effect logic Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix import Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Update inline doc Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix comment for /block logic Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
4 years ago
// UndelegationPayoutOperation is a side effect operation for committee election block only.
Rosetta Implementation Cleanup (Stage 3 of Node API Overhaul) (#3390) * [core] Add FindLogsWithTopic & unit test Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [hmy] Add GetDetailedBlockSignerInfo Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [hmy] Add IsCommitteeSelectionBlock Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [test] Add test transaction creation helpers Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Refactor account.go & add tests * Move TestNewAccountIdentifier & TestGetAddress to account_test.go Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Move Operation & Tx formatting to own files * Move Respective unit tests to own files * Expose GetOperations & GetStakingOperations * Expose FormatTransaction, FormatCrossShardReceiverTransaction, FormatGenesisTransaction, FormatPreStakingRewardTransaction & FormatUndelegationPayoutTransaction Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Move TransactionMetadata to transaction_construction.go Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Update construction to use new helpers & formatters * Make docs consistent for mempool.go Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Move all special tx & blk handling to own file Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Remove all moved fns, methods & tests from block.go Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * Fix lint & imports Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Rename all tx related files for clarity Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Rename DefaultSenderAddress to FormatDefaultSenderAddress Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Rename Currency to NativeCurrency * This is in anticipation of HRC20 token support with rosetta * Rename various native operation functions accordingly * Add documentation to explain what a native token is Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix pre-staking block reward calculation * Move getPreStakingRewardTransactionIdentifiers to block_special.go * Add epoch to block metadata * Update unit tests Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * Add IsLastBlockInEpoch method to Block & Header * Refactor all uses of length check `ShardState` * [hmy] Refactor IsCommitteeSelectionBlock to use chain.IsCommitteeSelectionBlock * Address PR comments Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Update var names in preStakingRewardBlockTransaction Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
4 years ago
// Note that no transaction can be constructed with this operation.
Rosetta Implementation - pt2 FIX2 (Stage 3.2 of Node API Overhaul) (#3338) * [rosetta] Update staking operations to account for re-delegation Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [hmy] Add GetUndelegationChange Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [hmy] Add GetAllUndelegatedDelegators Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [hmy] Fix GetAllUndelegatedDelegators & add GetDelegationLockingPeriodInEpoch Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix block reward TX ID formatting Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [hmy] Remove unused GetUndelegationChange * Fix GetUndelegationPayouts * Add GetDelegationsByValidatorAtBlock * Keep beaconchain usage at a minimum Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [hmy] Remove debug print & update comments for GetUndelegationPayouts Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [core] Add last garbage collected number to blockchain.go Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add oldest block ID in net stat for non-archival nodes Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix network oldest block case when garb col blk unknown Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [core] Rename lastGarbCollectedBlkNum to maxGarbCollectedBlkNum Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [internal/chain] Refactor token lock period getter & expose * Use refactored token lock period getter Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [hmy] Add UndelegationPayouts type Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Improve NewError detail failure message * Add UndelegationPayoutOperation * Rename PreStakingEraBlockRewardOperation to UndelegationPayoutOperation Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Integrate Correct undelegation payout operations * Refactor special case transaction handeling & add helper functions for determanining when payouts should be calculated * Make getBlockSignerInfo a method of BlockAPI * Rename constants for clarity * Add unit tests for formatting Undelegation payout special transaction Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [hmy] Add caching to GetUndelegationPayouts Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [hmy] Nit - fix comment Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add block not found error Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Refactor special case txID to be for general Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix lint Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Nit - fix comment Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [hmy] Nit - Make GetUndelegationPayouts more readable Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
4 years ago
UndelegationPayoutOperation = "UndelegationPayout"
Rosetta Implementation - pt2 (Stage 3.2 of Node API Overhaul) (#3312) * [rosetta] Add server stop Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Make network naming consistent Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Correct common package name & add error enum Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Remove needless forward of network info to services * Implement /network/list Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Refactor errors & add operation statuses and types Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Implement NetworkOptions & update NetworkAPIService * Rename *_service.go files to remove the suffix * Update StartServers to use new operation types Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Impl NetworkStatus - Finish init impl of /network endpoint * Fix import structure for rosetta.go Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [test] Make explorer run as archival for localnet Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add unit tests * Force errors to remain the same with unit tests * Force operations to remain the same with unit tests * Ensure network checking works for all cases with unit tests Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add InvalidNetworkError and correct error codes Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add UnmarshalFromInterface for SubNetworkMetadata Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add network checking Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Nit fixes & add unit test for Peer Info * Make names consistent Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add BlockNotFoundError & TransactionNotFoundError Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Implement skeleton for block transactions Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add ReceiptNotFoundError Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add receipt to formatTransaction sig for contract fails Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add currency, ExpendGasOperation, & ContractCreationOperation * Add Error creator Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Init impl of plain transaction formatting Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Update network.go for new error constructor Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Implement stx formatter & refactor BlockTransaction * Updated todo comments & function formatting Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Impl Block & make currency non-ptr for easy copy with custom metadata Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix collect rewards amount on transaction fetch Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix block look-up edge case & add recovery middleware Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add bocks unit tests Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix checkPeerID unit test in network_test.go Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix staking tx amount for tx ops & update inline docs Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix lint Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Refactor getStakingOperations Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix undelegate value Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Nit - fix formatting for network.go Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [node] Move genesis allocation to core & remove unused ContractDeployerKey Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix precision error & add cx receipt hash on blk fetch * Add unit tests for supporting helper functions Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix fmt Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix cx receipt hashes for blocks * Print stack trace on panic recovery Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [node] Nit - fix comment for StopRosetta Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [node] Expose GetMaxPeerHeight Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add SyncStatus enum Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Nit - remove redundant 'service' name in services namespace Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
4 years ago
)
var (
// PlainOperationTypes ..
PlainOperationTypes = []string{
ExpendGasOperation,
NativeTransferOperation,
NativeCrossShardTransferOperation,
Rosetta Implementation - pt2 (Stage 3.2 of Node API Overhaul) (#3312) * [rosetta] Add server stop Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Make network naming consistent Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Correct common package name & add error enum Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Remove needless forward of network info to services * Implement /network/list Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Refactor errors & add operation statuses and types Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Implement NetworkOptions & update NetworkAPIService * Rename *_service.go files to remove the suffix * Update StartServers to use new operation types Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Impl NetworkStatus - Finish init impl of /network endpoint * Fix import structure for rosetta.go Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [test] Make explorer run as archival for localnet Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add unit tests * Force errors to remain the same with unit tests * Force operations to remain the same with unit tests * Ensure network checking works for all cases with unit tests Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add InvalidNetworkError and correct error codes Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add UnmarshalFromInterface for SubNetworkMetadata Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add network checking Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Nit fixes & add unit test for Peer Info * Make names consistent Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add BlockNotFoundError & TransactionNotFoundError Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Implement skeleton for block transactions Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add ReceiptNotFoundError Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add receipt to formatTransaction sig for contract fails Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add currency, ExpendGasOperation, & ContractCreationOperation * Add Error creator Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Init impl of plain transaction formatting Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Update network.go for new error constructor Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Implement stx formatter & refactor BlockTransaction * Updated todo comments & function formatting Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Impl Block & make currency non-ptr for easy copy with custom metadata Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix collect rewards amount on transaction fetch Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix block look-up edge case & add recovery middleware Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add bocks unit tests Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix checkPeerID unit test in network_test.go Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix staking tx amount for tx ops & update inline docs Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix lint Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Refactor getStakingOperations Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix undelegate value Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Nit - fix formatting for network.go Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [node] Move genesis allocation to core & remove unused ContractDeployerKey Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix precision error & add cx receipt hash on blk fetch * Add unit tests for supporting helper functions Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix fmt Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix cx receipt hashes for blocks * Print stack trace on panic recovery Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [node] Nit - fix comment for StopRosetta Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [node] Expose GetMaxPeerHeight Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add SyncStatus enum Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Nit - remove redundant 'service' name in services namespace Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
4 years ago
ContractCreationOperation,
Rosetta Implementation - pt2 FIX (Stage 3.2 of Node API Overhaul) (#3321) * [rosetta] Fix decimal precision on staking transactions Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add GenesisFundsOperation & PreStakingEraBlockRewardsOperation Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add special case transaction ID & refactor to use Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [hmy] Fix block signer mask creation Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [staking] Update docs for block reward Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Rename PreStakingEraBlockRewardOperation Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add pre-staking block reward txs & refactor special cases * Add getBlockSigner info * Rename vars named block to blk for pkg imports * Add unit tests for block reward formatting Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix lint Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add new line to rosetta start msg Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [go.mod] Correct go mod Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Make pre-staking block rewards calc same as AccumulateRewardsAndCountSigs * Change committee to signers for blockSignerInfo Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add sanity check for pre-staking block reward amount * Correct network chain for sync status Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Improve unpackSpecialCaseTransactionIdentifier unit test Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
4 years ago
GenesisFundsOperation,
Rosetta Implementation - pt2 FIX2 (Stage 3.2 of Node API Overhaul) (#3338) * [rosetta] Update staking operations to account for re-delegation Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [hmy] Add GetUndelegationChange Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [hmy] Add GetAllUndelegatedDelegators Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [hmy] Fix GetAllUndelegatedDelegators & add GetDelegationLockingPeriodInEpoch Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix block reward TX ID formatting Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [hmy] Remove unused GetUndelegationChange * Fix GetUndelegationPayouts * Add GetDelegationsByValidatorAtBlock * Keep beaconchain usage at a minimum Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [hmy] Remove debug print & update comments for GetUndelegationPayouts Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [core] Add last garbage collected number to blockchain.go Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add oldest block ID in net stat for non-archival nodes Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix network oldest block case when garb col blk unknown Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [core] Rename lastGarbCollectedBlkNum to maxGarbCollectedBlkNum Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [internal/chain] Refactor token lock period getter & expose * Use refactored token lock period getter Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [hmy] Add UndelegationPayouts type Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Improve NewError detail failure message * Add UndelegationPayoutOperation * Rename PreStakingEraBlockRewardOperation to UndelegationPayoutOperation Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Integrate Correct undelegation payout operations * Refactor special case transaction handeling & add helper functions for determanining when payouts should be calculated * Make getBlockSignerInfo a method of BlockAPI * Rename constants for clarity * Add unit tests for formatting Undelegation payout special transaction Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [hmy] Add caching to GetUndelegationPayouts Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [hmy] Nit - fix comment Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add block not found error Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Refactor special case txID to be for general Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix lint Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Nit - fix comment Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [hmy] Nit - Make GetUndelegationPayouts more readable Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
4 years ago
PreStakingBlockRewardOperation,
UndelegationPayoutOperation,
Rosetta Implementation - pt2 (Stage 3.2 of Node API Overhaul) (#3312) * [rosetta] Add server stop Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Make network naming consistent Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Correct common package name & add error enum Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Remove needless forward of network info to services * Implement /network/list Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Refactor errors & add operation statuses and types Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Implement NetworkOptions & update NetworkAPIService * Rename *_service.go files to remove the suffix * Update StartServers to use new operation types Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Impl NetworkStatus - Finish init impl of /network endpoint * Fix import structure for rosetta.go Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [test] Make explorer run as archival for localnet Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add unit tests * Force errors to remain the same with unit tests * Force operations to remain the same with unit tests * Ensure network checking works for all cases with unit tests Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add InvalidNetworkError and correct error codes Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add UnmarshalFromInterface for SubNetworkMetadata Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add network checking Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Nit fixes & add unit test for Peer Info * Make names consistent Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add BlockNotFoundError & TransactionNotFoundError Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Implement skeleton for block transactions Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add ReceiptNotFoundError Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add receipt to formatTransaction sig for contract fails Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add currency, ExpendGasOperation, & ContractCreationOperation * Add Error creator Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Init impl of plain transaction formatting Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Update network.go for new error constructor Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Implement stx formatter & refactor BlockTransaction * Updated todo comments & function formatting Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Impl Block & make currency non-ptr for easy copy with custom metadata Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix collect rewards amount on transaction fetch Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix block look-up edge case & add recovery middleware Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add bocks unit tests Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix checkPeerID unit test in network_test.go Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix staking tx amount for tx ops & update inline docs Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix lint Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Refactor getStakingOperations Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix undelegate value Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Nit - fix formatting for network.go Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [node] Move genesis allocation to core & remove unused ContractDeployerKey Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix precision error & add cx receipt hash on blk fetch * Add unit tests for supporting helper functions Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix fmt Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix cx receipt hashes for blocks * Print stack trace on panic recovery Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [node] Nit - fix comment for StopRosetta Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [node] Expose GetMaxPeerHeight Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add SyncStatus enum Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Nit - remove redundant 'service' name in services namespace Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
4 years ago
}
// StakingOperationTypes ..
StakingOperationTypes = []string{
staking.DirectiveCreateValidator.String(),
staking.DirectiveEditValidator.String(),
staking.DirectiveDelegate.String(),
staking.DirectiveUndelegate.String(),
staking.DirectiveCollectRewards.String(),
}
[Rosetta] Track internal transactions (#3475) * [rosetta] Refactor operations & prep for internal tx exposure * Remove gas op relation for tx operations. Gas is for submission & processing the tx, thus not really related to the amount being transferred * Make optional starting op a ptr to a uint to keep consistent * Reorg file for consistency of fn placement * Rename functions for clarity * Make getContractCreationNativeOperations consume getBasicTransferOperations for consistency * Remove invariant doc as it does not apply anymore Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add framework for parsing traced txs * Define ContractInfo struct for FormatTransaction * Add tx trace helper function defs & propagate type defs * Add a GetTransactionStatus helper fn for Operation formatting/creation * Add wrapper function, getContractTransferNativeOperations, to get internal operations Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Implement transaction tracer Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [tracer] Add CallerAddress & CodeAddress to tracer logs Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [tracer] Remove ptr to slice & map in StructLogRes Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Implement getContractInternalTransferNativeOperations * Add ContractAddress to ContractInfo for future usages (i.e: erc20 parsing) * Only check for contract address if there is tx data in BlockTransaction Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix status report for contract related txs Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [tracer] Expose contract address instead of code address Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add trace cache & update TODO * Trace any PLAIN transaction instead of only transactions with data. This is to account for fall back contract fn calls & ignore staking data. Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Make internal tx formatter not return err on nil exec result Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * Fix lint Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix tests Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add internal tx unit tests * Fix tx data len check for contract related transfers as a transaction with len 0 data can happen for a contract (and fail) due to fall back operations. Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Update invariant comment Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Expose mutually exclusive ops + update docs & tests Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix docs and err msgs Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
4 years ago
// MutuallyExclusiveOperations for invariant: A transaction can only contain 1 type of 'native' operation.
MutuallyExclusiveOperations = map[string]interface{}{
NativeTransferOperation: struct{}{},
NativeCrossShardTransferOperation: struct{}{},
}
Rosetta Implementation - pt2 (Stage 3.2 of Node API Overhaul) (#3312) * [rosetta] Add server stop Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Make network naming consistent Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Correct common package name & add error enum Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Remove needless forward of network info to services * Implement /network/list Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Refactor errors & add operation statuses and types Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Implement NetworkOptions & update NetworkAPIService * Rename *_service.go files to remove the suffix * Update StartServers to use new operation types Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Impl NetworkStatus - Finish init impl of /network endpoint * Fix import structure for rosetta.go Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [test] Make explorer run as archival for localnet Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add unit tests * Force errors to remain the same with unit tests * Force operations to remain the same with unit tests * Ensure network checking works for all cases with unit tests Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add InvalidNetworkError and correct error codes Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add UnmarshalFromInterface for SubNetworkMetadata Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add network checking Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Nit fixes & add unit test for Peer Info * Make names consistent Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add BlockNotFoundError & TransactionNotFoundError Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Implement skeleton for block transactions Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add ReceiptNotFoundError Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add receipt to formatTransaction sig for contract fails Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add currency, ExpendGasOperation, & ContractCreationOperation * Add Error creator Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Init impl of plain transaction formatting Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Update network.go for new error constructor Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Implement stx formatter & refactor BlockTransaction * Updated todo comments & function formatting Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Impl Block & make currency non-ptr for easy copy with custom metadata Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix collect rewards amount on transaction fetch Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix block look-up edge case & add recovery middleware Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add bocks unit tests Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix checkPeerID unit test in network_test.go Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix staking tx amount for tx ops & update inline docs Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix lint Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Refactor getStakingOperations Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix undelegate value Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Nit - fix formatting for network.go Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [node] Move genesis allocation to core & remove unused ContractDeployerKey Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix precision error & add cx receipt hash on blk fetch * Add unit tests for supporting helper functions Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix fmt Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix cx receipt hashes for blocks * Print stack trace on panic recovery Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [node] Nit - fix comment for StopRosetta Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [node] Expose GetMaxPeerHeight Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add SyncStatus enum Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Nit - remove redundant 'service' name in services namespace Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
4 years ago
)
var (
// SuccessOperationStatus for tx operations who's amount affects the account
SuccessOperationStatus = &types.OperationStatus{
Status: "success",
Successful: true,
}
// ContractFailureOperationStatus for tx operations who's amount does not affect the account
// due to a contract call failure (but still incurs gas).
ContractFailureOperationStatus = &types.OperationStatus{
Status: "contract_failure",
Successful: false,
}
// FailureOperationStatus ..
FailureOperationStatus = &types.OperationStatus{
Status: "failure",
Successful: false,
}
)
Rosetta Implementation - pt4 (Stage 3.4 of Node API Overhaul) (#3380) * [rosetta] Add /construct function framework Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add network ID check to all construct endpoints Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add UnsupportedCurveTypeError Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Implement ConstructionDerive & add ConstructAPI router Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Make recover middleware the outermost middleware Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Correct error for block not found Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rpc] Expose EstimateGas Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add InvalidTransactionConstructionError * Add GetValidConstructionOperations Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Make TransactionMetadata optional ptr * Add UnmarshalFromInterface for TransactionMetadata Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add InvalidTransactionConstructionError to network response Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add ConstructionPreprocess & ConstructionMetadata skeleton * Add Helper methods for said functions Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add GasPrice to ConstructMetadata Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Make suggested gas fee & price its own fn Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Nit - fix comment Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add To & From Account ID in tx metadata * remove getAmountFromUndelegateMessage * make contract address a valid account identifier * remove needless metadata in non-staking operations Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add error report for b32 error in newAccountIdentifier Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Simplify assertValidNetworkIdentifier Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Use sdk MapMarshall instead of rpc structured response * remove unused GetValidConstructionOperations * Add CurrencyHash Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Implement assertValidTransferOperationsAndGetTxAccounts * refactor usages of rpc structured response for sdk map marshall * add account identifier checks for transaction metadata Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Max related operation check more general for tx op check * refactor names for readability Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add & Expose OperationComponents * Remove txAccounts & add OperationComponents to metadata for quicker processing * Remove From & To acc ID from TransactionMetadata as it's in OperationComponents * Update tests for changes Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add tx type to OperationComponents Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add logs to TransactionMetadata * Enforce Operation type uniqueness invariant for each transaction Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add error for 3+ operations in getOperationComponents Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Expose GetOperationComponents Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add CrossShardTransactionOperationMetadata Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add staking operation medata type declaration Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Fix error messages & update comment Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Implement getCrossShardOperationComponents * rename txAccs to components for clarity Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Implement getContractCreationOperationComponents * Fix some edge case optional checks for operation validation Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [go.mod] Bump rosetta version to 0.4.4 & dependent libs * Update broken rosetta structs Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add ChainID to ConstructMetadata Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Rename PreStakingBlockRewardOperation Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Init operation_components.go & move respective code Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Refactor formatTransaction for clarity Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Move maxNumOfConstructionOps to operation_components.go * Clarify unsupported type err msg Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Implement framework for ConstructionPayloads * Remove currying OperationComponents in metadata as PublicKeys is now part of the request in the necessary endpoints * Add respective checks for added PublicKeys * Make getAddressFromPublicKey more general & update tests Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add getAddress and update respective functions Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Create transaction_construction.go & impl ConstructTransaction Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add unmarshal check for ConstructMetadata & ConstructMetadataOptions * Remove constructTransaction * Wrap unsigned transaction with UnsignedTransaction to include intended signer * Add framework for ConstructionParse Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add getSigningPayload method to construction Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [internal/commonm] Add MustGeneratePrivateKey Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Implement parseUnsignedTransaction * Add unpackWrappedTransactionFromHexString & refactor rlp encoding of transactions * Make getSigningPayload return a list Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add TestUnpackWrappedTransactionFromHexString Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Implement parseSignedTransaction * Move unpackWrappedTransactionFromHexString to ConstructionParse before parsing transactions bases on if it's signed or not Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Nit - fix WrappedTransaction comments Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add extra negative tests for unpackWrappedTransactionFromHexString Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Finish initial Construct implementation * Implement ConstructionCombine * Implement ConstructionHash * Implement ConstructionSubmit * Ensure RLPbytes & From is present in WrappedTransaction when unpackWrappedTransactionFromHexString is called Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Refactor construction into separate files * Move tests into appropriate files Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Implement construction_check_test.go * Update edge case for getSuggestedFeeAndPrice found during testing Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Implement construction_parse_test.go * Clarify names for construction_create_test.go Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Fix ConstructionParse to not use crypto.PubkeyToAddress Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Fix UnmarshalFromInterface for CrossShardTransactionOperationMetadata Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add operation_components_test.go * Implement TestGetContractCreationOperationComponents * Implement TestGetCrossShardOperationComponents Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Finish operation_components_test.go * Implement TestGetTransferOperationComponents * Implement TestGetOperationComponents Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Fix big number checks for getTransferOperationComponents Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Implement transaction_construction_test.go * Implement TestConstructPlainTransaction * Implement TestConstructCrossShardTransaction * Implement TestConstructContractCreationTransaction Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add shard ID checks for constructCrossShardTransaction Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add bad curve test for TestGetAddressFromPublicKey Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add nil error catches for Construction API * Fix nits in messages as seen during pass * Add DefaultGasLimit Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add trace message with version to all err msgs * Add NewError unit test Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add TestGetAddressFromKnownPublicKey Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [hmy] Fix possible nil ptr crash for GetBlockSigners Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Edge case bug fixes * Create empty TransactionMetdata if no metadata is provided in operations. Also update tests to correctly account for the behavior. * In pre-staking era make current block one less than the absolute latest to guarentee calculation of pres-taking eara block rewards. Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix unpackWrappedTransactionFromHexString * Rename function to unpackWrappedTransactionFromString * Update respective tests Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Make parsed transaction statuses empty Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Remove needles list initialization Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add SignatureType & SignedPayloadLength with checks Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Fix genesis network status crash Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Correct error message dumps for transaction_construction.go Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add OperationType to ConstructMetadataOptions Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Fix rosetta service rebase Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rpc] Fix estimate gas fail check Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add formatNegativeValue to ensure there's only 1 zero * Correct regression found in constructCrossShardTransaction Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> [rosetta] Add contract creation estimate gas hack Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add DefaultSenderAddress for transaction formatter * Update Construction API parser to reflect change Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix imports Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Address PR comments * Add GetCallStackInfo to internal utils * Add EstimateGas TODO in RPC package * Remove DefaultGasLimit to use param gas limit Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add checks to tx formatter for nil to addr * Remove needless block check for genesisBlock Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Remove EstimatedGasUsed from WrappedTransaction Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
4 years ago
// CreateValidatorOperationMetadata ..
type CreateValidatorOperationMetadata rpcV2.CreateValidatorMsg
// EditValidatorOperationMetadata ..
type EditValidatorOperationMetadata rpcV2.EditValidatorMsg
// DelegateOperationMetadata ..
type DelegateOperationMetadata rpcV2.DelegateMsg
// UndelegateOperationMetadata ..
type UndelegateOperationMetadata rpcV2.UndelegateMsg
// CollectRewardsMetadata ..
type CollectRewardsMetadata rpcV2.CollectRewardsMsg
// CrossShardTransactionOperationMetadata ..
type CrossShardTransactionOperationMetadata struct {
From *types.AccountIdentifier `json:"from"`
To *types.AccountIdentifier `json:"to"`
}
// UnmarshalFromInterface ..
func (s *CrossShardTransactionOperationMetadata) UnmarshalFromInterface(data interface{}) error {
var T CrossShardTransactionOperationMetadata
dat, err := json.Marshal(data)
if err != nil {
return err
}
if err := json.Unmarshal(dat, &T); err != nil {
return err
}
if T.To == nil || T.From == nil {
return fmt.Errorf("expected to & from to be present for CrossShardTransactionOperationMetadata")
}
*s = T
return nil
}