execution/types, stagedsync: EIP-7928 phantom-read early reject#21495
Draft
yperbasis wants to merge 2 commits into
Draft
execution/types, stagedsync: EIP-7928 phantom-read early reject#21495yperbasis wants to merge 2 commits into
yperbasis wants to merge 2 commits into
Conversation
Implements the Security-Considerations mitigation from EIP-7928 against malicious proposers declaring phantom storage_reads. Without this check ValidateMaxItems only catches an oversized BAL post-execution, after the client has already paid the I/O cost the mitigation is meant to avoid. execution/types/block_access_list.go adds CountDeclaredReads, DeclaredReadTracker (idempotent under speculative re-execution) and the EarlyRejectCheck budget rule: G_remaining >= R_remaining * BalItemCost. execution/stagedsync/exec3_parallel.go captures the block gas limit at newBlockExec, builds a tracker from the declared accessList, and after each tx validates and consumes its gas walks the StoragePath reads, attributes them to declared slots, and calls EarlyRejectCheck. Failure returns ErrInvalidBlock via the existing invalidBlockResult path. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements the EIP-7928 Security-Considerations mitigation against a malicious proposer declaring phantom
storage_reads. The existingValidateMaxItemsonly checks the overall BAL size bound post-execution — after the client has already paid the I/O cost the mitigation is meant to avoid. This PR adds the per-tx gas-feasibility budget check:where
R_remainingis the number of declaredstorage_readsnot yet observed in actual execution.Changes
execution/types/block_access_list.goBlockAccessList.CountDeclaredReads() int—R_declared.DeclaredReadTracker(NewDeclaredReadTracker(bal),ObserveRead(addr, slot),Remaining()) — idempotent so safe under the parallel executor's speculative re-execution.EarlyRejectCheck(blockGasLimit, gasUsed, remainingDeclaredReads) error.execution/stagedsync/exec3_parallel.goblockExecutorgainsblockGasLimit(captured from the freshgasPool) anddeclaredReadTracker(built from the declaredaccessListalready plumbed in).gasUsedSoFar()helper computesblockGasLimit - min(regular, state)so the check is conservative across both EIP-8037 dimensions.nextResult, the finalized read set is scanned forStoragePathreads, attributed viaObserveRead, andEarlyRejectCheckruns. Failure routes through the existinginvalidBlockResultpath asErrInvalidBlock.Test plan
go test ./execution/types/— new unit tests cover counting, draining, idempotency, undeclared-slot no-ops, empty BAL, gas boundary, and gas-accounting bug.go test ./execution/stagedsync/ -short— no regressions.make lintclean (twice).make erigon integration— builds.exec3_serial.go) — not yet wired; same hook applies, deferred to keep this PR focused. Will follow up.blockExecutorsetup is heavy; the pure-logic unit tests cover the check, and the integration site is ~10 lines.🤖 Generated with Claude Code