@aztec/sequencer-client 0.0.1-commit.e2b2873ed → 0.0.1-commit.e304674f1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/dest/client/sequencer-client.d.ts +15 -7
  2. package/dest/client/sequencer-client.d.ts.map +1 -1
  3. package/dest/client/sequencer-client.js +60 -30
  4. package/dest/config.d.ts +26 -6
  5. package/dest/config.d.ts.map +1 -1
  6. package/dest/config.js +44 -21
  7. package/dest/global_variable_builder/global_builder.d.ts +15 -11
  8. package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
  9. package/dest/global_variable_builder/global_builder.js +29 -25
  10. package/dest/global_variable_builder/index.d.ts +2 -2
  11. package/dest/global_variable_builder/index.d.ts.map +1 -1
  12. package/dest/publisher/config.d.ts +47 -17
  13. package/dest/publisher/config.d.ts.map +1 -1
  14. package/dest/publisher/config.js +121 -42
  15. package/dest/publisher/index.d.ts +2 -1
  16. package/dest/publisher/index.d.ts.map +1 -1
  17. package/dest/publisher/l1_tx_failed_store/factory.d.ts +11 -0
  18. package/dest/publisher/l1_tx_failed_store/factory.d.ts.map +1 -0
  19. package/dest/publisher/l1_tx_failed_store/factory.js +22 -0
  20. package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts +59 -0
  21. package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts.map +1 -0
  22. package/dest/publisher/l1_tx_failed_store/failed_tx_store.js +1 -0
  23. package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.d.ts +15 -0
  24. package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.d.ts.map +1 -0
  25. package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.js +34 -0
  26. package/dest/publisher/l1_tx_failed_store/index.d.ts +4 -0
  27. package/dest/publisher/l1_tx_failed_store/index.d.ts.map +1 -0
  28. package/dest/publisher/l1_tx_failed_store/index.js +2 -0
  29. package/dest/publisher/sequencer-publisher-factory.d.ts +11 -5
  30. package/dest/publisher/sequencer-publisher-factory.d.ts.map +1 -1
  31. package/dest/publisher/sequencer-publisher-factory.js +27 -3
  32. package/dest/publisher/sequencer-publisher.d.ts +82 -37
  33. package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
  34. package/dest/publisher/sequencer-publisher.js +430 -118
  35. package/dest/sequencer/checkpoint_proposal_job.d.ts +36 -9
  36. package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -1
  37. package/dest/sequencer/checkpoint_proposal_job.js +361 -192
  38. package/dest/sequencer/checkpoint_voter.d.ts +1 -2
  39. package/dest/sequencer/checkpoint_voter.d.ts.map +1 -1
  40. package/dest/sequencer/checkpoint_voter.js +2 -5
  41. package/dest/sequencer/events.d.ts +2 -1
  42. package/dest/sequencer/events.d.ts.map +1 -1
  43. package/dest/sequencer/metrics.d.ts +21 -5
  44. package/dest/sequencer/metrics.d.ts.map +1 -1
  45. package/dest/sequencer/metrics.js +97 -15
  46. package/dest/sequencer/sequencer.d.ts +40 -17
  47. package/dest/sequencer/sequencer.d.ts.map +1 -1
  48. package/dest/sequencer/sequencer.js +152 -95
  49. package/dest/sequencer/timetable.d.ts +7 -3
  50. package/dest/sequencer/timetable.d.ts.map +1 -1
  51. package/dest/sequencer/timetable.js +21 -12
  52. package/dest/sequencer/types.d.ts +2 -2
  53. package/dest/sequencer/types.d.ts.map +1 -1
  54. package/dest/test/index.d.ts +3 -5
  55. package/dest/test/index.d.ts.map +1 -1
  56. package/dest/test/mock_checkpoint_builder.d.ts +11 -11
  57. package/dest/test/mock_checkpoint_builder.d.ts.map +1 -1
  58. package/dest/test/mock_checkpoint_builder.js +45 -34
  59. package/dest/test/utils.d.ts +3 -3
  60. package/dest/test/utils.d.ts.map +1 -1
  61. package/dest/test/utils.js +5 -4
  62. package/package.json +27 -28
  63. package/src/client/sequencer-client.ts +76 -30
  64. package/src/config.ts +56 -27
  65. package/src/global_variable_builder/global_builder.ts +38 -27
  66. package/src/global_variable_builder/index.ts +1 -1
  67. package/src/publisher/config.ts +153 -43
  68. package/src/publisher/index.ts +3 -0
  69. package/src/publisher/l1_tx_failed_store/factory.ts +32 -0
  70. package/src/publisher/l1_tx_failed_store/failed_tx_store.ts +55 -0
  71. package/src/publisher/l1_tx_failed_store/file_store_failed_tx_store.ts +46 -0
  72. package/src/publisher/l1_tx_failed_store/index.ts +3 -0
  73. package/src/publisher/sequencer-publisher-factory.ts +38 -9
  74. package/src/publisher/sequencer-publisher.ts +503 -168
  75. package/src/sequencer/README.md +81 -12
  76. package/src/sequencer/checkpoint_proposal_job.ts +471 -201
  77. package/src/sequencer/checkpoint_voter.ts +1 -12
  78. package/src/sequencer/events.ts +1 -1
  79. package/src/sequencer/metrics.ts +106 -18
  80. package/src/sequencer/sequencer.ts +216 -109
  81. package/src/sequencer/timetable.ts +26 -15
  82. package/src/sequencer/types.ts +1 -1
  83. package/src/test/index.ts +2 -4
  84. package/src/test/mock_checkpoint_builder.ts +63 -49
  85. package/src/test/utils.ts +5 -2
@@ -1,8 +1,8 @@
1
1
  # Sequencer Timing Model
2
2
 
3
- The Aztec sequencer divides each slot into **fixed-duration sub-slots**. Each sub-slot has a pre-defined start and end time based on an initialization offset (how much time we expect syncing the previous slot will take), a finalization time (how much time we need for closing a checkpoint and publishing it to L1), and the configured block duration.
3
+ The Aztec sequencer divides each slot into **fixed-duration sub-slots**. Each sub-slot has a pre-defined start and end time based on an initialization offset (how much time we expect syncing the previous slot will take), the configured block duration, and whether checkpoint finalization is paid for in the current slot or deferred under proposer pipelining.
4
4
 
5
- **Example: 72-second slot with 8-second sub-slots**
5
+ **Example: 72-second slot with 8-second sub-slots (non-pipelined)**
6
6
 
7
7
  ```
8
8
  0s: Slot starts
@@ -31,7 +31,7 @@ Deadlines are fixed relative to slot start, not relative to when work actually c
31
31
 
32
32
  ## Overview
33
33
 
34
- The Aztec sequencer operates in fixed-duration **slots** (typically 72 seconds). During each slot, a designated proposer builds multiple **blocks** containing transactions over multiple **sub-slots**, then collects a single round of attestations for the entire **checkpoint** from validators, and finally publishes the resulting checkpoint to L1 Ethereum.
34
+ The Aztec sequencer operates in fixed-duration **slots** (typically 72 seconds). During each slot, a designated proposer builds multiple **blocks** containing transactions over multiple **sub-slots**. In the default mode, the same slot also reserves time to collect attestations for the resulting **checkpoint**, finalize it, and publish it to L1 Ethereum. When proposer pipelining is enabled, the slot budget for block building is larger because checkpoint finalization is deferred to the next target slot.
35
35
 
36
36
  ## Key Concepts
37
37
 
@@ -42,12 +42,14 @@ The Aztec sequencer operates in fixed-duration **slots** (typically 72 seconds).
42
42
  - **Checkpoint**: The collection of all blocks built in a slot, attested by validators and published to L1
43
43
  - **Sub-slot**: A fixed-duration time window within a slot (e.g., 8 seconds) during which a block should be built
44
44
 
45
- In a typical configuration, a 72-second slot contains:
45
+ In a typical configuration without pipelining, a 72-second slot contains:
46
46
  - 1 initialization period (2 seconds)
47
47
  - 5 block-building sub-slots (8 seconds each = 40 seconds)
48
48
  - 1 last validator re-execution sub-slot (8 seconds)
49
49
  - 1 attestation and publishing period (17 seconds)
50
50
 
51
+ With proposer pipelining enabled, the last validator re-execution sub-slot is still reserved, but the checkpoint finalization and L1 publishing budget is no longer subtracted when deciding how many block-building sub-slots fit in the slot.
52
+
51
53
  ### The Fixed Sub-Slot Model
52
54
 
53
55
  Building multiple blocks per slot uses **fixed sub-slots** with predictable deadlines:
@@ -75,14 +77,18 @@ These values are configurable but must satisfy certain constraints (explained be
75
77
 
76
78
  ## Calculating Sub-Slots and Blocks
77
79
 
78
- Given a slot configuration, we calculate how many blocks fit using this formula:
80
+ Given a slot configuration, we calculate how many blocks fit using these formulas:
79
81
 
80
82
  ```
81
- timeReservedAtEnd = blockDuration (last sub-slot for reexecution)
82
- + propagationTime (validators receive proposal)
83
- + propagationTime (attestations come back)
84
- + finalizationTime (checkpoint finalization)
85
- + l1PublishingTime (L1 transaction)
83
+ checkpointFinalizationTime = propagationTime
84
+ + propagationTime
85
+ + finalizationTime
86
+ + l1PublishingTime
87
+
88
+ timeReservedAtEnd (normal mode) = blockDuration (last sub-slot for reexecution)
89
+ + checkpointFinalizationTime
90
+
91
+ timeReservedAtEnd (pipelining) = blockDuration (last sub-slot for reexecution only)
86
92
 
87
93
  timeAvailableForBlocks = slotDuration - initializationOffset - timeReservedAtEnd
88
94
 
@@ -101,6 +107,62 @@ This means:
101
107
  - Sub-slot 6: Reserved for validator re-execution of block 5
102
108
  - After sub-slot 6: Attestation collection, finalization, and L1 publishing
103
109
 
110
+ **The same slot with proposer pipelining enabled:**
111
+ ```
112
+ timeReservedAtEnd = 8s
113
+ timeAvailableForBlocks = 72s - 2s - 8s = 62s
114
+ numberOfBlocks = floor(62s / 8s) = 7 blocks
115
+ ```
116
+
117
+ The extra two block opportunities come from not charging the current slot for checkpoint finalization and L1 publishing.
118
+
119
+ ### Pipelining Mode
120
+
121
+ When proposer pipelining is enabled, the sequencer uses the current wall-clock slot to build the checkpoint for the **next target slot**.
122
+
123
+ It helps to think in terms of two different slots:
124
+
125
+ - **Wall-clock slot N-1**: The sequencer initializes checkpoint `N`, builds its blocks, and validators re-execute the last block
126
+ - **Target slot N**: Checkpoint `N` is proposed, attestations are gathered, and the L1 transaction is submitted
127
+
128
+ So the work is split like this:
129
+
130
+ - **During slot N-1**: Initialization, block building, and last-block re-execution
131
+ - **Near the end of slot N-1**: The checkpoint proposal is broadcast and validators attest to checkpoint N.
132
+ - **During slot N**: The proposer collects signatures, and the checkpoint is submitted to L1
133
+
134
+ In other words, pipelining does not mean "do everything for slot N earlier". It specifically moves **block production and block re-execution** earlier, while **checkpoint proposal, attestation gathering, and L1 submission** remain aligned with slot `N`.
135
+
136
+ **Example: building checkpoint 12 while wall-clock time is in slot 11**
137
+ ```
138
+ Slot 11 (wall clock):
139
+ - Build blocks that will make up checkpoint 12
140
+ - Validators re-execute the last block of checkpoint 12
141
+ - Broadcast checkpoint 12 proposal
142
+ - Collect checkpoint 12 attestations
143
+
144
+ Slot 12 (target/submission slot):
145
+ - Collect remaining checkpoint 12 attestations
146
+ - Submit checkpoint 12 to L1
147
+ ```
148
+
149
+ For timetable purposes, this changes two things:
150
+
151
+ - `maxNumberOfBlocks` is computed by reserving only the final validator re-execution sub-slot
152
+ - `initializeDeadline` no longer subtracts checkpoint finalization time; it only requires enough time for initialization, execution, and validator re-execution
153
+
154
+ In code, that means:
155
+
156
+ ```
157
+ initializeDeadline (normal mode) =
158
+ slotDuration - initializationOffset - 2 * minExecutionTime - checkpointFinalizationTime
159
+
160
+ initializeDeadline (pipelining) =
161
+ slotDuration - initializationOffset - 2 * minExecutionTime
162
+ ```
163
+
164
+ The fixed sub-slot deadlines themselves do not change. Pipelining only changes how much of the slot is considered available for block building.
165
+
104
166
  ## The Sequencer's Work
105
167
 
106
168
  When elected as proposer for a slot, the sequencer performs these tasks:
@@ -226,7 +288,9 @@ After the last block is built and validators have re-executed it:
226
288
 
227
289
  **Time reserved:** `2*propagationTime + finalizationTime + l1PublishingTime = 2s + 2s + 1s + 12s = 17s`
228
290
 
229
- This 17s comes after the last sub-slot, ensuring we have enough time to complete the checkpoint. If the sequencer receives the necessary attestations before the reserved time, the L1 tx is submitted earlier.
291
+ In the non-pipelined path, this 17s comes after the last sub-slot, ensuring we have enough time to complete the checkpoint. If the sequencer receives the necessary attestations before the reserved time, the L1 tx is submitted earlier.
292
+
293
+ With proposer pipelining enabled, this finalization budget is not charged against the current slot when calculating how many blocks fit. The checkpoint is instead queued for submission at the start of the target slot, so proposal broadcast, attestation gathering, and L1 submission happen in slot `N` while block building and block re-execution already happened in slot `N-1`.
230
294
 
231
295
  ## Handling Timing Variations
232
296
 
@@ -399,7 +463,7 @@ When configuring timing parameters, ensure these constraints are satisfied:
399
463
 
400
464
  ### Minimum Slot Duration
401
465
 
402
- For a valid configuration:
466
+ For a valid multi-block configuration without pipelining:
403
467
  ```
404
468
  slotDuration >= initializationOffset
405
469
  + blockDuration * 2 (at least 2 blocks)
@@ -414,6 +478,11 @@ Simplified:
414
478
  slotDuration >= initializationOffset + 3*blockDuration + 2*propagationTime + finalizationTime + l1PublishingTime
415
479
  ```
416
480
 
481
+ With proposer pipelining enabled, the same "at least 2 buildable blocks plus the final validator re-execution sub-slot" requirement becomes:
482
+ ```
483
+ slotDuration >= initializationOffset + 3*blockDuration
484
+ ```
485
+
417
486
  **Example:**
418
487
  ```
419
488
  slotDuration >= 2s + 3*8s + 2*2s + 1s + 12s = 2s + 24s + 4s + 1s + 12s = 43s