@aztec/simulator 0.0.1-commit.2ed92850 → 0.0.1-commit.3100065

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 (179) hide show
  1. package/README.md +4 -4
  2. package/dest/client.d.ts +1 -3
  3. package/dest/client.d.ts.map +1 -1
  4. package/dest/client.js +0 -2
  5. package/dest/private/acvm/acvm.d.ts +4 -2
  6. package/dest/private/acvm/acvm.d.ts.map +1 -1
  7. package/dest/private/acvm/acvm.js +4 -3
  8. package/dest/private/acvm_native.d.ts +5 -3
  9. package/dest/private/acvm_native.d.ts.map +1 -1
  10. package/dest/private/acvm_native.js +8 -6
  11. package/dest/private/acvm_wasm.d.ts +4 -3
  12. package/dest/private/acvm_wasm.d.ts.map +1 -1
  13. package/dest/private/acvm_wasm.js +7 -5
  14. package/dest/private/circuit_recording/circuit_recorder.d.ts +39 -25
  15. package/dest/private/circuit_recording/circuit_recorder.d.ts.map +1 -1
  16. package/dest/private/circuit_recording/circuit_recorder.js +70 -72
  17. package/dest/private/circuit_recording/file_circuit_recorder.d.ts +9 -20
  18. package/dest/private/circuit_recording/file_circuit_recorder.d.ts.map +1 -1
  19. package/dest/private/circuit_recording/file_circuit_recorder.js +39 -43
  20. package/dest/private/circuit_recording/memory_circuit_recorder.d.ts +7 -2
  21. package/dest/private/circuit_recording/memory_circuit_recorder.d.ts.map +1 -1
  22. package/dest/private/circuit_recording/memory_circuit_recorder.js +4 -4
  23. package/dest/private/circuit_recording/simulator_recorder_wrapper.d.ts +1 -1
  24. package/dest/private/circuit_recording/simulator_recorder_wrapper.d.ts.map +1 -1
  25. package/dest/private/circuit_recording/simulator_recorder_wrapper.js +11 -14
  26. package/dest/private/factory.d.ts +3 -3
  27. package/dest/private/factory.d.ts.map +1 -1
  28. package/dest/private/factory.js +7 -4
  29. package/dest/public/avm/avm_gas.js +3 -3
  30. package/dest/public/avm/avm_simulator.js +1 -1
  31. package/dest/public/avm/calldata.d.ts +1 -1
  32. package/dest/public/avm/calldata.d.ts.map +1 -1
  33. package/dest/public/avm/calldata.js +3 -2
  34. package/dest/public/avm/fixtures/account_proof_fetcher.d.ts +2 -0
  35. package/dest/public/avm/fixtures/account_proof_fetcher.d.ts.map +1 -0
  36. package/dest/public/avm/fixtures/account_proof_fetcher.js +152 -0
  37. package/dest/public/avm/fixtures/base_avm_simulation_tester.d.ts +2 -1
  38. package/dest/public/avm/fixtures/base_avm_simulation_tester.d.ts.map +1 -1
  39. package/dest/public/avm/fixtures/base_avm_simulation_tester.js +18 -3
  40. package/dest/public/avm/fixtures/utils.d.ts +1 -1
  41. package/dest/public/avm/fixtures/utils.d.ts.map +1 -1
  42. package/dest/public/avm/fixtures/utils.js +4 -1
  43. package/dest/public/avm/opcodes/accrued_substate.d.ts +4 -5
  44. package/dest/public/avm/opcodes/accrued_substate.d.ts.map +1 -1
  45. package/dest/public/avm/opcodes/accrued_substate.js +11 -16
  46. package/dest/public/avm/opcodes/contract.d.ts +3 -2
  47. package/dest/public/avm/opcodes/contract.d.ts.map +1 -1
  48. package/dest/public/avm/opcodes/contract.js +5 -1
  49. package/dest/public/avm/opcodes/ec_add.d.ts +2 -4
  50. package/dest/public/avm/opcodes/ec_add.d.ts.map +1 -1
  51. package/dest/public/avm/opcodes/ec_add.js +13 -27
  52. package/dest/public/avm/serialization/bytecode_serialization.js +3 -3
  53. package/dest/public/avm/serialization/instruction_serialization.d.ts +2 -2
  54. package/dest/public/avm/serialization/instruction_serialization.d.ts.map +1 -1
  55. package/dest/public/avm/serialization/instruction_serialization.js +1 -1
  56. package/dest/public/contracts_db_checkpoint.d.ts +2 -2
  57. package/dest/public/contracts_db_checkpoint.d.ts.map +1 -1
  58. package/dest/public/contracts_db_checkpoint.js +1 -1
  59. package/dest/public/executor_metrics.d.ts +1 -1
  60. package/dest/public/executor_metrics.d.ts.map +1 -1
  61. package/dest/public/executor_metrics.js +7 -2
  62. package/dest/public/fixtures/amm_test.js +4 -4
  63. package/dest/public/fixtures/bulk_test.d.ts +1 -1
  64. package/dest/public/fixtures/bulk_test.d.ts.map +1 -1
  65. package/dest/public/fixtures/bulk_test.js +33 -6
  66. package/dest/public/fixtures/custom_bytecode_tester.d.ts +1 -1
  67. package/dest/public/fixtures/custom_bytecode_tester.d.ts.map +1 -1
  68. package/dest/public/fixtures/custom_bytecode_tester.js +2 -2
  69. package/dest/public/fixtures/custom_bytecode_tests.d.ts +8 -1
  70. package/dest/public/fixtures/custom_bytecode_tests.d.ts.map +1 -1
  71. package/dest/public/fixtures/custom_bytecode_tests.js +91 -2
  72. package/dest/public/fixtures/opcode_spammer.d.ts +3 -4
  73. package/dest/public/fixtures/opcode_spammer.d.ts.map +1 -1
  74. package/dest/public/fixtures/opcode_spammer.js +18 -66
  75. package/dest/public/fixtures/public_tx_simulation_tester.d.ts +6 -5
  76. package/dest/public/fixtures/public_tx_simulation_tester.d.ts.map +1 -1
  77. package/dest/public/fixtures/public_tx_simulation_tester.js +38 -9
  78. package/dest/public/fixtures/token_test.js +3 -3
  79. package/dest/public/fixtures/utils.d.ts +2 -2
  80. package/dest/public/fixtures/utils.d.ts.map +1 -1
  81. package/dest/public/fixtures/utils.js +21 -20
  82. package/dest/public/hinting_db_sources.d.ts +5 -5
  83. package/dest/public/hinting_db_sources.d.ts.map +1 -1
  84. package/dest/public/hinting_db_sources.js +8 -7
  85. package/dest/public/public_db_sources.d.ts +9 -5
  86. package/dest/public/public_db_sources.d.ts.map +1 -1
  87. package/dest/public/public_db_sources.js +20 -14
  88. package/dest/public/public_processor/guarded_merkle_tree.d.ts +5 -5
  89. package/dest/public/public_processor/guarded_merkle_tree.d.ts.map +1 -1
  90. package/dest/public/public_processor/guarded_merkle_tree.js +5 -5
  91. package/dest/public/public_processor/public_processor.d.ts +11 -6
  92. package/dest/public/public_processor/public_processor.d.ts.map +1 -1
  93. package/dest/public/public_processor/public_processor.js +125 -68
  94. package/dest/public/public_processor/public_processor_metrics.d.ts +5 -2
  95. package/dest/public/public_processor/public_processor_metrics.d.ts.map +1 -1
  96. package/dest/public/public_processor/public_processor_metrics.js +28 -4
  97. package/dest/public/public_tx_simulator/contract_provider_for_cpp.d.ts +3 -2
  98. package/dest/public/public_tx_simulator/contract_provider_for_cpp.d.ts.map +1 -1
  99. package/dest/public/public_tx_simulator/contract_provider_for_cpp.js +7 -6
  100. package/dest/public/public_tx_simulator/cpp_public_tx_simulator.d.ts +5 -5
  101. package/dest/public/public_tx_simulator/cpp_public_tx_simulator.d.ts.map +1 -1
  102. package/dest/public/public_tx_simulator/cpp_public_tx_simulator.js +10 -11
  103. package/dest/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.d.ts +4 -4
  104. package/dest/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.d.ts.map +1 -1
  105. package/dest/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.js +7 -7
  106. package/dest/public/public_tx_simulator/cpp_vs_ts_public_tx_simulator.d.ts +4 -4
  107. package/dest/public/public_tx_simulator/cpp_vs_ts_public_tx_simulator.d.ts.map +1 -1
  108. package/dest/public/public_tx_simulator/cpp_vs_ts_public_tx_simulator.js +6 -6
  109. package/dest/public/public_tx_simulator/dumping_cpp_public_tx_simulator.d.ts +3 -2
  110. package/dest/public/public_tx_simulator/dumping_cpp_public_tx_simulator.d.ts.map +1 -1
  111. package/dest/public/public_tx_simulator/dumping_cpp_public_tx_simulator.js +2 -2
  112. package/dest/public/public_tx_simulator/factories.d.ts +3 -2
  113. package/dest/public/public_tx_simulator/factories.d.ts.map +1 -1
  114. package/dest/public/public_tx_simulator/factories.js +4 -4
  115. package/dest/public/public_tx_simulator/public_tx_context.d.ts +10 -5
  116. package/dest/public/public_tx_simulator/public_tx_context.d.ts.map +1 -1
  117. package/dest/public/public_tx_simulator/public_tx_context.js +16 -18
  118. package/dest/public/public_tx_simulator/public_tx_simulator.d.ts +9 -4
  119. package/dest/public/public_tx_simulator/public_tx_simulator.d.ts.map +1 -1
  120. package/dest/public/public_tx_simulator/public_tx_simulator.js +19 -12
  121. package/dest/public/side_effect_trace.d.ts +4 -4
  122. package/dest/public/side_effect_trace.d.ts.map +1 -1
  123. package/dest/public/side_effect_trace.js +3 -3
  124. package/dest/public/state_manager/state_manager.d.ts +10 -4
  125. package/dest/public/state_manager/state_manager.d.ts.map +1 -1
  126. package/dest/public/state_manager/state_manager.js +13 -6
  127. package/dest/public/test_executor_metrics.d.ts +8 -2
  128. package/dest/public/test_executor_metrics.d.ts.map +1 -1
  129. package/dest/public/test_executor_metrics.js +24 -2
  130. package/package.json +16 -16
  131. package/src/client.ts +0 -2
  132. package/src/private/acvm/acvm.ts +4 -3
  133. package/src/private/acvm_native.ts +11 -5
  134. package/src/private/acvm_wasm.ts +11 -4
  135. package/src/private/circuit_recording/circuit_recorder.ts +89 -81
  136. package/src/private/circuit_recording/file_circuit_recorder.ts +45 -50
  137. package/src/private/circuit_recording/memory_circuit_recorder.ts +6 -4
  138. package/src/private/circuit_recording/simulator_recorder_wrapper.ts +9 -15
  139. package/src/private/factory.ts +7 -4
  140. package/src/public/avm/avm_gas.ts +2 -2
  141. package/src/public/avm/avm_simulator.ts +1 -1
  142. package/src/public/avm/calldata.ts +3 -2
  143. package/src/public/avm/fixtures/account_proof.json +553 -0
  144. package/src/public/avm/fixtures/account_proof_fetcher.ts +166 -0
  145. package/src/public/avm/fixtures/base_avm_simulation_tester.ts +23 -3
  146. package/src/public/avm/fixtures/utils.ts +4 -1
  147. package/src/public/avm/opcodes/accrued_substate.ts +10 -19
  148. package/src/public/avm/opcodes/contract.ts +5 -1
  149. package/src/public/avm/opcodes/ec_add.ts +12 -31
  150. package/src/public/avm/opcodes/external_calls.ts +1 -1
  151. package/src/public/avm/serialization/bytecode_serialization.ts +2 -2
  152. package/src/public/avm/serialization/instruction_serialization.ts +1 -1
  153. package/src/public/contracts_db_checkpoint.ts +1 -1
  154. package/src/public/executor_metrics.ts +4 -1
  155. package/src/public/fixtures/amm_test.ts +4 -4
  156. package/src/public/fixtures/bulk_test.ts +31 -6
  157. package/src/public/fixtures/custom_bytecode_tester.ts +2 -2
  158. package/src/public/fixtures/custom_bytecode_tests.ts +209 -2
  159. package/src/public/fixtures/opcode_spammer.ts +22 -63
  160. package/src/public/fixtures/public_tx_simulation_tester.ts +45 -5
  161. package/src/public/fixtures/token_test.ts +3 -3
  162. package/src/public/fixtures/utils.ts +23 -24
  163. package/src/public/fuzzing/avm_fuzzer_simulator.ts +1 -1
  164. package/src/public/hinting_db_sources.ts +10 -7
  165. package/src/public/public_db_sources.ts +36 -19
  166. package/src/public/public_processor/guarded_merkle_tree.ts +6 -6
  167. package/src/public/public_processor/public_processor.ts +173 -90
  168. package/src/public/public_processor/public_processor_metrics.ts +22 -4
  169. package/src/public/public_tx_simulator/contract_provider_for_cpp.ts +11 -7
  170. package/src/public/public_tx_simulator/cpp_public_tx_simulator.ts +10 -8
  171. package/src/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.ts +7 -5
  172. package/src/public/public_tx_simulator/cpp_vs_ts_public_tx_simulator.ts +7 -5
  173. package/src/public/public_tx_simulator/dumping_cpp_public_tx_simulator.ts +3 -1
  174. package/src/public/public_tx_simulator/factories.ts +6 -3
  175. package/src/public/public_tx_simulator/public_tx_context.ts +21 -16
  176. package/src/public/public_tx_simulator/public_tx_simulator.ts +20 -12
  177. package/src/public/side_effect_trace.ts +5 -2
  178. package/src/public/state_manager/state_manager.ts +28 -5
  179. package/src/public/test_executor_metrics.ts +27 -3
@@ -1,8 +1,10 @@
1
+ import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
2
+
1
3
  import { strict as assert } from 'assert';
2
4
 
3
5
  import { TypeTag } from '../avm/avm_memory_types.js';
4
6
  import { Addressing, AddressingMode } from '../avm/opcodes/addressing_mode.js';
5
- import { Add, CalldataCopy, Jump, Return, Set } from '../avm/opcodes/index.js';
7
+ import { Add, Call, CalldataCopy, Cast, Jump, Return, Set, Sha256Compression, Xor } from '../avm/opcodes/index.js';
6
8
  import { encodeToBytecode } from '../avm/serialization/bytecode_serialization.js';
7
9
  import {
8
10
  MAX_OPCODE_VALUE,
@@ -10,7 +12,7 @@ import {
10
12
  OperandType,
11
13
  getOperandSize,
12
14
  } from '../avm/serialization/instruction_serialization.js';
13
- import { deployAndExecuteCustomBytecode } from './custom_bytecode_tester.js';
15
+ import { deployAndExecuteCustomBytecode, deployCustomBytecode } from './custom_bytecode_tester.js';
14
16
  import { PublicTxSimulationTester } from './public_tx_simulation_tester.js';
15
17
 
16
18
  // First instruction resolved a base address (offset 0) which is uninitialized and therefore
@@ -208,6 +210,144 @@ export async function invalidTagValueAndInstructionTruncatedTest(tester: PublicT
208
210
  return await deployAndExecuteCustomBytecode(bytecode, tester, txLabel);
209
211
  }
210
212
 
213
+ // Exercise SET truncation: set values whose widths exceed the target tag and
214
+ // rely on `buildFromTagTruncating` to truncate to the low bits of the tag.
215
+ // Covers sources larger than 128 bits (via SET_FF) and sources in (32, 128]
216
+ // bits (via SET_64) against destination tags U1/U8/U16/U32/U64/U128.
217
+ export async function setTruncationTest(tester: PublicTxSimulationTester) {
218
+ // 200-bit value: forces truncation for every target tag up to U128.
219
+ const LARGE_FIELD_VALUE = (1n << 200n) + 0x1234567890abcdef1234567890abcdefn;
220
+ // 40-bit value: forces truncation for target tags up to U32.
221
+ const LARGE_U64_VALUE = (1n << 40n) + 0xdeadbeefn;
222
+
223
+ const bytecode = encodeToBytecode([
224
+ // Zero U32 at offset 0 — used as the Return copy-size slot.
225
+ new Set(/*addressing_mode=*/ 0, /*dstOffset=*/ 0, TypeTag.UINT32, /*value=*/ 0).as(Opcode.SET_8, Set.wireFormat8),
226
+
227
+ // Source >128 bits (via SET_FF) truncated to smaller target tags.
228
+ new Set(/*addressing_mode=*/ 0, /*dstOffset=*/ 1, TypeTag.UINT128, LARGE_FIELD_VALUE).as(
229
+ Opcode.SET_FF,
230
+ Set.wireFormatFF,
231
+ ),
232
+ new Set(/*addressing_mode=*/ 0, /*dstOffset=*/ 2, TypeTag.UINT64, LARGE_FIELD_VALUE).as(
233
+ Opcode.SET_FF,
234
+ Set.wireFormatFF,
235
+ ),
236
+ new Set(/*addressing_mode=*/ 0, /*dstOffset=*/ 3, TypeTag.UINT32, LARGE_FIELD_VALUE).as(
237
+ Opcode.SET_FF,
238
+ Set.wireFormatFF,
239
+ ),
240
+ new Set(/*addressing_mode=*/ 0, /*dstOffset=*/ 4, TypeTag.UINT16, LARGE_FIELD_VALUE).as(
241
+ Opcode.SET_FF,
242
+ Set.wireFormatFF,
243
+ ),
244
+ new Set(/*addressing_mode=*/ 0, /*dstOffset=*/ 5, TypeTag.UINT8, LARGE_FIELD_VALUE).as(
245
+ Opcode.SET_FF,
246
+ Set.wireFormatFF,
247
+ ),
248
+ new Set(/*addressing_mode=*/ 0, /*dstOffset=*/ 6, TypeTag.UINT1, LARGE_FIELD_VALUE).as(
249
+ Opcode.SET_FF,
250
+ Set.wireFormatFF,
251
+ ),
252
+
253
+ // Source in (32, 128] bits (via SET_64) truncated to smaller target tags.
254
+ new Set(/*addressing_mode=*/ 0, /*dstOffset=*/ 7, TypeTag.UINT32, LARGE_U64_VALUE).as(
255
+ Opcode.SET_64,
256
+ Set.wireFormat64,
257
+ ),
258
+ new Set(/*addressing_mode=*/ 0, /*dstOffset=*/ 8, TypeTag.UINT16, LARGE_U64_VALUE).as(
259
+ Opcode.SET_64,
260
+ Set.wireFormat64,
261
+ ),
262
+ new Set(/*addressing_mode=*/ 0, /*dstOffset=*/ 9, TypeTag.UINT8, LARGE_U64_VALUE).as(
263
+ Opcode.SET_64,
264
+ Set.wireFormat64,
265
+ ),
266
+ new Set(/*addressing_mode=*/ 0, /*dstOffset=*/ 10, TypeTag.UINT1, LARGE_U64_VALUE).as(
267
+ Opcode.SET_64,
268
+ Set.wireFormat64,
269
+ ),
270
+
271
+ new Return(/*addressing_mode=*/ 0, /*copySizeOffset=*/ 0, /*returnOffset=*/ 0),
272
+ ]);
273
+
274
+ const txLabel = 'SetTruncation';
275
+ return await deployAndExecuteCustomBytecode(bytecode, tester, txLabel);
276
+ }
277
+
278
+ // Exercise CAST truncation: store a wide source value in memory then CAST it
279
+ // to smaller destination tags. Covers sources larger than 128 bits (FIELD
280
+ // source) and sources in (32, 128] bits (UINT64 source) against destination
281
+ // tags U1/U8/U16/U32/U64/U128.
282
+ export async function castTruncationTest(tester: PublicTxSimulationTester) {
283
+ // 200-bit source: stored as FIELD so that CASTs to any integer tag truncate.
284
+ const LARGE_FIELD_VALUE = (1n << 200n) + 0x1234567890abcdef1234567890abcdefn;
285
+ // 40-bit source: stored as UINT64 so CASTs to U1/U8/U16/U32 truncate.
286
+ const LARGE_U64_VALUE = (1n << 40n) + 0xdeadbeefn;
287
+
288
+ const bytecode = encodeToBytecode([
289
+ // Zero U32 at offset 0 — used as the Return copy-size slot.
290
+ new Set(/*addressing_mode=*/ 0, /*dstOffset=*/ 0, TypeTag.UINT32, /*value=*/ 0).as(Opcode.SET_8, Set.wireFormat8),
291
+
292
+ // Store wide FIELD source at offset 10, then CAST to smaller tags.
293
+ new Set(/*addressing_mode=*/ 0, /*dstOffset=*/ 10, TypeTag.FIELD, LARGE_FIELD_VALUE).as(
294
+ Opcode.SET_FF,
295
+ Set.wireFormatFF,
296
+ ),
297
+ new Cast(/*addressing_mode=*/ 0, /*srcOffset=*/ 10, /*dstOffset=*/ 11, TypeTag.UINT128).as(
298
+ Opcode.CAST_8,
299
+ Cast.wireFormat8,
300
+ ),
301
+ new Cast(/*addressing_mode=*/ 0, /*srcOffset=*/ 10, /*dstOffset=*/ 12, TypeTag.UINT64).as(
302
+ Opcode.CAST_8,
303
+ Cast.wireFormat8,
304
+ ),
305
+ new Cast(/*addressing_mode=*/ 0, /*srcOffset=*/ 10, /*dstOffset=*/ 13, TypeTag.UINT32).as(
306
+ Opcode.CAST_8,
307
+ Cast.wireFormat8,
308
+ ),
309
+ new Cast(/*addressing_mode=*/ 0, /*srcOffset=*/ 10, /*dstOffset=*/ 14, TypeTag.UINT16).as(
310
+ Opcode.CAST_8,
311
+ Cast.wireFormat8,
312
+ ),
313
+ new Cast(/*addressing_mode=*/ 0, /*srcOffset=*/ 10, /*dstOffset=*/ 15, TypeTag.UINT8).as(
314
+ Opcode.CAST_8,
315
+ Cast.wireFormat8,
316
+ ),
317
+ new Cast(/*addressing_mode=*/ 0, /*srcOffset=*/ 10, /*dstOffset=*/ 16, TypeTag.UINT1).as(
318
+ Opcode.CAST_8,
319
+ Cast.wireFormat8,
320
+ ),
321
+
322
+ // Store UINT64 source at offset 20, then CAST to smaller integer tags.
323
+ new Set(/*addressing_mode=*/ 0, /*dstOffset=*/ 20, TypeTag.UINT64, LARGE_U64_VALUE).as(
324
+ Opcode.SET_64,
325
+ Set.wireFormat64,
326
+ ),
327
+ new Cast(/*addressing_mode=*/ 0, /*srcOffset=*/ 20, /*dstOffset=*/ 21, TypeTag.UINT32).as(
328
+ Opcode.CAST_8,
329
+ Cast.wireFormat8,
330
+ ),
331
+ new Cast(/*addressing_mode=*/ 0, /*srcOffset=*/ 20, /*dstOffset=*/ 22, TypeTag.UINT16).as(
332
+ Opcode.CAST_8,
333
+ Cast.wireFormat8,
334
+ ),
335
+ new Cast(/*addressing_mode=*/ 0, /*srcOffset=*/ 20, /*dstOffset=*/ 23, TypeTag.UINT8).as(
336
+ Opcode.CAST_8,
337
+ Cast.wireFormat8,
338
+ ),
339
+ new Cast(/*addressing_mode=*/ 0, /*srcOffset=*/ 20, /*dstOffset=*/ 24, TypeTag.UINT1).as(
340
+ Opcode.CAST_8,
341
+ Cast.wireFormat8,
342
+ ),
343
+
344
+ new Return(/*addressing_mode=*/ 0, /*copySizeOffset=*/ 0, /*returnOffset=*/ 0),
345
+ ]);
346
+
347
+ const txLabel = 'CastTruncation';
348
+ return await deployAndExecuteCustomBytecode(bytecode, tester, txLabel);
349
+ }
350
+
211
351
  /**
212
352
  * Returns the offset of the tag in an instruction.
213
353
  * @details Loops over the wire format operand type entries until it finds the tag.
@@ -226,3 +366,70 @@ function getTagOffsetInInstruction(wireFormat: OperandType[]): number {
226
366
  }
227
367
  return offset;
228
368
  }
369
+
370
+ export async function deployBitwiseSha256ErrorRowCollisionContracts(
371
+ tester: PublicTxSimulationTester,
372
+ ): Promise<{ innerContract: ContractInstanceWithAddress; outerContract: ContractInstanceWithAddress }> {
373
+ const innerBytecode = encodeToBytecode([
374
+ new Set(/*addressing_mode=*/ 0, /*dstOffset=*/ 0, TypeTag.UINT32, /*value=*/ 0).as(Opcode.SET_8, Set.wireFormat8),
375
+ new Set(/*addressing_mode=*/ 0, /*dstOffset=*/ 1, TypeTag.UINT16, /*value=*/ 0).as(Opcode.SET_8, Set.wireFormat8),
376
+ new Xor(/*addressing_mode=*/ 0, /*aOffset=*/ 0, /*bOffset=*/ 1, /*dstOffset=*/ 2).as(Opcode.XOR_8, Xor.wireFormat8),
377
+ new Return(/*addressing_mode=*/ 0, /*copySizeOffset=*/ 0, /*returnOffset=*/ 0),
378
+ ]);
379
+
380
+ const outerInstructions = [
381
+ new Set(/*addressing_mode=*/ 0, /*dstOffset=*/ 0, TypeTag.UINT32, /*value=*/ 0).as(Opcode.SET_8, Set.wireFormat8),
382
+ new Set(/*addressing_mode=*/ 0, /*dstOffset=*/ 1, TypeTag.UINT32, /*value=*/ 1).as(Opcode.SET_8, Set.wireFormat8),
383
+ new Set(/*addressing_mode=*/ 0, /*dstOffset=*/ 2, TypeTag.UINT32, /*value=*/ 100_000).as(
384
+ Opcode.SET_32,
385
+ Set.wireFormat32,
386
+ ),
387
+ new CalldataCopy(/*addressing_mode=*/ 0, /*copySizeOffset=*/ 1, /*cdStartOffset=*/ 0, /*dstOffset=*/ 3),
388
+ new Call(
389
+ /*addressing_mode=*/ 0,
390
+ /*l2GasOffset=*/ 2,
391
+ /*daGasOffset=*/ 2,
392
+ /*addrOffset=*/ 3,
393
+ /*argsSizeOffset=*/ 0,
394
+ /*argsOffset=*/ 0,
395
+ ),
396
+ ];
397
+
398
+ for (let i = 0; i < 8; i++) {
399
+ outerInstructions.push(
400
+ new Set(/*addressing_mode=*/ 0, /*dstOffset=*/ 10 + i, TypeTag.UINT32, /*value=*/ 0).as(
401
+ Opcode.SET_8,
402
+ Set.wireFormat8,
403
+ ),
404
+ );
405
+ }
406
+
407
+ outerInstructions.push(
408
+ new Set(/*addressing_mode=*/ 0, /*dstOffset=*/ 18, TypeTag.UINT32, /*value=*/ 0x61626364).as(
409
+ Opcode.SET_32,
410
+ Set.wireFormat32,
411
+ ),
412
+ );
413
+
414
+ for (let i = 0; i < 15; i++) {
415
+ outerInstructions.push(
416
+ new Set(/*addressing_mode=*/ 0, /*dstOffset=*/ 19 + i, TypeTag.UINT32, /*value=*/ 0).as(
417
+ Opcode.SET_8,
418
+ Set.wireFormat8,
419
+ ),
420
+ );
421
+ }
422
+
423
+ outerInstructions.push(
424
+ new Sha256Compression(/*addressing_mode=*/ 0, /*outputOffset=*/ 34, /*stateOffset=*/ 10, /*inputsOffset=*/ 18),
425
+ new Return(/*addressing_mode=*/ 0, /*copySizeOffset=*/ 0, /*returnOffset=*/ 0),
426
+ );
427
+
428
+ const innerContract = await deployCustomBytecode(innerBytecode, tester, 'BitwiseSha256CollisionInner');
429
+ const outerContract = await deployCustomBytecode(
430
+ encodeToBytecode(outerInstructions),
431
+ tester,
432
+ 'BitwiseSha256CollisionOuter',
433
+ );
434
+ return { innerContract, outerContract };
435
+ }
@@ -143,7 +143,7 @@
143
143
  * - `EMITNOTEHASH`: max 64 per TX
144
144
  * - `EMITNULLIFIER`: max 63 per TX (one reserved for TX nullifier)
145
145
  * - `SENDL2TOL1MSG`: max 8 per TX
146
- * - `EMITUNENCRYPTEDLOG`: limited by total log payload size
146
+ * - `EMITPUBLICLOG`: limited by total log payload size
147
147
  *
148
148
  * By having the inner contract REVERT after emitting side effects, those effects are discarded, allowing the outer contract to call it again. This enables thousands of opcode executions per TX instead of just the limit.
149
149
  *
@@ -164,7 +164,7 @@ import { Fr } from '@aztec/foundation/curves/bn254';
164
164
  import type { Bufferable } from '@aztec/foundation/serialize';
165
165
  import { type CallStackMetadata, PublicDataWrite, type PublicTxResult } from '@aztec/stdlib/avm';
166
166
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
167
- import { computePublicDataTreeLeafSlot, siloNullifier } from '@aztec/stdlib/hash';
167
+ import { computePublicDataTreeLeafSlot } from '@aztec/stdlib/hash';
168
168
  import type { MerkleTreeWriteOperations } from '@aztec/stdlib/interfaces/server';
169
169
  import { MerkleTreeId } from '@aztec/stdlib/trees';
170
170
 
@@ -182,7 +182,7 @@ import {
182
182
  EcAdd,
183
183
  EmitNoteHash,
184
184
  EmitNullifier,
185
- EmitUnencryptedLog,
185
+ EmitPublicLog,
186
186
  Eq,
187
187
  FieldDiv,
188
188
  GetContractInstance,
@@ -295,9 +295,8 @@ export interface SpamConfigsForOpcode {
295
295
  export const WARM_NOTE_HASH = new Fr(0xdeadbeefn);
296
296
  export const WARM_L1_TO_L2_MSG = new Fr(0xcafebabedeadbeefn);
297
297
 
298
- /** Warm nullifier constants - uses a fixed address since NULLIFIEREXISTS takes address as parameter */
299
- export const WARM_NULLIFIER = new Fr(0xdeadbeef0001n);
300
- export const WARM_NULLIFIER_ADDRESS = AztecAddress.fromNumber(0xbeef);
298
+ /** Warm nullifier constant - a pre-siloed nullifier value inserted directly into the tree */
299
+ export const WARM_SILOED_NULLIFIER = new Fr(0xdeadbeef0001n);
301
300
 
302
301
  /** Warm storage constants - storage is inserted for the deployed contract's address */
303
302
  export const WARM_STORAGE_SLOT = new Fr(0xdeadbeef0002n);
@@ -331,9 +330,8 @@ export async function insertWarmTreeEntries(
331
330
  // Insert into L1 to L2 message tree
332
331
  await merkleTrees.appendLeaves(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, [WARM_L1_TO_L2_MSG]);
333
332
 
334
- // Insert siloed nullifier into nullifier tree
335
- const siloedNullifier = await siloNullifier(WARM_NULLIFIER_ADDRESS, WARM_NULLIFIER);
336
- await merkleTrees.sequentialInsert(MerkleTreeId.NULLIFIER_TREE, [siloedNullifier.toBuffer()]);
333
+ // Insert siloed nullifier into nullifier tree (already siloed - used directly by NULLIFIEREXISTS)
334
+ await merkleTrees.sequentialInsert(MerkleTreeId.NULLIFIER_TREE, [WARM_SILOED_NULLIFIER.toBuffer()]);
337
335
 
338
336
  // Insert storage value into public data tree
339
337
  const leafSlot = await computePublicDataTreeLeafSlot(contractAddress, WARM_STORAGE_SLOT);
@@ -1060,56 +1058,25 @@ export const SPAM_CONFIGS: Partial<Record<Opcode, SpamConfig[]>> = {
1060
1058
  [Opcode.NULLIFIEREXISTS]: [
1061
1059
  {
1062
1060
  label: 'Non-existent nullifier',
1061
+ // NULLIFIEREXISTS now takes a siloed nullifier directly (no address parameter)
1063
1062
  setup: [
1064
- { offset: 0, value: new Field(Fr.random()) }, // random nullifier
1065
- { offset: 1, value: new Field(Fr.random()) }, // random address
1063
+ { offset: 0, value: new Field(Fr.random()) }, // random siloed nullifier (won't exist)
1066
1064
  ],
1067
1065
  targetInstructions: () => [
1068
- new NullifierExists(/*addressing_mode=*/ 0, /*nullifierOffset=*/ 0, /*addressOffset=*/ 1, /*existsOffset=*/ 2),
1066
+ new NullifierExists(/*addressing_mode=*/ 0, /*siloedNullifierOffset=*/ 0, /*existsOffset=*/ 1),
1069
1067
  ],
1070
1068
  },
1071
1069
  {
1072
1070
  label: 'Existing nullifier (warm - from tree)',
1073
- // Uses pre-inserted nullifier from insertWarmTreeEntries()
1071
+ // Uses pre-inserted siloed nullifier from insertWarmTreeEntries()
1072
+ // NULLIFIEREXISTS now takes a siloed nullifier directly
1074
1073
  setup: [
1075
- { offset: 0, value: new Field(WARM_NULLIFIER) }, // pre-inserted nullifier
1076
- { offset: 1, value: new Field(WARM_NULLIFIER_ADDRESS.toField()) }, // address it was siloed with
1074
+ { offset: 0, value: new Field(WARM_SILOED_NULLIFIER) }, // pre-inserted siloed nullifier
1077
1075
  ],
1078
1076
  targetInstructions: () => [
1079
- new NullifierExists(/*addressing_mode=*/ 0, /*nullifierOffset=*/ 0, /*addressOffset=*/ 1, /*existsOffset=*/ 2),
1077
+ new NullifierExists(/*addressing_mode=*/ 0, /*siloedNullifierOffset=*/ 0, /*existsOffset=*/ 1),
1080
1078
  ],
1081
1079
  },
1082
- {
1083
- label: 'Existing nullifier (warm - EMITNULLIFIER first)',
1084
- // Memory layout: nullifier (incremented), constant 1, current address (from GETENVVAR), revertSize, exists result
1085
- setup: [
1086
- { offset: 0, value: new Field(Fr.random()) }, // nullifier (will be incremented)
1087
- { offset: 1, value: new Field(1n) }, // constant 1 for ADD
1088
- () => [
1089
- // Get current contract address into offset 2
1090
- new GetEnvVar(/*addressing_mode=*/ 0, /*dstOffset=*/ 2, /*varEnum=*/ 0).as(
1091
- Opcode.GETENVVAR_16,
1092
- GetEnvVar.wireFormat16,
1093
- ),
1094
- ],
1095
- { offset: 3, value: new Uint32(0n) }, // revertSize
1096
- ],
1097
- targetInstructions: () => [
1098
- new EmitNullifier(/*addressing_mode=*/ 0, /*nullifierOffset=*/ 0),
1099
- new NullifierExists(/*addressing_mode=*/ 0, /*nullifierOffset=*/ 0, /*addressOffset=*/ 2, /*existsOffset=*/ 4),
1100
- new Add(/*addressing_mode=*/ 0, /*aOffset=*/ 0, /*bOffset=*/ 1, /*dstOffset=*/ 0).as(
1101
- Opcode.ADD_8,
1102
- Add.wireFormat8,
1103
- ), // nullifier++
1104
- ],
1105
- cleanupInstructions: () => [
1106
- new Revert(/*addressing_mode=*/ 0, /*retSizeOffset=*/ 3, /*returnOffset=*/ 0).as(
1107
- Opcode.REVERT_8,
1108
- Revert.wireFormat8,
1109
- ),
1110
- ],
1111
- limit: MAX_NULLIFIERS_PER_TX - 1,
1112
- },
1113
1080
  ],
1114
1081
 
1115
1082
  [Opcode.L1TOL2MSGEXISTS]: [
@@ -1275,17 +1242,15 @@ export const SPAM_CONFIGS: Partial<Record<Opcode, SpamConfig[]>> = {
1275
1242
  },
1276
1243
  ],
1277
1244
 
1278
- // EMITUNENCRYPTEDLOG - two configs: minimal (many small logs) and max-size (one large log)
1279
- [Opcode.EMITUNENCRYPTEDLOG]: [
1245
+ // EMITPUBLICLOG - two configs: minimal (many small logs) and max-size (one large log)
1246
+ [Opcode.EMITPUBLICLOG]: [
1280
1247
  {
1281
1248
  label: 'Many empty logs, revert, repeat',
1282
1249
  setup: [
1283
1250
  { offset: 0, value: new Uint32(0n) }, // logSize = 0 fields (minimal)
1284
1251
  { offset: 1, value: new Uint32(0n) }, // revertSize
1285
1252
  ],
1286
- targetInstructions: () => [
1287
- new EmitUnencryptedLog(/*addressing_mode=*/ 0, /*logSizeOffset=*/ 0, /*logOffset=*/ 1),
1288
- ], // logOffset doesn't matter when size is 0
1253
+ targetInstructions: () => [new EmitPublicLog(/*addressing_mode=*/ 0, /*logSizeOffset=*/ 0, /*logOffset=*/ 1)], // logOffset doesn't matter when size is 0
1289
1254
  cleanupInstructions: () => [
1290
1255
  new Revert(/*addressing_mode=*/ 0, /*retSizeOffset=*/ 1, /*returnOffset=*/ 0).as(
1291
1256
  Opcode.REVERT_8,
@@ -1309,9 +1274,7 @@ export const SPAM_CONFIGS: Partial<Record<Opcode, SpamConfig[]>> = {
1309
1274
  // value: new Field(0n),
1310
1275
  //})),
1311
1276
  ],
1312
- targetInstructions: () => [
1313
- new EmitUnencryptedLog(/*addressing_mode=*/ 0, /*logSizeOffset=*/ 0, /*logOffset=*/ 2),
1314
- ], // uses logOffset 2 (uninitialized Field(0))
1277
+ targetInstructions: () => [new EmitPublicLog(/*addressing_mode=*/ 0, /*logSizeOffset=*/ 0, /*logOffset=*/ 2)], // uses logOffset 2 (uninitialized Field(0))
1315
1278
  cleanupInstructions: () => [
1316
1279
  new Revert(/*addressing_mode=*/ 0, /*retSizeOffset=*/ 1, /*returnOffset=*/ 0).as(
1317
1280
  Opcode.REVERT_8,
@@ -1376,20 +1339,16 @@ export const SPAM_CONFIGS: Partial<Record<Opcode, SpamConfig[]>> = {
1376
1339
  setup: [
1377
1340
  { offset: 0, value: new Field(Grumpkin.generator.x) }, // p1X = G.x
1378
1341
  { offset: 1, value: new Field(Grumpkin.generator.y) }, // p1Y = G.y
1379
- { offset: 2, value: new Uint1(0n) }, // p1IsInfinite = false
1380
- { offset: 3, value: new Field(Grumpkin.generator.x) }, // p2X = G.x
1381
- { offset: 4, value: new Field(Grumpkin.generator.y) }, // p2Y = G.y
1382
- { offset: 5, value: new Uint1(0n) }, // p2IsInfinite = false
1342
+ { offset: 2, value: new Field(Grumpkin.generator.x) }, // p2X = G.x
1343
+ { offset: 3, value: new Field(Grumpkin.generator.y) }, // p2Y = G.y
1383
1344
  ],
1384
1345
  targetInstructions: () => [
1385
1346
  new EcAdd(
1386
1347
  /*addressing_mode=*/ 0,
1387
1348
  /*p1XOffset=*/ 0,
1388
1349
  /*p1YOffset=*/ 1,
1389
- /*p1IsInfiniteOffset=*/ 2,
1390
- /*p2XOffset=*/ 3,
1391
- /*p2YOffset=*/ 4,
1392
- /*p2IsInfiniteOffset=*/ 5,
1350
+ /*p2XOffset=*/ 2,
1351
+ /*p2YOffset=*/ 3,
1393
1352
  /*dstOffset=*/ 0,
1394
1353
  ),
1395
1354
  ],
@@ -1,4 +1,4 @@
1
- import { DEFAULT_TEARDOWN_DA_GAS_LIMIT, DEFAULT_TEARDOWN_L2_GAS_LIMIT } from '@aztec/constants';
1
+ import { PUBLIC_TX_L2_GAS_OVERHEAD, TX_DA_GAS_OVERHEAD } from '@aztec/constants';
2
2
  import { asyncMap } from '@aztec/foundation/async-map';
3
3
  import { BlockNumber } from '@aztec/foundation/branded-types';
4
4
  import { Fr } from '@aztec/foundation/curves/bn254';
@@ -27,6 +27,8 @@ import { SimpleContractDataSource } from './simple_contract_data_source.js';
27
27
  import { type TestPrivateInsertions, createTxForPublicCalls } from './utils.js';
28
28
 
29
29
  const DEFAULT_GAS_FEES = new GasFees(2, 3);
30
+ const TEARDOWN_DA_GAS_LIMIT = 98_304;
31
+ const TEARDOWN_L2_GAS_LIMIT = 817_500;
30
32
 
31
33
  export type TestEnqueuedCall = {
32
34
  sender?: AztecAddress;
@@ -112,6 +114,7 @@ export class PublicTxSimulationTester extends BaseAvmSimulationTester {
112
114
  feePayer: AztecAddress = sender,
113
115
  /* need some unique first nullifier for note-nonce computations */
114
116
  privateInsertions: TestPrivateInsertions = { nonRevertible: { nullifiers: [new Fr(420000 + this.txCount)] } },
117
+ gasLimits?: Gas,
115
118
  ): Promise<Tx> {
116
119
  const setupCallRequests = await asyncMap(setupCalls, call =>
117
120
  this.#createPubicCallRequestForCall(call, call.sender ?? sender),
@@ -131,9 +134,10 @@ export class PublicTxSimulationTester extends BaseAvmSimulationTester {
131
134
  teardownCallRequest,
132
135
  feePayer,
133
136
  /*gasUsedByPrivate*/ teardownCall
134
- ? new Gas(DEFAULT_TEARDOWN_DA_GAS_LIMIT, DEFAULT_TEARDOWN_L2_GAS_LIMIT)
135
- : Gas.empty(),
137
+ ? new Gas(TEARDOWN_DA_GAS_LIMIT + TX_DA_GAS_OVERHEAD, TEARDOWN_L2_GAS_LIMIT + PUBLIC_TX_L2_GAS_OVERHEAD)
138
+ : new Gas(TX_DA_GAS_OVERHEAD, PUBLIC_TX_L2_GAS_OVERHEAD),
136
139
  defaultGlobals(),
140
+ gasLimits,
137
141
  );
138
142
  }
139
143
 
@@ -146,8 +150,9 @@ export class PublicTxSimulationTester extends BaseAvmSimulationTester {
146
150
  /* need some unique first nullifier for note-nonce computations */
147
151
  privateInsertions?: TestPrivateInsertions,
148
152
  txLabel: string = 'unlabeledTx',
153
+ gasLimits?: Gas,
149
154
  ): Promise<PublicTxResult> {
150
- const tx = await this.createTx(sender, setupCalls, appCalls, teardownCall, feePayer, privateInsertions);
155
+ const tx = await this.createTx(sender, setupCalls, appCalls, teardownCall, feePayer, privateInsertions, gasLimits);
151
156
 
152
157
  await this.setFeePayerBalance(feePayer);
153
158
 
@@ -161,6 +166,8 @@ export class PublicTxSimulationTester extends BaseAvmSimulationTester {
161
166
  }
162
167
  const avmResult = await this.simulator.simulate(tx, fullTxLabel);
163
168
 
169
+ await this.#recordBytecodeSizes(fullTxLabel, [...setupCalls, ...appCalls, ...(teardownCall ? [teardownCall] : [])]);
170
+
164
171
  // Something like this is often useful for debugging:
165
172
  //if (avmResult.revertReason) {
166
173
  // // resolve / enrich revert reason
@@ -190,8 +197,18 @@ export class PublicTxSimulationTester extends BaseAvmSimulationTester {
190
197
  teardownCall?: TestEnqueuedCall,
191
198
  feePayer?: AztecAddress,
192
199
  privateInsertions?: TestPrivateInsertions,
200
+ gasLimits?: Gas,
193
201
  ): Promise<PublicTxResult> {
194
- return await this.simulateTx(sender, setupCalls, appCalls, teardownCall, feePayer, privateInsertions, txLabel);
202
+ return await this.simulateTx(
203
+ sender,
204
+ setupCalls,
205
+ appCalls,
206
+ teardownCall,
207
+ feePayer,
208
+ privateInsertions,
209
+ txLabel,
210
+ gasLimits,
211
+ );
195
212
  }
196
213
 
197
214
  /**
@@ -209,6 +226,7 @@ export class PublicTxSimulationTester extends BaseAvmSimulationTester {
209
226
  teardownCall?: TestEnqueuedCall,
210
227
  feePayer?: AztecAddress,
211
228
  privateInsertions?: TestPrivateInsertions,
229
+ gasLimits?: Gas,
212
230
  ): Promise<PublicTxResult> {
213
231
  return await this.simulateTxWithLabel(
214
232
  txLabel,
@@ -218,6 +236,7 @@ export class PublicTxSimulationTester extends BaseAvmSimulationTester {
218
236
  teardownCall,
219
237
  feePayer,
220
238
  privateInsertions,
239
+ gasLimits,
221
240
  );
222
241
  }
223
242
 
@@ -277,6 +296,27 @@ export class PublicTxSimulationTester extends BaseAvmSimulationTester {
277
296
 
278
297
  return new PublicCallRequestWithCalldata(request, calldata);
279
298
  }
299
+
300
+ // WARNING: Deduplicates by artifact name, so two different artifacts with the same name
301
+ // in a single tx would only record the first one's bytecode size.
302
+ async #recordBytecodeSizes(txLabel: string, calls: TestEnqueuedCall[]) {
303
+ const seenArtifactNames = new Set<string>();
304
+ for (const call of calls) {
305
+ const artifact = await this.contractDataSource.getContractArtifact(call.address);
306
+ if (!artifact || seenArtifactNames.has(artifact.name)) {
307
+ continue;
308
+ }
309
+ seenArtifactNames.add(artifact.name);
310
+ const instance = await this.contractDataSource.getContract(call.address);
311
+ if (!instance) {
312
+ continue;
313
+ }
314
+ const contractClass = await this.contractDataSource.getContractClass(instance.currentContractClassId);
315
+ if (contractClass) {
316
+ this.metrics.recordBytecodeSize(txLabel, artifact.name, contractClass.packedBytecode.length);
317
+ }
318
+ }
319
+ }
280
320
  }
281
321
 
282
322
  export function defaultGlobals() {
@@ -21,9 +21,9 @@ export async function tokenTest(
21
21
  ) {
22
22
  const timer = new Timer();
23
23
 
24
- const admin = AztecAddress.fromNumber(42);
25
- const sender = AztecAddress.fromNumber(111);
26
- const receiver = AztecAddress.fromNumber(222);
24
+ const admin = AztecAddress.fromNumberUnsafe(42);
25
+ const sender = AztecAddress.fromNumberUnsafe(111);
26
+ const receiver = AztecAddress.fromNumberUnsafe(222);
27
27
 
28
28
  const token = await setUpToken(tester, tokenArtifact, admin, expectToBeTrue);
29
29
 
@@ -2,10 +2,8 @@ import {
2
2
  CONTRACT_CLASS_PUBLISHED_MAGIC_VALUE,
3
3
  CONTRACT_CLASS_REGISTRY_CONTRACT_ADDRESS,
4
4
  CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS,
5
- DEFAULT_DA_GAS_LIMIT,
6
- DEFAULT_L2_GAS_LIMIT,
7
- DEFAULT_TEARDOWN_DA_GAS_LIMIT,
8
- DEFAULT_TEARDOWN_L2_GAS_LIMIT,
5
+ MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT,
6
+ MAX_PROCESSABLE_L2_GAS,
9
7
  PRIVATE_LOG_SIZE_IN_FIELDS,
10
8
  } from '@aztec/constants';
11
9
  import { padArrayEnd } from '@aztec/foundation/collection';
@@ -38,6 +36,9 @@ import {
38
36
 
39
37
  import { strict as assert } from 'assert';
40
38
 
39
+ const TEARDOWN_DA_GAS_LIMIT = 98_304;
40
+ const TEARDOWN_L2_GAS_LIMIT = 817_500;
41
+
41
42
  export type TestPrivateInsertions = {
42
43
  revertible?: {
43
44
  nullifiers?: Fr[];
@@ -62,13 +63,14 @@ export async function createTxForPublicCalls(
62
63
  feePayer = AztecAddress.zero(),
63
64
  gasUsedByPrivate: Gas = Gas.empty(),
64
65
  globals: GlobalVariables = GlobalVariables.empty(),
66
+ gasLimits?: Gas,
65
67
  ): Promise<Tx> {
66
68
  assert(
67
69
  setupCallRequests.length > 0 || appCallRequests.length > 0 || teardownCallRequest !== undefined,
68
70
  "Can't create public tx with no enqueued calls",
69
71
  );
70
72
  // use max limits
71
- const gasLimits = new Gas(DEFAULT_DA_GAS_LIMIT, DEFAULT_L2_GAS_LIMIT);
73
+ gasLimits = gasLimits ?? new Gas(MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT, MAX_PROCESSABLE_L2_GAS);
72
74
 
73
75
  const forPublic = PartialPrivateTailPublicInputsForPublic.empty();
74
76
 
@@ -127,20 +129,18 @@ export async function createTxForPublicCalls(
127
129
  }
128
130
 
129
131
  const maxFeesPerGas = feePayer.isZero() ? GasFees.empty() : new GasFees(10, 10);
130
- const teardownGasLimits = teardownCallRequest
131
- ? new Gas(DEFAULT_TEARDOWN_DA_GAS_LIMIT, DEFAULT_TEARDOWN_L2_GAS_LIMIT)
132
- : Gas.empty();
132
+ const teardownGasLimits = teardownCallRequest ? new Gas(TEARDOWN_DA_GAS_LIMIT, TEARDOWN_L2_GAS_LIMIT) : Gas.empty();
133
133
  const gasSettings = new GasSettings(gasLimits, teardownGasLimits, maxFeesPerGas, GasFees.empty());
134
134
  const txContext = new TxContext(Fr.zero(), Fr.zero(), gasSettings);
135
135
  const header = BlockHeader.empty({ globalVariables: globals });
136
136
  const constantData = new TxConstantData(header, txContext, Fr.zero(), Fr.zero());
137
- const includeByTimestamp = 0n; // Not used in the simulator.
137
+ const expirationTimestamp = 0n; // Not used in the simulator.
138
138
 
139
139
  const txData = new PrivateKernelTailCircuitPublicInputs(
140
140
  constantData,
141
141
  /*gasUsed=*/ gasUsedByPrivate,
142
142
  feePayer,
143
- includeByTimestamp,
143
+ expirationTimestamp,
144
144
  forPublic,
145
145
  );
146
146
 
@@ -163,7 +163,7 @@ export async function createTxForPrivateOnly(
163
163
  gasUsedByPrivate: Gas = new Gas(10, 10),
164
164
  ): Promise<Tx> {
165
165
  // use max limits
166
- const gasLimits = new Gas(DEFAULT_DA_GAS_LIMIT, DEFAULT_L2_GAS_LIMIT);
166
+ const gasLimits = new Gas(MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT, MAX_PROCESSABLE_L2_GAS);
167
167
 
168
168
  const forRollup = PartialPrivateTailPublicInputsForRollup.empty();
169
169
 
@@ -171,13 +171,13 @@ export async function createTxForPrivateOnly(
171
171
  const gasSettings = new GasSettings(gasLimits, Gas.empty(), maxFeesPerGas, GasFees.empty());
172
172
  const txContext = new TxContext(Fr.zero(), Fr.zero(), gasSettings);
173
173
  const constantData = new TxConstantData(BlockHeader.empty(), txContext, Fr.zero(), Fr.zero());
174
- const includeByTimestamp = 0n; // Not used in the simulator.
174
+ const expirationTimestamp = 0n; // Not used in the simulator.
175
175
 
176
176
  const txData = new PrivateKernelTailCircuitPublicInputs(
177
177
  constantData,
178
178
  /*gasUsed=*/ gasUsedByPrivate,
179
179
  feePayer,
180
- includeByTimestamp,
180
+ expirationTimestamp,
181
181
  /*forPublic=*/ undefined,
182
182
  forRollup,
183
183
  );
@@ -228,17 +228,15 @@ export async function addNewContractInstanceToTx(
228
228
  contractInstance: ContractInstanceWithAddress,
229
229
  skipNullifierInsertion = false,
230
230
  ) {
231
- // can't use publicKeys.toFields() because it includes isInfinite which
232
- // is not broadcast in such private logs
231
+ // Only ivpk_m is broadcast as a point (x, y); the other five keys are hashes.
233
232
  const publicKeysAsFields = [
234
- contractInstance.publicKeys.masterNullifierPublicKey.x,
235
- contractInstance.publicKeys.masterNullifierPublicKey.y,
236
- contractInstance.publicKeys.masterIncomingViewingPublicKey.x,
237
- contractInstance.publicKeys.masterIncomingViewingPublicKey.y,
238
- contractInstance.publicKeys.masterOutgoingViewingPublicKey.x,
239
- contractInstance.publicKeys.masterOutgoingViewingPublicKey.y,
240
- contractInstance.publicKeys.masterTaggingPublicKey.x,
241
- contractInstance.publicKeys.masterTaggingPublicKey.y,
233
+ contractInstance.publicKeys.npkMHash,
234
+ contractInstance.publicKeys.ivpkM.x,
235
+ contractInstance.publicKeys.ivpkM.y,
236
+ contractInstance.publicKeys.ovpkMHash,
237
+ contractInstance.publicKeys.tpkMHash,
238
+ contractInstance.publicKeys.mspkMHash,
239
+ contractInstance.publicKeys.fbpkMHash,
242
240
  ];
243
241
  const logFields = [
244
242
  CONTRACT_INSTANCE_PUBLISHED_EVENT_TAG,
@@ -247,6 +245,7 @@ export async function addNewContractInstanceToTx(
247
245
  new Fr(contractInstance.salt),
248
246
  contractInstance.currentContractClassId,
249
247
  contractInstance.initializationHash,
248
+ contractInstance.immutablesHash,
250
249
  ...publicKeysAsFields,
251
250
  contractInstance.deployer.toField(),
252
251
  ];
@@ -256,7 +255,7 @@ export async function addNewContractInstanceToTx(
256
255
  );
257
256
 
258
257
  const contractAddressNullifier = await siloNullifier(
259
- AztecAddress.fromNumber(CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS),
258
+ AztecAddress.fromNumberUnsafe(CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS),
260
259
  contractInstance.address.toField(),
261
260
  );
262
261
 
@@ -146,7 +146,7 @@ async function createTxFromHint(cppTx: AvmTxHint): Promise<Tx> {
146
146
  constants,
147
147
  cppTx.gasUsedByPrivate,
148
148
  cppTx.feePayer,
149
- 0n, // includeByTimestamp
149
+ 0n, // expirationTimestamp
150
150
  forPublic,
151
151
  undefined, // forRollup - not needed for public simulation
152
152
  );