1. Refactored service manager with cleaner interface.
2. Add prometheus to the service manager.
3. Graceful shutdown of the services (including consensus).
4. Some code refactor regarding consensus graceful shutdown.
Co-authored-by: Rongjian Lan <rongjian.lan@gmail.com>
[viewchange] encapsulate view ID in the State struct
do NOT ues consensus.current directory to set/get viewID
use the following functions
consensus.SetCurViewID, consensus.SetViewChangingID
consensus.GetCurViewID, consensus.GetViewChangingID
Signed-off-by: Leo Chen <leo@harmony.one>
* [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>
* [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>
* [rpc] Refactor - expose RPC functions in rpc package
Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
* [rpc] Refactor - Undo v1 & v2 code duplication pt1
* Move apiv1 into rpc package as baseline
* Create version enum
* Refactor API creation to use version enum
Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
* [rpc] Refactor - Rejoin GetBlockByNumber & GetBlockByHash
* Both RPC versions are supported in 1 function
* Created types directory for v1 & v2 response types
* Added framework to make rpc layer more clear and legible
Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
* [rpc] Refactor - Undo v1 & v2 code duplication pt2
* Rejoin blockchain.go functions
* Create legacy service
* Improve inline documentation
Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
* [rpc] Refactor - Undo v1 & v2 code duplication pt3
* Use StructuredResponse when returning an exposed type from RPC
* Remove addrlock.go
* Add RPCBlock creation with exposed struct for easy utility from consumers
* Update blockchain.go to reflect changes of RPCBlock
Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
* [rpc] Refactor - Undo v1 & v2 code duplication pt3
* Create types for RPCs that are returned.
* Reorganize types to appropriate v1 & v2 package.
Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
* [rpc] Refactor - Undo v1 & v2 code duplication pt4
* Add context to all RPCs
* Add response switches based on different versions of the API
* Add debug logs for RPC that don't return errors
Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
* [rpc] Refactor - Undo v1 & v2 code duplication pt5
* Add versions switches to all transaction related RPCs
* Integrate response with newly defined structures
* Add debug messages for RPCs that don't return errors
* Add inline documentation for all transaction related RPCs
Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
* [rpc] Refactor - Undo v1 & v2 code duplication pt6
* Remove apiv2
* Move StructuredResponse & TxHistoryArgs to main rpc types.go
Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
* [rpc] Refactor - Undo v1 & v2 code duplication pt7
* Create contract, pool, staking & transaction services
* Move apis into correct services
* Remove util.go (functions are now baked into RPCs in pool.go)
* Remove transaction.go (functions/methods are distributed among created services)
* Update changes for StructuredResponse
Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
* [rpc] Refactor - Add rpc server start/stop to pkg
Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
* [node] Refactor - use new RPC start / stop for servers
Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
* [hmy] Refactor - rename network.go to net.go to match rpc
* Change names for consistency with rpc pkg
Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
* fix go lint & go imports
Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
* [rpc] Refactor - Fix GetTransactionReceipt for staking txs
Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
* [rpc] Refactor - Rename v1 & v2 struct to not have leading 'RPC'
* Update comments
Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
* [rpc] Refactor - make defaultBlocksPeriod be the num blocks per epoch
Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
* Add latest dir removal for make clean
Fix docker image in README
Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
* [hmy] Refactor - Expose Harmony attributes & remove accessors
* Add internals for APIBackend & Harmony fuse
* Add skeleton for refactor of GetTotalStakingSnapshot
Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
* [hmy] Refactor - Re-implement APIBacked methods in Harmony
* Add 'FIXME:done' comments to indicate implemented methods,
some were left out as they are simple accessors and will transition to using
the exposed harmony attributes.
* Split functions into standalone files for clarity.
Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
* [hmy] Refactor - Fix GetTotalStakingSnapshot in Harmony implementation
Previous implementation used rps.LatestBlockNumber, which is a constant -1,
thus, the cache was never used
Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
* [hmy] Refactor - Move ErrFinalizedTransaction to hmy.go
Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
* [hmyapi] Refactor - Make PublicHarmonyAPI use Harmony instead of Backed
Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
* [hmyapi] Refactor - Make NewPublicBlockChainAPI use Harmony instead of Backend
Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
* [hmyapi] Refactor - Make NewPublicTransactionPoolAPI use Harmony instead of Backend
Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
* [hmyapi] Refactor - Make DebugAPI use Harmony instead of Backend
Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
* [hmyapi] Refactor - Make filers use Harmony instead of Backend
* Fix unhandled errors
Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
* [hmy] Refactor - Change NetVersion to ChainID
Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
* [hmyapi] Refactor - Change API service declaration to use Harmony
* Remove irrelevant TODOs
Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
* [node] Refactor - Move harmony create to APIs fetch
Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
* [hmy] Refactor - Remove api_backend.go & Backend
* Update hmyapi net.go to return ChainID as Version
* Remove unused err return on New Harmony obj
Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
* [hmy] Refactor - Prettify var names, structure & comments
Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
* [hmyapi] Refactor - Prettify var names, structure & comments
Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
* [hmyapi] Refactor - Remove backend interface
* Fix lint
Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
* [hmy] Refactor - Remove exposure for eventMux and chainDb
This is to satisfy existing interfaces, mainly the in filters.
Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
* [hmy + hmyapi] Refactor - Fix imports
Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
* [hmy] Refactor - Apply changes from #3243
Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
* [hmyapi] Refactor - Make filters use Backend instead of hmy
This is for testing from eth if we need it in the future
Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
* [hmyapi] Refactor - Fix imports
Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
* Fix minor typos
* Properly sort imports
* [explorer] Add /node-sync to return if the node is in sync
* [explorer] Use different status code for node out of sync & JSON error
* [main] Do not initialize syncing as a separate go routine to ensure stateSync pointer is initialized before explorer service creation (adds 0.002 seconds to node start up time)
[sync] Fix nil pointer on syncConfig, return true since node has not yet checked if it is in sync
* [explorer] Reverse sync for display
* [types] Add TransactionErrorSink to report failed txs
[node] Create ErrorSink handler for unique error msgs
Implemented with a LRU cache.
[node] Rename ErrorSink to TransactionErrorSink
* Rename RPCTransactionError to TransactionError
[node] Make tx error sink not return err on Add & Remove
[node] Make tx errorSink Contains check take string as tx hash param
[errorsink] Move tx error sink into errorsink pkg
[errorsink] Rename Errors and Count methods
[errorsink] Rename NewTransactionErrorSink to NewTransactionSink
[types] Move error sink to core/types
* Rename NewTransactionSink to NewTransactionErrorSink
* [types] Fix log msg for unfound errors
* [types] Rename TransactionError to TransactionErrorReport
* [core] Remove RPCTransactionError & refactor tx_pool to use TxErrorSink
* [staking] Remove RPCTransactionError
* [node] Refactor tx_pool init to use new TxErrorSink
* [main] Construct transaction error sink before initing the node
* [node] Refactor error sink reporting at RPC layer
* [rpc] Refactor returned type of ErrorSink RPCs to 1 type
* [core] Remove tx from TxErrorSink on Add to tx_pool
* [types] Make NewTransactionErrorSink not return err
* [node] Make node.New create error sink
* [cmd] Revert to origin main.go
* [core] Add TxErrorSink unit test & fix bad ErrExcessiveBLSKeys in tests
* [testnet config] Change testnet config to allow for 5*4 external keys
* [cmd] Revert main.go to original node instantiation
* [rpc] Add GetPoolStats rpc to fetch pending and queued tx counts
* [project] Use tracepointer
* [project] Remove dead dependencies
* [rpc] Add unix time at boot as value for node metadata rpc - need direct machine uptime
* [project] Rename specs to specifications b/c gcc thinks specs is a special file
* [rpc][node] Refactor failed stking txn buffer as container/ring, track failed plain txn as well
* [rpc] Expose RPC for staking, plain txn error sink
* [rpc][staking] Quick way to add an staking transaction error sink for rpc consumption
* [staking] Satisfy Travis
* [rpc][staking] Expose staking transaction errors using slice, protect mutex
* [staking][rpc] Use string name of Directive
* [staking][rpc] Change func signature in tests
* [staking][rpc] Protect read with lock
for security reason, node program should only listen to localhost for rpc request by default.
-rpc_ip option is introduced to listen to any port for rpc service
Signed-off-by: Leo Chen <leo@harmony.one>
# This is the 1st commit message:
Fix travis
# This is the commit message #2:
[cleanup] remove is_genesis flag
Signed-off-by: Leo Chen <leo@harmony.one>
# This is the commit message #3:
[nodetype] add nodetype to replace is_explorer
Signed-off-by: Leo Chen <leo@harmony.one>
# This is the commit message #4:
fix beacon sync channel blocking issue
# This is the commit message #5:
use lastMileMux to protect lastMileBlock queue to avoid potential blocking; use sleep instead of ticker
# This is the commit message #6:
Fix the beacon committee check
# This is the commit message #7:
[release] add release action to go_executable_build.sh
Signed-off-by: Leo Chen <leo@harmony.one>
# This is the commit message #8:
[node.sh] add -d option
-d download only
Signed-off-by: Leo Chen <leo@harmony.one>
# This is the commit message #9:
[node.sh] add -T node_type option
-T node_type support node type (validator/explorer)
Signed-off-by: Leo Chen <leo@harmony.one>
# This is the commit message #10:
[node.sh] backward compatible with older harmony binary
Signed-off-by: Leo Chen <leo@harmony.one>
# This is the commit message #11:
[node.sh] support -i shard_id option
-i shard_id specify shard_id, this is applicable only to
explorer node
Signed-off-by: Leo Chen <leo@harmony.one>
# This is the commit message #12:
Revisited api
# This is the commit message #13:
Fix rpc integration
# This is the commit message #14:
address some minor issues in comments and code
# This is the commit message #15:
addressed comments on others' buckets
# This is the commit message #16:
Add Global Access to OS Temp Directory Variable and Move DHT Files Into Temp Directory