@aztec/stdlib 0.0.1-commit.f504929 → 0.0.1-commit.f81dbcf

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 (153) hide show
  1. package/dest/block/l2_block.d.ts +9 -1
  2. package/dest/block/l2_block.d.ts.map +1 -1
  3. package/dest/block/l2_block.js +12 -2
  4. package/dest/block/l2_block_source.d.ts +14 -8
  5. package/dest/block/l2_block_source.d.ts.map +1 -1
  6. package/dest/checkpoint/checkpoint.d.ts +2 -1
  7. package/dest/checkpoint/checkpoint.d.ts.map +1 -1
  8. package/dest/checkpoint/checkpoint.js +9 -4
  9. package/dest/checkpoint/index.d.ts +2 -1
  10. package/dest/checkpoint/index.d.ts.map +1 -1
  11. package/dest/checkpoint/index.js +1 -0
  12. package/dest/checkpoint/validate.d.ts +36 -0
  13. package/dest/checkpoint/validate.d.ts.map +1 -0
  14. package/dest/checkpoint/validate.js +120 -0
  15. package/dest/config/sequencer-config.d.ts +2 -4
  16. package/dest/config/sequencer-config.d.ts.map +1 -1
  17. package/dest/config/sequencer-config.js +1 -3
  18. package/dest/epoch-helpers/index.d.ts +5 -1
  19. package/dest/epoch-helpers/index.d.ts.map +1 -1
  20. package/dest/epoch-helpers/index.js +4 -2
  21. package/dest/gas/gas_fees.d.ts +1 -1
  22. package/dest/gas/gas_fees.d.ts.map +1 -1
  23. package/dest/gas/gas_fees.js +1 -4
  24. package/dest/interfaces/allowed_element.d.ts +25 -1
  25. package/dest/interfaces/allowed_element.d.ts.map +1 -1
  26. package/dest/interfaces/allowed_element.js +8 -2
  27. package/dest/interfaces/archiver.d.ts +1 -1
  28. package/dest/interfaces/archiver.d.ts.map +1 -1
  29. package/dest/interfaces/archiver.js +3 -2
  30. package/dest/interfaces/aztec-node-admin.d.ts +55 -7
  31. package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
  32. package/dest/interfaces/aztec-node.d.ts +11 -6
  33. package/dest/interfaces/aztec-node.d.ts.map +1 -1
  34. package/dest/interfaces/aztec-node.js +5 -2
  35. package/dest/interfaces/block-builder.d.ts +17 -9
  36. package/dest/interfaces/block-builder.d.ts.map +1 -1
  37. package/dest/interfaces/block-builder.js +12 -5
  38. package/dest/interfaces/configs.d.ts +42 -7
  39. package/dest/interfaces/configs.d.ts.map +1 -1
  40. package/dest/interfaces/configs.js +2 -1
  41. package/dest/interfaces/merkle_tree_operations.d.ts +9 -19
  42. package/dest/interfaces/merkle_tree_operations.d.ts.map +1 -1
  43. package/dest/interfaces/prover-client.d.ts +6 -1
  44. package/dest/interfaces/prover-client.d.ts.map +1 -1
  45. package/dest/interfaces/prover-client.js +7 -1
  46. package/dest/interfaces/validator.d.ts +65 -6
  47. package/dest/interfaces/validator.d.ts.map +1 -1
  48. package/dest/interfaces/validator.js +6 -3
  49. package/dest/kernel/private_kernel_tail_circuit_public_inputs.d.ts +2 -1
  50. package/dest/kernel/private_kernel_tail_circuit_public_inputs.d.ts.map +1 -1
  51. package/dest/kernel/private_kernel_tail_circuit_public_inputs.js +4 -0
  52. package/dest/logs/log_filter.d.ts +4 -1
  53. package/dest/logs/log_filter.d.ts.map +1 -1
  54. package/dest/logs/log_filter.js +2 -1
  55. package/dest/logs/tx_scoped_l2_log.d.ts +3 -1
  56. package/dest/logs/tx_scoped_l2_log.d.ts.map +1 -1
  57. package/dest/logs/tx_scoped_l2_log.js +7 -0
  58. package/dest/messaging/l2_to_l1_membership.d.ts +32 -6
  59. package/dest/messaging/l2_to_l1_membership.d.ts.map +1 -1
  60. package/dest/messaging/l2_to_l1_membership.js +69 -26
  61. package/dest/p2p/block_proposal.d.ts +2 -2
  62. package/dest/p2p/block_proposal.d.ts.map +1 -1
  63. package/dest/p2p/block_proposal.js +1 -1
  64. package/dest/p2p/checkpoint_proposal.d.ts +2 -7
  65. package/dest/p2p/checkpoint_proposal.d.ts.map +1 -1
  66. package/dest/p2p/checkpoint_proposal.js +14 -24
  67. package/dest/p2p/peer_error.d.ts +3 -1
  68. package/dest/p2p/peer_error.d.ts.map +1 -1
  69. package/dest/p2p/peer_error.js +5 -0
  70. package/dest/slashing/tally.d.ts +5 -6
  71. package/dest/slashing/tally.d.ts.map +1 -1
  72. package/dest/slashing/tally.js +19 -10
  73. package/dest/tests/mocks.d.ts +4 -2
  74. package/dest/tests/mocks.d.ts.map +1 -1
  75. package/dest/tests/mocks.js +13 -8
  76. package/dest/tx/block_header.d.ts +3 -1
  77. package/dest/tx/block_header.d.ts.map +1 -1
  78. package/dest/tx/block_header.js +4 -0
  79. package/dest/tx/tx.d.ts +6 -5
  80. package/dest/tx/tx.d.ts.map +1 -1
  81. package/dest/tx/tx.js +18 -6
  82. package/dest/tx/tx_receipt.d.ts +7 -2
  83. package/dest/tx/tx_receipt.d.ts.map +1 -1
  84. package/dest/tx/tx_receipt.js +6 -3
  85. package/dest/tx/validator/error_texts.d.ts +6 -1
  86. package/dest/tx/validator/error_texts.d.ts.map +1 -1
  87. package/dest/tx/validator/error_texts.js +6 -0
  88. package/dest/update-checker/index.d.ts +3 -2
  89. package/dest/update-checker/index.d.ts.map +1 -1
  90. package/dest/update-checker/index.js +2 -1
  91. package/dest/update-checker/package_version.d.ts +3 -0
  92. package/dest/update-checker/package_version.d.ts.map +1 -0
  93. package/dest/update-checker/package_version.js +24 -0
  94. package/dest/update-checker/version_checker.d.ts +25 -0
  95. package/dest/update-checker/version_checker.d.ts.map +1 -0
  96. package/dest/update-checker/version_checker.js +50 -0
  97. package/dest/validators/errors.d.ts +6 -1
  98. package/dest/validators/errors.d.ts.map +1 -1
  99. package/dest/validators/errors.js +7 -0
  100. package/dest/versioning/versioning.d.ts +4 -2
  101. package/dest/versioning/versioning.d.ts.map +1 -1
  102. package/dest/versioning/versioning.js +4 -1
  103. package/package.json +9 -9
  104. package/src/block/l2_block.ts +13 -1
  105. package/src/block/l2_block_source.ts +14 -7
  106. package/src/checkpoint/checkpoint.ts +12 -3
  107. package/src/checkpoint/index.ts +1 -0
  108. package/src/checkpoint/validate.ts +230 -0
  109. package/src/config/sequencer-config.ts +2 -5
  110. package/src/epoch-helpers/index.ts +3 -0
  111. package/src/gas/gas_fees.ts +1 -7
  112. package/src/interfaces/allowed_element.ts +28 -4
  113. package/src/interfaces/archiver.ts +3 -2
  114. package/src/interfaces/aztec-node.ts +23 -5
  115. package/src/interfaces/block-builder.ts +30 -11
  116. package/src/interfaces/configs.ts +12 -4
  117. package/src/interfaces/merkle_tree_operations.ts +8 -18
  118. package/src/interfaces/prover-client.ts +8 -0
  119. package/src/interfaces/validator.ts +18 -3
  120. package/src/kernel/private_kernel_tail_circuit_public_inputs.ts +9 -0
  121. package/src/logs/log_filter.ts +5 -0
  122. package/src/logs/tx_scoped_l2_log.ts +16 -0
  123. package/src/messaging/l2_to_l1_membership.ts +98 -33
  124. package/src/p2p/block_proposal.ts +1 -1
  125. package/src/p2p/checkpoint_proposal.ts +24 -38
  126. package/src/p2p/peer_error.ts +7 -0
  127. package/src/slashing/tally.ts +22 -4
  128. package/src/tests/mocks.ts +18 -7
  129. package/src/tx/block_header.ts +6 -0
  130. package/src/tx/tx.ts +20 -11
  131. package/src/tx/tx_receipt.ts +7 -2
  132. package/src/tx/validator/error_texts.ts +7 -0
  133. package/src/update-checker/index.ts +2 -1
  134. package/src/update-checker/package_version.ts +30 -0
  135. package/src/update-checker/version_checker.ts +65 -0
  136. package/src/validators/errors.ts +9 -0
  137. package/src/versioning/versioning.ts +4 -1
  138. package/dest/ha-signing/config.d.ts +0 -101
  139. package/dest/ha-signing/config.d.ts.map +0 -1
  140. package/dest/ha-signing/config.js +0 -92
  141. package/dest/ha-signing/index.d.ts +0 -3
  142. package/dest/ha-signing/index.d.ts.map +0 -1
  143. package/dest/ha-signing/index.js +0 -2
  144. package/dest/ha-signing/types.d.ts +0 -85
  145. package/dest/ha-signing/types.d.ts.map +0 -1
  146. package/dest/ha-signing/types.js +0 -32
  147. package/dest/update-checker/update-checker.d.ts +0 -49
  148. package/dest/update-checker/update-checker.d.ts.map +0 -1
  149. package/dest/update-checker/update-checker.js +0 -130
  150. package/src/ha-signing/config.ts +0 -149
  151. package/src/ha-signing/index.ts +0 -18
  152. package/src/ha-signing/types.ts +0 -112
  153. package/src/update-checker/update-checker.ts +0 -166
@@ -86,6 +86,7 @@ export const ArchiverApiSchema: ApiSchemaFor<ArchiverApi> = {
86
86
  getBlockNumber: z.function().args().returns(BlockNumberSchema),
87
87
  getProvenBlockNumber: z.function().args().returns(BlockNumberSchema),
88
88
  getCheckpointedL2BlockNumber: z.function().args().returns(BlockNumberSchema),
89
+ getCheckpointNumber: z.function().args().returns(CheckpointNumberSchema),
89
90
  getFinalizedL2BlockNumber: z.function().args().returns(BlockNumberSchema),
90
91
  getBlock: z.function().args(BlockNumberSchema).returns(L2Block.schema.optional()),
91
92
  getBlockHeader: z
@@ -113,8 +114,8 @@ export const ArchiverApiSchema: ApiSchemaFor<ArchiverApi> = {
113
114
  getL2BlockByArchive: z.function().args(schemas.Fr).returns(L2Block.schema.optional()),
114
115
  getTxEffect: z.function().args(TxHash.schema).returns(indexedTxSchema().optional()),
115
116
  getSettledTxReceipt: z.function().args(TxHash.schema).returns(TxReceipt.schema.optional()),
116
- getL2SlotNumber: z.function().args().returns(schemas.SlotNumber.optional()),
117
- getL2EpochNumber: z.function().args().returns(EpochNumberSchema.optional()),
117
+ getSyncedL2SlotNumber: z.function().args().returns(schemas.SlotNumber.optional()),
118
+ getSyncedL2EpochNumber: z.function().args().returns(EpochNumberSchema.optional()),
118
119
  getCheckpointsForEpoch: z.function().args(EpochNumberSchema).returns(z.array(Checkpoint.schema)),
119
120
  getCheckpointsDataForEpoch: z.function().args(EpochNumberSchema).returns(z.array(CheckpointDataSchema)),
120
121
  getCheckpointedBlocksForEpoch: z.function().args(EpochNumberSchema).returns(z.array(CheckpointedL2Block.schema)),
@@ -4,7 +4,9 @@ import {
4
4
  BlockNumber,
5
5
  BlockNumberPositiveSchema,
6
6
  BlockNumberSchema,
7
+ CheckpointNumber,
7
8
  CheckpointNumberPositiveSchema,
9
+ CheckpointNumberSchema,
8
10
  EpochNumber,
9
11
  EpochNumberSchema,
10
12
  type SlotNumber,
@@ -23,6 +25,7 @@ import { CheckpointedL2Block } from '../block/checkpointed_l2_block.js';
23
25
  import { type DataInBlock, dataInBlockSchemaFor } from '../block/in_block.js';
24
26
  import { L2Block } from '../block/l2_block.js';
25
27
  import { type L2BlockSource, type L2Tips, L2TipsSchema } from '../block/l2_block_source.js';
28
+ import { CheckpointDataSchema } from '../checkpoint/checkpoint_data.js';
26
29
  import { PublishedCheckpoint } from '../checkpoint/published_checkpoint.js';
27
30
  import {
28
31
  type ContractClassPublic,
@@ -72,7 +75,12 @@ import { type WorldStateSyncStatus, WorldStateSyncStatusSchema } from './world_s
72
75
  export interface AztecNode
73
76
  extends Pick<
74
77
  L2BlockSource,
75
- 'getBlocks' | 'getCheckpoints' | 'getBlockHeader' | 'getL2Tips' | 'getCheckpointedBlocks'
78
+ | 'getBlocks'
79
+ | 'getCheckpoints'
80
+ | 'getBlockHeader'
81
+ | 'getL2Tips'
82
+ | 'getCheckpointedBlocks'
83
+ | 'getCheckpointsDataForEpoch'
76
84
  > {
77
85
  /**
78
86
  * Returns the tips of the L2 chain.
@@ -172,14 +180,14 @@ export interface AztecNode
172
180
  l1ToL2Message: Fr,
173
181
  ): Promise<[bigint, SiblingPath<typeof L1_TO_L2_MSG_TREE_HEIGHT>] | undefined>;
174
182
 
175
- /** Returns the L2 block number in which this L1 to L2 message becomes available, or undefined if not found. */
176
- getL1ToL2MessageBlock(l1ToL2Message: Fr): Promise<BlockNumber | undefined>;
183
+ /** Returns the L2 checkpoint number in which this L1 to L2 message becomes available, or undefined if not found. */
184
+ getL1ToL2MessageCheckpoint(l1ToL2Message: Fr): Promise<CheckpointNumber | undefined>;
177
185
 
178
186
  /**
179
187
  * Returns whether an L1 to L2 message is synced by archiver.
180
188
  * @param l1ToL2Message - The L1 to L2 message to check.
181
189
  * @returns Whether the message is synced.
182
- * @deprecated Use `getL1ToL2MessageBlock` instead. This method may return true even if the message is not ready to use.
190
+ * @deprecated Use `getL1ToL2MessageCheckpoint` instead. This method may return true even if the message is not ready to use.
183
191
  */
184
192
  isL1ToL2MessageSynced(l1ToL2Message: Fr): Promise<boolean>;
185
193
 
@@ -230,6 +238,12 @@ export interface AztecNode
230
238
  */
231
239
  getCheckpointedBlockNumber(): Promise<BlockNumber>;
232
240
 
241
+ /**
242
+ * Method to fetch the latest checkpoint number synchronized by the node.
243
+ * @returns The checkpoint number.
244
+ */
245
+ getCheckpointNumber(): Promise<CheckpointNumber>;
246
+
233
247
  /**
234
248
  * Method to determine if the node is ready to accept transactions.
235
249
  * @returns - Flag indicating the readiness for tx submission.
@@ -517,7 +531,7 @@ export const AztecNodeApiSchema: ApiSchemaFor<AztecNode> = {
517
531
  .args(BlockParameterSchema, schemas.Fr)
518
532
  .returns(z.tuple([schemas.BigInt, SiblingPath.schemaFor(L1_TO_L2_MSG_TREE_HEIGHT)]).optional()),
519
533
 
520
- getL1ToL2MessageBlock: z.function().args(schemas.Fr).returns(BlockNumberSchema.optional()),
534
+ getL1ToL2MessageCheckpoint: z.function().args(schemas.Fr).returns(CheckpointNumberSchema.optional()),
521
535
 
522
536
  isL1ToL2MessageSynced: z.function().args(schemas.Fr).returns(z.boolean()),
523
537
 
@@ -534,6 +548,8 @@ export const AztecNodeApiSchema: ApiSchemaFor<AztecNode> = {
534
548
 
535
549
  getBlockNumber: z.function().returns(BlockNumberSchema),
536
550
 
551
+ getCheckpointNumber: z.function().returns(CheckpointNumberSchema),
552
+
537
553
  getProvenBlockNumber: z.function().returns(BlockNumberSchema),
538
554
 
539
555
  getCheckpointedBlockNumber: z.function().returns(BlockNumberSchema),
@@ -557,6 +573,8 @@ export const AztecNodeApiSchema: ApiSchemaFor<AztecNode> = {
557
573
  .args(BlockNumberPositiveSchema, z.number().gt(0).lte(MAX_RPC_BLOCKS_LEN))
558
574
  .returns(z.array(CheckpointedL2Block.schema)),
559
575
 
576
+ getCheckpointsDataForEpoch: z.function().args(EpochNumberSchema).returns(z.array(CheckpointDataSchema)),
577
+
560
578
  getCurrentMinFees: z.function().returns(GasFees.schema),
561
579
 
562
580
  getMaxPriorityFees: z.function().returns(GasFees.schema),
@@ -36,11 +36,16 @@ export interface IBlockFactory extends ProcessedTxHandler {
36
36
  }
37
37
 
38
38
  export interface PublicProcessorLimits {
39
+ /** Maximum number of txs to process. */
39
40
  maxTransactions?: number;
40
- maxBlockSize?: number;
41
+ /** L2 and DA gas limits. */
41
42
  maxBlockGas?: Gas;
43
+ /** Maximum number of blob fields allowed. */
42
44
  maxBlobFields?: number;
45
+ /** Deadline for processing the txs. Processor will stop as soon as it hits this time. */
43
46
  deadline?: Date;
47
+ /** Whether this processor is building a proposal (as opposed to re-executing one). Skipping txs due to gas or blob limits is only done during proposal building. */
48
+ isBuildingProposal?: boolean;
44
49
  }
45
50
 
46
51
  export interface PublicProcessorValidator {
@@ -48,11 +53,17 @@ export interface PublicProcessorValidator {
48
53
  nullifierCache?: { addNullifiers: (nullifiers: Buffer[]) => void };
49
54
  }
50
55
 
51
- export type FullNodeBlockBuilderConfig = Pick<L1RollupConstants, 'l1GenesisTime' | 'slotDuration'> &
56
+ export type FullNodeBlockBuilderConfig = Pick<L1RollupConstants, 'l1GenesisTime' | 'slotDuration' | 'rollupManaLimit'> &
52
57
  Pick<ChainConfig, 'l1ChainId' | 'rollupVersion'> &
53
58
  Pick<
54
59
  SequencerConfig,
55
- 'txPublicSetupAllowListExtend' | 'fakeProcessingDelayPerTxMs' | 'fakeThrowAfterProcessingTxCount'
60
+ | 'txPublicSetupAllowListExtend'
61
+ | 'fakeProcessingDelayPerTxMs'
62
+ | 'fakeThrowAfterProcessingTxCount'
63
+ | 'maxTxsPerBlock'
64
+ | 'maxTxsPerCheckpoint'
65
+ | 'maxL2BlockGas'
66
+ | 'maxDABlockGas'
56
67
  >;
57
68
 
58
69
  export const FullNodeBlockBuilderConfigKeys: (keyof FullNodeBlockBuilderConfig)[] = [
@@ -63,34 +74,42 @@ export const FullNodeBlockBuilderConfigKeys: (keyof FullNodeBlockBuilderConfig)[
63
74
  'txPublicSetupAllowListExtend',
64
75
  'fakeProcessingDelayPerTxMs',
65
76
  'fakeThrowAfterProcessingTxCount',
77
+ 'maxTxsPerBlock',
78
+ 'maxTxsPerCheckpoint',
79
+ 'maxL2BlockGas',
80
+ 'maxDABlockGas',
81
+ 'rollupManaLimit',
66
82
  ] as const;
67
83
 
68
- /** Thrown when no valid transactions are available to include in a block after processing, and this is not the first block in a checkpoint. */
69
- export class NoValidTxsError extends Error {
70
- constructor(public readonly failedTxs: FailedTx[]) {
71
- super('No valid transactions to include in block');
72
- this.name = 'NoValidTxsError';
84
+ /** Thrown when the number of successfully processed transactions is below the required minimum. */
85
+ export class InsufficientValidTxsError extends Error {
86
+ constructor(
87
+ public readonly processedCount: number,
88
+ public readonly minRequired: number,
89
+ public readonly failedTxs: FailedTx[],
90
+ ) {
91
+ super(`Insufficient valid txs: got ${processedCount} but need ${minRequired}`);
92
+ this.name = 'InsufficientValidTxsError';
73
93
  }
74
94
  }
75
95
 
76
96
  /** Result of building a block within a checkpoint. */
77
97
  export type BuildBlockInCheckpointResult = {
78
98
  block: L2Block;
79
- publicGas: Gas;
80
99
  publicProcessorDuration: number;
81
100
  numTxs: number;
82
101
  failedTxs: FailedTx[];
83
102
  usedTxs: Tx[];
84
- usedTxBlobFields: number;
85
103
  };
86
104
 
87
105
  /** Interface for building blocks within a checkpoint context. */
88
106
  export interface ICheckpointBlockBuilder {
107
+ /** Builds a single block within this checkpoint. Throws InsufficientValidTxsError if fewer than minValidTxs succeed. */
89
108
  buildBlock(
90
109
  pendingTxs: Iterable<Tx> | AsyncIterable<Tx>,
91
110
  blockNumber: BlockNumber,
92
111
  timestamp: bigint,
93
- opts: PublicProcessorLimits,
112
+ opts: PublicProcessorLimits & { minValidTxs?: number },
94
113
  ): Promise<BuildBlockInCheckpointResult>;
95
114
  }
96
115
 
@@ -13,6 +13,8 @@ export interface SequencerConfig {
13
13
  sequencerPollingIntervalMS?: number;
14
14
  /** The maximum number of txs to include in a block. */
15
15
  maxTxsPerBlock?: number;
16
+ /** The maximum number of txs across all blocks in a checkpoint. */
17
+ maxTxsPerCheckpoint?: number;
16
18
  /** The minimum number of txs to include in a block. */
17
19
  minTxsPerBlock?: number;
18
20
  /** The minimum number of valid txs (after execution) to include in a block. If not set, falls back to minTxsPerBlock. */
@@ -23,6 +25,8 @@ export interface SequencerConfig {
23
25
  maxL2BlockGas?: number;
24
26
  /** The maximum DA block gas. */
25
27
  maxDABlockGas?: number;
28
+ /** Per-block gas budget multiplier for both L2 and DA gas. Budget = (checkpointLimit / maxBlocks) * multiplier. */
29
+ perBlockAllocationMultiplier?: number;
26
30
  /** Recipient of block reward. */
27
31
  coinbase?: EthAddress;
28
32
  /** Address to receive fees. */
@@ -33,8 +37,6 @@ export interface SequencerConfig {
33
37
  acvmBinaryPath?: string;
34
38
  /** Additional entries to extend the default setup allow list. */
35
39
  txPublicSetupAllowListExtend?: AllowedElement[];
36
- /** Max block size */
37
- maxBlockSizeInBytes?: number;
38
40
  /** Payload address to vote for */
39
41
  governanceProposerPayload?: EthAddress;
40
42
  /** Whether to enforce the time table when building blocks */
@@ -85,17 +87,18 @@ export const SequencerConfigSchema = zodFor<SequencerConfig>()(
85
87
  z.object({
86
88
  sequencerPollingIntervalMS: z.number().optional(),
87
89
  maxTxsPerBlock: z.number().optional(),
90
+ maxTxsPerCheckpoint: z.number().optional(),
88
91
  minValidTxsPerBlock: z.number().optional(),
89
92
  minTxsPerBlock: z.number().optional(),
90
93
  maxL2BlockGas: z.number().optional(),
91
94
  publishTxsWithProposals: z.boolean().optional(),
92
95
  maxDABlockGas: z.number().optional(),
96
+ perBlockAllocationMultiplier: z.number().optional(),
93
97
  coinbase: schemas.EthAddress.optional(),
94
98
  feeRecipient: schemas.AztecAddress.optional(),
95
99
  acvmWorkingDirectory: z.string().optional(),
96
100
  acvmBinaryPath: z.string().optional(),
97
101
  txPublicSetupAllowListExtend: z.array(AllowedElementSchema).optional(),
98
- maxBlockSizeInBytes: z.number().optional(),
99
102
  governanceProposerPayload: schemas.EthAddress.optional(),
100
103
  l1PublishingTime: z.number().optional(),
101
104
  enforceTimeTable: z.boolean().optional(),
@@ -134,7 +137,12 @@ type SequencerConfigOptionalKeys =
134
137
  | 'l1PublishingTime'
135
138
  | 'txPublicSetupAllowListExtend'
136
139
  | 'minValidTxsPerBlock'
137
- | 'minBlocksForCheckpoint';
140
+ | 'minBlocksForCheckpoint'
141
+ | 'maxTxsPerBlock'
142
+ | 'maxTxsPerCheckpoint'
143
+ | 'maxL2BlockGas'
144
+ | 'maxDABlockGas'
145
+ | 'perBlockAllocationMultiplier';
138
146
 
139
147
  export type ResolvedSequencerConfig = Prettify<
140
148
  Required<Omit<SequencerConfig, SequencerConfigOptionalKeys>> & Pick<SequencerConfig, SequencerConfigOptionalKeys>
@@ -225,30 +225,20 @@ export interface MerkleTreeReadOperations {
225
225
  }
226
226
 
227
227
  export interface MerkleTreeCheckpointOperations {
228
- /**
229
- * Checkpoints the current fork state
230
- */
231
- createCheckpoint(): Promise<void>;
228
+ /** Checkpoints the current fork state. Returns the depth of the new checkpoint. */
229
+ createCheckpoint(): Promise<number>;
232
230
 
233
- /**
234
- * Commits the current checkpoint
235
- */
231
+ /** Commits the current checkpoint. */
236
232
  commitCheckpoint(): Promise<void>;
237
233
 
238
- /**
239
- * Reverts the current checkpoint
240
- */
234
+ /** Reverts the current checkpoint. */
241
235
  revertCheckpoint(): Promise<void>;
242
236
 
243
- /**
244
- * Commits all checkpoints
245
- */
246
- commitAllCheckpoints(): Promise<void>;
237
+ /** Commits all checkpoints above the given depth, leaving checkpoint depth at the given value. */
238
+ commitAllCheckpointsTo(depth: number): Promise<void>;
247
239
 
248
- /**
249
- * Reverts all checkpoints
250
- */
251
- revertAllCheckpoints(): Promise<void>;
240
+ /** Reverts all checkpoints above the given depth, leaving checkpoint depth at the given value. */
241
+ revertAllCheckpointsTo(depth: number): Promise<void>;
252
242
  }
253
243
 
254
244
  export interface MerkleTreeWriteOperations
@@ -23,6 +23,8 @@ export type ActualProverConfig = {
23
23
  * When true, jobs are explicitly cancelled with the broker, which prevents reuse.
24
24
  */
25
25
  cancelJobsOnStop: boolean;
26
+ /** Max concurrent jobs the orchestrator serializes and enqueues to the broker. */
27
+ enqueueConcurrency: number;
26
28
  };
27
29
 
28
30
  /**
@@ -53,6 +55,7 @@ export const ProverConfigSchema = zodFor<ProverConfig>()(
53
55
  proofStore: z.string().optional(),
54
56
  failedProofStore: z.string().optional(),
55
57
  cancelJobsOnStop: z.boolean(),
58
+ enqueueConcurrency: z.number(),
56
59
  }),
57
60
  );
58
61
 
@@ -107,6 +110,11 @@ export const proverConfigMappings: ConfigMappingsType<ProverConfig> = {
107
110
  'When true, jobs are explicitly cancelled with the broker, which prevents reuse.',
108
111
  ...booleanConfigHelper(false),
109
112
  },
113
+ enqueueConcurrency: {
114
+ env: 'PROVER_ENQUEUE_CONCURRENCY',
115
+ description: 'Max concurrent jobs the orchestrator serializes and enqueues to the broker.',
116
+ ...numberConfigHelper(50),
117
+ },
110
118
  };
111
119
 
112
120
  function parseProverId(str?: string) {
@@ -15,12 +15,12 @@ import type {
15
15
  } from '@aztec/stdlib/p2p';
16
16
  import type { CheckpointHeader } from '@aztec/stdlib/rollup';
17
17
  import type { BlockHeader, Tx } from '@aztec/stdlib/tx';
18
+ import { type ValidatorHASignerConfig, ValidatorHASignerConfigSchema } from '@aztec/validator-ha-signer/config';
18
19
 
19
20
  import type { PeerId } from '@libp2p/interface';
20
21
  import { z } from 'zod';
21
22
 
22
23
  import type { CommitteeAttestationsAndSigners } from '../block/index.js';
23
- import { type ValidatorHASignerConfig, ValidatorHASignerConfigSchema } from '../ha-signing/index.js';
24
24
  import { AllowedElementSchema } from './allowed_element.js';
25
25
 
26
26
  /**
@@ -59,10 +59,22 @@ export type ValidatorClientConfig = ValidatorHASignerConfig & {
59
59
 
60
60
  /** Agree to attest to equivocated checkpoint proposals (for testing purposes only) */
61
61
  attestToEquivocatedProposals?: boolean;
62
+
63
+ /** Maximum L2 gas per block for validation. Proposals exceeding this limit are rejected. */
64
+ validateMaxL2BlockGas?: number;
65
+
66
+ /** Maximum DA gas per block for validation. Proposals exceeding this limit are rejected. */
67
+ validateMaxDABlockGas?: number;
68
+
69
+ /** Maximum transactions per block for validation. Proposals exceeding this limit are rejected. */
70
+ validateMaxTxsPerBlock?: number;
71
+
72
+ /** Maximum transactions per checkpoint for validation. Proposals exceeding this limit are rejected. */
73
+ validateMaxTxsPerCheckpoint?: number;
62
74
  };
63
75
 
64
76
  export type ValidatorClientFullConfig = ValidatorClientConfig &
65
- Pick<SequencerConfig, 'txPublicSetupAllowListExtend' | 'broadcastInvalidBlockProposal' | 'maxTxsPerBlock'> &
77
+ Pick<SequencerConfig, 'txPublicSetupAllowListExtend' | 'broadcastInvalidBlockProposal'> &
66
78
  Pick<
67
79
  SlasherConfig,
68
80
  'slashBroadcastedInvalidBlockPenalty' | 'slashDuplicateProposalPenalty' | 'slashDuplicateAttestationPenalty'
@@ -86,6 +98,10 @@ export const ValidatorClientConfigSchema = zodFor<Omit<ValidatorClientConfig, 'v
86
98
  skipCheckpointProposalValidation: z.boolean().optional(),
87
99
  skipPushProposedBlocksToArchiver: z.boolean().optional(),
88
100
  attestToEquivocatedProposals: z.boolean().optional(),
101
+ validateMaxL2BlockGas: z.number().optional(),
102
+ validateMaxDABlockGas: z.number().optional(),
103
+ validateMaxTxsPerBlock: z.number().optional(),
104
+ validateMaxTxsPerCheckpoint: z.number().optional(),
89
105
  }),
90
106
  );
91
107
 
@@ -93,7 +109,6 @@ export const ValidatorClientFullConfigSchema = zodFor<Omit<ValidatorClientFullCo
93
109
  ValidatorClientConfigSchema.extend({
94
110
  txPublicSetupAllowListExtend: z.array(AllowedElementSchema).optional(),
95
111
  broadcastInvalidBlockProposal: z.boolean().optional(),
96
- maxTxsPerBlock: z.number().optional(),
97
112
  slashBroadcastedInvalidBlockPenalty: schemas.BigInt,
98
113
  slashDuplicateProposalPenalty: schemas.BigInt,
99
114
  slashDuplicateAttestationPenalty: schemas.BigInt,
@@ -234,6 +234,15 @@ export class PrivateKernelTailCircuitPublicInputs {
234
234
  return noteHashes.filter(n => !n.isZero());
235
235
  }
236
236
 
237
+ getNonEmptyL2ToL1Msgs() {
238
+ const l2ToL1Msgs = this.forPublic
239
+ ? this.forPublic.nonRevertibleAccumulatedData.l2ToL1Msgs.concat(
240
+ this.forPublic.revertibleAccumulatedData.l2ToL1Msgs,
241
+ )
242
+ : this.forRollup!.end.l2ToL1Msgs;
243
+ return l2ToL1Msgs.filter(m => !m.isEmpty());
244
+ }
245
+
237
246
  getNonEmptyNullifiers() {
238
247
  const nullifiers = this.forPublic
239
248
  ? this.forPublic.nonRevertibleAccumulatedData.nullifiers.concat(
@@ -1,3 +1,5 @@
1
+ import type { Fr } from '@aztec/foundation/curves/bn254';
2
+
1
3
  import { z } from 'zod';
2
4
 
3
5
  import type { AztecAddress } from '../aztec-address/index.js';
@@ -20,6 +22,8 @@ export type LogFilter = {
20
22
  afterLog?: LogId;
21
23
  /** The contract address to filter logs by. */
22
24
  contractAddress?: AztecAddress;
25
+ /** The tag (first field of the log) to filter logs by. */
26
+ tag?: Fr;
23
27
  };
24
28
 
25
29
  export const LogFilterSchema: ZodFor<LogFilter> = z.object({
@@ -28,4 +32,5 @@ export const LogFilterSchema: ZodFor<LogFilter> = z.object({
28
32
  toBlock: schemas.Integer.optional(),
29
33
  afterLog: LogId.schema.optional(),
30
34
  contractAddress: schemas.AztecAddress.optional(),
35
+ tag: schemas.Fr.optional(),
31
36
  });
@@ -1,4 +1,5 @@
1
1
  import { BlockNumber, BlockNumberSchema } from '@aztec/foundation/branded-types';
2
+ import { times } from '@aztec/foundation/collection';
2
3
  import { Fr } from '@aztec/foundation/curves/bn254';
3
4
  import { schemas as foundationSchemas } from '@aztec/foundation/schemas';
4
5
  import {
@@ -83,6 +84,21 @@ export class TxScopedL2Log {
83
84
  return new TxScopedL2Log(txHash, blockNumber, blockTimestamp, logData, noteHashes, firstNullifier);
84
85
  }
85
86
 
87
+ static getBlockNumberFromBuffer(buffer: Buffer) {
88
+ return BlockNumber(buffer.readUint32BE(Fr.SIZE_IN_BYTES));
89
+ }
90
+
91
+ static random() {
92
+ return new TxScopedL2Log(
93
+ TxHash.fromField(Fr.random()),
94
+ BlockNumber(Math.floor(Math.random() * 100000) + 1),
95
+ BigInt(Math.floor(Date.now() / 1000)),
96
+ times(3, Fr.random),
97
+ times(3, Fr.random),
98
+ Fr.random(),
99
+ );
100
+ }
101
+
86
102
  equals(other: TxScopedL2Log) {
87
103
  return (
88
104
  this.txHash.equals(other.txHash) &&
@@ -3,6 +3,9 @@ import type { EpochNumber } from '@aztec/foundation/branded-types';
3
3
  import { Fr } from '@aztec/foundation/curves/bn254';
4
4
  import { SiblingPath, UnbalancedMerkleTreeCalculator, computeUnbalancedShaRoot } from '@aztec/foundation/trees';
5
5
 
6
+ import type { AztecNode } from '../interfaces/aztec-node.js';
7
+ import { TxHash } from '../tx/tx_hash.js';
8
+
6
9
  /**
7
10
  * # L2-to-L1 Message Tree Structure and Leaf IDs
8
11
  *
@@ -92,59 +95,94 @@ export function getL2ToL1MessageLeafId(
92
95
  return 2n ** BigInt(membershipWitness.siblingPath.pathSize) + membershipWitness.leafIndex;
93
96
  }
94
97
 
95
- export interface MessageRetrieval {
96
- getL2ToL1Messages(epoch: EpochNumber): Promise<Fr[][][][]>;
97
- }
98
-
99
98
  export type L2ToL1MembershipWitness = {
100
99
  root: Fr;
101
100
  leafIndex: bigint;
102
101
  siblingPath: SiblingPath<number>;
102
+ epochNumber: EpochNumber;
103
103
  };
104
104
 
105
+ /**
106
+ * Computes the L2 to L1 membership witness for a given message in a transaction.
107
+ *
108
+ * @param node - The Aztec node to query for block/tx/epoch data.
109
+ * @param message - The L2 to L1 message hash to prove membership of.
110
+ * @param txHash - The hash of the transaction that emitted the message.
111
+ * @param messageIndexInTx - Optional index of the message within the transaction's L2-to-L1 messages.
112
+ * If not provided, the message is found by scanning the tx's messages (throws if duplicates exist).
113
+ * @returns The membership witness and epoch number, or undefined if the tx is not yet in a block/epoch.
114
+ */
105
115
  export async function computeL2ToL1MembershipWitness(
106
- messageRetriever: MessageRetrieval,
107
- epoch: EpochNumber,
116
+ node: Pick<
117
+ AztecNode,
118
+ 'getL2ToL1Messages' | 'getTxReceipt' | 'getTxEffect' | 'getBlock' | 'getCheckpointsDataForEpoch'
119
+ >,
108
120
  message: Fr,
121
+ txHash: TxHash,
122
+ messageIndexInTx?: number,
109
123
  ): Promise<L2ToL1MembershipWitness | undefined> {
110
- const messagesInEpoch = await messageRetriever.getL2ToL1Messages(epoch);
111
- if (messagesInEpoch.length === 0) {
124
+ const { epochNumber, blockNumber } = await node.getTxReceipt(txHash);
125
+ if (epochNumber === undefined || blockNumber === undefined) {
126
+ return undefined;
127
+ }
128
+
129
+ const [messagesInEpoch, block, txEffect, checkpointsData] = await Promise.all([
130
+ node.getL2ToL1Messages(epochNumber),
131
+ node.getBlock(blockNumber),
132
+ node.getTxEffect(txHash),
133
+ node.getCheckpointsDataForEpoch(epochNumber),
134
+ ]);
135
+
136
+ if (messagesInEpoch.length === 0 || !block || !txEffect) {
137
+ return undefined;
138
+ }
139
+
140
+ const checkpointIndex = checkpointsData.findIndex(c => c.checkpointNumber === block.checkpointNumber);
141
+ if (checkpointIndex === -1) {
112
142
  return undefined;
113
143
  }
114
144
 
115
- return computeL2ToL1MembershipWitnessFromMessagesInEpoch(messagesInEpoch, message);
145
+ const blockIndex = block.indexWithinCheckpoint;
146
+ const txIndex = txEffect.txIndexInBlock;
147
+
148
+ const { root, leafIndex, siblingPath } = computeL2ToL1MembershipWitnessFromMessagesInEpoch(
149
+ messagesInEpoch,
150
+ message,
151
+ checkpointIndex,
152
+ blockIndex,
153
+ txIndex,
154
+ messageIndexInTx,
155
+ );
156
+ return { epochNumber, root, leafIndex, siblingPath };
116
157
  }
117
158
 
118
- // TODO: Allow to specify the message to consume by its index or by an offset, in case there are multiple messages with
119
- // the same value.
159
+ /**
160
+ * Computes a membership witness for a message in the epoch's L2-to-L1 message tree, given explicit position indices.
161
+ *
162
+ * @param messagesInEpoch - All L2-to-L1 messages in the epoch, organized as checkpoints → blocks → txs → messages.
163
+ * @param message - The message hash to prove membership of.
164
+ * @param checkpointIndex - Index of the checkpoint within the epoch's message array.
165
+ * @param blockIndex - Index of the block within the checkpoint.
166
+ * @param txIndex - Index of the transaction within the block.
167
+ * @param messageIndexInTx - Optional index of the message within the transaction's messages.
168
+ * If not provided, the message is found by scanning (throws if duplicates exist within the tx).
169
+ */
170
+ /** @internal Exported for testing only. */
120
171
  export function computeL2ToL1MembershipWitnessFromMessagesInEpoch(
121
172
  messagesInEpoch: Fr[][][][],
122
173
  message: Fr,
123
- ): L2ToL1MembershipWitness {
124
- // Find the index of the message in the tx, index of the tx in the block, and index of the block in the epoch.
125
- let messageIndexInTx = -1;
126
- let txIndex = -1;
127
- let blockIndex = -1;
128
- const checkpointIndex = messagesInEpoch.findIndex(messagesInCheckpoint => {
129
- blockIndex = messagesInCheckpoint.findIndex(messagesInBlock => {
130
- txIndex = messagesInBlock.findIndex(messagesInTx => {
131
- messageIndexInTx = messagesInTx.findIndex(msg => msg.equals(message));
132
- return messageIndexInTx !== -1;
133
- });
134
- return txIndex !== -1;
135
- });
136
- return blockIndex !== -1;
137
- });
138
-
139
- if (checkpointIndex === -1) {
140
- throw new Error('The L2ToL1Message you are trying to prove inclusion of does not exist');
141
- }
174
+ checkpointIndex: number,
175
+ blockIndex: number,
176
+ txIndex: number,
177
+ messageIndexInTx?: number,
178
+ ): { root: Fr; leafIndex: bigint; siblingPath: SiblingPath<number> } {
179
+ const messagesInTx = messagesInEpoch[checkpointIndex][blockIndex][txIndex];
180
+ const resolvedMessageIndex = resolveMessageIndex(messagesInTx, message, messageIndexInTx);
142
181
 
143
182
  // Build the tx tree.
144
- const messagesInTx = messagesInEpoch[checkpointIndex][blockIndex][txIndex];
145
183
  const txTree = UnbalancedMerkleTreeCalculator.create(messagesInTx.map(msg => msg.toBuffer()));
146
184
  // Get the sibling path of the target message in the tx tree.
147
- const pathToMessageInTxSubtree = txTree.getSiblingPathByLeafIndex(messageIndexInTx);
185
+ const pathToMessageInTxSubtree = txTree.getSiblingPathByLeafIndex(resolvedMessageIndex);
148
186
 
149
187
  // Build the tree of the block containing the target message.
150
188
  const blockTree = buildBlockTree(messagesInEpoch[checkpointIndex][blockIndex]);
@@ -189,7 +227,7 @@ export function computeL2ToL1MembershipWitnessFromMessagesInEpoch(
189
227
  // Compute the combined index.
190
228
  // It is the index of the message in the balanced tree (by filling up the wonky tree with empty nodes) at its current
191
229
  // height. It's used to validate the membership proof.
192
- const messageLeafPosition = txTree.getLeafLocation(messageIndexInTx);
230
+ const messageLeafPosition = txTree.getLeafLocation(resolvedMessageIndex);
193
231
  const txLeafPosition = blockTree.getLeafLocation(txIndex);
194
232
  const blockLeafPosition = checkpointTree.getLeafLocation(blockIndex);
195
233
  const checkpointLeafPosition = epochTree.getLeafLocation(checkpointIndex);
@@ -207,6 +245,33 @@ export function computeL2ToL1MembershipWitnessFromMessagesInEpoch(
207
245
  };
208
246
  }
209
247
 
248
+ function resolveMessageIndex(messagesInTx: Fr[], message: Fr, messageIndexInTx?: number): number {
249
+ if (messageIndexInTx !== undefined) {
250
+ if (!messagesInTx[messageIndexInTx]?.equals(message)) {
251
+ throw new Error(`Message at index ${messageIndexInTx} in tx does not match the expected message ${message}`);
252
+ }
253
+ return messageIndexInTx;
254
+ }
255
+
256
+ const indices = messagesInTx.reduce<number[]>((acc, msg, i) => {
257
+ if (msg.equals(message)) {
258
+ acc.push(i);
259
+ }
260
+ return acc;
261
+ }, []);
262
+
263
+ if (indices.length === 0) {
264
+ throw new Error('The L2ToL1Message you are trying to prove inclusion of does not exist');
265
+ }
266
+ if (indices.length > 1) {
267
+ throw new Error(
268
+ `Multiple messages with the same value ${message} found in tx (indices: ${indices.join(', ')}). ` +
269
+ `Provide messageIndexInTx to disambiguate.`,
270
+ );
271
+ }
272
+ return indices[0];
273
+ }
274
+
210
275
  function buildCheckpointTree(messagesInCheckpoint: Fr[][][]) {
211
276
  const blockOutHashes = messagesInCheckpoint.map(messagesInBlock => buildBlockTree(messagesInBlock).getRoot());
212
277
  return buildCompressedTree(blockOutHashes);
@@ -6,11 +6,11 @@ import { Fr } from '@aztec/foundation/curves/bn254';
6
6
  import type { EthAddress } from '@aztec/foundation/eth-address';
7
7
  import { Signature } from '@aztec/foundation/eth-signature';
8
8
  import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
9
+ import { DutyType, type SigningContext } from '@aztec/validator-ha-signer/types';
9
10
 
10
11
  import type { L2Block } from '../block/l2_block.js';
11
12
  import type { L2BlockInfo } from '../block/l2_block_info.js';
12
13
  import { MAX_TXS_PER_BLOCK } from '../deserialization/index.js';
13
- import { DutyType, type SigningContext } from '../ha-signing/index.js';
14
14
  import { BlockHeader } from '../tx/block_header.js';
15
15
  import { TxHash } from '../tx/index.js';
16
16
  import type { Tx } from '../tx/tx.js';