@aztec/sequencer-client 0.0.1-commit.d431d1c → 0.0.1-commit.dbf9cec

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 (75) hide show
  1. package/dest/client/sequencer-client.d.ts +12 -7
  2. package/dest/client/sequencer-client.d.ts.map +1 -1
  3. package/dest/client/sequencer-client.js +15 -4
  4. package/dest/config.d.ts +3 -4
  5. package/dest/config.d.ts.map +1 -1
  6. package/dest/config.js +17 -14
  7. package/dest/global_variable_builder/global_builder.d.ts +2 -4
  8. package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
  9. package/dest/global_variable_builder/global_builder.js +2 -2
  10. package/dest/publisher/config.d.ts +35 -17
  11. package/dest/publisher/config.d.ts.map +1 -1
  12. package/dest/publisher/config.js +106 -42
  13. package/dest/publisher/index.d.ts +2 -1
  14. package/dest/publisher/index.d.ts.map +1 -1
  15. package/dest/publisher/l1_tx_failed_store/factory.d.ts +11 -0
  16. package/dest/publisher/l1_tx_failed_store/factory.d.ts.map +1 -0
  17. package/dest/publisher/l1_tx_failed_store/factory.js +22 -0
  18. package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts +59 -0
  19. package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts.map +1 -0
  20. package/dest/publisher/l1_tx_failed_store/failed_tx_store.js +1 -0
  21. package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.d.ts +15 -0
  22. package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.d.ts.map +1 -0
  23. package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.js +34 -0
  24. package/dest/publisher/l1_tx_failed_store/index.d.ts +4 -0
  25. package/dest/publisher/l1_tx_failed_store/index.d.ts.map +1 -0
  26. package/dest/publisher/l1_tx_failed_store/index.js +2 -0
  27. package/dest/publisher/sequencer-publisher-factory.d.ts +11 -3
  28. package/dest/publisher/sequencer-publisher-factory.d.ts.map +1 -1
  29. package/dest/publisher/sequencer-publisher-factory.js +13 -2
  30. package/dest/publisher/sequencer-publisher-metrics.d.ts +1 -1
  31. package/dest/publisher/sequencer-publisher-metrics.d.ts.map +1 -1
  32. package/dest/publisher/sequencer-publisher-metrics.js +12 -4
  33. package/dest/publisher/sequencer-publisher.d.ts +22 -8
  34. package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
  35. package/dest/publisher/sequencer-publisher.js +297 -47
  36. package/dest/sequencer/checkpoint_proposal_job.d.ts +32 -9
  37. package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -1
  38. package/dest/sequencer/checkpoint_proposal_job.js +121 -61
  39. package/dest/sequencer/metrics.d.ts +17 -5
  40. package/dest/sequencer/metrics.d.ts.map +1 -1
  41. package/dest/sequencer/metrics.js +111 -30
  42. package/dest/sequencer/sequencer.d.ts +17 -7
  43. package/dest/sequencer/sequencer.d.ts.map +1 -1
  44. package/dest/sequencer/sequencer.js +30 -27
  45. package/dest/sequencer/timetable.d.ts +1 -4
  46. package/dest/sequencer/timetable.d.ts.map +1 -1
  47. package/dest/sequencer/timetable.js +2 -5
  48. package/dest/test/index.d.ts +3 -5
  49. package/dest/test/index.d.ts.map +1 -1
  50. package/dest/test/mock_checkpoint_builder.d.ts +14 -9
  51. package/dest/test/mock_checkpoint_builder.d.ts.map +1 -1
  52. package/dest/test/mock_checkpoint_builder.js +24 -10
  53. package/dest/test/utils.d.ts +8 -8
  54. package/dest/test/utils.d.ts.map +1 -1
  55. package/dest/test/utils.js +10 -9
  56. package/package.json +28 -28
  57. package/src/client/sequencer-client.ts +25 -7
  58. package/src/config.ts +27 -22
  59. package/src/global_variable_builder/global_builder.ts +3 -3
  60. package/src/publisher/config.ts +121 -43
  61. package/src/publisher/index.ts +3 -0
  62. package/src/publisher/l1_tx_failed_store/factory.ts +32 -0
  63. package/src/publisher/l1_tx_failed_store/failed_tx_store.ts +55 -0
  64. package/src/publisher/l1_tx_failed_store/file_store_failed_tx_store.ts +46 -0
  65. package/src/publisher/l1_tx_failed_store/index.ts +3 -0
  66. package/src/publisher/sequencer-publisher-factory.ts +23 -6
  67. package/src/publisher/sequencer-publisher-metrics.ts +7 -3
  68. package/src/publisher/sequencer-publisher.ts +274 -53
  69. package/src/sequencer/checkpoint_proposal_job.ts +172 -87
  70. package/src/sequencer/metrics.ts +124 -32
  71. package/src/sequencer/sequencer.ts +40 -32
  72. package/src/sequencer/timetable.ts +7 -6
  73. package/src/test/index.ts +2 -4
  74. package/src/test/mock_checkpoint_builder.ts +44 -19
  75. package/src/test/utils.ts +22 -13
@@ -1,11 +1,9 @@
1
1
  import { type BlockNumber, CheckpointNumber } from '@aztec/foundation/branded-types';
2
2
  import { Fr } from '@aztec/foundation/curves/bn254';
3
- import { Timer } from '@aztec/foundation/timer';
4
- import { L2BlockNew } from '@aztec/stdlib/block';
3
+ import { L2Block } from '@aztec/stdlib/block';
5
4
  import { Checkpoint } from '@aztec/stdlib/checkpoint';
6
5
  import { Gas } from '@aztec/stdlib/gas';
7
6
  import type {
8
- BuildBlockInCheckpointResult,
9
7
  FullNodeBlockBuilderConfig,
10
8
  ICheckpointBlockBuilder,
11
9
  ICheckpointsBuilder,
@@ -15,19 +13,20 @@ import type {
15
13
  import { CheckpointHeader } from '@aztec/stdlib/rollup';
16
14
  import { makeAppendOnlyTreeSnapshot } from '@aztec/stdlib/testing';
17
15
  import type { CheckpointGlobalVariables, Tx } from '@aztec/stdlib/tx';
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
22
  export class MockCheckpointBuilder implements ICheckpointBlockBuilder {
24
- private blocks: L2BlockNew[] = [];
25
- private builtBlocks: L2BlockNew[] = [];
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 ICheckpointBlockBuilder {
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 ICheckpointBlockBuilder {
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 ICheckpointBlockBuilder {
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 ICheckpointBlockBuilder {
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,10 +79,10 @@ export class MockCheckpointBuilder implements ICheckpointBlockBuilder {
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) {
@@ -97,16 +98,28 @@ export class MockCheckpointBuilder implements ICheckpointBlockBuilder {
97
98
  this.builtBlocks.push(block);
98
99
  }
99
100
 
100
- return Promise.resolve({
101
+ // Check that no pending tx has already been consumed
102
+ for await (const tx of pendingTxs) {
103
+ const hash = tx.getTxHash().toString();
104
+ if (this.consumedTxHashes.has(hash)) {
105
+ throw new Error(`Transaction ${hash} was already consumed in a previous block`);
106
+ }
107
+ }
108
+
109
+ // Add used txs to consumed set
110
+ for (const tx of usedTxs) {
111
+ this.consumedTxHashes.add(tx.getTxHash().toString());
112
+ }
113
+
114
+ return {
101
115
  block,
102
116
  publicGas: Gas.empty(),
103
117
  publicProcessorDuration: 0,
104
118
  numTxs: block?.body?.txEffects?.length ?? usedTxs.length,
105
- blockBuildingTimer: new Timer(),
106
119
  usedTxs,
107
120
  failedTxs: [],
108
121
  usedTxBlobFields: block?.body?.txEffects?.reduce((sum, tx) => sum + tx.getNumBlobFields(), 0) ?? 0,
109
- });
122
+ };
110
123
  }
111
124
 
112
125
  completeCheckpoint(): Promise<Checkpoint> {
@@ -148,7 +161,7 @@ export class MockCheckpointBuilder implements ICheckpointBlockBuilder {
148
161
  * Creates a CheckpointHeader from a block's header for testing.
149
162
  * This is a simplified version that creates a minimal CheckpointHeader.
150
163
  */
151
- private createCheckpointHeader(block: L2BlockNew): CheckpointHeader {
164
+ private createCheckpointHeader(block: L2Block): CheckpointHeader {
152
165
  const header = block.header;
153
166
  const gv = header.globalVariables;
154
167
  return CheckpointHeader.empty({
@@ -170,6 +183,7 @@ export class MockCheckpointBuilder implements ICheckpointBlockBuilder {
170
183
  this.usedTxsPerBlock = [];
171
184
  this.blockIndex = 0;
172
185
  this.buildBlockCalls = [];
186
+ this.consumedTxHashes.clear();
173
187
  this.completeCheckpointCalled = false;
174
188
  this.getCheckpointCalled = false;
175
189
  this.errorOnBuild = undefined;
@@ -191,13 +205,15 @@ export class MockCheckpointsBuilder implements ICheckpointsBuilder {
191
205
  constants: CheckpointGlobalVariables;
192
206
  l1ToL2Messages: Fr[];
193
207
  previousCheckpointOutHashes: Fr[];
208
+ feeAssetPriceModifier: bigint;
194
209
  }> = [];
195
210
  public openCheckpointCalls: Array<{
196
211
  checkpointNumber: CheckpointNumber;
197
212
  constants: CheckpointGlobalVariables;
198
213
  l1ToL2Messages: Fr[];
199
214
  previousCheckpointOutHashes: Fr[];
200
- existingBlocks: L2BlockNew[];
215
+ existingBlocks: L2Block[];
216
+ feeAssetPriceModifier: bigint;
201
217
  }> = [];
202
218
  public updateConfigCalls: Array<Partial<FullNodeBlockBuilderConfig>> = [];
203
219
 
@@ -243,11 +259,18 @@ export class MockCheckpointsBuilder implements ICheckpointsBuilder {
243
259
  startCheckpoint(
244
260
  checkpointNumber: CheckpointNumber,
245
261
  constants: CheckpointGlobalVariables,
262
+ feeAssetPriceModifier: bigint,
246
263
  l1ToL2Messages: Fr[],
247
264
  previousCheckpointOutHashes: Fr[],
248
265
  _fork: MerkleTreeWriteOperations,
249
266
  ): Promise<ICheckpointBlockBuilder> {
250
- this.startCheckpointCalls.push({ checkpointNumber, constants, l1ToL2Messages, previousCheckpointOutHashes });
267
+ this.startCheckpointCalls.push({
268
+ checkpointNumber,
269
+ constants,
270
+ l1ToL2Messages,
271
+ previousCheckpointOutHashes,
272
+ feeAssetPriceModifier,
273
+ });
251
274
 
252
275
  if (!this.checkpointBuilder) {
253
276
  // Auto-create a builder if none was set
@@ -260,10 +283,11 @@ export class MockCheckpointsBuilder implements ICheckpointsBuilder {
260
283
  openCheckpoint(
261
284
  checkpointNumber: CheckpointNumber,
262
285
  constants: CheckpointGlobalVariables,
286
+ feeAssetPriceModifier: bigint,
263
287
  l1ToL2Messages: Fr[],
264
288
  previousCheckpointOutHashes: Fr[],
265
289
  _fork: MerkleTreeWriteOperations,
266
- existingBlocks: L2BlockNew[] = [],
290
+ existingBlocks: L2Block[] = [],
267
291
  ): Promise<ICheckpointBlockBuilder> {
268
292
  this.openCheckpointCalls.push({
269
293
  checkpointNumber,
@@ -271,6 +295,7 @@ export class MockCheckpointsBuilder implements ICheckpointsBuilder {
271
295
  l1ToL2Messages,
272
296
  previousCheckpointOutHashes,
273
297
  existingBlocks,
298
+ feeAssetPriceModifier,
274
299
  });
275
300
 
276
301
  if (!this.checkpointBuilder) {
package/src/test/utils.ts CHANGED
@@ -7,7 +7,7 @@ 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';
10
+ import { CommitteeAttestation, L2Block } from '@aztec/stdlib/block';
11
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';
@@ -30,9 +30,9 @@ export async function makeTx(seed?: number, chainId?: Fr): Promise<Tx> {
30
30
  }
31
31
 
32
32
  /**
33
- * Creates an L2BlockNew from transactions and global variables
33
+ * Creates an L2Block from transactions and global variables
34
34
  */
35
- export async function makeBlock(txs: Tx[], globalVariables: GlobalVariables): Promise<L2BlockNew> {
35
+ export async function makeBlock(txs: Tx[], globalVariables: GlobalVariables): Promise<L2Block> {
36
36
  const processedTxs = await Promise.all(
37
37
  txs.map(tx =>
38
38
  makeProcessedTxFromPrivateOnlyTx(tx, Fr.ZERO, new PublicDataWrite(Fr.random(), Fr.random()), globalVariables),
@@ -41,7 +41,13 @@ export async function makeBlock(txs: Tx[], globalVariables: GlobalVariables): Pr
41
41
  const body = new Body(processedTxs.map(tx => tx.txEffect));
42
42
  const header = BlockHeader.empty({ globalVariables });
43
43
  const archive = makeAppendOnlyTreeSnapshot(globalVariables.blockNumber + 1);
44
- return new L2BlockNew(archive, header, body, CheckpointNumber(globalVariables.blockNumber), IndexWithinCheckpoint(0));
44
+ return new L2Block(
45
+ archive,
46
+ header,
47
+ body,
48
+ CheckpointNumber.fromBlockNumber(globalVariables.blockNumber),
49
+ IndexWithinCheckpoint(0),
50
+ );
45
51
  }
46
52
 
47
53
  /**
@@ -50,6 +56,7 @@ export async function makeBlock(txs: Tx[], globalVariables: GlobalVariables): Pr
50
56
  export function mockPendingTxs(p2p: MockProxy<P2P>, txs: Tx[]): void {
51
57
  p2p.getPendingTxCount.mockResolvedValue(txs.length);
52
58
  p2p.iteratePendingTxs.mockImplementation(() => mockTxIterator(Promise.resolve(txs)));
59
+ p2p.iterateEligiblePendingTxs.mockImplementation(() => mockTxIterator(Promise.resolve(txs)));
53
60
  }
54
61
 
55
62
  /**
@@ -70,10 +77,10 @@ export function createMockSignatures(signer: Secp256k1Signer): CommitteeAttestat
70
77
  }
71
78
 
72
79
  /**
73
- * Creates a CheckpointHeader from an L2BlockNew for testing purposes.
74
- * Uses mock values for blockHeadersHash, blobsHash and inHash since 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.
75
82
  */
76
- function createCheckpointHeaderFromBlock(block: L2BlockNew): CheckpointHeader {
83
+ function createCheckpointHeaderFromBlock(block: L2Block): CheckpointHeader {
77
84
  const gv = block.header.globalVariables;
78
85
  return new CheckpointHeader(
79
86
  block.header.lastArchive.root,
@@ -93,7 +100,7 @@ function createCheckpointHeaderFromBlock(block: L2BlockNew): CheckpointHeader {
93
100
  /**
94
101
  * Creates a block proposal from a block and signature
95
102
  */
96
- export function createBlockProposal(block: L2BlockNew, signature: Signature): BlockProposal {
103
+ export function createBlockProposal(block: L2Block, signature: Signature): BlockProposal {
97
104
  const txHashes = block.body.txEffects.map(tx => tx.txHash);
98
105
  return new BlockProposal(
99
106
  block.header,
@@ -109,13 +116,14 @@ export function createBlockProposal(block: L2BlockNew, signature: Signature): Bl
109
116
  * Creates a checkpoint proposal from a block and signature
110
117
  */
111
118
  export function createCheckpointProposal(
112
- block: L2BlockNew,
119
+ block: L2Block,
113
120
  checkpointSignature: Signature,
114
121
  blockSignature?: Signature,
122
+ feeAssetPriceModifier: bigint = 0n,
115
123
  ): CheckpointProposal {
116
124
  const txHashes = block.body.txEffects.map(tx => tx.txHash);
117
125
  const checkpointHeader = createCheckpointHeaderFromBlock(block);
118
- return new CheckpointProposal(checkpointHeader, block.archive.root, checkpointSignature, {
126
+ return new CheckpointProposal(checkpointHeader, block.archive.root, feeAssetPriceModifier, checkpointSignature, {
119
127
  blockHeader: block.header,
120
128
  indexWithinCheckpoint: block.indexWithinCheckpoint,
121
129
  txHashes,
@@ -129,12 +137,13 @@ export function createCheckpointProposal(
129
137
  * In production, the sender is recovered from the signature.
130
138
  */
131
139
  export function createCheckpointAttestation(
132
- block: L2BlockNew,
140
+ block: L2Block,
133
141
  signature: Signature,
134
142
  sender: EthAddress,
143
+ feeAssetPriceModifier: bigint = 0n,
135
144
  ): CheckpointAttestation {
136
145
  const checkpointHeader = createCheckpointHeaderFromBlock(block);
137
- const payload = new ConsensusPayload(checkpointHeader, block.archive.root);
146
+ const payload = new ConsensusPayload(checkpointHeader, block.archive.root, feeAssetPriceModifier);
138
147
  const attestation = new CheckpointAttestation(payload, signature, signature);
139
148
  // Set sender directly for testing (bypasses signature recovery)
140
149
  (attestation as any).sender = sender;
@@ -150,7 +159,7 @@ export async function setupTxsAndBlock(
150
159
  globalVariables: GlobalVariables,
151
160
  txCount: number,
152
161
  chainId: Fr,
153
- ): Promise<{ txs: Tx[]; block: L2BlockNew }> {
162
+ ): Promise<{ txs: Tx[]; block: L2Block }> {
154
163
  const txs = await Promise.all(times(txCount, i => makeTx(i + 1, chainId)));
155
164
  const block = await makeBlock(txs, globalVariables);
156
165
  mockPendingTxs(p2p, txs);