|
|
|
package params
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"math/big"
|
|
|
|
"sync"
|
|
|
|
|
|
|
|
"github.com/ethereum/go-ethereum/common"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Well-known chain IDs.
|
|
|
|
var (
|
|
|
|
MainnetChainID = big.NewInt(1)
|
|
|
|
TestnetChainID = big.NewInt(2)
|
|
|
|
PangaeaChainID = big.NewInt(3)
|
|
|
|
PartnerChainID = big.NewInt(4)
|
|
|
|
StressnetChainID = big.NewInt(5)
|
|
|
|
TestChainID = big.NewInt(99) // not a real network
|
|
|
|
AllProtocolChangesChainID = big.NewInt(100) // not a real network
|
|
|
|
|
|
|
|
// EthMainnetShard0ChainID to be reserved unique chain ID for eth compatible chains.
|
|
|
|
EthMainnetShard0ChainID = big.NewInt(1666600000)
|
|
|
|
EthTestnetShard0ChainID = big.NewInt(1666700000)
|
|
|
|
EthPangaeaShard0ChainID = big.NewInt(1666800000)
|
|
|
|
EthPartnerShard0ChainID = big.NewInt(1666900000)
|
|
|
|
EthStressnetShard0ChainID = big.NewInt(1667000000)
|
|
|
|
EthTestShard0ChainID = big.NewInt(1667100000) // not a real network
|
|
|
|
EthAllProtocolChangesShard0ChainID = big.NewInt(1667200000) // not a real network
|
|
|
|
)
|
|
|
|
|
|
|
|
// EpochTBD is a large, “not anytime soon” epoch. It used as a placeholder
|
|
|
|
// until the exact epoch is decided.
|
|
|
|
var EpochTBD = big.NewInt(10000000)
|
|
|
|
var once sync.Once
|
|
|
|
|
|
|
|
var (
|
|
|
|
// MainnetChainConfig is the chain parameters to run a node on the main network.
|
|
|
|
MainnetChainConfig = &ChainConfig{
|
|
|
|
ChainID: MainnetChainID,
|
|
|
|
EthCompatibleChainID: EthMainnetShard0ChainID,
|
|
|
|
EthCompatibleShard0ChainID: EthMainnetShard0ChainID,
|
|
|
|
EthCompatibleEpoch: big.NewInt(442), // Around Thursday Feb 4th 2020, 10AM PST
|
|
|
|
CrossTxEpoch: big.NewInt(28),
|
|
|
|
CrossLinkEpoch: big.NewInt(186),
|
|
|
|
AggregatedRewardEpoch: big.NewInt(689), // Around Wed Sept 15th 2021 with 3.5s block time
|
|
|
|
StakingEpoch: big.NewInt(186),
|
|
|
|
PreStakingEpoch: big.NewInt(185),
|
|
|
|
QuickUnlockEpoch: big.NewInt(191),
|
|
|
|
FiveSecondsEpoch: big.NewInt(230),
|
|
|
|
TwoSecondsEpoch: big.NewInt(366), // Around Tuesday Dec 8th 2020, 8AM PST
|
|
|
|
SixtyPercentEpoch: big.NewInt(530), // Around Monday Apr 12th 2021, 22:30 UTC
|
|
|
|
RedelegationEpoch: big.NewInt(290),
|
|
|
|
NoEarlyUnlockEpoch: big.NewInt(530), // Around Monday Apr 12th 2021, 22:30 UTC
|
|
|
|
VRFEpoch: big.NewInt(631), // Around Wed July 7th 2021
|
|
|
|
PrevVRFEpoch: big.NewInt(689), // Around Wed Sept 15th 2021 with 3.5s block time
|
|
|
|
MinDelegation100Epoch: big.NewInt(631), // Around Wed July 7th 2021
|
|
|
|
MinCommissionRateEpoch: big.NewInt(631), // Around Wed July 7th 2021
|
|
|
|
MinCommissionPromoPeriod: big.NewInt(100),
|
|
|
|
EPoSBound35Epoch: big.NewInt(631), // Around Wed July 7th 2021
|
|
|
|
EIP155Epoch: big.NewInt(28),
|
|
|
|
S3Epoch: big.NewInt(28),
|
|
|
|
DataCopyFixEpoch: big.NewInt(689), // Around Wed Sept 15th 2021 with 3.5s block time
|
|
|
|
IstanbulEpoch: big.NewInt(314),
|
|
|
|
ReceiptLogEpoch: big.NewInt(101),
|
|
|
|
SHA3Epoch: big.NewInt(725), // Around Mon Oct 11 2021, 19:00 UTC
|
|
|
|
HIP6And8Epoch: big.NewInt(725), // Around Mon Oct 11 2021, 19:00 UTC
|
|
|
|
StakingPrecompileEpoch: big.NewInt(871), // Around Tue Feb 11 2022
|
|
|
|
ChainIdFixEpoch: big.NewInt(1323), // Around Wed 8 Feb 11:30PM UTC
|
|
|
|
SlotsLimitedEpoch: big.NewInt(999), // Around Fri, 27 May 2022 09:41:02 UTC with 2s block time
|
|
|
|
CrossShardXferPrecompileEpoch: big.NewInt(1323), // Around Wed 8 Feb 11:30PM UTC
|
|
|
|
AllowlistEpoch: EpochTBD,
|
|
|
|
LeaderRotationExternalNonBeaconLeaders: EpochTBD,
|
|
|
|
LeaderRotationExternalBeaconLeaders: EpochTBD,
|
Sync dev with main branch ( v2023.2.1 hotfix ) (#4435)
* Release Candidate 2023.2.0 ( dev -> main ) (#4399)
* 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
* Configurable tx pool. (#4240)
* AccountQueue & GlobalQueue.
* Lifetime duration.
* [pool] make flags configurable
* [pool] use 4096 as default `GlobalSlots`
* [rosetta] update default values of tx pool
* [test] update value to default
* PriceLimit and PriceBump.
* Fix tests.
* Fix price limit & bump.
* Updated, fixed migrate version and tests.
* Rebased.
* Fix go toml version.
---------
Co-authored-by: Konstantin <k.potapov@softpro.com>
Co-authored-by: MaxMustermann2 <82761650+MaxMustermann2@users.noreply.github.com>
* Upgrade rawdb and statedb codes to add the latest functionalities of ethdb (#4374)
* added bloom filter
* upgrade rawdb and statedb
* change var name and remove extra comments
* return back fake storage in case if we need it for test later
* add the previous change back
* remove some extra entries from go.mod
* fix WritePreimages to use batch
* mark unused functions which are ported over from eth
---------
Co-authored-by: Casey Gardiner <117784577+ONECasey@users.noreply.github.com>
* update all ethereum rawdb pointers to use harmony rawdb (#4395)
* Fix reduce node dependencies. (#4379)
* Fix.
* Fix.
* Fix pool init.
* Clean up.
* add prefix for contract code (#4397)
* Rotate external validators for non-beacon shards. (#4373)
* Rotate only non beacon shards.
* Rotate all shards, but only hmy validators for beacon.
* Fix type.
* Revert "Fix type."
This reverts commit 0a8b506c763d9f8609abff7395ba32b18e43b149.
* Revert "Rotate all shards, but only hmy validators for beacon."
This reverts commit 70b09e2de81aa2cbffae3ccdfd4e334e7d938759.
* Fixed failed test.
* Revert "Revert "Rotate all shards, but only hmy validators for beacon.""
This reverts commit 66cfaa9817488be60ed5b5cfee1fe833ede237c8.
* Frequency by slots count.
* Fix config.
* First validator produce rest blocks.
* Updated.
* Add lock.
* Add prefix for validator wrapper (#4402)
* add separate prefix for validator wrapper
* update comments
* make read/write backward compatible
* add validator codes to stats
* goimports
* goimports accessor_state
* add snapshot feature to state db (#4406)
* Typed cache & Node cleanup. (#4409)
* Channels usage through methods.
* Fix retry count. Removed proposedBlock.
* keysToAddrs rewritten to lrucache.
* core, internal/configs: HIP28-v2 fee collection (#4410)
* core, internal/configs: HIP28-v2 fee collection
Based on the Snapshot vote that has passed, collect 50% of the fee to a
community maintained account and the remainder to an account used to pay
for infrastructure costs. Note that these accounts need to be decided
and set in the code at this moment, and the feature needs to be
activated by setting the `FeeCollectEpoch` of the `ChainConfig` object.
The implementation for devnet is a bit different than compared to
others because the feature was activated on devnet with 100% collection
to an account. I have handled this case separately in `devnet.go`.
* test: add test for StateTransition.ApplyMessage
The objective of this unit test is to check that the fees of a
transaction are appropriately credited to the fee collectors that are
set. This means, for a transaction of 21,000 gas limit and 100 gwei gas
price, two equal fee collectors get 10,500 * 100 gwei each. In addition,
to be clear that the refund mechanism (in case a transaction with extra
gas comes in) works, the tested transaction has a 50,000 gas limit of
which only 21,000 gas limit is actually consumed.
* sharding/config: clarify local fee collector pk
* sharding/config: set testnet fee collector same as devnet
* test: add test for truncated fee distribution
* sharding/config: set fee collector addresses
* test: hardcode the expected fee collected
* goimports
* params/config: set testnet fee collect epoch
Schedule testnet hard fork epoch to be 1296, which begins around the
time 2023-04-28 07:14:20+00:00
* params/config: schedule devnee fee collection
Signed-off-by: MaxMustermann2 <82761650+MaxMustermann2@users.noreply.github.com>
* Minor: removed time.Sleep from tests. (#4412)
* Provide current time as argument.
* Fix test.
* Fix naming.
* Mainnet Release Candidate 2023.1.2 (#4376) (#4414)
* 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
...
* 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
...
* 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
...
* 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: Casey Gardiner <117784577+ONECasey@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>
* chore: merge `main` into `dev` (#4415)
* 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>
* build: update pinned curl version (#4394)
Per the Alpine Linux package repositories, the version for cURL included
with v3.16 has changed to revision 6
* consensus: replace type assert with test (#4398)
If `consensus.finalityCounter` does not have anything stored (for
example in Syncing mode), the `Load()` returns an interface that cannot
be automatically asserted to an `int64`. This results in the node
crashing. This commit fixes that.
* Turn pprof default on with local saved files (#3894)
* Turn pprof default on with local saved files
* [pprof] change interval from 600s to 3600s
* Revert "Turn pprof default on with local saved files (#3894)" (#4400)
This reverts commit 78d26d7910a58ded3bfe689b3de07ea28d95d7d5.
---------
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Casey Gardiner <117784577+ONECasey@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>
Co-authored-by: Jacky Wang <jackyw.se@gmail.com>
* internal/params: set validator code fix hard forks (#4413)
* internal/params: schedule hard forks
Signed-off-by: MaxMustermann2 <82761650+MaxMustermann2@users.noreply.github.com>
* internal/params: set localnet fee collect epoch 2
Signed-off-by: MaxMustermann2 <82761650+MaxMustermann2@users.noreply.github.com>
---------
Signed-off-by: MaxMustermann2 <82761650+MaxMustermann2@users.noreply.github.com>
* internal/params: schedule HIP28v2 + val code fix (#4416)
Signed-off-by: MaxMustermann2 <82761650+MaxMustermann2@users.noreply.github.com>
* Dev fix conflicts. (#4417)
* 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>
* build: update pinned curl version (#4394)
Per the Alpine Linux package repositories, the version for cURL included
with v3.16 has changed to revision 6
* consensus: replace type assert with test (#4398)
If `consensus.finalityCounter` does not have anything stored (for
example in Syncing mode), the `Load()` returns an interface that cannot
be automatically asserted to an `int64`. This results in the node
crashing. This commit fixes that.
* Turn pprof default on with local saved files (#3894)
* Turn pprof default on with local saved files
* [pprof] change interval from 600s to 3600s
* Revert "Turn pprof default on with local saved files (#3894)" (#4400)
This reverts commit 78d26d7910a58ded3bfe689b3de07ea28d95d7d5.
* go mod tidy.
* Increased wait time.
---------
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Casey Gardiner <117784577+ONECasey@users.noreply.github.com>
Co-authored-by: MaxMustermann2 <82761650+MaxMustermann2@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>
Co-authored-by: Jacky Wang <jackyw.se@gmail.com>
---------
Signed-off-by: MaxMustermann2 <82761650+MaxMustermann2@users.noreply.github.com>
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: frozen <355847+Frozen@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: MaxMustermann2 <82761650+MaxMustermann2@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>
Co-authored-by: Konstantin <k.potapov@softpro.com>
Co-authored-by: Gheis Mohammadi <Gheis.Mohammadi@gmail.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Jacky Wang <jackyw.se@gmail.com>
* internal/params: un-schedule mainnet hard forks (#4420)
* internal/params: un-schedule mainnet hard forks
and add logs to help debug the recent consensus loss
* core/state: update logs
* [hotfix] fix code hash conflicts (#4431)
* fix code hash issue
* goimports
---------
Signed-off-by: MaxMustermann2 <82761650+MaxMustermann2@users.noreply.github.com>
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Casey Gardiner <117784577+ONECasey@users.noreply.github.com>
Co-authored-by: frozen <355847+Frozen@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: MaxMustermann2 <82761650+MaxMustermann2@users.noreply.github.com>
Co-authored-by: Sun Hyuk Ahn <sunhyukahn@Suns-MacBook-Pro.local>
Co-authored-by: Konstantin <k.potapov@softpro.com>
Co-authored-by: Gheis Mohammadi <Gheis.Mohammadi@gmail.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Jacky Wang <jackyw.se@gmail.com>
2 years ago
|
|
|
FeeCollectEpoch: EpochTBD,
|
|
|
|
ValidatorCodeFixEpoch: EpochTBD,
|
|
|
|
}
|
|
|
|
|
|
|
|
// TestnetChainConfig contains the chain parameters to run a node on the harmony test network.
|
|
|
|
TestnetChainConfig = &ChainConfig{
|
|
|
|
ChainID: TestnetChainID,
|
|
|
|
EthCompatibleChainID: EthTestnetShard0ChainID,
|
|
|
|
EthCompatibleShard0ChainID: EthTestnetShard0ChainID,
|
|
|
|
EthCompatibleEpoch: big.NewInt(0),
|
|
|
|
CrossTxEpoch: big.NewInt(0),
|
|
|
|
CrossLinkEpoch: big.NewInt(2),
|
|
|
|
AggregatedRewardEpoch: big.NewInt(2),
|
|
|
|
StakingEpoch: big.NewInt(2),
|
|
|
|
PreStakingEpoch: big.NewInt(1),
|
|
|
|
QuickUnlockEpoch: big.NewInt(0),
|
|
|
|
FiveSecondsEpoch: big.NewInt(0),
|
|
|
|
TwoSecondsEpoch: big.NewInt(2),
|
|
|
|
SixtyPercentEpoch: big.NewInt(2),
|
|
|
|
RedelegationEpoch: big.NewInt(2),
|
|
|
|
NoEarlyUnlockEpoch: big.NewInt(2),
|
|
|
|
VRFEpoch: big.NewInt(2),
|
|
|
|
PrevVRFEpoch: big.NewInt(2),
|
|
|
|
MinDelegation100Epoch: big.NewInt(2),
|
|
|
|
MinCommissionRateEpoch: big.NewInt(2),
|
|
|
|
MinCommissionPromoPeriod: big.NewInt(2),
|
|
|
|
EPoSBound35Epoch: big.NewInt(2),
|
|
|
|
EIP155Epoch: big.NewInt(0),
|
|
|
|
S3Epoch: big.NewInt(0),
|
|
|
|
DataCopyFixEpoch: big.NewInt(0),
|
|
|
|
IstanbulEpoch: big.NewInt(0),
|
|
|
|
ReceiptLogEpoch: big.NewInt(0),
|
|
|
|
SHA3Epoch: big.NewInt(0),
|
|
|
|
HIP6And8Epoch: big.NewInt(2),
|
|
|
|
StakingPrecompileEpoch: big.NewInt(2),
|
|
|
|
SlotsLimitedEpoch: big.NewInt(2),
|
|
|
|
ChainIdFixEpoch: big.NewInt(0),
|
|
|
|
CrossShardXferPrecompileEpoch: big.NewInt(2),
|
|
|
|
AllowlistEpoch: big.NewInt(2),
|
|
|
|
LeaderRotationExternalNonBeaconLeaders: EpochTBD,
|
|
|
|
LeaderRotationExternalBeaconLeaders: EpochTBD,
|
core, internal/configs: HIP28-v2 fee collection (#4410)
* core, internal/configs: HIP28-v2 fee collection
Based on the Snapshot vote that has passed, collect 50% of the fee to a
community maintained account and the remainder to an account used to pay
for infrastructure costs. Note that these accounts need to be decided
and set in the code at this moment, and the feature needs to be
activated by setting the `FeeCollectEpoch` of the `ChainConfig` object.
The implementation for devnet is a bit different than compared to
others because the feature was activated on devnet with 100% collection
to an account. I have handled this case separately in `devnet.go`.
* test: add test for StateTransition.ApplyMessage
The objective of this unit test is to check that the fees of a
transaction are appropriately credited to the fee collectors that are
set. This means, for a transaction of 21,000 gas limit and 100 gwei gas
price, two equal fee collectors get 10,500 * 100 gwei each. In addition,
to be clear that the refund mechanism (in case a transaction with extra
gas comes in) works, the tested transaction has a 50,000 gas limit of
which only 21,000 gas limit is actually consumed.
* sharding/config: clarify local fee collector pk
* sharding/config: set testnet fee collector same as devnet
* test: add test for truncated fee distribution
* sharding/config: set fee collector addresses
* test: hardcode the expected fee collected
* goimports
* params/config: set testnet fee collect epoch
Schedule testnet hard fork epoch to be 1296, which begins around the
time 2023-04-28 07:14:20+00:00
* params/config: schedule devnee fee collection
Signed-off-by: MaxMustermann2 <82761650+MaxMustermann2@users.noreply.github.com>
2 years ago
|
|
|
FeeCollectEpoch: big.NewInt(1296), // 2023-04-28 07:14:20+00:00
|
|
|
|
ValidatorCodeFixEpoch: big.NewInt(1296), // 2023-04-28 07:14:20+00:00
|
|
|
|
}
|
|
|
|
// PangaeaChainConfig contains the chain parameters for the Pangaea network.
|
|
|
|
// All features except for CrossLink are enabled at launch.
|
|
|
|
PangaeaChainConfig = &ChainConfig{
|
|
|
|
ChainID: PangaeaChainID,
|
|
|
|
EthCompatibleChainID: EthPangaeaShard0ChainID,
|
|
|
|
EthCompatibleShard0ChainID: EthPangaeaShard0ChainID,
|
|
|
|
EthCompatibleEpoch: big.NewInt(0),
|
|
|
|
CrossTxEpoch: big.NewInt(0),
|
|
|
|
CrossLinkEpoch: big.NewInt(2),
|
|
|
|
AggregatedRewardEpoch: big.NewInt(3),
|
|
|
|
StakingEpoch: big.NewInt(2),
|
|
|
|
PreStakingEpoch: big.NewInt(1),
|
|
|
|
QuickUnlockEpoch: big.NewInt(0),
|
|
|
|
FiveSecondsEpoch: big.NewInt(0),
|
|
|
|
TwoSecondsEpoch: big.NewInt(0),
|
|
|
|
SixtyPercentEpoch: big.NewInt(0),
|
|
|
|
RedelegationEpoch: big.NewInt(0),
|
|
|
|
NoEarlyUnlockEpoch: big.NewInt(0),
|
|
|
|
VRFEpoch: big.NewInt(0),
|
|
|
|
PrevVRFEpoch: big.NewInt(0),
|
|
|
|
MinDelegation100Epoch: big.NewInt(0),
|
|
|
|
MinCommissionRateEpoch: big.NewInt(0),
|
|
|
|
MinCommissionPromoPeriod: big.NewInt(10),
|
|
|
|
EPoSBound35Epoch: big.NewInt(0),
|
|
|
|
EIP155Epoch: big.NewInt(0),
|
|
|
|
S3Epoch: big.NewInt(0),
|
|
|
|
DataCopyFixEpoch: big.NewInt(0),
|
|
|
|
IstanbulEpoch: big.NewInt(0),
|
|
|
|
ReceiptLogEpoch: big.NewInt(0),
|
|
|
|
SHA3Epoch: big.NewInt(0),
|
|
|
|
HIP6And8Epoch: big.NewInt(0),
|
|
|
|
StakingPrecompileEpoch: big.NewInt(2), // same as staking
|
|
|
|
ChainIdFixEpoch: big.NewInt(0),
|
|
|
|
SlotsLimitedEpoch: EpochTBD, // epoch to enable HIP-16
|
|
|
|
CrossShardXferPrecompileEpoch: big.NewInt(1),
|
|
|
|
AllowlistEpoch: EpochTBD,
|
|
|
|
LeaderRotationExternalNonBeaconLeaders: EpochTBD,
|
|
|
|
LeaderRotationExternalBeaconLeaders: EpochTBD,
|
|
|
|
FeeCollectEpoch: EpochTBD,
|
|
|
|
ValidatorCodeFixEpoch: EpochTBD,
|
|
|
|
}
|
|
|
|
|
|
|
|
// PartnerChainConfig contains the chain parameters for the Partner network.
|
|
|
|
// This is the Devnet config
|
|
|
|
PartnerChainConfig = &ChainConfig{
|
|
|
|
ChainID: PartnerChainID,
|
|
|
|
EthCompatibleChainID: EthPartnerShard0ChainID,
|
|
|
|
EthCompatibleShard0ChainID: EthPartnerShard0ChainID,
|
|
|
|
EthCompatibleEpoch: big.NewInt(0),
|
|
|
|
CrossTxEpoch: big.NewInt(0),
|
|
|
|
CrossLinkEpoch: big.NewInt(2),
|
|
|
|
AggregatedRewardEpoch: big.NewInt(3),
|
|
|
|
StakingEpoch: big.NewInt(2),
|
|
|
|
PreStakingEpoch: big.NewInt(1),
|
|
|
|
QuickUnlockEpoch: big.NewInt(0),
|
|
|
|
FiveSecondsEpoch: big.NewInt(0),
|
|
|
|
TwoSecondsEpoch: big.NewInt(0),
|
|
|
|
SixtyPercentEpoch: big.NewInt(4),
|
|
|
|
RedelegationEpoch: big.NewInt(0),
|
|
|
|
NoEarlyUnlockEpoch: big.NewInt(0),
|
|
|
|
VRFEpoch: big.NewInt(0),
|
|
|
|
PrevVRFEpoch: big.NewInt(0),
|
|
|
|
MinDelegation100Epoch: big.NewInt(0),
|
|
|
|
MinCommissionRateEpoch: big.NewInt(0),
|
|
|
|
MinCommissionPromoPeriod: big.NewInt(10),
|
|
|
|
EPoSBound35Epoch: big.NewInt(0),
|
|
|
|
EIP155Epoch: big.NewInt(0),
|
|
|
|
S3Epoch: big.NewInt(0),
|
|
|
|
DataCopyFixEpoch: big.NewInt(0),
|
|
|
|
IstanbulEpoch: big.NewInt(0),
|
|
|
|
ReceiptLogEpoch: big.NewInt(0),
|
|
|
|
SHA3Epoch: big.NewInt(0),
|
|
|
|
HIP6And8Epoch: big.NewInt(0),
|
|
|
|
StakingPrecompileEpoch: big.NewInt(2),
|
|
|
|
ChainIdFixEpoch: big.NewInt(0),
|
|
|
|
SlotsLimitedEpoch: EpochTBD, // epoch to enable HIP-16
|
|
|
|
CrossShardXferPrecompileEpoch: big.NewInt(1),
|
|
|
|
AllowlistEpoch: EpochTBD,
|
|
|
|
LeaderRotationExternalNonBeaconLeaders: EpochTBD,
|
|
|
|
LeaderRotationExternalBeaconLeaders: EpochTBD,
|
|
|
|
FeeCollectEpoch: big.NewInt(848), // 2023-04-28 04:33:33+00:00
|
core, internal/configs: HIP28-v2 fee collection (#4410)
* core, internal/configs: HIP28-v2 fee collection
Based on the Snapshot vote that has passed, collect 50% of the fee to a
community maintained account and the remainder to an account used to pay
for infrastructure costs. Note that these accounts need to be decided
and set in the code at this moment, and the feature needs to be
activated by setting the `FeeCollectEpoch` of the `ChainConfig` object.
The implementation for devnet is a bit different than compared to
others because the feature was activated on devnet with 100% collection
to an account. I have handled this case separately in `devnet.go`.
* test: add test for StateTransition.ApplyMessage
The objective of this unit test is to check that the fees of a
transaction are appropriately credited to the fee collectors that are
set. This means, for a transaction of 21,000 gas limit and 100 gwei gas
price, two equal fee collectors get 10,500 * 100 gwei each. In addition,
to be clear that the refund mechanism (in case a transaction with extra
gas comes in) works, the tested transaction has a 50,000 gas limit of
which only 21,000 gas limit is actually consumed.
* sharding/config: clarify local fee collector pk
* sharding/config: set testnet fee collector same as devnet
* test: add test for truncated fee distribution
* sharding/config: set fee collector addresses
* test: hardcode the expected fee collected
* goimports
* params/config: set testnet fee collect epoch
Schedule testnet hard fork epoch to be 1296, which begins around the
time 2023-04-28 07:14:20+00:00
* params/config: schedule devnee fee collection
Signed-off-by: MaxMustermann2 <82761650+MaxMustermann2@users.noreply.github.com>
2 years ago
|
|
|
ValidatorCodeFixEpoch: big.NewInt(848),
|
|
|
|
}
|
|
|
|
|
|
|
|
// StressnetChainConfig contains the chain parameters for the Stress test network.
|
|
|
|
// All features except for CrossLink are enabled at launch.
|
|
|
|
StressnetChainConfig = &ChainConfig{
|
|
|
|
ChainID: StressnetChainID,
|
|
|
|
EthCompatibleChainID: EthStressnetShard0ChainID,
|
|
|
|
EthCompatibleShard0ChainID: EthStressnetShard0ChainID,
|
|
|
|
EthCompatibleEpoch: big.NewInt(0),
|
|
|
|
CrossTxEpoch: big.NewInt(0),
|
|
|
|
CrossLinkEpoch: big.NewInt(2),
|
|
|
|
AggregatedRewardEpoch: big.NewInt(3),
|
|
|
|
StakingEpoch: big.NewInt(2),
|
|
|
|
PreStakingEpoch: big.NewInt(1),
|
|
|
|
QuickUnlockEpoch: big.NewInt(0),
|
|
|
|
FiveSecondsEpoch: big.NewInt(0),
|
|
|
|
TwoSecondsEpoch: big.NewInt(0),
|
|
|
|
SixtyPercentEpoch: big.NewInt(10),
|
|
|
|
RedelegationEpoch: big.NewInt(0),
|
|
|
|
NoEarlyUnlockEpoch: big.NewInt(0),
|
|
|
|
VRFEpoch: big.NewInt(0),
|
|
|
|
PrevVRFEpoch: big.NewInt(0),
|
|
|
|
MinDelegation100Epoch: big.NewInt(0),
|
|
|
|
MinCommissionRateEpoch: big.NewInt(0),
|
|
|
|
MinCommissionPromoPeriod: big.NewInt(10),
|
|
|
|
EPoSBound35Epoch: big.NewInt(0),
|
|
|
|
EIP155Epoch: big.NewInt(0),
|
|
|
|
S3Epoch: big.NewInt(0),
|
|
|
|
DataCopyFixEpoch: big.NewInt(0),
|
|
|
|
IstanbulEpoch: big.NewInt(0),
|
|
|
|
ReceiptLogEpoch: big.NewInt(0),
|
|
|
|
SHA3Epoch: big.NewInt(0),
|
|
|
|
HIP6And8Epoch: big.NewInt(0),
|
|
|
|
StakingPrecompileEpoch: big.NewInt(2),
|
|
|
|
ChainIdFixEpoch: big.NewInt(0),
|
|
|
|
SlotsLimitedEpoch: EpochTBD, // epoch to enable HIP-16
|
|
|
|
CrossShardXferPrecompileEpoch: big.NewInt(1),
|
|
|
|
AllowlistEpoch: EpochTBD,
|
|
|
|
FeeCollectEpoch: EpochTBD,
|
|
|
|
LeaderRotationExternalNonBeaconLeaders: EpochTBD,
|
|
|
|
LeaderRotationExternalBeaconLeaders: EpochTBD,
|
|
|
|
ValidatorCodeFixEpoch: EpochTBD,
|
|
|
|
}
|
|
|
|
|
|
|
|
// LocalnetChainConfig contains the chain parameters to run for local development.
|
|
|
|
LocalnetChainConfig = &ChainConfig{
|
|
|
|
ChainID: TestnetChainID,
|
|
|
|
EthCompatibleChainID: EthTestnetShard0ChainID,
|
|
|
|
EthCompatibleShard0ChainID: EthTestnetShard0ChainID,
|
|
|
|
EthCompatibleEpoch: big.NewInt(0),
|
|
|
|
CrossTxEpoch: big.NewInt(0),
|
|
|
|
CrossLinkEpoch: big.NewInt(2),
|
|
|
|
AggregatedRewardEpoch: big.NewInt(3),
|
|
|
|
StakingEpoch: big.NewInt(2),
|
|
|
|
PreStakingEpoch: big.NewInt(0),
|
|
|
|
QuickUnlockEpoch: big.NewInt(0),
|
|
|
|
FiveSecondsEpoch: big.NewInt(0),
|
|
|
|
TwoSecondsEpoch: big.NewInt(0),
|
|
|
|
SixtyPercentEpoch: EpochTBD, // Never enable it for localnet as localnet has no external validator setup
|
|
|
|
RedelegationEpoch: big.NewInt(0),
|
|
|
|
NoEarlyUnlockEpoch: big.NewInt(0),
|
|
|
|
VRFEpoch: big.NewInt(0),
|
|
|
|
PrevVRFEpoch: big.NewInt(0),
|
|
|
|
MinDelegation100Epoch: big.NewInt(0),
|
|
|
|
MinCommissionRateEpoch: big.NewInt(0),
|
|
|
|
MinCommissionPromoPeriod: big.NewInt(10),
|
|
|
|
EPoSBound35Epoch: big.NewInt(0),
|
|
|
|
EIP155Epoch: big.NewInt(0),
|
|
|
|
S3Epoch: big.NewInt(0),
|
|
|
|
DataCopyFixEpoch: big.NewInt(0),
|
|
|
|
IstanbulEpoch: big.NewInt(0),
|
|
|
|
ReceiptLogEpoch: big.NewInt(0),
|
|
|
|
SHA3Epoch: big.NewInt(0),
|
|
|
|
HIP6And8Epoch: EpochTBD, // Never enable it for localnet as localnet has no external validator setup
|
|
|
|
StakingPrecompileEpoch: big.NewInt(2),
|
|
|
|
ChainIdFixEpoch: big.NewInt(0),
|
|
|
|
SlotsLimitedEpoch: EpochTBD, // epoch to enable HIP-16
|
|
|
|
CrossShardXferPrecompileEpoch: big.NewInt(1),
|
|
|
|
AllowlistEpoch: EpochTBD,
|
|
|
|
LeaderRotationExternalNonBeaconLeaders: big.NewInt(5),
|
|
|
|
LeaderRotationExternalBeaconLeaders: big.NewInt(6),
|
core, internal/configs: HIP28-v2 fee collection (#4410)
* core, internal/configs: HIP28-v2 fee collection
Based on the Snapshot vote that has passed, collect 50% of the fee to a
community maintained account and the remainder to an account used to pay
for infrastructure costs. Note that these accounts need to be decided
and set in the code at this moment, and the feature needs to be
activated by setting the `FeeCollectEpoch` of the `ChainConfig` object.
The implementation for devnet is a bit different than compared to
others because the feature was activated on devnet with 100% collection
to an account. I have handled this case separately in `devnet.go`.
* test: add test for StateTransition.ApplyMessage
The objective of this unit test is to check that the fees of a
transaction are appropriately credited to the fee collectors that are
set. This means, for a transaction of 21,000 gas limit and 100 gwei gas
price, two equal fee collectors get 10,500 * 100 gwei each. In addition,
to be clear that the refund mechanism (in case a transaction with extra
gas comes in) works, the tested transaction has a 50,000 gas limit of
which only 21,000 gas limit is actually consumed.
* sharding/config: clarify local fee collector pk
* sharding/config: set testnet fee collector same as devnet
* test: add test for truncated fee distribution
* sharding/config: set fee collector addresses
* test: hardcode the expected fee collected
* goimports
* params/config: set testnet fee collect epoch
Schedule testnet hard fork epoch to be 1296, which begins around the
time 2023-04-28 07:14:20+00:00
* params/config: schedule devnee fee collection
Signed-off-by: MaxMustermann2 <82761650+MaxMustermann2@users.noreply.github.com>
2 years ago
|
|
|
FeeCollectEpoch: big.NewInt(2),
|
|
|
|
ValidatorCodeFixEpoch: big.NewInt(2),
|
|
|
|
}
|
|
|
|
|
|
|
|
// AllProtocolChanges ...
|
|
|
|
// This configuration is intentionally not using keyed fields to force anyone
|
|
|
|
// adding flags to the config to also have to set these fields.
|
|
|
|
AllProtocolChanges = &ChainConfig{
|
|
|
|
AllProtocolChangesChainID, // ChainID
|
|
|
|
EthAllProtocolChangesShard0ChainID, // EthCompatibleChainID
|
|
|
|
EthAllProtocolChangesShard0ChainID, // EthCompatibleShard0ChainID
|
|
|
|
big.NewInt(0), // EthCompatibleEpoch
|
|
|
|
big.NewInt(0), // CrossTxEpoch
|
|
|
|
big.NewInt(0), // CrossLinkEpoch
|
|
|
|
big.NewInt(0), // AggregatedRewardEpoch
|
|
|
|
big.NewInt(0), // StakingEpoch
|
|
|
|
big.NewInt(0), // PreStakingEpoch
|
|
|
|
big.NewInt(0), // QuickUnlockEpoch
|
|
|
|
big.NewInt(0), // FiveSecondsEpoch
|
|
|
|
big.NewInt(0), // TwoSecondsEpoch
|
|
|
|
big.NewInt(0), // SixtyPercentEpoch
|
|
|
|
big.NewInt(0), // RedelegationEpoch
|
|
|
|
big.NewInt(0), // NoEarlyUnlockEpoch
|
|
|
|
big.NewInt(0), // VRFEpoch
|
|
|
|
big.NewInt(0), // PrevVRFEpoch
|
|
|
|
big.NewInt(0), // MinDelegation100Epoch
|
|
|
|
big.NewInt(0), // MinCommissionRateEpoch
|
|
|
|
big.NewInt(10), // MinCommissionPromoPeriod
|
|
|
|
big.NewInt(0), // EPoSBound35Epoch
|
|
|
|
big.NewInt(0), // EIP155Epoch
|
|
|
|
big.NewInt(0), // S3Epoch
|
|
|
|
big.NewInt(0), // DataCopyFixEpoch
|
|
|
|
big.NewInt(0), // IstanbulEpoch
|
|
|
|
big.NewInt(0), // ReceiptLogEpoch
|
|
|
|
big.NewInt(0), // SHA3Epoch
|
|
|
|
big.NewInt(0), // HIP6And8Epoch
|
Resolve harmony-one/bounties#77: Staking precompiles (#3906)
* 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
3 years ago
|
|
|
big.NewInt(0), // StakingPrecompileEpoch
|
|
|
|
big.NewInt(0), // ChainIdFixEpoch
|
|
|
|
big.NewInt(0), // SlotsLimitedEpoch
|
|
|
|
big.NewInt(1), // CrossShardXferPrecompileEpoch
|
|
|
|
big.NewInt(0), // AllowlistEpoch
|
|
|
|
big.NewInt(1), // LeaderRotationExternalNonBeaconLeaders
|
|
|
|
big.NewInt(1), // LeaderRotationExternalBeaconLeaders
|
|
|
|
big.NewInt(0), // FeeCollectEpoch
|
|
|
|
big.NewInt(0), // ValidatorCodeFixEpoch
|
|
|
|
}
|
|
|
|
|
|
|
|
// TestChainConfig ...
|
|
|
|
// This configuration is intentionally not using keyed fields to force anyone
|
|
|
|
// adding flags to the config to also have to set these fields.
|
|
|
|
TestChainConfig = &ChainConfig{
|
|
|
|
TestChainID, // ChainID
|
|
|
|
EthTestShard0ChainID, // EthCompatibleChainID
|
|
|
|
EthTestShard0ChainID, // EthCompatibleShard0ChainID
|
|
|
|
big.NewInt(0), // EthCompatibleEpoch
|
|
|
|
big.NewInt(0), // CrossTxEpoch
|
|
|
|
big.NewInt(0), // CrossLinkEpoch
|
|
|
|
big.NewInt(0), // AggregatedRewardEpoch
|
|
|
|
big.NewInt(0), // StakingEpoch
|
|
|
|
big.NewInt(0), // PreStakingEpoch
|
|
|
|
big.NewInt(0), // QuickUnlockEpoch
|
|
|
|
big.NewInt(0), // FiveSecondsEpoch
|
|
|
|
big.NewInt(0), // TwoSecondsEpoch
|
|
|
|
big.NewInt(0), // SixtyPercentEpoch
|
|
|
|
big.NewInt(0), // RedelegationEpoch
|
|
|
|
big.NewInt(0), // NoEarlyUnlockEpoch
|
|
|
|
big.NewInt(0), // VRFEpoch
|
|
|
|
big.NewInt(0), // PrevVRFEpoch
|
|
|
|
big.NewInt(0), // MinDelegation100Epoch
|
|
|
|
big.NewInt(0), // MinCommissionRateEpoch
|
|
|
|
big.NewInt(10), // MinCommissionPromoPeriod
|
|
|
|
big.NewInt(0), // EPoSBound35Epoch
|
|
|
|
big.NewInt(0), // EIP155Epoch
|
|
|
|
big.NewInt(0), // S3Epoch
|
|
|
|
big.NewInt(0), // DataCopyFixEpoch
|
|
|
|
big.NewInt(0), // IstanbulEpoch
|
|
|
|
big.NewInt(0), // ReceiptLogEpoch
|
|
|
|
big.NewInt(0), // SHA3Epoch
|
|
|
|
big.NewInt(0), // HIP6And8Epoch
|
Resolve harmony-one/bounties#77: Staking precompiles (#3906)
* 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
3 years ago
|
|
|
big.NewInt(0), // StakingPrecompileEpoch
|
|
|
|
big.NewInt(0), // ChainIdFixEpoch
|
|
|
|
big.NewInt(0), // SlotsLimitedEpoch
|
|
|
|
big.NewInt(1), // CrossShardXferPrecompileEpoch
|
|
|
|
big.NewInt(0), // AllowlistEpoch
|
|
|
|
big.NewInt(1), // LeaderRotationExternalNonBeaconLeaders
|
|
|
|
big.NewInt(1), // LeaderRotationExternalBeaconLeaders
|
|
|
|
big.NewInt(0), // FeeCollectEpoch
|
|
|
|
big.NewInt(0), // ValidatorCodeFixEpoch
|
|
|
|
}
|
|
|
|
|
|
|
|
// TestRules ...
|
|
|
|
TestRules = TestChainConfig.Rules(new(big.Int))
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
MainnetChainConfig.mustValid()
|
|
|
|
TestnetChainConfig.mustValid()
|
|
|
|
PangaeaChainConfig.mustValid()
|
|
|
|
PartnerChainConfig.mustValid()
|
|
|
|
StressnetChainConfig.mustValid()
|
|
|
|
LocalnetChainConfig.mustValid()
|
|
|
|
}
|
|
|
|
|
|
|
|
// TrustedCheckpoint represents a set of post-processed trie roots (CHT and
|
|
|
|
// BloomTrie) associated with the appropriate section index and head hash. It is
|
|
|
|
// used to start light syncing from this checkpoint and avoid downloading the
|
|
|
|
// entire header chain while still being able to securely access old headers/logs.
|
|
|
|
type TrustedCheckpoint struct {
|
|
|
|
Name string `json:"-"`
|
|
|
|
SectionIndex uint64 `json:"sectionIndex"`
|
|
|
|
SectionHead common.Hash `json:"sectionHead"`
|
|
|
|
CHTRoot common.Hash `json:"chtRoot"`
|
|
|
|
BloomRoot common.Hash `json:"bloomRoot"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// ChainConfig is the core config which determines the blockchain settings.
|
|
|
|
//
|
|
|
|
// ChainConfig is stored in the database on a per block basis. This means
|
|
|
|
// that any network, identified by its genesis block, can have its own
|
|
|
|
// set of configuration options.
|
|
|
|
type ChainConfig struct {
|
|
|
|
// ChainId identifies the current chain and is used for replay protection
|
|
|
|
ChainID *big.Int `json:"chain-id"`
|
|
|
|
|
|
|
|
// EthCompatibleChainID identifies the chain id used for ethereum compatible transactions
|
|
|
|
EthCompatibleChainID *big.Int `json:"eth-compatible-chain-id"`
|
|
|
|
|
|
|
|
// EthCompatibleShard0ChainID identifies the shard 0 chain id used for ethereum compatible transactions
|
|
|
|
EthCompatibleShard0ChainID *big.Int `json:"eth-compatible-shard-0-chain-id"`
|
|
|
|
|
|
|
|
// EthCompatibleEpoch is the epoch where ethereum-compatible transaction starts being
|
|
|
|
// processed.
|
|
|
|
EthCompatibleEpoch *big.Int `json:"eth-compatible-epoch,omitempty"`
|
|
|
|
|
|
|
|
// CrossTxEpoch is the epoch where cross-shard transaction starts being
|
|
|
|
// processed.
|
|
|
|
CrossTxEpoch *big.Int `json:"cross-tx-epoch,omitempty"`
|
|
|
|
|
|
|
|
// CrossLinkEpoch is the epoch where beaconchain starts containing
|
|
|
|
// cross-shard links.
|
|
|
|
CrossLinkEpoch *big.Int `json:"cross-link-epoch,omitempty"`
|
|
|
|
|
|
|
|
// AggregatedRewardEpoch is the epoch when block rewards are distributed every 64 blocks
|
|
|
|
AggregatedRewardEpoch *big.Int `json:"aggregated-reward-epoch,omitempty"`
|
|
|
|
|
|
|
|
// StakingEpoch is the epoch when shard assign takes staking into account
|
|
|
|
StakingEpoch *big.Int `json:"staking-epoch,omitempty"`
|
|
|
|
|
|
|
|
// PreStakingEpoch is the epoch we allow staking transactions
|
|
|
|
PreStakingEpoch *big.Int `json:"prestaking-epoch,omitempty"`
|
|
|
|
|
|
|
|
// QuickUnlockEpoch is the epoch when undelegation will be unlocked at the current epoch
|
|
|
|
QuickUnlockEpoch *big.Int `json:"quick-unlock-epoch,omitempty"`
|
|
|
|
|
|
|
|
// FiveSecondsEpoch is the epoch when block time is reduced to 5 seconds
|
|
|
|
// and block rewards adjusted to 17.5 ONE/block
|
|
|
|
FiveSecondsEpoch *big.Int `json:"five-seconds-epoch,omitempty"`
|
|
|
|
|
|
|
|
// TwoSecondsEpoch is the epoch when block time is reduced to 2 seconds
|
|
|
|
// and block rewards adjusted to 7 ONE/block
|
|
|
|
TwoSecondsEpoch *big.Int `json:"two-seconds-epoch,omitempty"`
|
|
|
|
|
|
|
|
// SixtyPercentEpoch is the epoch when internal voting power reduced from 68% to 60%
|
|
|
|
SixtyPercentEpoch *big.Int `json:"sixty-percent-epoch,omitempty"`
|
|
|
|
|
|
|
|
// RedelegationEpoch is the epoch when redelegation is supported and undelegation locking time
|
|
|
|
// is restored to 7 epoch
|
|
|
|
RedelegationEpoch *big.Int `json:"redelegation-epoch,omitempty"`
|
|
|
|
|
|
|
|
// NoEarlyUnlockEpoch is the epoch when the early unlock of undelegated token from validators who were elected for
|
|
|
|
// more than 7 epochs is disabled
|
|
|
|
NoEarlyUnlockEpoch *big.Int `json:"no-early-unlock-epoch,omitempty"`
|
|
|
|
|
|
|
|
// VRFEpoch is the epoch when VRF randomness is enabled
|
|
|
|
VRFEpoch *big.Int `json:"vrf-epoch,omitempty"`
|
|
|
|
|
|
|
|
// PrevVRFEpoch is the epoch when previous VRF randomness can be fetched
|
|
|
|
PrevVRFEpoch *big.Int `json:"prev-vrf-epoch,omitempty"`
|
|
|
|
|
|
|
|
// MinDelegation100Epoch is the epoch when min delegation is reduced from 1000 ONE to 100 ONE
|
|
|
|
MinDelegation100Epoch *big.Int `json:"min-delegation-100-epoch,omitempty"`
|
|
|
|
|
|
|
|
// MinCommissionRateEpoch is the epoch when policy for minimum comission rate of 5% is started
|
|
|
|
MinCommissionRateEpoch *big.Int `json:"min-commission-rate-epoch,omitempty"`
|
|
|
|
|
|
|
|
// MinCommissionPromoPeriod is the number of epochs when newly elected validators can have 0% commission
|
|
|
|
MinCommissionPromoPeriod *big.Int `json:"commission-promo-period,omitempty"`
|
|
|
|
|
|
|
|
// EPoSBound35Epoch is the epoch when the EPoS bound parameter c is changed from 15% to 35%
|
|
|
|
EPoSBound35Epoch *big.Int `json:"epos-bound-35-epoch,omitempty"`
|
|
|
|
|
|
|
|
// EIP155 hard fork epoch (include EIP158 too)
|
|
|
|
EIP155Epoch *big.Int `json:"eip155-epoch,omitempty"`
|
|
|
|
|
|
|
|
// S3 epoch is the first epoch containing S3 mainnet and all ethereum update up to Constantinople
|
|
|
|
S3Epoch *big.Int `json:"s3-epoch,omitempty"`
|
|
|
|
|
|
|
|
// DataCopyFix epoch is the first epoch containing fix for evm datacopy bug.
|
|
|
|
DataCopyFixEpoch *big.Int `json:"data-copy-fix-epoch,omitempty"`
|
|
|
|
|
|
|
|
// Istanbul epoch
|
|
|
|
IstanbulEpoch *big.Int `json:"istanbul-epoch,omitempty"`
|
|
|
|
|
|
|
|
// ReceiptLogEpoch is the first epoch support receiptlog
|
|
|
|
ReceiptLogEpoch *big.Int `json:"receipt-log-epoch,omitempty"`
|
|
|
|
|
|
|
|
// IsSHA3Epoch is the first epoch in supporting SHA3 FIPS-202 standard
|
|
|
|
SHA3Epoch *big.Int `json:"sha3-epoch,omitempty"`
|
|
|
|
|
|
|
|
// IsHIP6And8Epoch is the first epoch to support HIP-6 and HIP-8
|
|
|
|
HIP6And8Epoch *big.Int `json:"hip6_8-epoch,omitempty"`
|
Resolve harmony-one/bounties#77: Staking precompiles (#3906)
* 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
3 years ago
|
|
|
|
|
|
|
// StakingPrecompileEpoch is the first epoch to support the staking precompiles
|
|
|
|
StakingPrecompileEpoch *big.Int `json:"staking-precompile-epoch,omitempty"`
|
|
|
|
|
|
|
|
// ChainIdFixEpoch is the first epoch to return ethereum compatible chain id by ChainID() op code
|
|
|
|
ChainIdFixEpoch *big.Int `json:"chain-id-fix-epoch,omitempty"`
|
|
|
|
|
|
|
|
// SlotsLimitedEpoch is the first epoch to enable HIP-16.
|
|
|
|
SlotsLimitedEpoch *big.Int `json:"slots-limit-epoch,omitempty"`
|
|
|
|
|
|
|
|
// CrossShardXferPrecompileEpoch is the first epoch to feature cross shard transfer precompile
|
|
|
|
CrossShardXferPrecompileEpoch *big.Int `json:"cross-shard-xfer-precompile-epoch,omitempty"`
|
|
|
|
|
|
|
|
// AllowlistEpoch is the first epoch to support allowlist of HIP18
|
|
|
|
AllowlistEpoch *big.Int
|
|
|
|
|
|
|
|
LeaderRotationExternalNonBeaconLeaders *big.Int `json:"leader-rotation-external-non-beacon-leaders,omitempty"`
|
|
|
|
|
|
|
|
LeaderRotationExternalBeaconLeaders *big.Int `json:"leader-rotation-external-beacon-leaders,omitempty"`
|
|
|
|
|
|
|
|
// FeeCollectEpoch is the first epoch that enables txn fees to be collected into the community-managed account.
|
|
|
|
// It should >= StakingEpoch.
|
|
|
|
// Before StakingEpoch, txn fees are paid to miner/leader.
|
|
|
|
// Then before FeeCollectEpoch, txn fees are burned.
|
|
|
|
// After FeeCollectEpoch, txn fees paid to FeeCollector account.
|
|
|
|
FeeCollectEpoch *big.Int
|
|
|
|
|
|
|
|
// ValidatorCodeFixEpoch is the first epoch that fixes the issue of validator code
|
|
|
|
// being available in Solidity. This is a temporary fix until we have a better
|
|
|
|
// solution.
|
|
|
|
// Contracts can check the (presence of) validator code by calling the following:
|
|
|
|
// extcodesize, extcodecopy and extcodehash.
|
|
|
|
ValidatorCodeFixEpoch *big.Int `json:"validator-code-fix-epoch,omitempty"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// String implements the fmt.Stringer interface.
|
|
|
|
func (c *ChainConfig) String() string {
|
|
|
|
return fmt.Sprintf("{ChainID: %v EthCompatibleChainID: %v EIP155: %v CrossTx: %v Staking: %v CrossLink: %v ReceiptLog: %v SHA3Epoch: %v StakingPrecompileEpoch: %v ChainIdFixEpoch: %v CrossShardXferPrecompileEpoch: %v}",
|
|
|
|
c.ChainID,
|
|
|
|
c.EthCompatibleChainID,
|
|
|
|
c.EIP155Epoch,
|
|
|
|
c.CrossTxEpoch,
|
|
|
|
c.StakingEpoch,
|
|
|
|
c.CrossLinkEpoch,
|
|
|
|
c.ReceiptLogEpoch,
|
|
|
|
c.SHA3Epoch,
|
Resolve harmony-one/bounties#77: Staking precompiles (#3906)
* 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
3 years ago
|
|
|
c.StakingPrecompileEpoch,
|
|
|
|
c.ChainIdFixEpoch,
|
|
|
|
c.CrossShardXferPrecompileEpoch,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
// check if ChainConfig is valid, it will panic if config is invalid. it should only be called in init()
|
|
|
|
func (c *ChainConfig) mustValid() {
|
|
|
|
require := func(cond bool, err string) {
|
|
|
|
if !cond {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// before staking epoch, fees were sent to coinbase
|
|
|
|
require(c.FeeCollectEpoch.Cmp(c.StakingEpoch) >= 0,
|
|
|
|
"must satisfy: FeeCollectEpoch >= StakingEpoch")
|
|
|
|
// obvious
|
|
|
|
require(c.PreStakingEpoch.Cmp(c.StakingEpoch) < 0,
|
|
|
|
"must satisfy: PreStakingEpoch < StakingEpoch")
|
|
|
|
// delegations can be made starting at PreStakingEpoch
|
|
|
|
require(c.StakingPrecompileEpoch.Cmp(c.PreStakingEpoch) >= 0,
|
|
|
|
"must satisfy: StakingPrecompileEpoch >= PreStakingEpoch")
|
|
|
|
// main functionality must come before the precompile
|
|
|
|
// see AcceptsCrossTx for why > and not >=
|
|
|
|
require(c.CrossShardXferPrecompileEpoch.Cmp(c.CrossTxEpoch) > 0,
|
|
|
|
"must satisfy: CrossShardXferPrecompileEpoch > CrossTxEpoch")
|
|
|
|
// the fix is applied only on the Solidity level, so you need eth compat
|
|
|
|
require(c.ValidatorCodeFixEpoch.Cmp(c.EthCompatibleEpoch) >= 0,
|
|
|
|
"must satisfy: ValidatorCodeFixEpoch >= EthCompatibleEpoch")
|
|
|
|
// we accept validator creation transactions starting at PreStakingEpoch
|
|
|
|
require(c.ValidatorCodeFixEpoch.Cmp(c.PreStakingEpoch) >= 0,
|
|
|
|
"must satisfy: ValidatorCodeFixEpoch >= PreStakingEpoch")
|
|
|
|
}
|
|
|
|
|
|
|
|
// IsEIP155 returns whether epoch is either equal to the EIP155 fork epoch or greater.
|
|
|
|
func (c *ChainConfig) IsEIP155(epoch *big.Int) bool {
|
|
|
|
return isForked(c.EIP155Epoch, epoch)
|
|
|
|
}
|
|
|
|
|
|
|
|
// AcceptsCrossTx returns whether cross-shard transaction is accepted in the
|
|
|
|
// given epoch.
|
|
|
|
//
|
|
|
|
// Note that this is different from comparing epoch against CrossTxEpoch.
|
|
|
|
// Cross-shard transaction is accepted from CrossTxEpoch+1 and on, in order to
|
|
|
|
// allow for all shards to roll into CrossTxEpoch and become able to handle
|
|
|
|
// ingress receipts. In other words, cross-shard transaction fields are
|
|
|
|
// introduced and ingress receipts are processed at CrossTxEpoch, but the shard
|
|
|
|
// does not accept cross-shard transactions from clients until CrossTxEpoch+1.
|
|
|
|
func (c *ChainConfig) AcceptsCrossTx(epoch *big.Int) bool {
|
|
|
|
crossTxEpoch := new(big.Int).Add(c.CrossTxEpoch, common.Big1)
|
|
|
|
return isForked(crossTxEpoch, epoch)
|
|
|
|
}
|
|
|
|
|
|
|
|
// HasCrossTxFields returns whether blocks in the given epoch includes
|
|
|
|
// cross-shard transaction fields.
|
|
|
|
func (c *ChainConfig) HasCrossTxFields(epoch *big.Int) bool {
|
|
|
|
return isForked(c.CrossTxEpoch, epoch)
|
|
|
|
}
|
|
|
|
|
|
|
|
// IsEthCompatible determines whether it is ethereum compatible epoch
|
|
|
|
func (c *ChainConfig) IsEthCompatible(epoch *big.Int) bool {
|
|
|
|
return isForked(c.EthCompatibleEpoch, epoch)
|
|
|
|
}
|
|
|
|
|
|
|
|
// IsAggregatedRewardEpoch determines whether it is the epoch when rewards are distributed every 64 blocks
|
|
|
|
func (c *ChainConfig) IsAggregatedRewardEpoch(epoch *big.Int) bool {
|
|
|
|
return isForked(c.AggregatedRewardEpoch, epoch)
|
|
|
|
}
|
|
|
|
|
|
|
|
// IsStaking determines whether it is staking epoch
|
|
|
|
func (c *ChainConfig) IsStaking(epoch *big.Int) bool {
|
|
|
|
return isForked(c.StakingEpoch, epoch)
|
|
|
|
}
|
|
|
|
|
|
|
|
// IsSlotsLimited determines whether HIP-16 is enabled
|
|
|
|
func (c *ChainConfig) IsSlotsLimited(epoch *big.Int) bool {
|
|
|
|
return isForked(c.SlotsLimitedEpoch, epoch)
|
|
|
|
}
|
|
|
|
|
|
|
|
// IsFiveSeconds determines whether it is the epoch to change to 5 seconds block time
|
|
|
|
func (c *ChainConfig) IsFiveSeconds(epoch *big.Int) bool {
|
|
|
|
return isForked(c.FiveSecondsEpoch, epoch)
|
|
|
|
}
|
|
|
|
|
|
|
|
// IsTwoSeconds determines whether it is the epoch to change to 3 seconds block time
|
|
|
|
func (c *ChainConfig) IsTwoSeconds(epoch *big.Int) bool {
|
|
|
|
return isForked(c.TwoSecondsEpoch, epoch)
|
|
|
|
}
|
|
|
|
|
|
|
|
// IsSixtyPercent determines whether it is the epoch to reduce internal voting power to 60%
|
|
|
|
func (c *ChainConfig) IsSixtyPercent(epoch *big.Int) bool {
|
|
|
|
return isForked(c.SixtyPercentEpoch, epoch)
|
|
|
|
}
|
|
|
|
|
|
|
|
// IsRedelegation determines whether it is the epoch to support redelegation
|
|
|
|
func (c *ChainConfig) IsRedelegation(epoch *big.Int) bool {
|
|
|
|
return isForked(c.RedelegationEpoch, epoch)
|
|
|
|
}
|
|
|
|
|
|
|
|
// IsNoEarlyUnlock determines whether it is the epoch to stop early unlock
|
|
|
|
func (c *ChainConfig) IsNoEarlyUnlock(epoch *big.Int) bool {
|
|
|
|
return isForked(c.NoEarlyUnlockEpoch, epoch)
|
|
|
|
}
|
|
|
|
|
|
|
|
// IsVRF determines whether it is the epoch to enable vrf
|
|
|
|
func (c *ChainConfig) IsVRF(epoch *big.Int) bool {
|
|
|
|
return isForked(c.VRFEpoch, epoch)
|
|
|
|
}
|
|
|
|
|
|
|
|
// IsPrevVRF determines whether it is the epoch to enable previous vrf
|
|
|
|
func (c *ChainConfig) IsPrevVRF(epoch *big.Int) bool {
|
|
|
|
return isForked(c.PrevVRFEpoch, epoch)
|
|
|
|
}
|
|
|
|
|
|
|
|
// IsMinDelegation100 determines whether it is the epoch to reduce min delegation to 100
|
|
|
|
func (c *ChainConfig) IsMinDelegation100(epoch *big.Int) bool {
|
|
|
|
return isForked(c.MinDelegation100Epoch, epoch)
|
|
|
|
}
|
|
|
|
|
|
|
|
// IsMinCommissionRate determines whether it is the epoch to start the policy of 5% min commission
|
|
|
|
func (c *ChainConfig) IsMinCommissionRate(epoch *big.Int) bool {
|
|
|
|
return isForked(c.MinCommissionRateEpoch, epoch)
|
|
|
|
}
|
|
|
|
|
|
|
|
// IsEPoSBound35 determines whether it is the epoch to extend the EPoS bound to 35%
|
|
|
|
func (c *ChainConfig) IsEPoSBound35(epoch *big.Int) bool {
|
|
|
|
return isForked(c.EPoSBound35Epoch, epoch)
|
|
|
|
}
|
|
|
|
|
|
|
|
// IsPreStaking determines whether staking transactions are allowed
|
|
|
|
func (c *ChainConfig) IsPreStaking(epoch *big.Int) bool {
|
|
|
|
return isForked(c.PreStakingEpoch, epoch)
|
|
|
|
}
|
|
|
|
|
|
|
|
// IsQuickUnlock determines whether it's the epoch when the undelegation should be unlocked at end of current epoch
|
|
|
|
func (c *ChainConfig) IsQuickUnlock(epoch *big.Int) bool {
|
|
|
|
return isForked(c.QuickUnlockEpoch, epoch)
|
|
|
|
}
|
|
|
|
|
|
|
|
// IsCrossLink returns whether epoch is either equal to the CrossLink fork epoch or greater.
|
|
|
|
func (c *ChainConfig) IsCrossLink(epoch *big.Int) bool {
|
|
|
|
return isForked(c.CrossLinkEpoch, epoch)
|
|
|
|
}
|
|
|
|
|
|
|
|
// IsS3 returns whether epoch is either equal to the S3 fork epoch or greater.
|
|
|
|
func (c *ChainConfig) IsS3(epoch *big.Int) bool {
|
|
|
|
return isForked(c.S3Epoch, epoch)
|
|
|
|
}
|
|
|
|
|
|
|
|
// IsDataCopyFixEpoch returns whether epoch has the fix for DataCopy evm bug.
|
|
|
|
func (c *ChainConfig) IsDataCopyFixEpoch(epoch *big.Int) bool {
|
|
|
|
return isForked(c.DataCopyFixEpoch, epoch)
|
|
|
|
}
|
|
|
|
|
|
|
|
// IsIstanbul returns whether epoch is either equal to the Istanbul fork epoch or greater.
|
|
|
|
func (c *ChainConfig) IsIstanbul(epoch *big.Int) bool {
|
|
|
|
return isForked(c.IstanbulEpoch, epoch)
|
|
|
|
}
|
|
|
|
|
|
|
|
// IsReceiptLog returns whether epoch is either equal to the ReceiptLog fork epoch or greater.
|
|
|
|
func (c *ChainConfig) IsReceiptLog(epoch *big.Int) bool {
|
|
|
|
return isForked(c.ReceiptLogEpoch, epoch)
|
|
|
|
}
|
|
|
|
|
|
|
|
// IsSHA3 returns whether epoch is either equal to the IsSHA3 fork epoch or greater.
|
|
|
|
func (c *ChainConfig) IsSHA3(epoch *big.Int) bool {
|
|
|
|
return isForked(c.SHA3Epoch, epoch)
|
|
|
|
}
|
|
|
|
|
|
|
|
// IsHIP6And8Epoch determines whether it is the epoch to support
|
|
|
|
// HIP-6: reduce the internal voting power from 60% to 49%
|
|
|
|
// HIP-8: increase external nodes from 800 to 900
|
|
|
|
func (c *ChainConfig) IsHIP6And8Epoch(epoch *big.Int) bool {
|
|
|
|
return isForked(c.HIP6And8Epoch, epoch)
|
|
|
|
}
|
|
|
|
|
Resolve harmony-one/bounties#77: Staking precompiles (#3906)
* 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
3 years ago
|
|
|
// IsStakingPrecompileEpoch determines whether staking
|
|
|
|
// precompiles are available in the EVM
|
|
|
|
func (c *ChainConfig) IsStakingPrecompile(epoch *big.Int) bool {
|
|
|
|
return isForked(c.StakingPrecompileEpoch, epoch)
|
|
|
|
}
|
|
|
|
|
|
|
|
// IsCrossShardXferPrecompile determines whether the
|
|
|
|
// Cross Shard Transfer Precompile is available in the EVM
|
|
|
|
func (c *ChainConfig) IsCrossShardXferPrecompile(epoch *big.Int) bool {
|
|
|
|
return isForked(c.CrossShardXferPrecompileEpoch, epoch)
|
|
|
|
}
|
|
|
|
|
|
|
|
// IsChainIdFix returns whether epoch is either equal to the ChainId Fix fork epoch or greater.
|
|
|
|
func (c *ChainConfig) IsChainIdFix(epoch *big.Int) bool {
|
|
|
|
return isForked(c.ChainIdFixEpoch, epoch)
|
|
|
|
}
|
|
|
|
|
|
|
|
// IsAllowlistEpoch determines whether IsAllowlist of HIP18 is enabled
|
|
|
|
func (c *ChainConfig) IsAllowlistEpoch(epoch *big.Int) bool {
|
|
|
|
return isForked(c.AllowlistEpoch, epoch)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *ChainConfig) IsLeaderRotation(epoch *big.Int) bool {
|
|
|
|
return isForked(c.LeaderRotationExternalNonBeaconLeaders, epoch)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *ChainConfig) IsLeaderRotationExternalValidatorsAllowed(epoch *big.Int, shardID uint32) bool {
|
|
|
|
if !c.IsLeaderRotation(epoch) {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
if shardID == 0 {
|
|
|
|
return isForked(c.LeaderRotationExternalBeaconLeaders, epoch)
|
|
|
|
}
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
// IsFeeCollectEpoch determines whether Txn Fees will be collected into the community-managed account.
|
|
|
|
func (c *ChainConfig) IsFeeCollectEpoch(epoch *big.Int) bool {
|
|
|
|
return isForked(c.FeeCollectEpoch, epoch)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *ChainConfig) IsValidatorCodeFix(epoch *big.Int) bool {
|
|
|
|
return isForked(c.ValidatorCodeFixEpoch, epoch)
|
|
|
|
}
|
|
|
|
|
|
|
|
// UpdateEthChainIDByShard update the ethChainID based on shard ID.
|
|
|
|
func UpdateEthChainIDByShard(shardID uint32) {
|
|
|
|
once.Do(func() {
|
|
|
|
MainnetChainConfig.EthCompatibleChainID = big.NewInt(0).Add(MainnetChainConfig.EthCompatibleChainID, big.NewInt(int64(shardID)))
|
|
|
|
TestnetChainConfig.EthCompatibleChainID = big.NewInt(0).Add(TestnetChainConfig.EthCompatibleChainID, big.NewInt(int64(shardID)))
|
|
|
|
PangaeaChainConfig.EthCompatibleChainID = big.NewInt(0).Add(PangaeaChainConfig.EthCompatibleChainID, big.NewInt(int64(shardID)))
|
|
|
|
PartnerChainConfig.EthCompatibleChainID = big.NewInt(0).Add(PartnerChainConfig.EthCompatibleChainID, big.NewInt(int64(shardID)))
|
|
|
|
StressnetChainConfig.EthCompatibleChainID = big.NewInt(0).Add(StressnetChainConfig.EthCompatibleChainID, big.NewInt(int64(shardID)))
|
|
|
|
LocalnetChainConfig.EthCompatibleChainID = big.NewInt(0).Add(LocalnetChainConfig.EthCompatibleChainID, big.NewInt(int64(shardID)))
|
|
|
|
AllProtocolChanges.EthCompatibleChainID = big.NewInt(0).Add(AllProtocolChanges.EthCompatibleChainID, big.NewInt(int64(shardID)))
|
|
|
|
TestChainConfig.EthCompatibleChainID = big.NewInt(0).Add(TestChainConfig.EthCompatibleChainID, big.NewInt(int64(shardID)))
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
// IsEthCompatible returns whether the chainID is for ethereum compatible txn or not
|
|
|
|
func IsEthCompatible(chainID *big.Int) bool {
|
|
|
|
return chainID.Cmp(EthMainnetShard0ChainID) >= 0
|
|
|
|
}
|
|
|
|
|
|
|
|
// GasTable returns the gas table corresponding to the current phase (homestead or homestead reprice).
|
|
|
|
//
|
|
|
|
// The returned GasTable's fields shouldn't, under any circumstances, be changed.
|
|
|
|
func (c *ChainConfig) GasTable(epoch *big.Int) GasTable {
|
|
|
|
if epoch == nil {
|
|
|
|
return GasTableR3
|
|
|
|
}
|
|
|
|
switch {
|
|
|
|
case c.IsS3(epoch):
|
|
|
|
return GasTableS3
|
|
|
|
default:
|
|
|
|
return GasTableR3
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// isForked returns whether a fork scheduled at epoch s is active at the given head epoch.
|
|
|
|
func isForked(s, epoch *big.Int) bool {
|
|
|
|
if s == nil || epoch == nil {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
return s.Cmp(epoch) <= 0
|
|
|
|
}
|
|
|
|
|
|
|
|
// Rules wraps ChainConfig and is merely syntactic sugar or can be used for functions
|
|
|
|
// that do not have or require information about the block.
|
|
|
|
//
|
|
|
|
// Rules is a one time interface meaning that it shouldn't be used in between transition
|
|
|
|
// phases.
|
|
|
|
type Rules struct {
|
|
|
|
ChainID *big.Int
|
|
|
|
EthChainID *big.Int
|
|
|
|
// gas
|
|
|
|
IsS3,
|
|
|
|
// precompiles
|
|
|
|
IsIstanbul, IsVRF, IsPrevVRF, IsSHA3,
|
|
|
|
IsStakingPrecompile, IsCrossShardXferPrecompile,
|
|
|
|
// eip-155 chain id fix
|
|
|
|
IsChainIdFix bool
|
|
|
|
IsValidatorCodeFix bool
|
|
|
|
}
|
|
|
|
|
|
|
|
// Rules ensures c's ChainID is not nil.
|
|
|
|
// The Rules object is only used by The EVM
|
|
|
|
func (c *ChainConfig) Rules(epoch *big.Int) Rules {
|
|
|
|
chainID := c.ChainID
|
|
|
|
if chainID == nil {
|
|
|
|
chainID = new(big.Int)
|
|
|
|
}
|
|
|
|
ethChainID := c.EthCompatibleChainID
|
|
|
|
if ethChainID == nil {
|
|
|
|
ethChainID = new(big.Int)
|
|
|
|
}
|
|
|
|
return Rules{
|
|
|
|
ChainID: new(big.Int).Set(chainID),
|
|
|
|
EthChainID: new(big.Int).Set(ethChainID),
|
|
|
|
IsS3: c.IsS3(epoch),
|
|
|
|
IsIstanbul: c.IsIstanbul(epoch),
|
|
|
|
IsVRF: c.IsVRF(epoch),
|
|
|
|
IsPrevVRF: c.IsPrevVRF(epoch),
|
|
|
|
IsSHA3: c.IsSHA3(epoch),
|
|
|
|
IsStakingPrecompile: c.IsStakingPrecompile(epoch),
|
|
|
|
IsCrossShardXferPrecompile: c.IsCrossShardXferPrecompile(epoch),
|
|
|
|
IsChainIdFix: c.IsChainIdFix(epoch),
|
|
|
|
IsValidatorCodeFix: c.IsValidatorCodeFix(epoch),
|
|
|
|
}
|
|
|
|
}
|