Skip to content

Commit 743ca54

Browse files
sunny2022dawelkin22
authored andcommitted
pevm: remove the ParallelLegacy (bnb-chain#201)
1 parent 9c7bd05 commit 743ca54

File tree

12 files changed

+6
-4056
lines changed

12 files changed

+6
-4056
lines changed

cmd/geth/main.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,6 @@ var (
169169
utils.RollupComputePendingBlock,
170170
utils.RollupHaltOnIncompatibleProtocolVersionFlag,
171171
utils.RollupSuperchainUpgradesFlag,
172-
utils.ParallelTxLegacyFlag,
173172
utils.ParallelTxFlag,
174173
utils.ParallelTxUnorderedMergeFlag,
175174
utils.ParallelTxNumFlag,

cmd/utils/flags.go

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import (
2929
"net/http"
3030
"os"
3131
"path/filepath"
32-
"runtime"
3332
godebug "runtime/debug"
3433
"strconv"
3534
"strings"
@@ -1095,12 +1094,6 @@ Please note that --` + MetricsHTTPFlag.Name + ` must be set to start the server.
10951094
Category: flags.MetricsCategory,
10961095
}
10971096

1098-
ParallelTxLegacyFlag = &cli.BoolFlag{
1099-
Name: "parallel-legacy",
1100-
Usage: "Enable the experimental parallel transaction execution mode, only valid in full sync mode (default = false)",
1101-
Category: flags.VMCategory,
1102-
}
1103-
11041097
ParallelTxFlag = &cli.BoolFlag{
11051098
Name: "parallel",
11061099
Usage: "Enable the experimental parallel transaction execution mode, only valid in full sync mode (default = false)",
@@ -2029,37 +2022,12 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
20292022
cfg.EnablePreimageRecording = ctx.Bool(VMEnableDebugFlag.Name)
20302023
}
20312024

2032-
if ctx.IsSet(ParallelTxLegacyFlag.Name) {
2033-
cfg.ParallelTxLegacyMode = ctx.Bool(ParallelTxLegacyFlag.Name)
2034-
// The best parallel num will be tuned later, we do a simple parallel num set here
2035-
numCpu := runtime.NumCPU()
2036-
var parallelNum int
2037-
if ctx.IsSet(ParallelTxNumFlag.Name) {
2038-
// Use value set by "--parallel.num", and "--parallel.num 0" is not allowed and be set to 1
2039-
parallelNum = ctx.Int(ParallelTxNumFlag.Name)
2040-
if parallelNum < 1 {
2041-
parallelNum = 1
2042-
}
2043-
} else if numCpu == 1 {
2044-
parallelNum = 1 // single CPU core
2045-
} else {
2046-
// 1-2 core for merge (with parallel KV check)
2047-
// 1-2 core for others (bc optimizer, main)
2048-
// 1-2 core for possible other concurrent routine
2049-
parallelNum = max(1, numCpu-6)
2050-
}
2051-
cfg.ParallelTxNum = parallelNum
2052-
}
2053-
20542025
if ctx.IsSet(ParallelTxFlag.Name) {
20552026
cfg.ParallelTxMode = ctx.Bool(ParallelTxFlag.Name)
20562027
}
20572028

20582029
if ctx.IsSet(ParallelTxUnorderedMergeFlag.Name) {
20592030
cfg.ParallelTxUnorderedMerge = ctx.Bool(ParallelTxUnorderedMergeFlag.Name)
2060-
if ctx.IsSet(ParallelTxLegacyFlag.Name) && ctx.Bool(ParallelTxLegacyFlag.Name) {
2061-
log.Warn("ParallelTxUnorderedMergeFlag does not have any effect in ParallelTxLegacy mode")
2062-
}
20632031
}
20642032

20652033
if ctx.IsSet(ParallelTxDAGFlag.Name) {

core/blockchain.go

Lines changed: 3 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -535,11 +535,7 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, genesis *Genesis
535535
bc.snaps, _ = snapshot.New(snapconfig, bc.db, bc.triedb, head.Root)
536536
}
537537

538-
if bc.vmConfig.EnableParallelExecLegacy {
539-
bc.CreateParallelProcessor(bc.vmConfig.ParallelTxNum)
540-
bc.CreateSerialProcessor(chainConfig, bc, engine)
541-
log.Info("Parallel V1 enabled", "parallelNum", bc.vmConfig.ParallelTxNum)
542-
} else if bc.vmConfig.EnableParallelExec {
538+
if bc.vmConfig.EnableParallelExec {
543539
bc.processor = newPEVMProcessor(chainConfig, bc, engine)
544540
log.Info("Parallel V2 enabled", "parallelNum", ParallelNum())
545541
} else {
@@ -1915,20 +1911,6 @@ func (bc *BlockChain) insertChain(chain types.Blocks, setHead bool) (int, error)
19151911
statedb.StartPrefetcher("chain")
19161912
activeState = statedb
19171913

1918-
if bc.vmConfig.EnableParallelExecLegacy {
1919-
bc.parseTxDAG(block)
1920-
txsCount := block.Transactions().Len()
1921-
threshold := min(bc.vmConfig.ParallelTxNum/2+2, 4)
1922-
if bc.vmConfig.ParallelTxNum < 2 || txsCount < threshold || bc.isEmptyTxDAG() {
1923-
bc.UseSerialProcessor()
1924-
log.Debug("Disable Parallel Tx execution", "block", block.NumberU64(), "transactions", txsCount, "parallelTxNum", bc.vmConfig.ParallelTxNum)
1925-
} else {
1926-
bc.UseParallelProcessor()
1927-
log.Debug("Enable Parallel Tx execution", "block", block.NumberU64(), "transactions", txsCount, "parallelTxNum", bc.vmConfig.ParallelTxNum)
1928-
1929-
}
1930-
}
1931-
19321914
if bc.vmConfig.EnableParallelExec {
19331915
bc.parseTxDAG(block)
19341916
}
@@ -1955,10 +1937,6 @@ func (bc *BlockChain) insertChain(chain types.Blocks, setHead bool) (int, error)
19551937
// Process block using the parent state as reference point
19561938
pstart = time.Now()
19571939
receipts, logs, usedGas, err = bc.processor.Process(block, statedb, bc.vmConfig)
1958-
if err == FallbackToSerialProcessorErr {
1959-
bc.UseSerialProcessor()
1960-
receipts, logs, usedGas, err = bc.processor.Process(block, statedb, bc.vmConfig)
1961-
}
19621940
if err != nil {
19631941
bc.reportBlock(block, receipts, err)
19641942
followupInterrupt.Store(true)
@@ -1977,7 +1955,7 @@ func (bc *BlockChain) insertChain(chain types.Blocks, setHead bool) (int, error)
19771955
vtime := time.Since(vstart)
19781956
proctime := time.Since(start) // processing + validation
19791957

1980-
if bc.enableTxDAG && !bc.vmConfig.EnableParallelExecLegacy && !bc.vmConfig.EnableParallelExec {
1958+
if bc.enableTxDAG && !bc.vmConfig.EnableParallelExec {
19811959
// compare input TxDAG when it enable in consensus
19821960
dag, err := statedb.ResolveTxDAG(len(block.Transactions()), []common.Address{block.Coinbase(), params.OptimismBaseFeeRecipient, params.OptimismL1FeeRecipient})
19831961
if err == nil {
@@ -2715,14 +2693,6 @@ func (bc *BlockChain) GetTrieFlushInterval() time.Duration {
27152693
return time.Duration(bc.flushInterval.Load())
27162694
}
27172695

2718-
func (bc *BlockChain) CreateParallelProcessor(parallelNum int) *BlockChain {
2719-
if bc.parallelProcessor == nil {
2720-
bc.parallelProcessor = newParallelStateProcessor(bc.Config(), bc, bc.engine, parallelNum)
2721-
bc.parallelExecution = true
2722-
}
2723-
return bc
2724-
}
2725-
27262696
func (bc *BlockChain) NoTries() bool {
27272697
return bc.stateCache.NoTries()
27282698
}
@@ -2755,7 +2725,7 @@ func (bc *BlockChain) HeaderChainForceSetHead(headNumber uint64) {
27552725
}
27562726

27572727
func (bc *BlockChain) TxDAGEnabledWhenMine() bool {
2758-
return bc.enableTxDAG && bc.txDAGWriteCh == nil && bc.txDAGReader == nil && !bc.vmConfig.EnableParallelExec && !bc.vmConfig.EnableParallelExecLegacy
2728+
return bc.enableTxDAG && bc.txDAGWriteCh == nil && bc.txDAGReader == nil && !bc.vmConfig.EnableParallelExec
27592729
}
27602730

27612731
func (bc *BlockChain) SetupTxDAGGeneration(output string, readFile bool) {
@@ -2803,25 +2773,6 @@ func (bc *BlockChain) SetupTxDAGGeneration(output string, readFile bool) {
28032773
}()
28042774
}
28052775

2806-
func (bc *BlockChain) UseParallelProcessor() {
2807-
if bc.parallelProcessor != nil {
2808-
bc.parallelExecution = true
2809-
bc.processor = bc.parallelProcessor
2810-
} else {
2811-
log.Error("bc.ParallelProcessor is nil! fallback to serial processor!")
2812-
bc.UseSerialProcessor()
2813-
}
2814-
}
2815-
2816-
func (bc *BlockChain) UseSerialProcessor() {
2817-
if bc.serialProcessor != nil {
2818-
bc.parallelExecution = false
2819-
bc.processor = bc.serialProcessor
2820-
} else {
2821-
bc.CreateSerialProcessor(bc.chainConfig, bc, bc.engine)
2822-
}
2823-
}
2824-
28252776
type TxDAGOutputItem struct {
28262777
blockNumber uint64
28272778
txDAG types.TxDAG

0 commit comments

Comments
 (0)