Skip to content
Draft
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
25 changes: 10 additions & 15 deletions execution/stagedsync/exec3_parallel.go
Original file line number Diff line number Diff line change
Expand Up @@ -2752,17 +2752,14 @@ func (be *blockExecutor) nextResult(ctx context.Context, pe *parallelExecutor, r
return nil, fmt.Errorf("apply loop: unexpected task type for tx %d: result.Task=%T", tx, txResult.Task)
}
if stateReader == nil {
// Shared base reader for this tx's calcFees and finalize (finalize
// reuses this stateReader). The version map is not a strict superset
// of the block write buffer in the EIP-161 empty-account sweep window
// (2016 Spurious Dragon): a finalize read there can miss the accumulated
// in-block state and fall to a stale pre-block value, corrupting the
// commitment structure and surfacing as a wrong trie root some blocks
// later. Keep the buffer as the fallback base.
// Shared pre-block base reader for this tx's calcFees and finalize
// (finalize reuses this stateReader). The version map carries every
// in-block write, so the reader only supplies the pre-block base for
// keys the version map does not hold.
if txTask.IsHistoric() {
stateReader = state.NewHistoryReaderV3WithBlockCache(applyTx, pe.rs.Domains(), be.blockStateCache, txTask.Version().TxNum)
stateReader = state.NewHistoryReaderV3WithSharedDomains(applyTx, pe.rs.Domains(), txTask.Version().TxNum)
} else {
stateReader = state.NewCurrentCachedReaderV3(pe.rs.Domains().AsGetter(applyTx), be.blockStateCache)
stateReader = state.NewReaderV3(pe.rs.Domains().AsGetter(applyTx))
}
}
tipWrites, err := txResult.calcFees(taskVer, be.versionMap, stateReader, txTask.Rules())
Expand Down Expand Up @@ -2874,14 +2871,12 @@ func (be *blockExecutor) nextResult(ctx context.Context, pe *parallelExecutor, r
}

if stateReader == nil {
// Same shared base as the calcFees block above (used when calcFees
// did not run for this tx). Keep the buffer as the fallback base:
// the version map is not a strict superset of it in the EIP-161
// empty-account sweep window.
// Same shared pre-block base as the calcFees block above (used
// when calcFees did not run for this tx).
if txTask.IsHistoric() {
stateReader = state.NewHistoryReaderV3WithBlockCache(applyTx, pe.rs.Domains(), be.blockStateCache, txTask.Version().TxNum)
stateReader = state.NewHistoryReaderV3WithSharedDomains(applyTx, pe.rs.Domains(), txTask.Version().TxNum)
} else {
stateReader = state.NewCurrentCachedReaderV3(pe.rs.Domains().AsGetterNoMetrics(applyTx), be.blockStateCache)
stateReader = state.NewReaderV3(pe.rs.Domains().AsGetterNoMetrics(applyTx))
}
}

Expand Down
Loading