Compare commits

...

12 Commits

Author SHA1 Message Date
zjubfd
70d08a5791 Merge pull request #942 from bnb-chain/hardfork_euler_mainnet
[R4R] Release For BSC v1.1.11
2022-06-08 21:56:50 +08:00
cosinlink
979bb8fca9 feat: add release info of BSC v1.1.11 2022-06-07 17:19:26 +08:00
cosinlink
0080707fc7 feat: update Euler Fork blockNumber 2022-06-07 16:52:10 +08:00
goth
b8413b129e chores: add BEP-127 operation readme 2022-05-26 11:50:59 +08:00
zjubfd
2f2b98abb2 Merge pull request #888 from bnb-chain/develop
[R4R] Release For BSC v1.1.10
2022-05-05 17:26:16 +08:00
zjubfd
55ef216c66 relace binance to bnb in changelog 2022-05-05 13:32:24 +08:00
zjubfd
b679ba81f2 prepare for release v1.1.10 (#889) 2022-05-05 11:29:33 +08:00
Gothery
4feb52e5b0 [R4R]: add Euler Hardfork, including BEP-127 and BEP-131 (#885)
* feat: add BEP-127 and BEP-131 hardfork bytecode to upgrade

* feat: force check that Euler height cannot be a multiple of 200, fix getCurrentValidators, raise SystemTxsGas after Euler fork

Co-authored-by: goth <goth>
2022-04-29 18:03:22 +08:00
WayToFuture
5b5abc4e22 [R4R] fix validator pipecommit issue (#877)
* fix validator account root issue in piepecommit

* fix test and imports

* add check for snap

* refacto a bit
2022-04-29 15:45:55 +08:00
Leon
717b38c5f5 [R4R] fix:defer bloomprocessor close (#860)
* fix:defer bloomprocessor close

* fix: fix deadlock in Close

* perf:rm defer bloomprocessors Close and manual close before return
2022-04-28 18:22:02 +08:00
Leon
0f5a4c87db [R4R]fix:Shift panic for zero length of heads (#870)
* fix:Shift panic for zero length of heads

* fix: make sure peek before shift

* refactor and update ut

* refactor
2022-04-25 10:47:02 +08:00
Jolly Zhao
15bc2548c1 fix logic issue: handlers.removePeer() is called twice. (#856)
* fix logic issue: handlers.removePeer() is called twice.

There is a logic issue which cause "Ethereum peer removal failed, err=peer not registered" occur quite often.

handler.runEthPeer set up a defer removePeer(). This is always called after a peer is disconnected.
However removePeer is also called by mulitple functions like downloader/fetcher.  After those kind of functions removePeer(), peer handler executes defer removePeer(). This makes removePeer() happened twice, and this is the reason we often see "Ethereum peer removal failed, err=peer not registered".

To solve this, removePeer only needs to hard Disconnect peer from networking layer. Then defer unregisterPeer() will do the cleanup task after then.

* fix: modify test function for close testing.

reference from go-thereum.

Co-authored-by: zjubfd <296179868@qq.com>
2022-04-24 14:24:07 +08:00
19 changed files with 1256 additions and 202 deletions

View File

@@ -1,11 +1,30 @@
# Changelog
## v1.1.11
UPGRADE
* [\#927](https://github.com/bnb-chain/bsc/pull/927) add readme for validators about how to enter/exit maintenance
* [\#942](https://github.com/bnb-chain/bsc/pull/942) update the blockNumber of Euler Fork upgrade on BSC Mainnet
## v1.1.10
FEATURE
* [\#885](https://github.com/bnb-chain/bsc/pull/885) add Euler Hardfork, including BEP-127 and BEP-131
BUGFIX
* [\#856](https://github.com/bnb-chain/bsc/pull/856) fix logic issue: handlers.removePeer() is called twice
* [\#860](https://github.com/bnb-chain/bsc/pull/860) fix:defer bloomprocessor close
* [\#877](https://github.com/bnb-chain/bsc/pull/877) fix validator pipecommit issue
* [\#870](https://github.com/bnb-chain/bsc/pull/870) fix:Shift panic for zero length of heads
## v1.1.9
IMPROVEMENT
* [\#792](https://github.com/binance-chain/bsc/pull/792) add shared storage for prefetching state data
* [\#795](https://github.com/binance-chain/bsc/pull/795) implement state verification pipeline in pipecommit
* [\#803](https://github.com/binance-chain/bsc/pull/803) prefetch state data during the mining process
* [\#792](https://github.com/bnb-chain/bsc/pull/792) add shared storage for prefetching state data
* [\#795](https://github.com/bnb-chain/bsc/pull/795) implement state verification pipeline in pipecommit
* [\#803](https://github.com/bnb-chain/bsc/pull/803) prefetch state data during the mining process
* [\#812](https://github.com/bnb-chain/bsc/pull/812) skip verification on account storage root to tolerate with fastnode when doing diffsync
* [\#818](https://github.com/bnb-chain/bsc/pull/818) add shared storage to the prefetcher of miner
* [\#820](https://github.com/bnb-chain/bsc/pull/820) disable diffsync when pipecommit is enabled
@@ -21,195 +40,195 @@ BUGFIX
## v1.1.8
FEATURES
* [\#668](https://github.com/binance-chain/bsc/pull/668) implement State Verification && Snapshot Commit pipeline
* [\#581](https://github.com/binance-chain/bsc/pull/581) implement geth native trace
* [\#543](https://github.com/binance-chain/bsc/pull/543) implement offline block prune tools
* [\#668](https://github.com/bnb-chain/bsc/pull/668) implement State Verification && Snapshot Commit pipeline
* [\#581](https://github.com/bnb-chain/bsc/pull/581) implement geth native trace
* [\#543](https://github.com/bnb-chain/bsc/pull/543) implement offline block prune tools
IMPROVEMENT
* [\#704](https://github.com/binance-chain/bsc/pull/704) prefetch state by applying the transactions within one block
* [\#713](https://github.com/binance-chain/bsc/pull/713) add ARM binaries for release pipeline
* [\#704](https://github.com/bnb-chain/bsc/pull/704) prefetch state by applying the transactions within one block
* [\#713](https://github.com/bnb-chain/bsc/pull/713) add ARM binaries for release pipeline
BUGFIX
* [\#667](https://github.com/binance-chain/bsc/pull/667) trie: reject deletions when verifying range proofs #667
* [\#643](https://github.com/binance-chain/bsc/pull/643) add timeout for stopping p2p server to fix can not gracefully shutdown issue
* [\#740](https://github.com/binance-chain/bsc/pull/740) update discord link which won't expire
* [\#667](https://github.com/bnb-chain/bsc/pull/667) trie: reject deletions when verifying range proofs #667
* [\#643](https://github.com/bnb-chain/bsc/pull/643) add timeout for stopping p2p server to fix can not gracefully shutdown issue
* [\#740](https://github.com/bnb-chain/bsc/pull/740) update discord link which won't expire
## v1.1.7
BUGFIX
* [\#628](https://github.com/binance-chain/bsc/pull/628) fix state inconsistent when doing diffsync
* [\#628](https://github.com/bnb-chain/bsc/pull/628) fix state inconsistent when doing diffsync
## v1.1.6
BUGFIX
* [\#582](https://github.com/binance-chain/bsc/pull/582) the DoS vulnerabilities fixed in go-ethereum v1.10.9
* [\#582](https://github.com/bnb-chain/bsc/pull/582) the DoS vulnerabilities fixed in go-ethereum v1.10.9
IMPROVEMENT
* [\#578](https://github.com/binance-chain/bsc/pull/578) reduce memory allocation and upgrade snappy version
* [\#578](https://github.com/bnb-chain/bsc/pull/578) reduce memory allocation and upgrade snappy version
FEATURES
* [\#570](https://github.com/binance-chain/bsc/pull/570) reannounce local pending transactions
* [\#570](https://github.com/bnb-chain/bsc/pull/570) reannounce local pending transactions
## v1.1.5
BUGFIX
* [\#509](https://github.com/binance-chain/bsc/pull/509) fix graceful shutdown bug
* [\#509](https://github.com/bnb-chain/bsc/pull/509) fix graceful shutdown bug
IMPROVEMENT
* [\#536](https://github.com/binance-chain/bsc/pull/536) get diff accounts by replaying block when diff layer not found
* [\#527](https://github.com/binance-chain/bsc/pull/527) improve diffsync protocol in many aspects
* [\#493](https://github.com/binance-chain/bsc/pull/493) implement fast getDiffAccountsWithScope API
* [\#536](https://github.com/bnb-chain/bsc/pull/536) get diff accounts by replaying block when diff layer not found
* [\#527](https://github.com/bnb-chain/bsc/pull/527) improve diffsync protocol in many aspects
* [\#493](https://github.com/bnb-chain/bsc/pull/493) implement fast getDiffAccountsWithScope API
## v1.1.4
Improvement
* [\#472](https://github.com/binance-chain/bsc/pull/472) add metrics for contract code bitmap cache
* [\#473](https://github.com/binance-chain/bsc/pull/473) fix ci test flow
* [\#472](https://github.com/bnb-chain/bsc/pull/472) add metrics for contract code bitmap cache
* [\#473](https://github.com/bnb-chain/bsc/pull/473) fix ci test flow
BUGFIX
* [\#491](https://github.com/binance-chain/bsc/pull/491) fix prefetcher related bugs
* [\#491](https://github.com/bnb-chain/bsc/pull/491) fix prefetcher related bugs
FEATURES
* [\#480](https://github.com/binance-chain/bsc/pull/480) implement bep 95
* [\#480](https://github.com/bnb-chain/bsc/pull/480) implement bep 95
## v1.1.3
Improvement
* [\#456](https://github.com/binance-chain/bsc/pull/456) git-flow support lint, unit test, and integration test
* [\#449](https://github.com/binance-chain/bsc/pull/449) cache bitmap and change the cache type of GetCode
* [\#454](https://github.com/binance-chain/bsc/pull/454) fix cache key do not have hash func
* [\#446](https://github.com/binance-chain/bsc/pull/446) parallel bloom calculation
* [\#442](https://github.com/binance-chain/bsc/pull/442) ignore empty tx in GetDiffAccountsWithScope
* [\#426](https://github.com/binance-chain/bsc/pull/426) add block proccess backoff time when validator is not in turn and received in turn block
* [\#398](https://github.com/binance-chain/bsc/pull/398) ci pipeline for release page
* [\#456](https://github.com/bnb-chain/bsc/pull/456) git-flow support lint, unit test, and integration test
* [\#449](https://github.com/bnb-chain/bsc/pull/449) cache bitmap and change the cache type of GetCode
* [\#454](https://github.com/bnb-chain/bsc/pull/454) fix cache key do not have hash func
* [\#446](https://github.com/bnb-chain/bsc/pull/446) parallel bloom calculation
* [\#442](https://github.com/bnb-chain/bsc/pull/442) ignore empty tx in GetDiffAccountsWithScope
* [\#426](https://github.com/bnb-chain/bsc/pull/426) add block proccess backoff time when validator is not in turn and received in turn block
* [\#398](https://github.com/bnb-chain/bsc/pull/398) ci pipeline for release page
BUGFIX
* [\#446](https://github.com/binance-chain/bsc/pull/446) fix concurrent write of subfetcher
* [\#444](https://github.com/binance-chain/bsc/pull/444) fix blockhash not correct for the logs of system tx receipt
* [\#409](https://github.com/binance-chain/bsc/pull/409) fix nil point in downloader
* [\#408](https://github.com/binance-chain/bsc/pull/408) core/state/snapshot: fix typo
* [\#446](https://github.com/bnb-chain/bsc/pull/446) fix concurrent write of subfetcher
* [\#444](https://github.com/bnb-chain/bsc/pull/444) fix blockhash not correct for the logs of system tx receipt
* [\#409](https://github.com/bnb-chain/bsc/pull/409) fix nil point in downloader
* [\#408](https://github.com/bnb-chain/bsc/pull/408) core/state/snapshot: fix typo
FEATURES
* [\#431](https://github.com/binance-chain/bsc/pull/431) Export get diff accounts in block api
* [\#412](https://github.com/binance-chain/bsc/pull/412) add extension in eth protocol handshake to disable tx broadcast
* [\#376](https://github.com/binance-chain/bsc/pull/376) implement diff sync
* [\#431](https://github.com/bnb-chain/bsc/pull/431) Export get diff accounts in block api
* [\#412](https://github.com/bnb-chain/bsc/pull/412) add extension in eth protocol handshake to disable tx broadcast
* [\#376](https://github.com/bnb-chain/bsc/pull/376) implement diff sync
## v1.1.2
Security
* [\#379](https://github.com/binance-chain/bsc/pull/379) A pre-announced hotfix release to patch a vulnerability in the EVM (CVE-2021-39137).
* [\#379](https://github.com/bnb-chain/bsc/pull/379) A pre-announced hotfix release to patch a vulnerability in the EVM (CVE-2021-39137).
## v1.1.1
IMPROVEMENT
* [\#355](https://github.com/binance-chain/bsc/pull/355) miner should propose block on a proper fork
* [\#355](https://github.com/bnb-chain/bsc/pull/355) miner should propose block on a proper fork
BUGFIX
* [\#350](https://github.com/binance-chain/bsc/pull/350) flag: fix TriesInmemory specified but not work
* [\#358](https://github.com/binance-chain/bsc/pull/358) miner: fix null pending block
* [\#360](https://github.com/binance-chain/bsc/pull/360) pruner: fix state bloom sync permission in Windows
* [\#366](https://github.com/binance-chain/bsc/pull/366) fix double close channel of subfetcher
* [\#350](https://github.com/bnb-chain/bsc/pull/350) flag: fix TriesInmemory specified but not work
* [\#358](https://github.com/bnb-chain/bsc/pull/358) miner: fix null pending block
* [\#360](https://github.com/bnb-chain/bsc/pull/360) pruner: fix state bloom sync permission in Windows
* [\#366](https://github.com/bnb-chain/bsc/pull/366) fix double close channel of subfetcher
## v1.1.1-beta
* [\#333](https://github.com/binance-chain/bsc/pull/333) improve block fetcher efficiency
* [\#326](https://github.com/binance-chain/bsc/pull/326) eth/tracers: improve tracing performance
* [\#257](https://github.com/binance-chain/bsc/pull/257) performance improvement in many aspects
* [\#333](https://github.com/bnb-chain/bsc/pull/333) improve block fetcher efficiency
* [\#326](https://github.com/bnb-chain/bsc/pull/326) eth/tracers: improve tracing performance
* [\#257](https://github.com/bnb-chain/bsc/pull/257) performance improvement in many aspects
## v1.1.0
* [\#282](https://github.com/binance-chain/bsc/pull/282) update discord link
* [\#280](https://github.com/binance-chain/bsc/pull/280) update discord link
* [\#227](https://github.com/binance-chain/bsc/pull/227) use more aggressive write cache policy
* [\#282](https://github.com/bnb-chain/bsc/pull/282) update discord link
* [\#280](https://github.com/bnb-chain/bsc/pull/280) update discord link
* [\#227](https://github.com/bnb-chain/bsc/pull/227) use more aggressive write cache policy
## v1.1.0-beta
* [\#152](https://github.com/binance-chain/bsc/pull/152) upgrade to go-ethereum 1.10.3
* [\#152](https://github.com/bnb-chain/bsc/pull/152) upgrade to go-ethereum 1.10.3
## v1.0.7-hf.2
BUGFIX
* [\#194](https://github.com/binance-chain/bsc/pull/194) bump btcd to v0.20.1-beta
* [\#194](https://github.com/bnb-chain/bsc/pull/194) bump btcd to v0.20.1-beta
## v1.0.7-hf.1
BUGFIX
* [\#190](https://github.com/binance-chain/bsc/pull/190) fix disk increase dramaticly
* [\#191](https://github.com/binance-chain/bsc/pull/191) fix the reorg routine of tx pool stuck issue
* [\#190](https://github.com/bnb-chain/bsc/pull/190) fix disk increase dramaticly
* [\#191](https://github.com/bnb-chain/bsc/pull/191) fix the reorg routine of tx pool stuck issue
## v1.0.7
* [\#120](https://github.com/binance-chain/bsc/pull/120) add health check endpoint
* [\#116](https://github.com/binance-chain/bsc/pull/116) validator only write database state when enough distance
* [\#115](https://github.com/binance-chain/bsc/pull/115) add batch query methods
* [\#112](https://github.com/binance-chain/bsc/pull/112) apply max commit tx time for miner worker to avoid empty block
* [\#101](https://github.com/binance-chain/bsc/pull/101) apply block number limit for the `eth_getLogs` api
* [\#99](https://github.com/binance-chain/bsc/pull/99) enable directbroadcast flag to decrease the block propagation time
* [\#90](https://github.com/binance-chain/bsc/pull/90) add tini in docker image
* [\#84](https://github.com/binance-chain/bsc/pull/84) add jq in docker image
* [\#120](https://github.com/bnb-chain/bsc/pull/120) add health check endpoint
* [\#116](https://github.com/bnb-chain/bsc/pull/116) validator only write database state when enough distance
* [\#115](https://github.com/bnb-chain/bsc/pull/115) add batch query methods
* [\#112](https://github.com/bnb-chain/bsc/pull/112) apply max commit tx time for miner worker to avoid empty block
* [\#101](https://github.com/bnb-chain/bsc/pull/101) apply block number limit for the `eth_getLogs` api
* [\#99](https://github.com/bnb-chain/bsc/pull/99) enable directbroadcast flag to decrease the block propagation time
* [\#90](https://github.com/bnb-chain/bsc/pull/90) add tini in docker image
* [\#84](https://github.com/bnb-chain/bsc/pull/84) add jq in docker image
## v1.0.6
* [\#68](https://github.com/binance-chain/bsc/pull/68) apply mirror sync upgrade on mainnet
* [\#68](https://github.com/bnb-chain/bsc/pull/68) apply mirror sync upgrade on mainnet
## v1.0.5
SECURITY
* [\#63](https://github.com/binance-chain/bsc/pull/63) security patches from go-ethereum
* [\#54](https://github.com/binance-chain/bsc/pull/54) les: fix GetProofsV2 that could potentially cause a panic.
* [\#63](https://github.com/bnb-chain/bsc/pull/63) security patches from go-ethereum
* [\#54](https://github.com/bnb-chain/bsc/pull/54) les: fix GetProofsV2 that could potentially cause a panic.
FEATURES
* [\#56](https://github.com/binance-chain/bsc/pull/56) apply mirror sync upgrade
* [\#53](https://github.com/binance-chain/bsc/pull/53) support fork id in header; elegant upgrade
* [\#56](https://github.com/bnb-chain/bsc/pull/56) apply mirror sync upgrade
* [\#53](https://github.com/bnb-chain/bsc/pull/53) support fork id in header; elegant upgrade
IMPROVEMENT
* [\#61](https://github.com/binance-chain/bsc/pull/61)Add `x-forward-for` log message when handle message failed
* [\#60](https://github.com/binance-chain/bsc/pull/61) add rpc method request gauge
* [\#61](https://github.com/bnb-chain/bsc/pull/61)Add `x-forward-for` log message when handle message failed
* [\#60](https://github.com/bnb-chain/bsc/pull/61) add rpc method request gauge
BUGFIX
* [\#59](https://github.com/binance-chain/bsc/pull/59) fix potential deadlock of pub/sub module
* [\#59](https://github.com/bnb-chain/bsc/pull/59) fix potential deadlock of pub/sub module
## v1.0.4
IMPROVEMENT
* [\#35](https://github.com/binance-chain/bsc/pull/35) use fixed gas price when network is idle
* [\#38](https://github.com/binance-chain/bsc/pull/38) disable noisy log from consensus engine
* [\#47](https://github.com/binance-chain/bsc/pull/47) upgrade to golang1.15.5
* [\#49](https://github.com/binance-chain/bsc/pull/49) Create pull request template for all developer to follow
* [\#35](https://github.com/bnb-chain/bsc/pull/35) use fixed gas price when network is idle
* [\#38](https://github.com/bnb-chain/bsc/pull/38) disable noisy log from consensus engine
* [\#47](https://github.com/bnb-chain/bsc/pull/47) upgrade to golang1.15.5
* [\#49](https://github.com/bnb-chain/bsc/pull/49) Create pull request template for all developer to follow
## v1.0.3
IMPROVEMENT
* [\#36](https://github.com/binance-chain/bsc/pull/36) add max gas allwance calculation
* [\#36](https://github.com/bnb-chain/bsc/pull/36) add max gas allwance calculation
## v1.0.2
IMPROVEMENT
* [\#29](https://github.com/binance-chain/bsc/pull/29) eth/tracers: revert reason in call_tracer + error for failed internal…
* [\#29](https://github.com/bnb-chain/bsc/pull/29) eth/tracers: revert reason in call_tracer + error for failed internal…
## v1.0.1-beta
IMPROVEMENT
* [\#22](https://github.com/binance-chain/bsc/pull/22) resolve best practice advice
* [\#22](https://github.com/bnb-chain/bsc/pull/22) resolve best practice advice
FEATURES
* [\#23](https://github.com/binance-chain/bsc/pull/23) enforce backoff time for out-turn validator
* [\#23](https://github.com/bnb-chain/bsc/pull/23) enforce backoff time for out-turn validator
BUGFIX
* [\#25](https://github.com/binance-chain/bsc/pull/25) minor fix for ramanujan upgrade
* [\#25](https://github.com/bnb-chain/bsc/pull/25) minor fix for ramanujan upgrade
UPGRADE
* [\#26](https://github.com/binance-chain/bsc/pull/26) update chapel network config for ramanujan fork
* [\#26](https://github.com/bnb-chain/bsc/pull/26) update chapel network config for ramanujan fork
## v1.0.0-beta.0
FEATURES
* [\#5](https://github.com/binance-chain/bsc/pull/5) enable bep2e tokens for faucet
* [\#14](https://github.com/binance-chain/bsc/pull/14) add cross chain contract to system contract
* [\#15](https://github.com/binance-chain/bsc/pull/15) Allow liveness slash fail
* [\#5](https://github.com/bnb-chain/bsc/pull/5) enable bep2e tokens for faucet
* [\#14](https://github.com/bnb-chain/bsc/pull/14) add cross chain contract to system contract
* [\#15](https://github.com/bnb-chain/bsc/pull/15) Allow liveness slash fail
IMPROVEMENT
* [\#11](https://github.com/binance-chain/bsc/pull/11) remove redundant gaslimit check
* [\#11](https://github.com/bnb-chain/bsc/pull/11) remove redundant gaslimit check
BUGFIX
* [\#4](https://github.com/binance-chain/bsc/pull/4) fix validator failed to sync a block produced by itself
* [\#6](https://github.com/binance-chain/bsc/pull/6) modify params for Parlia consensus with 21 validators
* [\#10](https://github.com/binance-chain/bsc/pull/10) add gas limit check in parlia implement
* [\#13](https://github.com/binance-chain/bsc/pull/13) fix debug_traceTransaction crashed issue
* [\#4](https://github.com/bnb-chain/bsc/pull/4) fix validator failed to sync a block produced by itself
* [\#6](https://github.com/bnb-chain/bsc/pull/6) modify params for Parlia consensus with 21 validators
* [\#10](https://github.com/bnb-chain/bsc/pull/10) add gas limit check in parlia implement
* [\#13](https://github.com/bnb-chain/bsc/pull/13) fix debug_traceTransaction crashed issue

View File

@@ -124,7 +124,7 @@ This command will:
Steps:
1. Download the binary, config and genesis files from [release](https://github.com/binance-chain/bsc/releases/download/v1.0.0-alpha.0/binary.zip), or compile the binary by `make geth`.
1. Download the binary, config and genesis files from [release](https://github.com/bnb-chain/bsc/releases/tag/v1.1.11), or compile the binary by `make geth`.
2. Init genesis state: `./geth --datadir node init genesis.json`.
3. Start your fullnode: `./geth --config ./config.toml --datadir ./node`.
4. Or start a validator node: `./geth --config ./config.toml --datadir ./node -unlock ${validatorAddr} --mine --allow-insecure-unlock`. The ${validatorAddr} is the wallet account address of your running validator node.

File diff suppressed because it is too large Load Diff

View File

@@ -616,7 +616,7 @@ func (p *Parlia) Prepare(chain consensus.ChainHeaderReader, header *types.Header
header.Extra = append(header.Extra, nextForkHash[:]...)
if number%p.config.Epoch == 0 {
newValidators, err := p.getCurrentValidators(header.ParentHash)
newValidators, err := p.getCurrentValidators(header.ParentHash, new(big.Int).Sub(header.Number, common.Big1))
if err != nil {
return err
}
@@ -662,7 +662,7 @@ func (p *Parlia) Finalize(chain consensus.ChainHeaderReader, header *types.Heade
// If the block is a epoch end block, verify the validator list
// The verification can only be done when the state is ready, it can't be done in VerifyHeader.
if header.Number.Uint64()%p.config.Epoch == 0 {
newValidators, err := p.getCurrentValidators(header.ParentHash)
newValidators, err := p.getCurrentValidators(header.ParentHash, new(big.Int).Sub(header.Number, common.Big1))
if err != nil {
return err
}
@@ -997,12 +997,15 @@ func (p *Parlia) Close() error {
// ========================== interaction with contract/account =========
// getCurrentValidators get current validators
func (p *Parlia) getCurrentValidators(blockHash common.Hash) ([]common.Address, error) {
func (p *Parlia) getCurrentValidators(blockHash common.Hash, blockNumber *big.Int) ([]common.Address, error) {
// block
blockNr := rpc.BlockNumberOrHashWithHash(blockHash, false)
// method
method := "getValidators"
if p.chainConfig.IsEuler(blockNumber) {
method = "getMiningValidators"
}
ctx, cancel := context.WithCancel(context.Background())
defer cancel() // cancel when we are finished consuming integers

View File

@@ -20,6 +20,7 @@ import (
"fmt"
"time"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/consensus"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
@@ -140,10 +141,8 @@ func (v *BlockValidator) ValidateState(block *types.Block, statedb *state.StateD
if err := statedb.WaitPipeVerification(); err != nil {
return err
}
statedb.CorrectAccountsRoot()
statedb.CorrectAccountsRoot(common.Hash{})
statedb.Finalise(v.config.IsEIP158(header.Number))
// State verification pipeline - accounts root are not calculated here, just populate needed fields for process
statedb.PopulateSnapAccountAndStorage()
return nil
})
} else {

View File

@@ -975,12 +975,23 @@ func (s *StateDB) IntermediateRoot(deleteEmptyObjects bool) common.Hash {
}
//CorrectAccountsRoot will fix account roots in pipecommit mode
func (s *StateDB) CorrectAccountsRoot() {
if accounts, err := s.snap.Accounts(); err == nil && accounts != nil {
func (s *StateDB) CorrectAccountsRoot(blockRoot common.Hash) {
var snapshot snapshot.Snapshot
if blockRoot == (common.Hash{}) {
snapshot = s.snap
} else if s.snaps != nil {
snapshot = s.snaps.Snapshot(blockRoot)
}
if snapshot == nil {
return
}
if accounts, err := snapshot.Accounts(); err == nil && accounts != nil {
for _, obj := range s.stateObjects {
if !obj.deleted && !obj.rootCorrected && obj.data.Root == dummyRoot {
if account, exist := accounts[crypto.Keccak256Hash(obj.address[:])]; exist && len(account.Root) != 0 {
obj.data.Root = common.BytesToHash(account.Root)
obj.rootCorrected = true
}
}
}
@@ -1465,6 +1476,8 @@ func (s *StateDB) Commit(failPostCommitFunc func(), postCommitFuncs ...func() er
}
if s.pipeCommit {
defer close(snapUpdated)
// State verification pipeline - accounts root are not calculated here, just populate needed fields for process
s.PopulateSnapAccountAndStorage()
}
diffLayer.Destructs, diffLayer.Accounts, diffLayer.Storages = s.SnapToDiffLayer()
// Only update if there's a state transition (skip empty Clique blocks)

View File

@@ -127,23 +127,21 @@ func (p *statePrefetcher) PrefetchMining(txs *types.TransactionsByPriceAndNonce,
go func(txset *types.TransactionsByPriceAndNonce) {
count := 0
for {
tx := txset.Peek()
if tx == nil {
return
}
select {
case <-interruptCh:
return
default:
}
if count++; count%checkInterval == 0 {
if *txCurr == nil {
if count++; count%checkInterval == 0 {
txset.Forward(*txCurr)
}
tx := txset.Peek()
if tx == nil {
return
}
txset.Forward(*txCurr)
txCh <- tx
txset.Shift()
}
txCh <- tx
txset.Shift()
}
}(txs)
}

View File

@@ -410,6 +410,7 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg
for i, tx := range block.Transactions() {
if isPoSA {
if isSystemTx, err := posa.IsSystemTransaction(tx, block.Header()); err != nil {
bloomProcessors.Close()
return statedb, nil, nil, 0, err
} else if isSystemTx {
systemTxs = append(systemTxs, tx)
@@ -419,11 +420,13 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg
msg, err := tx.AsMessage(signer)
if err != nil {
bloomProcessors.Close()
return statedb, nil, nil, 0, err
}
statedb.Prepare(tx.Hash(), block.Hash(), i)
receipt, err := applyTransaction(msg, p.config, p.bc, nil, gp, statedb, header, tx, usedGas, vmenv, bloomProcessors)
if err != nil {
bloomProcessors.Close()
return statedb, nil, nil, 0, fmt.Errorf("could not apply tx %d [%v]: %w", i, tx.Hash().Hex(), err)
}

File diff suppressed because one or more lines are too long

View File

@@ -506,7 +506,9 @@ func (t *TransactionsByPriceAndNonce) CurrentSize() int {
//Forward moves current transaction to be the one which is one index after tx
func (t *TransactionsByPriceAndNonce) Forward(tx *Transaction) {
if tx == nil {
t.heads = t.heads[0:0]
if len(t.heads) > 0 {
t.heads = t.heads[0:0]
}
return
}
//check whether target tx exists in t.heads

View File

@@ -392,7 +392,7 @@ func TestTransactionForward(t *testing.T) {
}
tmp := txset.Copy()
for j := 0; j < 10; j++ {
for j := 0; j < 11; j++ {
txset = tmp.Copy()
txsetCpy = tmp.Copy()
i := 0
@@ -400,6 +400,9 @@ func TestTransactionForward(t *testing.T) {
txset.Shift()
}
tx := txset.Peek()
if tx == nil {
continue
}
txsetCpy.Forward(tx)
txCpy := txsetCpy.Peek()
if txCpy == nil {

View File

@@ -0,0 +1,47 @@
## BEP-127: Temporary Maintenance Mode for Validators
Temporary Maintenance is supposed to last one or a few hours. The validator seat will be temporarily dropped from the block producing rotation during the maintenance. Since long-time offline maintenance is not encouraged, the validator will still be slashed if the maintenance lasts too long. To lower the impact from poorly-operating validators who forget to claim its maintenance, they will be forced to enter Temporary Maintenance mode too.
- **enterMaintenance**: Validator can claim itself to enter scheduled maintenance by sending a transaction signed by the consensus key.
- **exitMaintenance**: The validator can claim itself to exit maintenance by sending another transaction.
More details in [BEP-127](https://github.com/bnb-chain/BEPs/blob/master/BEP127.md).
## How to enter/exit maintenance
### Running `geth`
make sure you have unlocked the consensus address of your validator
### Running `built-in interactive`
```shell
$ geth attach geth.ipc
```
This command will:
* Start up `geth`'s built-in interactive [JavaScript console](https://geth.ethereum.org/docs/interface/javascript-console),
(via the trailing `console` subcommand) through which you can interact using [`web3` methods](https://web3js.readthedocs.io/en/)
(note: the `web3` version bundled within `geth` is very old, and not up to date with official docs),
as well as `geth`'s own [management APIs](https://geth.ethereum.org/docs/rpc/server).
### enter maintenance
```
web3.eth.sendTransaction({
from: "consensus address of your validator",
to: "0x0000000000000000000000000000000000001000",
data: "0x9369d7de"
})
```
### exit maintenance
```
web3.eth.sendTransaction({
from: "consensus address of your validator",
to: "0x0000000000000000000000000000000000001000",
data: "0x04c4fec6"
})
```

View File

@@ -83,6 +83,7 @@ func generateTestChainWithFork(n int, fork int) (*core.Genesis, []*types.Block,
NielsBlock: big.NewInt(0),
MirrorSyncBlock: big.NewInt(0),
BrunoBlock: big.NewInt(0),
EulerBlock: big.NewInt(0),
Ethash: new(params.EthashConfig),
}

View File

@@ -313,7 +313,7 @@ func (h *handler) runEthPeer(peer *eth.Peer, handler eth.Handler) error {
peer.Log().Error("Ethereum peer registration failed", "err", err)
return err
}
defer h.removePeer(peer.ID())
defer h.unregisterPeer(peer.ID())
p := h.peers.peer(peer.ID())
if p == nil {
@@ -395,9 +395,17 @@ func (h *handler) runDiffExtension(peer *diff.Peer, handler diff.Handler) error
return handler(peer)
}
// removePeer unregisters a peer from the downloader and fetchers, removes it from
// the set of tracked peers and closes the network connection to it.
// removePeer requests disconnection of a peer.
func (h *handler) removePeer(id string) {
peer := h.peers.peer(id)
if peer != nil {
// Hard disconnect at the networking layer. Handler will get an EOF and terminate the peer. defer unregisterPeer will do the cleanup task after then.
peer.Peer.Disconnect(p2p.DiscUselessPeer)
}
}
// unregisterPeer removes a peer from the downloader, fetchers and main peer set.
func (h *handler) unregisterPeer(id string) {
// Create a custom logger to avoid printing the entire id
var logger log.Logger
if len(id) < 16 {
@@ -425,8 +433,6 @@ func (h *handler) removePeer(id string) {
if err := h.peers.unregisterPeer(id); err != nil {
logger.Error("Ethereum peer removal failed", "err", err)
}
// Hard disconnect at the networking layer
peer.Peer.Disconnect(p2p.DiscUselessPeer)
}
func (h *handler) Start(maxPeers int) {

View File

@@ -641,14 +641,20 @@ func testCheckpointChallenge(t *testing.T, syncmode downloader.SyncMode, checkpo
defer p2pLocal.Close()
defer p2pRemote.Close()
local := eth.NewPeer(eth.ETH65, p2p.NewPeer(enode.ID{1}, "", nil), p2pLocal, handler.txpool)
remote := eth.NewPeer(eth.ETH65, p2p.NewPeer(enode.ID{2}, "", nil), p2pRemote, handler.txpool)
local := eth.NewPeer(eth.ETH65, p2p.NewPeerPipe(enode.ID{1}, "", nil, p2pLocal), p2pLocal, handler.txpool)
remote := eth.NewPeer(eth.ETH65, p2p.NewPeerPipe(enode.ID{2}, "", nil, p2pRemote), p2pRemote, handler.txpool)
defer local.Close()
defer remote.Close()
go handler.handler.runEthPeer(local, func(peer *eth.Peer) error {
return eth.Handle((*ethHandler)(handler.handler), peer)
})
handlerDone := make(chan struct{})
go func() {
defer close(handlerDone)
handler.handler.runEthPeer(local, func(peer *eth.Peer) error {
err := eth.Handle((*ethHandler)(handler.handler), peer)
return err
})
}()
// Run the handshake locally to avoid spinning up a remote handler
var (
genesis = handler.chain.Genesis()
@@ -685,6 +691,7 @@ func testCheckpointChallenge(t *testing.T, syncmode downloader.SyncMode, checkpo
// Verify that the remote peer is maintained or dropped
if drop {
<-handlerDone
if peers := handler.handler.peers.len(); peers != 0 {
t.Fatalf("peer count mismatch: have %d, want %d", peers, 0)
}

View File

@@ -761,7 +761,12 @@ func (w *worker) commitTransactions(txs *types.TransactionsByPriceAndNonce, coin
if w.current.gasPool == nil {
w.current.gasPool = new(core.GasPool).AddGas(w.current.header.GasLimit)
w.current.gasPool.SubGas(params.SystemTxsGas)
if w.chain.Config().IsEuler(w.current.header.Number) {
w.current.gasPool.SubGas(params.SystemTxsGas * 3)
} else {
w.current.gasPool.SubGas(params.SystemTxsGas)
}
}
var coalescedLogs []*types.Log
@@ -1009,6 +1014,9 @@ func (w *worker) commit(uncles []*types.Header, interval func(), update bool, st
if err != nil {
return err
}
s.CorrectAccountsRoot(w.chain.CurrentBlock().Root())
block, receipts, err := w.engine.FinalizeAndAssemble(w.chain, types.CopyHeader(w.current.header), s, w.current.txs, uncles, w.current.receipts)
if err != nil {
return err

View File

@@ -116,7 +116,8 @@ type Peer struct {
disc chan DiscReason
// events receives message send / receive events if set
events *event.Feed
events *event.Feed
testPipe *MsgPipeRW // for testing
}
// NewPeer returns a peer for testing purposes.
@@ -129,6 +130,15 @@ func NewPeer(id enode.ID, name string, caps []Cap) *Peer {
return peer
}
// NewPeerPipe creates a peer for testing purposes.
// The message pipe given as the last parameter is closed when
// Disconnect is called on the peer.
func NewPeerPipe(id enode.ID, name string, caps []Cap, pipe *MsgPipeRW) *Peer {
p := NewPeer(id, name, caps)
p.testPipe = pipe
return p
}
// NewPeerWithProtocols returns a peer for testing purposes.
func NewPeerWithProtocols(id enode.ID, protocols []Protocol, name string, caps []Cap) *Peer {
pipe, _ := net.Pipe()
@@ -196,6 +206,10 @@ func (p *Peer) LocalAddr() net.Addr {
// Disconnect terminates the peer connection with the given reason.
// It returns immediately and does not wait until the connection is closed.
func (p *Peer) Disconnect(reason DiscReason) {
if p.testPipe != nil {
p.testPipe.Close()
}
select {
case p.disc <- reason:
case <-p.closed:

View File

@@ -34,7 +34,7 @@ var (
BSCGenesisHash = common.HexToHash("0x0d21840abff46b96c84b2ac9e10e4f5cdaeb5693cb665db62a2f3b02d2d57b5b")
ChapelGenesisHash = common.HexToHash("0x6d3c66c5357ec91d5c43af47e234a939b22557cbb552dc45bebbceeed90fbe34")
RialtoGenesisHash = common.HexToHash("0xaabe549bfa85c84f7aee9da7010b97453ad686f2c2d8ce00503d1a00c72cad54")
RialtoGenesisHash = common.HexToHash("0xee835a629f9cf5510b48b6ba41d69e0ff7d6ef10f977166ef939db41f59f5501")
YoloV3GenesisHash = common.HexToHash("0xf1f2876e8500c77afcc03228757b39477eceffccf645b734967fe3c7e16967b7")
)
@@ -76,6 +76,7 @@ var (
NielsBlock: big.NewInt(0),
MirrorSyncBlock: big.NewInt(0),
BrunoBlock: big.NewInt(0),
EulerBlock: big.NewInt(0),
BerlinBlock: big.NewInt(12_244_000),
Ethash: new(EthashConfig),
}
@@ -120,6 +121,7 @@ var (
NielsBlock: big.NewInt(0),
MirrorSyncBlock: big.NewInt(0),
BrunoBlock: big.NewInt(0),
EulerBlock: big.NewInt(0),
BerlinBlock: big.NewInt(9_812_189),
Ethash: new(EthashConfig),
}
@@ -164,6 +166,7 @@ var (
NielsBlock: big.NewInt(0),
MirrorSyncBlock: big.NewInt(0),
BrunoBlock: big.NewInt(0),
EulerBlock: big.NewInt(0),
BerlinBlock: big.NewInt(8_290_928),
Clique: &CliqueConfig{
Period: 15,
@@ -207,6 +210,7 @@ var (
NielsBlock: big.NewInt(0),
MirrorSyncBlock: big.NewInt(0),
BrunoBlock: big.NewInt(0),
EulerBlock: big.NewInt(0),
IstanbulBlock: big.NewInt(1_561_651),
MuirGlacierBlock: nil,
BerlinBlock: big.NewInt(4_460_644),
@@ -251,6 +255,8 @@ var (
NielsBlock: big.NewInt(0),
MirrorSyncBlock: big.NewInt(5184000),
BrunoBlock: big.NewInt(13082000),
EulerBlock: big.NewInt(18907621),
Parlia: &ParliaConfig{
Period: 3,
Epoch: 200,
@@ -272,6 +278,8 @@ var (
NielsBlock: big.NewInt(1014369),
MirrorSyncBlock: big.NewInt(5582500),
BrunoBlock: big.NewInt(13837000),
EulerBlock: big.NewInt(19203503),
Parlia: &ParliaConfig{
Period: 3,
Epoch: 200,
@@ -293,6 +301,8 @@ var (
NielsBlock: big.NewInt(0),
MirrorSyncBlock: big.NewInt(400),
BrunoBlock: big.NewInt(400),
EulerBlock: nil,
Parlia: &ParliaConfig{
Period: 3,
Epoch: 200,
@@ -316,6 +326,7 @@ var (
NielsBlock: big.NewInt(0),
MirrorSyncBlock: big.NewInt(0),
BrunoBlock: big.NewInt(0),
EulerBlock: big.NewInt(0),
MuirGlacierBlock: nil,
BerlinBlock: nil, // Don't enable Berlin directly, we're YOLOing it
YoloV3Block: big.NewInt(0),
@@ -330,16 +341,16 @@ var (
//
// This configuration is intentionally not using keyed fields to force anyone
// adding flags to the config to also have to set these fields.
AllEthashProtocolChanges = &ChainConfig{big.NewInt(1337), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, nil, nil, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), new(EthashConfig), nil, nil}
AllEthashProtocolChanges = &ChainConfig{big.NewInt(1337), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, nil, nil, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), new(EthashConfig), nil, nil}
// AllCliqueProtocolChanges contains every protocol change (EIPs) introduced
// and accepted by the Ethereum core developers into the Clique consensus.
//
// This configuration is intentionally not using keyed fields to force anyone
// adding flags to the config to also have to set these fields.
AllCliqueProtocolChanges = &ChainConfig{big.NewInt(1337), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, nil, nil, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, &CliqueConfig{Period: 0, Epoch: 30000}, nil}
AllCliqueProtocolChanges = &ChainConfig{big.NewInt(1337), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, nil, nil, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, &CliqueConfig{Period: 0, Epoch: 30000}, nil}
TestChainConfig = &ChainConfig{big.NewInt(1), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, nil, nil, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), new(EthashConfig), nil, nil}
TestChainConfig = &ChainConfig{big.NewInt(1), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, nil, nil, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), new(EthashConfig), nil, nil}
TestRules = TestChainConfig.Rules(new(big.Int))
)
@@ -427,6 +438,7 @@ type ChainConfig struct {
NielsBlock *big.Int `json:"nielsBlock,omitempty" toml:",omitempty"` // nielsBlock switch block (nil = no fork, 0 = already activated)
MirrorSyncBlock *big.Int `json:"mirrorSyncBlock,omitempty" toml:",omitempty"` // mirrorSyncBlock switch block (nil = no fork, 0 = already activated)
BrunoBlock *big.Int `json:"brunoBlock,omitempty" toml:",omitempty"` // brunoBlock switch block (nil = no fork, 0 = already activated)
EulerBlock *big.Int `json:"eulerBlock,omitempty" toml:",omitempty"` // eulerBlock switch block (nil = no fork, 0 = already activated)
// Various consensus engines
Ethash *EthashConfig `json:"ethash,omitempty" toml:",omitempty"`
@@ -477,7 +489,7 @@ func (c *ChainConfig) String() string {
default:
engine = "unknown"
}
return fmt.Sprintf("{ChainID: %v Homestead: %v DAO: %v DAOSupport: %v EIP150: %v EIP155: %v EIP158: %v Byzantium: %v Constantinople: %v Petersburg: %v Istanbul: %v, Muir Glacier: %v, Ramanujan: %v, Niels: %v, MirrorSync: %v, Bruno: %v, Berlin: %v, YOLO v3: %v, Engine: %v}",
return fmt.Sprintf("{ChainID: %v Homestead: %v DAO: %v DAOSupport: %v EIP150: %v EIP155: %v EIP158: %v Byzantium: %v Constantinople: %v Petersburg: %v Istanbul: %v, Muir Glacier: %v, Ramanujan: %v, Niels: %v, MirrorSync: %v, Bruno: %v, Berlin: %v, YOLO v3: %v, Euler: %v, Engine: %v}",
c.ChainID,
c.HomesteadBlock,
c.DAOForkBlock,
@@ -496,6 +508,7 @@ func (c *ChainConfig) String() string {
c.BrunoBlock,
c.BerlinBlock,
c.YoloV3Block,
c.EulerBlock,
engine,
)
}
@@ -575,6 +588,16 @@ func (c *ChainConfig) IsOnBruno(num *big.Int) bool {
return configNumEqual(c.BrunoBlock, num)
}
// IsEuler returns whether num is either equal to the euler fork block or greater.
func (c *ChainConfig) IsEuler(num *big.Int) bool {
return isForked(c.EulerBlock, num)
}
// IsOnEuler returns whether num is equal to the euler fork block
func (c *ChainConfig) IsOnEuler(num *big.Int) bool {
return configNumEqual(c.EulerBlock, num)
}
// IsMuirGlacier returns whether num is either equal to the Muir Glacier (EIP-2384) fork block or greater.
func (c *ChainConfig) IsMuirGlacier(num *big.Int) bool {
return isForked(c.MuirGlacierBlock, num)
@@ -637,6 +660,7 @@ func (c *ChainConfig) CheckConfigForkOrder() error {
for _, cur := range []fork{
{name: "mirrorSyncBlock", block: c.MirrorSyncBlock},
{name: "brunoBlock", block: c.BrunoBlock},
{name: "eulerBlock", block: c.EulerBlock},
{name: "berlinBlock", block: c.BerlinBlock},
} {
if lastFork.name != "" {
@@ -719,6 +743,9 @@ func (c *ChainConfig) checkCompatible(newcfg *ChainConfig, head *big.Int) *Confi
if isForkIncompatible(c.BrunoBlock, newcfg.BrunoBlock, head) {
return newCompatError("bruno fork block", c.BrunoBlock, newcfg.BrunoBlock)
}
if isForkIncompatible(c.EulerBlock, newcfg.EulerBlock, head) {
return newCompatError("euler fork block", c.EulerBlock, newcfg.EulerBlock)
}
return nil
}

View File

@@ -23,7 +23,7 @@ import (
const (
VersionMajor = 1 // Major version component of the current release
VersionMinor = 1 // Minor version component of the current release
VersionPatch = 9 // Patch version component of the current release
VersionPatch = 11 // Patch version component of the current release
VersionMeta = "" // Version metadata to append to the version string
)