-
Notifications
You must be signed in to change notification settings - Fork 583
feat(pxe): add syncChainTip config to control anchor block source #19874
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Adds a `PXE_SYNC_CHAIN_TIP` config option that controls which chain tip the PXE syncs to: - `proposed` (default): Current behavior, updates anchor on every blocks-added event - `checkpointed`: Only update anchor when blocks are checkpointed on L1 - `proven`: Only update anchor when blocks are proven - `finalized`: Only update anchor when blocks are finalized This allows PXE users to choose a more conservative anchor block source to avoid transactions being built against provisional blocks that may get pruned. Also improves handling of chain prune events by ignoring prunes when the anchor is already at or below the prune point. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
| const blockHeader = await this.node.getBlockHeader(BlockNumber(event.block.number)); | ||
| if (blockHeader) { | ||
| await this.updateAnchorBlockHeader(blockHeader); | ||
| } | ||
| } | ||
| break; | ||
| } | ||
| case 'chain-finalized': { | ||
| if (this.config.syncChainTip === 'finalized') { | ||
| const blockHeader = await this.node.getBlockHeader(BlockNumber(event.block.number)); | ||
| if (blockHeader) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These two will add a full roundtrip to these sync modes. Is it possible to have the events include the block header already, like in the other modes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The full roundtrip is already happening in the other sync modes. The only difference is whether it's hidden in the L2BlockStream or explicit here, so they're all equally inefficient.
| if (currentAnchorBlockNumber <= event.block.number) { | ||
| this.log.verbose( | ||
| `Ignoring prune event to block ${event.block.number} greater than current anchor block ${currentAnchorBlockNumber}`, | ||
| { pruneEvent: event, currentAnchorBlockHeader: currentAnchorBlockHeader.toInspect() }, | ||
| ); | ||
| return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I worry that this might break once we add the capacity to select a per-call anchor block.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd expect most of this class to need a rework when that's implemented.
Flakey Tests🤖 says: This CI run detected 1 tests that failed, but were tolerated due to a .test_patterns.yml entry. |
Summary
Adds a
PXE_SYNC_CHAIN_TIPconfig option that controls which chain tip the PXE syncs to:proposed(default): Current behavior, updates anchor on everyblocks-addedeventcheckpointed: Only update anchor when blocks are checkpointed on L1proven: Only update anchor when blocks are provenfinalized: Only update anchor when blocks are finalizedThis allows PXE users to choose a more conservative anchor block source to avoid transactions being built against provisional blocks that may get pruned.
Motivation
With
skipPushProposedBlocksToArchiver: false, the sequencer pushes provisional blocks to the archiver before they're checkpointed on L1. The PXE would sync these blocks and use them as anchor, but if those blocks get pruned (slot passes without checkpoint), transactions built against them become invalid.By setting
PXE_SYNC_CHAIN_TIP=checkpointed, the PXE will only advance its anchor when blocks are confirmed on L1, making transactions safer.Changes
syncChainTipconfig option toBlockSynchronizerConfigBlockSynchronizerto handlechain-checkpointed,chain-proven, andchain-finalizedevents based on configTest plan
syncChainTipmodesyarn test src/block_synchronizer/block_synchronizer.test.tsin pxe package🤖 Generated with Claude Code