@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
@@ -36,6 +36,24 @@ export class PublicDataTreeLeafPreimage implements IndexedTreeLeafPreimage {
36
36
  .transform(({ leaf, nextKey, nextIndex }) => new PublicDataTreeLeafPreimage(leaf, nextKey, nextIndex));
37
37
  }
38
38
 
39
+ /**
40
+ * Creates a PublicDataTreeLeafPreimage 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 PublicDataTreeLeafPreimage fields
44
+ * @returns A PublicDataTreeLeafPreimage instance
45
+ */
46
+ static fromPlainObject(obj: any): PublicDataTreeLeafPreimage {
47
+ if (obj instanceof PublicDataTreeLeafPreimage) {
48
+ return obj;
49
+ }
50
+ return new PublicDataTreeLeafPreimage(
51
+ PublicDataTreeLeaf.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 PublicDataTreeLeaf.schema;
41
59
  }
@@ -172,4 +190,18 @@ export class PublicDataTreeLeaf implements IndexedTreeLeaf {
172
190
  })
173
191
  .transform(({ slot, value }) => new PublicDataTreeLeaf(slot, value));
174
192
  }
193
+
194
+ /**
195
+ * Creates a PublicDataTreeLeaf from a plain object without Zod validation.
196
+ * This method is optimized for performance and skips validation, making it suitable
197
+ * for deserializing trusted data (e.g., from C++ via MessagePack).
198
+ * @param obj - Plain object containing PublicDataTreeLeaf fields
199
+ * @returns A PublicDataTreeLeaf instance
200
+ */
201
+ static fromPlainObject(obj: any): PublicDataTreeLeaf {
202
+ if (obj instanceof PublicDataTreeLeaf) {
203
+ return obj;
204
+ }
205
+ return new PublicDataTreeLeaf(Fr.fromPlainObject(obj.slot), Fr.fromPlainObject(obj.value));
206
+ }
175
207
  }
@@ -0,0 +1,60 @@
1
+ import type { FunctionCall } from '../abi/function_call.js';
2
+ import type { AuthWitness } from '../auth_witness/auth_witness.js';
3
+ import { AztecAddress } from '../aztec-address/index.js';
4
+ import type { Capsule } from './capsule.js';
5
+ import type { HashedValues } from './hashed_values.js';
6
+
7
+ /**
8
+ * Represents data necessary to perform an action in the network successfully.
9
+ * This class can be considered Aztec's "minimal execution unit".
10
+ * */
11
+ export class ExecutionPayload {
12
+ public constructor(
13
+ /** The function calls to be executed. */
14
+ public calls: FunctionCall[],
15
+ /** Any transient auth witnesses needed for this execution */
16
+ public authWitnesses: AuthWitness[],
17
+ /** Data passed through an oracle for this execution. */
18
+ public capsules: Capsule[],
19
+ /** Extra hashed values to be injected in the execution cache */
20
+ public extraHashedArgs: HashedValues[] = [],
21
+ /**
22
+ * The address that is paying for the fee in this execution payload (if any).
23
+ * If undefined, the wallet software executing the payload will have to add a fee payment method
24
+ */
25
+ public feePayer?: AztecAddress,
26
+ ) {}
27
+
28
+ static empty() {
29
+ return new ExecutionPayload([], [], [], [], undefined);
30
+ }
31
+ }
32
+
33
+ /**
34
+ * Merges an array ExecutionPayloads combining their calls, authWitnesses, capsules and extraArgHashes.
35
+ * @throws Error if multiple payloads have different fee payers set
36
+ */
37
+ export function mergeExecutionPayloads(requests: ExecutionPayload[]): ExecutionPayload {
38
+ const calls = requests.map(r => r.calls).flat();
39
+ const combinedAuthWitnesses = requests.map(r => r.authWitnesses ?? []).flat();
40
+ const combinedCapsules = requests.map(r => r.capsules ?? []).flat();
41
+ const combinedExtraHashedArgs = requests.map(r => r.extraHashedArgs ?? []).flat();
42
+
43
+ // Collect unique fee payers
44
+ const uniqueFeePayers = new Set(
45
+ requests
46
+ .map(r => r.feePayer)
47
+ .filter((fp): fp is AztecAddress => fp !== undefined)
48
+ .map(fp => fp.toString()),
49
+ );
50
+
51
+ if (uniqueFeePayers.size > 1) {
52
+ throw new Error(
53
+ `Cannot merge execution payloads with different fee payers. Found: ${Array.from(uniqueFeePayers).join(', ')}`,
54
+ );
55
+ }
56
+
57
+ const feePayer = uniqueFeePayers.size === 1 ? AztecAddress.fromString(Array.from(uniqueFeePayers)[0]) : undefined;
58
+
59
+ return new ExecutionPayload(calls, combinedAuthWitnesses, combinedCapsules, combinedExtraHashedArgs, feePayer);
60
+ }
@@ -65,6 +65,26 @@ export class GlobalVariables {
65
65
  return new GlobalVariables(...GlobalVariables.getFields(fields));
66
66
  }
67
67
 
68
+ /**
69
+ * Creates a GlobalVariables 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 GlobalVariables fields
73
+ * @returns A GlobalVariables instance
74
+ */
75
+ static fromPlainObject(obj: any): GlobalVariables {
76
+ return new GlobalVariables(
77
+ Fr.fromPlainObject(obj.chainId),
78
+ Fr.fromPlainObject(obj.version),
79
+ obj.blockNumber,
80
+ Fr.fromPlainObject(obj.slotNumber),
81
+ typeof obj.timestamp === 'bigint' ? obj.timestamp : BigInt(obj.timestamp),
82
+ EthAddress.fromPlainObject(obj.coinbase),
83
+ AztecAddress.fromPlainObject(obj.feeRecipient),
84
+ GasFees.fromPlainObject(obj.gasFees),
85
+ );
86
+ }
87
+
68
88
  static empty(fields: Partial<FieldsOf<GlobalVariables>> = {}): GlobalVariables {
69
89
  return GlobalVariables.from({
70
90
  blockNumber: 0,
package/src/tx/index.ts CHANGED
@@ -31,3 +31,4 @@ export * from './indexed_tx_effect.js';
31
31
  export * from './offchain_effect.js';
32
32
  export * from './profiling.js';
33
33
  export * from './protocol_contracts.js';
34
+ export * from './execution_payload.js';
@@ -1,12 +1,10 @@
1
1
  import { Fr } from '@aztec/foundation/fields';
2
- import { type ZodFor, optional } from '@aztec/foundation/schemas';
2
+ import { type ZodFor, optional, schemas } from '@aztec/foundation/schemas';
3
3
 
4
4
  import { z } from 'zod';
5
5
 
6
- import type { AbiDecoded } from '../abi/decoder.js';
7
6
  import type { AztecNode } from '../interfaces/aztec-node.js';
8
7
  import { type PrivateExecutionStep, PrivateExecutionStepSchema } from '../kernel/private_kernel_prover_output.js';
9
- import { AbiDecodedSchema } from '../schemas/schemas.js';
10
8
 
11
9
  export type NodeStats = Partial<Record<keyof AztecNode, { times: number[] }>>;
12
10
 
@@ -127,21 +125,21 @@ export class TxProfileResult {
127
125
 
128
126
  export class UtilitySimulationResult {
129
127
  constructor(
130
- public result: AbiDecoded,
128
+ public result: Fr[],
131
129
  public stats?: SimulationStats,
132
130
  ) {}
133
131
 
134
132
  static get schema(): ZodFor<UtilitySimulationResult> {
135
133
  return z
136
134
  .object({
137
- result: AbiDecodedSchema,
135
+ result: z.array(schemas.Fr),
138
136
  stats: optional(SimulationStatsSchema),
139
137
  })
140
138
  .transform(({ result, stats }) => new UtilitySimulationResult(result, stats));
141
139
  }
142
140
 
143
141
  static random(): UtilitySimulationResult {
144
- return new UtilitySimulationResult(Fr.random().toBigInt(), {
142
+ return new UtilitySimulationResult([Fr.random()], {
145
143
  nodeRPCCalls: { getBlockHeader: { times: [1] } },
146
144
  timings: {
147
145
  sync: 1,
@@ -50,6 +50,22 @@ export class ProtocolContracts {
50
50
  return new ProtocolContracts(makeTuple(MAX_PROTOCOL_CONTRACTS, () => AztecAddress.zero()));
51
51
  }
52
52
 
53
+ /**
54
+ * Creates a ProtocolContracts instance from a plain object without Zod validation.
55
+ * This method is optimized for performance and skips validation, making it suitable
56
+ * for deserializing trusted data (e.g., from C++ via MessagePack).
57
+ * @param obj - Plain object containing ProtocolContracts fields
58
+ * @returns A ProtocolContracts instance
59
+ */
60
+ static fromPlainObject(obj: any): ProtocolContracts {
61
+ return new ProtocolContracts(
62
+ assertLength(
63
+ obj.derivedAddresses.map((addr: any) => AztecAddress.fromPlainObject(addr)),
64
+ MAX_PROTOCOL_CONTRACTS,
65
+ ),
66
+ );
67
+ }
68
+
53
69
  getSize() {
54
70
  return arraySerializedSizeOfNonEmpty(this.derivedAddresses);
55
71
  }
@@ -46,6 +46,23 @@ export class PublicCallRequestWithCalldata {
46
46
  return new PublicCallRequestWithCalldata(fields.request, fields.calldata);
47
47
  }
48
48
 
49
+ /**
50
+ * Creates a PublicCallRequestWithCalldata from a plain object without Zod validation.
51
+ * This method is optimized for performance and skips validation, making it suitable
52
+ * for deserializing trusted data (e.g., from C++ via MessagePack).
53
+ * @param obj - Plain object containing PublicCallRequestWithCalldata fields
54
+ * @returns A PublicCallRequestWithCalldata instance
55
+ */
56
+ static fromPlainObject(obj: any): PublicCallRequestWithCalldata {
57
+ if (obj instanceof PublicCallRequestWithCalldata) {
58
+ return obj;
59
+ }
60
+ return new PublicCallRequestWithCalldata(
61
+ PublicCallRequest.fromPlainObject(obj.request),
62
+ obj.calldata.map((f: any) => Fr.fromPlainObject(f)),
63
+ );
64
+ }
65
+
49
66
  toBuffer() {
50
67
  return serializeToBuffer(this.request, new Vector(this.calldata));
51
68
  }
@@ -91,6 +91,22 @@ export class TreeSnapshots {
91
91
  );
92
92
  }
93
93
 
94
+ /**
95
+ * Creates a TreeSnapshots 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 TreeSnapshots fields
99
+ * @returns A TreeSnapshots instance
100
+ */
101
+ static fromPlainObject(obj: any): TreeSnapshots {
102
+ return new TreeSnapshots(
103
+ AppendOnlyTreeSnapshot.fromPlainObject(obj.l1ToL2MessageTree),
104
+ AppendOnlyTreeSnapshot.fromPlainObject(obj.noteHashTree),
105
+ AppendOnlyTreeSnapshot.fromPlainObject(obj.nullifierTree),
106
+ AppendOnlyTreeSnapshot.fromPlainObject(obj.publicDataTree),
107
+ );
108
+ }
109
+
94
110
  isEmpty(): boolean {
95
111
  return (
96
112
  this.l1ToL2MessageTree.isEmpty() &&