@aztec/stdlib 3.0.0-nightly.20251111 → 3.0.0-nightly.20251113

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 (176) hide show
  1. package/dest/abi/abi.d.ts +8 -8
  2. package/dest/abi/abi.d.ts.map +1 -1
  3. package/dest/abi/abi.js +2 -2
  4. package/dest/abi/contract_artifact.js +3 -3
  5. package/dest/avm/avm.d.ts +780 -1010
  6. package/dest/avm/avm.d.ts.map +1 -1
  7. package/dest/avm/avm.js +209 -15
  8. package/dest/avm/avm_accumulated_data.d.ts +22 -6
  9. package/dest/avm/avm_accumulated_data.d.ts.map +1 -1
  10. package/dest/avm/avm_accumulated_data.js +18 -0
  11. package/dest/avm/avm_circuit_public_inputs.d.ts +35 -27
  12. package/dest/avm/avm_circuit_public_inputs.d.ts.map +1 -1
  13. package/dest/avm/avm_circuit_public_inputs.js +9 -0
  14. package/dest/avm/avm_proving_request.d.ts +308 -464
  15. package/dest/avm/avm_proving_request.d.ts.map +1 -1
  16. package/dest/avm/public_data_write.d.ts +10 -2
  17. package/dest/avm/public_data_write.d.ts.map +1 -1
  18. package/dest/avm/public_data_write.js +9 -0
  19. package/dest/avm/revert_code.d.ts +8 -0
  20. package/dest/avm/revert_code.d.ts.map +1 -1
  21. package/dest/avm/revert_code.js +16 -0
  22. package/dest/aztec-address/index.d.ts +9 -0
  23. package/dest/aztec-address/index.d.ts.map +1 -1
  24. package/dest/aztec-address/index.js +16 -0
  25. package/dest/block/l2_block.d.ts +1 -1
  26. package/dest/block/l2_block_info.d.ts +3 -3
  27. package/dest/block/proposal/attestations_and_signers.d.ts +1 -1
  28. package/dest/block/proposal/committee_attestation.d.ts +1 -1
  29. package/dest/block/published_l2_block.d.ts +2 -2
  30. package/dest/block/validate_block_result.d.ts +12 -12
  31. package/dest/contract/contract_deployment_data.d.ts +10 -2
  32. package/dest/contract/contract_deployment_data.d.ts.map +1 -1
  33. package/dest/contract/contract_deployment_data.js +12 -0
  34. package/dest/contract/interfaces/contract_class.d.ts +19 -19
  35. package/dest/contract/interfaces/contract_instance.d.ts +32 -200
  36. package/dest/contract/interfaces/contract_instance.d.ts.map +1 -1
  37. package/dest/database-version/version_manager.d.ts +1 -1
  38. package/dest/file-store/http.d.ts.map +1 -1
  39. package/dest/file-store/http.js +8 -3
  40. package/dest/file-store/s3.d.ts.map +1 -1
  41. package/dest/file-store/s3.js +3 -7
  42. package/dest/gas/gas.d.ts +8 -0
  43. package/dest/gas/gas.d.ts.map +1 -1
  44. package/dest/gas/gas.js +12 -0
  45. package/dest/gas/gas_fees.d.ts +8 -0
  46. package/dest/gas/gas_fees.d.ts.map +1 -1
  47. package/dest/gas/gas_fees.js +12 -0
  48. package/dest/gas/gas_settings.d.ts +8 -0
  49. package/dest/gas/gas_settings.d.ts.map +1 -1
  50. package/dest/gas/gas_settings.js +12 -0
  51. package/dest/gas/gas_used.d.ts +12 -1
  52. package/dest/gas/gas_used.d.ts.map +1 -1
  53. package/dest/gas/gas_used.js +19 -1
  54. package/dest/interfaces/aztec-node-admin.d.ts +8 -5
  55. package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
  56. package/dest/interfaces/configs.d.ts +5 -0
  57. package/dest/interfaces/configs.d.ts.map +1 -1
  58. package/dest/interfaces/configs.js +1 -0
  59. package/dest/interfaces/proving-job.d.ts +336 -492
  60. package/dest/interfaces/proving-job.d.ts.map +1 -1
  61. package/dest/interfaces/slasher.d.ts +3 -3
  62. package/dest/interfaces/validator.d.ts +12 -4
  63. package/dest/interfaces/validator.d.ts.map +1 -1
  64. package/dest/interfaces/validator.js +2 -1
  65. package/dest/kernel/private_to_avm_accumulated_data.d.ts +20 -4
  66. package/dest/kernel/private_to_avm_accumulated_data.d.ts.map +1 -1
  67. package/dest/kernel/private_to_avm_accumulated_data.js +18 -0
  68. package/dest/kernel/public_call_request.d.ts +17 -1
  69. package/dest/kernel/public_call_request.d.ts.map +1 -1
  70. package/dest/kernel/public_call_request.js +18 -0
  71. package/dest/keys/public_keys.d.ts +20 -84
  72. package/dest/keys/public_keys.d.ts.map +1 -1
  73. package/dest/keys/public_keys.js +12 -0
  74. package/dest/logs/contract_class_log.d.ts +18 -2
  75. package/dest/logs/contract_class_log.d.ts.map +1 -1
  76. package/dest/logs/contract_class_log.js +24 -0
  77. package/dest/logs/debug_log.d.ts +9 -1
  78. package/dest/logs/debug_log.d.ts.map +1 -1
  79. package/dest/logs/debug_log.js +13 -0
  80. package/dest/logs/directional_app_tagging_secret.d.ts +1 -1
  81. package/dest/logs/pre_tag.d.ts +1 -1
  82. package/dest/logs/private_log.d.ts +9 -1
  83. package/dest/logs/private_log.d.ts.map +1 -1
  84. package/dest/logs/private_log.js +12 -0
  85. package/dest/logs/public_log.d.ts +8 -0
  86. package/dest/logs/public_log.d.ts.map +1 -1
  87. package/dest/logs/public_log.js +9 -0
  88. package/dest/logs/tx_scoped_l2_log.d.ts +1 -1
  89. package/dest/messaging/l2_to_l1_message.d.ts +24 -8
  90. package/dest/messaging/l2_to_l1_message.d.ts.map +1 -1
  91. package/dest/messaging/l2_to_l1_message.js +18 -0
  92. package/dest/noir/index.d.ts +1 -1
  93. package/dest/noir/index.d.ts.map +1 -1
  94. package/dest/noir/index.js +1 -2
  95. package/dest/p2p/consensus_payload.d.ts +5 -5
  96. package/dest/snapshots/types.d.ts +2 -2
  97. package/dest/tests/factories.d.ts +4 -1
  98. package/dest/tests/factories.d.ts.map +1 -1
  99. package/dest/tests/factories.js +14 -2
  100. package/dest/trees/append_only_tree_snapshot.d.ts +9 -1
  101. package/dest/trees/append_only_tree_snapshot.d.ts.map +1 -1
  102. package/dest/trees/append_only_tree_snapshot.js +9 -0
  103. package/dest/trees/nullifier_leaf.d.ts +20 -4
  104. package/dest/trees/nullifier_leaf.d.ts.map +1 -1
  105. package/dest/trees/nullifier_leaf.js +24 -0
  106. package/dest/trees/nullifier_membership_witness.d.ts +2 -2
  107. package/dest/trees/public_data_leaf.d.ts +23 -7
  108. package/dest/trees/public_data_leaf.d.ts.map +1 -1
  109. package/dest/trees/public_data_leaf.js +24 -0
  110. package/dest/trees/public_data_witness.d.ts +3 -3
  111. package/dest/tx/content_commitment.d.ts +3 -3
  112. package/dest/tx/execution_payload.d.ts +45 -0
  113. package/dest/tx/execution_payload.d.ts.map +1 -0
  114. package/dest/tx/execution_payload.js +40 -0
  115. package/dest/tx/global_variables.d.ts +8 -0
  116. package/dest/tx/global_variables.d.ts.map +1 -1
  117. package/dest/tx/global_variables.js +9 -0
  118. package/dest/tx/index.d.ts +1 -0
  119. package/dest/tx/index.d.ts.map +1 -1
  120. package/dest/tx/index.js +1 -0
  121. package/dest/tx/partial_state_reference.d.ts +3 -3
  122. package/dest/tx/profiling.d.ts +3 -3
  123. package/dest/tx/profiling.d.ts.map +1 -1
  124. package/dest/tx/profiling.js +5 -4
  125. package/dest/tx/protocol_contracts.d.ts +8 -0
  126. package/dest/tx/protocol_contracts.d.ts.map +1 -1
  127. package/dest/tx/protocol_contracts.js +9 -0
  128. package/dest/tx/public_call_request_with_calldata.d.ts +8 -0
  129. package/dest/tx/public_call_request_with_calldata.d.ts.map +1 -1
  130. package/dest/tx/public_call_request_with_calldata.js +12 -0
  131. package/dest/tx/simulated_tx.d.ts +28 -148
  132. package/dest/tx/simulated_tx.d.ts.map +1 -1
  133. package/dest/tx/state_reference.d.ts +4 -4
  134. package/dest/tx/tree_snapshots.d.ts +12 -4
  135. package/dest/tx/tree_snapshots.d.ts.map +1 -1
  136. package/dest/tx/tree_snapshots.js +9 -0
  137. package/dest/tx/tx_context.d.ts +2 -2
  138. package/dest/validators/schemas.d.ts +3 -3
  139. package/package.json +8 -8
  140. package/src/abi/abi.ts +4 -4
  141. package/src/abi/contract_artifact.ts +3 -3
  142. package/src/avm/avm.ts +362 -15
  143. package/src/avm/avm_accumulated_data.ts +40 -0
  144. package/src/avm/avm_circuit_public_inputs.ts +40 -0
  145. package/src/avm/public_data_write.ts +11 -0
  146. package/src/avm/revert_code.ts +18 -0
  147. package/src/aztec-address/index.ts +18 -0
  148. package/src/contract/contract_deployment_data.ts +17 -0
  149. package/src/file-store/http.ts +6 -3
  150. package/src/file-store/s3.ts +3 -7
  151. package/src/gas/gas.ts +14 -0
  152. package/src/gas/gas_fees.ts +14 -0
  153. package/src/gas/gas_settings.ts +19 -0
  154. package/src/gas/gas_used.ts +22 -1
  155. package/src/interfaces/configs.ts +3 -0
  156. package/src/interfaces/validator.ts +4 -0
  157. package/src/kernel/private_to_avm_accumulated_data.ts +35 -0
  158. package/src/kernel/public_call_request.ts +27 -0
  159. package/src/keys/public_keys.ts +19 -0
  160. package/src/logs/contract_class_log.ts +32 -0
  161. package/src/logs/debug_log.ts +20 -1
  162. package/src/logs/private_log.ts +17 -0
  163. package/src/logs/public_log.ts +14 -0
  164. package/src/messaging/l2_to_l1_message.ts +25 -0
  165. package/src/noir/index.ts +1 -2
  166. package/src/tests/factories.ts +45 -0
  167. package/src/trees/append_only_tree_snapshot.ts +11 -0
  168. package/src/trees/nullifier_leaf.ts +32 -0
  169. package/src/trees/public_data_leaf.ts +32 -0
  170. package/src/tx/execution_payload.ts +60 -0
  171. package/src/tx/global_variables.ts +20 -0
  172. package/src/tx/index.ts +1 -0
  173. package/src/tx/profiling.ts +4 -6
  174. package/src/tx/protocol_contracts.ts +16 -0
  175. package/src/tx/public_call_request_with_calldata.ts +17 -0
  176. package/src/tx/tree_snapshots.ts +16 -0
@@ -72,6 +72,24 @@ export class AztecAddress {
72
72
  return new AztecAddress(hexToBuffer(buf));
73
73
  }
74
74
 
75
+ /**
76
+ * Creates an AztecAddress from a plain object without Zod validation.
77
+ * This method is optimized for performance and skips validation, making it suitable
78
+ * for deserializing trusted data (e.g., from C++ via MessagePack).
79
+ * Handles buffers, strings, or existing instances.
80
+ * @param obj - Plain object, buffer, string, or AztecAddress instance
81
+ * @returns An AztecAddress instance
82
+ */
83
+ static fromPlainObject(obj: any): AztecAddress {
84
+ if (obj instanceof AztecAddress) {
85
+ return obj;
86
+ }
87
+ if (obj instanceof Buffer || Buffer.isBuffer(obj)) {
88
+ return new AztecAddress(obj);
89
+ }
90
+ return AztecAddress.fromString(obj);
91
+ }
92
+
75
93
  /**
76
94
  * @returns a random valid address (i.e. one that can be encrypted to).
77
95
  */
@@ -37,6 +37,23 @@ export class ContractDeploymentData {
37
37
  })
38
38
  .transform(ContractDeploymentData.from);
39
39
  }
40
+
41
+ /**
42
+ * Creates a ContractDeploymentData from a plain object without Zod validation.
43
+ * This method is optimized for performance and skips validation, making it suitable
44
+ * for deserializing trusted data (e.g., from C++ via MessagePack).
45
+ * @param obj - Plain object containing ContractDeploymentData fields
46
+ * @returns A ContractDeploymentData instance
47
+ */
48
+ public static fromPlainObject(obj: any): ContractDeploymentData {
49
+ if (obj instanceof ContractDeploymentData) {
50
+ return obj;
51
+ }
52
+ return new ContractDeploymentData(
53
+ obj.contractClassLogs.map((log: any) => ContractClassLog.fromPlainObject(log)),
54
+ obj.privateLogs.map((log: any) => PrivateLog.fromPlainObject(log)),
55
+ );
56
+ }
40
57
  }
41
58
 
42
59
  /**
@@ -6,7 +6,7 @@ import { createWriteStream } from 'fs';
6
6
  import { mkdir } from 'fs/promises';
7
7
  import { dirname } from 'path';
8
8
  import { Readable } from 'stream';
9
- import { finished } from 'stream/promises';
9
+ import { pipeline } from 'stream/promises';
10
10
 
11
11
  import type { ReadOnlyFileStore } from './interface.js';
12
12
 
@@ -43,11 +43,14 @@ export class HttpFileStore implements ReadOnlyFileStore {
43
43
  public async download(pathOrUrl: string, destPath: string): Promise<void> {
44
44
  const url = this.getUrl(pathOrUrl);
45
45
  try {
46
+ this.log.debug(`Downloading file from ${url} to ${destPath}`);
46
47
  const response = await this.fetch<Readable>({ url, method: 'GET', responseType: 'stream' });
48
+ this.log.debug(`Response ${response.status} (${response.statusText}) from ${url}, writing to ${destPath}`);
47
49
  await mkdir(dirname(destPath), { recursive: true });
48
- await finished(response.data.pipe(createWriteStream(destPath)));
50
+ await pipeline(response.data, createWriteStream(destPath));
51
+ this.log.debug(`Download of ${url} to ${destPath} complete`);
49
52
  } catch (error) {
50
- throw new Error(`Error fetching file from ${url}: ${error instanceof Error ? error.message : String(error)}`);
53
+ throw new Error(`Error fetching file from ${url}`, { cause: error });
51
54
  }
52
55
  }
53
56
 
@@ -12,7 +12,7 @@ import { mkdir, mkdtemp, stat, unlink } from 'fs/promises';
12
12
  import { tmpdir } from 'os';
13
13
  import { basename, dirname, join } from 'path';
14
14
  import { Readable } from 'stream';
15
- import { finished } from 'stream/promises';
15
+ import { pipeline } from 'stream/promises';
16
16
  import { createGzip } from 'zlib';
17
17
 
18
18
  import type { FileStore, FileStoreSaveOptions } from './interface.js';
@@ -88,11 +88,8 @@ export class S3FileStore implements FileStore {
88
88
  // Pre-gzip to a temp file so we know the exact length for R2/S3 headers
89
89
  const tmpDir = await mkdtemp(join(tmpdir(), 's3-upload-'));
90
90
  const gzPath = join(tmpDir, `${basename(srcPath)}.gz`);
91
- const source = createReadStream(srcPath);
92
- const gz = createGzip();
93
- const out = createWriteStream(gzPath);
94
91
  try {
95
- await finished(source.pipe(gz).pipe(out));
92
+ await pipeline(createReadStream(srcPath), createGzip(), createWriteStream(gzPath));
96
93
  const st = await stat(gzPath);
97
94
  contentLength = st.size;
98
95
  bodyPath = gzPath;
@@ -144,8 +141,7 @@ export class S3FileStore implements FileStore {
144
141
  const { bucket, key } = this.getBucketAndKey(pathOrUrlStr);
145
142
  const out: GetObjectCommandOutput = await this.s3.send(new GetObjectCommand({ Bucket: bucket, Key: key }));
146
143
  await mkdir(dirname(destPath), { recursive: true });
147
- const write = createWriteStream(destPath);
148
- await finished((out.Body as Readable).pipe(write));
144
+ await pipeline(out.Body as Readable, createWriteStream(destPath));
149
145
  }
150
146
 
151
147
  public async exists(pathOrUrlStr: string): Promise<boolean> {
package/src/gas/gas.ts CHANGED
@@ -48,6 +48,20 @@ export class Gas {
48
48
  return new Gas(fields.daGas ?? 0, fields.l2Gas ?? 0);
49
49
  }
50
50
 
51
+ /**
52
+ * Creates a Gas instance from a plain object without Zod validation.
53
+ * This method is optimized for performance and skips validation, making it suitable
54
+ * for deserializing trusted data (e.g., from C++ via MessagePack).
55
+ * @param obj - Plain object containing Gas fields
56
+ * @returns A Gas instance
57
+ */
58
+ static fromPlainObject(obj: any): Gas {
59
+ if (obj instanceof Gas) {
60
+ return obj;
61
+ }
62
+ return Gas.from(obj);
63
+ }
64
+
51
65
  static empty() {
52
66
  return new Gas(0, 0);
53
67
  }
@@ -65,6 +65,20 @@ export class GasFees {
65
65
  return new GasFees(fields.feePerDaGas, fields.feePerL2Gas);
66
66
  }
67
67
 
68
+ /**
69
+ * Creates a GasFees instance from a plain object without Zod validation.
70
+ * This method is optimized for performance and skips validation, making it suitable
71
+ * for deserializing trusted data (e.g., from C++ via MessagePack).
72
+ * @param obj - Plain object containing GasFees fields
73
+ * @returns A GasFees instance
74
+ */
75
+ static fromPlainObject(obj: any): GasFees {
76
+ if (obj instanceof GasFees) {
77
+ return obj;
78
+ }
79
+ return GasFees.from(obj);
80
+ }
81
+
68
82
  static random() {
69
83
  return new GasFees(Math.floor(Math.random() * 1e9), Math.floor(Math.random() * 1e9));
70
84
  }
@@ -54,6 +54,25 @@ export class GasSettings {
54
54
  );
55
55
  }
56
56
 
57
+ /**
58
+ * Creates a GasSettings instance from a plain object without Zod validation.
59
+ * This method is optimized for performance and skips validation, making it suitable
60
+ * for deserializing trusted data (e.g., from C++ via MessagePack).
61
+ * @param obj - Plain object containing GasSettings fields
62
+ * @returns A GasSettings instance
63
+ */
64
+ static fromPlainObject(obj: any): GasSettings {
65
+ if (obj instanceof GasSettings) {
66
+ return obj;
67
+ }
68
+ return new GasSettings(
69
+ Gas.fromPlainObject(obj.gasLimits),
70
+ Gas.fromPlainObject(obj.teardownGasLimits),
71
+ GasFees.fromPlainObject(obj.maxFeesPerGas),
72
+ GasFees.fromPlainObject(obj.maxPriorityFeesPerGas),
73
+ );
74
+ }
75
+
57
76
  clone() {
58
77
  return new GasSettings(
59
78
  this.gasLimits.clone(),
@@ -1,4 +1,4 @@
1
- import type { Gas } from './gas.js';
1
+ import { Gas } from './gas.js';
2
2
 
3
3
  export interface GasUsed {
4
4
  /**
@@ -21,3 +21,24 @@ export interface GasUsed {
21
21
  */
22
22
  billedGas: Gas;
23
23
  }
24
+
25
+ /**
26
+ * Creates a GasUsed from a plain object without Zod validation.
27
+ * This method is optimized for performance and skips validation, making it suitable
28
+ * for deserializing trusted data (e.g., from C++ via MessagePack).
29
+ * @param obj - Plain object containing GasUsed fields
30
+ * @returns A GasUsed object
31
+ */
32
+ export function gasUsedFromPlainObject(obj: any): GasUsed {
33
+ return {
34
+ totalGas: Gas.fromPlainObject(obj.totalGas),
35
+ publicGas: Gas.fromPlainObject(obj.publicGas),
36
+ teardownGas: Gas.fromPlainObject(obj.teardownGas),
37
+ billedGas: Gas.fromPlainObject(obj.billedGas),
38
+ };
39
+ }
40
+
41
+ // Export as a namespace to match the pattern
42
+ export const GasUsed = {
43
+ fromPlainObject: gasUsedFromPlainObject,
44
+ };
@@ -56,6 +56,8 @@ export interface SequencerConfig {
56
56
  broadcastInvalidBlockProposal?: boolean;
57
57
  /** Inject a fake attestation (for testing only) */
58
58
  injectFakeAttestation?: boolean;
59
+ /** Whether to run in fisherman mode: builds blocks on every slot for validation without publishing */
60
+ fishermanMode?: boolean;
59
61
  /** Shuffle attestation ordering to create invalid ordering (for testing only) */
60
62
  shuffleAttestationOrdering?: boolean;
61
63
  }
@@ -83,5 +85,6 @@ export const SequencerConfigSchema = z.object({
83
85
  secondsBeforeInvalidatingBlockAsNonCommitteeMember: z.number(),
84
86
  broadcastInvalidBlockProposal: z.boolean().optional(),
85
87
  injectFakeAttestation: z.boolean().optional(),
88
+ fishermanMode: z.boolean().optional(),
86
89
  shuffleAttestationOrdering: z.boolean().optional(),
87
90
  }) satisfies ZodFor<SequencerConfig>;
@@ -41,6 +41,9 @@ export interface ValidatorClientConfig {
41
41
 
42
42
  /** Whether to always reexecute block proposals, even for non-validator nodes or when out of the currnet committee */
43
43
  alwaysReexecuteBlockProposals?: boolean;
44
+
45
+ /** Whether to run in fisherman mode: validates all proposals and attestations but does not broadcast attestations or participate in consensus */
46
+ fishermanMode?: boolean;
44
47
  }
45
48
 
46
49
  export type ValidatorClientFullConfig = ValidatorClientConfig &
@@ -61,6 +64,7 @@ export const ValidatorClientConfigSchema = z.object({
61
64
  validatorReexecute: z.boolean(),
62
65
  validatorReexecuteDeadlineMs: z.number().min(0),
63
66
  alwaysReexecuteBlockProposals: z.boolean().optional(),
67
+ fishermanMode: z.boolean().optional(),
64
68
  }) satisfies ZodFor<Omit<ValidatorClientConfig, 'validatorPrivateKeys'>>;
65
69
 
66
70
  export const ValidatorClientFullConfigSchema = ValidatorClientConfigSchema.extend({
@@ -112,6 +112,30 @@ export class PrivateToAvmAccumulatedData {
112
112
  );
113
113
  }
114
114
 
115
+ /**
116
+ * Creates a PrivateToAvmAccumulatedData instance from a plain object without Zod validation.
117
+ * This method is optimized for performance and skips validation, making it suitable
118
+ * for deserializing trusted data (e.g., from C++ via MessagePack).
119
+ * @param obj - Plain object containing PrivateToAvmAccumulatedData fields
120
+ * @returns A PrivateToAvmAccumulatedData instance
121
+ */
122
+ static fromPlainObject(obj: any): PrivateToAvmAccumulatedData {
123
+ return new PrivateToAvmAccumulatedData(
124
+ assertLength(
125
+ obj.noteHashes.map((h: any) => Fr.fromPlainObject(h)),
126
+ MAX_NOTE_HASHES_PER_TX,
127
+ ),
128
+ assertLength(
129
+ obj.nullifiers.map((n: any) => Fr.fromPlainObject(n)),
130
+ MAX_NULLIFIERS_PER_TX,
131
+ ),
132
+ assertLength(
133
+ obj.l2ToL1Msgs.map((m: any) => ScopedL2ToL1Message.fromPlainObject(m)),
134
+ MAX_L2_TO_L1_MSGS_PER_TX,
135
+ ),
136
+ );
137
+ }
138
+
115
139
  [inspect.custom]() {
116
140
  return `PrivateToAvmAccumulatedData {
117
141
  noteHashes: [${this.noteHashes
@@ -184,6 +208,17 @@ export class PrivateToAvmAccumulatedDataArrayLengths {
184
208
  return new PrivateToAvmAccumulatedDataArrayLengths(0, 0, 0);
185
209
  }
186
210
 
211
+ /**
212
+ * Creates a PrivateToAvmAccumulatedDataArrayLengths instance from a plain object without Zod validation.
213
+ * This method is optimized for performance and skips validation, making it suitable
214
+ * for deserializing trusted data (e.g., from C++ via MessagePack).
215
+ * @param obj - Plain object containing PrivateToAvmAccumulatedDataArrayLengths fields
216
+ * @returns A PrivateToAvmAccumulatedDataArrayLengths instance
217
+ */
218
+ static fromPlainObject(obj: any): PrivateToAvmAccumulatedDataArrayLengths {
219
+ return new PrivateToAvmAccumulatedDataArrayLengths(obj.noteHashes, obj.nullifiers, obj.l2ToL1Msgs);
220
+ }
221
+
187
222
  [inspect.custom]() {
188
223
  return `PrivateToAvmAccumulatedDataArrayLengths {
189
224
  noteHashes: ${this.noteHashes},
@@ -97,6 +97,22 @@ export class PublicCallRequest {
97
97
  return new PublicCallRequest(AztecAddress.ZERO, AztecAddress.ZERO, false, Fr.ZERO);
98
98
  }
99
99
 
100
+ /**
101
+ * Creates a PublicCallRequest instance from a plain object without Zod validation.
102
+ * This method is optimized for performance and skips validation, making it suitable
103
+ * for deserializing trusted data (e.g., from C++ via MessagePack).
104
+ * @param obj - Plain object containing PublicCallRequest fields
105
+ * @returns A PublicCallRequest instance
106
+ */
107
+ static fromPlainObject(obj: any): PublicCallRequest {
108
+ return new PublicCallRequest(
109
+ AztecAddress.fromPlainObject(obj.msgSender),
110
+ AztecAddress.fromPlainObject(obj.contractAddress),
111
+ obj.isStaticCall,
112
+ Fr.fromPlainObject(obj.calldataHash),
113
+ );
114
+ }
115
+
100
116
  isEmpty(): boolean {
101
117
  return (
102
118
  this.msgSender.isZero() && this.contractAddress.isZero() && !this.isStaticCall && this.calldataHash.isEmpty()
@@ -180,6 +196,17 @@ export class PublicCallRequestArrayLengths {
180
196
  return new PublicCallRequestArrayLengths(0, 0, false);
181
197
  }
182
198
 
199
+ /**
200
+ * Creates a PublicCallRequestArrayLengths instance from a plain object without Zod validation.
201
+ * This method is optimized for performance and skips validation, making it suitable
202
+ * for deserializing trusted data (e.g., from C++ via MessagePack).
203
+ * @param obj - Plain object containing PublicCallRequestArrayLengths fields
204
+ * @returns A PublicCallRequestArrayLengths instance
205
+ */
206
+ static fromPlainObject(obj: any): PublicCallRequestArrayLengths {
207
+ return new PublicCallRequestArrayLengths(obj.setupCalls, obj.appLogicCalls, obj.teardownCall);
208
+ }
209
+
183
210
  [inspect.custom]() {
184
211
  return `PublicCallRequestArrayLengths {
185
212
  setupCalls: ${this.setupCalls}
@@ -52,6 +52,25 @@ export class PublicKeys {
52
52
  );
53
53
  }
54
54
 
55
+ /**
56
+ * Creates a PublicKeys from a plain object without Zod validation.
57
+ * This method is optimized for performance and skips validation, making it suitable
58
+ * for deserializing trusted data (e.g., from C++ via MessagePack).
59
+ * @param obj - Plain object containing PublicKeys fields
60
+ * @returns A PublicKeys instance
61
+ */
62
+ static fromPlainObject(obj: any): PublicKeys {
63
+ if (obj instanceof PublicKeys) {
64
+ return obj;
65
+ }
66
+ return new PublicKeys(
67
+ Point.fromPlainObject(obj.masterNullifierPublicKey),
68
+ Point.fromPlainObject(obj.masterIncomingViewingPublicKey),
69
+ Point.fromPlainObject(obj.masterOutgoingViewingPublicKey),
70
+ Point.fromPlainObject(obj.masterTaggingPublicKey),
71
+ );
72
+ }
73
+
55
74
  hash() {
56
75
  return this.isEmpty()
57
76
  ? Fr.ZERO
@@ -29,6 +29,20 @@ export class ContractClassLogFields {
29
29
  .transform(({ fields }) => new ContractClassLogFields(fields));
30
30
  }
31
31
 
32
+ /**
33
+ * Creates a ContractClassLogFields from a plain object without Zod validation.
34
+ * This method is optimized for performance and skips validation, making it suitable
35
+ * for deserializing trusted data (e.g., from C++ via MessagePack).
36
+ * @param obj - Plain object containing ContractClassLogFields fields
37
+ * @returns A ContractClassLogFields instance
38
+ */
39
+ static fromPlainObject(obj: any): ContractClassLogFields {
40
+ if (obj instanceof ContractClassLogFields) {
41
+ return obj;
42
+ }
43
+ return new ContractClassLogFields(obj.fields.map((f: any) => Fr.fromPlainObject(f)));
44
+ }
45
+
32
46
  toFields(): Fr[] {
33
47
  return this.fields;
34
48
  }
@@ -191,6 +205,24 @@ export class ContractClassLog {
191
205
  .transform(ContractClassLog.from);
192
206
  }
193
207
 
208
+ /**
209
+ * Creates a ContractClassLog from a plain object without Zod validation.
210
+ * This method is optimized for performance and skips validation, making it suitable
211
+ * for deserializing trusted data (e.g., from C++ via MessagePack).
212
+ * @param obj - Plain object containing ContractClassLog fields
213
+ * @returns A ContractClassLog instance
214
+ */
215
+ static fromPlainObject(obj: any): ContractClassLog {
216
+ if (obj instanceof ContractClassLog) {
217
+ return obj;
218
+ }
219
+ return new ContractClassLog(
220
+ AztecAddress.fromPlainObject(obj.contractAddress),
221
+ ContractClassLogFields.fromPlainObject(obj.fields),
222
+ obj.emittedLength,
223
+ );
224
+ }
225
+
194
226
  [inspect.custom](): string {
195
227
  return `ContractClassLog {
196
228
  contractAddress: ${this.contractAddress.toString()},
@@ -1,4 +1,4 @@
1
- import type { Fr } from '@aztec/foundation/fields';
1
+ import { Fr } from '@aztec/foundation/fields';
2
2
  import { type LogLevel, LogLevels } from '@aztec/foundation/log';
3
3
  import { type ZodFor, schemas } from '@aztec/foundation/schemas';
4
4
 
@@ -29,4 +29,23 @@ export class DebugLog {
29
29
  ({ contractAddress, level, message, fields }) => new DebugLog(contractAddress, level, message, fields),
30
30
  );
31
31
  }
32
+
33
+ /**
34
+ * Creates a DebugLog from a plain object without Zod validation.
35
+ * This method is optimized for performance and skips validation, making it suitable
36
+ * for deserializing trusted data (e.g., from C++ via MessagePack).
37
+ * @param obj - Plain object containing DebugLog fields
38
+ * @returns A DebugLog instance
39
+ */
40
+ static fromPlainObject(obj: any): DebugLog {
41
+ if (obj instanceof DebugLog) {
42
+ return obj;
43
+ }
44
+ return new DebugLog(
45
+ AztecAddress.fromPlainObject(obj.contractAddress),
46
+ obj.level,
47
+ obj.message,
48
+ obj.fields.map((f: any) => Fr.fromPlainObject(f)),
49
+ );
50
+ }
32
51
  }
@@ -92,6 +92,23 @@ export class PrivateLog {
92
92
  .transform(({ fields, emittedLength }) => PrivateLog.fromFields(fields.concat(new Fr(emittedLength))));
93
93
  }
94
94
 
95
+ /**
96
+ * Creates a PrivateLog from a plain object without Zod validation.
97
+ * This method is optimized for performance and skips validation, making it suitable
98
+ * for deserializing trusted data (e.g., from C++ via MessagePack).
99
+ * @param obj - Plain object containing PrivateLog fields
100
+ * @returns A PrivateLog instance
101
+ */
102
+ static fromPlainObject(obj: any): PrivateLog {
103
+ if (obj instanceof PrivateLog) {
104
+ return obj;
105
+ }
106
+ return new PrivateLog(
107
+ obj.fields.map((f: any) => Fr.fromPlainObject(f)),
108
+ obj.emittedLength,
109
+ );
110
+ }
111
+
95
112
  equals(other: PrivateLog) {
96
113
  return this.fields.every((field, i) => field.equals(other.fields[i])) && this.emittedLength === other.emittedLength;
97
114
  }
@@ -99,6 +99,20 @@ export class FlatPublicLogs {
99
99
  return new FlatPublicLogs(0, Array(FLAT_PUBLIC_LOGS_PAYLOAD_LENGTH).fill(Fr.ZERO));
100
100
  }
101
101
 
102
+ /**
103
+ * Creates a FlatPublicLogs instance from a plain object without Zod validation.
104
+ * This method is optimized for performance and skips validation, making it suitable
105
+ * for deserializing trusted data (e.g., from C++ via MessagePack).
106
+ * @param obj - Plain object containing FlatPublicLogs fields
107
+ * @returns A FlatPublicLogs instance
108
+ */
109
+ static fromPlainObject(obj: any): FlatPublicLogs {
110
+ return new FlatPublicLogs(
111
+ obj.length,
112
+ obj.payload.map((p: any) => Fr.fromPlainObject(p)),
113
+ );
114
+ }
115
+
102
116
  isEmpty() {
103
117
  return this.length === 0;
104
118
  }
@@ -30,6 +30,17 @@ export class L2ToL1Message {
30
30
  return new L2ToL1Message(EthAddress.ZERO, Fr.zero());
31
31
  }
32
32
 
33
+ /**
34
+ * Creates an L2ToL1Message instance from a plain object without Zod validation.
35
+ * This method is optimized for performance and skips validation, making it suitable
36
+ * for deserializing trusted data (e.g., from C++ via MessagePack).
37
+ * @param obj - Plain object containing L2ToL1Message fields
38
+ * @returns An L2ToL1Message instance
39
+ */
40
+ static fromPlainObject(obj: any): L2ToL1Message {
41
+ return new L2ToL1Message(EthAddress.fromPlainObject(obj.recipient), Fr.fromPlainObject(obj.content));
42
+ }
43
+
33
44
  /**
34
45
  * Checks if another L2ToL1Message is equal to this instance.
35
46
  * @param other Another L2ToL1Message instance to compare with.
@@ -149,6 +160,20 @@ export class ScopedL2ToL1Message {
149
160
  return new ScopedL2ToL1Message(L2ToL1Message.empty(), AztecAddress.ZERO);
150
161
  }
151
162
 
163
+ /**
164
+ * Creates a ScopedL2ToL1Message instance from a plain object without Zod validation.
165
+ * This method is optimized for performance and skips validation, making it suitable
166
+ * for deserializing trusted data (e.g., from C++ via MessagePack).
167
+ * @param obj - Plain object containing ScopedL2ToL1Message fields
168
+ * @returns A ScopedL2ToL1Message instance
169
+ */
170
+ static fromPlainObject(obj: any): ScopedL2ToL1Message {
171
+ return new ScopedL2ToL1Message(
172
+ L2ToL1Message.fromPlainObject(obj.message),
173
+ AztecAddress.fromPlainObject(obj.contractAddress),
174
+ );
175
+ }
176
+
152
177
  isEmpty(): boolean {
153
178
  return this.message.isEmpty() && this.contractAddress.isZero();
154
179
  }
package/src/noir/index.ts CHANGED
@@ -11,8 +11,7 @@ import type {
11
11
  export const AZTEC_PRIVATE_ATTRIBUTE = 'abi_private';
12
12
  export const AZTEC_PUBLIC_ATTRIBUTE = 'abi_public';
13
13
  export const AZTEC_UTILITY_ATTRIBUTE = 'abi_utility';
14
- // TODO(F-142): Fix the naming here.
15
- export const AZTEC_INTERNAL_ATTRIBUTE = 'abi_only_self';
14
+ export const AZTEC_ONLY_SELF_ATTRIBUTE = 'abi_only_self';
16
15
  export const AZTEC_INITIALIZER_ATTRIBUTE = 'abi_initializer';
17
16
  export const AZTEC_VIEW_ATTRIBUTE = 'abi_view';
18
17
 
@@ -59,6 +59,9 @@ import {
59
59
  AvmCircuitPublicInputs,
60
60
  AvmCommitCheckpointHint,
61
61
  AvmContractClassHint,
62
+ AvmContractDBCommitCheckpointHint,
63
+ AvmContractDBCreateCheckpointHint,
64
+ AvmContractDBRevertCheckpointHint,
62
65
  AvmContractInstanceHint,
63
66
  AvmCreateCheckpointHint,
64
67
  AvmDebugFunctionNameHint,
@@ -1364,6 +1367,30 @@ export function makeAvmCheckpointActionRevertCheckpointHint(seed = 0): AvmRevert
1364
1367
  );
1365
1368
  }
1366
1369
 
1370
+ export function makeAvmContractDBCheckpointActionCreateCheckpointHint(seed = 0): AvmContractDBCreateCheckpointHint {
1371
+ return new AvmContractDBCreateCheckpointHint(
1372
+ /*actionCounter=*/ seed,
1373
+ /*oldCheckpointId=*/ seed + 1,
1374
+ /*newCheckpointId=*/ seed + 2,
1375
+ );
1376
+ }
1377
+
1378
+ export function makeAvmContractDBCheckpointActionCommitCheckpointHint(seed = 0): AvmContractDBCommitCheckpointHint {
1379
+ return new AvmContractDBCommitCheckpointHint(
1380
+ /*actionCounter=*/ seed,
1381
+ /*oldCheckpointId=*/ seed + 1,
1382
+ /*newCheckpointId=*/ seed + 2,
1383
+ );
1384
+ }
1385
+
1386
+ export function makeAvmContractDBCheckpointActionRevertCheckpointHint(seed = 0): AvmContractDBRevertCheckpointHint {
1387
+ return new AvmContractDBRevertCheckpointHint(
1388
+ /*actionCounter=*/ seed,
1389
+ /*oldCheckpointId=*/ seed + 1,
1390
+ /*newCheckpointId=*/ seed + 2,
1391
+ );
1392
+ }
1393
+
1367
1394
  /**
1368
1395
  * Makes arbitrary AvmContractInstanceHint.
1369
1396
  * @param seed - The seed to use for generating the state reference.
@@ -1479,6 +1506,21 @@ export async function makeAvmExecutionHints(
1479
1506
  contractClasses: makeArray(baseLength + 5, makeAvmContractClassHint, seed + 0x4900),
1480
1507
  bytecodeCommitments: await makeArrayAsync(baseLength + 5, makeAvmBytecodeCommitmentHint, seed + 0x4900),
1481
1508
  debugFunctionNames: makeArray(baseLength + 5, makeAvmDebugFunctionNameHint, seed + 0x4a00),
1509
+ contractDBCreateCheckpointHints: makeArray(
1510
+ baseLength + 5,
1511
+ makeAvmContractDBCheckpointActionCreateCheckpointHint,
1512
+ seed + 0x5900,
1513
+ ),
1514
+ contractDBCommitCheckpointHints: makeArray(
1515
+ baseLength + 5,
1516
+ makeAvmContractDBCheckpointActionCommitCheckpointHint,
1517
+ seed + 0x5b00,
1518
+ ),
1519
+ contractDBRevertCheckpointHints: makeArray(
1520
+ baseLength + 5,
1521
+ makeAvmContractDBCheckpointActionRevertCheckpointHint,
1522
+ seed + 0x5d00,
1523
+ ),
1482
1524
  startingTreeRoots: makeTreeSnapshots(seed + 0x4900),
1483
1525
  getSiblingPathHints: makeArray(baseLength + 5, makeAvmGetSiblingPathHint, seed + 0x4b00),
1484
1526
  getPreviousValueIndexHints: makeArray(baseLength + 5, makeAvmGetPreviousValueIndexHint, seed + 0x4d00),
@@ -1514,6 +1556,9 @@ export async function makeAvmExecutionHints(
1514
1556
  fields.contractClasses,
1515
1557
  fields.bytecodeCommitments,
1516
1558
  fields.debugFunctionNames,
1559
+ fields.contractDBCreateCheckpointHints,
1560
+ fields.contractDBCommitCheckpointHints,
1561
+ fields.contractDBRevertCheckpointHints,
1517
1562
  fields.startingTreeRoots,
1518
1563
  fields.getSiblingPathHints,
1519
1564
  fields.getPreviousValueIndexHints,
@@ -91,6 +91,17 @@ export class AppendOnlyTreeSnapshot {
91
91
  return new AppendOnlyTreeSnapshot(Fr.ZERO, 0);
92
92
  }
93
93
 
94
+ /**
95
+ * Creates an AppendOnlyTreeSnapshot instance from a plain object without Zod validation.
96
+ * This method is optimized for performance and skips validation, making it suitable
97
+ * for deserializing trusted data (e.g., from C++ via MessagePack).
98
+ * @param obj - Plain object containing AppendOnlyTreeSnapshot fields
99
+ * @returns An AppendOnlyTreeSnapshot instance
100
+ */
101
+ static fromPlainObject(obj: any): AppendOnlyTreeSnapshot {
102
+ return new AppendOnlyTreeSnapshot(Fr.fromPlainObject(obj.root), obj.nextAvailableLeafIndex);
103
+ }
104
+
94
105
  isEmpty(): boolean {
95
106
  return this.root.isZero() && this.nextAvailableLeafIndex === 0;
96
107
  }
@@ -36,6 +36,24 @@ export class NullifierLeafPreimage implements IndexedTreeLeafPreimage {
36
36
  .transform(({ leaf, nextKey, nextIndex }) => new NullifierLeafPreimage(leaf, nextKey, nextIndex));
37
37
  }
38
38
 
39
+ /**
40
+ * Creates a NullifierLeafPreimage from a plain object without Zod validation.
41
+ * This method is optimized for performance and skips validation, making it suitable
42
+ * for deserializing trusted data (e.g., from C++ via MessagePack).
43
+ * @param obj - Plain object containing NullifierLeafPreimage fields
44
+ * @returns A NullifierLeafPreimage instance
45
+ */
46
+ static fromPlainObject(obj: any): NullifierLeafPreimage {
47
+ if (obj instanceof NullifierLeafPreimage) {
48
+ return obj;
49
+ }
50
+ return new NullifierLeafPreimage(
51
+ NullifierLeaf.fromPlainObject(obj.leaf),
52
+ Fr.fromPlainObject(obj.nextKey),
53
+ typeof obj.nextIndex === 'bigint' ? obj.nextIndex : BigInt(obj.nextIndex),
54
+ );
55
+ }
56
+
39
57
  static get leafSchema() {
40
58
  return NullifierLeaf.schema;
41
59
  }
@@ -157,4 +175,18 @@ export class NullifierLeaf implements IndexedTreeLeaf {
157
175
  static get schema() {
158
176
  return z.object({ nullifier: schemas.Fr }).transform(({ nullifier }) => new NullifierLeaf(nullifier));
159
177
  }
178
+
179
+ /**
180
+ * Creates a NullifierLeaf from a plain object without Zod validation.
181
+ * This method is optimized for performance and skips validation, making it suitable
182
+ * for deserializing trusted data (e.g., from C++ via MessagePack).
183
+ * @param obj - Plain object containing NullifierLeaf fields
184
+ * @returns A NullifierLeaf instance
185
+ */
186
+ static fromPlainObject(obj: any): NullifierLeaf {
187
+ if (obj instanceof NullifierLeaf) {
188
+ return obj;
189
+ }
190
+ return new NullifierLeaf(Fr.fromPlainObject(obj.nullifier));
191
+ }
160
192
  }