Skip to content

execution/stagedsync: use versionmap instead of BlockStateCache in block-finalize (P2) - #23149

Draft
sudeepdino008 wants to merge 2 commits into
sudeepdino008/bsc-rm-worker-committed-tierfrom
sudeepdino008/bsc-finalize-versionmap
Draft

execution/stagedsync: use versionmap instead of BlockStateCache in block-finalize (P2)#23149
sudeepdino008 wants to merge 2 commits into
sudeepdino008/bsc-rm-worker-committed-tierfrom
sudeepdino008/bsc-finalize-versionmap

Conversation

@sudeepdino008

@sudeepdino008 sudeepdino008 commented Aug 10, 2026

Copy link
Copy Markdown
Member

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

Summary

The block-complete finalize IBS (engine.Finalize: withdrawals, EIP-7002/7251 syscalls) read the in-block state through the BlockStateCache write buffer (it got an empty versionMap, so all reads fell through to the blockCache).

This PR gives it a populated versionMap + a pre-block-only reader instead.

  • at block end every be.versionMap cell is Done and versionedReadCore applies self-destruct/revival — so it's a strict superset of the old blockCache read. Mirrors finalizeSystemTx, which already reads via be.versionMap.

@sudeepdino008
sudeepdino008 force-pushed the sudeepdino008/bsc-finalize-versionmap branch from c27675b to 561dd02 Compare August 11, 2026 05:03
@sudeepdino008
sudeepdino008 changed the base branch from sudeepdino008/bsc-rm-calcfees-normalize-reader to sudeepdino008/bsc-rm-worker-committed-tier August 11, 2026 05:03
@sudeepdino008 sudeepdino008 changed the title execution/stagedsync: read block-finalize IBS through the version map (#23140) execution/stagedsync: read block-finalize IBS through the versionmap instead of BlockStateCache (#23140) Aug 11, 2026
@sudeepdino008 sudeepdino008 changed the title execution/stagedsync: read block-finalize IBS through the versionmap instead of BlockStateCache (#23140) execution/stagedsync: use versionmap instead of BlockStateCache in block-finalize (#23140) 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
sudeepdino008 force-pushed the sudeepdino008/bsc-rm-worker-committed-tier branch from 3960cee to d07d799 Compare August 12, 2026 06:13
@sudeepdino008
sudeepdino008 force-pushed the sudeepdino008/bsc-finalize-versionmap branch from 5dac65a to 53e4734 Compare August 12, 2026 06:13
@sudeepdino008 sudeepdino008 changed the title execution/stagedsync: use versionmap instead of BlockStateCache in block-finalize (#23140) execution/stagedsync: use versionmap instead of BlockStateCache in block-finalize (P2) Aug 12, 2026
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