@aztec/stdlib 5.0.0-nightly.20260324 → 5.0.0-nightly.20260328

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 (72) hide show
  1. package/dest/abi/decoder.d.ts +5 -44
  2. package/dest/abi/decoder.d.ts.map +1 -1
  3. package/dest/abi/decoder.js +12 -67
  4. package/dest/abi/function_selector.js +1 -1
  5. package/dest/abi/function_signature_decoder.d.ts +43 -0
  6. package/dest/abi/function_signature_decoder.d.ts.map +1 -0
  7. package/dest/abi/function_signature_decoder.js +66 -0
  8. package/dest/abi/index.d.ts +2 -1
  9. package/dest/abi/index.d.ts.map +1 -1
  10. package/dest/abi/index.js +1 -0
  11. package/dest/epoch-helpers/index.d.ts +3 -1
  12. package/dest/epoch-helpers/index.d.ts.map +1 -1
  13. package/dest/epoch-helpers/index.js +3 -0
  14. package/dest/file-store/factory.d.ts +4 -3
  15. package/dest/file-store/factory.d.ts.map +1 -1
  16. package/dest/file-store/factory.js +2 -2
  17. package/dest/file-store/http.d.ts +9 -2
  18. package/dest/file-store/http.d.ts.map +1 -1
  19. package/dest/file-store/http.js +20 -9
  20. package/dest/file-store/index.d.ts +2 -1
  21. package/dest/file-store/index.d.ts.map +1 -1
  22. package/dest/hash/hash.d.ts +4 -1
  23. package/dest/hash/hash.d.ts.map +1 -1
  24. package/dest/hash/hash.js +5 -0
  25. package/dest/interfaces/aztec-node-admin.d.ts +1 -4
  26. package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
  27. package/dest/interfaces/validator.d.ts +2 -10
  28. package/dest/interfaces/validator.d.ts.map +1 -1
  29. package/dest/interfaces/validator.js +0 -1
  30. package/dest/logs/message_context.d.ts +4 -7
  31. package/dest/logs/message_context.d.ts.map +1 -1
  32. package/dest/logs/message_context.js +23 -9
  33. package/dest/logs/pending_tagged_log.d.ts +2 -3
  34. package/dest/logs/pending_tagged_log.d.ts.map +1 -1
  35. package/dest/logs/pending_tagged_log.js +2 -2
  36. package/dest/logs/shared_secret_derivation.d.ts +11 -10
  37. package/dest/logs/shared_secret_derivation.d.ts.map +1 -1
  38. package/dest/logs/shared_secret_derivation.js +15 -9
  39. package/dest/logs/siloed_tag.d.ts +4 -1
  40. package/dest/logs/siloed_tag.d.ts.map +1 -1
  41. package/dest/logs/siloed_tag.js +7 -3
  42. package/dest/messaging/l1_to_l2_message.d.ts +3 -2
  43. package/dest/messaging/l1_to_l2_message.d.ts.map +1 -1
  44. package/dest/messaging/l1_to_l2_message.js +11 -13
  45. package/dest/note/note_dao.d.ts +1 -1
  46. package/dest/note/note_dao.d.ts.map +1 -1
  47. package/dest/note/note_dao.js +1 -4
  48. package/dest/proofs/chonk_proof.d.ts +46 -2
  49. package/dest/proofs/chonk_proof.d.ts.map +1 -1
  50. package/dest/proofs/chonk_proof.js +85 -10
  51. package/dest/tx/capsule.d.ts +6 -2
  52. package/dest/tx/capsule.d.ts.map +1 -1
  53. package/dest/tx/capsule.js +9 -3
  54. package/package.json +8 -8
  55. package/src/abi/decoder.ts +23 -78
  56. package/src/abi/function_selector.ts +1 -1
  57. package/src/abi/function_signature_decoder.ts +77 -0
  58. package/src/abi/index.ts +1 -0
  59. package/src/epoch-helpers/index.ts +8 -0
  60. package/src/file-store/factory.ts +13 -4
  61. package/src/file-store/http.ts +29 -10
  62. package/src/file-store/index.ts +1 -0
  63. package/src/hash/hash.ts +5 -0
  64. package/src/interfaces/validator.ts +1 -5
  65. package/src/logs/message_context.ts +17 -7
  66. package/src/logs/pending_tagged_log.ts +1 -3
  67. package/src/logs/shared_secret_derivation.ts +21 -10
  68. package/src/logs/siloed_tag.ts +7 -2
  69. package/src/messaging/l1_to_l2_message.ts +12 -9
  70. package/src/note/note_dao.ts +1 -4
  71. package/src/proofs/chonk_proof.ts +91 -5
  72. package/src/tx/capsule.ts +10 -2
@@ -1,20 +1,35 @@
1
+ import { BarretenbergSync, flattenChonkProofFields } from '@aztec/bb.js';
1
2
  import { CHONK_PROOF_LENGTH } from '@aztec/constants';
2
3
  import { times } from '@aztec/foundation/collection';
3
4
  import { randomBytes } from '@aztec/foundation/crypto/random';
4
5
  import { Fr } from '@aztec/foundation/curves/bn254';
5
6
  import { bufferSchemaFor } from '@aztec/foundation/schemas';
6
- import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
7
- // CHONK: "Client Honk" - An UltraHonk variant with incremental folding and delayed non-native arithmetic.
7
+ import { BufferReader, numToUInt32BE, serializeToBuffer } from '@aztec/foundation/serialize';
8
+ /**
9
+ * Serialization format detection for ChonkProof is size-based:
10
+ * - UNCOMPRESSED (legacy): [field_count=1632: uint32] [fields...] → total ≈ 52KB (>= 40KB)
11
+ * - COMPRESSED: [byte_count: uint32] [compressed_bytes] → total ≈ 35KB (< 40KB)
12
+ *
13
+ * Detection: if the first uint32 equals CHONK_PROOF_LENGTH (1632), it's legacy format
14
+ * (field count). Otherwise, it's compressed format (byte count). The old uncompressed
15
+ * format is never smaller than 40KB; compressed proofs are always smaller than 40KB.
16
+ */ // CHONK: "Client Honk" - An UltraHonk variant with incremental folding and delayed non-native arithmetic.
8
17
  export class ChonkProof {
9
18
  fields;
19
+ /**
20
+ * Optional compressed proof bytes from chonk compression (point compression + u256 encoding).
21
+ * When set, toBuffer() will serialize in compressed format (~1.7x smaller).
22
+ * When reading from compressed format, this is populated and fields are decompressed on demand.
23
+ */ compressedProof;
10
24
  constructor(// The proof fields.
11
25
  // For native verification, attach public inputs via `attachPublicInputs(publicInputs)`.
12
26
  // Not using Tuple here due to the length being too high.
13
- fields){
27
+ fields, compressedProof){
14
28
  this.fields = fields;
15
29
  if (fields.length !== CHONK_PROOF_LENGTH) {
16
30
  throw new Error(`Invalid ChonkProof length: ${fields.length}`);
17
31
  }
32
+ this.compressedProof = compressedProof;
18
33
  }
19
34
  attachPublicInputs(publicInputs) {
20
35
  return new ChonkProofWithPublicInputs([
@@ -48,18 +63,77 @@ export class ChonkProof {
48
63
  toJSON() {
49
64
  return this.toBuffer();
50
65
  }
51
- static fromBuffer(buffer) {
66
+ /**
67
+ * Deserialize a ChonkProof from a buffer.
68
+ * Supports both legacy (field elements) and compressed (chonk compression) formats.
69
+ *
70
+ * Size-based format detection:
71
+ * - First uint32 == CHONK_PROOF_LENGTH (1632): legacy format, read field elements
72
+ * Total proof data ≈ 52KB (always >= 40KB)
73
+ * - Otherwise: compressed format, first uint32 is byte count of compressed data
74
+ * Total proof data ≈ 35KB (always < 40KB)
75
+ */ static fromBuffer(buffer) {
52
76
  const reader = BufferReader.asReader(buffer);
53
- const proofLength = reader.readNumber();
54
- const proof = reader.readArray(proofLength, Fr);
55
- return new ChonkProof(proof);
56
- }
57
- toBuffer() {
77
+ const firstUint32 = reader.readNumber();
78
+ if (firstUint32 === CHONK_PROOF_LENGTH) {
79
+ // Legacy format: firstUint32 is the field count (1632)
80
+ // Widen to `number` to prevent TS from narrowing to literal 1632,
81
+ // which would cause Tuple<Fr, 1632> to exceed the recursion limit.
82
+ const fieldCount = firstUint32;
83
+ const proof = reader.readArray(fieldCount, Fr);
84
+ return new ChonkProof(proof);
85
+ }
86
+ // Compressed format: firstUint32 is the compressed byte count
87
+ const compressedBytes = reader.readBytes(firstUint32);
88
+ return ChonkProof.fromCompressedBytes(Buffer.from(compressedBytes));
89
+ }
90
+ /**
91
+ * Create a ChonkProof from compressed bytes by decompressing via the BarretenbergSync API.
92
+ * The compressed format uses point compression and u256 encoding (from PR #20645).
93
+ *
94
+ * @param compressed - Compressed proof bytes from chonk compression
95
+ * @returns ChonkProof with both fields and compressed bytes populated
96
+ */ static fromCompressedBytes(compressed) {
97
+ const api = BarretenbergSync.getSingleton();
98
+ const result = api.chonkDecompressProof({
99
+ compressedProof: new Uint8Array(compressed)
100
+ });
101
+ // Flatten the structured bb.js ChonkProof into flat Fr[] field elements
102
+ const flatFields = flattenChonkProofFields(result.proof);
103
+ const fields = flatFields.map((f)=>Fr.fromBuffer(Buffer.from(f)));
104
+ // The decompressed proof includes public inputs in hidingOinkProof.
105
+ // Since ChonkProof stores fields WITHOUT public inputs, strip them.
106
+ // The number of public inputs = total fields - CHONK_PROOF_LENGTH
107
+ if (fields.length > CHONK_PROOF_LENGTH) {
108
+ const numPubInputs = fields.length - CHONK_PROOF_LENGTH;
109
+ const proofFields = fields.slice(numPubInputs);
110
+ return new ChonkProof(proofFields, compressed);
111
+ }
112
+ return new ChonkProof(fields, compressed);
113
+ }
114
+ /**
115
+ * Serialize the proof to a buffer.
116
+ * If compressed bytes are available, uses the compressed format (~1.7x smaller).
117
+ * Otherwise falls back to legacy field element format.
118
+ */ toBuffer() {
119
+ if (this.compressedProof) {
120
+ // Compressed format: [compressed_byte_count: uint32] [compressed_bytes]
121
+ return Buffer.concat([
122
+ numToUInt32BE(this.compressedProof.length),
123
+ this.compressedProof
124
+ ]);
125
+ }
126
+ // Legacy format: [field_count=1632: uint32] [fields...]
58
127
  return serializeToBuffer(this.fields.length, this.fields);
59
128
  }
60
129
  }
61
130
  export class ChonkProofWithPublicInputs {
62
131
  fieldsWithPublicInputs;
132
+ /**
133
+ * Optional compressed proof bytes (covers the full proof WITH public inputs).
134
+ * Set by the prover when using chonk compression. Flows through to ChonkProof
135
+ * via removePublicInputs() so the Tx can serialize in compressed format.
136
+ */ compressedProof;
63
137
  constructor(// The proof fields with public inputs.
64
138
  // For recursive verification, use without public inputs via `removePublicInputs()`.
65
139
  fieldsWithPublicInputs){
@@ -74,7 +148,8 @@ export class ChonkProofWithPublicInputs {
74
148
  }
75
149
  removePublicInputs() {
76
150
  const numPublicInputs = this.fieldsWithPublicInputs.length - CHONK_PROOF_LENGTH;
77
- return new ChonkProof(this.fieldsWithPublicInputs.slice(numPublicInputs));
151
+ // Flow compressed proof bytes through so the ChonkProof can serialize efficiently
152
+ return new ChonkProof(this.fieldsWithPublicInputs.slice(numPublicInputs), this.compressedProof);
78
153
  }
79
154
  isEmpty() {
80
155
  return this.fieldsWithPublicInputs.every((field)=>field.isZero());
@@ -13,13 +13,17 @@ export declare class Capsule {
13
13
  readonly storageSlot: Fr;
14
14
  /** Data passed to the contract */
15
15
  readonly data: Fr[];
16
+ /** Optional namespace for the capsule contents */
17
+ readonly scope?: AztecAddress | undefined;
16
18
  constructor(
17
19
  /** The address of the contract the capsule is for */
18
20
  contractAddress: AztecAddress,
19
21
  /** The storage slot of the capsule */
20
22
  storageSlot: Fr,
21
23
  /** Data passed to the contract */
22
- data: Fr[]);
24
+ data: Fr[],
25
+ /** Optional namespace for the capsule contents */
26
+ scope?: AztecAddress | undefined);
23
27
  static get schema(): import("zod").ZodType<Capsule, any, string>;
24
28
  toJSON(): `0x${string}`;
25
29
  toBuffer(): Buffer<ArrayBufferLike>;
@@ -27,4 +31,4 @@ export declare class Capsule {
27
31
  toString(): `0x${string}`;
28
32
  static fromString(str: string): Capsule;
29
33
  }
30
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2Fwc3VsZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3R4L2NhcHN1bGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLEVBQUUsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBRXBELE9BQU8sRUFBRSxZQUFZLEVBQXFCLE1BQU0sNkJBQTZCLENBQUM7QUFHOUUsT0FBTyxFQUFFLFlBQVksRUFBRSxNQUFNLDJCQUEyQixDQUFDO0FBR3pEOzs7O0dBSUc7QUFDSCxxQkFBYSxPQUFPO0lBRWhCLHFEQUFxRDthQUNyQyxlQUFlLEVBQUUsWUFBWTtJQUM3QyxzQ0FBc0M7YUFDdEIsV0FBVyxFQUFFLEVBQUU7SUFDL0IsbUNBQW1DO2FBQ25CLElBQUksRUFBRSxFQUFFLEVBQUU7SUFONUI7SUFDRSxxREFBcUQ7SUFDckMsZUFBZSxFQUFFLFlBQVk7SUFDN0Msc0NBQXNDO0lBQ3RCLFdBQVcsRUFBRSxFQUFFO0lBQy9CLG1DQUFtQztJQUNuQixJQUFJLEVBQUUsRUFBRSxFQUFFLEVBQ3hCO0lBRUosTUFBTSxLQUFLLE1BQU0sZ0RBRWhCO0lBRUQsTUFBTSxrQkFFTDtJQUVELFFBQVEsNEJBRVA7SUFFRCxNQUFNLENBQUMsVUFBVSxDQUFDLE1BQU0sRUFBRSxNQUFNLEdBQUcsWUFBWSxHQUFHLE9BQU8sQ0FHeEQ7SUFFRCxRQUFRLGtCQUVQO0lBRUQsTUFBTSxDQUFDLFVBQVUsQ0FBQyxHQUFHLEVBQUUsTUFBTSxXQUU1QjtDQUNGIn0=
34
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2Fwc3VsZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3R4L2NhcHN1bGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLEVBQUUsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBRXBELE9BQU8sRUFBRSxZQUFZLEVBQXFCLE1BQU0sNkJBQTZCLENBQUM7QUFHOUUsT0FBTyxFQUFFLFlBQVksRUFBRSxNQUFNLDJCQUEyQixDQUFDO0FBR3pEOzs7O0dBSUc7QUFDSCxxQkFBYSxPQUFPO0lBRWhCLHFEQUFxRDthQUNyQyxlQUFlLEVBQUUsWUFBWTtJQUM3QyxzQ0FBc0M7YUFDdEIsV0FBVyxFQUFFLEVBQUU7SUFDL0IsbUNBQW1DO2FBQ25CLElBQUksRUFBRSxFQUFFLEVBQUU7SUFDMUIsa0RBQWtEO2FBQ2xDLEtBQUssQ0FBQztJQVJ4QjtJQUNFLHFEQUFxRDtJQUNyQyxlQUFlLEVBQUUsWUFBWTtJQUM3QyxzQ0FBc0M7SUFDdEIsV0FBVyxFQUFFLEVBQUU7SUFDL0IsbUNBQW1DO0lBQ25CLElBQUksRUFBRSxFQUFFLEVBQUU7SUFDMUIsa0RBQWtEO0lBQ2xDLEtBQUssQ0FBQywwQkFBYyxFQUNsQztJQUVKLE1BQU0sS0FBSyxNQUFNLGdEQUVoQjtJQUVELE1BQU0sa0JBRUw7SUFFRCxRQUFRLDRCQUlQO0lBRUQsTUFBTSxDQUFDLFVBQVUsQ0FBQyxNQUFNLEVBQUUsTUFBTSxHQUFHLFlBQVksR0FBRyxPQUFPLENBT3hEO0lBRUQsUUFBUSxrQkFFUDtJQUVELE1BQU0sQ0FBQyxVQUFVLENBQUMsR0FBRyxFQUFFLE1BQU0sV0FFNUI7Q0FDRiJ9
@@ -1 +1 @@
1
- {"version":3,"file":"capsule.d.ts","sourceRoot":"","sources":["../../src/tx/capsule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AAEpD,OAAO,EAAE,YAAY,EAAqB,MAAM,6BAA6B,CAAC;AAG9E,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAGzD;;;;GAIG;AACH,qBAAa,OAAO;IAEhB,qDAAqD;aACrC,eAAe,EAAE,YAAY;IAC7C,sCAAsC;aACtB,WAAW,EAAE,EAAE;IAC/B,mCAAmC;aACnB,IAAI,EAAE,EAAE,EAAE;IAN5B;IACE,qDAAqD;IACrC,eAAe,EAAE,YAAY;IAC7C,sCAAsC;IACtB,WAAW,EAAE,EAAE;IAC/B,mCAAmC;IACnB,IAAI,EAAE,EAAE,EAAE,EACxB;IAEJ,MAAM,KAAK,MAAM,gDAEhB;IAED,MAAM,kBAEL;IAED,QAAQ,4BAEP;IAED,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,GAAG,OAAO,CAGxD;IAED,QAAQ,kBAEP;IAED,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,MAAM,WAE5B;CACF"}
1
+ {"version":3,"file":"capsule.d.ts","sourceRoot":"","sources":["../../src/tx/capsule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AAEpD,OAAO,EAAE,YAAY,EAAqB,MAAM,6BAA6B,CAAC;AAG9E,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAGzD;;;;GAIG;AACH,qBAAa,OAAO;IAEhB,qDAAqD;aACrC,eAAe,EAAE,YAAY;IAC7C,sCAAsC;aACtB,WAAW,EAAE,EAAE;IAC/B,mCAAmC;aACnB,IAAI,EAAE,EAAE,EAAE;IAC1B,kDAAkD;aAClC,KAAK,CAAC;IARxB;IACE,qDAAqD;IACrC,eAAe,EAAE,YAAY;IAC7C,sCAAsC;IACtB,WAAW,EAAE,EAAE;IAC/B,mCAAmC;IACnB,IAAI,EAAE,EAAE,EAAE;IAC1B,kDAAkD;IAClC,KAAK,CAAC,0BAAc,EAClC;IAEJ,MAAM,KAAK,MAAM,gDAEhB;IAED,MAAM,kBAEL;IAED,QAAQ,4BAIP;IAED,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,GAAG,OAAO,CAOxD;IAED,QAAQ,kBAEP;IAED,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,MAAM,WAE5B;CACF"}
@@ -12,10 +12,12 @@ import { Vector } from '../types/shared.js';
12
12
  contractAddress;
13
13
  storageSlot;
14
14
  data;
15
- constructor(/** The address of the contract the capsule is for */ contractAddress, /** The storage slot of the capsule */ storageSlot, /** Data passed to the contract */ data){
15
+ scope;
16
+ constructor(/** The address of the contract the capsule is for */ contractAddress, /** The storage slot of the capsule */ storageSlot, /** Data passed to the contract */ data, /** Optional namespace for the capsule contents */ scope){
16
17
  this.contractAddress = contractAddress;
17
18
  this.storageSlot = storageSlot;
18
19
  this.data = data;
20
+ this.scope = scope;
19
21
  }
20
22
  static get schema() {
21
23
  return hexSchemaFor(Capsule);
@@ -24,11 +26,15 @@ import { Vector } from '../types/shared.js';
24
26
  return this.toString();
25
27
  }
26
28
  toBuffer() {
27
- return serializeToBuffer(this.contractAddress, this.storageSlot, new Vector(this.data));
29
+ return this.scope ? serializeToBuffer(this.contractAddress, this.storageSlot, new Vector(this.data), true, this.scope) : serializeToBuffer(this.contractAddress, this.storageSlot, new Vector(this.data), false);
28
30
  }
29
31
  static fromBuffer(buffer) {
30
32
  const reader = BufferReader.asReader(buffer);
31
- return new Capsule(AztecAddress.fromBuffer(reader), Fr.fromBuffer(reader), reader.readVector(Fr));
33
+ const contractAddress = AztecAddress.fromBuffer(reader);
34
+ const storageSlot = Fr.fromBuffer(reader);
35
+ const data = reader.readVector(Fr);
36
+ const hasScope = reader.readBoolean();
37
+ return new Capsule(contractAddress, storageSlot, data, hasScope ? AztecAddress.fromBuffer(reader) : undefined);
32
38
  }
33
39
  toString() {
34
40
  return bufferToHex(this.toBuffer());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/stdlib",
3
- "version": "5.0.0-nightly.20260324",
3
+ "version": "5.0.0-nightly.20260328",
4
4
  "type": "module",
5
5
  "inherits": [
6
6
  "../package.common.json",
@@ -92,13 +92,13 @@
92
92
  },
93
93
  "dependencies": {
94
94
  "@aws-sdk/client-s3": "^3.892.0",
95
- "@aztec/bb.js": "5.0.0-nightly.20260324",
96
- "@aztec/blob-lib": "5.0.0-nightly.20260324",
97
- "@aztec/constants": "5.0.0-nightly.20260324",
98
- "@aztec/ethereum": "5.0.0-nightly.20260324",
99
- "@aztec/foundation": "5.0.0-nightly.20260324",
100
- "@aztec/l1-artifacts": "5.0.0-nightly.20260324",
101
- "@aztec/noir-noirc_abi": "5.0.0-nightly.20260324",
95
+ "@aztec/bb.js": "5.0.0-nightly.20260328",
96
+ "@aztec/blob-lib": "5.0.0-nightly.20260328",
97
+ "@aztec/constants": "5.0.0-nightly.20260328",
98
+ "@aztec/ethereum": "5.0.0-nightly.20260328",
99
+ "@aztec/foundation": "5.0.0-nightly.20260328",
100
+ "@aztec/l1-artifacts": "5.0.0-nightly.20260328",
101
+ "@aztec/noir-noirc_abi": "5.0.0-nightly.20260328",
102
102
  "@google-cloud/storage": "^7.15.0",
103
103
  "axios": "^1.13.5",
104
104
  "json-stringify-deterministic": "1.0.12",
@@ -1,8 +1,17 @@
1
1
  import { Fr } from '@aztec/foundation/curves/bn254';
2
+ import { EthAddress } from '@aztec/foundation/eth-address';
2
3
 
3
4
  import { AztecAddress } from '../aztec-address/index.js';
4
- import type { ABIParameter, ABIVariable, AbiType } from './abi.js';
5
- import { isAztecAddressStruct, isOptionStruct, parseSignedInt } from './utils.js';
5
+ import type { AbiType } from './abi.js';
6
+ import { FunctionSelector } from './function_selector.js';
7
+ import {
8
+ isAztecAddressStruct,
9
+ isEthAddressStruct,
10
+ isFunctionSelectorStruct,
11
+ isOptionStruct,
12
+ isWrappedFieldStruct,
13
+ parseSignedInt,
14
+ } from './utils.js';
6
15
 
7
16
  /**
8
17
  * The type of our decoded ABI.
@@ -12,6 +21,9 @@ export type AbiDecoded =
12
21
  | boolean
13
22
  | string
14
23
  | AztecAddress
24
+ | EthAddress
25
+ | FunctionSelector
26
+ | Fr
15
27
  | AbiDecoded[]
16
28
  | { [key: string]: AbiDecoded }
17
29
  | undefined;
@@ -58,6 +70,15 @@ class AbiDecoder {
58
70
  if (isAztecAddressStruct(abiType)) {
59
71
  return new AztecAddress(this.getNextField().toBuffer());
60
72
  }
73
+ if (isEthAddressStruct(abiType)) {
74
+ return EthAddress.fromField(this.getNextField());
75
+ }
76
+ if (isFunctionSelectorStruct(abiType)) {
77
+ return FunctionSelector.fromField(this.getNextField());
78
+ }
79
+ if (isWrappedFieldStruct(abiType)) {
80
+ return this.getNextField();
81
+ }
61
82
  if (isOptionStruct(abiType)) {
62
83
  const isSome = this.decodeNext(abiType.fields[0].type);
63
84
  const value = this.decodeNext(abiType.fields[1].type);
@@ -123,79 +144,3 @@ class AbiDecoder {
123
144
  export function decodeFromAbi(typ: AbiType[], buffer: Fr[]) {
124
145
  return new AbiDecoder(typ, buffer.slice()).decode();
125
146
  }
126
-
127
- /**
128
- * Decodes the signature of a function from the name and parameters.
129
- */
130
- export class FunctionSignatureDecoder {
131
- private separator: string;
132
- constructor(
133
- private name: string,
134
- private parameters: ABIParameter[],
135
- private includeNames = false,
136
- ) {
137
- this.separator = includeNames ? ', ' : ',';
138
- }
139
-
140
- /**
141
- * Decodes a single function parameter type for the function signature.
142
- * @param param - The parameter type to decode.
143
- * @returns A string representing the parameter type.
144
- */
145
- private getParameterType(param: AbiType): string {
146
- switch (param.kind) {
147
- case 'field':
148
- return 'Field';
149
- case 'integer':
150
- return param.sign === 'signed' ? `i${param.width}` : `u${param.width}`;
151
- case 'boolean':
152
- return 'bool';
153
- case 'array':
154
- return `[${this.getParameterType(param.type)};${param.length}]`;
155
- case 'string':
156
- return `str<${param.length}>`;
157
- case 'struct':
158
- return `(${param.fields.map(field => `${this.decodeParameter(field)}`).join(this.separator)})`;
159
- default:
160
- throw new Error(`Unsupported type: ${param.kind}`);
161
- }
162
- }
163
-
164
- /**
165
- * Decodes a single function parameter for the function signature.
166
- * @param param - The parameter to decode.
167
- * @returns A string representing the parameter type and optionally its name.
168
- */
169
- private decodeParameter(param: ABIVariable): string {
170
- const type = this.getParameterType(param.type);
171
- return this.includeNames ? `${param.name}: ${type}` : type;
172
- }
173
-
174
- /**
175
- * Decodes all the parameters and build the function signature
176
- * @returns The function signature.
177
- */
178
- public decode(): string {
179
- return `${this.name}(${this.parameters.map(param => this.decodeParameter(param)).join(this.separator)})`;
180
- }
181
- }
182
-
183
- /**
184
- * Decodes a function signature from the name and parameters.
185
- * @param name - The name of the function.
186
- * @param parameters - The parameters of the function.
187
- * @returns - The function signature.
188
- */
189
- export function decodeFunctionSignature(name: string, parameters: ABIParameter[]) {
190
- return new FunctionSignatureDecoder(name, parameters).decode();
191
- }
192
-
193
- /**
194
- * Decodes a function signature from the name and parameters including parameter names.
195
- * @param name - The name of the function.
196
- * @param parameters - The parameters of the function.
197
- * @returns - The user-friendly function signature.
198
- */
199
- export function decodeFunctionSignatureWithParameterNames(name: string, parameters: ABIParameter[]) {
200
- return new FunctionSignatureDecoder(name, parameters, true).decode();
201
- }
@@ -6,7 +6,7 @@ import { type ZodFor, hexSchemaFor } from '@aztec/foundation/schemas';
6
6
  import { BufferReader, FieldReader, TypeRegistry } from '@aztec/foundation/serialize';
7
7
 
8
8
  import type { ABIParameter } from './abi.js';
9
- import { decodeFunctionSignature } from './decoder.js';
9
+ import { decodeFunctionSignature } from './function_signature_decoder.js';
10
10
  import { Selector } from './selector.js';
11
11
 
12
12
  /* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */
@@ -0,0 +1,77 @@
1
+ import type { ABIParameter, ABIVariable, AbiType } from './abi.js';
2
+
3
+ /**
4
+ * Decodes the signature of a function from the name and parameters.
5
+ */
6
+ export class FunctionSignatureDecoder {
7
+ private separator: string;
8
+ constructor(
9
+ private name: string,
10
+ private parameters: ABIParameter[],
11
+ private includeNames = false,
12
+ ) {
13
+ this.separator = includeNames ? ', ' : ',';
14
+ }
15
+
16
+ /**
17
+ * Decodes a single function parameter type for the function signature.
18
+ * @param param - The parameter type to decode.
19
+ * @returns A string representing the parameter type.
20
+ */
21
+ private getParameterType(param: AbiType): string {
22
+ switch (param.kind) {
23
+ case 'field':
24
+ return 'Field';
25
+ case 'integer':
26
+ return param.sign === 'signed' ? `i${param.width}` : `u${param.width}`;
27
+ case 'boolean':
28
+ return 'bool';
29
+ case 'array':
30
+ return `[${this.getParameterType(param.type)};${param.length}]`;
31
+ case 'string':
32
+ return `str<${param.length}>`;
33
+ case 'struct':
34
+ return `(${param.fields.map(field => `${this.decodeParameter(field)}`).join(this.separator)})`;
35
+ default:
36
+ throw new Error(`Unsupported type: ${param.kind}`);
37
+ }
38
+ }
39
+
40
+ /**
41
+ * Decodes a single function parameter for the function signature.
42
+ * @param param - The parameter to decode.
43
+ * @returns A string representing the parameter type and optionally its name.
44
+ */
45
+ private decodeParameter(param: ABIVariable): string {
46
+ const type = this.getParameterType(param.type);
47
+ return this.includeNames ? `${param.name}: ${type}` : type;
48
+ }
49
+
50
+ /**
51
+ * Decodes all the parameters and build the function signature
52
+ * @returns The function signature.
53
+ */
54
+ public decode(): string {
55
+ return `${this.name}(${this.parameters.map(param => this.decodeParameter(param)).join(this.separator)})`;
56
+ }
57
+ }
58
+
59
+ /**
60
+ * Decodes a function signature from the name and parameters.
61
+ * @param name - The name of the function.
62
+ * @param parameters - The parameters of the function.
63
+ * @returns - The function signature.
64
+ */
65
+ export function decodeFunctionSignature(name: string, parameters: ABIParameter[]) {
66
+ return new FunctionSignatureDecoder(name, parameters).decode();
67
+ }
68
+
69
+ /**
70
+ * Decodes a function signature from the name and parameters including parameter names.
71
+ * @param name - The name of the function.
72
+ * @param parameters - The parameters of the function.
73
+ * @returns - The user-friendly function signature.
74
+ */
75
+ export function decodeFunctionSignatureWithParameterNames(name: string, parameters: ABIParameter[]) {
76
+ return new FunctionSignatureDecoder(name, parameters, true).decode();
77
+ }
package/src/abi/index.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export * from './abi.js';
2
2
  export * from './buffer.js';
3
3
  export * from './decoder.js';
4
+ export * from './function_signature_decoder.js';
4
5
  export * from './encoder.js';
5
6
  export * from './authorization_selector.js';
6
7
  export * from './event_metadata_definition.js';
@@ -68,6 +68,14 @@ export function getNextL1SlotTimestamp(
68
68
  return constants.l1GenesisTime + (currentL1Slot + 1n) * BigInt(constants.ethereumSlotDuration);
69
69
  }
70
70
 
71
+ /** Returns the timestamp of the last L1 slot within a given L2 slot. */
72
+ export function getLastL1SlotTimestampForL2Slot(
73
+ slot: SlotNumber,
74
+ constants: Pick<L1RollupConstants, 'l1GenesisTime' | 'slotDuration' | 'ethereumSlotDuration'>,
75
+ ): bigint {
76
+ return getTimestampForSlot(slot, constants) + BigInt(constants.slotDuration - constants.ethereumSlotDuration);
77
+ }
78
+
71
79
  /** Returns the L2 slot number at the next L1 block based on the current timestamp. */
72
80
  export function getSlotAtNextL1Block(
73
81
  currentL1Timestamp: bigint,
@@ -1,7 +1,7 @@
1
1
  import { type Logger, createLogger } from '@aztec/foundation/log';
2
2
 
3
3
  import { GoogleCloudFileStore } from './gcs.js';
4
- import { HttpFileStore } from './http.js';
4
+ import { HttpFileStore, type HttpFileStoreOptions } from './http.js';
5
5
  import type { FileStore, ReadOnlyFileStore } from './interface.js';
6
6
  import { LocalFileStore } from './local.js';
7
7
  import { S3FileStore } from './s3.js';
@@ -59,17 +59,26 @@ export async function createFileStore(
59
59
  }
60
60
  }
61
61
 
62
- export async function createReadOnlyFileStore(config: string, logger?: Logger): Promise<ReadOnlyFileStore>;
63
- export async function createReadOnlyFileStore(config: undefined, logger?: Logger): Promise<undefined>;
62
+ export async function createReadOnlyFileStore(
63
+ config: string,
64
+ logger?: Logger,
65
+ options?: HttpFileStoreOptions,
66
+ ): Promise<ReadOnlyFileStore>;
67
+ export async function createReadOnlyFileStore(
68
+ config: undefined,
69
+ logger?: Logger,
70
+ options?: HttpFileStoreOptions,
71
+ ): Promise<undefined>;
64
72
  export async function createReadOnlyFileStore(
65
73
  config: string | undefined,
66
74
  logger = createLogger('stdlib:file-store'),
75
+ options?: HttpFileStoreOptions,
67
76
  ): Promise<ReadOnlyFileStore | undefined> {
68
77
  if (config === undefined) {
69
78
  return undefined;
70
79
  } else if (config.startsWith('http://') || config.startsWith('https://')) {
71
80
  logger.info(`Creating read-only HTTP file store at ${config}`);
72
- return new HttpFileStore(config, logger);
81
+ return new HttpFileStore(config, logger, options);
73
82
  } else {
74
83
  return await createFileStore(config, logger);
75
84
  }
@@ -10,6 +10,14 @@ import { pipeline } from 'stream/promises';
10
10
 
11
11
  import type { ReadOnlyFileStore } from './interface.js';
12
12
 
13
+ /** Options for configuring HttpFileStore behavior. */
14
+ export interface HttpFileStoreOptions {
15
+ /** Retry backoff intervals in seconds. Empty array disables retries. Default: [1, 1, 3]. */
16
+ retryBackoff?: number[];
17
+ /** Request timeout in milliseconds. Default: no timeout (axios default). */
18
+ timeoutMs?: number;
19
+ }
20
+
13
21
  export class HttpFileStore implements ReadOnlyFileStore {
14
22
  private readonly axiosInstance: AxiosInstance;
15
23
  private readonly fetch: <T>(config: AxiosRequestConfig) => Promise<AxiosResponse<T>>;
@@ -17,17 +25,28 @@ export class HttpFileStore implements ReadOnlyFileStore {
17
25
  constructor(
18
26
  private readonly baseUrl: string,
19
27
  private readonly log: Logger = createLogger('stdlib:http-file-store'),
28
+ options?: HttpFileStoreOptions,
20
29
  ) {
21
- this.axiosInstance = axios.create();
22
- this.fetch = async <T>(config: AxiosRequestConfig) => {
23
- return await retry(
24
- () => this.axiosInstance.request<T>(config),
25
- `Fetching ${config.url}`,
26
- makeBackoff([1, 1, 3]),
27
- this.log,
28
- /*failSilently=*/ true,
29
- );
30
- };
30
+ this.axiosInstance = axios.create({
31
+ ...(options?.timeoutMs !== undefined && { timeout: options.timeoutMs }),
32
+ });
33
+
34
+ const retryBackoff = options?.retryBackoff ?? [1, 1, 3];
35
+ if (retryBackoff.length > 0) {
36
+ this.fetch = async <T>(config: AxiosRequestConfig) => {
37
+ return await retry(
38
+ () => this.axiosInstance.request<T>(config),
39
+ `Fetching ${config.url}`,
40
+ makeBackoff(retryBackoff),
41
+ this.log,
42
+ /*failSilently=*/ true,
43
+ );
44
+ };
45
+ } else {
46
+ this.fetch = async <T>(config: AxiosRequestConfig) => {
47
+ return await this.axiosInstance.request<T>(config);
48
+ };
49
+ }
31
50
  }
32
51
 
33
52
  public async read(pathOrUrl: string): Promise<Buffer> {
@@ -1,2 +1,3 @@
1
1
  export * from './interface.js';
2
2
  export * from './factory.js';
3
+ export { type HttpFileStoreOptions } from './http.js';
package/src/hash/hash.ts CHANGED
@@ -98,6 +98,11 @@ export function computeProtocolNullifier(txRequestHash: Fr): Promise<Fr> {
98
98
  return siloNullifier(AztecAddress.fromBigInt(NULL_MSG_SENDER_CONTRACT_ADDRESS), txRequestHash);
99
99
  }
100
100
 
101
+ /** Domain-separates a raw log tag with the given domain separator. */
102
+ export function computeLogTag(rawTag: number | bigint | boolean | Fr | Buffer, domSep: DomainSeparator): Promise<Fr> {
103
+ return poseidon2HashWithSeparator([new Fr(rawTag)], domSep);
104
+ }
105
+
101
106
  export function computeSiloedPrivateLogFirstField(contract: AztecAddress, field: Fr): Promise<Fr> {
102
107
  return poseidon2HashWithSeparator([contract, field], DomainSeparator.PRIVATE_LOG_FIRST_FIELD);
103
108
  }
@@ -48,10 +48,7 @@ export type ValidatorClientConfig = ValidatorHASignerConfig &
48
48
  /** Interval between polling for new attestations from peers */
49
49
  attestationPollingIntervalMs: number;
50
50
 
51
- /** Whether to re-execute transactions in a block proposal before attesting */
52
- validatorReexecute: boolean;
53
-
54
- /** Whether to always reexecute block proposals, even for non-validator nodes or when out of the currnet committee */
51
+ /** Whether to always reexecute block proposals, even for non-validator nodes or when out of the current committee */
55
52
  alwaysReexecuteBlockProposals?: boolean;
56
53
 
57
54
  /** Whether to run in fisherman mode: validates all proposals and attestations but does not broadcast attestations or participate in consensus */
@@ -98,7 +95,6 @@ export const ValidatorClientConfigSchema = zodFor<Omit<ValidatorClientConfig, 'v
98
95
  disableValidator: z.boolean(),
99
96
  disabledValidators: z.array(schemas.EthAddress),
100
97
  attestationPollingIntervalMs: z.number().min(0),
101
- validatorReexecute: z.boolean(),
102
98
  alwaysReexecuteBlockProposals: z.boolean().optional(),
103
99
  fishermanMode: z.boolean().optional(),
104
100
  skipCheckpointProposalValidation: z.boolean().optional(),
@@ -1,8 +1,7 @@
1
1
  import { MAX_NOTE_HASHES_PER_TX } from '@aztec/constants';
2
+ import { range } from '@aztec/foundation/array';
2
3
  import { Fr } from '@aztec/foundation/curves/bn254';
3
4
 
4
- import type { AztecAddress } from '../aztec-address/index.js';
5
- import type { TxEffect } from '../tx/tx_effect.js';
6
5
  import type { TxHash } from '../tx/tx_hash.js';
7
6
 
8
7
  /**
@@ -19,7 +18,6 @@ export class MessageContext {
19
18
  public txHash: TxHash,
20
19
  public uniqueNoteHashesInTx: Fr[],
21
20
  public firstNullifierInTx: Fr,
22
- public recipient: AztecAddress,
23
21
  ) {}
24
22
 
25
23
  toFields(): Fr[] {
@@ -27,7 +25,6 @@ export class MessageContext {
27
25
  this.txHash.hash,
28
26
  ...serializeBoundedVec(this.uniqueNoteHashesInTx, MAX_NOTE_HASHES_PER_TX),
29
27
  this.firstNullifierInTx,
30
- this.recipient.toField(),
31
28
  ];
32
29
  }
33
30
 
@@ -37,13 +34,22 @@ export class MessageContext {
37
34
  tx_hash: this.txHash.hash,
38
35
  unique_note_hashes_in_tx: this.uniqueNoteHashesInTx,
39
36
  first_nullifier_in_tx: this.firstNullifierInTx,
40
- recipient: this.recipient,
41
37
  };
42
38
  /* eslint-enable camelcase */
43
39
  }
44
40
 
45
- static fromTxEffectAndRecipient(txEffect: TxEffect, recipient: AztecAddress): MessageContext {
46
- return new MessageContext(txEffect.txHash, txEffect.noteHashes, txEffect.nullifiers[0], recipient);
41
+ static toEmptyFields(): Fr[] {
42
+ const serializationLen =
43
+ 1 /* txHash */ + MAX_NOTE_HASHES_PER_TX + 1 /* uniqueNoteHashesInTx BVec */ + 1; /* firstNullifierInTx */
44
+ return range(serializationLen).map(_ => Fr.zero());
45
+ }
46
+
47
+ static toSerializedOption(response: MessageContext | null): Fr[] {
48
+ if (response) {
49
+ return [new Fr(1), ...response.toFields()];
50
+ } else {
51
+ return [new Fr(0), ...MessageContext.toEmptyFields()];
52
+ }
47
53
  }
48
54
  }
49
55
 
@@ -55,6 +61,10 @@ export class MessageContext {
55
61
  * @dev Copied over from pending_tagged_log.ts.
56
62
  */
57
63
  function serializeBoundedVec(values: Fr[], maxLength: number): Fr[] {
64
+ if (values.length > maxLength) {
65
+ throw new Error(`Attempted to serialize ${values} values into a BoundedVec with max length ${maxLength}`);
66
+ }
67
+
58
68
  const lengthDiff = maxLength - values.length;
59
69
  const zeroPaddingArray = Array(lengthDiff).fill(Fr.ZERO);
60
70
  const storage = values.concat(zeroPaddingArray);