Skip to content

fix(archiver): always advance L1-to-L2 messages syncpoint to current L1 block (backport #22154)#22625

Closed
spalladino wants to merge 4 commits into
v4from
spl/backport-22154-v4
Closed

fix(archiver): always advance L1-to-L2 messages syncpoint to current L1 block (backport #22154)#22625
spalladino wants to merge 4 commits into
v4from
spl/backport-22154-v4

Conversation

@spalladino

Copy link
Copy Markdown
Contributor

Backport of #22154 to v4.

Motivation

The L1-to-L2 messages syncpoint tracked the L1 block of the last downloaded message. If no messages were sent for a long time, the syncpoint got stuck and the next non-empty sync iteration re-scanned old block ranges. The rolling hash check and rollback logic already handle L1 reorgs, making this conservative syncpoint advancement redundant.

Approach

The syncpoint now always advances to currentL1BlockNumber on success. After downloading, local state is verified against L1; on mismatch the syncpoint rolls back and the operation retries (up to 3 times within the same L1 sync iteration). retrieveL1ToL2Message now scans a single L1 block (the one recorded on the local message) rather than a large range.

Changes

  • archiver: Refactored handleL1ToL2Messages to always advance the syncpoint on success, with rollback-and-retry on mismatch. Re-throws unexpected (non-MessageStoreError) exceptions instead of swallowing them. Updated README to document the new sync logic.
  • archiver (tests): Improved fake_l1_state to correctly filter messages by block number in getState and support getMessageSentEventByHash(msgHash, l1BlockHash).
  • ethereum: Updated InboxContract.getMessageSentEventByHash signature to take (msgHash, l1BlockHash) instead of (hash, fromBlock, toBlock).
  • foundation: Added retryTimes utility (like retryUntil but with a retry count instead of a timeout).

Notes on the backport

v4 does not have the setInboxTreeInProgress / tree-in-progress persistence concept, so this backport differs from the original PR in the following ways:

  • setMessageSyncState is simplified to take only l1Block (the treeInProgress parameter is dropped, since there is nothing to persist in v4).
  • The new tree-in-progress guard tests from the original PR are not included (they do not apply to v4).
  • The fake_l1_state.getState improvements (computing treeInProgress from checkpoint/message visibility) are kept as-is — InboxContractState.treeInProgress is still returned by the real inbox contract in v4.
  • getInboxTreeInProgress on the message store is not added.

The two commits are preserved (cherry-pick with conflicts + resolution) so the adaptations are easier to review — PR should merge with ci-no-squash.

spalladino and others added 2 commits April 16, 2026 18:25
…L1 block (backport #22154)

The messages syncpoint used to track the L1 block of the last downloaded
message, causing unnecessary re-scans when no messages were sent for a
long time. Now it always advances to currentL1BlockNumber, with the
rolling hash check and rollback logic providing reorg protection.

Also moves setInboxTreeInProgress to after message insertion to prevent
concurrent reads from seeing a checkpoint as sealed before its messages
are available, and fixes a pre-existing division by zero in metrics when
a batch has no messages.

NOTE: Cherry-picked with conflicts still present; resolved in following commit.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
v4 has no setInboxTreeInProgress/treeInProgress persistence concept, so:
- simplify setMessageSyncState to take only l1Block (drop treeInProgress param)
- drop the tree-in-progress guard tests that don't apply to v4
- keep the improved fake_l1_state getState that computes treeInProgress
  from checkpoint/message visibility (InboxContractState.treeInProgress
  is still returned by the real inbox contract in v4)
- drop getInboxTreeInProgress from message_store

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@spalladino spalladino requested a review from a team April 16, 2026 21:56
spalladino and others added 2 commits April 17, 2026 13:11
…22641) [conflicts]

Cherry-pick of 4a10365 with unresolved conflicts in l1_synchronizer.ts.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Use remote messages state in rollbackL1ToL2Messages. On v4 the
syncpoint does not need treeInProgress, so only destructure
messagesRollingHash.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@spalladino spalladino closed this Apr 20, 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