* lower gas limit to 30M
* increase suggested gas to 70 percentile and increase max suggested gas to 1000
* Fix race error.
* Increase price limit to 100e9.
* Set 95 percentile.
* Fix rpc response.
* [test] adjust funds for new higher gas price
* [rosetta] use new gas price
Co-authored-by: Rongjian Lan <rongjian.lan@gmail.com>
Co-authored-by: Konstantin <k.potapov@softpro.com>
Co-authored-by: MaxMustermann2 <82761650+MaxMustermann2@users.noreply.github.com>
* Resolve harmony-one/bounties#77: Staking precompiles
Create write capable precompiles that can perform staking transactions
Add hard fork logic (EpochTBD) for these precompiles
Tests for new code with at least 80% unit test coverage
Staking library + tests in MaxMustermann2/harmony-staking-precompiles
* Fix small typo in comment
* Run goimports on files to fix Travis
* Do not activate staking precompile on shard 0
* Cascade readOnly to WriteCapableContract
* No overlap in readOnly + writeCapable precompiles
* Use function selector instead of directive
From Solidity, use abi.encodeWithSelector and match it against the
exact ABI of the functions. This allows us to remove the need for
a directive (32) being encoded, and thus saves 28 bytes of data.
* Do not allow contracts to become validators
As discussed with Jacky on #3906
* Merge harmony-one/harmony/main properly this time
* Run goimports
* Update gas calculation for staking precompile
Please see comment in core/vm/contracts_write.go RequiredGas
* Do not allow contract to become validator (2/2)
* Cache StakeMsgs from precompiled transactions
Add the StakeMsgs to ProcessorResult and cascade them in insertChain
* Remove ContractCode fields from validators
Since smart contracts can no longer beecome validators,
this field is superfluous. Remove it from the Wrapper
structure, and do not assign it a value when creating
a validator. Build and goimports checked
* Update comments in response to feedback
(1) Comments to start with function names
(2) Comments for public variables
(3) Comment to match function name RunPrecompiledContract
(4) Clarify that CreateValidatorFunc + EditValidatorFunc are still used
* Fix Travis build by reverting rosetta change
* Add revert capability to 3 staking tx types
- Delegate
- Undelegate
- CollectRewards
* Fix build: Update evm_test for ValidatorWrapper
* Merge main into harmony-staking-precompiles
* Add gas for precompile calls and allow EOA usage
- Each time the precompile is called, charge the base gas fee plus data
cost (if data can be parsed successfully). A gas fee is added to
prevent benevolent contract deployers from subsidizing the staking
transactions for EOAs through repeated assembly `delegatecall`.
- Allow EOAs to use the staking precompile directly. Some changes to
the Solidity library are associated with this change.
- Remove bytes from parsing address, since the ABI unpacks it into an
address format correctly.
- Add or update tests. Test coverage report to be attached to the PR
shortly.
* Run goimports
* Check read only and write capable for overlap
* Handle precompile stakeMsgs for block proposer
The staking precompile generates staking messages which are cascaded to
the block via the EVM in `state_processor.go`. This change cascades them
in `worker.go` to allow block proposers and block verifiers to keep the
same state.
* Run goimports for cf2dfac4081444e36a120c9432f4e..
* Update staking precompile epoch to 2 for localnet
Bring it in line with staking epoch. Change effects all configurations
except mainnet and testnet. `goimports` included.
* Add read only precompile to fetch the epoch num
* Move epoch precompile to 250
* precompiles: left pad the returned epoch number
* chainConfig: check epochs for precompiles
panic if staking precompile epoch < pre staking epoch
* Add staking migration precompile
- Lives at address 251
- Migrates delegations + pending undelegations from address A to B
- Useful if address A is hacked
- Charges gas of 21k + cost of bytes for two addresses
- Does not remove existing delegations, just sets them to zero.
Replicates current undelegate setup
- Unit tests and `goimports` included. Integration test following
shortly in MaxMustermann2/harmony-staking-precompiles
* Migration precompile: merge into staking
Merge the two precompiles into one, add gas calculation for migration
precompile. Move epoch precompile to 251 as a result. When migrating,
add undelegations to `To`'s existing undelegations, if any match the
epoch.
* Add migration gas test, remove panic, add check
In response to review comments, add tests for migration gas wherein
there are 0/1/2 delegations to migrate. Add the index out of bound check
to migration gas calculator and remove panics. Lastly, re-sort
migrated undelegations if no existing undelegation in the same epoch was
found on `To`.
* Move undelegations sorting to end of loop
* Add ethereum transaction support
* fix fmt
* fix lint
* add new block body fork logic
* add back deleted code
* lower case block version const
* add eth txn into new version of block
* refactor back
* refactor more
* fix test code
* Fix build
* Fix build
* Rollup evm to geth v1.9.9 Muir Glacier
* fix go gen
* update intrinsic gas for istanbul
* Update statedb.Commit
* revert go gen result
* revert protobuf version
* update protobuf
* update go gen files
* set testnet epoch for evm upgrade
* [config] Fix confusing variable name
* [pool] Allow pool to accept Delegate transactions that utilize the locked redelegation amount
* [pool] Bypass balance check for Delegate transactions, let validation be done with validateStakingTx
* [list] Perform validation on staking transactions when filtering for overpriced/invalid transactions
* [list] Rename FilterCost to FilterValid, to reflect changes & update comment
* [pool] Remove now unnecessary staking logic in demotion logic
* [list] Fix imports
* add support for redelegation
* Add test
* Revert "[go.mod] version upgrade of libp2p modules"
This reverts commit ce53468e3e.
* Fix bug that validator self delegation doesn't work
* Restore 7 epoch locking time at redelegation epoch
* Add debug log for chain context
* [tx_list] Add transaction after you can fetch tx cost
* [tx_pool] Add error sink reports for removed tx
* Correct log levels for known transactions
* Remove redundant hash to `enqueue` and `add` signatures
* Update tests for signature changes
* [build] Fix local build for MacOs
* [tx_pool] Correct typo & logging level for known tx
* [tx_pool] Fix for go imports
* [tx_list] Add transaction after you can fetch tx cost
* [tx_pool] Add error sink reports for removed tx
* Correct log levels for known transactions
* Remove redundant hash to `enqueue` and `add` signatures
* Update tests for signature changes
* [build] Fix local build for MacOs
* [tx_pool] Correct typo & logging level for known tx
* [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
* Add cache to state validator access; refactor snapshot read/write
* make validator update happen at commit
* fix lint
* make sure slashing applies on validator wrapper in state
* Revert live update of validtor wrapper in staking txn
* add init population of validator cache logic
* Fix validator cache commit logic
* Separate validatorWrapper func
* fix build
* Fix lint
* [rpc][validator] Extend hmy blockchain validator information
* [availability] Optimize bump count
* [staking][validator][rpc] Remove validator stats rpc, fold into validator information, make existing pattern default behavior
* [slash] Reimplement SetDifference
* [reward][engine][network] Remove bad API from fall, begin setup for Per validator awards
* [header] Custom Marshal header for downstream, remove dev code
* [effective][committee] Factor out EPoS round of computation thereby unification in codebase of EPoS
* [unit-test] Fix semantically wrong validator unit tests, punt on maxBLS key wrt tx-pool test
* [reward] Use excellent singleflight package for caching lookup of subcommittees
* [apr][reward] Begin APR package itself, iterate on iterface signatures
* [reward] Handle possible error from singleflight
* [rpc][validator][reward] Adjust RPC committees, singleflight on votingPower, foldStats into Validator Information
* [apr] Stub out computation of APR
* [effective][committee] Upgrade SlotPurchase with named fields, provide marshal
* [effective] Update Tests
* [blockchain] TODO Remove the validators no longer in committee
* [validator][effective] More expressive string representation of eligibilty, ValidatorRPC explicit say if in committee now
* [rpc] Median-stake more semantic meaningful
* [validator] Iterate on semantic meaning of JSON representation
* [offchain] Make validator stats return explicit error
* [availability] Small typo
* [rpc] Quick visual hack until fix delete out kicked out validators
* [offchain] Delete validator from offchain that lost their slot
* [apr] Forgot to update interface signature
* [apr] Mul instead of Div
* [protocol][validator] Fold block reward accum per vaidator into validator-wrapper, off-chain => on-chain
* [votepower] Refactor votepower Roster, simplify aggregation of network wide rosters
* [votepower][shard] Adjust roster, optimize usage of BLSPublicKey as key, use MarshalText trick
* [shard] Granular errors
* [votepower][validator] Unify votepower data structure with off-chain usage
* [votepower][consensus][validator] Further simplify and unify votepower with off-chain, validator stats
* [votepower] Use RJs naming convention group,overall
* [votepower] Remove Println, do keep enforcing order
* [effective][reward] Expand semantics of eligibility as it was overloaded and confusing, evict old voting power computations
* [apr] Adjust json field name
* [votepower] Only aggregate on external validator
* [votepower] Mistake on aggregation, custom presentation network-wide
* [rpc][validator][availability] Remove parameter, take into account empty snapshot
* [apr] Use snapshots from two, one epochs ago. Still have question on header
* [apr] Use GetHeaderByNumber for the header needed for time stamp
* [chain] Evict > 3 epoch old voting power
* [blockchain] Leave Delete Validator snapshot as TODO
* [validator][rpc][effective] Undo changes to Protocol field, use virtual construct at RPC layer for meaning
* [project] Address PR comments
* [committee][rpc] Move +1 to computation of epos round rather than hack mutation
* [reward] Remove entire unnecessary loop, hook on AddReward. Remove unnecessary new big int
* [votepower][rpc][validator] Stick with numeric.Dec for token involved with computation, expose accumulate block-reward in RPC
* [effective][committee] Track the candidates for the EPoS auction, RPC median-stake benefits
* [node] Add hack way to get real error reason of why cannot load shardchain
* [consensus] Expand log on current issue on nil block
* [apr] Do the actual call to compute for validator's APR
* [committee] Wrap SlotOrder with validator address, manifests in median-stake RPC
* [apr] Incorrect error handle order
* [quorum] Remove incorrect compare on bls Key, (typo), remove redundant error check
* [shard] Add log if stakedSlots is 0
* [apr] More sanity check on div by zero, more lenient on error when dont have historical data yet
* [committee] Remove + 1 on seat count
* [apr] Use int64() directly
* [apr] Log when odd empty nil header
* [apr] Do not crash on empty header, figure out later
* Define constants for tx-data and check size limit in tx-pool
* Check for raw data size limitation at RPC layer
* Check for raw data size limitation at Network layer
* [core] Add tx-pool txn interface & update supporting components
* Add txn interface (`PoolTransaction`) for tx-pool
* Update tx_journal to handle pool's txn interface
* Update tx_list to handle pool's txn interface
* [staking] Satisfy `PoolTransaction` interface & move error sink types
* Implement `Protected`, `ToShardID`, `To`, `Data`, `Value` and `Size`
for `StakingTransaction` to satisfy `PoolTransaction` interface
* Refactor `Price` to `GasPrice` for `StakingTransaction` to
satisfy `PoolTransaction` interface
* Move error sink related components to transaction.go
* Expose `VerifyBLSKey` and `VerifyBLSKeys`
* [core] Generalize tx pool & refactor error sink logic
* Refactor txn logic to use `PoolTransaction` and `PoolTransactions`
* Add `txPoolErrorReporter` to handle reporting to plainTx and stakingTx
error sinks
* Remove old & unpayable txs error reports (to error sink) since errs
are already reported when adding the txs
* Fix known transaction error report when adding txn batches
* Add error sink reporting when failed to enqueue txs
* [node] Fix error sink & update tx pool interaction
* Integrate staking transaction in tx-pool
* Remove staking transaction error sink
* [hmy api] Integrate staking transactions from tx pool
* Remove looking at tx pool for `GetTransactionByHash`
* Add `PendingStakingTransactions` and update `PendingTransactions` to
only return plainTx
* [tests] Update all tests for tx pool txn interface & staking err sink
* Update transactions to `PoolTransaction` interface
* Remove `CommitTransactions` staking txn error sink
* Add basic staking txn tests to tx pool tests
* [node] Make all node broadcast staking tx and plain tx
* [core + staking] Separate staking msg check and put in tx pool
* Move `Validator` specific sanity check into its own method and
call said method in `ValidatorWrapper` sanity check
* Create staking msg verifiers and preprocessors in `staking_verifier.go`
* Remove staking msg verification on all staking msg applications
in `state_transition.go` and call new staking msg verifiers & preprocessors
* Add staking msg verification to tx pool
* Remove `ToShardID` from `PoolTransaction` interface and remove trivial
implementation of `ToShardID` in `StakingTransaction`
* update testnet epochs
* Fix the one-off error fully
* Add const for the bad block num
* Graceful shutdown of node
* Add syscall.SIGTERM for shutdown
* Add transaction base fee for createValidator as 10x of create contract
* Add transaction base fee for createValidator as 100x of create contract
* Add transaction base fee for createValidator as 10x of create contract
* Add transaction base fee for createValidator as 100x of create contract
* Fix lint