@aztec/stdlib 0.87.2 → 0.87.3-nightly.20250528

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 (152) hide show
  1. package/dest/abi/abi.d.ts +3 -0
  2. package/dest/abi/abi.d.ts.map +1 -1
  3. package/dest/abi/abi.js +38 -0
  4. package/dest/avm/avm.d.ts +696 -12
  5. package/dest/avm/avm.d.ts.map +1 -1
  6. package/dest/avm/avm.js +16 -8
  7. package/dest/avm/avm_accumulated_data.d.ts +77 -0
  8. package/dest/avm/avm_accumulated_data.d.ts.map +1 -1
  9. package/dest/avm/avm_accumulated_data.js +67 -0
  10. package/dest/avm/avm_circuit_public_inputs.d.ts +73 -3
  11. package/dest/avm/avm_circuit_public_inputs.d.ts.map +1 -1
  12. package/dest/avm/avm_circuit_public_inputs.js +19 -9
  13. package/dest/avm/avm_proving_request.d.ts +366 -0
  14. package/dest/avm/avm_proving_request.d.ts.map +1 -1
  15. package/dest/block/body.d.ts +1 -1
  16. package/dest/block/body.d.ts.map +1 -1
  17. package/dest/block/body.js +2 -2
  18. package/dest/block/index.d.ts +1 -0
  19. package/dest/block/index.d.ts.map +1 -1
  20. package/dest/block/index.js +1 -0
  21. package/dest/block/l2_block.d.ts +1 -1
  22. package/dest/block/l2_block.d.ts.map +1 -1
  23. package/dest/block/l2_block.js +2 -2
  24. package/dest/block/l2_block_source.d.ts +9 -4
  25. package/dest/block/l2_block_source.d.ts.map +1 -1
  26. package/dest/block/l2_block_source.js +1 -0
  27. package/dest/block/proposal/committee_attestation.d.ts +34 -0
  28. package/dest/block/proposal/committee_attestation.d.ts.map +1 -0
  29. package/dest/block/proposal/committee_attestation.js +59 -0
  30. package/dest/block/proposal/index.d.ts +2 -0
  31. package/dest/block/proposal/index.d.ts.map +1 -0
  32. package/dest/block/proposal/index.js +1 -0
  33. package/dest/block/published_l2_block.d.ts +99 -69
  34. package/dest/block/published_l2_block.d.ts.map +1 -1
  35. package/dest/block/published_l2_block.js +38 -12
  36. package/dest/block/test/l2_tips_store_test_suite.js +1 -1
  37. package/dest/interfaces/archiver.js +2 -2
  38. package/dest/interfaces/aztec-node.js +2 -2
  39. package/dest/interfaces/prover-agent.d.ts +31 -6
  40. package/dest/interfaces/prover-agent.d.ts.map +1 -1
  41. package/dest/interfaces/prover-agent.js +15 -6
  42. package/dest/interfaces/proving-job.d.ts +370 -4
  43. package/dest/interfaces/proving-job.d.ts.map +1 -1
  44. package/dest/interfaces/proving-job.js +2 -2
  45. package/dest/interfaces/server_circuit_prover.d.ts +3 -2
  46. package/dest/interfaces/server_circuit_prover.d.ts.map +1 -1
  47. package/dest/kernel/index.d.ts +1 -0
  48. package/dest/kernel/index.d.ts.map +1 -1
  49. package/dest/kernel/index.js +1 -0
  50. package/dest/kernel/padded_side_effects.d.ts +26 -0
  51. package/dest/kernel/padded_side_effects.d.ts.map +1 -0
  52. package/dest/kernel/padded_side_effects.js +51 -0
  53. package/dest/kernel/private_kernel_data.d.ts +6 -25
  54. package/dest/kernel/private_kernel_data.d.ts.map +1 -1
  55. package/dest/kernel/private_kernel_data.js +8 -19
  56. package/dest/kernel/private_kernel_prover_output.d.ts +3 -0
  57. package/dest/kernel/private_kernel_prover_output.d.ts.map +1 -1
  58. package/dest/kernel/private_kernel_reset_circuit_private_inputs.d.ts +5 -2
  59. package/dest/kernel/private_kernel_reset_circuit_private_inputs.d.ts.map +1 -1
  60. package/dest/kernel/private_kernel_reset_circuit_private_inputs.js +9 -5
  61. package/dest/kernel/private_kernel_tail_circuit_private_inputs.d.ts +10 -1
  62. package/dest/kernel/private_kernel_tail_circuit_private_inputs.d.ts.map +1 -1
  63. package/dest/kernel/private_kernel_tail_circuit_private_inputs.js +8 -3
  64. package/dest/kernel/public_call_request.d.ts +54 -0
  65. package/dest/kernel/public_call_request.d.ts.map +1 -1
  66. package/dest/kernel/public_call_request.js +58 -0
  67. package/dest/logs/pending_tagged_log.d.ts +1 -1
  68. package/dest/logs/pending_tagged_log.js +1 -1
  69. package/dest/rollup/avm_proof_data.d.ts +7 -5
  70. package/dest/rollup/avm_proof_data.d.ts.map +1 -1
  71. package/dest/rollup/avm_proof_data.js +12 -4
  72. package/dest/rollup/previous_rollup_block_data.d.ts +6 -15
  73. package/dest/rollup/previous_rollup_block_data.d.ts.map +1 -1
  74. package/dest/rollup/previous_rollup_block_data.js +8 -13
  75. package/dest/rollup/previous_rollup_data.d.ts +6 -15
  76. package/dest/rollup/previous_rollup_data.d.ts.map +1 -1
  77. package/dest/rollup/previous_rollup_data.js +8 -13
  78. package/dest/rollup/private_tube_data.d.ts +3 -3
  79. package/dest/rollup/private_tube_data.d.ts.map +1 -1
  80. package/dest/rollup/private_tube_data.js +3 -3
  81. package/dest/rollup/public_tube_data.d.ts +3 -3
  82. package/dest/rollup/public_tube_data.d.ts.map +1 -1
  83. package/dest/rollup/public_tube_data.js +3 -3
  84. package/dest/rollup/root_rollup.d.ts +9 -10
  85. package/dest/rollup/root_rollup.d.ts.map +1 -1
  86. package/dest/rollup/root_rollup.js +9 -20
  87. package/dest/tests/factories.d.ts +2 -1
  88. package/dest/tests/factories.d.ts.map +1 -1
  89. package/dest/tests/factories.js +21 -15
  90. package/dest/tests/mocks.d.ts.map +1 -1
  91. package/dest/tests/mocks.js +4 -3
  92. package/dest/tx/private_execution_result.d.ts +6 -0
  93. package/dest/tx/private_execution_result.d.ts.map +1 -1
  94. package/dest/tx/profiling.d.ts +41 -0
  95. package/dest/tx/profiling.d.ts.map +1 -1
  96. package/dest/tx/profiling.js +4 -1
  97. package/dest/tx/proven_tx.d.ts +40 -18
  98. package/dest/tx/proven_tx.d.ts.map +1 -1
  99. package/dest/tx/proven_tx.js +2 -2
  100. package/dest/tx/tx_effect.d.ts +1 -1
  101. package/dest/tx/tx_effect.d.ts.map +1 -1
  102. package/dest/tx/tx_effect.js +2 -2
  103. package/dest/validators/types.d.ts +4 -0
  104. package/dest/validators/types.d.ts.map +1 -1
  105. package/dest/vks/index.d.ts +1 -1
  106. package/dest/vks/index.d.ts.map +1 -1
  107. package/dest/vks/index.js +1 -1
  108. package/dest/vks/{vk_witness_data.d.ts → vk_data.d.ts} +8 -8
  109. package/dest/vks/vk_data.d.ts.map +1 -0
  110. package/dest/vks/{vk_witness_data.js → vk_data.js} +10 -10
  111. package/package.json +7 -7
  112. package/src/abi/abi.ts +37 -0
  113. package/src/avm/avm.ts +14 -0
  114. package/src/avm/avm_accumulated_data.ts +93 -0
  115. package/src/avm/avm_circuit_public_inputs.ts +22 -2
  116. package/src/block/body.ts +7 -2
  117. package/src/block/index.ts +1 -0
  118. package/src/block/l2_block.ts +2 -1
  119. package/src/block/l2_block_source.ts +9 -3
  120. package/src/block/proposal/committee_attestation.ts +70 -0
  121. package/src/block/proposal/index.ts +1 -0
  122. package/src/block/published_l2_block.ts +38 -24
  123. package/src/block/test/l2_tips_store_test_suite.ts +1 -1
  124. package/src/interfaces/archiver.ts +2 -2
  125. package/src/interfaces/aztec-node.ts +2 -2
  126. package/src/interfaces/prover-agent.ts +9 -10
  127. package/src/interfaces/proving-job.ts +3 -3
  128. package/src/interfaces/server_circuit_prover.ts +3 -2
  129. package/src/kernel/index.ts +1 -0
  130. package/src/kernel/padded_side_effects.ts +73 -0
  131. package/src/kernel/private_kernel_data.ts +7 -29
  132. package/src/kernel/private_kernel_prover_output.ts +1 -0
  133. package/src/kernel/private_kernel_reset_circuit_private_inputs.ts +6 -3
  134. package/src/kernel/private_kernel_tail_circuit_private_inputs.ts +10 -2
  135. package/src/kernel/public_call_request.ts +66 -0
  136. package/src/logs/pending_tagged_log.ts +1 -1
  137. package/src/rollup/avm_proof_data.ts +14 -7
  138. package/src/rollup/previous_rollup_block_data.ts +6 -12
  139. package/src/rollup/previous_rollup_data.ts +6 -12
  140. package/src/rollup/private_tube_data.ts +4 -4
  141. package/src/rollup/public_tube_data.ts +4 -4
  142. package/src/rollup/root_rollup.ts +6 -19
  143. package/src/tests/factories.ts +32 -20
  144. package/src/tests/mocks.ts +6 -3
  145. package/src/tx/private_execution_result.ts +1 -1
  146. package/src/tx/profiling.ts +6 -1
  147. package/src/tx/proven_tx.ts +2 -2
  148. package/src/tx/tx_effect.ts +23 -5
  149. package/src/validators/types.ts +2 -0
  150. package/src/vks/index.ts +1 -1
  151. package/src/vks/{vk_witness_data.ts → vk_data.ts} +6 -6
  152. package/dest/vks/vk_witness_data.d.ts.map +0 -1
@@ -4,28 +4,28 @@ import { Fr } from '@aztec/foundation/fields';
4
4
  import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
5
5
  import { bufferToHex } from '@aztec/foundation/string';
6
6
  import { VerificationKeyData } from './verification_key.js';
7
- export class VkWitnessData {
7
+ export class VkData {
8
8
  vk;
9
- vkIndex;
10
- vkPath;
9
+ leafIndex;
10
+ siblingPath;
11
11
  constructor(vk, /**
12
12
  * Index of the vk in the vk tree.
13
- */ vkIndex, /**
13
+ */ leafIndex, /**
14
14
  * Sibling path of the vk in the vk tree.
15
- */ vkPath){
15
+ */ siblingPath){
16
16
  this.vk = vk;
17
- this.vkIndex = vkIndex;
18
- this.vkPath = vkPath;
17
+ this.leafIndex = leafIndex;
18
+ this.siblingPath = siblingPath;
19
19
  }
20
20
  static empty() {
21
- return new VkWitnessData(VerificationKeyData.empty(), 0, makeTuple(VK_TREE_HEIGHT, Fr.zero));
21
+ return new VkData(VerificationKeyData.empty(), 0, makeTuple(VK_TREE_HEIGHT, Fr.zero));
22
22
  }
23
23
  static fromBuffer(buffer) {
24
24
  const reader = BufferReader.asReader(buffer);
25
- return new VkWitnessData(reader.readObject(VerificationKeyData), reader.readNumber(), reader.readArray(VK_TREE_HEIGHT, Fr));
25
+ return new VkData(reader.readObject(VerificationKeyData), reader.readNumber(), reader.readArray(VK_TREE_HEIGHT, Fr));
26
26
  }
27
27
  toBuffer() {
28
- return serializeToBuffer(this.vk, this.vkIndex, this.vkPath);
28
+ return serializeToBuffer(this.vk, this.leafIndex, this.siblingPath);
29
29
  }
30
30
  toString() {
31
31
  return bufferToHex(this.toBuffer());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/stdlib",
3
- "version": "0.87.2",
3
+ "version": "0.87.3-nightly.20250528",
4
4
  "type": "module",
5
5
  "inherits": [
6
6
  "../package.common.json",
@@ -67,12 +67,12 @@
67
67
  "test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=${JEST_MAX_WORKERS:-8}"
68
68
  },
69
69
  "dependencies": {
70
- "@aztec/bb.js": "0.87.2",
71
- "@aztec/blob-lib": "0.87.2",
72
- "@aztec/constants": "0.87.2",
73
- "@aztec/ethereum": "0.87.2",
74
- "@aztec/foundation": "0.87.2",
75
- "@aztec/noir-noirc_abi": "0.87.2",
70
+ "@aztec/bb.js": "0.87.3-nightly.20250528",
71
+ "@aztec/blob-lib": "0.87.3-nightly.20250528",
72
+ "@aztec/constants": "0.87.3-nightly.20250528",
73
+ "@aztec/ethereum": "0.87.3-nightly.20250528",
74
+ "@aztec/foundation": "0.87.3-nightly.20250528",
75
+ "@aztec/noir-noirc_abi": "0.87.3-nightly.20250528",
76
76
  "@google-cloud/storage": "^7.15.0",
77
77
  "axios": "^1.9.0",
78
78
  "json-stringify-deterministic": "1.0.12",
package/src/abi/abi.ts CHANGED
@@ -533,3 +533,40 @@ export function getInitializer(
533
533
  return initializerNameOrArtifact;
534
534
  }
535
535
  }
536
+
537
+ export function emptyFunctionAbi(): FunctionAbi {
538
+ return {
539
+ name: '',
540
+ functionType: FunctionType.PRIVATE,
541
+ isInternal: false,
542
+ isStatic: false,
543
+ parameters: [],
544
+ returnTypes: [],
545
+ errorTypes: {},
546
+ isInitializer: false,
547
+ };
548
+ }
549
+
550
+ export function emptyFunctionArtifact(): FunctionArtifact {
551
+ const abi = emptyFunctionAbi();
552
+ return {
553
+ ...abi,
554
+ bytecode: Buffer.from([]),
555
+ debugSymbols: '',
556
+ };
557
+ }
558
+
559
+ export function emptyContractArtifact(): ContractArtifact {
560
+ return {
561
+ name: '',
562
+ functions: [emptyFunctionArtifact()],
563
+ nonDispatchPublicFunctions: [emptyFunctionAbi()],
564
+ outputs: {
565
+ structs: {},
566
+ globals: {},
567
+ },
568
+ storageLayout: {},
569
+ fileMap: {},
570
+ notes: {},
571
+ };
572
+ }
package/src/avm/avm.ts CHANGED
@@ -5,6 +5,8 @@ import { schemas } from '@aztec/foundation/schemas';
5
5
  import { z } from 'zod';
6
6
 
7
7
  import { AztecAddress } from '../aztec-address/index.js';
8
+ import { Gas } from '../gas/gas.js';
9
+ import { GasSettings } from '../gas/gas_settings.js';
8
10
  import { PublicKeys } from '../keys/public_keys.js';
9
11
  import { AppendOnlyTreeSnapshot } from '../trees/append_only_tree_snapshot.js';
10
12
  import { MerkleTreeId } from '../trees/merkle_tree_id.js';
@@ -406,6 +408,7 @@ export class AvmTxHint {
406
408
  constructor(
407
409
  public readonly hash: string,
408
410
  public readonly globalVariables: GlobalVariables,
411
+ public readonly gasSettings: GasSettings,
409
412
  public readonly nonRevertibleAccumulatedData: {
410
413
  noteHashes: Fr[];
411
414
  nullifiers: Fr[];
@@ -421,6 +424,7 @@ export class AvmTxHint {
421
424
  // We need this to be null and not undefined because that's what
422
425
  // MessagePack expects for an std::optional.
423
426
  public readonly teardownEnqueuedCall: AvmEnqueuedCallHint | null,
427
+ public readonly gasUsedByPrivate: Gas,
424
428
  ) {}
425
429
 
426
430
  static async fromTx(tx: Tx): Promise<AvmTxHint> {
@@ -434,6 +438,7 @@ export class AvmTxHint {
434
438
  return new AvmTxHint(
435
439
  txHash.hash.toString(),
436
440
  tx.data.constants.historicalHeader.globalVariables,
441
+ tx.data.constants.txContext.gasSettings,
437
442
  {
438
443
  noteHashes: tx.data.forPublic!.nonRevertibleAccumulatedData.noteHashes.filter(x => !x.isZero()),
439
444
  nullifiers: tx.data.forPublic!.nonRevertibleAccumulatedData.nullifiers.filter(x => !x.isZero()),
@@ -468,6 +473,7 @@ export class AvmTxHint {
468
473
  teardownCallRequest.request.isStaticCall,
469
474
  )
470
475
  : null,
476
+ tx.data.gasUsed,
471
477
  );
472
478
  }
473
479
 
@@ -475,11 +481,13 @@ export class AvmTxHint {
475
481
  return new AvmTxHint(
476
482
  '',
477
483
  GlobalVariables.empty(),
484
+ GasSettings.empty(),
478
485
  { noteHashes: [], nullifiers: [] },
479
486
  { noteHashes: [], nullifiers: [] },
480
487
  [],
481
488
  [],
482
489
  null,
490
+ Gas.empty(),
483
491
  );
484
492
  }
485
493
 
@@ -488,6 +496,7 @@ export class AvmTxHint {
488
496
  .object({
489
497
  hash: z.string(),
490
498
  globalVariables: GlobalVariables.schema,
499
+ gasSettings: GasSettings.schema,
491
500
  nonRevertibleAccumulatedData: z.object({
492
501
  noteHashes: schemas.Fr.array(),
493
502
  nullifiers: schemas.Fr.array(),
@@ -499,25 +508,30 @@ export class AvmTxHint {
499
508
  setupEnqueuedCalls: AvmEnqueuedCallHint.schema.array(),
500
509
  appLogicEnqueuedCalls: AvmEnqueuedCallHint.schema.array(),
501
510
  teardownEnqueuedCall: AvmEnqueuedCallHint.schema.nullable(),
511
+ gasUsedByPrivate: Gas.schema,
502
512
  })
503
513
  .transform(
504
514
  ({
505
515
  hash,
506
516
  globalVariables,
517
+ gasSettings,
507
518
  nonRevertibleAccumulatedData,
508
519
  revertibleAccumulatedData,
509
520
  setupEnqueuedCalls,
510
521
  appLogicEnqueuedCalls,
511
522
  teardownEnqueuedCall,
523
+ gasUsedByPrivate,
512
524
  }) =>
513
525
  new AvmTxHint(
514
526
  hash,
515
527
  globalVariables,
528
+ gasSettings,
516
529
  nonRevertibleAccumulatedData,
517
530
  revertibleAccumulatedData,
518
531
  setupEnqueuedCalls,
519
532
  appLogicEnqueuedCalls,
520
533
  teardownEnqueuedCall,
534
+ gasUsedByPrivate,
521
535
  ),
522
536
  );
523
537
  }
@@ -185,3 +185,96 @@ export class AvmAccumulatedData {
185
185
  }`;
186
186
  }
187
187
  }
188
+
189
+ /**
190
+ * Represents the lengths of arrays in AVM accumulated data
191
+ */
192
+ export class AvmAccumulatedDataArrayLengths {
193
+ constructor(
194
+ /**
195
+ * Number of note hashes
196
+ */
197
+ public noteHashes: number,
198
+ /**
199
+ * Number of nullifiers
200
+ */
201
+ public nullifiers: number,
202
+ /**
203
+ * Number of L2 to L1 messages
204
+ */
205
+ public l2ToL1Msgs: number,
206
+ /**
207
+ * Number of public logs
208
+ */
209
+ public publicLogs: number,
210
+ /**
211
+ * Number of public data writes
212
+ */
213
+ public publicDataWrites: number,
214
+ ) {}
215
+
216
+ static get schema() {
217
+ return z
218
+ .object({
219
+ noteHashes: z.number(),
220
+ nullifiers: z.number(),
221
+ l2ToL1Msgs: z.number(),
222
+ publicLogs: z.number(),
223
+ publicDataWrites: z.number(),
224
+ })
225
+ .transform(
226
+ ({ noteHashes, nullifiers, l2ToL1Msgs, publicLogs, publicDataWrites }) =>
227
+ new AvmAccumulatedDataArrayLengths(noteHashes, nullifiers, l2ToL1Msgs, publicLogs, publicDataWrites),
228
+ );
229
+ }
230
+
231
+ static fromBuffer(buffer: Buffer | BufferReader) {
232
+ const reader = BufferReader.asReader(buffer);
233
+ return new AvmAccumulatedDataArrayLengths(
234
+ reader.readNumber(),
235
+ reader.readNumber(),
236
+ reader.readNumber(),
237
+ reader.readNumber(),
238
+ reader.readNumber(),
239
+ );
240
+ }
241
+
242
+ toBuffer() {
243
+ return serializeToBuffer(this.noteHashes, this.nullifiers, this.l2ToL1Msgs, this.publicLogs, this.publicDataWrites);
244
+ }
245
+
246
+ static fromFields(fields: Fr[] | FieldReader) {
247
+ const reader = FieldReader.asReader(fields);
248
+ return new AvmAccumulatedDataArrayLengths(
249
+ Number(reader.readField()),
250
+ Number(reader.readField()),
251
+ Number(reader.readField()),
252
+ Number(reader.readField()),
253
+ Number(reader.readField()),
254
+ );
255
+ }
256
+
257
+ toFields(): Fr[] {
258
+ return [
259
+ new Fr(this.noteHashes),
260
+ new Fr(this.nullifiers),
261
+ new Fr(this.l2ToL1Msgs),
262
+ new Fr(this.publicLogs),
263
+ new Fr(this.publicDataWrites),
264
+ ];
265
+ }
266
+
267
+ static empty() {
268
+ return new AvmAccumulatedDataArrayLengths(0, 0, 0, 0, 0);
269
+ }
270
+
271
+ [inspect.custom]() {
272
+ return `AvmAccumulatedDataArrayLengths {
273
+ noteHashes: ${this.noteHashes},
274
+ nullifiers: ${this.nullifiers},
275
+ l2ToL1Msgs: ${this.l2ToL1Msgs},
276
+ publicLogs: ${this.publicLogs},
277
+ publicDataWrites: ${this.publicDataWrites},
278
+ }`;
279
+ }
280
+ }
@@ -14,10 +14,10 @@ import {
14
14
  PrivateToAvmAccumulatedData,
15
15
  PrivateToAvmAccumulatedDataArrayLengths,
16
16
  } from '../kernel/private_to_avm_accumulated_data.js';
17
- import { PublicCallRequest } from '../kernel/public_call_request.js';
17
+ import { PublicCallRequest, PublicCallRequestArrayLengths } from '../kernel/public_call_request.js';
18
18
  import { GlobalVariables } from '../tx/global_variables.js';
19
19
  import { TreeSnapshots } from '../tx/tree_snapshots.js';
20
- import { AvmAccumulatedData } from './avm_accumulated_data.js';
20
+ import { AvmAccumulatedData, AvmAccumulatedDataArrayLengths } from './avm_accumulated_data.js';
21
21
  import { serializeWithMessagePack } from './message_pack.js';
22
22
 
23
23
  // Note: the {from,to}{Buffer,Fields,String} methods are needed by AvmProofData and PublicBaseRollupInputs.
@@ -31,6 +31,7 @@ export class AvmCircuitPublicInputs {
31
31
  public startGasUsed: Gas,
32
32
  public gasSettings: GasSettings,
33
33
  public feePayer: AztecAddress,
34
+ public publicCallRequestArrayLengths: PublicCallRequestArrayLengths,
34
35
  public publicSetupCallRequests: Tuple<PublicCallRequest, typeof MAX_ENQUEUED_CALLS_PER_TX>,
35
36
  public publicAppLogicCallRequests: Tuple<PublicCallRequest, typeof MAX_ENQUEUED_CALLS_PER_TX>,
36
37
  public publicTeardownCallRequest: PublicCallRequest,
@@ -42,6 +43,7 @@ export class AvmCircuitPublicInputs {
42
43
  // Outputs.
43
44
  public endTreeSnapshots: TreeSnapshots,
44
45
  public endGasUsed: Gas,
46
+ public accumulatedDataArrayLengths: AvmAccumulatedDataArrayLengths,
45
47
  public accumulatedData: AvmAccumulatedData,
46
48
  public transactionFee: Fr,
47
49
  public reverted: boolean,
@@ -55,6 +57,7 @@ export class AvmCircuitPublicInputs {
55
57
  startGasUsed: Gas.schema,
56
58
  gasSettings: GasSettings.schema,
57
59
  feePayer: AztecAddress.schema,
60
+ publicCallRequestArrayLengths: PublicCallRequestArrayLengths.schema,
58
61
  publicSetupCallRequests: PublicCallRequest.schema.array().max(MAX_ENQUEUED_CALLS_PER_TX),
59
62
  publicAppLogicCallRequests: PublicCallRequest.schema.array().max(MAX_ENQUEUED_CALLS_PER_TX),
60
63
  publicTeardownCallRequest: PublicCallRequest.schema,
@@ -64,6 +67,7 @@ export class AvmCircuitPublicInputs {
64
67
  previousRevertibleAccumulatedData: PrivateToAvmAccumulatedData.schema,
65
68
  endTreeSnapshots: TreeSnapshots.schema,
66
69
  endGasUsed: Gas.schema,
70
+ accumulatedDataArrayLengths: AvmAccumulatedDataArrayLengths.schema,
67
71
  accumulatedData: AvmAccumulatedData.schema,
68
72
  transactionFee: schemas.Fr,
69
73
  reverted: z.boolean(),
@@ -75,6 +79,7 @@ export class AvmCircuitPublicInputs {
75
79
  startGasUsed,
76
80
  gasSettings,
77
81
  feePayer,
82
+ publicCallRequestArrayLengths,
78
83
  publicSetupCallRequests,
79
84
  publicAppLogicCallRequests,
80
85
  publicTeardownCallRequest,
@@ -84,6 +89,7 @@ export class AvmCircuitPublicInputs {
84
89
  previousRevertibleAccumulatedData,
85
90
  endTreeSnapshots,
86
91
  endGasUsed,
92
+ accumulatedDataArrayLengths,
87
93
  accumulatedData,
88
94
  transactionFee,
89
95
  reverted,
@@ -94,6 +100,7 @@ export class AvmCircuitPublicInputs {
94
100
  startGasUsed,
95
101
  gasSettings,
96
102
  feePayer,
103
+ publicCallRequestArrayLengths,
97
104
  assertLength(publicSetupCallRequests, MAX_ENQUEUED_CALLS_PER_TX),
98
105
  assertLength(publicAppLogicCallRequests, MAX_ENQUEUED_CALLS_PER_TX),
99
106
  publicTeardownCallRequest,
@@ -103,6 +110,7 @@ export class AvmCircuitPublicInputs {
103
110
  previousRevertibleAccumulatedData,
104
111
  endTreeSnapshots,
105
112
  endGasUsed,
113
+ accumulatedDataArrayLengths,
106
114
  accumulatedData,
107
115
  transactionFee,
108
116
  reverted,
@@ -118,6 +126,7 @@ export class AvmCircuitPublicInputs {
118
126
  reader.readObject(Gas),
119
127
  reader.readObject(GasSettings),
120
128
  reader.readObject(AztecAddress),
129
+ reader.readObject(PublicCallRequestArrayLengths),
121
130
  reader.readArray(MAX_ENQUEUED_CALLS_PER_TX, PublicCallRequest),
122
131
  reader.readArray(MAX_ENQUEUED_CALLS_PER_TX, PublicCallRequest),
123
132
  reader.readObject(PublicCallRequest),
@@ -127,6 +136,7 @@ export class AvmCircuitPublicInputs {
127
136
  reader.readObject(PrivateToAvmAccumulatedData),
128
137
  reader.readObject(TreeSnapshots),
129
138
  reader.readObject(Gas),
139
+ reader.readObject(AvmAccumulatedDataArrayLengths),
130
140
  reader.readObject(AvmAccumulatedData),
131
141
  reader.readObject(Fr),
132
142
  reader.readBoolean(),
@@ -140,6 +150,7 @@ export class AvmCircuitPublicInputs {
140
150
  this.startGasUsed,
141
151
  this.gasSettings,
142
152
  this.feePayer,
153
+ this.publicCallRequestArrayLengths,
143
154
  this.publicSetupCallRequests,
144
155
  this.publicAppLogicCallRequests,
145
156
  this.publicTeardownCallRequest,
@@ -149,6 +160,7 @@ export class AvmCircuitPublicInputs {
149
160
  this.previousRevertibleAccumulatedData,
150
161
  this.endTreeSnapshots,
151
162
  this.endGasUsed,
163
+ this.accumulatedDataArrayLengths,
152
164
  this.accumulatedData,
153
165
  this.transactionFee,
154
166
  this.reverted,
@@ -171,6 +183,7 @@ export class AvmCircuitPublicInputs {
171
183
  Gas.fromFields(reader),
172
184
  GasSettings.fromFields(reader),
173
185
  AztecAddress.fromFields(reader),
186
+ PublicCallRequestArrayLengths.fromFields(reader),
174
187
  reader.readArray(MAX_ENQUEUED_CALLS_PER_TX, PublicCallRequest),
175
188
  reader.readArray(MAX_ENQUEUED_CALLS_PER_TX, PublicCallRequest),
176
189
  PublicCallRequest.fromFields(reader),
@@ -180,6 +193,7 @@ export class AvmCircuitPublicInputs {
180
193
  PrivateToAvmAccumulatedData.fromFields(reader),
181
194
  TreeSnapshots.fromFields(reader),
182
195
  Gas.fromFields(reader),
196
+ AvmAccumulatedDataArrayLengths.fromFields(reader),
183
197
  AvmAccumulatedData.fromFields(reader),
184
198
  reader.readField(),
185
199
  reader.readBoolean(),
@@ -193,6 +207,7 @@ export class AvmCircuitPublicInputs {
193
207
  ...this.startGasUsed.toFields(),
194
208
  ...this.gasSettings.toFields(),
195
209
  this.feePayer,
210
+ ...this.publicCallRequestArrayLengths.toFields(),
196
211
  ...this.publicSetupCallRequests.map(request => request.toFields()),
197
212
  ...this.publicAppLogicCallRequests.map(request => request.toFields()),
198
213
  ...this.publicTeardownCallRequest.toFields(),
@@ -202,6 +217,7 @@ export class AvmCircuitPublicInputs {
202
217
  ...this.previousRevertibleAccumulatedData.toFields(),
203
218
  ...this.endTreeSnapshots.toFields(),
204
219
  ...this.endGasUsed.toFields(),
220
+ ...this.accumulatedDataArrayLengths.toFields(),
205
221
  ...this.accumulatedData.toFields(),
206
222
  this.transactionFee,
207
223
  this.reverted,
@@ -215,6 +231,7 @@ export class AvmCircuitPublicInputs {
215
231
  Gas.empty(),
216
232
  GasSettings.empty(),
217
233
  AztecAddress.zero(),
234
+ PublicCallRequestArrayLengths.empty(),
218
235
  makeTuple(MAX_ENQUEUED_CALLS_PER_TX, PublicCallRequest.empty),
219
236
  makeTuple(MAX_ENQUEUED_CALLS_PER_TX, PublicCallRequest.empty),
220
237
  PublicCallRequest.empty(),
@@ -224,6 +241,7 @@ export class AvmCircuitPublicInputs {
224
241
  PrivateToAvmAccumulatedData.empty(),
225
242
  TreeSnapshots.empty(),
226
243
  Gas.empty(),
244
+ AvmAccumulatedDataArrayLengths.empty(),
227
245
  AvmAccumulatedData.empty(),
228
246
  Fr.zero(),
229
247
  false,
@@ -241,6 +259,7 @@ export class AvmCircuitPublicInputs {
241
259
  startGasUsed: ${inspect(this.startGasUsed)},
242
260
  gasSettings: ${inspect(this.gasSettings)},
243
261
  feePayer: ${inspect(this.feePayer)},
262
+ publicCallRequestArrayLengths: ${inspect(this.publicCallRequestArrayLengths)},
244
263
  publicSetupCallRequests: [${this.publicSetupCallRequests
245
264
  .filter(x => !x.isEmpty())
246
265
  .map(h => inspect(h))
@@ -258,6 +277,7 @@ export class AvmCircuitPublicInputs {
258
277
  previousRevertibleAccumulatedData: ${inspect(this.previousRevertibleAccumulatedData)},
259
278
  endTreeSnapshots: ${inspect(this.endTreeSnapshots)},
260
279
  endGasUsed: ${inspect(this.endGasUsed)},
280
+ accumulatedDataArrayLengths: ${inspect(this.accumulatedDataArrayLengths)},
261
281
  accumulatedData: ${inspect(this.accumulatedData)},
262
282
  transactionFee: ${inspect(this.transactionFee)},
263
283
  reverted: ${this.reverted},
package/src/block/body.ts CHANGED
@@ -87,9 +87,14 @@ export class Body {
87
87
  }`;
88
88
  }
89
89
 
90
- static async random(txsPerBlock = 4, numPublicCallsPerTx = 3, numPublicLogsPerCall = 1) {
90
+ static async random(
91
+ txsPerBlock = 4,
92
+ numPublicCallsPerTx = 3,
93
+ numPublicLogsPerCall = 1,
94
+ maxEffects: number | undefined = undefined,
95
+ ) {
91
96
  const txEffects = await timesParallel(txsPerBlock, () =>
92
- TxEffect.random(numPublicCallsPerTx, numPublicLogsPerCall),
97
+ TxEffect.random(numPublicCallsPerTx, numPublicLogsPerCall, maxEffects),
93
98
  );
94
99
 
95
100
  return new Body(txEffects);
@@ -6,3 +6,4 @@ export * from './l2_block_number.js';
6
6
  export * from './l2_block_source.js';
7
7
  export * from './block_hash.js';
8
8
  export * from './published_l2_block.js';
9
+ export * from './proposal/index.js';
@@ -86,8 +86,9 @@ export class L2Block {
86
86
  numPublicLogsPerCall = 1,
87
87
  inHash: Buffer | undefined = undefined,
88
88
  slotNumber: number | undefined = undefined,
89
+ maxEffects: number | undefined = undefined,
89
90
  ): Promise<L2Block> {
90
- const body = await Body.random(txsPerBlock, numPublicCallsPerTx, numPublicLogsPerCall);
91
+ const body = await Body.random(txsPerBlock, numPublicCallsPerTx, numPublicLogsPerCall, maxEffects);
91
92
 
92
93
  return new L2Block(
93
94
  makeAppendOnlyTreeSnapshot(l2BlockNum + 1),
@@ -1,6 +1,6 @@
1
1
  import type { EthAddress } from '@aztec/foundation/eth-address';
2
+ import type { TypedEventEmitter } from '@aztec/foundation/types';
2
3
 
3
- import type { EventEmitter } from 'events';
4
4
  import { z } from 'zod';
5
5
 
6
6
  import type { L1RollupConstants } from '../epoch-helpers/index.js';
@@ -127,7 +127,12 @@ export interface L2BlockSource {
127
127
  * L2BlockSource that emits events upon pending / proven chain changes.
128
128
  * see L2BlockSourceEvents for the events emitted.
129
129
  */
130
- export interface L2BlockSourceEventEmitter extends L2BlockSource, EventEmitter {}
130
+
131
+ export type ArchiverEmitter = TypedEventEmitter<{
132
+ [L2BlockSourceEvents.L2PruneDetected]: (args: L2BlockSourceEvent) => void;
133
+ [L2BlockSourceEvents.L2BlockProven]: (args: L2BlockSourceEvent) => void;
134
+ }>;
135
+ export interface L2BlockSourceEventEmitter extends L2BlockSource, ArchiverEmitter {}
131
136
 
132
137
  /**
133
138
  * Identifier for L2 block tags.
@@ -171,10 +176,11 @@ export const L2TipsSchema = z.object({
171
176
 
172
177
  export enum L2BlockSourceEvents {
173
178
  L2PruneDetected = 'l2PruneDetected',
179
+ L2BlockProven = 'l2BlockProven',
174
180
  }
175
181
 
176
182
  export type L2BlockSourceEvent = {
177
- type: 'l2PruneDetected';
183
+ type: 'l2PruneDetected' | 'l2BlockProven';
178
184
  blockNumber: bigint;
179
185
  slotNumber: bigint;
180
186
  epochNumber: bigint;
@@ -0,0 +1,70 @@
1
+ import type { ViemCommitteeAttestation } from '@aztec/ethereum';
2
+ import { EthAddress } from '@aztec/foundation/eth-address';
3
+ import { Signature } from '@aztec/foundation/eth-signature';
4
+ import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
5
+
6
+ import { z } from 'zod';
7
+
8
+ export { Signature };
9
+ export { EthAddress };
10
+
11
+ export class CommitteeAttestation {
12
+ constructor(
13
+ public readonly address: EthAddress,
14
+ public readonly signature: Signature,
15
+ ) {}
16
+
17
+ static get schema() {
18
+ return z
19
+ .object({
20
+ address: EthAddress.schema,
21
+ signature: Signature.schema,
22
+ })
23
+ .transform(({ address, signature }) => new CommitteeAttestation(address, signature));
24
+ }
25
+
26
+ // Create an empty attestation for an address that has not signed
27
+ static fromAddress(address: EthAddress): CommitteeAttestation {
28
+ return new CommitteeAttestation(address, Signature.empty());
29
+ }
30
+
31
+ // Create an attestation from an address and a signature
32
+ static fromAddressAndSignature(address: EthAddress, signature: Signature): CommitteeAttestation {
33
+ return new CommitteeAttestation(address, signature);
34
+ }
35
+
36
+ static fromViem(viem: ViemCommitteeAttestation): CommitteeAttestation {
37
+ return new CommitteeAttestation(EthAddress.fromString(viem.addr), Signature.fromViemSignature(viem.signature));
38
+ }
39
+
40
+ static fromBuffer(buffer: Buffer): CommitteeAttestation {
41
+ const reader = BufferReader.asReader(buffer);
42
+ const address = reader.readObject(EthAddress);
43
+ const signature = reader.readObject(Signature);
44
+ return new CommitteeAttestation(address, signature);
45
+ }
46
+
47
+ static random(): CommitteeAttestation {
48
+ // note: will be invalid
49
+ return new CommitteeAttestation(EthAddress.random(), Signature.random());
50
+ }
51
+
52
+ static empty(): CommitteeAttestation {
53
+ return new CommitteeAttestation(EthAddress.ZERO, Signature.empty());
54
+ }
55
+
56
+ toBuffer(): Buffer {
57
+ return serializeToBuffer([this.address, this.signature]);
58
+ }
59
+
60
+ equals(other: CommitteeAttestation): boolean {
61
+ return this.address.equals(other.address) && this.signature.equals(other.signature);
62
+ }
63
+
64
+ toViem(): ViemCommitteeAttestation {
65
+ return {
66
+ addr: this.address.toString(),
67
+ signature: this.signature.toViemSignature(),
68
+ };
69
+ }
70
+ }
@@ -0,0 +1 @@
1
+ export * from './committee_attestation.js';
@@ -1,37 +1,51 @@
1
- import { Signature } from '@aztec/foundation/eth-signature';
1
+ // Ignoring import issue to fix portable inferred type issue in zod schema
2
2
  import { schemas } from '@aztec/foundation/schemas';
3
- import { L2Block } from '@aztec/stdlib/block';
4
3
 
5
4
  import { z } from 'zod';
6
5
 
7
6
  import { BlockAttestation } from '../p2p/block_attestation.js';
8
7
  import { ConsensusPayload } from '../p2p/consensus_payload.js';
8
+ import { L2Block } from './l2_block.js';
9
+ import { CommitteeAttestation } from './proposal/committee_attestation.js';
9
10
 
10
- export type L1PublishedData = {
11
- blockNumber: bigint;
12
- timestamp: bigint;
13
- blockHash: string;
14
- };
11
+ export class L1PublishedData {
12
+ constructor(
13
+ public blockNumber: bigint,
14
+ public timestamp: bigint,
15
+ public blockHash: string,
16
+ ) {}
15
17
 
16
- export type PublishedL2Block = {
17
- block: L2Block;
18
- l1: L1PublishedData;
19
- signatures: Signature[];
20
- };
18
+ static get schema() {
19
+ return z.object({
20
+ blockNumber: schemas.BigInt,
21
+ timestamp: schemas.BigInt,
22
+ blockHash: z.string(),
23
+ });
24
+ }
25
+ }
26
+
27
+ export class PublishedL2Block {
28
+ constructor(
29
+ public block: L2Block,
30
+ public l1: L1PublishedData,
31
+ public attestations: CommitteeAttestation[],
32
+ ) {}
21
33
 
22
- export const PublishedL2BlockSchema = z.object({
23
- block: L2Block.schema,
24
- l1: z.object({
25
- blockNumber: schemas.BigInt,
26
- timestamp: schemas.BigInt,
27
- blockHash: z.string(),
28
- }),
29
- signatures: z.array(Signature.schema),
30
- });
34
+ static get schema() {
35
+ return z.object({
36
+ block: L2Block.schema,
37
+ l1: L1PublishedData.schema,
38
+ attestations: z.array(CommitteeAttestation.schema),
39
+ });
40
+ }
41
+ }
31
42
 
32
43
  export function getAttestationsFromPublishedL2Block(block: PublishedL2Block) {
33
44
  const payload = ConsensusPayload.fromBlock(block.block);
34
- return block.signatures
35
- .filter(sig => !sig.isEmpty)
36
- .map(signature => new BlockAttestation(block.block.header.globalVariables.blockNumber, payload, signature));
45
+ return block.attestations
46
+ .filter(attestation => !attestation.signature.isEmpty())
47
+ .map(
48
+ attestation =>
49
+ new BlockAttestation(block.block.header.globalVariables.blockNumber, payload, attestation.signature),
50
+ );
37
51
  }