mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-08 07:58:40 +00:00
add --bal.blockingprefetch: if enabled, will ensure that when executing with a BAL, state loading tasks are completed before tx and state root calculation. can be used with --bal.prefetchworkers
This commit is contained in:
parent
457491107a
commit
ac8354d4ca
5 changed files with 20 additions and 4 deletions
|
|
@ -160,6 +160,7 @@ var (
|
|||
utils.BeaconCheckpointFileFlag,
|
||||
utils.LogSlowBlockFlag,
|
||||
utils.PrefetchWorkersFlag,
|
||||
utils.BlockingPrefetch,
|
||||
}, utils.NetworkFlags, utils.DatabaseFlags)
|
||||
|
||||
rpcFlags = []cli.Flag{
|
||||
|
|
|
|||
|
|
@ -721,6 +721,12 @@ var (
|
|||
Category: flags.MiscCategory,
|
||||
}
|
||||
|
||||
BlockingPrefetch = &cli.BoolFlag{
|
||||
Name: "bal.blockingprefetch",
|
||||
Usage: "only relevant when executing in parallel with a BAL: if true, the prefetcher will block tx/state-root calculation until all scheduled fetching tasks have completed.",
|
||||
Category: flags.MiscCategory,
|
||||
}
|
||||
|
||||
// RPC settings
|
||||
IPCDisabledFlag = &cli.BoolFlag{
|
||||
Name: "ipcdisable",
|
||||
|
|
@ -2467,7 +2473,8 @@ func MakeChain(ctx *cli.Context, stack *node.Node, readonly bool) (*core.BlockCh
|
|||
TrienodeHistory: ctx.Int64(TrienodeHistoryFlag.Name),
|
||||
NodeFullValueCheckpoint: uint32(ctx.Uint(TrienodeHistoryFullValueCheckpointFlag.Name)),
|
||||
|
||||
PrefetchWorkers: int(ctx.Uint(PrefetchWorkersFlag.Name)),
|
||||
PrefetchWorkers: int(ctx.Uint(PrefetchWorkersFlag.Name)),
|
||||
BlockingPrefetch: ctx.Bool(BlockingPrefetch.Name),
|
||||
// Disable transaction indexing/unindexing.
|
||||
TxLookupLimit: -1,
|
||||
|
||||
|
|
|
|||
|
|
@ -211,7 +211,9 @@ type BlockChainConfig struct {
|
|||
Overrides *ChainOverrides // Optional chain config overrides
|
||||
VmConfig vm.Config // Config options for the EVM Interpreter
|
||||
|
||||
PrefetchWorkers int // number of concurrent go-routines for BAL state prefetching
|
||||
// BAL-related
|
||||
PrefetchWorkers int // number of concurrent go-routines for BAL state prefetching
|
||||
BlockingPrefetch bool // whether the prefetch should block further execution until it finishes
|
||||
|
||||
// TxLookupLimit specifies the maximum number of blocks from head for which
|
||||
// transaction hashes will be indexed.
|
||||
|
|
@ -599,7 +601,7 @@ func (bc *BlockChain) processBlockWithAccessList(parentRoot common.Hash, block *
|
|||
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 := sdb.ReaderEIP7928(parentRoot, accessListReader.StorageKeys(useAsyncReads), bc.cfg.PrefetchWorkers)
|
||||
prefetchReader, err := sdb.ReaderEIP7928(parentRoot, accessListReader.StorageKeys(useAsyncReads), bc.cfg.PrefetchWorkers, bc.cfg.BlockingPrefetch)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -240,7 +240,7 @@ func (db *CachingDB) ReadersWithCacheStats(stateRoot common.Hash) (Reader, Reade
|
|||
}
|
||||
|
||||
// ReaderEIP7928 creates a state reader with the manner of Block-level accessList.
|
||||
func (db *CachingDB) ReaderEIP7928(stateRoot common.Hash, accessList map[common.Address][]common.Hash, threads int) (Reader, error) {
|
||||
func (db *CachingDB) ReaderEIP7928(stateRoot common.Hash, accessList map[common.Address][]common.Hash, threads int, block bool) (Reader, error) {
|
||||
base, err := db.StateReader(stateRoot)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
@ -250,6 +250,11 @@ func (db *CachingDB) ReaderEIP7928(stateRoot common.Hash, accessList map[common.
|
|||
|
||||
// Construct the state reader with background prefetching
|
||||
pr := newPrefetchStateReader(r, accessList, threads)
|
||||
if block {
|
||||
if err := pr.Wait(); err != nil {
|
||||
panic("wat do")
|
||||
}
|
||||
}
|
||||
|
||||
return newReaderWithPrefetch(db.codedb.Reader(), pr, pr), nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -162,6 +162,7 @@ func (t *BlockTest) createTestBlockChain(config *params.ChainConfig, snapshotter
|
|||
},
|
||||
StatelessSelfValidation: witness,
|
||||
NoPrefetch: true,
|
||||
BlockingPrefetch: true,
|
||||
PrefetchWorkers: 100, // note: this is totally unrelated to NoPrefetch, just for BAL execution
|
||||
}
|
||||
if snapshotter {
|
||||
|
|
|
|||
Loading…
Reference in a new issue