clean up the configuration of the BAL execution mode based on the preset flag specified

This commit is contained in:
Jared Wasinger 2026-03-10 17:34:11 -04:00
parent 24b6d44201
commit af8d1ad024
6 changed files with 24 additions and 20 deletions

View file

@ -20,6 +20,7 @@ import (
"bufio"
"errors"
"fmt"
"github.com/ethereum/go-ethereum/core/types/bal"
"os"
"reflect"
"runtime"
@ -243,12 +244,12 @@ func makeFullNode(ctx *cli.Context) *node.Node {
if ctx.IsSet(utils.BlockAccessListExecutionModeFlag.Name) {
val := ctx.String(utils.BlockAccessListExecutionModeFlag.Name)
switch val {
case utils.BalExecutionModeFull:
cfg.Eth.BALExecutionMode = 0
case utils.BalExecutionModeOptimized:
cfg.Eth.BALExecutionMode = bal.BALExecutionOptimized
case utils.BalExecutionModeNoBatchIO:
cfg.Eth.BALExecutionMode = 1
cfg.Eth.BALExecutionMode = bal.BALExecutionNoBatchIO
case utils.BalExecutionModeSequential:
cfg.Eth.BALExecutionMode = 2
cfg.Eth.BALExecutionMode = bal.BALExecutionSequential
default:
utils.Fatalf("invalid option for --bal.executionmode: %s. acceptable values are full|nobatchio|sequential", val)
}

View file

@ -1124,13 +1124,13 @@ block access list execution type. possible inputs are:
- sequential: no performance acceleration
- full: parallel transaction execution, state root calculation, async warming of access list reads
- nobatchio: same as 'full', but without async warming of access list reads`,
Value: BalExecutionModeFull,
Value: BalExecutionModeOptimized,
Category: flags.MiscCategory,
}
)
const (
BalExecutionModeFull = "full"
BalExecutionModeOptimized = "full"
BalExecutionModeNoBatchIO = "nobatchio"
BalExecutionModeSequential = "sequential"
)

View file

@ -179,12 +179,6 @@ const (
BlockChainVersion uint64 = 9
)
const (
BALExecutionModeFull = 0
BALExecutionModeNoBatchIO = iota
BALExecutionModeSequential = iota
)
// BlockChainConfig contains the configuration of the BlockChain object.
type BlockChainConfig struct {
// Trie database related options
@ -246,8 +240,7 @@ type BlockChainConfig struct {
StatelessSelfValidation bool // Generate execution witnesses and self-check against them (testing purpose)
EnableWitnessStats bool // Whether trie access statistics collection is enabled
// TODO clean this config up to use defined constants...
BALExecutionMode int
BALExecutionMode bal.BALExecutionMode
}
// DefaultConfig returns the default config.
@ -609,7 +602,7 @@ func (bc *BlockChain) processBlockWithAccessList(parentRoot common.Hash, block *
statedb *state.StateDB
)
useAsyncReads := bc.cfg.BALExecutionMode != BALExecutionModeNoBatchIO
useAsyncReads := bc.cfg.BALExecutionMode != bal.BALExecutionNoBatchIO
al := block.AccessList() // TODO: make the return of this method not be a pointer
accessListReader := bal.NewAccessListReader(*al)
prefetchReader, err := bc.statedb.ReaderEIP7928(parentRoot, accessListReader.StorageKeys(useAsyncReads), runtime.NumCPU())
@ -2146,7 +2139,7 @@ func (bc *BlockChain) insertChain(ctx context.Context, chain types.Blocks, setHe
return nil, it.index, err
}
blockHasAccessList := block.AccessList() != nil
if blockHasAccessList && bc.cfg.BALExecutionMode != BALExecutionModeSequential {
if blockHasAccessList && bc.cfg.BALExecutionMode != bal.BALExecutionSequential {
res.stats.reportBALMetrics()
} else {
res.stats.reportMetrics()
@ -2265,7 +2258,7 @@ func (bc *BlockChain) ProcessBlock(ctx context.Context, parentRoot common.Hash,
blockHasAccessList := block.AccessList() != nil
// optimized execution path for blocks which contain BALs
if blockHasAccessList && bc.cfg.BALExecutionMode != BALExecutionModeSequential {
if blockHasAccessList && bc.cfg.BALExecutionMode != bal.BALExecutionSequential {
return bc.processBlockWithAccessList(parentRoot, block, config.WriteHead)
}

View file

@ -531,3 +531,11 @@ func (a *AccountMutations) Eq(other *AccountMutations) bool {
}
return true
}
type BALExecutionMode int
const (
BALExecutionOptimized BALExecutionMode = iota
BALExecutionNoBatchIO
BALExecutionSequential
)

View file

@ -19,6 +19,7 @@ package ethconfig
import (
"errors"
"github.com/ethereum/go-ethereum/core/types/bal"
"time"
"github.com/ethereum/go-ethereum/common"
@ -210,7 +211,7 @@ type Config struct {
// RangeLimit restricts the maximum range (end - start) for range queries.
RangeLimit uint64 `toml:",omitempty"`
BALExecutionMode int
BALExecutionMode bal.BALExecutionMode
}
// CreateConsensusEngine creates a consensus engine for the given chain config.

View file

@ -3,6 +3,7 @@
package ethconfig
import (
"github.com/ethereum/go-ethereum/core/types/bal"
"time"
"github.com/ethereum/go-ethereum/common"
@ -68,7 +69,7 @@ func (c Config) MarshalTOML() (interface{}, error) {
TxSyncDefaultTimeout time.Duration `toml:",omitempty"`
TxSyncMaxTimeout time.Duration `toml:",omitempty"`
RangeLimit uint64 `toml:",omitempty"`
BALExecutionMode int
BALExecutionMode bal.BALExecutionMode
}
var enc Config
enc.Genesis = c.Genesis
@ -340,7 +341,7 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error {
c.RangeLimit = *dec.RangeLimit
}
if dec.BALExecutionMode != nil {
c.BALExecutionMode = *dec.BALExecutionMode
c.BALExecutionMode = bal.BALExecutionMode(*dec.BALExecutionMode)
}
return nil
}