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/rosetta.go

139 lines
4.1 KiB

Node API Refactor - pt3 (Stage 3.1 of Node API Overhaul) (#3297) * [rosetta] Add server with example block & network services * Update go.mod for rosetta SDK Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [internal/configs] Add RosettaServer to node config Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Add rosetta port flag Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [node] Add rosetta server start & rename api.go Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Change server start to use nodeconfig of rosetta Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Cleanup debugging prints Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix stdout print & document placeholders Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix lint & make StartSevers more consistent Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Disable rosetta by default Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [test] Make explorer deploy rosetta server Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Use direct http server for start * Make go.mod changes minimal 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 fmt of go.mod Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Use port 9700 instead of 10000 Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Bump config version Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Add v1.0.0 config backwards compatibility test * Included update message if old config is loaded Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [test] Do not broadcast invalid tx on localnet Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Correct for invalid port when loading old config Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Make rosetta variable names consistent Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
4 years ago
package rosetta
import (
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
"errors"
Node API Refactor - pt3 (Stage 3.1 of Node API Overhaul) (#3297) * [rosetta] Add server with example block & network services * Update go.mod for rosetta SDK Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [internal/configs] Add RosettaServer to node config Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Add rosetta port flag Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [node] Add rosetta server start & rename api.go Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Change server start to use nodeconfig of rosetta Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Cleanup debugging prints Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix stdout print & document placeholders Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix lint & make StartSevers more consistent Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Disable rosetta by default Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [test] Make explorer deploy rosetta server Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Use direct http server for start * Make go.mod changes minimal 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 fmt of go.mod Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Use port 9700 instead of 10000 Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Bump config version Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Add v1.0.0 config backwards compatibility test * Included update message if old config is loaded Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [test] Do not broadcast invalid tx on localnet Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Correct for invalid port when loading old config Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Make rosetta variable names consistent Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
4 years ago
"fmt"
"net"
"net/http"
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
"os"
"runtime/debug"
Node API Refactor - pt3 (Stage 3.1 of Node API Overhaul) (#3297) * [rosetta] Add server with example block & network services * Update go.mod for rosetta SDK Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [internal/configs] Add RosettaServer to node config Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Add rosetta port flag Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [node] Add rosetta server start & rename api.go Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Change server start to use nodeconfig of rosetta Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Cleanup debugging prints Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix stdout print & document placeholders Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix lint & make StartSevers more consistent Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Disable rosetta by default Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [test] Make explorer deploy rosetta server Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Use direct http server for start * Make go.mod changes minimal 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 fmt of go.mod Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Use port 9700 instead of 10000 Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Bump config version Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Add v1.0.0 config backwards compatibility test * Included update message if old config is loaded Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [test] Do not broadcast invalid tx on localnet Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Correct for invalid port when loading old config Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Make rosetta variable names consistent Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
4 years ago
"time"
"github.com/coinbase/rosetta-sdk-go/asserter"
"github.com/coinbase/rosetta-sdk-go/server"
"github.com/coinbase/rosetta-sdk-go/types"
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
8 months ago
"github.com/woop-chain/woop/wiki"
nodeconfig "github.com/woop-chain/woop/internal/configs/node"
"github.com/woop-chain/woop/internal/utils"
"github.com/woop-chain/woop/rosetta/common"
"github.com/woop-chain/woop/rosetta/services"
Node API Refactor - pt3 (Stage 3.1 of Node API Overhaul) (#3297) * [rosetta] Add server with example block & network services * Update go.mod for rosetta SDK Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [internal/configs] Add RosettaServer to node config Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Add rosetta port flag Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [node] Add rosetta server start & rename api.go Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Change server start to use nodeconfig of rosetta Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Cleanup debugging prints Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix stdout print & document placeholders Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix lint & make StartSevers more consistent Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Disable rosetta by default Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [test] Make explorer deploy rosetta server Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Use direct http server for start * Make go.mod changes minimal 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 fmt of go.mod Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Use port 9700 instead of 10000 Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Bump config version Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Add v1.0.0 config backwards compatibility test * Included update message if old config is loaded Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [test] Do not broadcast invalid tx on localnet Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Correct for invalid port when loading old config Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Make rosetta variable names consistent Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
4 years ago
)
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 listener net.Listener
Node API Refactor - pt3 (Stage 3.1 of Node API Overhaul) (#3297) * [rosetta] Add server with example block & network services * Update go.mod for rosetta SDK Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [internal/configs] Add RosettaServer to node config Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Add rosetta port flag Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [node] Add rosetta server start & rename api.go Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Change server start to use nodeconfig of rosetta Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Cleanup debugging prints Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix stdout print & document placeholders Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix lint & make StartSevers more consistent Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Disable rosetta by default Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [test] Make explorer deploy rosetta server Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Use direct http server for start * Make go.mod changes minimal 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 fmt of go.mod Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Use port 9700 instead of 10000 Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Bump config version Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Add v1.0.0 config backwards compatibility test * Included update message if old config is loaded Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [test] Do not broadcast invalid tx on localnet Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Correct for invalid port when loading old config Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Make rosetta variable names consistent Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
4 years ago
// StartServers starts the rosetta http server
[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
// TODO (dm): optimize rosetta to use single flight & use extra caching type DB to avoid re-processing data
8 months ago
func StartServers(wiki *wiki.Woop, config nodeconfig.RosettaServerConfig, limiterEnable bool, rateLimit int) error {
Node API Refactor - pt3 (Stage 3.1 of Node API Overhaul) (#3297) * [rosetta] Add server with example block & network services * Update go.mod for rosetta SDK Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [internal/configs] Add RosettaServer to node config Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Add rosetta port flag Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [node] Add rosetta server start & rename api.go Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Change server start to use nodeconfig of rosetta Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Cleanup debugging prints Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix stdout print & document placeholders Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix lint & make StartSevers more consistent Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Disable rosetta by default Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [test] Make explorer deploy rosetta server Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Use direct http server for start * Make go.mod changes minimal 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 fmt of go.mod Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Use port 9700 instead of 10000 Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Bump config version Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Add v1.0.0 config backwards compatibility test * Included update message if old config is loaded Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [test] Do not broadcast invalid tx on localnet Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Correct for invalid port when loading old config Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Make rosetta variable names consistent Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
4 years ago
if !config.HTTPEnabled {
utils.Logger().Info().Msg("Rosetta http server disabled...")
return nil
}
8 months ago
network, err := common.GetNetwork(wiki.ShardID)
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
if err != nil {
return err
}
Node API Refactor - pt3 (Stage 3.1 of Node API Overhaul) (#3297) * [rosetta] Add server with example block & network services * Update go.mod for rosetta SDK Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [internal/configs] Add RosettaServer to node config Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Add rosetta port flag Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [node] Add rosetta server start & rename api.go Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Change server start to use nodeconfig of rosetta Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Cleanup debugging prints Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix stdout print & document placeholders Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix lint & make StartSevers more consistent Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Disable rosetta by default Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [test] Make explorer deploy rosetta server Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Use direct http server for start * Make go.mod changes minimal 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 fmt of go.mod Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Use port 9700 instead of 10000 Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Bump config version Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Add v1.0.0 config backwards compatibility test * Included update message if old config is loaded Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [test] Do not broadcast invalid tx on localnet Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Correct for invalid port when loading old config Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Make rosetta variable names consistent Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
4 years ago
serverAsserter, err := asserter.NewServer(
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
append(common.PlainOperationTypes, common.StakingOperationTypes...),
8 months ago
nodeconfig.GetShardConfig(wiki.ShardID).Role() == nodeconfig.ExplorerNode,
[]*types.NetworkIdentifier{network}, services.CallMethod, false, "",
Node API Refactor - pt3 (Stage 3.1 of Node API Overhaul) (#3297) * [rosetta] Add server with example block & network services * Update go.mod for rosetta SDK Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [internal/configs] Add RosettaServer to node config Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Add rosetta port flag Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [node] Add rosetta server start & rename api.go Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Change server start to use nodeconfig of rosetta Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Cleanup debugging prints Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix stdout print & document placeholders Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix lint & make StartSevers more consistent Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Disable rosetta by default Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [test] Make explorer deploy rosetta server Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Use direct http server for start * Make go.mod changes minimal 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 fmt of go.mod Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Use port 9700 instead of 10000 Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Bump config version Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Add v1.0.0 config backwards compatibility test * Included update message if old config is loaded Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [test] Do not broadcast invalid tx on localnet Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Correct for invalid port when loading old config Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Make rosetta variable names consistent Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
4 years ago
)
if err != nil {
return err
}
8 months ago
router := recoverMiddleware(server.CorsMiddleware(loggerMiddleware(getRouter(serverAsserter, wiki, limiterEnable, rateLimit))))
Node API Refactor - pt3 (Stage 3.1 of Node API Overhaul) (#3297) * [rosetta] Add server with example block & network services * Update go.mod for rosetta SDK Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [internal/configs] Add RosettaServer to node config Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Add rosetta port flag Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [node] Add rosetta server start & rename api.go Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Change server start to use nodeconfig of rosetta Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Cleanup debugging prints Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix stdout print & document placeholders Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix lint & make StartSevers more consistent Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Disable rosetta by default Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [test] Make explorer deploy rosetta server Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Use direct http server for start * Make go.mod changes minimal 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 fmt of go.mod Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Use port 9700 instead of 10000 Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Bump config version Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Add v1.0.0 config backwards compatibility test * Included update message if old config is loaded Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [test] Do not broadcast invalid tx on localnet Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Correct for invalid port when loading old config Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Make rosetta variable names consistent Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
4 years ago
utils.Logger().Info().
Int("port", config.HTTPPort).
Str("ip", config.HTTPIp).
Msg("Starting Rosetta server")
endpoint := fmt.Sprintf("%s:%d", config.HTTPIp, config.HTTPPort)
if listener, err = net.Listen("tcp", endpoint); err != nil {
return err
}
go newHTTPServer(router).Serve(listener)
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
fmt.Printf("Started Rosetta server at: %v\n", endpoint)
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
return nil
}
// StopServers stops the rosetta http server
func StopServers() error {
if listener == nil {
return nil
}
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
if err := listener.Close(); err != nil {
return err
}
Node API Refactor - pt3 (Stage 3.1 of Node API Overhaul) (#3297) * [rosetta] Add server with example block & network services * Update go.mod for rosetta SDK Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [internal/configs] Add RosettaServer to node config Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Add rosetta port flag Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [node] Add rosetta server start & rename api.go Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Change server start to use nodeconfig of rosetta Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Cleanup debugging prints Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix stdout print & document placeholders Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix lint & make StartSevers more consistent Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Disable rosetta by default Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [test] Make explorer deploy rosetta server Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Use direct http server for start * Make go.mod changes minimal 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 fmt of go.mod Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Use port 9700 instead of 10000 Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Bump config version Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Add v1.0.0 config backwards compatibility test * Included update message if old config is loaded Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [test] Do not broadcast invalid tx on localnet Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Correct for invalid port when loading old config Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Make rosetta variable names consistent Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
4 years ago
return nil
}
func newHTTPServer(handler http.Handler) *http.Server {
return &http.Server{
Handler: handler,
ReadTimeout: common.ReadTimeout,
WriteTimeout: common.WriteTimeout,
IdleTimeout: common.IdleTimeout,
}
}
8 months ago
func getRouter(asserter *asserter.Asserter, wiki *wiki.Woop, limiterEnable bool, rateLimit int) http.Handler {
Node API Refactor - pt3 (Stage 3.1 of Node API Overhaul) (#3297) * [rosetta] Add server with example block & network services * Update go.mod for rosetta SDK Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [internal/configs] Add RosettaServer to node config Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Add rosetta port flag Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [node] Add rosetta server start & rename api.go Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Change server start to use nodeconfig of rosetta Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Cleanup debugging prints Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix stdout print & document placeholders Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix lint & make StartSevers more consistent Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Disable rosetta by default Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [test] Make explorer deploy rosetta server Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Use direct http server for start * Make go.mod changes minimal 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 fmt of go.mod Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Use port 9700 instead of 10000 Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Bump config version Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Add v1.0.0 config backwards compatibility test * Included update message if old config is loaded Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [test] Do not broadcast invalid tx on localnet Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Correct for invalid port when loading old config Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Make rosetta variable names consistent Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
4 years ago
return server.NewRouter(
8 months ago
server.NewAccountAPIController(services.NewAccountAPI(wiki), asserter),
server.NewBlockAPIController(services.NewBlockAPI(wiki), asserter),
server.NewMempoolAPIController(services.NewMempoolAPI(wiki), asserter),
server.NewNetworkAPIController(services.NewNetworkAPI(wiki), asserter),
server.NewConstructionAPIController(services.NewConstructionAPI(wiki), asserter),
Mainnet Release Candidate 2023.1.2 (#4376) * remove default timeouts * store the evm call timeout in rosetta object * [cmd] actually apply ToRPCServerConfig * Removed unused method. * Rotate external leaders on non-beacon chains. * Fix nil panic. * Bump github.com/aws/aws-sdk-go from 1.33.0 to 1.34.0 Bumps [github.com/aws/aws-sdk-go](https://github.com/aws/aws-sdk-go) from 1.33.0 to 1.34.0. - [Release notes](https://github.com/aws/aws-sdk-go/releases) - [Changelog](https://github.com/aws/aws-sdk-go/blob/v1.34.0/CHANGELOG.md) - [Commits](https://github.com/aws/aws-sdk-go/compare/v1.33.0...v1.34.0) --- updated-dependencies: - dependency-name: github.com/aws/aws-sdk-go dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com> * Bump github.com/ipld/go-ipld-prime from 0.9.0 to 0.19.0 Bumps [github.com/ipld/go-ipld-prime](https://github.com/ipld/go-ipld-prime) from 0.9.0 to 0.19.0. - [Release notes](https://github.com/ipld/go-ipld-prime/releases) - [Changelog](https://github.com/ipld/go-ipld-prime/blob/master/CHANGELOG.md) - [Commits](https://github.com/ipld/go-ipld-prime/compare/v0.9.0...v0.19.0) --- updated-dependencies: - dependency-name: github.com/ipld/go-ipld-prime dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * Bump golang.org/x/net from 0.3.0 to 0.7.0 Bumps [golang.org/x/net](https://github.com/golang/net) from 0.3.0 to 0.7.0. - [Release notes](https://github.com/golang/net/releases) - [Commits](https://github.com/golang/net/compare/v0.3.0...v0.7.0) --- updated-dependencies: - dependency-name: golang.org/x/net dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * Small fixes. * in progress. * in progress. * in progress. * consensus check is forked * update master * fix leader * check leader for N blocks * fix * fix * Cleanup and fix update pub keys. * Rotate leader. * fix fix fix fix fix * Cleaned. * Cache for `GetLeaderPubKeyFromCoinbase`, removed `NthNextHmyExt`. * activate epoch * comment activation * 295 epoch * Fix failed tests. * Fixed code review. * Fix review "--port flag". * Fix review comments. * Returned locks in rotateLeader. * Rebased onto dev. * Commented golangci. * staged stream sync v1.0 * fix protocol tests * fix spell * remove unused struct * fix rosetta test * add comments and refactor verify sig * add comments, remove extra function * add comment * refactor errors, rename metrics * refactor p2p host creation * fix initsync and host creation * fix short range hash chain * fix beacon node detection for p2p protocol * refactor stream peer cooldown and fix protocol beacon node field * refactor p2p host and routing * fix p2p discovery test issue * add MaxAdvertiseWaitTime to handle advertisements interval and address stream connection issue * terminal print the peer id and proto id * fix boot complete message when node is shut down * add new config option ( ForceReachabilityPublic ) to fix local-net consensus issue * fix self query issue * fix test NewDNSSyncingPeerProvider * [testnet] disable leader rotation * fix discovery issue for legacy sync * add watermark low/high options for p2p connection manager * add test for new conn manager flags * fix dedent * add comment to inform about p2p connection manager options * fix max height issue * add a separate log for get max height error * fix log * feat: triesInMemory flag * fix: panic if TriesInMemory is 1 to 2 * in progress. * consensus check is forked * fix * Cleanup and fix update pub keys. * fix fix fix fix fix * activate epoch * EpochTBD for leader rotation epoch. * 295 epoch * Decider no longer requires public keys as a dependency. (#4289) * Consensus doesn't require anymore `Node` as a circular dependency. * Proper blockchain initialization. * Rwlock consensus. * Removed channels. * Removed view change locks. * Removed timers locks. * Removed fbft locks. * Removed multiSigMutex locks. * Removed leader locks. * Removed additional locks and isViewChange. * Added locks detected by race. * Added locks detected by race. * Locks for start. * Removed additional logs. * Removed additional locks. * Removed additional locks. * Make func private. * Make VerifyBlock private. * Make IsLeader private. * Make ParseFBFTMessage private. * Fix remove locks. * Added additional locks. * Added additional locks. * Added readSignatureBitmapPayload locks. * Added HandleMessageUpdate locks. * Added LastMile locks. * Locks for IsValidatorInCommittee. * Fixed locks. * Fixed tests. * Fixed tests. * Fixed lock. * Rebased over leader rotation. * Fix formatting. * Rebased onto dev. * in progress. * consensus check is forked * update master * fix leader * check leader for N blocks * fix * fix * Cleanup and fix update pub keys. * Rotate leader. * fix fix fix fix fix * Cleaned. * Cache for `GetLeaderPubKeyFromCoinbase`, removed `NthNextHmyExt`. * comment activation * 295 epoch * Fix failed tests. * Fixed code review. * Fix review comments. * Merged leader rotation. * Rebased on dev. * Rebased on dev. * Fix usage of private methods. * Fix usage of private methods. * Fix usage of private methods. * Removed deadcode, LockedFBFTPhase. * Fix review comment. * Fix review comment. * Go mod tidy. * Set to EpochTBD. * Fix tests. * [core] fix state handling of self destruct If a contract self destructs to self and then receives funds within the same transaction, it is possible for its stale state to be saved. This change removes that possibility by checking for deleted state objects before returning them. * Fixed race error. * rpc: add configurable http and `eth_call` timeout * remove default timeouts * store the evm call timeout in rosetta object * [cmd] actually apply ToRPCServerConfig * Removed unused method. * Rotate external leaders on non-beacon chains. * Fix nil panic. * in progress. * in progress. * in progress. * consensus check is forked * update master * fix leader * check leader for N blocks * fix * fix * Cleanup and fix update pub keys. * Rotate leader. * fix fix fix fix fix * Cleaned. * Cache for `GetLeaderPubKeyFromCoinbase`, removed `NthNextHmyExt`. * Fixed code review. * Fix review comments. * Returned locks in rotateLeader. * Rebased onto dev. * staged stream sync v1.0 * refactor errors, rename metrics * fix p2p discovery test issue * add watermark low/high options for p2p connection manager * fix dedent * in progress. * consensus check is forked * fix * Cleanup and fix update pub keys. * fix fix fix fix fix * activate epoch * EpochTBD for leader rotation epoch. * 295 epoch * Decider no longer requires public keys as a dependency. (#4289) * Consensus doesn't require anymore `Node` as a circular dependency. * Proper blockchain initialization. * Rwlock consensus. * Removed channels. * Removed view change locks. * Removed multiSigMutex locks. * Removed leader locks. * Removed additional locks and isViewChange. * Added locks detected by race. * Added locks detected by race. * Locks for start. * Removed additional locks. * Removed additional locks. * Make func private. * Make VerifyBlock private. * Make IsLeader private. * Make ParseFBFTMessage private. * Fix remove locks. * Added additional locks. * Added additional locks. * Added readSignatureBitmapPayload locks. * Added HandleMessageUpdate locks. * Added LastMile locks. * Locks for IsValidatorInCommittee. * Fixed locks. * Fixed tests. * Fixed lock. * Rebased over leader rotation. * in progress. * consensus check is forked * update master * fix leader * check leader for N blocks * fix * fix * Cleanup and fix update pub keys. * Rotate leader. * fix fix fix fix fix * Cleaned. * Cache for `GetLeaderPubKeyFromCoinbase`, removed `NthNextHmyExt`. * Fix failed tests. * Fixed code review. * Fix review comments. * Merged leader rotation. * Rebased on dev. * Rebased on dev. * Fix usage of private methods. * Fix usage of private methods. * Fix usage of private methods. * Removed deadcode, LockedFBFTPhase. * Fix review comment. * Go mod tidy. * remove default timeouts * Rotate external leaders on non-beacon chains. * Fix nil panic. * Fixes. * Update singleton.go * evm: don't return extcode for validators Due to technical debt, validator information is stored in the code field of the address. The code field can be accessed in Solidity for an arbitrary address using `extcodesize`, `extcodehash`, and `extcodecopy` or helper commands (such as `address.code.Length`). The presence of this field is used by contract developers to (erroneously) deny smart contract access to other smart contracts (and therefore, validators). This PR fixes that oversight by returning the same values as other EOAs for known validator addresses. Obviously, it needs a hard fork that will be scheduled separately. * Fix context passing. * Clean up code. * Removed engine dependency. * Fix possible panic. * Clean up code. * Network type. * Fix tests. * Revert "Removed engine dependency." (#4392) * Revert "Fix tests." This reverts commit 597ba2d6f1ed54ff599b9d9b8940c7285ab1277a. * Revert "Network type." This reverts commit 5e1878aedca3989dc0f34161dae1833e43ca6a76. * Revert "Clean up code." This reverts commit 15885f4c9b9263746827172b4f4f56d0926d18e2. * Revert "Fix possible panic." This reverts commit 1a70d5eb66cdbf8a23791806b71a323eed320085. * Revert "Removed engine dependency." This reverts commit 8c2ff803f709f944cfc8b1278f35cf5b2cacf859. * gitignore the cache folder (#4389) * stable localnet with external validator (#4388) * stable localnet with external validator * ignore deploy config file comments * reduce node launched in localnet * update makefile * localnet configuration - add more fn * fix validator information command typo --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: MaxMustermann2 <82761650+MaxMustermann2@users.noreply.github.com> Co-authored-by: frozen <355847+Frozen@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: “GheisMohammadi” <“Gheis.Mohammadi@gmail.com”> Co-authored-by: “GheisMohammadi” <36589218+GheisMohammadi@users.noreply.github.com> Co-authored-by: Sun Hyuk Ahn <sunhyukahn@Suns-MacBook-Pro.local> Co-authored-by: Soph <35721420+sophoah@users.noreply.github.com>
2 years ago
server.NewCallAPIController(
8 months ago
services.NewCallAPIService(wiki, limiterEnable, rateLimit,
wiki.NodeAPI.GetConfig().NodeConfig.RPCServer.EvmCallTimeout),
Mainnet Release Candidate 2023.1.2 (#4376) * remove default timeouts * store the evm call timeout in rosetta object * [cmd] actually apply ToRPCServerConfig * Removed unused method. * Rotate external leaders on non-beacon chains. * Fix nil panic. * Bump github.com/aws/aws-sdk-go from 1.33.0 to 1.34.0 Bumps [github.com/aws/aws-sdk-go](https://github.com/aws/aws-sdk-go) from 1.33.0 to 1.34.0. - [Release notes](https://github.com/aws/aws-sdk-go/releases) - [Changelog](https://github.com/aws/aws-sdk-go/blob/v1.34.0/CHANGELOG.md) - [Commits](https://github.com/aws/aws-sdk-go/compare/v1.33.0...v1.34.0) --- updated-dependencies: - dependency-name: github.com/aws/aws-sdk-go dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com> * Bump github.com/ipld/go-ipld-prime from 0.9.0 to 0.19.0 Bumps [github.com/ipld/go-ipld-prime](https://github.com/ipld/go-ipld-prime) from 0.9.0 to 0.19.0. - [Release notes](https://github.com/ipld/go-ipld-prime/releases) - [Changelog](https://github.com/ipld/go-ipld-prime/blob/master/CHANGELOG.md) - [Commits](https://github.com/ipld/go-ipld-prime/compare/v0.9.0...v0.19.0) --- updated-dependencies: - dependency-name: github.com/ipld/go-ipld-prime dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * Bump golang.org/x/net from 0.3.0 to 0.7.0 Bumps [golang.org/x/net](https://github.com/golang/net) from 0.3.0 to 0.7.0. - [Release notes](https://github.com/golang/net/releases) - [Commits](https://github.com/golang/net/compare/v0.3.0...v0.7.0) --- updated-dependencies: - dependency-name: golang.org/x/net dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * Small fixes. * in progress. * in progress. * in progress. * consensus check is forked * update master * fix leader * check leader for N blocks * fix * fix * Cleanup and fix update pub keys. * Rotate leader. * fix fix fix fix fix * Cleaned. * Cache for `GetLeaderPubKeyFromCoinbase`, removed `NthNextHmyExt`. * activate epoch * comment activation * 295 epoch * Fix failed tests. * Fixed code review. * Fix review "--port flag". * Fix review comments. * Returned locks in rotateLeader. * Rebased onto dev. * Commented golangci. * staged stream sync v1.0 * fix protocol tests * fix spell * remove unused struct * fix rosetta test * add comments and refactor verify sig * add comments, remove extra function * add comment * refactor errors, rename metrics * refactor p2p host creation * fix initsync and host creation * fix short range hash chain * fix beacon node detection for p2p protocol * refactor stream peer cooldown and fix protocol beacon node field * refactor p2p host and routing * fix p2p discovery test issue * add MaxAdvertiseWaitTime to handle advertisements interval and address stream connection issue * terminal print the peer id and proto id * fix boot complete message when node is shut down * add new config option ( ForceReachabilityPublic ) to fix local-net consensus issue * fix self query issue * fix test NewDNSSyncingPeerProvider * [testnet] disable leader rotation * fix discovery issue for legacy sync * add watermark low/high options for p2p connection manager * add test for new conn manager flags * fix dedent * add comment to inform about p2p connection manager options * fix max height issue * add a separate log for get max height error * fix log * feat: triesInMemory flag * fix: panic if TriesInMemory is 1 to 2 * in progress. * consensus check is forked * fix * Cleanup and fix update pub keys. * fix fix fix fix fix * activate epoch * EpochTBD for leader rotation epoch. * 295 epoch * Decider no longer requires public keys as a dependency. (#4289) * Consensus doesn't require anymore `Node` as a circular dependency. * Proper blockchain initialization. * Rwlock consensus. * Removed channels. * Removed view change locks. * Removed timers locks. * Removed fbft locks. * Removed multiSigMutex locks. * Removed leader locks. * Removed additional locks and isViewChange. * Added locks detected by race. * Added locks detected by race. * Locks for start. * Removed additional logs. * Removed additional locks. * Removed additional locks. * Make func private. * Make VerifyBlock private. * Make IsLeader private. * Make ParseFBFTMessage private. * Fix remove locks. * Added additional locks. * Added additional locks. * Added readSignatureBitmapPayload locks. * Added HandleMessageUpdate locks. * Added LastMile locks. * Locks for IsValidatorInCommittee. * Fixed locks. * Fixed tests. * Fixed tests. * Fixed lock. * Rebased over leader rotation. * Fix formatting. * Rebased onto dev. * in progress. * consensus check is forked * update master * fix leader * check leader for N blocks * fix * fix * Cleanup and fix update pub keys. * Rotate leader. * fix fix fix fix fix * Cleaned. * Cache for `GetLeaderPubKeyFromCoinbase`, removed `NthNextHmyExt`. * comment activation * 295 epoch * Fix failed tests. * Fixed code review. * Fix review comments. * Merged leader rotation. * Rebased on dev. * Rebased on dev. * Fix usage of private methods. * Fix usage of private methods. * Fix usage of private methods. * Removed deadcode, LockedFBFTPhase. * Fix review comment. * Fix review comment. * Go mod tidy. * Set to EpochTBD. * Fix tests. * [core] fix state handling of self destruct If a contract self destructs to self and then receives funds within the same transaction, it is possible for its stale state to be saved. This change removes that possibility by checking for deleted state objects before returning them. * Fixed race error. * rpc: add configurable http and `eth_call` timeout * remove default timeouts * store the evm call timeout in rosetta object * [cmd] actually apply ToRPCServerConfig * Removed unused method. * Rotate external leaders on non-beacon chains. * Fix nil panic. * in progress. * in progress. * in progress. * consensus check is forked * update master * fix leader * check leader for N blocks * fix * fix * Cleanup and fix update pub keys. * Rotate leader. * fix fix fix fix fix * Cleaned. * Cache for `GetLeaderPubKeyFromCoinbase`, removed `NthNextHmyExt`. * Fixed code review. * Fix review comments. * Returned locks in rotateLeader. * Rebased onto dev. * staged stream sync v1.0 * refactor errors, rename metrics * fix p2p discovery test issue * add watermark low/high options for p2p connection manager * fix dedent * in progress. * consensus check is forked * fix * Cleanup and fix update pub keys. * fix fix fix fix fix * activate epoch * EpochTBD for leader rotation epoch. * 295 epoch * Decider no longer requires public keys as a dependency. (#4289) * Consensus doesn't require anymore `Node` as a circular dependency. * Proper blockchain initialization. * Rwlock consensus. * Removed channels. * Removed view change locks. * Removed multiSigMutex locks. * Removed leader locks. * Removed additional locks and isViewChange. * Added locks detected by race. * Added locks detected by race. * Locks for start. * Removed additional locks. * Removed additional locks. * Make func private. * Make VerifyBlock private. * Make IsLeader private. * Make ParseFBFTMessage private. * Fix remove locks. * Added additional locks. * Added additional locks. * Added readSignatureBitmapPayload locks. * Added HandleMessageUpdate locks. * Added LastMile locks. * Locks for IsValidatorInCommittee. * Fixed locks. * Fixed tests. * Fixed lock. * Rebased over leader rotation. * in progress. * consensus check is forked * update master * fix leader * check leader for N blocks * fix * fix * Cleanup and fix update pub keys. * Rotate leader. * fix fix fix fix fix * Cleaned. * Cache for `GetLeaderPubKeyFromCoinbase`, removed `NthNextHmyExt`. * Fix failed tests. * Fixed code review. * Fix review comments. * Merged leader rotation. * Rebased on dev. * Rebased on dev. * Fix usage of private methods. * Fix usage of private methods. * Fix usage of private methods. * Removed deadcode, LockedFBFTPhase. * Fix review comment. * Go mod tidy. * remove default timeouts * Rotate external leaders on non-beacon chains. * Fix nil panic. * Fixes. * Update singleton.go * evm: don't return extcode for validators Due to technical debt, validator information is stored in the code field of the address. The code field can be accessed in Solidity for an arbitrary address using `extcodesize`, `extcodehash`, and `extcodecopy` or helper commands (such as `address.code.Length`). The presence of this field is used by contract developers to (erroneously) deny smart contract access to other smart contracts (and therefore, validators). This PR fixes that oversight by returning the same values as other EOAs for known validator addresses. Obviously, it needs a hard fork that will be scheduled separately. * Fix context passing. * Clean up code. * Removed engine dependency. * Fix possible panic. * Clean up code. * Network type. * Fix tests. * Revert "Removed engine dependency." (#4392) * Revert "Fix tests." This reverts commit 597ba2d6f1ed54ff599b9d9b8940c7285ab1277a. * Revert "Network type." This reverts commit 5e1878aedca3989dc0f34161dae1833e43ca6a76. * Revert "Clean up code." This reverts commit 15885f4c9b9263746827172b4f4f56d0926d18e2. * Revert "Fix possible panic." This reverts commit 1a70d5eb66cdbf8a23791806b71a323eed320085. * Revert "Removed engine dependency." This reverts commit 8c2ff803f709f944cfc8b1278f35cf5b2cacf859. * gitignore the cache folder (#4389) * stable localnet with external validator (#4388) * stable localnet with external validator * ignore deploy config file comments * reduce node launched in localnet * update makefile * localnet configuration - add more fn * fix validator information command typo --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: MaxMustermann2 <82761650+MaxMustermann2@users.noreply.github.com> Co-authored-by: frozen <355847+Frozen@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: “GheisMohammadi” <“Gheis.Mohammadi@gmail.com”> Co-authored-by: “GheisMohammadi” <36589218+GheisMohammadi@users.noreply.github.com> Co-authored-by: Sun Hyuk Ahn <sunhyukahn@Suns-MacBook-Pro.local> Co-authored-by: Soph <35721420+sophoah@users.noreply.github.com>
2 years ago
asserter,
),
8 months ago
server.NewEventsAPIController(services.NewEventAPI(wiki), asserter),
server.NewSearchAPIController(services.NewSearchAPI(wiki), asserter),
Node API Refactor - pt3 (Stage 3.1 of Node API Overhaul) (#3297) * [rosetta] Add server with example block & network services * Update go.mod for rosetta SDK Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [internal/configs] Add RosettaServer to node config Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Add rosetta port flag Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [node] Add rosetta server start & rename api.go Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Change server start to use nodeconfig of rosetta Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Cleanup debugging prints Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix stdout print & document placeholders Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix lint & make StartSevers more consistent Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Disable rosetta by default Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [test] Make explorer deploy rosetta server Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Use direct http server for start * Make go.mod changes minimal 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 fmt of go.mod Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Use port 9700 instead of 10000 Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Bump config version Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Add v1.0.0 config backwards compatibility test * Included update message if old config is loaded Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [test] Do not broadcast invalid tx on localnet Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Correct for invalid port when loading old config Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Make rosetta variable names consistent Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
4 years ago
)
}
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
func recoverMiddleware(h http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
var err error
defer func() {
r := recover()
if r != nil {
switch t := r.(type) {
case string:
err = errors.New(t)
case error:
err = t
default:
err = errors.New("unknown error")
}
http.Error(w, err.Error(), http.StatusInternalServerError)
utils.Logger().Error().Err(err).Msg("Rosetta Error")
// Print to stderr for quick check of rosetta activity
debug.PrintStack()
_, _ = fmt.Fprintf(
os.Stderr, "%s PANIC: %s\n", time.Now().Format("2006-01-02 15:04:05"), err.Error(),
)
}
}()
h.ServeHTTP(w, r)
})
}
Node API Refactor - pt3 (Stage 3.1 of Node API Overhaul) (#3297) * [rosetta] Add server with example block & network services * Update go.mod for rosetta SDK Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [internal/configs] Add RosettaServer to node config Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Add rosetta port flag Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [node] Add rosetta server start & rename api.go Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Change server start to use nodeconfig of rosetta Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Cleanup debugging prints Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix stdout print & document placeholders Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Fix lint & make StartSevers more consistent Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Disable rosetta by default Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [test] Make explorer deploy rosetta server Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Use direct http server for start * Make go.mod changes minimal 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 fmt of go.mod Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Use port 9700 instead of 10000 Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Bump config version Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Add v1.0.0 config backwards compatibility test * Included update message if old config is loaded Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [test] Do not broadcast invalid tx on localnet Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Correct for invalid port when loading old config Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [cmd] Make rosetta variable names consistent Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
4 years ago
func loggerMiddleware(router http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
start := time.Now()
router.ServeHTTP(w, r)
msg := fmt.Sprintf(
"Rosetta: %s %s %s",
r.Method,
r.RequestURI,
time.Since(start),
)
utils.Logger().Info().Msg(msg)
// Print to stdout for quick check of rosetta activity
fmt.Printf("%s %s\n", time.Now().Format("2006-01-02 15:04:05"), msg)
})
}