Skip to content

fix: Wait until rollup catches up to inbox for msg sync#17039

Merged
spalladino merged 1 commit intonextfrom
palla/fix-is-msg-synced
Sep 16, 2025
Merged

fix: Wait until rollup catches up to inbox for msg sync#17039
spalladino merged 1 commit intonextfrom
palla/fix-is-msg-synced

Conversation

@spalladino
Copy link
Contributor

@spalladino spalladino commented Sep 15, 2025

Do not acknowledge an L1 to L2 message as synced until the rollup
pending block number has caught up with the message block. The inbox
block number may drift way ahead of the rollup block number in the event
of a reorg or if there are too many l1 to l2 messages being inserted.

Note that the existing approach used throughout the codebase of waiting
for two blocks if flawed, since if there was an earlier reorg on the
chain, then the inbox will have drifted and the message will require
more blocks to become available.

This PR does NOT remove the existing isL1ToL2MessageSynced call, since
it's used all over the place, but rather flags it as deprecated.

Instead, the node and pxe now expose a function that returns the block
in which the message is to be available, and aztecjs provides a helper
to wait until the block is reached.

The bot factory is updated to use this new approach.

Copy link
Contributor

@LHerskind LHerskind left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good find.

/** Returns whether a message with the given leaf index is synced */
static isMessageSynced(index: bigint, l2BlockNumber: number): boolean {
const messageL2Block = this.l2BlockFromIndex(index);
return messageL2Block <= l2BlockNumber;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think you can get away with

return messageL2Block <= l2BlockNumber + 1;

since the messages should be inserted at the start of the block, so can work if it is the next block. But this is stricter so should also work well, just slightly longer than needed.

@spalladino spalladino force-pushed the palla/fix-is-msg-synced branch from d20698a to ae630ed Compare September 15, 2025 22:11
@PhilWindle PhilWindle added this pull request to the merge queue Sep 16, 2025
github-merge-queue bot pushed a commit that referenced this pull request Sep 16, 2025
Do not acknowledge an L1 to L2 message as synced until the rollup
pending block number has caught up with the message block. The inbox
block number may drift way ahead of the rollup block number in the event
of a reorg or if there are too many l1 to l2 messages being inserted.

Note that the existing approach used throughout the codebase of waiting
for two blocks if flawed, since if there was an earlier reorg on the
chain, then the inbox will have drifted and the message will require
more blocks to become available.

This PR does NOT remove the existing isL1ToL2MessageSynced call, since
it's used all over the place, but rather flags it as deprecated.

Instead, the node and pxe now expose a function that returns the block
in which the message is to be available, and aztecjs provides a helper
to wait until the block is reached.

The bot factory is updated to use this new approach.
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Sep 16, 2025
@PhilWindle PhilWindle added this pull request to the merge queue Sep 16, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Sep 16, 2025
alexghr added a commit that referenced this pull request Sep 16, 2025
This PR takes the changes introduced by
[this](#17039) PR
and applies then to `v2`.

---------

Co-authored-by: Alex Gherghisan <alexghr@users.noreply.github.com>
Co-authored-by: Santiago Palladino <santiago@aztecprotocol.com>
Co-authored-by: alexghr <3816165+alexghr@users.noreply.github.com>
Do not acknowledge an L1 to L2 message as synced until the rollup
pending block number has caught up with the message block. The inbox
block number may drift way ahead of the rollup block number in the event
of a reorg or if there are too many l1 to l2 messages being inserted.

Note that the existing approach used throughout the codebase of waiting
for two blocks if flawed, since if there was an earlier reorg on the
chain, then the inbox will have drifted and the message will require
more blocks to become available.

This PR does NOT remove the existing isL1ToL2MessageSynced call, since
it's used all over the place, but rather flags it as deprecated.
Instead, the node and pxe now expose a function that returns the block
in which the message is to be available, and aztecjs provides a helper
to wait until the block is reached.

The bot factory is updated to use this new approach.
@spalladino spalladino force-pushed the palla/fix-is-msg-synced branch from ae630ed to 7b8396d Compare September 16, 2025 15:20
@spalladino
Copy link
Contributor Author

I've fixed a flake on the l1_to_l2.test and added a test for the bot setup on e2e_bot.test

@spalladino spalladino added this pull request to the merge queue Sep 16, 2025
Merged via the queue into next with commit 9f2e319 Sep 16, 2025
14 checks passed
@spalladino spalladino deleted the palla/fix-is-msg-synced branch September 16, 2025 16:54
spalladino added a commit that referenced this pull request Sep 25, 2025
Do not acknowledge an L1 to L2 message as synced until the rollup
pending block number has caught up with the message block. The inbox
block number may drift way ahead of the rollup block number in the event
of a reorg or if there are too many l1 to l2 messages being inserted.

Note that the existing approach used throughout the codebase of waiting
for two blocks if flawed, since if there was an earlier reorg on the
chain, then the inbox will have drifted and the message will require
more blocks to become available.

This PR does NOT remove the existing isL1ToL2MessageSynced call, since
it's used all over the place, but rather flags it as deprecated.

Instead, the node and pxe now expose a function that returns the block
in which the message is to be available, and aztecjs provides a helper
to wait until the block is reached.

The bot factory is updated to use this new approach.
PhilWindle added a commit that referenced this pull request Sep 29, 2025
This PR is a backport of the following into V2.

#17169
#17176 
#17186 
#17178 
#17177
#17130
#17039 
#17230
#17245 
#17273
#17186
#17192
#17194 
#17225 
#17285 
#17312 
#17326

---------

Co-authored-by: Alex Gherghisan <alexghr@users.noreply.github.com>
Co-authored-by: Santiago Palladino <santiago@aztec-labs.com>
Co-authored-by: Santiago Palladino <spalladino@gmail.com>
Co-authored-by: alexghr <3816165+alexghr@users.noreply.github.com>
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.

2 participants