@aztec/simulator 0.0.1-commit.7d4e6cd → 0.0.1-commit.808bf7f90

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 (238) hide show
  1. package/README.md +6 -4
  2. package/dest/common/errors.d.ts +7 -1
  3. package/dest/common/errors.d.ts.map +1 -1
  4. package/dest/private/acvm/acvm.d.ts +4 -2
  5. package/dest/private/acvm/acvm.d.ts.map +1 -1
  6. package/dest/private/acvm/acvm.js +4 -3
  7. package/dest/private/acvm_native.d.ts +5 -3
  8. package/dest/private/acvm_native.d.ts.map +1 -1
  9. package/dest/private/acvm_native.js +8 -6
  10. package/dest/private/acvm_wasm.d.ts +4 -3
  11. package/dest/private/acvm_wasm.d.ts.map +1 -1
  12. package/dest/private/acvm_wasm.js +4 -4
  13. package/dest/private/circuit_recording/circuit_recorder.d.ts +4 -3
  14. package/dest/private/circuit_recording/circuit_recorder.d.ts.map +1 -1
  15. package/dest/private/circuit_recording/circuit_recorder.js +5 -3
  16. package/dest/private/circuit_recording/file_circuit_recorder.d.ts +3 -2
  17. package/dest/private/circuit_recording/file_circuit_recorder.d.ts.map +1 -1
  18. package/dest/private/circuit_recording/file_circuit_recorder.js +2 -2
  19. package/dest/private/circuit_recording/memory_circuit_recorder.d.ts +7 -2
  20. package/dest/private/circuit_recording/memory_circuit_recorder.d.ts.map +1 -1
  21. package/dest/private/circuit_recording/memory_circuit_recorder.js +4 -4
  22. package/dest/private/factory.d.ts +3 -3
  23. package/dest/private/factory.d.ts.map +1 -1
  24. package/dest/private/factory.js +7 -4
  25. package/dest/public/avm/avm_context.d.ts +3 -3
  26. package/dest/public/avm/avm_context.d.ts.map +1 -1
  27. package/dest/public/avm/avm_contract_call_result.d.ts +6 -6
  28. package/dest/public/avm/avm_contract_call_result.d.ts.map +1 -1
  29. package/dest/public/avm/avm_contract_call_result.js +3 -3
  30. package/dest/public/avm/avm_execution_environment.d.ts +6 -5
  31. package/dest/public/avm/avm_execution_environment.d.ts.map +1 -1
  32. package/dest/public/avm/avm_gas.js +3 -3
  33. package/dest/public/avm/avm_machine_state.d.ts +6 -5
  34. package/dest/public/avm/avm_machine_state.d.ts.map +1 -1
  35. package/dest/public/avm/avm_machine_state.js +3 -2
  36. package/dest/public/avm/avm_memory_types.d.ts +1 -1
  37. package/dest/public/avm/avm_memory_types.d.ts.map +1 -1
  38. package/dest/public/avm/avm_memory_types.js +3 -0
  39. package/dest/public/avm/avm_simulator.d.ts +3 -2
  40. package/dest/public/avm/avm_simulator.d.ts.map +1 -1
  41. package/dest/public/avm/avm_simulator.js +5 -4
  42. package/dest/public/avm/calldata.d.ts +51 -0
  43. package/dest/public/avm/calldata.d.ts.map +1 -0
  44. package/dest/public/avm/calldata.js +63 -0
  45. package/dest/public/avm/fixtures/account_proof_fetcher.d.ts +2 -0
  46. package/dest/public/avm/fixtures/account_proof_fetcher.d.ts.map +1 -0
  47. package/dest/public/avm/fixtures/account_proof_fetcher.js +152 -0
  48. package/dest/public/avm/fixtures/avm_simulation_tester.d.ts +1 -1
  49. package/dest/public/avm/fixtures/avm_simulation_tester.d.ts.map +1 -1
  50. package/dest/public/avm/fixtures/avm_simulation_tester.js +3 -2
  51. package/dest/public/avm/fixtures/initializers.d.ts +1 -1
  52. package/dest/public/avm/fixtures/initializers.d.ts.map +1 -1
  53. package/dest/public/avm/fixtures/initializers.js +2 -1
  54. package/dest/public/avm/opcodes/accrued_substate.d.ts +17 -18
  55. package/dest/public/avm/opcodes/accrued_substate.d.ts.map +1 -1
  56. package/dest/public/avm/opcodes/accrued_substate.js +41 -42
  57. package/dest/public/avm/opcodes/arithmetic.d.ts +8 -8
  58. package/dest/public/avm/opcodes/arithmetic.d.ts.map +1 -1
  59. package/dest/public/avm/opcodes/arithmetic.js +1 -1
  60. package/dest/public/avm/opcodes/bitwise.d.ts +7 -7
  61. package/dest/public/avm/opcodes/bitwise.d.ts.map +1 -1
  62. package/dest/public/avm/opcodes/bitwise.js +5 -5
  63. package/dest/public/avm/opcodes/comparators.d.ts +4 -4
  64. package/dest/public/avm/opcodes/comparators.d.ts.map +1 -1
  65. package/dest/public/avm/opcodes/comparators.js +1 -1
  66. package/dest/public/avm/opcodes/contract.d.ts +3 -3
  67. package/dest/public/avm/opcodes/contract.d.ts.map +1 -1
  68. package/dest/public/avm/opcodes/contract.js +8 -8
  69. package/dest/public/avm/opcodes/control_flow.d.ts +3 -3
  70. package/dest/public/avm/opcodes/control_flow.d.ts.map +1 -1
  71. package/dest/public/avm/opcodes/control_flow.js +4 -4
  72. package/dest/public/avm/opcodes/conversion.d.ts +3 -3
  73. package/dest/public/avm/opcodes/conversion.d.ts.map +1 -1
  74. package/dest/public/avm/opcodes/conversion.js +4 -4
  75. package/dest/public/avm/opcodes/ec_add.d.ts +4 -4
  76. package/dest/public/avm/opcodes/ec_add.d.ts.map +1 -1
  77. package/dest/public/avm/opcodes/ec_add.js +15 -6
  78. package/dest/public/avm/opcodes/environment_getters.d.ts +3 -3
  79. package/dest/public/avm/opcodes/environment_getters.d.ts.map +1 -1
  80. package/dest/public/avm/opcodes/environment_getters.js +4 -4
  81. package/dest/public/avm/opcodes/external_calls.d.ts +9 -9
  82. package/dest/public/avm/opcodes/external_calls.d.ts.map +1 -1
  83. package/dest/public/avm/opcodes/external_calls.js +23 -23
  84. package/dest/public/avm/opcodes/hashing.d.ts +8 -8
  85. package/dest/public/avm/opcodes/hashing.d.ts.map +1 -1
  86. package/dest/public/avm/opcodes/hashing.js +12 -12
  87. package/dest/public/avm/opcodes/instruction_impl.d.ts +4 -4
  88. package/dest/public/avm/opcodes/instruction_impl.d.ts.map +1 -1
  89. package/dest/public/avm/opcodes/instruction_impl.js +4 -4
  90. package/dest/public/avm/opcodes/memory.d.ts +14 -14
  91. package/dest/public/avm/opcodes/memory.d.ts.map +1 -1
  92. package/dest/public/avm/opcodes/memory.js +25 -25
  93. package/dest/public/avm/opcodes/misc.d.ts +3 -3
  94. package/dest/public/avm/opcodes/misc.d.ts.map +1 -1
  95. package/dest/public/avm/opcodes/misc.js +4 -4
  96. package/dest/public/avm/opcodes/storage.d.ts +16 -15
  97. package/dest/public/avm/opcodes/storage.d.ts.map +1 -1
  98. package/dest/public/avm/opcodes/storage.js +34 -24
  99. package/dest/public/avm/serialization/bytecode_serialization.js +3 -3
  100. package/dest/public/avm/serialization/instruction_serialization.d.ts +2 -2
  101. package/dest/public/avm/serialization/instruction_serialization.d.ts.map +1 -1
  102. package/dest/public/avm/serialization/instruction_serialization.js +1 -1
  103. package/dest/public/debug_fn_name.d.ts +4 -4
  104. package/dest/public/debug_fn_name.d.ts.map +1 -1
  105. package/dest/public/debug_fn_name.js +7 -5
  106. package/dest/public/executor_metrics.d.ts +1 -1
  107. package/dest/public/executor_metrics.d.ts.map +1 -1
  108. package/dest/public/executor_metrics.js +7 -2
  109. package/dest/public/fixtures/amm_test.js +2 -2
  110. package/dest/public/fixtures/bulk_test.d.ts +3 -3
  111. package/dest/public/fixtures/bulk_test.d.ts.map +1 -1
  112. package/dest/public/fixtures/custom_bytecode_tests.d.ts +11 -11
  113. package/dest/public/fixtures/custom_bytecode_tests.d.ts.map +1 -1
  114. package/dest/public/fixtures/custom_bytecode_tests.js +18 -18
  115. package/dest/public/fixtures/minimal_public_tx.js +2 -2
  116. package/dest/public/fixtures/opcode_spammer.d.ts +3 -4
  117. package/dest/public/fixtures/opcode_spammer.d.ts.map +1 -1
  118. package/dest/public/fixtures/opcode_spammer.js +99 -127
  119. package/dest/public/fixtures/public_tx_simulation_tester.d.ts +1 -1
  120. package/dest/public/fixtures/public_tx_simulation_tester.d.ts.map +1 -1
  121. package/dest/public/fixtures/public_tx_simulation_tester.js +29 -2
  122. package/dest/public/fixtures/utils.js +4 -4
  123. package/dest/public/fuzzing/avm_fuzzer_simulator.d.ts +21 -7
  124. package/dest/public/fuzzing/avm_fuzzer_simulator.d.ts.map +1 -1
  125. package/dest/public/fuzzing/avm_fuzzer_simulator.js +42 -10
  126. package/dest/public/fuzzing/avm_simulator_bin.js +15 -8
  127. package/dest/public/hinting_db_sources.d.ts +2 -2
  128. package/dest/public/hinting_db_sources.d.ts.map +1 -1
  129. package/dest/public/hinting_db_sources.js +1 -1
  130. package/dest/public/public_db_sources.d.ts +4 -3
  131. package/dest/public/public_db_sources.d.ts.map +1 -1
  132. package/dest/public/public_db_sources.js +4 -4
  133. package/dest/public/public_processor/guarded_merkle_tree.d.ts +2 -2
  134. package/dest/public/public_processor/guarded_merkle_tree.d.ts.map +1 -1
  135. package/dest/public/public_processor/guarded_merkle_tree.js +1 -1
  136. package/dest/public/public_processor/public_processor.d.ts +8 -4
  137. package/dest/public/public_processor/public_processor.d.ts.map +1 -1
  138. package/dest/public/public_processor/public_processor.js +26 -11
  139. package/dest/public/public_processor/public_processor_metrics.d.ts +2 -2
  140. package/dest/public/public_processor/public_processor_metrics.d.ts.map +1 -1
  141. package/dest/public/public_processor/public_processor_metrics.js +20 -4
  142. package/dest/public/public_tx_simulator/contract_provider_for_cpp.d.ts +3 -2
  143. package/dest/public/public_tx_simulator/contract_provider_for_cpp.d.ts.map +1 -1
  144. package/dest/public/public_tx_simulator/contract_provider_for_cpp.js +2 -2
  145. package/dest/public/public_tx_simulator/cpp_public_tx_simulator.d.ts +5 -5
  146. package/dest/public/public_tx_simulator/cpp_public_tx_simulator.d.ts.map +1 -1
  147. package/dest/public/public_tx_simulator/cpp_public_tx_simulator.js +10 -9
  148. package/dest/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.d.ts +4 -4
  149. package/dest/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.d.ts.map +1 -1
  150. package/dest/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.js +5 -5
  151. package/dest/public/public_tx_simulator/cpp_vs_ts_public_tx_simulator.d.ts +4 -4
  152. package/dest/public/public_tx_simulator/cpp_vs_ts_public_tx_simulator.d.ts.map +1 -1
  153. package/dest/public/public_tx_simulator/cpp_vs_ts_public_tx_simulator.js +6 -6
  154. package/dest/public/public_tx_simulator/dumping_cpp_public_tx_simulator.d.ts +3 -2
  155. package/dest/public/public_tx_simulator/dumping_cpp_public_tx_simulator.d.ts.map +1 -1
  156. package/dest/public/public_tx_simulator/dumping_cpp_public_tx_simulator.js +2 -2
  157. package/dest/public/public_tx_simulator/factories.d.ts +3 -2
  158. package/dest/public/public_tx_simulator/factories.d.ts.map +1 -1
  159. package/dest/public/public_tx_simulator/factories.js +4 -4
  160. package/dest/public/public_tx_simulator/measured_public_tx_simulator.d.ts +1 -1
  161. package/dest/public/public_tx_simulator/public_tx_context.d.ts +4 -3
  162. package/dest/public/public_tx_simulator/public_tx_context.d.ts.map +1 -1
  163. package/dest/public/public_tx_simulator/public_tx_context.js +8 -8
  164. package/dest/public/public_tx_simulator/public_tx_simulator.d.ts +6 -4
  165. package/dest/public/public_tx_simulator/public_tx_simulator.d.ts.map +1 -1
  166. package/dest/public/public_tx_simulator/public_tx_simulator.js +14 -9
  167. package/dest/public/side_effect_trace.d.ts +5 -4
  168. package/dest/public/side_effect_trace.d.ts.map +1 -1
  169. package/dest/public/side_effect_trace.js +3 -3
  170. package/dest/public/state_manager/state_manager.d.ts +10 -4
  171. package/dest/public/state_manager/state_manager.d.ts.map +1 -1
  172. package/dest/public/state_manager/state_manager.js +14 -7
  173. package/dest/public/test_executor_metrics.d.ts +8 -2
  174. package/dest/public/test_executor_metrics.d.ts.map +1 -1
  175. package/dest/public/test_executor_metrics.js +24 -2
  176. package/package.json +17 -17
  177. package/src/private/acvm/acvm.ts +4 -3
  178. package/src/private/acvm_native.ts +11 -5
  179. package/src/private/acvm_wasm.ts +7 -3
  180. package/src/private/circuit_recording/circuit_recorder.ts +5 -3
  181. package/src/private/circuit_recording/file_circuit_recorder.ts +7 -2
  182. package/src/private/circuit_recording/memory_circuit_recorder.ts +6 -4
  183. package/src/private/factory.ts +7 -4
  184. package/src/public/avm/avm_context.ts +2 -2
  185. package/src/public/avm/avm_contract_call_result.ts +8 -6
  186. package/src/public/avm/avm_execution_environment.ts +9 -4
  187. package/src/public/avm/avm_gas.ts +2 -2
  188. package/src/public/avm/avm_machine_state.ts +6 -5
  189. package/src/public/avm/avm_memory_types.ts +4 -0
  190. package/src/public/avm/avm_simulator.ts +8 -5
  191. package/src/public/avm/calldata.ts +100 -0
  192. package/src/public/avm/fixtures/account_proof.json +553 -0
  193. package/src/public/avm/fixtures/account_proof_fetcher.ts +166 -0
  194. package/src/public/avm/fixtures/avm_simulation_tester.ts +8 -2
  195. package/src/public/avm/fixtures/initializers.ts +2 -1
  196. package/src/public/avm/opcodes/accrued_substate.ts +30 -33
  197. package/src/public/avm/opcodes/arithmetic.ts +1 -1
  198. package/src/public/avm/opcodes/bitwise.ts +3 -3
  199. package/src/public/avm/opcodes/comparators.ts +1 -1
  200. package/src/public/avm/opcodes/contract.ts +4 -7
  201. package/src/public/avm/opcodes/control_flow.ts +2 -2
  202. package/src/public/avm/opcodes/conversion.ts +3 -3
  203. package/src/public/avm/opcodes/ec_add.ts +13 -4
  204. package/src/public/avm/opcodes/environment_getters.ts +3 -3
  205. package/src/public/avm/opcodes/external_calls.ts +17 -16
  206. package/src/public/avm/opcodes/hashing.ts +6 -6
  207. package/src/public/avm/opcodes/instruction_impl.ts +2 -2
  208. package/src/public/avm/opcodes/memory.ts +19 -19
  209. package/src/public/avm/opcodes/misc.ts +2 -2
  210. package/src/public/avm/opcodes/storage.ts +30 -22
  211. package/src/public/avm/serialization/bytecode_serialization.ts +2 -2
  212. package/src/public/avm/serialization/instruction_serialization.ts +1 -1
  213. package/src/public/debug_fn_name.ts +10 -8
  214. package/src/public/executor_metrics.ts +4 -1
  215. package/src/public/fixtures/amm_test.ts +2 -2
  216. package/src/public/fixtures/custom_bytecode_tests.ts +27 -18
  217. package/src/public/fixtures/minimal_public_tx.ts +2 -2
  218. package/src/public/fixtures/opcode_spammer.ts +196 -117
  219. package/src/public/fixtures/public_tx_simulation_tester.ts +34 -3
  220. package/src/public/fixtures/utils.ts +4 -4
  221. package/src/public/fuzzing/avm_fuzzer_simulator.ts +61 -13
  222. package/src/public/fuzzing/avm_simulator_bin.ts +26 -4
  223. package/src/public/hinting_db_sources.ts +1 -1
  224. package/src/public/public_db_sources.ts +15 -5
  225. package/src/public/public_processor/guarded_merkle_tree.ts +1 -1
  226. package/src/public/public_processor/public_processor.ts +43 -20
  227. package/src/public/public_processor/public_processor_metrics.ts +10 -4
  228. package/src/public/public_tx_simulator/contract_provider_for_cpp.ts +6 -3
  229. package/src/public/public_tx_simulator/cpp_public_tx_simulator.ts +11 -7
  230. package/src/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.ts +6 -4
  231. package/src/public/public_tx_simulator/cpp_vs_ts_public_tx_simulator.ts +7 -5
  232. package/src/public/public_tx_simulator/dumping_cpp_public_tx_simulator.ts +3 -1
  233. package/src/public/public_tx_simulator/factories.ts +6 -3
  234. package/src/public/public_tx_simulator/public_tx_context.ts +13 -6
  235. package/src/public/public_tx_simulator/public_tx_simulator.ts +21 -10
  236. package/src/public/side_effect_trace.ts +5 -2
  237. package/src/public/state_manager/state_manager.ts +29 -20
  238. package/src/public/test_executor_metrics.ts +27 -3
@@ -1,4 +1,9 @@
1
- import { DEFAULT_TEARDOWN_DA_GAS_LIMIT, DEFAULT_TEARDOWN_L2_GAS_LIMIT } from '@aztec/constants';
1
+ import {
2
+ DEFAULT_TEARDOWN_DA_GAS_LIMIT,
3
+ DEFAULT_TEARDOWN_L2_GAS_LIMIT,
4
+ PUBLIC_TX_L2_GAS_OVERHEAD,
5
+ TX_DA_GAS_OVERHEAD,
6
+ } from '@aztec/constants';
2
7
  import { asyncMap } from '@aztec/foundation/async-map';
3
8
  import { BlockNumber } from '@aztec/foundation/branded-types';
4
9
  import { Fr } from '@aztec/foundation/curves/bn254';
@@ -131,8 +136,11 @@ export class PublicTxSimulationTester extends BaseAvmSimulationTester {
131
136
  teardownCallRequest,
132
137
  feePayer,
133
138
  /*gasUsedByPrivate*/ teardownCall
134
- ? new Gas(DEFAULT_TEARDOWN_DA_GAS_LIMIT, DEFAULT_TEARDOWN_L2_GAS_LIMIT)
135
- : Gas.empty(),
139
+ ? new Gas(
140
+ DEFAULT_TEARDOWN_DA_GAS_LIMIT + TX_DA_GAS_OVERHEAD,
141
+ DEFAULT_TEARDOWN_L2_GAS_LIMIT + PUBLIC_TX_L2_GAS_OVERHEAD,
142
+ )
143
+ : new Gas(TX_DA_GAS_OVERHEAD, PUBLIC_TX_L2_GAS_OVERHEAD),
136
144
  defaultGlobals(),
137
145
  );
138
146
  }
@@ -161,6 +169,8 @@ export class PublicTxSimulationTester extends BaseAvmSimulationTester {
161
169
  }
162
170
  const avmResult = await this.simulator.simulate(tx, fullTxLabel);
163
171
 
172
+ await this.#recordBytecodeSizes(fullTxLabel, [...setupCalls, ...appCalls, ...(teardownCall ? [teardownCall] : [])]);
173
+
164
174
  // Something like this is often useful for debugging:
165
175
  //if (avmResult.revertReason) {
166
176
  // // resolve / enrich revert reason
@@ -277,6 +287,27 @@ export class PublicTxSimulationTester extends BaseAvmSimulationTester {
277
287
 
278
288
  return new PublicCallRequestWithCalldata(request, calldata);
279
289
  }
290
+
291
+ // WARNING: Deduplicates by artifact name, so two different artifacts with the same name
292
+ // in a single tx would only record the first one's bytecode size.
293
+ async #recordBytecodeSizes(txLabel: string, calls: TestEnqueuedCall[]) {
294
+ const seenArtifactNames = new Set<string>();
295
+ for (const call of calls) {
296
+ const artifact = await this.contractDataSource.getContractArtifact(call.address);
297
+ if (!artifact || seenArtifactNames.has(artifact.name)) {
298
+ continue;
299
+ }
300
+ seenArtifactNames.add(artifact.name);
301
+ const instance = await this.contractDataSource.getContract(call.address);
302
+ if (!instance) {
303
+ continue;
304
+ }
305
+ const contractClass = await this.contractDataSource.getContractClass(instance.currentContractClassId);
306
+ if (contractClass) {
307
+ this.metrics.recordBytecodeSize(txLabel, artifact.name, contractClass.packedBytecode.length);
308
+ }
309
+ }
310
+ }
280
311
  }
281
312
 
282
313
  export function defaultGlobals() {
@@ -134,13 +134,13 @@ export async function createTxForPublicCalls(
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
 
@@ -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
  );
@@ -4,6 +4,7 @@ import {
4
4
  MAX_NOTE_HASHES_PER_TX,
5
5
  MAX_NULLIFIERS_PER_TX,
6
6
  MAX_PRIVATE_LOGS_PER_TX,
7
+ MAX_PROTOCOL_CONTRACTS,
7
8
  } from '@aztec/constants';
8
9
  import { padArrayEnd } from '@aztec/foundation/collection';
9
10
  import { Fr } from '@aztec/foundation/curves/bn254';
@@ -19,8 +20,17 @@ import {
19
20
  import { PrivateLog } from '@aztec/stdlib/logs';
20
21
  import { ScopedL2ToL1Message } from '@aztec/stdlib/messaging';
21
22
  import { ChonkProof } from '@aztec/stdlib/proofs';
22
- import type { MerkleTreeWriteOperations } from '@aztec/stdlib/trees';
23
- import { BlockHeader, GlobalVariables, HashedValues, Tx, TxConstantData, TxContext, TxHash } from '@aztec/stdlib/tx';
23
+ import { MerkleTreeId, type MerkleTreeWriteOperations, PublicDataTreeLeaf } from '@aztec/stdlib/trees';
24
+ import {
25
+ BlockHeader,
26
+ GlobalVariables,
27
+ HashedValues,
28
+ ProtocolContracts,
29
+ Tx,
30
+ TxConstantData,
31
+ TxContext,
32
+ TxHash,
33
+ } from '@aztec/stdlib/tx';
24
34
  import type { NativeWorldStateService } from '@aztec/world-state';
25
35
 
26
36
  import { BaseAvmSimulationTester } from '../avm/fixtures/base_avm_simulation_tester.js';
@@ -40,6 +50,9 @@ export class FuzzerSimulationRequest {
40
50
  public readonly globals: GlobalVariables,
41
51
  public readonly contractClasses: any[], // Raw, processed by addContractClassFromCpp
42
52
  public readonly contractInstances: [any, any][], // Raw pairs [address, instance]
53
+ public readonly publicDataWrites: any[], // Raw public data tree writes to apply before simulation
54
+ public readonly noteHashes: any[], // Raw note hashes to apply before simulation
55
+ public readonly protocolContracts: ProtocolContracts, // Protocol contracts mapping from C++
43
56
  ) {}
44
57
 
45
58
  static fromPlainObject(obj: any): FuzzerSimulationRequest {
@@ -53,6 +66,9 @@ export class FuzzerSimulationRequest {
53
66
  GlobalVariables.fromPlainObject(obj.globals),
54
67
  obj.contractClasses,
55
68
  obj.contractInstances,
69
+ obj.publicDataWrites ?? [],
70
+ obj.noteHashes ?? [],
71
+ ProtocolContracts.fromPlainObject(obj.protocolContracts),
56
72
  );
57
73
  }
58
74
  }
@@ -130,7 +146,7 @@ async function createTxFromHint(cppTx: AvmTxHint): Promise<Tx> {
130
146
  constants,
131
147
  cppTx.gasUsedByPrivate,
132
148
  cppTx.feePayer,
133
- 0n, // includeByTimestamp
149
+ 0n, // expirationTimestamp
134
150
  forPublic,
135
151
  undefined, // forRollup - not needed for public simulation
136
152
  );
@@ -181,16 +197,23 @@ export class AvmFuzzerSimulator extends BaseAvmSimulationTester {
181
197
  merkleTrees: MerkleTreeWriteOperations,
182
198
  contractDataSource: SimpleContractDataSource,
183
199
  globals: GlobalVariables,
200
+ protocolContracts: ProtocolContracts,
184
201
  ) {
185
202
  super(contractDataSource, merkleTrees);
186
203
  const contractsDb = new PublicContractsDB(contractDataSource);
187
- this.simulator = new PublicTxSimulator(merkleTrees, contractsDb, globals, {
188
- skipFeeEnforcement: false,
189
- collectDebugLogs: false,
190
- collectHints: false,
191
- collectStatistics: false,
192
- collectCallMetadata: false,
193
- });
204
+ this.simulator = new PublicTxSimulator(
205
+ merkleTrees,
206
+ contractsDb,
207
+ globals,
208
+ {
209
+ skipFeeEnforcement: false,
210
+ collectDebugLogs: false,
211
+ collectHints: false,
212
+ collectStatistics: false,
213
+ collectCallMetadata: false,
214
+ },
215
+ protocolContracts,
216
+ );
194
217
  }
195
218
 
196
219
  /**
@@ -199,10 +222,11 @@ export class AvmFuzzerSimulator extends BaseAvmSimulationTester {
199
222
  public static async create(
200
223
  worldStateService: NativeWorldStateService,
201
224
  globals: GlobalVariables,
225
+ protocolContracts: ProtocolContracts,
202
226
  ): Promise<AvmFuzzerSimulator> {
203
227
  const contractDataSource = new SimpleContractDataSource();
204
228
  const merkleTrees = await worldStateService.fork();
205
- return new AvmFuzzerSimulator(merkleTrees, contractDataSource, globals);
229
+ return new AvmFuzzerSimulator(merkleTrees, contractDataSource, globals, protocolContracts);
206
230
  }
207
231
 
208
232
  /**
@@ -230,11 +254,35 @@ export class AvmFuzzerSimulator extends BaseAvmSimulationTester {
230
254
 
231
255
  /**
232
256
  * Add a contract instance from C++ raw msgpack data.
233
- * This also inserts the contract address nullifier into the nullifier tree.
257
+ * This also inserts the contract address nullifier into the nullifier tree,
258
+ * unless the address is a protocol canonical address (1-11).
234
259
  */
235
260
  public async addContractInstanceFromCpp(rawAddress: any, rawInstance: any): Promise<void> {
236
261
  const address = AztecAddress.fromPlainObject(rawAddress);
237
262
  const instance = contractInstanceWithAddressFromPlainObject(address, rawInstance);
238
- await this.addContractInstance(instance);
263
+ // Protocol canonical addresses (1-11) should not have nullifiers inserted
264
+ const isProtocolCanonicalAddress = address.toBigInt() <= MAX_PROTOCOL_CONTRACTS && address.toBigInt() >= 1n;
265
+ await this.addContractInstance(instance, /* skipNullifierInsertion */ isProtocolCanonicalAddress);
266
+ }
267
+
268
+ /**
269
+ * Apply public data tree writes from C++ raw msgpack data.
270
+ * This is used to pre-populate the public data tree before simulation (e.g., for bytecode upgrades).
271
+ */
272
+ public async applyPublicDataWrites(rawWrites: any[]): Promise<void> {
273
+ for (const rawWrite of rawWrites) {
274
+ const leaf = PublicDataTreeLeaf.fromPlainObject(rawWrite);
275
+ await this.merkleTrees.sequentialInsert(MerkleTreeId.PUBLIC_DATA_TREE, [leaf.toBuffer()]);
276
+ }
277
+ }
278
+
279
+ /**
280
+ * Apply note hashes from C++ raw msgpack data.
281
+ * This is used to pre-populate the note hash tree before simulation.
282
+ */
283
+ public async applyNoteHashes(rawNoteHashes: any[]): Promise<void> {
284
+ const paddingLeaves = MAX_NOTE_HASHES_PER_TX - (rawNoteHashes.length % MAX_NOTE_HASHES_PER_TX);
285
+ const paddedNoteHashes = [...rawNoteHashes, ...Array(paddingLeaves).fill(Fr.ZERO)];
286
+ await this.merkleTrees.appendLeaves(MerkleTreeId.NOTE_HASH_TREE, paddedNoteHashes);
239
287
  }
240
288
  }
@@ -3,10 +3,11 @@ import { EthAddress } from '@aztec/foundation/eth-address';
3
3
  import {
4
4
  AvmCircuitPublicInputs,
5
5
  type AvmTxHint,
6
+ PublicTxEffect,
6
7
  deserializeFromMessagePack,
7
8
  serializeWithMessagePack,
8
9
  } from '@aztec/stdlib/avm';
9
- import { GlobalVariables, TreeSnapshots } from '@aztec/stdlib/tx';
10
+ import { GlobalVariables, ProtocolContracts, TreeSnapshots } from '@aztec/stdlib/tx';
10
11
  import { NativeWorldStateService } from '@aztec/world-state';
11
12
 
12
13
  import { createInterface } from 'readline';
@@ -55,12 +56,23 @@ async function simulateWithFuzzer(
55
56
  globals: GlobalVariables,
56
57
  rawContractClasses: any[], // Replace these when we are moving contract classes to TS
57
58
  rawContractInstances: [any, any][], // Replace these when we are moving contract instances to TS
58
- ): Promise<{ reverted: boolean; output: Fr[]; revertReason?: string; publicInputs: AvmCircuitPublicInputs }> {
59
+ rawPublicDataWrites: any[], // Public data tree writes to apply before simulation
60
+ rawNoteHashes: any[], // Note hashes to apply before simulation
61
+ protocolContracts: ProtocolContracts, // Protocol contracts mapping from C++
62
+ ): Promise<{
63
+ reverted: boolean;
64
+ output: Fr[];
65
+ revertReason?: string;
66
+ publicInputs: AvmCircuitPublicInputs;
67
+ publicTxEffect: PublicTxEffect;
68
+ }> {
59
69
  const worldStateService = await openExistingWorldState(dataDir, mapSizeKb);
60
70
 
61
- const simulator = await AvmFuzzerSimulator.create(worldStateService, globals);
71
+ const simulator = await AvmFuzzerSimulator.create(worldStateService, globals, protocolContracts);
62
72
 
63
- // Register contract classes from C++
73
+ await simulator.applyNoteHashes(rawNoteHashes);
74
+
75
+ // Register contract classes from C++ (must happen before public data writes to match C++ order)
64
76
  for (const rawClass of rawContractClasses) {
65
77
  await simulator.addContractClassFromCpp(rawClass);
66
78
  }
@@ -70,6 +82,10 @@ async function simulateWithFuzzer(
70
82
  await simulator.addContractInstanceFromCpp(rawAddress, rawInstance);
71
83
  }
72
84
 
85
+ // Apply public data writes after contract registration (e.g., for bytecode upgrades)
86
+ // This must happen last to match C++ setup_fuzzer_state ordering
87
+ await simulator.applyPublicDataWrites(rawPublicDataWrites);
88
+
73
89
  const result = await simulator.simulate(txHint);
74
90
 
75
91
  const output = result
@@ -81,6 +97,7 @@ async function simulateWithFuzzer(
81
97
  output,
82
98
  revertReason: result.findRevertReason()?.message,
83
99
  publicInputs: result.publicInputs!,
100
+ publicTxEffect: result.publicTxEffect,
84
101
  };
85
102
  }
86
103
 
@@ -99,6 +116,9 @@ async function execute(base64Line: string): Promise<void> {
99
116
  request.globals,
100
117
  request.contractClasses,
101
118
  request.contractInstances,
119
+ request.publicDataWrites,
120
+ request.noteHashes,
121
+ request.protocolContracts,
102
122
  );
103
123
 
104
124
  // Serialize the result to msgpack and encode it in base64 for output
@@ -107,6 +127,7 @@ async function execute(base64Line: string): Promise<void> {
107
127
  output: result.output,
108
128
  revertReason: result.revertReason ?? '',
109
129
  endTreeSnapshots: result.publicInputs.endTreeSnapshots,
130
+ publicTxEffect: result.publicTxEffect,
110
131
  });
111
132
  const base64Response = resultBuffer.toString('base64') + '\n';
112
133
  await writeOutput(base64Response);
@@ -117,6 +138,7 @@ async function execute(base64Line: string): Promise<void> {
117
138
  output: [] as Fr[],
118
139
  revertReason: `Unexpected Error ${error.message}`,
119
140
  endTreeSnapshots: TreeSnapshots.empty(),
141
+ publicTxEffect: PublicTxEffect.empty(),
120
142
  });
121
143
  await writeOutput(errorResult.toString('base64') + '\n');
122
144
  }
@@ -572,7 +572,7 @@ export class HintingMerkleWriteOperations implements MerkleTreeWriteOperations {
572
572
  return await this.db.close();
573
573
  }
574
574
 
575
- async [Symbol.dispose](): Promise<void> {
575
+ async [Symbol.asyncDispose](): Promise<void> {
576
576
  await this.close();
577
577
  }
578
578
 
@@ -5,7 +5,7 @@ import {
5
5
  PUBLIC_DATA_SUBTREE_HEIGHT,
6
6
  } from '@aztec/constants';
7
7
  import { Fr } from '@aztec/foundation/curves/bn254';
8
- import { createLogger } from '@aztec/foundation/log';
8
+ import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
9
9
  import { Timer } from '@aztec/foundation/timer';
10
10
  import { ContractClassPublishedEvent } from '@aztec/protocol-contracts/class-registry';
11
11
  import { ContractInstancePublishedEvent } from '@aztec/protocol-contracts/instance-registry';
@@ -46,9 +46,14 @@ import { L1ToL2MessageIndexOutOfRangeError, NoteHashIndexOutOfRangeError } from
46
46
  export class PublicContractsDB implements PublicContractsDBInterface {
47
47
  private contractStateStack: ContractsDbCheckpoint[] = [new ContractsDbCheckpoint()];
48
48
 
49
- private log = createLogger('simulator:contracts-data-source');
49
+ private log: Logger;
50
50
 
51
- constructor(private dataSource: ContractDataSource) {}
51
+ constructor(
52
+ private dataSource: ContractDataSource,
53
+ bindings?: LoggerBindings,
54
+ ) {
55
+ this.log = createLogger('simulator:contracts-data-source', bindings);
56
+ }
52
57
 
53
58
  public async addContracts(contractDeploymentData: ContractDeploymentData): Promise<void> {
54
59
  const currentState = this.getCurrentState();
@@ -208,9 +213,14 @@ export class PublicContractsDB implements PublicContractsDBInterface {
208
213
  * to decide whether to use hints or not (same with tracing, etc).
209
214
  */
210
215
  export class PublicTreesDB implements PublicStateDBInterface {
211
- private logger = createLogger('simulator:public-trees-db');
216
+ private logger: Logger;
212
217
 
213
- constructor(private readonly db: MerkleTreeWriteOperations) {}
218
+ constructor(
219
+ private readonly db: MerkleTreeWriteOperations,
220
+ bindings?: LoggerBindings,
221
+ ) {
222
+ this.logger = createLogger('simulator:public-trees-db', bindings);
223
+ }
214
224
 
215
225
  public async storageRead(contract: AztecAddress, slot: Fr): Promise<Fr> {
216
226
  const timer = new Timer();
@@ -82,7 +82,7 @@ export class GuardedMerkleTreeOperations implements MerkleTreeWriteOperations {
82
82
  return this.guardAndPush(() => this.target.close());
83
83
  }
84
84
 
85
- async [Symbol.dispose](): Promise<void> {
85
+ async [Symbol.asyncDispose](): Promise<void> {
86
86
  await this.close();
87
87
  }
88
88
  getTreeInfo(treeId: MerkleTreeId): Promise<TreeInfo> {
@@ -1,7 +1,7 @@
1
1
  import { MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX, NULLIFIER_SUBTREE_HEIGHT } from '@aztec/constants';
2
2
  import { padArrayEnd } from '@aztec/foundation/collection';
3
3
  import { Fr } from '@aztec/foundation/curves/bn254';
4
- import { createLogger } from '@aztec/foundation/log';
4
+ import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
5
5
  import { sleep } from '@aztec/foundation/sleep';
6
6
  import { DateProvider, Timer, elapsed, executeTimeout } from '@aztec/foundation/timer';
7
7
  import { ProtocolContractAddress } from '@aztec/protocol-contracts';
@@ -25,6 +25,7 @@ import type {
25
25
  PublicProcessorValidator,
26
26
  SequencerConfig,
27
27
  } from '@aztec/stdlib/interfaces/server';
28
+ import { type DebugLog, type DebugLogStore, NullDebugLogStore } from '@aztec/stdlib/logs';
28
29
  import { ProvingRequestType } from '@aztec/stdlib/proofs';
29
30
  import { MerkleTreeId } from '@aztec/stdlib/trees';
30
31
  import {
@@ -62,11 +63,15 @@ import { PublicProcessorMetrics } from './public_processor_metrics.js';
62
63
  * Creates new instances of PublicProcessor given the provided merkle tree db and contract data source.
63
64
  */
64
65
  export class PublicProcessorFactory {
66
+ private log: Logger;
65
67
  constructor(
66
68
  private contractDataSource: ContractDataSource,
67
69
  private dateProvider: DateProvider = new DateProvider(),
68
70
  protected telemetryClient: TelemetryClient = getTelemetryClient(),
69
- ) {}
71
+ bindings?: LoggerBindings,
72
+ ) {
73
+ this.log = createLogger('simulator:public-processor-factory', bindings);
74
+ }
70
75
 
71
76
  /**
72
77
  * Creates a new instance of a PublicProcessor.
@@ -79,7 +84,8 @@ export class PublicProcessorFactory {
79
84
  globalVariables: GlobalVariables,
80
85
  config: PublicSimulatorConfig,
81
86
  ): PublicProcessor {
82
- const contractsDB = new PublicContractsDB(this.contractDataSource);
87
+ const bindings = this.log.getBindings();
88
+ const contractsDB = new PublicContractsDB(this.contractDataSource, bindings);
83
89
 
84
90
  const guardedFork = new GuardedMerkleTreeOperations(merkleTree);
85
91
  const publicTxSimulator = this.createPublicTxSimulator(guardedFork, contractsDB, globalVariables, config);
@@ -91,6 +97,7 @@ export class PublicProcessorFactory {
91
97
  publicTxSimulator,
92
98
  this.dateProvider,
93
99
  this.telemetryClient,
100
+ createLogger('simulator:public-processor', bindings),
94
101
  );
95
102
  }
96
103
 
@@ -100,7 +107,14 @@ export class PublicProcessorFactory {
100
107
  globalVariables: GlobalVariables,
101
108
  config?: Partial<PublicTxSimulatorConfig>,
102
109
  ): PublicTxSimulatorInterface {
103
- return new TelemetryCppPublicTxSimulator(merkleTree, contractsDB, globalVariables, this.telemetryClient, config);
110
+ return new TelemetryCppPublicTxSimulator(
111
+ merkleTree,
112
+ contractsDB,
113
+ globalVariables,
114
+ this.telemetryClient,
115
+ config,
116
+ this.log.getBindings(),
117
+ );
104
118
  }
105
119
  }
106
120
 
@@ -117,7 +131,6 @@ class PublicProcessorTimeoutError extends Error {
117
131
  */
118
132
  export class PublicProcessor implements Traceable {
119
133
  private metrics: PublicProcessorMetrics;
120
-
121
134
  constructor(
122
135
  protected globalVariables: GlobalVariables,
123
136
  private guardedMerkleTree: GuardedMerkleTreeOperations,
@@ -125,8 +138,9 @@ export class PublicProcessor implements Traceable {
125
138
  protected publicTxSimulator: PublicTxSimulatorInterface,
126
139
  private dateProvider: DateProvider,
127
140
  telemetryClient: TelemetryClient = getTelemetryClient(),
128
- private log = createLogger('simulator:public-processor'),
141
+ private log: Logger,
129
142
  private opts: Pick<SequencerConfig, 'fakeProcessingDelayPerTxMs' | 'fakeThrowAfterProcessingTxCount'> = {},
143
+ private debugLogStore: DebugLogStore = new NullDebugLogStore(),
130
144
  ) {
131
145
  this.metrics = new PublicProcessorMetrics(telemetryClient, 'PublicProcessor');
132
146
  }
@@ -146,12 +160,13 @@ export class PublicProcessor implements Traceable {
146
160
  txs: Iterable<Tx> | AsyncIterable<Tx>,
147
161
  limits: PublicProcessorLimits = {},
148
162
  validator: PublicProcessorValidator = {},
149
- ): Promise<[ProcessedTx[], FailedTx[], Tx[], NestedProcessReturnValues[]]> {
163
+ ): Promise<[ProcessedTx[], FailedTx[], Tx[], NestedProcessReturnValues[], number, DebugLog[]]> {
150
164
  const { maxTransactions, maxBlockSize, deadline, maxBlockGas, maxBlobFields } = limits;
151
165
  const { preprocessValidator, nullifierCache } = validator;
152
166
  const result: ProcessedTx[] = [];
153
167
  const usedTxs: Tx[] = [];
154
168
  const failed: FailedTx[] = [];
169
+ const debugLogs: DebugLog[] = [];
155
170
  const timer = new Timer();
156
171
 
157
172
  let totalSizeInBytes = 0;
@@ -228,7 +243,7 @@ export class PublicProcessor implements Traceable {
228
243
  this.contractsDB.createCheckpoint();
229
244
 
230
245
  try {
231
- const [processedTx, returnValues] = await this.processTx(tx, deadline);
246
+ const [processedTx, returnValues, txDebugLogs] = await this.processTx(tx, deadline);
232
247
 
233
248
  // Inject a fake processing failure after N txs if requested
234
249
  const fakeThrowAfter = this.opts.fakeThrowAfterProcessingTxCount;
@@ -254,6 +269,7 @@ export class PublicProcessor implements Traceable {
254
269
  }
255
270
 
256
271
  // If the actual blob fields of this tx would exceed the limit, skip it
272
+ // Note: maxBlobFields already accounts for block end blob fields and previous blocks in checkpoint.
257
273
  if (maxBlobFields !== undefined && totalBlobFields + txBlobFields > maxBlobFields) {
258
274
  this.log.debug(
259
275
  `Skipping processed tx ${txHash} with ${txBlobFields} blob fields due to max blob fields limit.`,
@@ -276,6 +292,9 @@ export class PublicProcessor implements Traceable {
276
292
  result.push(processedTx);
277
293
  usedTxs.push(tx);
278
294
  returns = returns.concat(returnValues);
295
+ debugLogs.push(...txDebugLogs);
296
+
297
+ this.debugLogStore.storeLogs(processedTx.hash.toString(), txDebugLogs);
279
298
 
280
299
  totalPublicGas = totalPublicGas.add(processedTx.gasUsed.publicGas);
281
300
  totalBlockGas = totalBlockGas.add(processedTx.gasUsed.totalGas);
@@ -349,7 +368,7 @@ export class PublicProcessor implements Traceable {
349
368
  totalSizeInBytes,
350
369
  });
351
370
 
352
- return [result, failed, usedTxs, returns];
371
+ return [result, failed, usedTxs, returns, totalBlobFields, debugLogs];
353
372
  }
354
373
 
355
374
  private async checkWorldStateUnchanged(
@@ -369,8 +388,13 @@ export class PublicProcessor implements Traceable {
369
388
  }
370
389
 
371
390
  @trackSpan('PublicProcessor.processTx', tx => ({ [Attributes.TX_HASH]: tx.getTxHash().toString() }))
372
- private async processTx(tx: Tx, deadline: Date | undefined): Promise<[ProcessedTx, NestedProcessReturnValues[]]> {
373
- const [time, [processedTx, returnValues]] = await elapsed(() => this.processTxWithinDeadline(tx, deadline));
391
+ private async processTx(
392
+ tx: Tx,
393
+ deadline: Date | undefined,
394
+ ): Promise<[ProcessedTx, NestedProcessReturnValues[], DebugLog[]]> {
395
+ const [time, [processedTx, returnValues, debugLogs]] = await elapsed(() =>
396
+ this.processTxWithinDeadline(tx, deadline),
397
+ );
374
398
 
375
399
  this.log.verbose(
376
400
  !tx.hasPublicCalls()
@@ -393,7 +417,7 @@ export class PublicProcessor implements Traceable {
393
417
  },
394
418
  );
395
419
 
396
- return [processedTx, returnValues ?? []];
420
+ return [processedTx, returnValues ?? [], debugLogs];
397
421
  }
398
422
 
399
423
  private async doTreeInsertionsForPrivateOnlyTx(processedTx: ProcessedTx): Promise<void> {
@@ -427,10 +451,9 @@ export class PublicProcessor implements Traceable {
427
451
  private async processTxWithinDeadline(
428
452
  tx: Tx,
429
453
  deadline: Date | undefined,
430
- ): Promise<[ProcessedTx, NestedProcessReturnValues[] | undefined]> {
431
- const innerProcessFn: () => Promise<[ProcessedTx, NestedProcessReturnValues[] | undefined]> = tx.hasPublicCalls()
432
- ? () => this.processTxWithPublicCalls(tx)
433
- : () => this.processPrivateOnlyTx(tx);
454
+ ): Promise<[ProcessedTx, NestedProcessReturnValues[] | undefined, DebugLog[]]> {
455
+ const innerProcessFn: () => Promise<[ProcessedTx, NestedProcessReturnValues[] | undefined, DebugLog[]]> =
456
+ tx.hasPublicCalls() ? () => this.processTxWithPublicCalls(tx) : () => this.processPrivateOnlyTx(tx);
434
457
 
435
458
  // Fake a delay per tx if instructed (used for tests)
436
459
  const fakeDelayPerTxMs = this.opts.fakeProcessingDelayPerTxMs;
@@ -498,7 +521,7 @@ export class PublicProcessor implements Traceable {
498
521
  @trackSpan('PublicProcessor.processPrivateOnlyTx', (tx: Tx) => ({
499
522
  [Attributes.TX_HASH]: tx.getTxHash().toString(),
500
523
  }))
501
- private async processPrivateOnlyTx(tx: Tx): Promise<[ProcessedTx, undefined]> {
524
+ private async processPrivateOnlyTx(tx: Tx): Promise<[ProcessedTx, undefined, DebugLog[]]> {
502
525
  const gasFees = this.globalVariables.gasFees;
503
526
  const transactionFee = computeTransactionFee(gasFees, tx.data.constants.txContext.gasSettings, tx.data.gasUsed);
504
527
 
@@ -523,13 +546,13 @@ export class PublicProcessor implements Traceable {
523
546
 
524
547
  await this.contractsDB.addNewContracts(tx);
525
548
 
526
- return [processedTx, undefined];
549
+ return [processedTx, undefined, []];
527
550
  }
528
551
 
529
552
  @trackSpan('PublicProcessor.processTxWithPublicCalls', tx => ({
530
553
  [Attributes.TX_HASH]: tx.getTxHash().toString(),
531
554
  }))
532
- private async processTxWithPublicCalls(tx: Tx): Promise<[ProcessedTx, NestedProcessReturnValues[]]> {
555
+ private async processTxWithPublicCalls(tx: Tx): Promise<[ProcessedTx, NestedProcessReturnValues[], DebugLog[]]> {
533
556
  const timer = new Timer();
534
557
 
535
558
  const result = await this.publicTxSimulator.simulate(tx);
@@ -567,7 +590,7 @@ export class PublicProcessor implements Traceable {
567
590
  revertReason,
568
591
  );
569
592
 
570
- return [processedTx, appLogicReturnValues];
593
+ return [processedTx, appLogicReturnValues, result.logs ?? []];
571
594
  }
572
595
 
573
596
  /**
@@ -1,6 +1,6 @@
1
1
  import type { ContractClassPublishedEvent } from '@aztec/protocol-contracts/class-registry';
2
2
  import type { Gas } from '@aztec/stdlib/gas';
3
- import type { TxExecutionPhase } from '@aztec/stdlib/tx';
3
+ import { TxExecutionPhase } from '@aztec/stdlib/tx';
4
4
  import {
5
5
  Attributes,
6
6
  type Gauge,
@@ -9,6 +9,7 @@ import {
9
9
  type TelemetryClient,
10
10
  type Tracer,
11
11
  type UpDownCounter,
12
+ createUpDownCounterWithDefault,
12
13
  } from '@aztec/telemetry-client';
13
14
 
14
15
  export class PublicProcessorMetrics {
@@ -35,13 +36,18 @@ export class PublicProcessorMetrics {
35
36
 
36
37
  this.txDuration = meter.createHistogram(Metrics.PUBLIC_PROCESSOR_TX_DURATION);
37
38
 
38
- this.txCount = meter.createUpDownCounter(Metrics.PUBLIC_PROCESSOR_TX_COUNT);
39
+ this.txCount = createUpDownCounterWithDefault(meter, Metrics.PUBLIC_PROCESSOR_TX_COUNT, {
40
+ [Attributes.OK]: [true, false],
41
+ });
39
42
 
40
- this.txPhaseCount = meter.createUpDownCounter(Metrics.PUBLIC_PROCESSOR_TX_PHASE_COUNT);
43
+ this.txPhaseCount = createUpDownCounterWithDefault(meter, Metrics.PUBLIC_PROCESSOR_TX_PHASE_COUNT);
41
44
 
42
45
  this.phaseDuration = meter.createHistogram(Metrics.PUBLIC_PROCESSOR_PHASE_DURATION);
43
46
 
44
- this.phaseCount = meter.createUpDownCounter(Metrics.PUBLIC_PROCESSOR_PHASE_COUNT);
47
+ this.phaseCount = createUpDownCounterWithDefault(meter, Metrics.PUBLIC_PROCESSOR_PHASE_COUNT, {
48
+ [Attributes.TX_PHASE_NAME]: [TxExecutionPhase.SETUP, TxExecutionPhase.APP_LOGIC, TxExecutionPhase.TEARDOWN],
49
+ [Attributes.OK]: [true, false],
50
+ });
45
51
 
46
52
  this.bytecodeDeployed = meter.createHistogram(Metrics.PUBLIC_PROCESSOR_DEPLOY_BYTECODE_SIZE);
47
53
 
@@ -1,5 +1,5 @@
1
1
  import { Fr } from '@aztec/foundation/curves/bn254';
2
- import { type Logger, createLogger } from '@aztec/foundation/log';
2
+ import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
3
3
  import type { ContractProvider } from '@aztec/native';
4
4
  import { FunctionSelector } from '@aztec/stdlib/abi';
5
5
  import { deserializeFromMessagePack, serializeWithMessagePack } from '@aztec/stdlib/avm';
@@ -10,12 +10,15 @@ import type { GlobalVariables } from '@aztec/stdlib/tx';
10
10
  import type { PublicContractsDB } from '../public_db_sources.js';
11
11
 
12
12
  export class ContractProviderForCpp implements ContractProvider {
13
- private log: Logger = createLogger('simulator:contract_provider_for_cpp');
13
+ private log: Logger;
14
14
 
15
15
  constructor(
16
16
  private contractsDB: PublicContractsDB,
17
17
  private globalVariables: GlobalVariables,
18
- ) {}
18
+ bindings?: LoggerBindings,
19
+ ) {
20
+ this.log = createLogger('simulator:contract_provider_for_cpp', bindings);
21
+ }
19
22
 
20
23
  public getContractInstance = async (address: string): Promise<Buffer | undefined> => {
21
24
  this.log.trace(`Contract provider callback: getContractInstance(${address})`);