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 597ba2d6f1.

* Revert "Network type."

This reverts commit 5e1878aedc.

* Revert "Clean up code."

This reverts commit 15885f4c9b.

* Revert "Fix possible panic."

This reverts commit 1a70d5eb66.

* Revert "Removed engine dependency."

This reverts commit 8c2ff803f7.

* 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 597ba2d6f1.

* Revert "Network type."

This reverts commit 5e1878aedc.

* Revert "Clean up code."

This reverts commit 15885f4c9b.

* Revert "Fix possible panic."

This reverts commit 1a70d5eb66.

* Revert "Removed engine dependency."

This reverts commit 8c2ff803f7.

* 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 597ba2d6f1.

* Revert "Network type."

This reverts commit 5e1878aedc.

* Revert "Clean up code."

This reverts commit 15885f4c9b.

* Revert "Fix possible panic."

This reverts commit 1a70d5eb66.

* Revert "Removed engine dependency."

This reverts commit 8c2ff803f7.

* 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 78d26d7910.

---------

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 597ba2d6f1.

* Revert "Network type."

This reverts commit 5e1878aedc.

* Revert "Clean up code."

This reverts commit 15885f4c9b.

* Revert "Fix possible panic."

This reverts commit 1a70d5eb66.

* Revert "Removed engine dependency."

This reverts commit 8c2ff803f7.

* 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 78d26d7910.

* 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>
pull/4436/head
Soph 2 years ago committed by GitHub
parent ef171ef301
commit d2a34630ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      core/state/dump.go
  2. 2
      core/state/prefeth.go
  3. 108
      core/state/state_object.go
  4. 2
      core/state/state_test.go
  5. 16
      core/state/statedb.go
  6. 22
      core/state/statedb_test.go
  7. 2
      core/vm/contracts_write.go
  8. 8
      core/vm/evm.go
  9. 4
      core/vm/instructions.go
  10. 4
      core/vm/interface.go
  11. 2
      hmy/tracers/block_tracer.go
  12. 2
      hmy/tracers/tracer.go
  13. 4
      internal/params/config.go
  14. 4
      rosetta/services/block.go
  15. 2
      rosetta/services/construction_check.go
  16. 2
      rpc/contract.go

@ -165,7 +165,7 @@ func (s *DB) DumpToCollector(c DumpCollector, conf *DumpConfig) (nextKey []byte)
addr := common.BytesToAddress(addrBytes) addr := common.BytesToAddress(addrBytes)
obj := newObject(s, addr, data) obj := newObject(s, addr, data)
if !conf.SkipCode { if !conf.SkipCode {
account.Code = obj.Code(s.db, false) account.Code = obj.Code(s.db)
} }
if !conf.SkipStorage { if !conf.SkipStorage {
account.Storage = make(map[common.Hash]string) account.Storage = make(map[common.Hash]string)

@ -100,7 +100,7 @@ func (s *DB) prefetchWorker(job *prefetchJob, jobs chan *prefetchJob) {
addr := common.BytesToAddress(addrBytes) addr := common.BytesToAddress(addrBytes)
obj := newObject(s, addr, data) obj := newObject(s, addr, data)
if data.CodeHash != nil { if data.CodeHash != nil {
obj.Code(s.db, false) obj.Code(s.db)
} }
// build account trie tree // build account trie tree

@ -32,7 +32,13 @@ import (
"github.com/harmony-one/harmony/staking" "github.com/harmony-one/harmony/staking"
) )
var emptyCodeHash = crypto.Keccak256(nil) var (
// EmptyRootHash is the known root hash of an empty trie.
EmptyRootHash = common.HexToHash("56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421")
// EmptyCodeHash is the known hash of the empty EVM bytecode.
EmptyCodeHash = crypto.Keccak256Hash(nil) // c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470
)
// Code ... // Code ...
type Code []byte type Code []byte
@ -101,7 +107,7 @@ type Object struct {
// empty returns whether the account is considered empty. // empty returns whether the account is considered empty.
func (s *Object) empty() bool { func (s *Object) empty() bool {
return s.data.Nonce == 0 && s.data.Balance.Sign() == 0 && bytes.Equal(s.data.CodeHash, emptyCodeHash) return s.data.Nonce == 0 && s.data.Balance.Sign() == 0 && bytes.Equal(s.data.CodeHash, EmptyCodeHash.Bytes())
} }
// Account is the Ethereum consensus representation of accounts. // Account is the Ethereum consensus representation of accounts.
@ -119,10 +125,10 @@ func newObject(db *DB, address common.Address, data types.StateAccount) *Object
data.Balance = new(big.Int) data.Balance = new(big.Int)
} }
if data.CodeHash == nil { if data.CodeHash == nil {
data.CodeHash = types.EmptyCodeHash.Bytes() data.CodeHash = EmptyCodeHash.Bytes()
} }
if data.Root == (common.Hash{}) { if data.Root == (common.Hash{}) {
data.Root = types.EmptyRootHash data.Root = EmptyRootHash
} }
return &Object{ return &Object{
db: db, db: db,
@ -169,7 +175,7 @@ func (s *Object) getTrie(db Database) (Trie, error) {
if s.trie == nil { if s.trie == nil {
// Try fetching from prefetcher first // Try fetching from prefetcher first
// We don't prefetch empty tries // We don't prefetch empty tries
if s.data.Root != types.EmptyRootHash && s.db.prefetcher != nil { if s.data.Root != EmptyRootHash && s.db.prefetcher != nil {
// When the miner is creating the pending state, there is no // When the miner is creating the pending state, there is no
// prefetcher // prefetcher
s.trie = s.db.prefetcher.trie(s.addrHash, s.data.Root) s.trie = s.db.prefetcher.trie(s.addrHash, s.data.Root)
@ -316,7 +322,7 @@ func (s *Object) finalise(prefetch bool) {
slotsToPrefetch = append(slotsToPrefetch, common.CopyBytes(key[:])) // Copy needed for closure slotsToPrefetch = append(slotsToPrefetch, common.CopyBytes(key[:])) // Copy needed for closure
} }
} }
if s.db.prefetcher != nil && prefetch && len(slotsToPrefetch) > 0 && s.data.Root != types.EmptyRootHash { if s.db.prefetcher != nil && prefetch && len(slotsToPrefetch) > 0 && s.data.Root != EmptyRootHash {
s.db.prefetcher.prefetch(s.addrHash, s.data.Root, slotsToPrefetch) s.db.prefetcher.prefetch(s.addrHash, s.data.Root, slotsToPrefetch)
} }
if len(s.dirtyStorage) > 0 { if len(s.dirtyStorage) > 0 {
@ -475,18 +481,18 @@ func (s *Object) setBalance(amount *big.Int) {
func (s *Object) ReturnGas(gas *big.Int) {} func (s *Object) ReturnGas(gas *big.Int) {}
func (s *Object) deepCopy(db *DB) *Object { func (s *Object) deepCopy(db *DB) *Object {
Object := newObject(db, s.address, s.data) stateObject := newObject(db, s.address, s.data)
if s.trie != nil { if s.trie != nil {
Object.trie = db.db.CopyTrie(s.trie) stateObject.trie = db.db.CopyTrie(s.trie)
} }
Object.code = s.code stateObject.code = s.code
Object.dirtyStorage = s.dirtyStorage.Copy() stateObject.dirtyStorage = s.dirtyStorage.Copy()
Object.originStorage = s.originStorage.Copy() stateObject.originStorage = s.originStorage.Copy()
Object.pendingStorage = s.pendingStorage.Copy() stateObject.pendingStorage = s.pendingStorage.Copy()
Object.suicided = s.suicided stateObject.suicided = s.suicided
Object.dirtyCode = s.dirtyCode stateObject.dirtyCode = s.dirtyCode
Object.deleted = s.deleted stateObject.deleted = s.deleted
return Object return stateObject
} }
// //
@ -499,27 +505,35 @@ func (s *Object) Address() common.Address {
} }
// Code returns the contract/validator code associated with this object, if any. // Code returns the contract/validator code associated with this object, if any.
func (s *Object) Code(db Database, isValidatorCode bool) []byte { func (s *Object) Code(db Database) []byte {
if s.code != nil { if s.code != nil {
return s.code return s.code
} }
if bytes.Equal(s.CodeHash(), types.EmptyCodeHash.Bytes()) { if bytes.Equal(s.CodeHash(), EmptyCodeHash.Bytes()) {
return nil return nil
} }
if s.validatorWrapper || isValidatorCode { var err error
code, err := db.ValidatorCode(s.addrHash, common.BytesToHash(s.CodeHash())) code := []byte{}
if err != nil { // if it's not set for validator wrapper, then it may be either contract code or validator wrapper (old version of db
s.setError(fmt.Errorf("can't load validator code hash %x: %v", s.CodeHash(), err)) // don't have any prefix to differentiate between them)
// so, if it's not set for validator wrapper, we need to check contract code as well
if !s.validatorWrapper {
code, err = db.ContractCode(s.addrHash, common.BytesToHash(s.CodeHash()))
}
// if it couldn't load contract code or it is set to validator wrapper, then it tries to fetch validator wrapper code
if s.validatorWrapper || err != nil {
vCode, errVCode := db.ValidatorCode(s.addrHash, common.BytesToHash(s.CodeHash()))
if errVCode == nil && vCode != nil {
s.code = vCode
return vCode
} }
if code != nil { if s.validatorWrapper {
s.code = code s.setError(fmt.Errorf("can't load validator code hash %x for account address hash %x : %v", s.CodeHash(), s.addrHash, err))
return code } else {
s.setError(fmt.Errorf("can't load contract/validator code hash %x for account address hash %x : contract code error: %v, validator code error: %v",
s.CodeHash(), s.addrHash, err, errVCode))
} }
} }
code, err := db.ContractCode(s.addrHash, common.BytesToHash(s.CodeHash()))
if err != nil {
s.setError(fmt.Errorf("can't load code hash %x: %v", s.CodeHash(), err))
}
s.code = code s.code = code
return code return code
} }
@ -527,31 +541,41 @@ func (s *Object) Code(db Database, isValidatorCode bool) []byte {
// CodeSize returns the size of the contract/validator code associated with this object, // CodeSize returns the size of the contract/validator code associated with this object,
// or zero if none. This method is an almost mirror of Code, but uses a cache // or zero if none. This method is an almost mirror of Code, but uses a cache
// inside the database to avoid loading codes seen recently. // inside the database to avoid loading codes seen recently.
func (s *Object) CodeSize(db Database, isValidatorCode bool) int { func (s *Object) CodeSize(db Database) int {
if s.code != nil { if s.code != nil {
return len(s.code) return len(s.code)
} }
if bytes.Equal(s.CodeHash(), types.EmptyCodeHash.Bytes()) { if bytes.Equal(s.CodeHash(), EmptyCodeHash.Bytes()) {
return 0 return 0
} }
if s.validatorWrapper || isValidatorCode { var err error
size, err := db.ValidatorCodeSize(s.addrHash, common.BytesToHash(s.CodeHash())) size := int(0)
if err != nil {
s.setError(fmt.Errorf("can't load validator code size %x: %v", s.CodeHash(), err)) // if it's not set for validator wrapper, then it may be either contract code or validator wrapper (old version of db
} // don't have any prefix to differentiate between them)
if size > 0 { // so, if it's not set for validator wrapper, we need to check contract code as well
if !s.validatorWrapper {
size, err = db.ContractCodeSize(s.addrHash, common.BytesToHash(s.CodeHash()))
}
// if it couldn't get contract code or it is set to validator wrapper, then it tries to retrieve validator wrapper code
if s.validatorWrapper || err != nil {
vcSize, errVCSize := db.ValidatorCodeSize(s.addrHash, common.BytesToHash(s.CodeHash()))
if errVCSize == nil && vcSize > 0 {
return size return size
} }
} if s.validatorWrapper {
size, err := db.ContractCodeSize(s.addrHash, common.BytesToHash(s.CodeHash())) s.setError(fmt.Errorf("can't load validator code size %x for account address hash %x : %v", s.CodeHash(), s.addrHash, err))
if err != nil { } else {
s.setError(fmt.Errorf("can't load code size %x: %v", s.CodeHash(), err)) s.setError(fmt.Errorf("can't load contract/validator code size %x for account address hash %x : contract code size error: %v, validator code size error: %v",
s.CodeHash(), s.addrHash, err, errVCSize))
}
s.setError(fmt.Errorf("can't load code size %x (validator wrapper: %t): %v", s.CodeHash(), s.validatorWrapper, err))
} }
return size return size
} }
func (s *Object) SetCode(codeHash common.Hash, code []byte, isValidatorCode bool) { func (s *Object) SetCode(codeHash common.Hash, code []byte, isValidatorCode bool) {
prevcode := s.Code(s.db.db, isValidatorCode) prevcode := s.Code(s.db.db)
s.db.journal.append(codeChange{ s.db.journal.append(codeChange{
account: &s.address, account: &s.address,
prevhash: s.CodeHash(), prevhash: s.CodeHash(),

@ -194,7 +194,7 @@ func TestSnapshot2(t *testing.T) {
so0Restored := state.getStateObject(stateobjaddr0) so0Restored := state.getStateObject(stateobjaddr0)
// Update lazily-loaded values before comparing. // Update lazily-loaded values before comparing.
so0Restored.GetState(state.db, storageaddr) so0Restored.GetState(state.db, storageaddr)
so0Restored.Code(state.db, false) so0Restored.Code(state.db)
// non-deleted is equal (restored) // non-deleted is equal (restored)
compareStateObjects(so0Restored, so0, t) compareStateObjects(so0Restored, so0, t)

@ -342,18 +342,18 @@ func (db *DB) BlockHash() common.Hash {
return db.bhash return db.bhash
} }
func (db *DB) GetCode(addr common.Address, isValidatorCode bool) []byte { func (db *DB) GetCode(addr common.Address) []byte {
Object := db.getStateObject(addr) Object := db.getStateObject(addr)
if Object != nil { if Object != nil {
return Object.Code(db.db, isValidatorCode) return Object.Code(db.db)
} }
return nil return nil
} }
func (db *DB) GetCodeSize(addr common.Address, isValidatorCode bool) int { func (db *DB) GetCodeSize(addr common.Address) int {
Object := db.getStateObject(addr) Object := db.getStateObject(addr)
if Object != nil { if Object != nil {
return Object.CodeSize(db.db, isValidatorCode) return Object.CodeSize(db.db)
} }
return 0 return 0
} }
@ -1241,13 +1241,11 @@ func (db *DB) ValidatorWrapper(
return copyValidatorWrapperIfNeeded(cached, sendOriginal, copyDelegations), nil return copyValidatorWrapperIfNeeded(cached, sendOriginal, copyDelegations), nil
} }
by := db.GetCode(addr, true) by := db.GetCode(addr)
if len(by) == 0 { if len(by) == 0 {
by = db.GetCode(addr, false) return nil, ErrAddressNotPresent
if len(by) == 0 {
return nil, ErrAddressNotPresent
}
} }
val := stk.ValidatorWrapper{} val := stk.ValidatorWrapper{}
if err := rlp.DecodeBytes(by, &val); err != nil { if err := rlp.DecodeBytes(by, &val); err != nil {
return nil, errors.Wrapf( return nil, errors.Wrapf(

@ -452,9 +452,9 @@ func (test *snapshotTest) checkEqual(state, checkstate *DB) error {
checkeq("HasSuicided", state.HasSuicided(addr), checkstate.HasSuicided(addr)) checkeq("HasSuicided", state.HasSuicided(addr), checkstate.HasSuicided(addr))
checkeq("GetBalance", state.GetBalance(addr), checkstate.GetBalance(addr)) checkeq("GetBalance", state.GetBalance(addr), checkstate.GetBalance(addr))
checkeq("GetNonce", state.GetNonce(addr), checkstate.GetNonce(addr)) checkeq("GetNonce", state.GetNonce(addr), checkstate.GetNonce(addr))
checkeq("GetCode", state.GetCode(addr, false), checkstate.GetCode(addr, false)) checkeq("GetCode", state.GetCode(addr), checkstate.GetCode(addr))
checkeq("GetCodeHash", state.GetCodeHash(addr), checkstate.GetCodeHash(addr)) checkeq("GetCodeHash", state.GetCodeHash(addr), checkstate.GetCodeHash(addr))
checkeq("GetCodeSize", state.GetCodeSize(addr, false), checkstate.GetCodeSize(addr, false)) checkeq("GetCodeSize", state.GetCodeSize(addr), checkstate.GetCodeSize(addr))
// Check storage. // Check storage.
if obj := state.getStateObject(addr); obj != nil { if obj := state.getStateObject(addr); obj != nil {
state.ForEachStorage(addr, func(key, value common.Hash) bool { state.ForEachStorage(addr, func(key, value common.Hash) bool {
@ -532,7 +532,7 @@ func TestCopyCommitCopy(t *testing.T) {
if balance := state.GetBalance(addr); balance.Cmp(big.NewInt(42)) != 0 { if balance := state.GetBalance(addr); balance.Cmp(big.NewInt(42)) != 0 {
t.Fatalf("initial balance mismatch: have %v, want %v", balance, 42) t.Fatalf("initial balance mismatch: have %v, want %v", balance, 42)
} }
if code := state.GetCode(addr, false); !bytes.Equal(code, []byte("hello")) { if code := state.GetCode(addr); !bytes.Equal(code, []byte("hello")) {
t.Fatalf("initial code mismatch: have %x, want %x", code, []byte("hello")) t.Fatalf("initial code mismatch: have %x, want %x", code, []byte("hello"))
} }
if val := state.GetState(addr, skey); val != sval { if val := state.GetState(addr, skey); val != sval {
@ -546,7 +546,7 @@ func TestCopyCommitCopy(t *testing.T) {
if balance := copyOne.GetBalance(addr); balance.Cmp(big.NewInt(42)) != 0 { if balance := copyOne.GetBalance(addr); balance.Cmp(big.NewInt(42)) != 0 {
t.Fatalf("first copy pre-commit balance mismatch: have %v, want %v", balance, 42) t.Fatalf("first copy pre-commit balance mismatch: have %v, want %v", balance, 42)
} }
if code := copyOne.GetCode(addr, false); !bytes.Equal(code, []byte("hello")) { if code := copyOne.GetCode(addr); !bytes.Equal(code, []byte("hello")) {
t.Fatalf("first copy pre-commit code mismatch: have %x, want %x", code, []byte("hello")) t.Fatalf("first copy pre-commit code mismatch: have %x, want %x", code, []byte("hello"))
} }
if val := copyOne.GetState(addr, skey); val != sval { if val := copyOne.GetState(addr, skey); val != sval {
@ -560,7 +560,7 @@ func TestCopyCommitCopy(t *testing.T) {
if balance := copyOne.GetBalance(addr); balance.Cmp(big.NewInt(42)) != 0 { if balance := copyOne.GetBalance(addr); balance.Cmp(big.NewInt(42)) != 0 {
t.Fatalf("first copy post-commit balance mismatch: have %v, want %v", balance, 42) t.Fatalf("first copy post-commit balance mismatch: have %v, want %v", balance, 42)
} }
if code := copyOne.GetCode(addr, false); !bytes.Equal(code, []byte("hello")) { if code := copyOne.GetCode(addr); !bytes.Equal(code, []byte("hello")) {
t.Fatalf("first copy post-commit code mismatch: have %x, want %x", code, []byte("hello")) t.Fatalf("first copy post-commit code mismatch: have %x, want %x", code, []byte("hello"))
} }
if val := copyOne.GetState(addr, skey); val != sval { if val := copyOne.GetState(addr, skey); val != sval {
@ -574,7 +574,7 @@ func TestCopyCommitCopy(t *testing.T) {
if balance := copyTwo.GetBalance(addr); balance.Cmp(big.NewInt(42)) != 0 { if balance := copyTwo.GetBalance(addr); balance.Cmp(big.NewInt(42)) != 0 {
t.Fatalf("second copy balance mismatch: have %v, want %v", balance, 42) t.Fatalf("second copy balance mismatch: have %v, want %v", balance, 42)
} }
if code := copyTwo.GetCode(addr, false); !bytes.Equal(code, []byte("hello")) { if code := copyTwo.GetCode(addr); !bytes.Equal(code, []byte("hello")) {
t.Fatalf("second copy code mismatch: have %x, want %x", code, []byte("hello")) t.Fatalf("second copy code mismatch: have %x, want %x", code, []byte("hello"))
} }
if val := copyTwo.GetState(addr, skey); val != sval { if val := copyTwo.GetState(addr, skey); val != sval {
@ -604,7 +604,7 @@ func TestCopyCopyCommitCopy(t *testing.T) {
if balance := state.GetBalance(addr); balance.Cmp(big.NewInt(42)) != 0 { if balance := state.GetBalance(addr); balance.Cmp(big.NewInt(42)) != 0 {
t.Fatalf("initial balance mismatch: have %v, want %v", balance, 42) t.Fatalf("initial balance mismatch: have %v, want %v", balance, 42)
} }
if code := state.GetCode(addr, false); !bytes.Equal(code, []byte("hello")) { if code := state.GetCode(addr); !bytes.Equal(code, []byte("hello")) {
t.Fatalf("initial code mismatch: have %x, want %x", code, []byte("hello")) t.Fatalf("initial code mismatch: have %x, want %x", code, []byte("hello"))
} }
if val := state.GetState(addr, skey); val != sval { if val := state.GetState(addr, skey); val != sval {
@ -618,7 +618,7 @@ func TestCopyCopyCommitCopy(t *testing.T) {
if balance := copyOne.GetBalance(addr); balance.Cmp(big.NewInt(42)) != 0 { if balance := copyOne.GetBalance(addr); balance.Cmp(big.NewInt(42)) != 0 {
t.Fatalf("first copy balance mismatch: have %v, want %v", balance, 42) t.Fatalf("first copy balance mismatch: have %v, want %v", balance, 42)
} }
if code := copyOne.GetCode(addr, false); !bytes.Equal(code, []byte("hello")) { if code := copyOne.GetCode(addr); !bytes.Equal(code, []byte("hello")) {
t.Fatalf("first copy code mismatch: have %x, want %x", code, []byte("hello")) t.Fatalf("first copy code mismatch: have %x, want %x", code, []byte("hello"))
} }
if val := copyOne.GetState(addr, skey); val != sval { if val := copyOne.GetState(addr, skey); val != sval {
@ -632,7 +632,7 @@ func TestCopyCopyCommitCopy(t *testing.T) {
if balance := copyTwo.GetBalance(addr); balance.Cmp(big.NewInt(42)) != 0 { if balance := copyTwo.GetBalance(addr); balance.Cmp(big.NewInt(42)) != 0 {
t.Fatalf("second copy pre-commit balance mismatch: have %v, want %v", balance, 42) t.Fatalf("second copy pre-commit balance mismatch: have %v, want %v", balance, 42)
} }
if code := copyTwo.GetCode(addr, false); !bytes.Equal(code, []byte("hello")) { if code := copyTwo.GetCode(addr); !bytes.Equal(code, []byte("hello")) {
t.Fatalf("second copy pre-commit code mismatch: have %x, want %x", code, []byte("hello")) t.Fatalf("second copy pre-commit code mismatch: have %x, want %x", code, []byte("hello"))
} }
if val := copyTwo.GetState(addr, skey); val != sval { if val := copyTwo.GetState(addr, skey); val != sval {
@ -645,7 +645,7 @@ func TestCopyCopyCommitCopy(t *testing.T) {
if balance := copyTwo.GetBalance(addr); balance.Cmp(big.NewInt(42)) != 0 { if balance := copyTwo.GetBalance(addr); balance.Cmp(big.NewInt(42)) != 0 {
t.Fatalf("second copy post-commit balance mismatch: have %v, want %v", balance, 42) t.Fatalf("second copy post-commit balance mismatch: have %v, want %v", balance, 42)
} }
if code := copyTwo.GetCode(addr, false); !bytes.Equal(code, []byte("hello")) { if code := copyTwo.GetCode(addr); !bytes.Equal(code, []byte("hello")) {
t.Fatalf("second copy post-commit code mismatch: have %x, want %x", code, []byte("hello")) t.Fatalf("second copy post-commit code mismatch: have %x, want %x", code, []byte("hello"))
} }
if val := copyTwo.GetState(addr, skey); val != sval { if val := copyTwo.GetState(addr, skey); val != sval {
@ -659,7 +659,7 @@ func TestCopyCopyCommitCopy(t *testing.T) {
if balance := copyThree.GetBalance(addr); balance.Cmp(big.NewInt(42)) != 0 { if balance := copyThree.GetBalance(addr); balance.Cmp(big.NewInt(42)) != 0 {
t.Fatalf("third copy balance mismatch: have %v, want %v", balance, 42) t.Fatalf("third copy balance mismatch: have %v, want %v", balance, 42)
} }
if code := copyThree.GetCode(addr, false); !bytes.Equal(code, []byte("hello")) { if code := copyThree.GetCode(addr); !bytes.Equal(code, []byte("hello")) {
t.Fatalf("third copy code mismatch: have %x, want %x", code, []byte("hello")) t.Fatalf("third copy code mismatch: have %x, want %x", code, []byte("hello"))
} }
if val := copyThree.GetState(addr, skey); val != sval { if val := copyThree.GetState(addr, skey); val != sval {

@ -242,7 +242,7 @@ func (c *crossShardXferPrecompile) RunWriteCapable(
return nil, err return nil, err
} }
// validate not a contract (toAddress can still be a contract) // validate not a contract (toAddress can still be a contract)
if len(evm.StateDB.GetCode(fromAddress, false)) > 0 && !evm.IsValidator(evm.StateDB, fromAddress) { if len(evm.StateDB.GetCode(fromAddress)) > 0 && !evm.IsValidator(evm.StateDB, fromAddress) {
return nil, errors.New("cross shard xfer not yet implemented for contracts") return nil, errors.New("cross shard xfer not yet implemented for contracts")
} }
// can't have too many shards // can't have too many shards

@ -336,7 +336,7 @@ func (evm *EVM) Call(caller ContractRef, addr common.Address, input []byte, gas
evm.Transfer(evm.StateDB, caller.Address(), to.Address(), value, txType) evm.Transfer(evm.StateDB, caller.Address(), to.Address(), value, txType)
codeHash := evm.StateDB.GetCodeHash(addr) codeHash := evm.StateDB.GetCodeHash(addr)
code := evm.StateDB.GetCode(addr, false) code := evm.StateDB.GetCode(addr)
// If address is a validator address, then it's not a smart contract address // If address is a validator address, then it's not a smart contract address
// we don't use its code and codeHash fields // we don't use its code and codeHash fields
if evm.Context.IsValidator(evm.StateDB, addr) { if evm.Context.IsValidator(evm.StateDB, addr) {
@ -402,7 +402,7 @@ func (evm *EVM) CallCode(caller ContractRef, addr common.Address, input []byte,
// EVM. The contract is a scoped environment for this execution context // EVM. The contract is a scoped environment for this execution context
// only. // only.
contract := NewContract(caller, to, value, gas) contract := NewContract(caller, to, value, gas)
contract.SetCallCode(&addr, evm.StateDB.GetCodeHash(addr), evm.StateDB.GetCode(addr, false)) contract.SetCallCode(&addr, evm.StateDB.GetCodeHash(addr), evm.StateDB.GetCode(addr))
ret, err = run(evm, contract, input, false) ret, err = run(evm, contract, input, false)
if err != nil { if err != nil {
@ -435,7 +435,7 @@ func (evm *EVM) DelegateCall(caller ContractRef, addr common.Address, input []by
// Initialise a new contract and make initialise the delegate values // Initialise a new contract and make initialise the delegate values
contract := NewContract(caller, to, nil, gas).AsDelegate() contract := NewContract(caller, to, nil, gas).AsDelegate()
contract.SetCallCode(&addr, evm.StateDB.GetCodeHash(addr), evm.StateDB.GetCode(addr, false)) contract.SetCallCode(&addr, evm.StateDB.GetCodeHash(addr), evm.StateDB.GetCode(addr))
ret, err = run(evm, contract, input, false) ret, err = run(evm, contract, input, false)
if err != nil { if err != nil {
@ -468,7 +468,7 @@ func (evm *EVM) StaticCall(caller ContractRef, addr common.Address, input []byte
// EVM. The contract is a scoped environment for this execution context // EVM. The contract is a scoped environment for this execution context
// only. // only.
contract := NewContract(caller, to, new(big.Int), gas) contract := NewContract(caller, to, new(big.Int), gas)
contract.SetCallCode(&addr, evm.StateDB.GetCodeHash(addr), evm.StateDB.GetCode(addr, false)) contract.SetCallCode(&addr, evm.StateDB.GetCodeHash(addr), evm.StateDB.GetCode(addr))
// We do an AddBalance of zero here, just in order to trigger a touch. // We do an AddBalance of zero here, just in order to trigger a touch.
// This doesn't matter on Mainnet, where all empties are gone at the time of Byzantium, // This doesn't matter on Mainnet, where all empties are gone at the time of Byzantium,

@ -488,7 +488,7 @@ func opExtCodeSize(pc *uint64, interpreter *EVMInterpreter, contract *Contract,
slot.SetUint64(0) slot.SetUint64(0)
return nil, nil return nil, nil
} }
slot.SetUint64(uint64(interpreter.evm.StateDB.GetCodeSize(common.BigToAddress(slot), false))) slot.SetUint64(uint64(interpreter.evm.StateDB.GetCodeSize(common.BigToAddress(slot))))
return nil, nil return nil, nil
} }
@ -528,7 +528,7 @@ func opExtCodeCopy(pc *uint64, interpreter *EVMInterpreter, contract *Contract,
// for EOAs that are not validators, statedb returns nil // for EOAs that are not validators, statedb returns nil
code = nil code = nil
} else { } else {
code = interpreter.evm.StateDB.GetCode(addr, false) code = interpreter.evm.StateDB.GetCode(addr)
} }
codeCopy := getDataBig(code, codeOffset, length) codeCopy := getDataBig(code, codeOffset, length)
memory.Set(memOffset.Uint64(), length.Uint64(), codeCopy) memory.Set(memOffset.Uint64(), length.Uint64(), codeCopy)

@ -38,9 +38,9 @@ type StateDB interface {
SetNonce(common.Address, uint64) SetNonce(common.Address, uint64)
GetCodeHash(common.Address) common.Hash GetCodeHash(common.Address) common.Hash
GetCode(common.Address, bool) []byte GetCode(common.Address) []byte
SetCode(common.Address, []byte, bool) SetCode(common.Address, []byte, bool)
GetCodeSize(common.Address, bool) int GetCodeSize(common.Address) int
ValidatorWrapper(common.Address, bool, bool) (*staking.ValidatorWrapper, error) ValidatorWrapper(common.Address, bool, bool) (*staking.ValidatorWrapper, error)
UpdateValidatorWrapper(common.Address, *staking.ValidatorWrapper) error UpdateValidatorWrapper(common.Address, *staking.ValidatorWrapper) error

@ -353,7 +353,7 @@ func (jst *ParityBlockTracer) CaptureState(env *vm.EVM, pc uint64, op vm.OpCode,
ret := stackPeek(0) ret := stackPeek(0)
if ret.Sign() != 0 { if ret.Sign() != 0 {
call.to = common.BigToAddress(ret) call.to = common.BigToAddress(ret)
call.output = env.StateDB.GetCode(call.to, false) call.output = env.StateDB.GetCode(call.to)
} else if call.err == nil { } else if call.err == nil {
call.err = errors.New("internal failure") call.err = errors.New("internal failure")
} }

@ -210,7 +210,7 @@ func (dw *dbWrapper) pushObject(vm *duktape.Context) {
// Push the wrapper for statedb.GetCode // Push the wrapper for statedb.GetCode
vm.PushGoFunction(func(ctx *duktape.Context) int { vm.PushGoFunction(func(ctx *duktape.Context) int {
code := dw.db.GetCode(common.BytesToAddress(popSlice(ctx)), false) code := dw.db.GetCode(common.BytesToAddress(popSlice(ctx)))
ptr := ctx.PushFixedBuffer(len(code)) ptr := ctx.PushFixedBuffer(len(code))
copy(makeSlice(ptr, uint(len(code))), code) copy(makeSlice(ptr, uint(len(code))), code)

@ -71,8 +71,8 @@ var (
AllowlistEpoch: EpochTBD, AllowlistEpoch: EpochTBD,
LeaderRotationExternalNonBeaconLeaders: EpochTBD, LeaderRotationExternalNonBeaconLeaders: EpochTBD,
LeaderRotationExternalBeaconLeaders: EpochTBD, LeaderRotationExternalBeaconLeaders: EpochTBD,
FeeCollectEpoch: big.NewInt(1451), // 2023-05-17 04:02:00+00:00 FeeCollectEpoch: EpochTBD,
ValidatorCodeFixEpoch: big.NewInt(1451), ValidatorCodeFixEpoch: EpochTBD,
} }
// TestnetChainConfig contains the chain parameters to run a node on the harmony test network. // TestnetChainConfig contains the chain parameters to run a node on the harmony test network.

@ -178,11 +178,11 @@ func (s *BlockAPI) BlockTransaction(
// check for contract related operations, if it is a plain transaction. // check for contract related operations, if it is a plain transaction.
if txInfo.tx.To() != nil { if txInfo.tx.To() != nil {
// possible call to existing contract so fetch relevant data // possible call to existing contract so fetch relevant data
contractInfo.ContractCode = state.GetCode(*txInfo.tx.To(), false) contractInfo.ContractCode = state.GetCode(*txInfo.tx.To())
contractInfo.ContractAddress = txInfo.tx.To() contractInfo.ContractAddress = txInfo.tx.To()
} else { } else {
// contract creation, so address is in receipt // contract creation, so address is in receipt
contractInfo.ContractCode = state.GetCode(txInfo.receipt.ContractAddress, false) contractInfo.ContractCode = state.GetCode(txInfo.receipt.ContractAddress)
contractInfo.ContractAddress = &txInfo.receipt.ContractAddress contractInfo.ContractAddress = &txInfo.receipt.ContractAddress
} }
contractInfo.ExecutionResult, rosettaError = s.getTransactionTrace(ctx, blk, txInfo) contractInfo.ExecutionResult, rosettaError = s.getTransactionTrace(ctx, blk, txInfo)

@ -289,7 +289,7 @@ func (s *ConstructAPI) ConstructionMetadata(
GasPrice: sugNativePrice, GasPrice: sugNativePrice,
GasLimit: estGasUsed, GasLimit: estGasUsed,
Transaction: options.TransactionMetadata, Transaction: options.TransactionMetadata,
ContractCode: state.GetCode(contractAddress, false), ContractCode: state.GetCode(contractAddress),
EvmErrorMessage: evmErrorMsg, EvmErrorMessage: evmErrorMsg,
EvmReturn: evmReturn, EvmReturn: evmReturn,
}) })

@ -123,7 +123,7 @@ func (s *PublicContractService) GetCode(
DoMetricRPCQueryInfo(GetCode, FailedNumber) DoMetricRPCQueryInfo(GetCode, FailedNumber)
return nil, err return nil, err
} }
code := state.GetCode(address, false) code := state.GetCode(address)
// Response output is the same for all versions // Response output is the same for all versions
return code, state.Error() return code, state.Error()

Loading…
Cancel
Save