Skip to content

execution/stagedsync: drop block write buffer from calcFees/finalize readers (#23140) - #23147

Closed
sudeepdino008 wants to merge 1 commit into
sudeepdino008/bsc-rm-worker-committed-tierfrom
sudeepdino008/bsc-rm-calcfees-normalize-reader
Closed

execution/stagedsync: drop block write buffer from calcFees/finalize readers (#23140)#23147
sudeepdino008 wants to merge 1 commit into
sudeepdino008/bsc-rm-worker-committed-tierfrom
sudeepdino008/bsc-rm-calcfees-normalize-reader

Conversation

@sudeepdino008

Copy link
Copy Markdown
Member

Part 2 of removing BlockStateCache (#23140). Stacked on #23146.

calcFees and finalize (per-tx finalizeTx and the block-end finalizeSystemTx) read through NewVersionedStateReader(be.versionMap, ...). The version map supplies all accumulated in-block state; the state reader passed alongside is only the pre-block base. So these readers do not need the BlockStateCache write buffer.

This passes nil block cache to those readers. Values are unchanged — a version-map miss means no tx wrote the key, so the read falls to the pre-block base, which the plain reader serves. The finalize comment claiming the buffer was load-bearing was stale; the version map has supplied in-block state since the parallel-commitment work landed.

The block-complete engine.Finalize IBS (withdrawals, EIP-7002/7251) still uses the buffer via an empty local version map. The next part moves it to be.versionMap.

…ize readers (#23140)

calcFees and finalize (finalizeTx and the block-end finalizeSystemTx) read
through NewVersionedStateReader(be.versionMap, ...), so the version map supplies
all accumulated in-block state. The state reader passed alongside is only the
pre-block base. It therefore does not need the BlockStateCache write buffer.

Pass nil block cache to these readers. Values are unchanged: a version-map miss
means no tx wrote the key, so the read falls to the pre-block base, which the
plain reader serves. The finalize-comment claiming the buffer is load-bearing
was stale — the version map has supplied in-block state since the parallel
commitment work landed.

The block-complete engine.Finalize IBS (withdrawals/EIP-7002/7251) still uses
the write buffer; a later part of #23140 moves it to the version map.
sudeepdino008 added a commit that referenced this pull request Aug 11, 2026
… map (#23140)

The block-complete engine.Finalize IBS (withdrawals, EIP-7002/7251 system
calls) read prior-tx in-block state through the BlockStateCache write buffer
via an empty local version map. Give it be.versionMap and a pre-block-only
reader: at block end every cell is Done and versionedReadCore applies
self-destruct/revival, so the version map is a strict superset of the old
blockCache read for this reader — and fixes the block 24839300 trie-root race
(a tip-adjacent historic block's withdrawal read the pre-block balance and
stomped a prior tx's update). TestFinalizeIBSSeesVersionMapWrite pins it.

The per-tx calcFees/finalize readers keep the block write buffer. Dropping it
there (folded-out #23147) regressed the 2016 EIP-161 empty-account sweep
window: CachedReaderV3.ReadAccountData populates the buffer's committed tier
as a read side-effect that feeds the deferred-commitment touchmap, so a nil
base corrupted the commitment structure and produced a wrong trie root some
blocks later (block 2676607 on a from-0 mainnet re-execution).
@sudeepdino008

Copy link
Copy Markdown
Member Author

Folding this out. Its change (nil block cache for the per-tx calcFees/finalize readers) regressed the 2016 EIP-161 empty-account sweep window: CachedReaderV3.ReadAccountData populates the buffer's committed tier as a read side-effect that feeds the deferred-commitment touchmap, so a nil base corrupts the commitment structure and produces a wrong trie root some blocks later (first seen at block 2676607 on a from-0 mainnet re-execution). Those readers stay on the buffer. #23149 now bases directly on #23146 and carries only the block-finalize-IBS-via-version-map change.

sudeepdino008 added a commit that referenced this pull request Aug 12, 2026
… map (#23140)

The block-complete engine.Finalize IBS (withdrawals, EIP-7002/7251 system
calls) read prior-tx in-block state through the BlockStateCache write buffer
via an empty local version map. Give it be.versionMap and a pre-block-only
reader: at block end every cell is Done and versionedReadCore applies
self-destruct/revival, so the version map is a strict superset of the old
blockCache read for this reader — and fixes the block 24839300 trie-root race
(a tip-adjacent historic block's withdrawal read the pre-block balance and
stomped a prior tx's update). TestFinalizeIBSSeesVersionMapWrite pins it.

The per-tx calcFees/finalize readers keep the block write buffer. Dropping it
there (folded-out #23147) regressed the 2016 EIP-161 empty-account sweep
window: CachedReaderV3.ReadAccountData populates the buffer's committed tier
as a read side-effect that feeds the deferred-commitment touchmap, so a nil
base corrupted the commitment structure and produced a wrong trie root some
blocks later (block 2676607 on a from-0 mainnet re-execution).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant