-
Notifications
You must be signed in to change notification settings - Fork 575
feat: Multiple blocks per checkpoint #18825
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
0f4ef07 to
6c17d6c
Compare
2249b20 to
e6c739f
Compare
| ...booleanConfigHelper(DefaultSequencerConfig.shuffleAttestationOrdering), | ||
| }, | ||
| blockDurationMs: { | ||
| env: 'SEQ_BLOCK_DURATION_MS', |
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.
Would it be more intuitive to configure a 'num blocks per slot' instead?
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.
Fair. I wanted to be more explicit, since block duration is not just slot_duration / num_blocks. It also depends on the SEQ_L1_PUBLISHING_TIME_ALLOWANCE_IN_SLOT below, plus some constant overheads, plus how late we actually started building (affected by sync time). This ultimately relates to the big TODO I have on the timetable.
| env: 'SEQ_MAX_L1_TX_INCLUSION_TIME_INTO_SLOT', | ||
| description: 'How many seconds into an L1 slot we can still send a tx and get it mined.', | ||
| l1PublishingTime: { | ||
| env: 'SEQ_L1_PUBLISHING_TIME_ALLOWANCE_IN_SLOT', |
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.
Does this not have a default?
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.
Default depends on whether we're running on Anvil or a real network, same as the old env var it replaced
| return await this.db.close(); | ||
| } | ||
|
|
||
| async [Symbol.dispose](): Promise<void> { |
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.
Lovely!
e7f1686 to
eed0404
Compare
PhilWindle
left a comment
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.
This is a fantastic PR, thanks @spalladino .
I have a couple of questions but we follow up separately. I don't want to hold this up or we will get merge conflicts. I also want to get this running on next ASAP.
yarn-project/sequencer-client/src/publisher/sequencer-publisher.ts
Outdated
Show resolved
Hide resolved
f1339ca to
4ed9f7e
Compare
Summary
This PR refactors the sequencer to propose checkpoints instead of individual blocks, enabling multi-block checkpoint proposals. The sequencer now builds multiple blocks within a slot and packages them into a single checkpoint for L1 publication.
Yes, this text was written by Claude
Environment Variables
New
SEQ_BLOCK_DURATION_MS: Duration per block in milliseconds when building multiple blocks per slot. If undefined (default), builds a single block per slot using the full slot duration.SEQ_BUILD_CHECKPOINT_IF_EMPTY: Whether to build and publish an empty checkpoint when there are no txs (defaults totrue).Changed
SEQ_MAX_L1_TX_INCLUSION_TIME_INTO_SLOTchanged toSEQ_L1_PUBLISHING_TIME_ALLOWANCE_IN_SLOT: Aka "the dead zone". Renamed to better reflect its purpose of how much time (in seconds) we allow in the slot for publishing the L1 tx (defaults to 1 L1 slot).SEQ_TX_POLLING_INTERVAL_MSchanged toSEQ_POLLING_INTERVAL_MS: This is the polling for the sequencer loop, unrelated to polling for txs.Architecture Changes
Main
SequencerSequencer now focuses on orchestration and state management by delegating checkpoint proposal logic to a job-like class. It now manages lifecycle of checkpoint proposal jobs and handles checkpoint invalidation.
CheckpointProposalJob(new)Extracted checkpoint proposal logic into a dedicated, self-contained job that manages the full lifecycle of building and proposing a checkpoint. Handles block building loop, attestation collection, L1 publishing, and P2P broadcasting.
CheckpointVoter(new)Handles voting for slashing and governance proposals, called from both the main sequencer and the proposal job.
SequencerPublisherUpdated the publisher to work with Checkpoints as opposed to Blocks.
CheckpointsBuilder(new)Emulates the old
BlockBuilderbut for checkpoints, managing checkpoint-level state, and orchestrating building multiple blocks within a checkpoint. Builds on top of theLightweightCheckpointBuilder.Miscellaneous Changes
Disposable Interface
MerkleTreeWriteOperations,GuardedMerkleTree, andHintingDbSourcenow implement aDisposableinterface for proper resource cleanup.Global Variables
Introduced a
CheckpointGlobalVariablesfor checkpoint-level constants, separating block-level and checkpoint-level variables.Sequencer Config
All sequencer config defaults are now in a single
DefaultSequencerConfigobject, and theSequencerworks with a config type with most entries defined.Placeholders
Validator Client
Block proposals currently create dummy checkpoint proposals, and checkpoint proposal creation needs to be distinguished from block proposals.
Archiver & World State Sync
Provisional blocks are not yet sent to archiver and world state, actual sync mechanism to be wired once available.
P2P Broadcasting
Checkpoint proposals and provisional blocks use placeholder P2P API, needs wiring to new P2P protocol once available.
Pending Work