@aztec/sequencer-client 0.0.1-commit.03f7ef2 → 0.0.1-commit.04852196a

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 (106) hide show
  1. package/dest/client/sequencer-client.d.ts +26 -11
  2. package/dest/client/sequencer-client.d.ts.map +1 -1
  3. package/dest/client/sequencer-client.js +99 -16
  4. package/dest/config.d.ts +24 -6
  5. package/dest/config.d.ts.map +1 -1
  6. package/dest/config.js +45 -28
  7. package/dest/global_variable_builder/global_builder.d.ts +5 -7
  8. package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
  9. package/dest/global_variable_builder/global_builder.js +13 -13
  10. package/dest/index.d.ts +2 -3
  11. package/dest/index.d.ts.map +1 -1
  12. package/dest/index.js +1 -2
  13. package/dest/publisher/config.d.ts +35 -17
  14. package/dest/publisher/config.d.ts.map +1 -1
  15. package/dest/publisher/config.js +106 -42
  16. package/dest/publisher/index.d.ts +2 -1
  17. package/dest/publisher/index.d.ts.map +1 -1
  18. package/dest/publisher/l1_tx_failed_store/factory.d.ts +11 -0
  19. package/dest/publisher/l1_tx_failed_store/factory.d.ts.map +1 -0
  20. package/dest/publisher/l1_tx_failed_store/factory.js +22 -0
  21. package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts +59 -0
  22. package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts.map +1 -0
  23. package/dest/publisher/l1_tx_failed_store/failed_tx_store.js +1 -0
  24. package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.d.ts +15 -0
  25. package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.d.ts.map +1 -0
  26. package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.js +34 -0
  27. package/dest/publisher/l1_tx_failed_store/index.d.ts +4 -0
  28. package/dest/publisher/l1_tx_failed_store/index.d.ts.map +1 -0
  29. package/dest/publisher/l1_tx_failed_store/index.js +2 -0
  30. package/dest/publisher/sequencer-publisher-factory.d.ts +12 -4
  31. package/dest/publisher/sequencer-publisher-factory.d.ts.map +1 -1
  32. package/dest/publisher/sequencer-publisher-factory.js +27 -2
  33. package/dest/publisher/sequencer-publisher-metrics.d.ts +1 -1
  34. package/dest/publisher/sequencer-publisher-metrics.d.ts.map +1 -1
  35. package/dest/publisher/sequencer-publisher-metrics.js +23 -86
  36. package/dest/publisher/sequencer-publisher.d.ts +44 -25
  37. package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
  38. package/dest/publisher/sequencer-publisher.js +781 -101
  39. package/dest/sequencer/checkpoint_proposal_job.d.ts +39 -13
  40. package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -1
  41. package/dest/sequencer/checkpoint_proposal_job.js +683 -79
  42. package/dest/sequencer/checkpoint_voter.d.ts +3 -2
  43. package/dest/sequencer/checkpoint_voter.d.ts.map +1 -1
  44. package/dest/sequencer/checkpoint_voter.js +34 -10
  45. package/dest/sequencer/index.d.ts +1 -3
  46. package/dest/sequencer/index.d.ts.map +1 -1
  47. package/dest/sequencer/index.js +0 -2
  48. package/dest/sequencer/metrics.d.ts +19 -7
  49. package/dest/sequencer/metrics.d.ts.map +1 -1
  50. package/dest/sequencer/metrics.js +131 -141
  51. package/dest/sequencer/sequencer.d.ts +46 -23
  52. package/dest/sequencer/sequencer.d.ts.map +1 -1
  53. package/dest/sequencer/sequencer.js +514 -67
  54. package/dest/sequencer/timetable.d.ts +4 -6
  55. package/dest/sequencer/timetable.d.ts.map +1 -1
  56. package/dest/sequencer/timetable.js +7 -11
  57. package/dest/sequencer/types.d.ts +5 -2
  58. package/dest/sequencer/types.d.ts.map +1 -1
  59. package/dest/test/index.d.ts +4 -7
  60. package/dest/test/index.d.ts.map +1 -1
  61. package/dest/test/mock_checkpoint_builder.d.ts +28 -16
  62. package/dest/test/mock_checkpoint_builder.d.ts.map +1 -1
  63. package/dest/test/mock_checkpoint_builder.js +86 -34
  64. package/dest/test/utils.d.ts +13 -9
  65. package/dest/test/utils.d.ts.map +1 -1
  66. package/dest/test/utils.js +27 -17
  67. package/package.json +30 -28
  68. package/src/client/sequencer-client.ts +139 -23
  69. package/src/config.ts +59 -38
  70. package/src/global_variable_builder/global_builder.ts +14 -14
  71. package/src/index.ts +1 -9
  72. package/src/publisher/config.ts +121 -43
  73. package/src/publisher/index.ts +3 -0
  74. package/src/publisher/l1_tx_failed_store/factory.ts +32 -0
  75. package/src/publisher/l1_tx_failed_store/failed_tx_store.ts +55 -0
  76. package/src/publisher/l1_tx_failed_store/file_store_failed_tx_store.ts +46 -0
  77. package/src/publisher/l1_tx_failed_store/index.ts +3 -0
  78. package/src/publisher/sequencer-publisher-factory.ts +39 -7
  79. package/src/publisher/sequencer-publisher-metrics.ts +17 -69
  80. package/src/publisher/sequencer-publisher.ts +420 -137
  81. package/src/sequencer/checkpoint_proposal_job.ts +361 -104
  82. package/src/sequencer/checkpoint_voter.ts +32 -7
  83. package/src/sequencer/index.ts +0 -2
  84. package/src/sequencer/metrics.ts +132 -148
  85. package/src/sequencer/sequencer.ts +160 -69
  86. package/src/sequencer/timetable.ts +13 -12
  87. package/src/sequencer/types.ts +4 -1
  88. package/src/test/index.ts +3 -6
  89. package/src/test/mock_checkpoint_builder.ts +147 -71
  90. package/src/test/utils.ts +58 -28
  91. package/dest/sequencer/block_builder.d.ts +0 -26
  92. package/dest/sequencer/block_builder.d.ts.map +0 -1
  93. package/dest/sequencer/block_builder.js +0 -129
  94. package/dest/sequencer/checkpoint_builder.d.ts +0 -63
  95. package/dest/sequencer/checkpoint_builder.d.ts.map +0 -1
  96. package/dest/sequencer/checkpoint_builder.js +0 -131
  97. package/dest/tx_validator/nullifier_cache.d.ts +0 -14
  98. package/dest/tx_validator/nullifier_cache.d.ts.map +0 -1
  99. package/dest/tx_validator/nullifier_cache.js +0 -24
  100. package/dest/tx_validator/tx_validator_factory.d.ts +0 -18
  101. package/dest/tx_validator/tx_validator_factory.d.ts.map +0 -1
  102. package/dest/tx_validator/tx_validator_factory.js +0 -53
  103. package/src/sequencer/block_builder.ts +0 -217
  104. package/src/sequencer/checkpoint_builder.ts +0 -217
  105. package/src/tx_validator/nullifier_cache.ts +0 -30
  106. package/src/tx_validator/tx_validator_factory.ts +0 -133
@@ -1,33 +1,32 @@
1
- import { type BlockNumber, CheckpointNumber } from '@aztec/foundation/branded-types';
1
+ import { type BlockNumber, CheckpointNumber, IndexWithinCheckpoint } from '@aztec/foundation/branded-types';
2
2
  import { Fr } from '@aztec/foundation/curves/bn254';
3
- import { Timer } from '@aztec/foundation/timer';
4
- import type { FunctionsOf } from '@aztec/foundation/types';
5
- import { L2BlockNew } from '@aztec/stdlib/block';
3
+ import { unfreeze } from '@aztec/foundation/types';
4
+ import { L2Block } from '@aztec/stdlib/block';
6
5
  import { Checkpoint } from '@aztec/stdlib/checkpoint';
7
- import { Gas } from '@aztec/stdlib/gas';
8
- import type { FullNodeBlockBuilderConfig, PublicProcessorLimits } from '@aztec/stdlib/interfaces/server';
6
+ import type {
7
+ FullNodeBlockBuilderConfig,
8
+ ICheckpointBlockBuilder,
9
+ ICheckpointsBuilder,
10
+ MerkleTreeWriteOperations,
11
+ PublicProcessorLimits,
12
+ } from '@aztec/stdlib/interfaces/server';
9
13
  import { CheckpointHeader } from '@aztec/stdlib/rollup';
10
14
  import { makeAppendOnlyTreeSnapshot } from '@aztec/stdlib/testing';
11
15
  import type { CheckpointGlobalVariables, Tx } from '@aztec/stdlib/tx';
12
-
13
- import type {
14
- BuildBlockInCheckpointResult,
15
- CheckpointBuilder,
16
- FullNodeCheckpointsBuilder,
17
- } from '../sequencer/checkpoint_builder.js';
16
+ import type { BuildBlockInCheckpointResult } from '@aztec/validator-client';
18
17
 
19
18
  /**
20
19
  * A fake CheckpointBuilder for testing that implements the same interface as the real one.
21
20
  * Can be seeded with blocks to return sequentially on each `buildBlock` call.
22
21
  */
23
- export class MockCheckpointBuilder implements FunctionsOf<CheckpointBuilder> {
24
- private blocks: L2BlockNew[] = [];
25
- private builtBlocks: L2BlockNew[] = [];
22
+ export class MockCheckpointBuilder implements ICheckpointBlockBuilder {
23
+ private blocks: L2Block[] = [];
24
+ private builtBlocks: L2Block[] = [];
26
25
  private usedTxsPerBlock: Tx[][] = [];
27
26
  private blockIndex = 0;
28
27
 
29
28
  /** Optional function to dynamically provide the block (alternative to seedBlocks) */
30
- private blockProvider: (() => L2BlockNew) | undefined = undefined;
29
+ private blockProvider: (() => L2Block) | undefined = undefined;
31
30
 
32
31
  /** Track calls for assertions */
33
32
  public buildBlockCalls: Array<{
@@ -35,6 +34,8 @@ export class MockCheckpointBuilder implements FunctionsOf<CheckpointBuilder> {
35
34
  timestamp: bigint;
36
35
  opts: PublicProcessorLimits;
37
36
  }> = [];
37
+ /** Track all consumed transaction hashes across buildBlock calls */
38
+ public consumedTxHashes: Set<string> = new Set();
38
39
  public completeCheckpointCalled = false;
39
40
  public getCheckpointCalled = false;
40
41
 
@@ -47,7 +48,7 @@ export class MockCheckpointBuilder implements FunctionsOf<CheckpointBuilder> {
47
48
  ) {}
48
49
 
49
50
  /** Seed the builder with blocks to return on successive buildBlock calls */
50
- seedBlocks(blocks: L2BlockNew[], usedTxsPerBlock?: Tx[][]): this {
51
+ seedBlocks(blocks: L2Block[], usedTxsPerBlock?: Tx[][]): this {
51
52
  this.blocks = blocks;
52
53
  this.usedTxsPerBlock = usedTxsPerBlock ?? blocks.map(() => []);
53
54
  this.blockIndex = 0;
@@ -59,7 +60,7 @@ export class MockCheckpointBuilder implements FunctionsOf<CheckpointBuilder> {
59
60
  * Set a function that provides blocks dynamically.
60
61
  * Useful for tests where the block is determined at call time (e.g., sequencer tests).
61
62
  */
62
- setBlockProvider(provider: () => L2BlockNew): this {
63
+ setBlockProvider(provider: () => L2Block): this {
63
64
  this.blockProvider = provider;
64
65
  this.blocks = [];
65
66
  return this;
@@ -69,8 +70,8 @@ export class MockCheckpointBuilder implements FunctionsOf<CheckpointBuilder> {
69
70
  return this.constants;
70
71
  }
71
72
 
72
- buildBlock(
73
- _pendingTxs: Iterable<Tx> | AsyncIterable<Tx>,
73
+ async buildBlock(
74
+ pendingTxs: Iterable<Tx> | AsyncIterable<Tx>,
74
75
  blockNumber: BlockNumber,
75
76
  timestamp: bigint,
76
77
  opts: PublicProcessorLimits,
@@ -78,15 +79,17 @@ export class MockCheckpointBuilder implements FunctionsOf<CheckpointBuilder> {
78
79
  this.buildBlockCalls.push({ blockNumber, timestamp, opts });
79
80
 
80
81
  if (this.errorOnBuild) {
81
- return Promise.reject(this.errorOnBuild);
82
+ throw this.errorOnBuild;
82
83
  }
83
84
 
84
- let block: L2BlockNew;
85
+ let block: L2Block;
85
86
  let usedTxs: Tx[];
86
87
 
87
88
  if (this.blockProvider) {
88
- // Dynamic mode: get block from provider
89
- block = this.blockProvider();
89
+ // Dynamic mode: get block from provider, cloning to avoid shared references across multiple buildBlock calls
90
+ block = L2Block.fromBuffer(this.blockProvider().toBuffer());
91
+ block.header.globalVariables.blockNumber = blockNumber;
92
+ await block.header.recomputeHash();
90
93
  usedTxs = [];
91
94
  this.builtBlocks.push(block);
92
95
  } else {
@@ -97,82 +100,94 @@ export class MockCheckpointBuilder implements FunctionsOf<CheckpointBuilder> {
97
100
  this.builtBlocks.push(block);
98
101
  }
99
102
 
100
- return Promise.resolve({
103
+ // Check that no pending tx has already been consumed
104
+ for await (const tx of pendingTxs) {
105
+ const hash = tx.getTxHash().toString();
106
+ if (this.consumedTxHashes.has(hash)) {
107
+ throw new Error(`Transaction ${hash} was already consumed in a previous block`);
108
+ }
109
+ }
110
+
111
+ // Add used txs to consumed set
112
+ for (const tx of usedTxs) {
113
+ this.consumedTxHashes.add(tx.getTxHash().toString());
114
+ }
115
+
116
+ return {
101
117
  block,
102
- publicGas: Gas.empty(),
103
118
  publicProcessorDuration: 0,
104
119
  numTxs: block?.body?.txEffects?.length ?? usedTxs.length,
105
- blockBuildingTimer: new Timer(),
106
120
  usedTxs,
107
121
  failedTxs: [],
108
- });
122
+ };
109
123
  }
110
124
 
111
125
  completeCheckpoint(): Promise<Checkpoint> {
112
126
  this.completeCheckpointCalled = true;
113
127
  const allBlocks = this.blockProvider ? this.builtBlocks : this.blocks;
114
- const lastBlock = allBlocks[allBlocks.length - 1];
115
- // Create a CheckpointHeader from the last block's header for testing
116
- const checkpointHeader = this.createCheckpointHeader(lastBlock);
117
- return Promise.resolve(
118
- new Checkpoint(
119
- makeAppendOnlyTreeSnapshot(lastBlock.header.globalVariables.blockNumber + 1),
120
- checkpointHeader,
121
- allBlocks,
122
- this.checkpointNumber,
123
- ),
124
- );
128
+ return this.buildCheckpoint(allBlocks);
125
129
  }
126
130
 
127
131
  getCheckpoint(): Promise<Checkpoint> {
128
132
  this.getCheckpointCalled = true;
129
133
  const builtBlocks = this.blockProvider ? this.builtBlocks : this.blocks.slice(0, this.blockIndex);
130
- const lastBlock = builtBlocks[builtBlocks.length - 1];
131
- if (!lastBlock) {
134
+ if (builtBlocks.length === 0) {
132
135
  throw new Error('No blocks built yet');
133
136
  }
134
- // Create a CheckpointHeader from the last block's header for testing
135
- const checkpointHeader = this.createCheckpointHeader(lastBlock);
136
- return Promise.resolve(
137
- new Checkpoint(
138
- makeAppendOnlyTreeSnapshot(lastBlock.header.globalVariables.blockNumber + 1),
139
- checkpointHeader,
140
- builtBlocks,
141
- this.checkpointNumber,
142
- ),
143
- );
137
+ return this.buildCheckpoint(builtBlocks);
144
138
  }
145
139
 
146
- /**
147
- * Creates a CheckpointHeader from a block's header for testing.
148
- * This is a simplified version that creates a minimal CheckpointHeader.
149
- */
150
- private createCheckpointHeader(block: L2BlockNew): CheckpointHeader {
151
- const header = block.header;
152
- const gv = header.globalVariables;
153
- return CheckpointHeader.empty({
154
- lastArchiveRoot: header.lastArchive.root,
155
- blockHeadersHash: Fr.random(), // Use random for testing
140
+ /** Builds a structurally valid Checkpoint from a list of blocks, fixing up indexes and archive chaining. */
141
+ private async buildCheckpoint(blocks: L2Block[]): Promise<Checkpoint> {
142
+ // Fix up indexWithinCheckpoint and archive chaining so the checkpoint passes structural validation.
143
+ for (let i = 0; i < blocks.length; i++) {
144
+ blocks[i].indexWithinCheckpoint = IndexWithinCheckpoint(i);
145
+ if (i > 0) {
146
+ unfreeze(blocks[i].header).lastArchive = blocks[i - 1].archive;
147
+ await blocks[i].header.recomputeHash();
148
+ }
149
+ }
150
+
151
+ const firstBlock = blocks[0];
152
+ const lastBlock = blocks[blocks.length - 1];
153
+ const gv = firstBlock.header.globalVariables;
154
+
155
+ const checkpointHeader = CheckpointHeader.empty({
156
+ lastArchiveRoot: firstBlock.header.lastArchive.root,
157
+ blockHeadersHash: Fr.random(),
156
158
  slotNumber: gv.slotNumber,
157
159
  timestamp: gv.timestamp,
158
160
  coinbase: gv.coinbase,
159
161
  feeRecipient: gv.feeRecipient,
160
162
  gasFees: gv.gasFees,
161
- totalManaUsed: header.totalManaUsed,
163
+ totalManaUsed: lastBlock.header.totalManaUsed,
162
164
  });
165
+
166
+ return new Checkpoint(
167
+ makeAppendOnlyTreeSnapshot(lastBlock.header.globalVariables.blockNumber + 1),
168
+ checkpointHeader,
169
+ blocks,
170
+ this.checkpointNumber,
171
+ );
172
+ }
173
+
174
+ /** Resets per-checkpoint state (built blocks, consumed txs) while preserving config (blockProvider, seeded blocks). */
175
+ resetCheckpointState(): void {
176
+ this.builtBlocks = [];
177
+ this.blockIndex = 0;
178
+ this.consumedTxHashes.clear();
179
+ this.completeCheckpointCalled = false;
180
+ this.getCheckpointCalled = false;
163
181
  }
164
182
 
165
183
  /** Reset for reuse in another test */
166
184
  reset(): void {
167
185
  this.blocks = [];
168
- this.builtBlocks = [];
169
186
  this.usedTxsPerBlock = [];
170
- this.blockIndex = 0;
171
187
  this.buildBlockCalls = [];
172
- this.completeCheckpointCalled = false;
173
- this.getCheckpointCalled = false;
174
188
  this.errorOnBuild = undefined;
175
189
  this.blockProvider = undefined;
190
+ this.resetCheckpointState();
176
191
  }
177
192
  }
178
193
 
@@ -181,7 +196,7 @@ export class MockCheckpointBuilder implements FunctionsOf<CheckpointBuilder> {
181
196
  * as FullNodeCheckpointsBuilder. Returns MockCheckpointBuilder instances.
182
197
  * Does NOT use jest mocks - this is a proper test double.
183
198
  */
184
- export class MockCheckpointsBuilder implements FunctionsOf<FullNodeCheckpointsBuilder> {
199
+ export class MockCheckpointsBuilder implements ICheckpointsBuilder {
185
200
  private checkpointBuilder: MockCheckpointBuilder | undefined;
186
201
 
187
202
  /** Track calls for assertions */
@@ -189,6 +204,16 @@ export class MockCheckpointsBuilder implements FunctionsOf<FullNodeCheckpointsBu
189
204
  checkpointNumber: CheckpointNumber;
190
205
  constants: CheckpointGlobalVariables;
191
206
  l1ToL2Messages: Fr[];
207
+ previousCheckpointOutHashes: Fr[];
208
+ feeAssetPriceModifier: bigint;
209
+ }> = [];
210
+ public openCheckpointCalls: Array<{
211
+ checkpointNumber: CheckpointNumber;
212
+ constants: CheckpointGlobalVariables;
213
+ l1ToL2Messages: Fr[];
214
+ previousCheckpointOutHashes: Fr[];
215
+ existingBlocks: L2Block[];
216
+ feeAssetPriceModifier: bigint;
192
217
  }> = [];
193
218
  public updateConfigCalls: Array<Partial<FullNodeBlockBuilderConfig>> = [];
194
219
 
@@ -218,6 +243,16 @@ export class MockCheckpointsBuilder implements FunctionsOf<FullNodeCheckpointsBu
218
243
  return this.checkpointBuilder;
219
244
  }
220
245
 
246
+ getConfig(): FullNodeBlockBuilderConfig {
247
+ return {
248
+ l1GenesisTime: 0n,
249
+ slotDuration: 24,
250
+ l1ChainId: 1,
251
+ rollupVersion: 1,
252
+ rollupManaLimit: 200_000_000,
253
+ };
254
+ }
255
+
221
256
  updateConfig(config: Partial<FullNodeBlockBuilderConfig>): void {
222
257
  this.updateConfigCalls.push(config);
223
258
  }
@@ -225,23 +260,64 @@ export class MockCheckpointsBuilder implements FunctionsOf<FullNodeCheckpointsBu
225
260
  startCheckpoint(
226
261
  checkpointNumber: CheckpointNumber,
227
262
  constants: CheckpointGlobalVariables,
263
+ feeAssetPriceModifier: bigint,
264
+ l1ToL2Messages: Fr[],
265
+ previousCheckpointOutHashes: Fr[],
266
+ _fork: MerkleTreeWriteOperations,
267
+ ): Promise<ICheckpointBlockBuilder> {
268
+ this.startCheckpointCalls.push({
269
+ checkpointNumber,
270
+ constants,
271
+ l1ToL2Messages,
272
+ previousCheckpointOutHashes,
273
+ feeAssetPriceModifier,
274
+ });
275
+
276
+ if (!this.checkpointBuilder) {
277
+ // Auto-create a builder if none was set
278
+ this.checkpointBuilder = new MockCheckpointBuilder(constants, checkpointNumber);
279
+ } else {
280
+ this.checkpointBuilder.resetCheckpointState();
281
+ }
282
+
283
+ return Promise.resolve(this.checkpointBuilder);
284
+ }
285
+
286
+ openCheckpoint(
287
+ checkpointNumber: CheckpointNumber,
288
+ constants: CheckpointGlobalVariables,
289
+ feeAssetPriceModifier: bigint,
228
290
  l1ToL2Messages: Fr[],
229
- _fork: unknown,
230
- ): Promise<CheckpointBuilder> {
231
- this.startCheckpointCalls.push({ checkpointNumber, constants, l1ToL2Messages });
291
+ previousCheckpointOutHashes: Fr[],
292
+ _fork: MerkleTreeWriteOperations,
293
+ existingBlocks: L2Block[] = [],
294
+ ): Promise<ICheckpointBlockBuilder> {
295
+ this.openCheckpointCalls.push({
296
+ checkpointNumber,
297
+ constants,
298
+ l1ToL2Messages,
299
+ previousCheckpointOutHashes,
300
+ existingBlocks,
301
+ feeAssetPriceModifier,
302
+ });
232
303
 
233
304
  if (!this.checkpointBuilder) {
234
305
  // Auto-create a builder if none was set
235
306
  this.checkpointBuilder = new MockCheckpointBuilder(constants, checkpointNumber);
236
307
  }
237
308
 
238
- return Promise.resolve(this.checkpointBuilder as unknown as CheckpointBuilder);
309
+ return Promise.resolve(this.checkpointBuilder);
310
+ }
311
+
312
+ getFork(_blockNumber: BlockNumber): Promise<MerkleTreeWriteOperations> {
313
+ throw new Error('MockCheckpointsBuilder.getFork not implemented');
239
314
  }
240
315
 
241
316
  /** Reset for reuse in another test */
242
317
  reset(): void {
243
318
  this.checkpointBuilder = undefined;
244
319
  this.startCheckpointCalls = [];
320
+ this.openCheckpointCalls = [];
245
321
  this.updateConfigCalls = [];
246
322
  }
247
323
  }
package/src/test/utils.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Body } from '@aztec/aztec.js/block';
2
- import { CheckpointNumber } from '@aztec/foundation/branded-types';
2
+ import { CheckpointNumber, IndexWithinCheckpoint } from '@aztec/foundation/branded-types';
3
3
  import { times } from '@aztec/foundation/collection';
4
4
  import { Secp256k1Signer } from '@aztec/foundation/crypto/secp256k1-signer';
5
5
  import { Fr } from '@aztec/foundation/curves/bn254';
@@ -7,17 +7,11 @@ import type { EthAddress } from '@aztec/foundation/eth-address';
7
7
  import { Signature } from '@aztec/foundation/eth-signature';
8
8
  import type { P2P } from '@aztec/p2p';
9
9
  import { PublicDataWrite } from '@aztec/stdlib/avm';
10
- import { CommitteeAttestation, L2BlockNew } from '@aztec/stdlib/block';
11
- import { BlockAttestation, BlockProposal, ConsensusPayload } from '@aztec/stdlib/p2p';
10
+ import { CommitteeAttestation, L2Block } from '@aztec/stdlib/block';
11
+ import { BlockProposal, CheckpointAttestation, CheckpointProposal, ConsensusPayload } from '@aztec/stdlib/p2p';
12
12
  import { CheckpointHeader } from '@aztec/stdlib/rollup';
13
13
  import { makeAppendOnlyTreeSnapshot, mockTxForRollup } from '@aztec/stdlib/testing';
14
- import {
15
- BlockHeader,
16
- ContentCommitment,
17
- GlobalVariables,
18
- type Tx,
19
- makeProcessedTxFromPrivateOnlyTx,
20
- } from '@aztec/stdlib/tx';
14
+ import { BlockHeader, GlobalVariables, type Tx, makeProcessedTxFromPrivateOnlyTx } from '@aztec/stdlib/tx';
21
15
 
22
16
  import type { MockProxy } from 'jest-mock-extended';
23
17
 
@@ -36,9 +30,9 @@ export async function makeTx(seed?: number, chainId?: Fr): Promise<Tx> {
36
30
  }
37
31
 
38
32
  /**
39
- * Creates an L2BlockNew from transactions and global variables
33
+ * Creates an L2Block from transactions and global variables
40
34
  */
41
- export async function makeBlock(txs: Tx[], globalVariables: GlobalVariables): Promise<L2BlockNew> {
35
+ export async function makeBlock(txs: Tx[], globalVariables: GlobalVariables): Promise<L2Block> {
42
36
  const processedTxs = await Promise.all(
43
37
  txs.map(tx =>
44
38
  makeProcessedTxFromPrivateOnlyTx(tx, Fr.ZERO, new PublicDataWrite(Fr.random(), Fr.random()), globalVariables),
@@ -47,7 +41,13 @@ export async function makeBlock(txs: Tx[], globalVariables: GlobalVariables): Pr
47
41
  const body = new Body(processedTxs.map(tx => tx.txEffect));
48
42
  const header = BlockHeader.empty({ globalVariables });
49
43
  const archive = makeAppendOnlyTreeSnapshot(globalVariables.blockNumber + 1);
50
- return new L2BlockNew(archive, header, body, CheckpointNumber(globalVariables.blockNumber), 0);
44
+ return new L2Block(
45
+ archive,
46
+ header,
47
+ body,
48
+ CheckpointNumber.fromBlockNumber(globalVariables.blockNumber),
49
+ IndexWithinCheckpoint(0),
50
+ );
51
51
  }
52
52
 
53
53
  /**
@@ -56,6 +56,7 @@ export async function makeBlock(txs: Tx[], globalVariables: GlobalVariables): Pr
56
56
  export function mockPendingTxs(p2p: MockProxy<P2P>, txs: Tx[]): void {
57
57
  p2p.getPendingTxCount.mockResolvedValue(txs.length);
58
58
  p2p.iteratePendingTxs.mockImplementation(() => mockTxIterator(Promise.resolve(txs)));
59
+ p2p.iterateEligiblePendingTxs.mockImplementation(() => mockTxIterator(Promise.resolve(txs)));
59
60
  }
60
61
 
61
62
  /**
@@ -76,16 +77,17 @@ export function createMockSignatures(signer: Secp256k1Signer): CommitteeAttestat
76
77
  }
77
78
 
78
79
  /**
79
- * Creates a CheckpointHeader from an L2BlockNew for testing purposes.
80
- * Uses mock values for contentCommitment and blockHeadersHash since
81
- * L2BlockNew doesn't have these fields.
80
+ * Creates a CheckpointHeader from an L2Block for testing purposes.
81
+ * Uses mock values for blockHeadersHash, blobsHash and inHash since L2Block doesn't have these fields.
82
82
  */
83
- function createCheckpointHeaderFromBlock(block: L2BlockNew): CheckpointHeader {
83
+ function createCheckpointHeaderFromBlock(block: L2Block): CheckpointHeader {
84
84
  const gv = block.header.globalVariables;
85
85
  return new CheckpointHeader(
86
86
  block.header.lastArchive.root,
87
87
  Fr.random(), // blockHeadersHash - mock value for testing
88
- ContentCommitment.empty(), // contentCommitment - mock value for testing
88
+ Fr.random(), // blobsHash - mock value for testing
89
+ Fr.random(), // inHash - mock value for testing
90
+ Fr.random(), // outHash - mock value for testing
89
91
  gv.slotNumber,
90
92
  gv.timestamp,
91
93
  gv.coinbase,
@@ -98,24 +100,52 @@ function createCheckpointHeaderFromBlock(block: L2BlockNew): CheckpointHeader {
98
100
  /**
99
101
  * Creates a block proposal from a block and signature
100
102
  */
101
- export function createBlockProposal(block: L2BlockNew, signature: Signature): BlockProposal {
102
- const checkpointHeader = createCheckpointHeaderFromBlock(block);
103
- const consensusPayload = new ConsensusPayload(checkpointHeader, block.archive.root);
103
+ export function createBlockProposal(block: L2Block, signature: Signature): BlockProposal {
104
+ const txHashes = block.body.txEffects.map(tx => tx.txHash);
105
+ return new BlockProposal(
106
+ block.header,
107
+ block.indexWithinCheckpoint,
108
+ Fr.ZERO, // inHash - using zero for testing
109
+ block.archive.root,
110
+ txHashes,
111
+ signature,
112
+ );
113
+ }
114
+
115
+ /**
116
+ * Creates a checkpoint proposal from a block and signature
117
+ */
118
+ export function createCheckpointProposal(
119
+ block: L2Block,
120
+ checkpointSignature: Signature,
121
+ blockSignature?: Signature,
122
+ feeAssetPriceModifier: bigint = 0n,
123
+ ): CheckpointProposal {
104
124
  const txHashes = block.body.txEffects.map(tx => tx.txHash);
105
- return new BlockProposal(consensusPayload, signature, txHashes);
125
+ const checkpointHeader = createCheckpointHeaderFromBlock(block);
126
+ return new CheckpointProposal(checkpointHeader, block.archive.root, feeAssetPriceModifier, checkpointSignature, {
127
+ blockHeader: block.header,
128
+ indexWithinCheckpoint: block.indexWithinCheckpoint,
129
+ txHashes,
130
+ signature: blockSignature ?? checkpointSignature, // Use checkpoint signature as block signature if not provided
131
+ });
106
132
  }
107
133
 
108
134
  /**
109
- * Creates a block attestation from a block and signature.
135
+ * Creates a checkpoint attestation from a block and signature.
110
136
  * Note: We manually set the sender since we use random signatures in tests.
111
137
  * In production, the sender is recovered from the signature.
112
138
  */
113
- export function createBlockAttestation(block: L2BlockNew, signature: Signature, sender: EthAddress): BlockAttestation {
139
+ export function createCheckpointAttestation(
140
+ block: L2Block,
141
+ signature: Signature,
142
+ sender: EthAddress,
143
+ feeAssetPriceModifier: bigint = 0n,
144
+ ): CheckpointAttestation {
114
145
  const checkpointHeader = createCheckpointHeaderFromBlock(block);
115
- const consensusPayload = new ConsensusPayload(checkpointHeader, block.archive.root);
116
- const attestation = new BlockAttestation(consensusPayload, signature, signature);
146
+ const payload = new ConsensusPayload(checkpointHeader, block.archive.root, feeAssetPriceModifier);
147
+ const attestation = new CheckpointAttestation(payload, signature, signature);
117
148
  // Set sender directly for testing (bypasses signature recovery)
118
-
119
149
  (attestation as any).sender = sender;
120
150
  return attestation;
121
151
  }
@@ -129,7 +159,7 @@ export async function setupTxsAndBlock(
129
159
  globalVariables: GlobalVariables,
130
160
  txCount: number,
131
161
  chainId: Fr,
132
- ): Promise<{ txs: Tx[]; block: L2BlockNew }> {
162
+ ): Promise<{ txs: Tx[]; block: L2Block }> {
133
163
  const txs = await Promise.all(times(txCount, i => makeTx(i + 1, chainId)));
134
164
  const block = await makeBlock(txs, globalVariables);
135
165
  mockPendingTxs(p2p, txs);
@@ -1,26 +0,0 @@
1
- import { BlockNumber } from '@aztec/foundation/branded-types';
2
- import type { Fr } from '@aztec/foundation/curves/bn254';
3
- import { DateProvider } from '@aztec/foundation/timer';
4
- import { PublicProcessor } from '@aztec/simulator/server';
5
- import type { ContractDataSource } from '@aztec/stdlib/contract';
6
- import type { BuildBlockResult, FullNodeBlockBuilderConfig, IFullNodeBlockBuilder, MerkleTreeWriteOperations, PublicProcessorLimits, PublicProcessorValidator, WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
7
- import { GlobalVariables, Tx } from '@aztec/stdlib/tx';
8
- import { type TelemetryClient } from '@aztec/telemetry-client';
9
- export declare class FullNodeBlockBuilder implements IFullNodeBlockBuilder {
10
- private config;
11
- private worldState;
12
- private contractDataSource;
13
- private dateProvider;
14
- private telemetryClient;
15
- constructor(config: FullNodeBlockBuilderConfig, worldState: WorldStateSynchronizer, contractDataSource: ContractDataSource, dateProvider: DateProvider, telemetryClient?: TelemetryClient);
16
- getConfig(): FullNodeBlockBuilderConfig;
17
- updateConfig(config: Partial<FullNodeBlockBuilderConfig>): void;
18
- makeBlockBuilderDeps(globalVariables: GlobalVariables, fork: MerkleTreeWriteOperations): Promise<{
19
- processor: PublicProcessor;
20
- validator: PublicProcessorValidator;
21
- }>;
22
- private syncToPreviousBlock;
23
- buildBlock(pendingTxs: Iterable<Tx> | AsyncIterable<Tx>, l1ToL2Messages: Fr[], globalVariables: GlobalVariables, opts: PublicProcessorLimits, suppliedFork?: MerkleTreeWriteOperations): Promise<BuildBlockResult>;
24
- getFork(blockNumber: BlockNumber): Promise<MerkleTreeWriteOperations>;
25
- }
26
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmxvY2tfYnVpbGRlci5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3NlcXVlbmNlci9ibG9ja19idWlsZGVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUNBLE9BQU8sRUFBRSxXQUFXLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUU5RCxPQUFPLEtBQUssRUFBRSxFQUFFLEVBQUUsTUFBTSxnQ0FBZ0MsQ0FBQztBQUl6RCxPQUFPLEVBQUUsWUFBWSxFQUFrQixNQUFNLHlCQUF5QixDQUFDO0FBR3ZFLE9BQU8sRUFHTCxlQUFlLEVBRWhCLE1BQU0seUJBQXlCLENBQUM7QUFDakMsT0FBTyxLQUFLLEVBQUUsa0JBQWtCLEVBQUUsTUFBTSx3QkFBd0IsQ0FBQztBQUdqRSxPQUFPLEtBQUssRUFDVixnQkFBZ0IsRUFDaEIsMEJBQTBCLEVBQzFCLHFCQUFxQixFQUNyQix5QkFBeUIsRUFDekIscUJBQXFCLEVBQ3JCLHdCQUF3QixFQUN4QixzQkFBc0IsRUFDdkIsTUFBTSxpQ0FBaUMsQ0FBQztBQUN6QyxPQUFPLEVBQUUsZUFBZSxFQUFFLEVBQUUsRUFBRSxNQUFNLGtCQUFrQixDQUFDO0FBQ3ZELE9BQU8sRUFBRSxLQUFLLGVBQWUsRUFBc0IsTUFBTSx5QkFBeUIsQ0FBQztBQTJFbkYscUJBQWEsb0JBQXFCLFlBQVcscUJBQXFCO0lBRTlELE9BQU8sQ0FBQyxNQUFNO0lBQ2QsT0FBTyxDQUFDLFVBQVU7SUFDbEIsT0FBTyxDQUFDLGtCQUFrQjtJQUMxQixPQUFPLENBQUMsWUFBWTtJQUNwQixPQUFPLENBQUMsZUFBZTtJQUx6QixZQUNVLE1BQU0sRUFBRSwwQkFBMEIsRUFDbEMsVUFBVSxFQUFFLHNCQUFzQixFQUNsQyxrQkFBa0IsRUFBRSxrQkFBa0IsRUFDdEMsWUFBWSxFQUFFLFlBQVksRUFDMUIsZUFBZSxHQUFFLGVBQXNDLEVBQzdEO0lBRUcsU0FBUyxJQUFJLDBCQUEwQixDQUU3QztJQUVNLFlBQVksQ0FBQyxNQUFNLEVBQUUsT0FBTyxDQUFDLDBCQUEwQixDQUFDLFFBRTlEO0lBRVksb0JBQW9CLENBQUMsZUFBZSxFQUFFLGVBQWUsRUFBRSxJQUFJLEVBQUUseUJBQXlCOzs7T0FrQ2xHO1lBRWEsbUJBQW1CO0lBVTNCLFVBQVUsQ0FDZCxVQUFVLEVBQUUsUUFBUSxDQUFDLEVBQUUsQ0FBQyxHQUFHLGFBQWEsQ0FBQyxFQUFFLENBQUMsRUFDNUMsY0FBYyxFQUFFLEVBQUUsRUFBRSxFQUNwQixlQUFlLEVBQUUsZUFBZSxFQUNoQyxJQUFJLEVBQUUscUJBQXFCLEVBQzNCLFlBQVksQ0FBQyxFQUFFLHlCQUF5QixHQUN2QyxPQUFPLENBQUMsZ0JBQWdCLENBQUMsQ0FzQzNCO0lBRUQsT0FBTyxDQUFDLFdBQVcsRUFBRSxXQUFXLEdBQUcsT0FBTyxDQUFDLHlCQUF5QixDQUFDLENBRXBFO0NBQ0YifQ==
@@ -1 +0,0 @@
1
- {"version":3,"file":"block_builder.d.ts","sourceRoot":"","sources":["../../src/sequencer/block_builder.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAE9D,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AAIzD,OAAO,EAAE,YAAY,EAAkB,MAAM,yBAAyB,CAAC;AAGvE,OAAO,EAGL,eAAe,EAEhB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAGjE,OAAO,KAAK,EACV,gBAAgB,EAChB,0BAA0B,EAC1B,qBAAqB,EACrB,yBAAyB,EACzB,qBAAqB,EACrB,wBAAwB,EACxB,sBAAsB,EACvB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,KAAK,eAAe,EAAsB,MAAM,yBAAyB,CAAC;AA2EnF,qBAAa,oBAAqB,YAAW,qBAAqB;IAE9D,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,kBAAkB;IAC1B,OAAO,CAAC,YAAY;IACpB,OAAO,CAAC,eAAe;IALzB,YACU,MAAM,EAAE,0BAA0B,EAClC,UAAU,EAAE,sBAAsB,EAClC,kBAAkB,EAAE,kBAAkB,EACtC,YAAY,EAAE,YAAY,EAC1B,eAAe,GAAE,eAAsC,EAC7D;IAEG,SAAS,IAAI,0BAA0B,CAE7C;IAEM,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,0BAA0B,CAAC,QAE9D;IAEY,oBAAoB,CAAC,eAAe,EAAE,eAAe,EAAE,IAAI,EAAE,yBAAyB;;;OAkClG;YAEa,mBAAmB;IAU3B,UAAU,CACd,UAAU,EAAE,QAAQ,CAAC,EAAE,CAAC,GAAG,aAAa,CAAC,EAAE,CAAC,EAC5C,cAAc,EAAE,EAAE,EAAE,EACpB,eAAe,EAAE,eAAe,EAChC,IAAI,EAAE,qBAAqB,EAC3B,YAAY,CAAC,EAAE,yBAAyB,GACvC,OAAO,CAAC,gBAAgB,CAAC,CAsC3B;IAED,OAAO,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAEpE;CACF"}
@@ -1,129 +0,0 @@
1
- import { MerkleTreeId } from '@aztec/aztec.js/trees';
2
- import { BlockNumber } from '@aztec/foundation/branded-types';
3
- import { merge, pick } from '@aztec/foundation/collection';
4
- import { createLogger } from '@aztec/foundation/log';
5
- import { retryUntil } from '@aztec/foundation/retry';
6
- import { bufferToHex } from '@aztec/foundation/string';
7
- import { Timer, elapsed } from '@aztec/foundation/timer';
8
- import { getDefaultAllowedSetupFunctions } from '@aztec/p2p/msg_validators';
9
- import { LightweightBlockFactory } from '@aztec/prover-client/block-factory';
10
- import { GuardedMerkleTreeOperations, PublicContractsDB, PublicProcessor, createPublicTxSimulatorForBlockBuilding } from '@aztec/simulator/server';
11
- import { getTimestampForSlot } from '@aztec/stdlib/epoch-helpers';
12
- import { Gas } from '@aztec/stdlib/gas';
13
- import { getTelemetryClient } from '@aztec/telemetry-client';
14
- import { createValidatorForBlockBuilding } from '../tx_validator/tx_validator_factory.js';
15
- const log = createLogger('block-builder');
16
- /** Builds a block out of pending txs */ async function buildBlock(pendingTxs, l1ToL2Messages, newGlobalVariables, opts = {}, worldStateFork, processor, validator, l1Constants, dateProvider, telemetryClient = getTelemetryClient()) {
17
- const blockBuildingTimer = new Timer();
18
- const blockNumber = newGlobalVariables.blockNumber;
19
- const slot = newGlobalVariables.slotNumber;
20
- const msgCount = l1ToL2Messages.length;
21
- const stateReference = await worldStateFork.getStateReference();
22
- const archiveTree = await worldStateFork.getTreeInfo(MerkleTreeId.ARCHIVE);
23
- log.verbose(`Building block ${blockNumber} for slot ${slot}`, {
24
- slot,
25
- slotStart: new Date(Number(getTimestampForSlot(slot, l1Constants)) * 1000),
26
- now: new Date(dateProvider.now()),
27
- blockNumber,
28
- msgCount,
29
- initialStateReference: stateReference.toInspect(),
30
- initialArchiveRoot: bufferToHex(archiveTree.root),
31
- opts
32
- });
33
- const blockFactory = new LightweightBlockFactory(worldStateFork, telemetryClient);
34
- await blockFactory.startNewBlock(newGlobalVariables, l1ToL2Messages);
35
- const [publicProcessorDuration, [processedTxs, failedTxs, usedTxs]] = await elapsed(()=>processor.process(pendingTxs, opts, validator));
36
- // All real transactions have been added, set the block as full and pad if needed
37
- await blockFactory.addTxs(processedTxs);
38
- const block = await blockFactory.setBlockCompleted();
39
- // How much public gas was processed
40
- const publicGas = processedTxs.reduce((acc, tx)=>acc.add(tx.gasUsed.publicGas), Gas.empty());
41
- const res = {
42
- block,
43
- publicGas,
44
- publicProcessorDuration,
45
- numMsgs: l1ToL2Messages.length,
46
- numTxs: processedTxs.length,
47
- failedTxs: failedTxs,
48
- blockBuildingTimer,
49
- usedTxs
50
- };
51
- log.trace('Built block', res.block.header);
52
- return res;
53
- }
54
- const FullNodeBlockBuilderConfigKeys = [
55
- 'l1GenesisTime',
56
- 'slotDuration',
57
- 'l1ChainId',
58
- 'rollupVersion',
59
- 'txPublicSetupAllowList',
60
- 'fakeProcessingDelayPerTxMs',
61
- 'fakeThrowAfterProcessingTxCount'
62
- ];
63
- // TODO(palla/mbps): Try killing this in favor of the CheckpointsBuilder
64
- export class FullNodeBlockBuilder {
65
- config;
66
- worldState;
67
- contractDataSource;
68
- dateProvider;
69
- telemetryClient;
70
- constructor(config, worldState, contractDataSource, dateProvider, telemetryClient = getTelemetryClient()){
71
- this.config = config;
72
- this.worldState = worldState;
73
- this.contractDataSource = contractDataSource;
74
- this.dateProvider = dateProvider;
75
- this.telemetryClient = telemetryClient;
76
- }
77
- getConfig() {
78
- return pick(this.config, ...FullNodeBlockBuilderConfigKeys);
79
- }
80
- updateConfig(config) {
81
- this.config = merge(this.config, pick(config, ...FullNodeBlockBuilderConfigKeys));
82
- }
83
- async makeBlockBuilderDeps(globalVariables, fork) {
84
- const txPublicSetupAllowList = this.config.txPublicSetupAllowList ?? await getDefaultAllowedSetupFunctions();
85
- const contractsDB = new PublicContractsDB(this.contractDataSource);
86
- const guardedFork = new GuardedMerkleTreeOperations(fork);
87
- const publicTxSimulator = createPublicTxSimulatorForBlockBuilding(guardedFork, contractsDB, globalVariables, this.telemetryClient);
88
- const processor = new PublicProcessor(globalVariables, guardedFork, contractsDB, publicTxSimulator, this.dateProvider, this.telemetryClient, undefined, this.config);
89
- const validator = createValidatorForBlockBuilding(fork, this.contractDataSource, globalVariables, txPublicSetupAllowList);
90
- return {
91
- processor,
92
- validator
93
- };
94
- }
95
- async syncToPreviousBlock(parentBlockNumber, timeout) {
96
- await retryUntil(()=>this.worldState.syncImmediate(parentBlockNumber, true).then((syncedTo)=>syncedTo >= parentBlockNumber), 'sync to previous block', timeout, 0.1);
97
- log.debug(`Synced to previous block ${parentBlockNumber}`);
98
- }
99
- async buildBlock(pendingTxs, l1ToL2Messages, globalVariables, opts, suppliedFork) {
100
- const parentBlockNumber = BlockNumber(globalVariables.blockNumber - 1);
101
- const syncTimeout = opts.deadline ? (opts.deadline.getTime() - this.dateProvider.now()) / 1000 : undefined;
102
- await this.syncToPreviousBlock(parentBlockNumber, syncTimeout);
103
- const fork = suppliedFork ?? await this.worldState.fork(parentBlockNumber);
104
- try {
105
- const { processor, validator } = await this.makeBlockBuilderDeps(globalVariables, fork);
106
- const res = await buildBlock(pendingTxs, l1ToL2Messages, globalVariables, opts, fork, processor, validator, this.config, this.dateProvider, this.telemetryClient);
107
- return res;
108
- } finally{
109
- // If the fork was supplied, we don't close it.
110
- // Otherwise, we wait a bit to close the fork we just created,
111
- // since the processor may still be working on a dangling tx
112
- // which was interrupted due to the processingDeadline being hit.
113
- if (!suppliedFork) {
114
- // eslint-disable-next-line @typescript-eslint/no-misused-promises
115
- setTimeout(async ()=>{
116
- try {
117
- await fork.close();
118
- } catch (err) {
119
- // This can happen if the sequencer is stopped before we hit this timeout.
120
- log.warn(`Error closing forks for block processing`, err);
121
- }
122
- }, 5000);
123
- }
124
- }
125
- }
126
- getFork(blockNumber) {
127
- return this.worldState.fork(blockNumber);
128
- }
129
- }