Skip to content

fix(protocol): decouple preconf metadata existence from anchorBlockNumber#21763

Open
dantaik wants to merge 1 commit into
mainfrom
claude/great-ptolemy-6zp7xf
Open

fix(protocol): decouple preconf metadata existence from anchorBlockNumber#21763
dantaik wants to merge 1 commit into
mainfrom
claude/great-ptolemy-6zp7xf

Conversation

@dantaik

@dantaik dantaik commented Jun 10, 2026

Copy link
Copy Markdown
Member

What

Fixes the Anchor.getPreconfMetadata existence sentinel, which collides with a valid anchorBlockNumber == 0.

Closes #21762.

Problem

getPreconfMetadata used anchorBlockNumber != 0 as the "metadata exists" sentinel (Anchor.sol:208), but BlockParams.anchorBlockNumber is documented as "0 to skip" (Anchor.sol:36). A block legitimately recorded with anchorBlockNumber == 0 was therefore indistinguishable from one 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). _validateBlock enforces no anchorBlockNumber != 0 guard, 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)

  • Add an explicit bool stored marker to PreconfMetadata and use it as the existence sentinel in getPreconfMetadata.
  • Set stored: true in _storePreconfMetadata (called unconditionally for every block).
  • This preserves the documented anchorBlockNumber == 0 "skip" semantic, rather than removing it (which a naive require(anchorBlockNumber != 0) would do).

Storage-layout safety

stored packs into the existing first slot alongside the three uint48 fields (18 + 1 = 19 bytes ≤ 32), so rawTxListHash / parentRawTxListHash keep their sub-slots and the contract-level layout is unchanged: _preconfMetadata stays at slot 258 and __gap at slot 259 (Anchor_Layout.sol is unaffected). Please regenerate via pnpm layout in CI to confirm. Note: any PreconfMetadata entries written before this upgrade would read stored == 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 with anchorBlockNumber == 0 is now retrievable (the regression).
  • test_getPreconfMetadata_RevertWhen_BlockNotRecorded — an unrecorded block still reverts with InvalidBlockNumber.

Note: forge could not be run in the authoring environment (network policy blocked the toolchain install), so compilation/tests rely on CI here. The change is small and the diff is included for review.

Reviewers

Requesting @ggonzalez94 and @davidtaikocha.

https://claude.ai/code/session_0187MFZTJHwwQ6zUhRus39we


Generated by Claude Code

…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
@dantaik dantaik marked this pull request as ready for review June 10, 2026 01:28
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

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.

Anchor: getPreconfMetadata existence sentinel collides with a valid anchorBlockNumber == 0

2 participants