Skip to content

Commit

Permalink
remove the ParallelLegacy
Browse files Browse the repository at this point in the history
  • Loading branch information
sunny2022da committed Oct 21, 2024
1 parent 2b01ec3 commit fa8d0e8
Show file tree
Hide file tree
Showing 12 changed files with 4 additions and 4,052 deletions.
1 change: 0 additions & 1 deletion cmd/geth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ var (
utils.RollupComputePendingBlock,
utils.RollupHaltOnIncompatibleProtocolVersionFlag,
utils.RollupSuperchainUpgradesFlag,
utils.ParallelTxLegacyFlag,
utils.ParallelTxFlag,
utils.ParallelTxNumFlag,
utils.ParallelTxDAGFlag,
Expand Down
29 changes: 0 additions & 29 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import (
"net/http"
"os"
"path/filepath"
"runtime"
godebug "runtime/debug"
"strconv"
"strings"
Expand Down Expand Up @@ -1095,12 +1094,6 @@ Please note that --` + MetricsHTTPFlag.Name + ` must be set to start the server.
Category: flags.MetricsCategory,
}

ParallelTxLegacyFlag = &cli.BoolFlag{
Name: "parallel-legacy",
Usage: "Enable the experimental parallel transaction execution mode, only valid in full sync mode (default = false)",
Category: flags.VMCategory,
}

ParallelTxFlag = &cli.BoolFlag{
Name: "parallel",
Usage: "Enable the experimental parallel transaction execution mode, only valid in full sync mode (default = false)",
Expand Down Expand Up @@ -2023,28 +2016,6 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
cfg.EnablePreimageRecording = ctx.Bool(VMEnableDebugFlag.Name)
}

if ctx.IsSet(ParallelTxLegacyFlag.Name) {
cfg.ParallelTxLegacyMode = ctx.Bool(ParallelTxLegacyFlag.Name)
// The best parallel num will be tuned later, we do a simple parallel num set here
numCpu := runtime.NumCPU()
var parallelNum int
if ctx.IsSet(ParallelTxNumFlag.Name) {
// Use value set by "--parallel.num", and "--parallel.num 0" is not allowed and be set to 1
parallelNum = ctx.Int(ParallelTxNumFlag.Name)
if parallelNum < 1 {
parallelNum = 1
}
} else if numCpu == 1 {
parallelNum = 1 // single CPU core
} else {
// 1-2 core for merge (with parallel KV check)
// 1-2 core for others (bc optimizer, main)
// 1-2 core for possible other concurrent routine
parallelNum = max(1, numCpu-6)
}
cfg.ParallelTxNum = parallelNum
}

if ctx.IsSet(ParallelTxFlag.Name) {
cfg.ParallelTxMode = ctx.Bool(ParallelTxFlag.Name)
}
Expand Down
53 changes: 2 additions & 51 deletions core/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -531,11 +531,7 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, genesis *Genesis
bc.snaps, _ = snapshot.New(snapconfig, bc.db, bc.triedb, head.Root)
}

if bc.vmConfig.EnableParallelExecLegacy {
bc.CreateParallelProcessor(bc.vmConfig.ParallelTxNum)
bc.CreateSerialProcessor(chainConfig, bc, engine)
log.Info("Parallel V1 enabled", "parallelNum", bc.vmConfig.ParallelTxNum)
} else if bc.vmConfig.EnableParallelExec {
if bc.vmConfig.EnableParallelExec {
bc.processor = newPEVMProcessor(chainConfig, bc, engine)
log.Info("Parallel V2 enabled", "parallelNum", ParallelNum())
} else {
Expand Down Expand Up @@ -1911,20 +1907,6 @@ func (bc *BlockChain) insertChain(chain types.Blocks, setHead bool) (int, error)
statedb.StartPrefetcher("chain")
activeState = statedb

if bc.vmConfig.EnableParallelExecLegacy {
bc.parseTxDAG(block)
txsCount := block.Transactions().Len()
threshold := min(bc.vmConfig.ParallelTxNum/2+2, 4)
if bc.vmConfig.ParallelTxNum < 2 || txsCount < threshold || bc.isEmptyTxDAG() {
bc.UseSerialProcessor()
log.Debug("Disable Parallel Tx execution", "block", block.NumberU64(), "transactions", txsCount, "parallelTxNum", bc.vmConfig.ParallelTxNum)
} else {
bc.UseParallelProcessor()
log.Debug("Enable Parallel Tx execution", "block", block.NumberU64(), "transactions", txsCount, "parallelTxNum", bc.vmConfig.ParallelTxNum)

}
}

if bc.vmConfig.EnableParallelExec {
bc.parseTxDAG(block)
}
Expand All @@ -1951,10 +1933,6 @@ func (bc *BlockChain) insertChain(chain types.Blocks, setHead bool) (int, error)
// Process block using the parent state as reference point
pstart = time.Now()
receipts, logs, usedGas, err = bc.processor.Process(block, statedb, bc.vmConfig)
if err == FallbackToSerialProcessorErr {
bc.UseSerialProcessor()
receipts, logs, usedGas, err = bc.processor.Process(block, statedb, bc.vmConfig)
}
if err != nil {
bc.reportBlock(block, receipts, err)
followupInterrupt.Store(true)
Expand All @@ -1973,7 +1951,7 @@ func (bc *BlockChain) insertChain(chain types.Blocks, setHead bool) (int, error)
vtime := time.Since(vstart)
proctime := time.Since(start) // processing + validation

if bc.enableTxDAG && !bc.vmConfig.EnableParallelExecLegacy && !bc.vmConfig.EnableParallelExec {
if bc.enableTxDAG && !bc.vmConfig.EnableParallelExec {
// compare input TxDAG when it enable in consensus
dag, err := statedb.ResolveTxDAG(len(block.Transactions()), []common.Address{block.Coinbase(), params.OptimismBaseFeeRecipient, params.OptimismL1FeeRecipient})
if err == nil {
Expand Down Expand Up @@ -2711,14 +2689,6 @@ func (bc *BlockChain) GetTrieFlushInterval() time.Duration {
return time.Duration(bc.flushInterval.Load())
}

func (bc *BlockChain) CreateParallelProcessor(parallelNum int) *BlockChain {
if bc.parallelProcessor == nil {
bc.parallelProcessor = newParallelStateProcessor(bc.Config(), bc, bc.engine, parallelNum)
bc.parallelExecution = true
}
return bc
}

func (bc *BlockChain) NoTries() bool {
return bc.stateCache.NoTries()
}
Expand Down Expand Up @@ -2799,25 +2769,6 @@ func (bc *BlockChain) SetupTxDAGGeneration(output string, readFile bool) {
}()
}

func (bc *BlockChain) UseParallelProcessor() {
if bc.parallelProcessor != nil {
bc.parallelExecution = true
bc.processor = bc.parallelProcessor
} else {
log.Error("bc.ParallelProcessor is nil! fallback to serial processor!")
bc.UseSerialProcessor()
}
}

func (bc *BlockChain) UseSerialProcessor() {
if bc.serialProcessor != nil {
bc.parallelExecution = false
bc.processor = bc.serialProcessor
} else {
bc.CreateSerialProcessor(bc.chainConfig, bc, bc.engine)
}
}

type TxDAGOutputItem struct {
blockNumber uint64
txDAG types.TxDAG
Expand Down
Loading

0 comments on commit fa8d0e8

Please sign in to comment.