From f7e9adc2c87787ed6e42d79d5b64cc9a1007fb0a Mon Sep 17 00:00:00 2001 From: "larry.lx" Date: Wed, 29 Nov 2023 12:37:43 +0800 Subject: [PATCH 1/9] fix: remove sharedPool --- CHANGELOG.md | 4 ++++ core/state_prefetcher.go | 8 ++++++-- params/version.go | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ca6c99957..36dbe9b34 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,8 @@ # Changelog +## v1.3.2 +BUGFIX +fix: remove sharedPool + ## v1.3.1 FEATURE * [\#1881](https://github.com/bnb-chain/bsc/pull/1881) feat: active pbss diff --git a/core/state_prefetcher.go b/core/state_prefetcher.go index f1bb60feb..12e90998f 100644 --- a/core/state_prefetcher.go +++ b/core/state_prefetcher.go @@ -59,7 +59,9 @@ func (p *statePrefetcher) Prefetch(block *types.Block, statedb *state.StateDB, c for i := 0; i < prefetchThread; i++ { go func() { newStatedb := statedb.CopyDoPrefetch() - newStatedb.EnableWriteOnSharedStorage() + if header.Number.Uint64() < 33968300 { + newStatedb.EnableWriteOnSharedStorage() + } gaspool := new(GasPool).AddGas(block.GasLimit()) blockContext := NewEVMBlockContext(header, p.bc, nil) evm := vm.NewEVM(blockContext, vm.TxContext{}, statedb, p.config, *cfg) @@ -106,7 +108,9 @@ func (p *statePrefetcher) PrefetchMining(txs TransactionsByPriceAndNonce, header go func(startCh <-chan *types.Transaction, stopCh <-chan struct{}) { idx := 0 newStatedb := statedb.CopyDoPrefetch() - newStatedb.EnableWriteOnSharedStorage() + if header.Number.Uint64() < 33968300 { + newStatedb.EnableWriteOnSharedStorage() + } gaspool := new(GasPool).AddGas(gasLimit) blockContext := NewEVMBlockContext(header, p.bc, nil) evm := vm.NewEVM(blockContext, vm.TxContext{}, statedb, p.config, cfg) diff --git a/params/version.go b/params/version.go index 4f356fe34..b0aa560d4 100644 --- a/params/version.go +++ b/params/version.go @@ -23,7 +23,7 @@ import ( const ( VersionMajor = 1 // Major version component of the current release VersionMinor = 3 // Minor version component of the current release - VersionPatch = 1 // Patch version component of the current release + VersionPatch = 2 // Patch version component of the current release VersionMeta = "" // Version metadata to append to the version string ) From b494339e1052316ecc451a5ae28c258b2cc13abd Mon Sep 17 00:00:00 2001 From: Ng Wei Han <47109095+weiihann@users.noreply.github.com> Date: Tue, 14 Nov 2023 20:10:41 +0800 Subject: [PATCH 2/9] fix(cmd): check pruneancient when creating db (#1986) --- cmd/utils/flags.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 36455d86b..7c6ce0e6c 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -2355,7 +2355,7 @@ func tryMakeReadOnlyDatabase(ctx *cli.Context, stack *node.Node) ethdb.Database // If datadir doesn't exist we need to open db in write-mode // so database engine can create files. readonly := true - if !common.FileExist(stack.ResolvePath("chaindata")) { + if !common.FileExist(stack.ResolvePath("chaindata")) || ctx.Bool(PruneAncientDataFlag.Name) { readonly = false } return MakeChainDatabase(ctx, stack, readonly, false) From a3507cc2c119add44f4a22f5d62634a69fd17886 Mon Sep 17 00:00:00 2001 From: Ng Wei Han <47109095+weiihann@users.noreply.github.com> Date: Sat, 25 Nov 2023 20:57:23 +0800 Subject: [PATCH 3/9] cmd/utils: exit process if txlookuplimit flag is set (#2000) --- README.md | 5 ++--- cmd/utils/flags.go | 6 ++---- log/root.go | 2 ++ tests/truffle/scripts/bsc-rpc.sh | 2 +- tests/truffle/scripts/bsc-validator.sh | 2 +- 5 files changed, 8 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index f198c999e..b69995330 100644 --- a/README.md +++ b/README.md @@ -153,11 +153,10 @@ Note: if you can not download the chaindata snapshot and want to sync from genes So just run: `geth --datadir init ./genesis.json` #### 4. Start a full node ```shell -./geth --config ./config.toml --datadir ./node --cache 8000 --rpc.allow-unprotected-txs --txlookuplimit 0 +./geth --config ./config.toml --datadir ./node --cache 8000 --rpc.allow-unprotected-txs --history.transactions 0 ## It is recommand to run fullnode with `--tries-verify-mode none` if you want high performance and care little about state consistency -./geth --config ./config.toml --datadir ./node --cache 8000 --rpc.allow-unprotected-txs --txlookuplimit 0 --tries-verify-mode none -``` +./geth --config ./config.toml --datadir ./node --cache 8000 --rpc.allow-unprotected-txs --history.transactions 0 --tries-verify-mode none #### 5. Monitor node status diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 7c6ce0e6c..406c5f707 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -1948,14 +1948,12 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) { // Parse transaction history flag, if user is still using legacy config // file with 'TxLookupLimit' configured, copy the value to 'TransactionHistory'. if cfg.TransactionHistory == ethconfig.Defaults.TransactionHistory && cfg.TxLookupLimit != ethconfig.Defaults.TxLookupLimit { - log.Warn("The config option 'TxLookupLimit' is deprecated and will be removed, please use 'TransactionHistory'") - cfg.TransactionHistory = cfg.TxLookupLimit + log.Crit("The config option 'TxLookupLimit' is deprecated and may cause unexpected performance degradation issues, please use 'TransactionHistory' instead") } if ctx.IsSet(TransactionHistoryFlag.Name) { cfg.TransactionHistory = ctx.Uint64(TransactionHistoryFlag.Name) } else if ctx.IsSet(TxLookupLimitFlag.Name) { - log.Warn("The flag --txlookuplimit is deprecated and will be removed, please use --history.transactions") - cfg.TransactionHistory = ctx.Uint64(TransactionHistoryFlag.Name) + log.Crit("The flag --txlookuplimit is deprecated and may cause unexpected performance degradation issues. Please use --history.transactions instead") } if ctx.IsSet(PathDBSyncFlag.Name) { cfg.PathSyncFlush = true diff --git a/log/root.go b/log/root.go index 5a41723c3..c8893bf80 100644 --- a/log/root.go +++ b/log/root.go @@ -2,6 +2,7 @@ package log import ( "os" + "time" ) var ( @@ -105,6 +106,7 @@ func Error(msg string, ctx ...interface{}) { // log.Crit("msg", "key1", val1, "key2", val2) func Crit(msg string, ctx ...interface{}) { root.write(msg, LvlCrit, ctx, skipLevel) + time.Sleep(3 * time.Second) os.Exit(1) } diff --git a/tests/truffle/scripts/bsc-rpc.sh b/tests/truffle/scripts/bsc-rpc.sh index 5367b807c..43c811c78 100755 --- a/tests/truffle/scripts/bsc-rpc.sh +++ b/tests/truffle/scripts/bsc-rpc.sh @@ -12,5 +12,5 @@ done geth --config ${DATA_DIR}/config.toml --datadir ${DATA_DIR} --netrestrict ${CLUSTER_CIDR} \ --verbosity ${VERBOSE} --nousb \ - --rpc.allow-unprotected-txs --txlookuplimit 15768000 \ + --rpc.allow-unprotected-txs --history.transactions 15768000 \ -unlock ${unlock_sequences} --password /dev/null diff --git a/tests/truffle/scripts/bsc-validator.sh b/tests/truffle/scripts/bsc-validator.sh index 4605a867a..16b8c2ed5 100755 --- a/tests/truffle/scripts/bsc-validator.sh +++ b/tests/truffle/scripts/bsc-validator.sh @@ -15,4 +15,4 @@ geth --config ${DATA_DIR}/config.toml --datadir ${DATA_DIR} --netrestrict ${CLUS --bootnodes enode://${BOOTSTRAP_PUB_KEY}@${BOOTSTRAP_IP}:${BOOTSTRAP_TCP_PORT} \ --mine -unlock ${VALIDATOR_ADDR} --miner.etherbase ${VALIDATOR_ADDR} --password /dev/null \ --light.serve 50 \ - --rpc.allow-unprotected-txs --txlookuplimit 15768000 + --rpc.allow-unprotected-txs --history.transactions 15768000 From a8409158a5ee7817ae4973c9688e42b298a36b35 Mon Sep 17 00:00:00 2001 From: "larry.lx" Date: Thu, 30 Nov 2023 09:35:50 +0800 Subject: [PATCH 4/9] release: draft v1.3.3 --- CHANGELOG.md | 7 +++++++ params/version.go | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 36dbe9b34..e8c70718a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,11 @@ # Changelog +## v1.3.3 +IMPROVEMENT +* [\#2000](https://github.com/bnb-chain/bsc/pull/2000) cmd/utils: exit process if txlookuplimit flag is set + +BUGFIX +* [\#1986](https://github.com/bnb-chain/bsc/pull/1986) fix(cmd): check pruneancient when creating db + ## v1.3.2 BUGFIX fix: remove sharedPool diff --git a/params/version.go b/params/version.go index b0aa560d4..49a5efbc3 100644 --- a/params/version.go +++ b/params/version.go @@ -23,7 +23,7 @@ import ( const ( VersionMajor = 1 // Major version component of the current release VersionMinor = 3 // Minor version component of the current release - VersionPatch = 2 // Patch version component of the current release + VersionPatch = 3 // Patch version component of the current release VersionMeta = "" // Version metadata to append to the version string ) From 8b00720640aec6f979214a64d82481f9bc9e19e5 Mon Sep 17 00:00:00 2001 From: "larry.lx" Date: Fri, 1 Dec 2023 22:30:16 +0800 Subject: [PATCH 5/9] fix: remove pipecommit in miner --- miner/worker.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/miner/worker.go b/miner/worker.go index ffade84a3..6b4683b14 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -1163,12 +1163,14 @@ func (w *worker) commit(env *environment, interval func(), update bool, start ti if interval != nil { interval() } + /* - err := env.state.WaitPipeVerification() - if err != nil { - return err - } - env.state.CorrectAccountsRoot(w.chain.CurrentBlock().Root) + err := env.state.WaitPipeVerification() + if err != nil { + return err + } + env.state.CorrectAccountsRoot(w.chain.CurrentBlock().Root) + */ // Withdrawals are set to nil here, because this is only called in PoW. finalizeStart := time.Now() From 761563155c788812c777c7230b0690a3083a2ce4 Mon Sep 17 00:00:00 2001 From: "larry.lx" Date: Mon, 4 Dec 2023 10:03:03 +0800 Subject: [PATCH 6/9] fork: add hardfork Hertzfix --- core/state_prefetcher.go | 4 ++-- params/config.go | 45 +++++++++++++++++++++++++++------------- 2 files changed, 33 insertions(+), 16 deletions(-) diff --git a/core/state_prefetcher.go b/core/state_prefetcher.go index 12e90998f..5e616b29e 100644 --- a/core/state_prefetcher.go +++ b/core/state_prefetcher.go @@ -59,7 +59,7 @@ func (p *statePrefetcher) Prefetch(block *types.Block, statedb *state.StateDB, c for i := 0; i < prefetchThread; i++ { go func() { newStatedb := statedb.CopyDoPrefetch() - if header.Number.Uint64() < 33968300 { + if !p.config.IsHertzfix(header.Number) { newStatedb.EnableWriteOnSharedStorage() } gaspool := new(GasPool).AddGas(block.GasLimit()) @@ -108,7 +108,7 @@ func (p *statePrefetcher) PrefetchMining(txs TransactionsByPriceAndNonce, header go func(startCh <-chan *types.Transaction, stopCh <-chan struct{}) { idx := 0 newStatedb := statedb.CopyDoPrefetch() - if header.Number.Uint64() < 33968300 { + if !p.config.IsHertzfix(header.Number) { newStatedb.EnableWriteOnSharedStorage() } gaspool := new(GasPool).AddGas(gasLimit) diff --git a/params/config.go b/params/config.go index fc1f40e6d..93a0b83c1 100644 --- a/params/config.go +++ b/params/config.go @@ -165,10 +165,10 @@ var ( LubanBlock: big.NewInt(29020050), PlatoBlock: big.NewInt(30720096), // TODO modify blockNumber, make sure HertzBlock=BerlinBlock=LondonBlock to enable Berlin and London EIPs - BerlinBlock: big.NewInt(31302048), - LondonBlock: big.NewInt(31302048), - HertzBlock: big.NewInt(31302048), - + BerlinBlock: big.NewInt(31302048), + LondonBlock: big.NewInt(31302048), + HertzBlock: big.NewInt(31302048), + HertzfixBlock: big.NewInt(34140700), Parlia: &ParliaConfig{ Period: 3, Epoch: 200, @@ -201,9 +201,10 @@ var ( LubanBlock: big.NewInt(29295050), PlatoBlock: big.NewInt(29861024), // TODO modify blockNumber, make sure HertzBlock=BerlinBlock=LondonBlock to enable Berlin and London EIPs - BerlinBlock: big.NewInt(31103030), - LondonBlock: big.NewInt(31103030), - HertzBlock: big.NewInt(31103030), + BerlinBlock: big.NewInt(31103030), + LondonBlock: big.NewInt(31103030), + HertzBlock: big.NewInt(31103030), + HertzfixBlock: big.NewInt(35682300), Parlia: &ParliaConfig{ Period: 3, @@ -233,10 +234,11 @@ var ( PlanckBlock: nil, // TODO - LubanBlock: nil, - PlatoBlock: nil, - BerlinBlock: nil, - HertzBlock: nil, + LubanBlock: nil, + PlatoBlock: nil, + BerlinBlock: nil, + HertzBlock: nil, + HertzfixBlock: nil, Parlia: &ParliaConfig{ Period: 3, @@ -269,7 +271,7 @@ var ( BerlinBlock: big.NewInt(0), LondonBlock: big.NewInt(0), HertzBlock: big.NewInt(0), - + HertzfixBlock: big.NewInt(0), Parlia: &ParliaConfig{ Period: 3, Epoch: 200, @@ -483,7 +485,7 @@ type ChainConfig struct { LubanBlock *big.Int `json:"lubanBlock,omitempty" toml:",omitempty"` // lubanBlock switch block (nil = no fork, 0 = already activated) PlatoBlock *big.Int `json:"platoBlock,omitempty" toml:",omitempty"` // platoBlock switch block (nil = no fork, 0 = already activated) HertzBlock *big.Int `json:"hertzBlock,omitempty" toml:",omitempty"` // hertzBlock switch block (nil = no fork, 0 = already activated) - + HertzfixBlock *big.Int `json:"hertzfixBlock,omitempty" toml:",omitempty"` // hertzfixBlock switch block (nil = no fork, 0 = already activated) // Various consensus engines Ethash *EthashConfig `json:"ethash,omitempty" toml:",omitempty"` Clique *CliqueConfig `json:"clique,omitempty" toml:",omitempty"` @@ -540,7 +542,7 @@ func (c *ChainConfig) String() string { 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, CatalystBlock: %v, London: %v, ArrowGlacier: %v, MergeFork:%v, Euler: %v, Gibbs: %v, Nano: %v, Moran: %v, Planck: %v,Luban: %v, Plato: %v, Hertz: %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, CatalystBlock: %v, London: %v, ArrowGlacier: %v, MergeFork:%v, Euler: %v, Gibbs: %v, Nano: %v, Moran: %v, Planck: %v,Luban: %v, Plato: %v, Hertz: %v, Hertzfix: %v, Engine: %v}", c.ChainID, c.HomesteadBlock, c.DAOForkBlock, @@ -571,6 +573,7 @@ func (c *ChainConfig) String() string { c.LubanBlock, c.PlatoBlock, c.HertzBlock, + c.HertzfixBlock, engine, ) } @@ -690,6 +693,14 @@ func (c *ChainConfig) IsOnHertz(num *big.Int) bool { return configBlockEqual(c.HertzBlock, num) } +func (c *ChainConfig) IsHertzfix(num *big.Int) bool { + return isBlockForked(c.HertzfixBlock, num) +} + +func (c *ChainConfig) IsOnHertzfix(num *big.Int) bool { + return configBlockEqual(c.HertzfixBlock, 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 isBlockForked(c.MuirGlacierBlock, num) @@ -837,6 +848,7 @@ func (c *ChainConfig) CheckConfigForkOrder() error { {name: "lubanBlock", block: c.LubanBlock}, {name: "platoBlock", block: c.PlatoBlock}, {name: "hertzBlock", block: c.HertzBlock}, + {name: "hertzfixBlock", block: c.HertzfixBlock}, {name: "shanghaiTime", timestamp: c.ShanghaiTime}, {name: "cancunTime", timestamp: c.CancunTime, optional: true}, {name: "pragueTime", timestamp: c.PragueTime, optional: true}, @@ -968,6 +980,9 @@ func (c *ChainConfig) checkCompatible(newcfg *ChainConfig, headNumber *big.Int, if isForkBlockIncompatible(c.HertzBlock, newcfg.HertzBlock, headNumber) { return newBlockCompatError("hertz fork block", c.HertzBlock, newcfg.HertzBlock) } + if isForkBlockIncompatible(c.HertzfixBlock, newcfg.HertzfixBlock, headNumber) { + return newBlockCompatError("hertzfix fork block", c.HertzfixBlock, newcfg.HertzfixBlock) + } if isForkTimestampIncompatible(c.ShanghaiTime, newcfg.ShanghaiTime, headTimestamp) { return newTimestampCompatError("Shanghai fork timestamp", c.ShanghaiTime, newcfg.ShanghaiTime) } @@ -1131,6 +1146,7 @@ type Rules struct { IsLuban bool IsPlato bool IsHertz bool + IsHertzfix bool IsShanghai, IsCancun, IsPrague bool IsVerkle bool } @@ -1160,6 +1176,7 @@ func (c *ChainConfig) Rules(num *big.Int, isMerge bool, timestamp uint64) Rules IsLuban: c.IsLuban(num), IsPlato: c.IsPlato(num), IsHertz: c.IsHertz(num), + IsHertzfix: c.IsHertzfix(num), IsShanghai: c.IsShanghai(num, timestamp), IsCancun: c.IsCancun(num, timestamp), IsPrague: c.IsPrague(num, timestamp), From a2f9ac0c8bc6e52a1372376b2816940766fc27fc Mon Sep 17 00:00:00 2001 From: "larry.lx" Date: Mon, 4 Dec 2023 11:45:52 +0800 Subject: [PATCH 7/9] release: prepare v1.3.4 --- CHANGELOG.md | 7 ++++++- params/version.go | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e8c70718a..75d36b42c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,9 @@ # Changelog +## v1.3.4 +BUGFIX +* fix: remove pipecommit in miner +* add a hard fork: Hertzfix + ## v1.3.3 IMPROVEMENT * [\#2000](https://github.com/bnb-chain/bsc/pull/2000) cmd/utils: exit process if txlookuplimit flag is set @@ -8,7 +13,7 @@ BUGFIX ## v1.3.2 BUGFIX -fix: remove sharedPool +* fix: remove sharedPool ## v1.3.1 FEATURE diff --git a/params/version.go b/params/version.go index 49a5efbc3..cca396d7c 100644 --- a/params/version.go +++ b/params/version.go @@ -23,7 +23,7 @@ import ( const ( VersionMajor = 1 // Major version component of the current release VersionMinor = 3 // Minor version component of the current release - VersionPatch = 3 // Patch version component of the current release + VersionPatch = 4 // Patch version component of the current release VersionMeta = "" // Version metadata to append to the version string ) From afc3b42241f9b976537f8faa46d7cd2d4d881a28 Mon Sep 17 00:00:00 2001 From: "larry.lx" Date: Mon, 4 Dec 2023 13:02:19 +0800 Subject: [PATCH 8/9] fix: disable flag --pipecommit --- cmd/utils/flags.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 406c5f707..33030bd5d 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -1919,7 +1919,7 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) { cfg.EnableTrustProtocol = ctx.IsSet(EnableTrustProtocolFlag.Name) } if ctx.IsSet(PipeCommitFlag.Name) { - cfg.PipeCommit = ctx.Bool(PipeCommitFlag.Name) + log.Warn("The --pipecommit flag is deprecated and could be removed in the future!") } if ctx.IsSet(RangeLimitFlag.Name) { cfg.RangeLimit = ctx.Bool(RangeLimitFlag.Name) From 885de2c1ca4c8cd73d7c8c6e6dba479015fb585e Mon Sep 17 00:00:00 2001 From: "larry.lx" Date: Mon, 4 Dec 2023 13:56:14 +0800 Subject: [PATCH 9/9] fix: failed ut --- core/eip3529tests/eip3529_parlia_test.go | 1 + eth/gasprice/gasprice_test.go | 1 + 2 files changed, 2 insertions(+) diff --git a/core/eip3529tests/eip3529_parlia_test.go b/core/eip3529tests/eip3529_parlia_test.go index f759a8f88..517b39d05 100644 --- a/core/eip3529tests/eip3529_parlia_test.go +++ b/core/eip3529tests/eip3529_parlia_test.go @@ -19,6 +19,7 @@ func preHertzConfig() *params.ChainConfig { config.LondonBlock = nil config.BerlinBlock = nil config.HertzBlock = nil + config.HertzfixBlock = nil return &config } diff --git a/eth/gasprice/gasprice_test.go b/eth/gasprice/gasprice_test.go index 8835fbb60..fa4159473 100644 --- a/eth/gasprice/gasprice_test.go +++ b/eth/gasprice/gasprice_test.go @@ -146,6 +146,7 @@ func newTestBackend(t *testing.T, londonBlock *big.Int, pending bool) *testBacke config.LubanBlock = nil config.PlatoBlock = nil config.HertzBlock = nil + config.HertzfixBlock = nil config.TerminalTotalDifficulty = common.Big0 engine := ethash.NewFaker()