@aztec/stdlib 0.87.6 → 1.0.0-nightly.20250604

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 (220) hide show
  1. package/dest/abi/abi.d.ts +3 -0
  2. package/dest/abi/abi.d.ts.map +1 -1
  3. package/dest/abi/abi.js +38 -0
  4. package/dest/avm/avm.d.ts +1188 -25
  5. package/dest/avm/avm.d.ts.map +1 -1
  6. package/dest/avm/avm.js +31 -14
  7. package/dest/avm/avm_accumulated_data.d.ts +77 -0
  8. package/dest/avm/avm_accumulated_data.d.ts.map +1 -1
  9. package/dest/avm/avm_accumulated_data.js +67 -0
  10. package/dest/avm/avm_circuit_public_inputs.d.ts +73 -3
  11. package/dest/avm/avm_circuit_public_inputs.d.ts.map +1 -1
  12. package/dest/avm/avm_circuit_public_inputs.js +19 -9
  13. package/dest/avm/avm_proving_request.d.ts +572 -0
  14. package/dest/avm/avm_proving_request.d.ts.map +1 -1
  15. package/dest/avm/gas.d.ts +7 -0
  16. package/dest/avm/gas.d.ts.map +1 -0
  17. package/dest/avm/gas.js +13 -0
  18. package/dest/avm/index.d.ts +1 -0
  19. package/dest/avm/index.d.ts.map +1 -1
  20. package/dest/avm/index.js +1 -0
  21. package/dest/block/body.d.ts +1 -1
  22. package/dest/block/body.d.ts.map +1 -1
  23. package/dest/block/body.js +2 -2
  24. package/dest/block/index.d.ts +1 -0
  25. package/dest/block/index.d.ts.map +1 -1
  26. package/dest/block/index.js +1 -0
  27. package/dest/block/l2_block.d.ts +3 -2
  28. package/dest/block/l2_block.d.ts.map +1 -1
  29. package/dest/block/l2_block.js +10 -5
  30. package/dest/block/l2_block_source.d.ts +9 -4
  31. package/dest/block/l2_block_source.d.ts.map +1 -1
  32. package/dest/block/l2_block_source.js +1 -0
  33. package/dest/block/proposal/committee_attestation.d.ts +34 -0
  34. package/dest/block/proposal/committee_attestation.d.ts.map +1 -0
  35. package/dest/block/proposal/committee_attestation.js +59 -0
  36. package/dest/block/proposal/index.d.ts +2 -0
  37. package/dest/block/proposal/index.d.ts.map +1 -0
  38. package/dest/block/proposal/index.js +1 -0
  39. package/dest/block/published_l2_block.d.ts +99 -69
  40. package/dest/block/published_l2_block.d.ts.map +1 -1
  41. package/dest/block/published_l2_block.js +38 -12
  42. package/dest/block/test/l2_tips_store_test_suite.js +1 -1
  43. package/dest/interfaces/archiver.js +2 -2
  44. package/dest/interfaces/aztec-node.d.ts +3 -8
  45. package/dest/interfaces/aztec-node.d.ts.map +1 -1
  46. package/dest/interfaces/aztec-node.js +3 -6
  47. package/dest/interfaces/block-builder.d.ts +41 -2
  48. package/dest/interfaces/block-builder.d.ts.map +1 -1
  49. package/dest/interfaces/block-builder.js +1 -1
  50. package/dest/interfaces/epoch-prover.d.ts +2 -2
  51. package/dest/interfaces/epoch-prover.d.ts.map +1 -1
  52. package/dest/interfaces/merkle_tree_operations.d.ts +14 -0
  53. package/dest/interfaces/merkle_tree_operations.d.ts.map +1 -1
  54. package/dest/interfaces/p2p.d.ts +6 -3
  55. package/dest/interfaces/p2p.d.ts.map +1 -1
  56. package/dest/interfaces/p2p.js +1 -2
  57. package/dest/interfaces/proving-job.d.ts +576 -4
  58. package/dest/interfaces/proving-job.d.ts.map +1 -1
  59. package/dest/interfaces/proving-job.js +2 -2
  60. package/dest/interfaces/server_circuit_prover.d.ts +3 -2
  61. package/dest/interfaces/server_circuit_prover.d.ts.map +1 -1
  62. package/dest/kernel/hints/find_private_kernel_reset_dimensions.js +1 -1
  63. package/dest/kernel/hints/key_validation_hint.d.ts +2 -6
  64. package/dest/kernel/hints/key_validation_hint.d.ts.map +1 -1
  65. package/dest/kernel/hints/key_validation_hint.js +5 -7
  66. package/dest/kernel/hints/private_kernel_reset_hints.d.ts +7 -7
  67. package/dest/kernel/hints/private_kernel_reset_hints.d.ts.map +1 -1
  68. package/dest/kernel/hints/private_kernel_reset_hints.js +8 -4
  69. package/dest/kernel/hints/read_request_hints.d.ts +8 -8
  70. package/dest/kernel/hints/read_request_hints.d.ts.map +1 -1
  71. package/dest/kernel/index.d.ts +1 -0
  72. package/dest/kernel/index.d.ts.map +1 -1
  73. package/dest/kernel/index.js +1 -0
  74. package/dest/kernel/padded_side_effects.d.ts +26 -0
  75. package/dest/kernel/padded_side_effects.d.ts.map +1 -0
  76. package/dest/kernel/padded_side_effects.js +51 -0
  77. package/dest/kernel/private_kernel_data.d.ts +6 -25
  78. package/dest/kernel/private_kernel_data.d.ts.map +1 -1
  79. package/dest/kernel/private_kernel_data.js +8 -19
  80. package/dest/kernel/private_kernel_reset_circuit_private_inputs.d.ts +7 -4
  81. package/dest/kernel/private_kernel_reset_circuit_private_inputs.d.ts.map +1 -1
  82. package/dest/kernel/private_kernel_reset_circuit_private_inputs.js +10 -6
  83. package/dest/kernel/private_kernel_reset_dimensions.d.ts +10 -10
  84. package/dest/kernel/private_kernel_reset_dimensions.d.ts.map +1 -1
  85. package/dest/kernel/private_kernel_reset_dimensions.js +29 -29
  86. package/dest/kernel/private_kernel_tail_circuit_private_inputs.d.ts +10 -1
  87. package/dest/kernel/private_kernel_tail_circuit_private_inputs.d.ts.map +1 -1
  88. package/dest/kernel/private_kernel_tail_circuit_private_inputs.js +8 -3
  89. package/dest/kernel/private_to_avm_accumulated_data.d.ts +1 -0
  90. package/dest/kernel/private_to_avm_accumulated_data.d.ts.map +1 -1
  91. package/dest/kernel/private_to_avm_accumulated_data.js +4 -0
  92. package/dest/kernel/public_call_request.d.ts +54 -0
  93. package/dest/kernel/public_call_request.d.ts.map +1 -1
  94. package/dest/kernel/public_call_request.js +58 -0
  95. package/dest/logs/contract_class_log.d.ts +0 -4
  96. package/dest/logs/contract_class_log.d.ts.map +1 -1
  97. package/dest/logs/contract_class_log.js +0 -33
  98. package/dest/logs/log_with_tx_data.d.ts +13 -3
  99. package/dest/logs/log_with_tx_data.d.ts.map +1 -1
  100. package/dest/logs/log_with_tx_data.js +26 -14
  101. package/dest/logs/private_log.d.ts +1 -0
  102. package/dest/logs/private_log.d.ts.map +1 -1
  103. package/dest/logs/private_log.js +3 -0
  104. package/dest/logs/public_log.d.ts +1 -0
  105. package/dest/logs/public_log.d.ts.map +1 -1
  106. package/dest/logs/public_log.js +3 -0
  107. package/dest/logs/tx_scoped_l2_log.d.ts.map +1 -1
  108. package/dest/logs/tx_scoped_l2_log.js +1 -0
  109. package/dest/messaging/index.d.ts +1 -0
  110. package/dest/messaging/index.d.ts.map +1 -1
  111. package/dest/messaging/index.js +1 -0
  112. package/dest/messaging/l2_to_l1_membership.d.ts +11 -0
  113. package/dest/messaging/l2_to_l1_membership.d.ts.map +1 -0
  114. package/dest/messaging/l2_to_l1_membership.js +70 -0
  115. package/dest/p2p/consensus_payload.d.ts.map +1 -1
  116. package/dest/rollup/avm_proof_data.d.ts +7 -5
  117. package/dest/rollup/avm_proof_data.d.ts.map +1 -1
  118. package/dest/rollup/avm_proof_data.js +12 -4
  119. package/dest/rollup/base_rollup_hints.d.ts +4 -4
  120. package/dest/rollup/base_rollup_hints.d.ts.map +1 -1
  121. package/dest/rollup/base_rollup_hints.js +8 -8
  122. package/dest/rollup/previous_rollup_block_data.d.ts +6 -15
  123. package/dest/rollup/previous_rollup_block_data.d.ts.map +1 -1
  124. package/dest/rollup/previous_rollup_block_data.js +8 -13
  125. package/dest/rollup/previous_rollup_data.d.ts +6 -15
  126. package/dest/rollup/previous_rollup_data.d.ts.map +1 -1
  127. package/dest/rollup/previous_rollup_data.js +8 -13
  128. package/dest/rollup/private_tube_data.d.ts +3 -3
  129. package/dest/rollup/private_tube_data.d.ts.map +1 -1
  130. package/dest/rollup/private_tube_data.js +3 -3
  131. package/dest/rollup/public_tube_data.d.ts +3 -3
  132. package/dest/rollup/public_tube_data.d.ts.map +1 -1
  133. package/dest/rollup/public_tube_data.js +3 -3
  134. package/dest/rollup/root_rollup.d.ts +9 -10
  135. package/dest/rollup/root_rollup.d.ts.map +1 -1
  136. package/dest/rollup/root_rollup.js +9 -20
  137. package/dest/tests/factories.d.ts +2 -1
  138. package/dest/tests/factories.d.ts.map +1 -1
  139. package/dest/tests/factories.js +53 -28
  140. package/dest/tests/mocks.d.ts.map +1 -1
  141. package/dest/tests/mocks.js +4 -3
  142. package/dest/tx/processed_tx.d.ts.map +1 -1
  143. package/dest/tx/processed_tx.js +2 -5
  144. package/dest/tx/tx.d.ts +10 -25
  145. package/dest/tx/tx.d.ts.map +1 -1
  146. package/dest/tx/tx.js +25 -50
  147. package/dest/tx/tx_effect.d.ts +1 -1
  148. package/dest/tx/tx_effect.d.ts.map +1 -1
  149. package/dest/tx/tx_effect.js +2 -2
  150. package/dest/tx/tx_hash.d.ts +1 -0
  151. package/dest/tx/tx_hash.d.ts.map +1 -1
  152. package/dest/tx/tx_hash.js +3 -0
  153. package/dest/validators/types.d.ts +4 -0
  154. package/dest/validators/types.d.ts.map +1 -1
  155. package/dest/vks/index.d.ts +1 -1
  156. package/dest/vks/index.d.ts.map +1 -1
  157. package/dest/vks/index.js +1 -1
  158. package/dest/vks/{vk_witness_data.d.ts → vk_data.d.ts} +8 -8
  159. package/dest/vks/vk_data.d.ts.map +1 -0
  160. package/dest/vks/{vk_witness_data.js → vk_data.js} +10 -10
  161. package/package.json +7 -7
  162. package/src/abi/abi.ts +37 -0
  163. package/src/avm/avm.ts +25 -4
  164. package/src/avm/avm_accumulated_data.ts +93 -0
  165. package/src/avm/avm_circuit_public_inputs.ts +22 -2
  166. package/src/avm/gas.ts +26 -0
  167. package/src/avm/index.ts +1 -0
  168. package/src/block/body.ts +7 -2
  169. package/src/block/index.ts +1 -0
  170. package/src/block/l2_block.ts +8 -3
  171. package/src/block/l2_block_source.ts +9 -3
  172. package/src/block/proposal/committee_attestation.ts +70 -0
  173. package/src/block/proposal/index.ts +1 -0
  174. package/src/block/published_l2_block.ts +38 -24
  175. package/src/block/test/l2_tips_store_test_suite.ts +1 -1
  176. package/src/interfaces/archiver.ts +2 -2
  177. package/src/interfaces/aztec-node.ts +8 -16
  178. package/src/interfaces/block-builder.ts +49 -2
  179. package/src/interfaces/epoch-prover.ts +2 -2
  180. package/src/interfaces/merkle_tree_operations.ts +20 -0
  181. package/src/interfaces/p2p.ts +9 -4
  182. package/src/interfaces/proving-job.ts +3 -3
  183. package/src/interfaces/server_circuit_prover.ts +3 -2
  184. package/src/kernel/hints/find_private_kernel_reset_dimensions.ts +3 -3
  185. package/src/kernel/hints/key_validation_hint.ts +4 -6
  186. package/src/kernel/hints/private_kernel_reset_hints.ts +34 -43
  187. package/src/kernel/hints/read_request_hints.ts +27 -15
  188. package/src/kernel/index.ts +1 -0
  189. package/src/kernel/padded_side_effects.ts +73 -0
  190. package/src/kernel/private_kernel_data.ts +7 -29
  191. package/src/kernel/private_kernel_reset_circuit_private_inputs.ts +16 -13
  192. package/src/kernel/private_kernel_reset_dimensions.ts +27 -27
  193. package/src/kernel/private_kernel_tail_circuit_private_inputs.ts +10 -2
  194. package/src/kernel/private_to_avm_accumulated_data.ts +9 -0
  195. package/src/kernel/public_call_request.ts +66 -0
  196. package/src/logs/contract_class_log.ts +0 -36
  197. package/src/logs/log_with_tx_data.ts +26 -12
  198. package/src/logs/private_log.ts +4 -0
  199. package/src/logs/public_log.ts +4 -0
  200. package/src/logs/tx_scoped_l2_log.ts +1 -0
  201. package/src/messaging/index.ts +1 -0
  202. package/src/messaging/l2_to_l1_membership.ts +113 -0
  203. package/src/p2p/consensus_payload.ts +3 -1
  204. package/src/rollup/avm_proof_data.ts +14 -7
  205. package/src/rollup/base_rollup_hints.ts +4 -4
  206. package/src/rollup/previous_rollup_block_data.ts +6 -12
  207. package/src/rollup/previous_rollup_data.ts +6 -12
  208. package/src/rollup/private_tube_data.ts +4 -4
  209. package/src/rollup/public_tube_data.ts +4 -4
  210. package/src/rollup/root_rollup.ts +6 -19
  211. package/src/tests/factories.ts +80 -43
  212. package/src/tests/mocks.ts +6 -3
  213. package/src/tx/processed_tx.ts +4 -5
  214. package/src/tx/tx.ts +28 -54
  215. package/src/tx/tx_effect.ts +23 -5
  216. package/src/tx/tx_hash.ts +4 -0
  217. package/src/validators/types.ts +2 -0
  218. package/src/vks/index.ts +1 -1
  219. package/src/vks/{vk_witness_data.ts → vk_data.ts} +6 -6
  220. package/dest/vks/vk_witness_data.d.ts.map +0 -1
@@ -14,10 +14,10 @@ import {
14
14
  PrivateToAvmAccumulatedData,
15
15
  PrivateToAvmAccumulatedDataArrayLengths,
16
16
  } from '../kernel/private_to_avm_accumulated_data.js';
17
- import { PublicCallRequest } from '../kernel/public_call_request.js';
17
+ import { PublicCallRequest, PublicCallRequestArrayLengths } from '../kernel/public_call_request.js';
18
18
  import { GlobalVariables } from '../tx/global_variables.js';
19
19
  import { TreeSnapshots } from '../tx/tree_snapshots.js';
20
- import { AvmAccumulatedData } from './avm_accumulated_data.js';
20
+ import { AvmAccumulatedData, AvmAccumulatedDataArrayLengths } from './avm_accumulated_data.js';
21
21
  import { serializeWithMessagePack } from './message_pack.js';
22
22
 
23
23
  // Note: the {from,to}{Buffer,Fields,String} methods are needed by AvmProofData and PublicBaseRollupInputs.
@@ -31,6 +31,7 @@ export class AvmCircuitPublicInputs {
31
31
  public startGasUsed: Gas,
32
32
  public gasSettings: GasSettings,
33
33
  public feePayer: AztecAddress,
34
+ public publicCallRequestArrayLengths: PublicCallRequestArrayLengths,
34
35
  public publicSetupCallRequests: Tuple<PublicCallRequest, typeof MAX_ENQUEUED_CALLS_PER_TX>,
35
36
  public publicAppLogicCallRequests: Tuple<PublicCallRequest, typeof MAX_ENQUEUED_CALLS_PER_TX>,
36
37
  public publicTeardownCallRequest: PublicCallRequest,
@@ -42,6 +43,7 @@ export class AvmCircuitPublicInputs {
42
43
  // Outputs.
43
44
  public endTreeSnapshots: TreeSnapshots,
44
45
  public endGasUsed: Gas,
46
+ public accumulatedDataArrayLengths: AvmAccumulatedDataArrayLengths,
45
47
  public accumulatedData: AvmAccumulatedData,
46
48
  public transactionFee: Fr,
47
49
  public reverted: boolean,
@@ -55,6 +57,7 @@ export class AvmCircuitPublicInputs {
55
57
  startGasUsed: Gas.schema,
56
58
  gasSettings: GasSettings.schema,
57
59
  feePayer: AztecAddress.schema,
60
+ publicCallRequestArrayLengths: PublicCallRequestArrayLengths.schema,
58
61
  publicSetupCallRequests: PublicCallRequest.schema.array().max(MAX_ENQUEUED_CALLS_PER_TX),
59
62
  publicAppLogicCallRequests: PublicCallRequest.schema.array().max(MAX_ENQUEUED_CALLS_PER_TX),
60
63
  publicTeardownCallRequest: PublicCallRequest.schema,
@@ -64,6 +67,7 @@ export class AvmCircuitPublicInputs {
64
67
  previousRevertibleAccumulatedData: PrivateToAvmAccumulatedData.schema,
65
68
  endTreeSnapshots: TreeSnapshots.schema,
66
69
  endGasUsed: Gas.schema,
70
+ accumulatedDataArrayLengths: AvmAccumulatedDataArrayLengths.schema,
67
71
  accumulatedData: AvmAccumulatedData.schema,
68
72
  transactionFee: schemas.Fr,
69
73
  reverted: z.boolean(),
@@ -75,6 +79,7 @@ export class AvmCircuitPublicInputs {
75
79
  startGasUsed,
76
80
  gasSettings,
77
81
  feePayer,
82
+ publicCallRequestArrayLengths,
78
83
  publicSetupCallRequests,
79
84
  publicAppLogicCallRequests,
80
85
  publicTeardownCallRequest,
@@ -84,6 +89,7 @@ export class AvmCircuitPublicInputs {
84
89
  previousRevertibleAccumulatedData,
85
90
  endTreeSnapshots,
86
91
  endGasUsed,
92
+ accumulatedDataArrayLengths,
87
93
  accumulatedData,
88
94
  transactionFee,
89
95
  reverted,
@@ -94,6 +100,7 @@ export class AvmCircuitPublicInputs {
94
100
  startGasUsed,
95
101
  gasSettings,
96
102
  feePayer,
103
+ publicCallRequestArrayLengths,
97
104
  assertLength(publicSetupCallRequests, MAX_ENQUEUED_CALLS_PER_TX),
98
105
  assertLength(publicAppLogicCallRequests, MAX_ENQUEUED_CALLS_PER_TX),
99
106
  publicTeardownCallRequest,
@@ -103,6 +110,7 @@ export class AvmCircuitPublicInputs {
103
110
  previousRevertibleAccumulatedData,
104
111
  endTreeSnapshots,
105
112
  endGasUsed,
113
+ accumulatedDataArrayLengths,
106
114
  accumulatedData,
107
115
  transactionFee,
108
116
  reverted,
@@ -118,6 +126,7 @@ export class AvmCircuitPublicInputs {
118
126
  reader.readObject(Gas),
119
127
  reader.readObject(GasSettings),
120
128
  reader.readObject(AztecAddress),
129
+ reader.readObject(PublicCallRequestArrayLengths),
121
130
  reader.readArray(MAX_ENQUEUED_CALLS_PER_TX, PublicCallRequest),
122
131
  reader.readArray(MAX_ENQUEUED_CALLS_PER_TX, PublicCallRequest),
123
132
  reader.readObject(PublicCallRequest),
@@ -127,6 +136,7 @@ export class AvmCircuitPublicInputs {
127
136
  reader.readObject(PrivateToAvmAccumulatedData),
128
137
  reader.readObject(TreeSnapshots),
129
138
  reader.readObject(Gas),
139
+ reader.readObject(AvmAccumulatedDataArrayLengths),
130
140
  reader.readObject(AvmAccumulatedData),
131
141
  reader.readObject(Fr),
132
142
  reader.readBoolean(),
@@ -140,6 +150,7 @@ export class AvmCircuitPublicInputs {
140
150
  this.startGasUsed,
141
151
  this.gasSettings,
142
152
  this.feePayer,
153
+ this.publicCallRequestArrayLengths,
143
154
  this.publicSetupCallRequests,
144
155
  this.publicAppLogicCallRequests,
145
156
  this.publicTeardownCallRequest,
@@ -149,6 +160,7 @@ export class AvmCircuitPublicInputs {
149
160
  this.previousRevertibleAccumulatedData,
150
161
  this.endTreeSnapshots,
151
162
  this.endGasUsed,
163
+ this.accumulatedDataArrayLengths,
152
164
  this.accumulatedData,
153
165
  this.transactionFee,
154
166
  this.reverted,
@@ -171,6 +183,7 @@ export class AvmCircuitPublicInputs {
171
183
  Gas.fromFields(reader),
172
184
  GasSettings.fromFields(reader),
173
185
  AztecAddress.fromFields(reader),
186
+ PublicCallRequestArrayLengths.fromFields(reader),
174
187
  reader.readArray(MAX_ENQUEUED_CALLS_PER_TX, PublicCallRequest),
175
188
  reader.readArray(MAX_ENQUEUED_CALLS_PER_TX, PublicCallRequest),
176
189
  PublicCallRequest.fromFields(reader),
@@ -180,6 +193,7 @@ export class AvmCircuitPublicInputs {
180
193
  PrivateToAvmAccumulatedData.fromFields(reader),
181
194
  TreeSnapshots.fromFields(reader),
182
195
  Gas.fromFields(reader),
196
+ AvmAccumulatedDataArrayLengths.fromFields(reader),
183
197
  AvmAccumulatedData.fromFields(reader),
184
198
  reader.readField(),
185
199
  reader.readBoolean(),
@@ -193,6 +207,7 @@ export class AvmCircuitPublicInputs {
193
207
  ...this.startGasUsed.toFields(),
194
208
  ...this.gasSettings.toFields(),
195
209
  this.feePayer,
210
+ ...this.publicCallRequestArrayLengths.toFields(),
196
211
  ...this.publicSetupCallRequests.map(request => request.toFields()),
197
212
  ...this.publicAppLogicCallRequests.map(request => request.toFields()),
198
213
  ...this.publicTeardownCallRequest.toFields(),
@@ -202,6 +217,7 @@ export class AvmCircuitPublicInputs {
202
217
  ...this.previousRevertibleAccumulatedData.toFields(),
203
218
  ...this.endTreeSnapshots.toFields(),
204
219
  ...this.endGasUsed.toFields(),
220
+ ...this.accumulatedDataArrayLengths.toFields(),
205
221
  ...this.accumulatedData.toFields(),
206
222
  this.transactionFee,
207
223
  this.reverted,
@@ -215,6 +231,7 @@ export class AvmCircuitPublicInputs {
215
231
  Gas.empty(),
216
232
  GasSettings.empty(),
217
233
  AztecAddress.zero(),
234
+ PublicCallRequestArrayLengths.empty(),
218
235
  makeTuple(MAX_ENQUEUED_CALLS_PER_TX, PublicCallRequest.empty),
219
236
  makeTuple(MAX_ENQUEUED_CALLS_PER_TX, PublicCallRequest.empty),
220
237
  PublicCallRequest.empty(),
@@ -224,6 +241,7 @@ export class AvmCircuitPublicInputs {
224
241
  PrivateToAvmAccumulatedData.empty(),
225
242
  TreeSnapshots.empty(),
226
243
  Gas.empty(),
244
+ AvmAccumulatedDataArrayLengths.empty(),
227
245
  AvmAccumulatedData.empty(),
228
246
  Fr.zero(),
229
247
  false,
@@ -241,6 +259,7 @@ export class AvmCircuitPublicInputs {
241
259
  startGasUsed: ${inspect(this.startGasUsed)},
242
260
  gasSettings: ${inspect(this.gasSettings)},
243
261
  feePayer: ${inspect(this.feePayer)},
262
+ publicCallRequestArrayLengths: ${inspect(this.publicCallRequestArrayLengths)},
244
263
  publicSetupCallRequests: [${this.publicSetupCallRequests
245
264
  .filter(x => !x.isEmpty())
246
265
  .map(h => inspect(h))
@@ -258,6 +277,7 @@ export class AvmCircuitPublicInputs {
258
277
  previousRevertibleAccumulatedData: ${inspect(this.previousRevertibleAccumulatedData)},
259
278
  endTreeSnapshots: ${inspect(this.endTreeSnapshots)},
260
279
  endGasUsed: ${inspect(this.endGasUsed)},
280
+ accumulatedDataArrayLengths: ${inspect(this.accumulatedDataArrayLengths)},
261
281
  accumulatedData: ${inspect(this.accumulatedData)},
262
282
  transactionFee: ${inspect(this.transactionFee)},
263
283
  reverted: ${this.reverted},
package/src/avm/gas.ts ADDED
@@ -0,0 +1,26 @@
1
+ import { MAX_L2_GAS_PER_TX_PUBLIC_PORTION } from '@aztec/constants';
2
+
3
+ import { Gas } from '../gas/gas.js';
4
+ import { GasSettings } from '../gas/gas_settings.js';
5
+
6
+ /**
7
+ * Apply L2 gas maximum to the gas settings.
8
+ */
9
+ export function clampGasSettingsForAVM(gasSettings: GasSettings, gasUsedByPrivate: Gas): GasSettings {
10
+ return new GasSettings(
11
+ clampGasLimitsForAVM(gasSettings.gasLimits, gasUsedByPrivate),
12
+ clampGasLimitsForAVM(gasSettings.teardownGasLimits, new Gas(0, 0)),
13
+ gasSettings.maxFeesPerGas,
14
+ gasSettings.maxPriorityFeesPerGas,
15
+ );
16
+ }
17
+
18
+ /**
19
+ * Apply L2 gas maximum to the gas limits.
20
+ */
21
+ function clampGasLimitsForAVM(gasLimits: Gas, gasUsedByPrivate: Gas): Gas {
22
+ return new Gas(
23
+ /*daGas=*/ gasLimits.daGas,
24
+ /*l2Gas=*/ Math.min(gasLimits.l2Gas, gasUsedByPrivate.l2Gas + MAX_L2_GAS_PER_TX_PUBLIC_PORTION),
25
+ );
26
+ }
package/src/avm/index.ts CHANGED
@@ -10,3 +10,4 @@ export * from './contract_storage_read.js';
10
10
  export * from './public_inner_call_request.js';
11
11
  export * from './public_call_stack_item_compressed.js';
12
12
  export * from './avm_proving_request.js';
13
+ export * from './gas.js';
package/src/block/body.ts CHANGED
@@ -87,9 +87,14 @@ export class Body {
87
87
  }`;
88
88
  }
89
89
 
90
- static async random(txsPerBlock = 4, numPublicCallsPerTx = 3, numPublicLogsPerCall = 1) {
90
+ static async random(
91
+ txsPerBlock = 4,
92
+ numPublicCallsPerTx = 3,
93
+ numPublicLogsPerCall = 1,
94
+ maxEffects: number | undefined = undefined,
95
+ ) {
91
96
  const txEffects = await timesParallel(txsPerBlock, () =>
92
- TxEffect.random(numPublicCallsPerTx, numPublicLogsPerCall),
97
+ TxEffect.random(numPublicCallsPerTx, numPublicLogsPerCall, maxEffects),
93
98
  );
94
99
 
95
100
  return new Body(txEffects);
@@ -6,3 +6,4 @@ export * from './l2_block_number.js';
6
6
  export * from './l2_block_source.js';
7
7
  export * from './block_hash.js';
8
8
  export * from './published_l2_block.js';
9
+ export * from './proposal/index.js';
@@ -20,6 +20,7 @@ export class L2Block {
20
20
  public header: BlockHeader,
21
21
  /** L2 block body. */
22
22
  public body: Body,
23
+ private blockHash: Fr | undefined = undefined,
23
24
  ) {}
24
25
 
25
26
  static get schema() {
@@ -86,8 +87,9 @@ export class L2Block {
86
87
  numPublicLogsPerCall = 1,
87
88
  inHash: Buffer | undefined = undefined,
88
89
  slotNumber: number | undefined = undefined,
90
+ maxEffects: number | undefined = undefined,
89
91
  ): Promise<L2Block> {
90
- const body = await Body.random(txsPerBlock, numPublicCallsPerTx, numPublicLogsPerCall);
92
+ const body = await Body.random(txsPerBlock, numPublicCallsPerTx, numPublicLogsPerCall, maxEffects);
91
93
 
92
94
  return new L2Block(
93
95
  makeAppendOnlyTreeSnapshot(l2BlockNum + 1),
@@ -112,8 +114,11 @@ export class L2Block {
112
114
  * Returns the block's hash (hash of block header).
113
115
  * @returns The block's hash.
114
116
  */
115
- public hash(): Promise<Fr> {
116
- return this.header.hash();
117
+ public async hash(): Promise<Fr> {
118
+ if (this.blockHash === undefined) {
119
+ this.blockHash = await this.header.hash();
120
+ }
121
+ return this.blockHash;
117
122
  }
118
123
 
119
124
  /**
@@ -1,6 +1,6 @@
1
1
  import type { EthAddress } from '@aztec/foundation/eth-address';
2
+ import type { TypedEventEmitter } from '@aztec/foundation/types';
2
3
 
3
- import type { EventEmitter } from 'events';
4
4
  import { z } from 'zod';
5
5
 
6
6
  import type { L1RollupConstants } from '../epoch-helpers/index.js';
@@ -127,7 +127,12 @@ export interface L2BlockSource {
127
127
  * L2BlockSource that emits events upon pending / proven chain changes.
128
128
  * see L2BlockSourceEvents for the events emitted.
129
129
  */
130
- export interface L2BlockSourceEventEmitter extends L2BlockSource, EventEmitter {}
130
+
131
+ export type ArchiverEmitter = TypedEventEmitter<{
132
+ [L2BlockSourceEvents.L2PruneDetected]: (args: L2BlockSourceEvent) => void;
133
+ [L2BlockSourceEvents.L2BlockProven]: (args: L2BlockSourceEvent) => void;
134
+ }>;
135
+ export interface L2BlockSourceEventEmitter extends L2BlockSource, ArchiverEmitter {}
131
136
 
132
137
  /**
133
138
  * Identifier for L2 block tags.
@@ -171,10 +176,11 @@ export const L2TipsSchema = z.object({
171
176
 
172
177
  export enum L2BlockSourceEvents {
173
178
  L2PruneDetected = 'l2PruneDetected',
179
+ L2BlockProven = 'l2BlockProven',
174
180
  }
175
181
 
176
182
  export type L2BlockSourceEvent = {
177
- type: 'l2PruneDetected';
183
+ type: 'l2PruneDetected' | 'l2BlockProven';
178
184
  blockNumber: bigint;
179
185
  slotNumber: bigint;
180
186
  epochNumber: bigint;
@@ -0,0 +1,70 @@
1
+ import type { ViemCommitteeAttestation } from '@aztec/ethereum';
2
+ import { EthAddress } from '@aztec/foundation/eth-address';
3
+ import { Signature } from '@aztec/foundation/eth-signature';
4
+ import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
5
+
6
+ import { z } from 'zod';
7
+
8
+ export { Signature };
9
+ export { EthAddress };
10
+
11
+ export class CommitteeAttestation {
12
+ constructor(
13
+ public readonly address: EthAddress,
14
+ public readonly signature: Signature,
15
+ ) {}
16
+
17
+ static get schema() {
18
+ return z
19
+ .object({
20
+ address: EthAddress.schema,
21
+ signature: Signature.schema,
22
+ })
23
+ .transform(({ address, signature }) => new CommitteeAttestation(address, signature));
24
+ }
25
+
26
+ // Create an empty attestation for an address that has not signed
27
+ static fromAddress(address: EthAddress): CommitteeAttestation {
28
+ return new CommitteeAttestation(address, Signature.empty());
29
+ }
30
+
31
+ // Create an attestation from an address and a signature
32
+ static fromAddressAndSignature(address: EthAddress, signature: Signature): CommitteeAttestation {
33
+ return new CommitteeAttestation(address, signature);
34
+ }
35
+
36
+ static fromViem(viem: ViemCommitteeAttestation): CommitteeAttestation {
37
+ return new CommitteeAttestation(EthAddress.fromString(viem.addr), Signature.fromViemSignature(viem.signature));
38
+ }
39
+
40
+ static fromBuffer(buffer: Buffer): CommitteeAttestation {
41
+ const reader = BufferReader.asReader(buffer);
42
+ const address = reader.readObject(EthAddress);
43
+ const signature = reader.readObject(Signature);
44
+ return new CommitteeAttestation(address, signature);
45
+ }
46
+
47
+ static random(): CommitteeAttestation {
48
+ // note: will be invalid
49
+ return new CommitteeAttestation(EthAddress.random(), Signature.random());
50
+ }
51
+
52
+ static empty(): CommitteeAttestation {
53
+ return new CommitteeAttestation(EthAddress.ZERO, Signature.empty());
54
+ }
55
+
56
+ toBuffer(): Buffer {
57
+ return serializeToBuffer([this.address, this.signature]);
58
+ }
59
+
60
+ equals(other: CommitteeAttestation): boolean {
61
+ return this.address.equals(other.address) && this.signature.equals(other.signature);
62
+ }
63
+
64
+ toViem(): ViemCommitteeAttestation {
65
+ return {
66
+ addr: this.address.toString(),
67
+ signature: this.signature.toViemSignature(),
68
+ };
69
+ }
70
+ }
@@ -0,0 +1 @@
1
+ export * from './committee_attestation.js';
@@ -1,37 +1,51 @@
1
- import { Signature } from '@aztec/foundation/eth-signature';
1
+ // Ignoring import issue to fix portable inferred type issue in zod schema
2
2
  import { schemas } from '@aztec/foundation/schemas';
3
- import { L2Block } from '@aztec/stdlib/block';
4
3
 
5
4
  import { z } from 'zod';
6
5
 
7
6
  import { BlockAttestation } from '../p2p/block_attestation.js';
8
7
  import { ConsensusPayload } from '../p2p/consensus_payload.js';
8
+ import { L2Block } from './l2_block.js';
9
+ import { CommitteeAttestation } from './proposal/committee_attestation.js';
9
10
 
10
- export type L1PublishedData = {
11
- blockNumber: bigint;
12
- timestamp: bigint;
13
- blockHash: string;
14
- };
11
+ export class L1PublishedData {
12
+ constructor(
13
+ public blockNumber: bigint,
14
+ public timestamp: bigint,
15
+ public blockHash: string,
16
+ ) {}
15
17
 
16
- export type PublishedL2Block = {
17
- block: L2Block;
18
- l1: L1PublishedData;
19
- signatures: Signature[];
20
- };
18
+ static get schema() {
19
+ return z.object({
20
+ blockNumber: schemas.BigInt,
21
+ timestamp: schemas.BigInt,
22
+ blockHash: z.string(),
23
+ });
24
+ }
25
+ }
26
+
27
+ export class PublishedL2Block {
28
+ constructor(
29
+ public block: L2Block,
30
+ public l1: L1PublishedData,
31
+ public attestations: CommitteeAttestation[],
32
+ ) {}
21
33
 
22
- export const PublishedL2BlockSchema = z.object({
23
- block: L2Block.schema,
24
- l1: z.object({
25
- blockNumber: schemas.BigInt,
26
- timestamp: schemas.BigInt,
27
- blockHash: z.string(),
28
- }),
29
- signatures: z.array(Signature.schema),
30
- });
34
+ static get schema() {
35
+ return z.object({
36
+ block: L2Block.schema,
37
+ l1: L1PublishedData.schema,
38
+ attestations: z.array(CommitteeAttestation.schema),
39
+ });
40
+ }
41
+ }
31
42
 
32
43
  export function getAttestationsFromPublishedL2Block(block: PublishedL2Block) {
33
44
  const payload = ConsensusPayload.fromBlock(block.block);
34
- return block.signatures
35
- .filter(sig => !sig.isEmpty)
36
- .map(signature => new BlockAttestation(block.block.header.globalVariables.blockNumber, payload, signature));
45
+ return block.attestations
46
+ .filter(attestation => !attestation.signature.isEmpty())
47
+ .map(
48
+ attestation =>
49
+ new BlockAttestation(block.block.header.globalVariables.blockNumber, payload, attestation.signature),
50
+ );
37
51
  }
@@ -17,7 +17,7 @@ export function testL2TipsStore(makeTipsStore: () => Promise<L2TipsStore>) {
17
17
  const makeBlock = (number: number): PublishedL2Block => ({
18
18
  block: { number, header: { hash: () => Promise.resolve(new Fr(number)) } as BlockHeader } as L2Block,
19
19
  l1: { blockNumber: BigInt(number), blockHash: `0x${number}`, timestamp: BigInt(number) },
20
- signatures: [],
20
+ attestations: [],
21
21
  });
22
22
 
23
23
  const makeBlockId = (number: number): L2BlockId => ({
@@ -4,7 +4,7 @@ import { z } from 'zod';
4
4
 
5
5
  import { L2Block } from '../block/l2_block.js';
6
6
  import { type L2BlockSource, L2TipsSchema } from '../block/l2_block_source.js';
7
- import { PublishedL2BlockSchema } from '../block/published_l2_block.js';
7
+ import { PublishedL2Block } from '../block/published_l2_block.js';
8
8
  import {
9
9
  ContractClassPublicSchema,
10
10
  type ContractDataSource,
@@ -45,7 +45,7 @@ export const ArchiverApiSchema: ApiSchemaFor<ArchiverApi> = {
45
45
  getPublishedBlocks: z
46
46
  .function()
47
47
  .args(schemas.Integer, schemas.Integer, optional(z.boolean()))
48
- .returns(z.array(PublishedL2BlockSchema)),
48
+ .returns(z.array(PublishedL2Block.schema)),
49
49
  getTxEffect: z.function().args(TxHash.schema).returns(indexedTxSchema().optional()),
50
50
  getSettledTxReceipt: z.function().args(TxHash.schema).returns(TxReceipt.schema.optional()),
51
51
  getL2SlotNumber: z.function().args().returns(schemas.BigInt),
@@ -17,7 +17,7 @@ import { type InBlock, inBlockSchemaFor } from '../block/in_block.js';
17
17
  import { L2Block } from '../block/l2_block.js';
18
18
  import { type L2BlockNumber, L2BlockNumberSchema } from '../block/l2_block_number.js';
19
19
  import { type L2BlockSource, type L2Tips, L2TipsSchema } from '../block/l2_block_source.js';
20
- import { PublishedL2BlockSchema } from '../block/published_l2_block.js';
20
+ import { PublishedL2Block } from '../block/published_l2_block.js';
21
21
  import {
22
22
  type ContractClassPublic,
23
23
  ContractClassPublicSchema,
@@ -129,19 +129,11 @@ export interface AztecNode
129
129
  isL1ToL2MessageSynced(l1ToL2Message: Fr): Promise<boolean>;
130
130
 
131
131
  /**
132
- * Returns a membership witness of an l2ToL1Message in an ephemeral l2 to l1 message tree.
133
- * @dev Membership witness is a consists of the index and the sibling path of the l2ToL1Message.
134
- * @remarks This tree is considered ephemeral because it is created on-demand by: taking all the l2ToL1 messages
135
- * in a single block, and then using them to make a variable depth append-only tree with these messages as leaves.
136
- * The tree is discarded immediately after calculating what we need from it.
132
+ * Returns all the L2 to L1 messages in a block.
137
133
  * @param blockNumber - The block number at which to get the data.
138
- * @param l2ToL1Message - The l2ToL1Message to get the membership witness for.
139
- * @returns A tuple of the index and the sibling path of the L2ToL1Message.
134
+ * @returns The L2 to L1 messages (undefined if the block number is not found).
140
135
  */
141
- getL2ToL1MessageMembershipWitness(
142
- blockNumber: L2BlockNumber,
143
- l2ToL1Message: Fr,
144
- ): Promise<[bigint, SiblingPath<number>]>;
136
+ getL2ToL1Messages(blockNumber: L2BlockNumber): Promise<Fr[][] | undefined>;
145
137
 
146
138
  /**
147
139
  * Returns a sibling path for a leaf in the committed historic blocks tree.
@@ -445,10 +437,10 @@ export const AztecNodeApiSchema: ApiSchemaFor<AztecNode> = {
445
437
 
446
438
  isL1ToL2MessageSynced: z.function().args(schemas.Fr).returns(z.boolean()),
447
439
 
448
- getL2ToL1MessageMembershipWitness: z
440
+ getL2ToL1Messages: z
449
441
  .function()
450
- .args(L2BlockNumberSchema, schemas.Fr)
451
- .returns(z.tuple([schemas.BigInt, SiblingPath.schema])),
442
+ .args(L2BlockNumberSchema)
443
+ .returns(z.array(z.array(schemas.Fr)).optional()),
452
444
 
453
445
  getArchiveSiblingPath: z
454
446
  .function()
@@ -484,7 +476,7 @@ export const AztecNodeApiSchema: ApiSchemaFor<AztecNode> = {
484
476
 
485
477
  getBlocks: z.function().args(z.number(), z.number()).returns(z.array(L2Block.schema)),
486
478
 
487
- getPublishedBlocks: z.function().args(z.number(), z.number()).returns(z.array(PublishedL2BlockSchema)),
479
+ getPublishedBlocks: z.function().args(z.number(), z.number()).returns(z.array(PublishedL2Block.schema)),
488
480
 
489
481
  getCurrentBaseFees: z.function().returns(GasFees.schema),
490
482
 
@@ -1,13 +1,18 @@
1
1
  import type { Fr } from '@aztec/foundation/fields';
2
+ import type { Timer } from '@aztec/foundation/timer';
2
3
 
3
4
  import type { L2Block } from '../block/l2_block.js';
5
+ import type { AllowedElement } from '../config/index.js';
6
+ import type { Gas } from '../gas/gas.js';
4
7
  import type { BlockHeader } from '../tx/block_header.js';
5
8
  import type { GlobalVariables } from '../tx/global_variables.js';
6
- import type { ProcessedTx } from '../tx/processed_tx.js';
9
+ import type { FailedTx, ProcessedTx } from '../tx/processed_tx.js';
10
+ import { Tx } from '../tx/tx.js';
11
+ import type { TxValidator } from '../tx/validator/tx_validator.js';
7
12
  import type { ProcessedTxHandler } from './processed-tx-handler.js';
8
13
 
9
14
  /** The interface to a block builder. Generates an L2 block out of a set of processed txs. */
10
- export interface BlockBuilder extends ProcessedTxHandler {
15
+ export interface IBlockFactory extends ProcessedTxHandler {
11
16
  /**
12
17
  * Prepares to build a new block. Updates the L1 to L2 message tree.
13
18
  * @param globalVariables - The global variables for this block.
@@ -31,3 +36,45 @@ export interface BlockBuilder extends ProcessedTxHandler {
31
36
  */
32
37
  setBlockCompleted(expectedBlockHeader?: BlockHeader): Promise<L2Block>;
33
38
  }
39
+
40
+ export interface PublicProcessorLimits {
41
+ maxTransactions?: number;
42
+ maxBlockSize?: number;
43
+ maxBlockGas?: Gas;
44
+ deadline?: Date;
45
+ }
46
+
47
+ export interface PublicProcessorValidator {
48
+ preprocessValidator?: TxValidator<Tx>;
49
+ nullifierCache?: { addNullifiers: (nullifiers: Buffer[]) => void };
50
+ }
51
+
52
+ export interface BuildBlockOptions extends PublicProcessorLimits {
53
+ txPublicSetupAllowList?: AllowedElement[];
54
+ }
55
+
56
+ export interface BuildBlockResult {
57
+ block: L2Block;
58
+ publicGas: Gas;
59
+ publicProcessorDuration: number;
60
+ numMsgs: number;
61
+ numTxs: number;
62
+ failedTxs: FailedTx[];
63
+ blockBuildingTimer: Timer;
64
+ usedTxs: Tx[];
65
+ }
66
+
67
+ export interface IFullNodeBlockBuilder {
68
+ getConfig(): {
69
+ l1GenesisTime: bigint;
70
+ slotDuration: number;
71
+ l1ChainId: number;
72
+ rollupVersion: number;
73
+ };
74
+
75
+ buildBlock(
76
+ txs: Iterable<Tx> | AsyncIterable<Tx>,
77
+ globalVariables: GlobalVariables,
78
+ options: BuildBlockOptions,
79
+ ): Promise<BuildBlockResult>;
80
+ }
@@ -5,10 +5,10 @@ import type { Proof } from '../proofs/proof.js';
5
5
  import type { RootRollupPublicInputs } from '../rollup/root_rollup.js';
6
6
  import type { BlockHeader } from '../tx/block_header.js';
7
7
  import type { Tx } from '../tx/tx.js';
8
- import type { BlockBuilder } from './block-builder.js';
8
+ import type { IBlockFactory } from './block-builder.js';
9
9
 
10
10
  /** Coordinates the proving of an entire epoch. */
11
- export interface EpochProver extends Omit<BlockBuilder, 'setBlockCompleted'> {
11
+ export interface EpochProver extends Omit<IBlockFactory, 'setBlockCompleted'> {
12
12
  /**
13
13
  * Starts a new epoch. Must be the first method to be called.
14
14
  * @param epochNumber - The epoch number.
@@ -178,6 +178,16 @@ export interface MerkleTreeReadOperations {
178
178
  values: MerkleTreeLeafType<ID>[],
179
179
  ): Promise<(bigint | undefined)[]>;
180
180
 
181
+ /**
182
+ * Returns the sibling paths for the given leaf values
183
+ * @param treeId - The tree for which the index should be returned.
184
+ * @param values - The values to search for in the tree.
185
+ */
186
+ findSiblingPaths<ID extends MerkleTreeId, N extends number>(
187
+ treeId: ID,
188
+ values: MerkleTreeLeafType<ID>[],
189
+ ): Promise<(SiblingPath<N> | undefined)[]>;
190
+
181
191
  /**
182
192
  * Returns the first index containing a leaf value after `startIndex`.
183
193
  * @param treeId - The tree for which the index should be returned.
@@ -226,6 +236,16 @@ export interface MerkleTreeCheckpointOperations {
226
236
  * Reverts the current checkpoint
227
237
  */
228
238
  revertCheckpoint(): Promise<void>;
239
+
240
+ /**
241
+ * Commits all checkpoints
242
+ */
243
+ commitAllCheckpoints(): Promise<void>;
244
+
245
+ /**
246
+ * Reverts all checkpoints
247
+ */
248
+ revertAllCheckpoints(): Promise<void>;
229
249
  }
230
250
 
231
251
  export interface MerkleTreeWriteOperations extends MerkleTreeReadOperations, MerkleTreeCheckpointOperations {