fix(protocol): decouple preconf metadata existence from anchorBlockNumber#21763
Open
dantaik wants to merge 1 commit into
Open
fix(protocol): decouple preconf metadata existence from anchorBlockNumber#21763dantaik wants to merge 1 commit into
dantaik wants to merge 1 commit into
Conversation
…mber getPreconfMetadata used "anchorBlockNumber != 0" as the sentinel for "metadata exists", but anchorBlockNumber is documented as "0 to skip" in BlockParams. A block legitimately anchored with anchorBlockNumber == 0 was therefore indistinguishable from a block that was never recorded, causing getPreconfMetadata to revert and blocking PreconfSlasherL2 from validating faults for that block (or its predecessor, which also reads the next block's metadata). Add an explicit "bool stored" marker to PreconfMetadata (packed into the existing uint48 slot, so the rawTxListHash/parentRawTxListHash sub-slots and the contract-level storage layout are unchanged) and use it as the existence sentinel. This preserves the documented "anchorBlockNumber == 0 to skip" semantic. https://claude.ai/code/session_0187MFZTJHwwQ6zUhRus39we
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
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.
What
Fixes the
Anchor.getPreconfMetadataexistence sentinel, which collides with a validanchorBlockNumber == 0.Closes #21762.
Problem
getPreconfMetadatausedanchorBlockNumber != 0as the "metadata exists" sentinel (Anchor.sol:208), butBlockParams.anchorBlockNumberis documented as "0 to skip" (Anchor.sol:36). A block legitimately recorded withanchorBlockNumber == 0was therefore indistinguishable from one that was never recorded, causinggetPreconfMetadatato revert and blockingPreconfSlasherL2from validating faults for that block (or its predecessor, which also reads the next block's metadata)._validateBlockenforces noanchorBlockNumber != 0guard, so nothing on-chain prevents the collision. Currently latent (the driver passes real L1 block numbers), but the fix removes the dependence on off-chain driver behavior for a slashing-safety invariant.Change (minimal)
bool storedmarker toPreconfMetadataand use it as the existence sentinel ingetPreconfMetadata.stored: truein_storePreconfMetadata(called unconditionally for every block).anchorBlockNumber == 0"skip" semantic, rather than removing it (which a naiverequire(anchorBlockNumber != 0)would do).Storage-layout safety
storedpacks into the existing first slot alongside the threeuint48fields (18 + 1 = 19 bytes ≤ 32), sorawTxListHash/parentRawTxListHashkeep their sub-slots and the contract-level layout is unchanged:_preconfMetadatastays at slot 258 and__gapat slot 259 (Anchor_Layout.solis unaffected). Please regenerate viapnpm layoutin CI to confirm. Note: anyPreconfMetadataentries written before this upgrade would readstored == false; this is acceptable for the rolling/recent preconf window but worth confirming there are no live pre-upgrade entries that must remain readable.Tests
test_getPreconfMetadata_recordsBlockAnchoredAtZero— a block anchored withanchorBlockNumber == 0is now retrievable (the regression).test_getPreconfMetadata_RevertWhen_BlockNotRecorded— an unrecorded block still reverts withInvalidBlockNumber.Reviewers
Requesting @ggonzalez94 and @davidtaikocha.
https://claude.ai/code/session_0187MFZTJHwwQ6zUhRus39we
Generated by Claude Code