Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 3 additions & 17 deletions execution/exec/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,9 @@ func (rw *Worker) ResetState(rs *state.StateV3Buffered, chainTx kv.TemporalTx, s
if chainTx != nil {
getter = rs.Domains().AsGetterMetered(chainTx, rw.readMetrics)
}
// Use CachedReaderV3 for parallel workers — caches account data
// on first read per block, providing a stable pre-block committed
// view for GetCommittedState. The blockStateCache is set per block
// via SetBlockStateCache before workers start.
// Parallel workers read the pre-block base directly (sd.mem → StateCache
// → files). The version map on top of this reader gives intra-block
// isolation, so no per-block committed cache is needed here.
rw.SetReader(state.NewCachedReaderV3(getter, nil))
}

Expand Down Expand Up @@ -496,14 +495,6 @@ func (rw *Worker) SetReader(reader state.StateReader) {
}
}

// SetBlockStateCache updates the block-level account cache on the worker's
// CachedReaderV3. Called before each block's workers start execution.
func (rw *Worker) SetBlockStateCache(cache *state.BlockStateCache) {
if cr, ok := rw.stateReader.(*state.CachedReaderV3); ok {
cr.SetBlockStateCache(cache)
}
}

func (rw *Worker) RunTxTaskNoLock(txTask Task) *TxResult {
if txTask.IsHistoric() && !rw.historyMode {
// in case if we cancelled execution and commitment happened in the middle of the block, we have to process block
Expand All @@ -517,11 +508,6 @@ func (rw *Worker) RunTxTaskNoLock(txTask Task) *TxResult {
rw.SetReader(state.NewCachedReaderV3(rw.rs.Domains().AsGetterMetered(rw.chainTx, rw.readMetrics), nil))
}

// Set the per-block committed state cache from the task.
if cache := txTask.GetBlockStateCache(); cache != nil {
rw.SetBlockStateCache(cache)
}

if rw.background && rw.chainTx == nil {
chainTx, err := rw.chainDb.BeginTemporalRo(rw.ctx) //nolint

Expand Down
9 changes: 0 additions & 9 deletions execution/exec/txtask.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ type Task interface {

Version() state.Version
VersionMap() *state.VersionMap
GetBlockStateCache() *state.BlockStateCache
VersionedReads(ibs *state.IntraBlockState) state.ReadSet
VersionedWrites(ibs *state.IntraBlockState) *state.WriteSet
Reset(evm *vm.EVM, ibs *state.IntraBlockState, callTracer *calltracer.CallTracer) error
Expand Down Expand Up @@ -231,10 +230,6 @@ type TxTask struct {
signer *types.Signer
dependencies []int
rules *chain.Rules

// BlockStateCache holds pre-block account state for stable committed reads.
// Shared across all tasks in the same block. Set by the parallel executor.
BlockStateCache *state.BlockStateCache
}

func (t *TxTask) compare(other Task) int {
Expand Down Expand Up @@ -438,10 +433,6 @@ func (t *TxTask) VersionMap() *state.VersionMap {
return nil
}

func (t *TxTask) GetBlockStateCache() *state.BlockStateCache {
return t.BlockStateCache
}

func (t *TxTask) VersionedReads(ibs *state.IntraBlockState) state.ReadSet {
return ibs.VersionedReads()
}
Expand Down
3 changes: 0 additions & 3 deletions execution/stagedsync/exec3.go
Original file line number Diff line number Diff line change
Expand Up @@ -718,8 +718,6 @@ func (te *txExecutor) executeBlocks(ctx context.Context, startBlockNum uint64, m
}), te.cfg.engine, te.cfg.author, te.cfg.chainConfig)

var txTasks []exec.Task
// Per-block committed state cache for parallel workers' GetCommittedState.
blockStateCache := state.NewBlockStateCache()

blockStartTxNum := inputTxNum
for txIndex := -1; txIndex <= len(txs); txIndex++ {
Expand All @@ -744,7 +742,6 @@ func (te *txExecutor) executeBlocks(ctx context.Context, startBlockNum uint64, m
Trace: dbg.TraceTx(blockNum, txIndex),
Hooks: te.hooks,
Logger: te.logger,
BlockStateCache: blockStateCache,
}

txTasks = append(txTasks, txTask)
Expand Down
Loading