@aztec/simulator 0.0.1-commit.03f7ef2 → 0.0.1-commit.04852196a

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 (243) 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 +22 -19
  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 +42 -43
  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 +5 -5
  79. package/dest/public/avm/opcodes/environment_getters.d.ts.map +1 -1
  80. package/dest/public/avm/opcodes/environment_getters.js +6 -6
  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 -22
  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 +12 -33
  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/bulk_test.js +1 -17
  113. package/dest/public/fixtures/custom_bytecode_tests.d.ts +11 -11
  114. package/dest/public/fixtures/custom_bytecode_tests.d.ts.map +1 -1
  115. package/dest/public/fixtures/custom_bytecode_tests.js +18 -18
  116. package/dest/public/fixtures/minimal_public_tx.js +2 -2
  117. package/dest/public/fixtures/opcode_spammer.d.ts +3 -4
  118. package/dest/public/fixtures/opcode_spammer.d.ts.map +1 -1
  119. package/dest/public/fixtures/opcode_spammer.js +99 -127
  120. package/dest/public/fixtures/public_tx_simulation_tester.d.ts +6 -5
  121. package/dest/public/fixtures/public_tx_simulation_tester.d.ts.map +1 -1
  122. package/dest/public/fixtures/public_tx_simulation_tester.js +36 -9
  123. package/dest/public/fixtures/utils.d.ts +2 -2
  124. package/dest/public/fixtures/utils.d.ts.map +1 -1
  125. package/dest/public/fixtures/utils.js +6 -6
  126. package/dest/public/fuzzing/avm_fuzzer_simulator.d.ts +21 -7
  127. package/dest/public/fuzzing/avm_fuzzer_simulator.d.ts.map +1 -1
  128. package/dest/public/fuzzing/avm_fuzzer_simulator.js +42 -10
  129. package/dest/public/fuzzing/avm_simulator_bin.js +29 -11
  130. package/dest/public/hinting_db_sources.d.ts +2 -2
  131. package/dest/public/hinting_db_sources.d.ts.map +1 -1
  132. package/dest/public/hinting_db_sources.js +3 -1
  133. package/dest/public/public_db_sources.d.ts +4 -3
  134. package/dest/public/public_db_sources.d.ts.map +1 -1
  135. package/dest/public/public_db_sources.js +4 -4
  136. package/dest/public/public_processor/guarded_merkle_tree.d.ts +2 -2
  137. package/dest/public/public_processor/guarded_merkle_tree.d.ts.map +1 -1
  138. package/dest/public/public_processor/guarded_merkle_tree.js +3 -1
  139. package/dest/public/public_processor/public_processor.d.ts +8 -4
  140. package/dest/public/public_processor/public_processor.d.ts.map +1 -1
  141. package/dest/public/public_processor/public_processor.js +451 -55
  142. package/dest/public/public_processor/public_processor_metrics.d.ts +2 -2
  143. package/dest/public/public_processor/public_processor_metrics.d.ts.map +1 -1
  144. package/dest/public/public_processor/public_processor_metrics.js +28 -45
  145. package/dest/public/public_tx_simulator/contract_provider_for_cpp.d.ts +3 -2
  146. package/dest/public/public_tx_simulator/contract_provider_for_cpp.d.ts.map +1 -1
  147. package/dest/public/public_tx_simulator/contract_provider_for_cpp.js +2 -2
  148. package/dest/public/public_tx_simulator/cpp_public_tx_simulator.d.ts +5 -5
  149. package/dest/public/public_tx_simulator/cpp_public_tx_simulator.d.ts.map +1 -1
  150. package/dest/public/public_tx_simulator/cpp_public_tx_simulator.js +10 -10
  151. package/dest/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.d.ts +4 -4
  152. package/dest/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.d.ts.map +1 -1
  153. package/dest/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.js +7 -7
  154. package/dest/public/public_tx_simulator/cpp_vs_ts_public_tx_simulator.d.ts +4 -4
  155. package/dest/public/public_tx_simulator/cpp_vs_ts_public_tx_simulator.d.ts.map +1 -1
  156. package/dest/public/public_tx_simulator/cpp_vs_ts_public_tx_simulator.js +6 -6
  157. package/dest/public/public_tx_simulator/dumping_cpp_public_tx_simulator.d.ts +3 -2
  158. package/dest/public/public_tx_simulator/dumping_cpp_public_tx_simulator.d.ts.map +1 -1
  159. package/dest/public/public_tx_simulator/dumping_cpp_public_tx_simulator.js +2 -2
  160. package/dest/public/public_tx_simulator/factories.d.ts +3 -2
  161. package/dest/public/public_tx_simulator/factories.d.ts.map +1 -1
  162. package/dest/public/public_tx_simulator/factories.js +4 -4
  163. package/dest/public/public_tx_simulator/measured_public_tx_simulator.d.ts +1 -1
  164. package/dest/public/public_tx_simulator/public_tx_context.d.ts +4 -3
  165. package/dest/public/public_tx_simulator/public_tx_context.d.ts.map +1 -1
  166. package/dest/public/public_tx_simulator/public_tx_context.js +8 -8
  167. package/dest/public/public_tx_simulator/public_tx_simulator.d.ts +6 -4
  168. package/dest/public/public_tx_simulator/public_tx_simulator.d.ts.map +1 -1
  169. package/dest/public/public_tx_simulator/public_tx_simulator.js +14 -9
  170. package/dest/public/public_tx_simulator/telemetry_public_tx_simulator.js +395 -19
  171. package/dest/public/side_effect_trace.d.ts +5 -4
  172. package/dest/public/side_effect_trace.d.ts.map +1 -1
  173. package/dest/public/side_effect_trace.js +3 -3
  174. package/dest/public/state_manager/state_manager.d.ts +10 -4
  175. package/dest/public/state_manager/state_manager.d.ts.map +1 -1
  176. package/dest/public/state_manager/state_manager.js +14 -7
  177. package/dest/public/test_executor_metrics.d.ts +8 -2
  178. package/dest/public/test_executor_metrics.d.ts.map +1 -1
  179. package/dest/public/test_executor_metrics.js +24 -2
  180. package/package.json +17 -17
  181. package/src/private/acvm/acvm.ts +4 -3
  182. package/src/private/acvm_native.ts +11 -5
  183. package/src/private/acvm_wasm.ts +7 -3
  184. package/src/private/circuit_recording/circuit_recorder.ts +23 -20
  185. package/src/private/circuit_recording/file_circuit_recorder.ts +7 -2
  186. package/src/private/circuit_recording/memory_circuit_recorder.ts +6 -4
  187. package/src/private/factory.ts +7 -4
  188. package/src/public/avm/avm_context.ts +2 -2
  189. package/src/public/avm/avm_contract_call_result.ts +8 -6
  190. package/src/public/avm/avm_execution_environment.ts +9 -4
  191. package/src/public/avm/avm_gas.ts +2 -2
  192. package/src/public/avm/avm_machine_state.ts +6 -5
  193. package/src/public/avm/avm_memory_types.ts +4 -0
  194. package/src/public/avm/avm_simulator.ts +8 -5
  195. package/src/public/avm/calldata.ts +100 -0
  196. package/src/public/avm/fixtures/account_proof.json +553 -0
  197. package/src/public/avm/fixtures/account_proof_fetcher.ts +166 -0
  198. package/src/public/avm/fixtures/avm_simulation_tester.ts +8 -2
  199. package/src/public/avm/fixtures/initializers.ts +2 -1
  200. package/src/public/avm/opcodes/accrued_substate.ts +31 -34
  201. package/src/public/avm/opcodes/arithmetic.ts +1 -1
  202. package/src/public/avm/opcodes/bitwise.ts +3 -3
  203. package/src/public/avm/opcodes/comparators.ts +1 -1
  204. package/src/public/avm/opcodes/contract.ts +4 -7
  205. package/src/public/avm/opcodes/control_flow.ts +2 -2
  206. package/src/public/avm/opcodes/conversion.ts +3 -3
  207. package/src/public/avm/opcodes/ec_add.ts +13 -4
  208. package/src/public/avm/opcodes/environment_getters.ts +7 -7
  209. package/src/public/avm/opcodes/external_calls.ts +17 -15
  210. package/src/public/avm/opcodes/hashing.ts +6 -6
  211. package/src/public/avm/opcodes/instruction_impl.ts +2 -2
  212. package/src/public/avm/opcodes/memory.ts +19 -19
  213. package/src/public/avm/opcodes/misc.ts +2 -2
  214. package/src/public/avm/opcodes/storage.ts +30 -22
  215. package/src/public/avm/serialization/bytecode_serialization.ts +2 -2
  216. package/src/public/avm/serialization/instruction_serialization.ts +1 -1
  217. package/src/public/debug_fn_name.ts +10 -8
  218. package/src/public/executor_metrics.ts +9 -33
  219. package/src/public/fixtures/amm_test.ts +2 -2
  220. package/src/public/fixtures/bulk_test.ts +2 -2
  221. package/src/public/fixtures/custom_bytecode_tests.ts +27 -18
  222. package/src/public/fixtures/minimal_public_tx.ts +2 -2
  223. package/src/public/fixtures/opcode_spammer.ts +196 -117
  224. package/src/public/fixtures/public_tx_simulation_tester.ts +51 -5
  225. package/src/public/fixtures/utils.ts +6 -5
  226. package/src/public/fuzzing/avm_fuzzer_simulator.ts +61 -13
  227. package/src/public/fuzzing/avm_simulator_bin.ts +43 -8
  228. package/src/public/hinting_db_sources.ts +1 -1
  229. package/src/public/public_db_sources.ts +15 -5
  230. package/src/public/public_processor/guarded_merkle_tree.ts +1 -1
  231. package/src/public/public_processor/public_processor.ts +76 -47
  232. package/src/public/public_processor/public_processor_metrics.ts +16 -44
  233. package/src/public/public_tx_simulator/contract_provider_for_cpp.ts +6 -3
  234. package/src/public/public_tx_simulator/cpp_public_tx_simulator.ts +17 -7
  235. package/src/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.ts +7 -5
  236. package/src/public/public_tx_simulator/cpp_vs_ts_public_tx_simulator.ts +7 -5
  237. package/src/public/public_tx_simulator/dumping_cpp_public_tx_simulator.ts +3 -1
  238. package/src/public/public_tx_simulator/factories.ts +6 -3
  239. package/src/public/public_tx_simulator/public_tx_context.ts +13 -6
  240. package/src/public/public_tx_simulator/public_tx_simulator.ts +21 -10
  241. package/src/public/side_effect_trace.ts +5 -2
  242. package/src/public/state_manager/state_manager.ts +29 -20
  243. package/src/public/test_executor_metrics.ts +27 -3
@@ -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[]]> {
150
- const { maxTransactions, maxBlockSize, deadline, maxBlockGas, maxBlobFields } = limits;
163
+ ): Promise<[ProcessedTx[], FailedTx[], Tx[], NestedProcessReturnValues[], DebugLog[]]> {
164
+ const { maxTransactions, deadline, maxBlockGas, maxBlobFields, isBuildingProposal } = 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;
@@ -173,22 +188,23 @@ export class PublicProcessor implements Traceable {
173
188
  break;
174
189
  }
175
190
 
176
- // Skip this tx if it'd exceed max block size
177
191
  const txHash = tx.getTxHash().toString();
178
- const preTxSizeInBytes = tx.getEstimatedPrivateTxEffectsSize();
179
- if (maxBlockSize !== undefined && totalSizeInBytes + preTxSizeInBytes > maxBlockSize) {
180
- this.log.warn(`Skipping processing of tx ${txHash} sized ${preTxSizeInBytes} bytes due to block size limit`, {
181
- txHash,
182
- sizeInBytes: preTxSizeInBytes,
183
- totalSizeInBytes,
184
- maxBlockSize,
185
- });
192
+
193
+ // Skip this tx if its estimated blob fields would exceed the limit.
194
+ // Only done during proposal building: during re-execution we must process the exact txs from the proposal.
195
+ const txBlobFields = tx.getPrivateTxEffectsSizeInFields();
196
+ if (isBuildingProposal && maxBlobFields !== undefined && totalBlobFields + txBlobFields > maxBlobFields) {
197
+ this.log.warn(
198
+ `Skipping tx ${txHash} with ${txBlobFields} fields from private side effects due to blob fields limit`,
199
+ { txHash, txBlobFields, totalBlobFields, maxBlobFields },
200
+ );
186
201
  continue;
187
202
  }
188
203
 
189
- // Skip this tx if its gas limit would exceed the block gas limit
204
+ // Skip this tx if its gas limit would exceed the block gas limit (either da or l2).
205
+ // Only done during proposal building: during re-execution we must process the exact txs from the proposal.
190
206
  const txGasLimit = tx.data.constants.txContext.gasSettings.gasLimits;
191
- if (maxBlockGas !== undefined && totalBlockGas.add(txGasLimit).gtAny(maxBlockGas)) {
207
+ if (isBuildingProposal && maxBlockGas !== undefined && totalBlockGas.add(txGasLimit).gtAny(maxBlockGas)) {
192
208
  this.log.warn(`Skipping processing of tx ${txHash} due to block gas limit`, {
193
209
  txHash,
194
210
  txGasLimit,
@@ -228,7 +244,7 @@ export class PublicProcessor implements Traceable {
228
244
  this.contractsDB.createCheckpoint();
229
245
 
230
246
  try {
231
- const [processedTx, returnValues] = await this.processTx(tx, deadline);
247
+ const [processedTx, returnValues, txDebugLogs] = await this.processTx(tx, deadline);
232
248
 
233
249
  // Inject a fake processing failure after N txs if requested
234
250
  const fakeThrowAfter = this.opts.fakeThrowAfterProcessingTxCount;
@@ -237,23 +253,10 @@ export class PublicProcessor implements Traceable {
237
253
  }
238
254
 
239
255
  const txBlobFields = processedTx.txEffect.getNumBlobFields();
240
-
241
- // If the actual size of this tx would exceed block size, skip it
242
256
  const txSize = txBlobFields * Fr.SIZE_IN_BYTES;
243
- if (maxBlockSize !== undefined && totalSizeInBytes + txSize > maxBlockSize) {
244
- this.log.debug(`Skipping processed tx ${txHash} sized ${txSize} due to max block size.`, {
245
- txHash,
246
- sizeInBytes: txSize,
247
- totalSizeInBytes,
248
- maxBlockSize,
249
- });
250
- // Need to revert the checkpoint here and don't go any further
251
- await checkpoint.revert();
252
- this.contractsDB.revertCheckpoint();
253
- continue;
254
- }
255
257
 
256
- // If the actual blob fields of this tx would exceed the limit, skip it
258
+ // If the actual blob fields of this tx would exceed the limit, skip it.
259
+ // Note: maxBlobFields already accounts for block end blob fields and previous blocks in checkpoint.
257
260
  if (maxBlobFields !== undefined && totalBlobFields + txBlobFields > maxBlobFields) {
258
261
  this.log.debug(
259
262
  `Skipping processed tx ${txHash} with ${txBlobFields} blob fields due to max blob fields limit.`,
@@ -270,12 +273,34 @@ export class PublicProcessor implements Traceable {
270
273
  continue;
271
274
  }
272
275
 
276
+ // During re-execution, check if the actual gas used by this tx would push the block over the gas limit.
277
+ // Unlike the proposal-building check (which uses declared gas limits pessimistically before processing),
278
+ // this uses actual gas and stops processing when the limit is exceeded.
279
+ if (
280
+ !isBuildingProposal &&
281
+ maxBlockGas !== undefined &&
282
+ totalBlockGas.add(processedTx.gasUsed.totalGas).gtAny(maxBlockGas)
283
+ ) {
284
+ this.log.warn(`Stopping re-execution since tx ${txHash} would push block gas over limit`, {
285
+ txHash,
286
+ txGas: processedTx.gasUsed.totalGas,
287
+ totalBlockGas,
288
+ maxBlockGas,
289
+ });
290
+ await checkpoint.revert();
291
+ this.contractsDB.revertCheckpoint();
292
+ break;
293
+ }
294
+
273
295
  // FIXME(fcarreiro): it's ugly to have to notify the validator of nullifiers.
274
296
  // I'd rather pass the validators the processedTx as well and let them deal with it.
275
297
  nullifierCache?.addNullifiers(processedTx.txEffect.nullifiers.map(n => n.toBuffer()));
276
298
  result.push(processedTx);
277
299
  usedTxs.push(tx);
278
300
  returns = returns.concat(returnValues);
301
+ debugLogs.push(...txDebugLogs);
302
+
303
+ this.debugLogStore.storeLogs(processedTx.hash.toString(), txDebugLogs);
279
304
 
280
305
  totalPublicGas = totalPublicGas.add(processedTx.gasUsed.publicGas);
281
306
  totalBlockGas = totalBlockGas.add(processedTx.gasUsed.totalGas);
@@ -349,7 +374,7 @@ export class PublicProcessor implements Traceable {
349
374
  totalSizeInBytes,
350
375
  });
351
376
 
352
- return [result, failed, usedTxs, returns];
377
+ return [result, failed, usedTxs, returns, debugLogs];
353
378
  }
354
379
 
355
380
  private async checkWorldStateUnchanged(
@@ -369,8 +394,13 @@ export class PublicProcessor implements Traceable {
369
394
  }
370
395
 
371
396
  @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));
397
+ private async processTx(
398
+ tx: Tx,
399
+ deadline: Date | undefined,
400
+ ): Promise<[ProcessedTx, NestedProcessReturnValues[], DebugLog[]]> {
401
+ const [time, [processedTx, returnValues, debugLogs]] = await elapsed(() =>
402
+ this.processTxWithinDeadline(tx, deadline),
403
+ );
374
404
 
375
405
  this.log.verbose(
376
406
  !tx.hasPublicCalls()
@@ -393,7 +423,7 @@ export class PublicProcessor implements Traceable {
393
423
  },
394
424
  );
395
425
 
396
- return [processedTx, returnValues ?? []];
426
+ return [processedTx, returnValues ?? [], debugLogs];
397
427
  }
398
428
 
399
429
  private async doTreeInsertionsForPrivateOnlyTx(processedTx: ProcessedTx): Promise<void> {
@@ -427,10 +457,9 @@ export class PublicProcessor implements Traceable {
427
457
  private async processTxWithinDeadline(
428
458
  tx: Tx,
429
459
  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);
460
+ ): Promise<[ProcessedTx, NestedProcessReturnValues[] | undefined, DebugLog[]]> {
461
+ const innerProcessFn: () => Promise<[ProcessedTx, NestedProcessReturnValues[] | undefined, DebugLog[]]> =
462
+ tx.hasPublicCalls() ? () => this.processTxWithPublicCalls(tx) : () => this.processPrivateOnlyTx(tx);
434
463
 
435
464
  // Fake a delay per tx if instructed (used for tests)
436
465
  const fakeDelayPerTxMs = this.opts.fakeProcessingDelayPerTxMs;
@@ -498,7 +527,7 @@ export class PublicProcessor implements Traceable {
498
527
  @trackSpan('PublicProcessor.processPrivateOnlyTx', (tx: Tx) => ({
499
528
  [Attributes.TX_HASH]: tx.getTxHash().toString(),
500
529
  }))
501
- private async processPrivateOnlyTx(tx: Tx): Promise<[ProcessedTx, undefined]> {
530
+ private async processPrivateOnlyTx(tx: Tx): Promise<[ProcessedTx, undefined, DebugLog[]]> {
502
531
  const gasFees = this.globalVariables.gasFees;
503
532
  const transactionFee = computeTransactionFee(gasFees, tx.data.constants.txContext.gasSettings, tx.data.gasUsed);
504
533
 
@@ -523,13 +552,13 @@ export class PublicProcessor implements Traceable {
523
552
 
524
553
  await this.contractsDB.addNewContracts(tx);
525
554
 
526
- return [processedTx, undefined];
555
+ return [processedTx, undefined, []];
527
556
  }
528
557
 
529
558
  @trackSpan('PublicProcessor.processTxWithPublicCalls', tx => ({
530
559
  [Attributes.TX_HASH]: tx.getTxHash().toString(),
531
560
  }))
532
- private async processTxWithPublicCalls(tx: Tx): Promise<[ProcessedTx, NestedProcessReturnValues[]]> {
561
+ private async processTxWithPublicCalls(tx: Tx): Promise<[ProcessedTx, NestedProcessReturnValues[], DebugLog[]]> {
533
562
  const timer = new Timer();
534
563
 
535
564
  const result = await this.publicTxSimulator.simulate(tx);
@@ -567,7 +596,7 @@ export class PublicProcessor implements Traceable {
567
596
  revertReason,
568
597
  );
569
598
 
570
- return [processedTx, appLogicReturnValues];
599
+ return [processedTx, appLogicReturnValues, result.logs ?? []];
571
600
  }
572
601
 
573
602
  /**
@@ -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,7 +9,7 @@ import {
9
9
  type TelemetryClient,
10
10
  type Tracer,
11
11
  type UpDownCounter,
12
- ValueType,
12
+ createUpDownCounterWithDefault,
13
13
  } from '@aztec/telemetry-client';
14
14
 
15
15
  export class PublicProcessorMetrics {
@@ -34,60 +34,32 @@ export class PublicProcessorMetrics {
34
34
  this.tracer = client.getTracer(name);
35
35
  const meter = client.getMeter(name);
36
36
 
37
- this.txDuration = meter.createHistogram(Metrics.PUBLIC_PROCESSOR_TX_DURATION, {
38
- description: 'How long it takes to process a transaction',
39
- unit: 'ms',
40
- valueType: ValueType.INT,
41
- });
37
+ this.txDuration = meter.createHistogram(Metrics.PUBLIC_PROCESSOR_TX_DURATION);
42
38
 
43
- this.txCount = meter.createUpDownCounter(Metrics.PUBLIC_PROCESSOR_TX_COUNT, {
44
- description: 'Number of transactions processed',
39
+ this.txCount = createUpDownCounterWithDefault(meter, Metrics.PUBLIC_PROCESSOR_TX_COUNT, {
40
+ [Attributes.OK]: [true, false],
45
41
  });
46
42
 
47
- this.txPhaseCount = meter.createUpDownCounter(Metrics.PUBLIC_PROCESSOR_TX_PHASE_COUNT, {
48
- description: 'Number of phases processed',
49
- });
43
+ this.txPhaseCount = createUpDownCounterWithDefault(meter, Metrics.PUBLIC_PROCESSOR_TX_PHASE_COUNT);
50
44
 
51
- this.phaseDuration = meter.createHistogram(Metrics.PUBLIC_PROCESSOR_PHASE_DURATION, {
52
- description: 'How long it takes to process a phase',
53
- unit: 'ms',
54
- valueType: ValueType.INT,
55
- });
45
+ this.phaseDuration = meter.createHistogram(Metrics.PUBLIC_PROCESSOR_PHASE_DURATION);
56
46
 
57
- this.phaseCount = meter.createUpDownCounter(Metrics.PUBLIC_PROCESSOR_PHASE_COUNT, {
58
- description: 'Number of failed phases',
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],
59
50
  });
60
51
 
61
- this.bytecodeDeployed = meter.createHistogram(Metrics.PUBLIC_PROCESSOR_DEPLOY_BYTECODE_SIZE, {
62
- description: 'Size of deployed bytecode',
63
- unit: 'By',
64
- });
52
+ this.bytecodeDeployed = meter.createHistogram(Metrics.PUBLIC_PROCESSOR_DEPLOY_BYTECODE_SIZE);
65
53
 
66
- this.totalGas = meter.createGauge(Metrics.PUBLIC_PROCESSOR_TOTAL_GAS, {
67
- description: 'Total gas used in block',
68
- unit: 'gas',
69
- });
54
+ this.totalGas = meter.createGauge(Metrics.PUBLIC_PROCESSOR_TOTAL_GAS);
70
55
 
71
- this.totalGasHistogram = meter.createHistogram(Metrics.PUBLIC_PROCESSOR_TOTAL_GAS_HISTOGRAM, {
72
- description: 'Total gas used in block as histogram',
73
- unit: 'gas/block',
74
- });
56
+ this.totalGasHistogram = meter.createHistogram(Metrics.PUBLIC_PROCESSOR_TOTAL_GAS_HISTOGRAM);
75
57
 
76
- this.txGas = meter.createHistogram(Metrics.PUBLIC_PROCESSOR_TX_GAS, {
77
- description: 'Gas used in transaction',
78
- unit: 'gas/tx',
79
- });
58
+ this.txGas = meter.createHistogram(Metrics.PUBLIC_PROCESSOR_TX_GAS);
80
59
 
81
- this.gasRate = meter.createHistogram(Metrics.PUBLIC_PROCESSOR_GAS_RATE, {
82
- description: 'L2 gas per second for complete block',
83
- unit: 'gas/s',
84
- });
60
+ this.gasRate = meter.createHistogram(Metrics.PUBLIC_PROCESSOR_GAS_RATE);
85
61
 
86
- this.treeInsertionDuration = meter.createHistogram(Metrics.PUBLIC_PROCESSOR_TREE_INSERTION, {
87
- description: 'How long it takes for tree insertion',
88
- unit: 'us',
89
- valueType: ValueType.INT,
90
- });
62
+ this.treeInsertionDuration = meter.createHistogram(Metrics.PUBLIC_PROCESSOR_TREE_INSERTION);
91
63
  }
92
64
 
93
65
  recordPhaseDuration(phaseName: TxExecutionPhase, durationMs: number) {
@@ -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})`);
@@ -1,4 +1,4 @@
1
- import { type Logger, createLogger, logLevel } from '@aztec/foundation/log';
1
+ import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
2
2
  import { sleep } from '@aztec/foundation/sleep';
3
3
  import { type CancellationToken, avmSimulate, cancelSimulation, createCancellationToken } from '@aztec/native';
4
4
  import { ProtocolContractsList } from '@aztec/protocol-contracts';
@@ -44,9 +44,10 @@ export class CppPublicTxSimulator extends PublicTxSimulator implements PublicTxS
44
44
  contractsDB: PublicContractsDB,
45
45
  globalVariables: GlobalVariables,
46
46
  config?: Partial<PublicSimulatorConfig>,
47
+ bindings?: LoggerBindings,
47
48
  ) {
48
- super(merkleTree, contractsDB, globalVariables, config);
49
- this.log = createLogger(`simulator:cpp_public_tx_simulator`);
49
+ super(merkleTree, contractsDB, globalVariables, config, undefined, bindings);
50
+ this.log = createLogger(`simulator:cpp_public_tx_simulator`, bindings);
50
51
  }
51
52
 
52
53
  /**
@@ -84,7 +85,7 @@ export class CppPublicTxSimulator extends PublicTxSimulator implements PublicTxS
84
85
  );
85
86
 
86
87
  // Create contract provider for callbacks to TypeScript PublicContractsDB from C++
87
- const contractProvider = new ContractProviderForCpp(this.contractsDB, this.globalVariables);
88
+ const contractProvider = new ContractProviderForCpp(this.contractsDB, this.globalVariables, this.bindings);
88
89
 
89
90
  // Serialize to msgpack and call the C++ simulator
90
91
  this.log.trace(`Serializing fast simulation inputs to msgpack...`);
@@ -95,7 +96,14 @@ export class CppPublicTxSimulator extends PublicTxSimulator implements PublicTxS
95
96
 
96
97
  // Store the promise so cancel() can wait for it
97
98
  this.log.debug(`Calling C++ simulator for tx ${txHash}`);
98
- this.simulationPromise = avmSimulate(inputBuffer, contractProvider, wsCppHandle, logLevel, this.cancellationToken);
99
+ this.simulationPromise = avmSimulate(
100
+ inputBuffer,
101
+ contractProvider,
102
+ wsCppHandle,
103
+ this.log.level,
104
+ undefined,
105
+ this.cancellationToken,
106
+ );
99
107
 
100
108
  let resultBuffer: Buffer;
101
109
  try {
@@ -163,8 +171,9 @@ export class MeasuredCppPublicTxSimulator extends CppPublicTxSimulator implement
163
171
  globalVariables: GlobalVariables,
164
172
  protected readonly metrics: ExecutorMetricsInterface,
165
173
  config?: Partial<PublicSimulatorConfig>,
174
+ bindings?: LoggerBindings,
166
175
  ) {
167
- super(merkleTree, contractsDB, globalVariables, config);
176
+ super(merkleTree, contractsDB, globalVariables, config, bindings);
168
177
  }
169
178
 
170
179
  public override async simulate(tx: Tx, txLabel: string = 'unlabeledTx'): Promise<PublicTxResult> {
@@ -192,9 +201,10 @@ export class TelemetryCppPublicTxSimulator extends MeasuredCppPublicTxSimulator
192
201
  globalVariables: GlobalVariables,
193
202
  telemetryClient: TelemetryClient = getTelemetryClient(),
194
203
  config?: Partial<PublicSimulatorConfig>,
204
+ bindings?: LoggerBindings,
195
205
  ) {
196
206
  const metrics = new ExecutorMetrics(telemetryClient, 'CppPublicTxSimulator');
197
- super(merkleTree, contractsDB, globalVariables, metrics, config);
207
+ super(merkleTree, contractsDB, globalVariables, metrics, config, bindings);
198
208
  this.tracer = metrics.tracer;
199
209
  }
200
210
  }
@@ -1,4 +1,4 @@
1
- import { type Logger, createLogger, logLevel } from '@aztec/foundation/log';
1
+ import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
2
2
  import { avmSimulateWithHintedDbs } from '@aztec/native';
3
3
  import {
4
4
  AvmCircuitInputs,
@@ -34,9 +34,10 @@ export class CppPublicTxSimulatorHintedDbs extends PublicTxSimulator implements
34
34
  contractsDB: PublicContractsDB,
35
35
  globalVariables: GlobalVariables,
36
36
  config?: Partial<PublicSimulatorConfig>,
37
+ bindings?: LoggerBindings,
37
38
  ) {
38
- super(merkleTree, contractsDB, globalVariables, config);
39
- this.log = createLogger(`simulator:cpp_public_tx_simulator_hinted_dbs`);
39
+ super(merkleTree, contractsDB, globalVariables, config, undefined, bindings);
40
+ this.log = createLogger(`simulator:cpp_public_tx_simulator_hinted_dbs`, bindings);
40
41
  }
41
42
 
42
43
  /**
@@ -74,7 +75,7 @@ export class CppPublicTxSimulatorHintedDbs extends PublicTxSimulator implements
74
75
 
75
76
  let resultBuffer: Buffer;
76
77
  try {
77
- resultBuffer = await avmSimulateWithHintedDbs(inputBuffer, logLevel);
78
+ resultBuffer = await avmSimulateWithHintedDbs(inputBuffer, this.log.level);
78
79
  } catch (error: any) {
79
80
  throw new SimulationError(`C++ hinted simulation failed: ${error.message}`, []);
80
81
  }
@@ -115,8 +116,9 @@ export class MeasuredCppPublicTxSimulatorHintedDbs
115
116
  globalVariables: GlobalVariables,
116
117
  protected readonly metrics: ExecutorMetricsInterface,
117
118
  config?: Partial<PublicSimulatorConfig>,
119
+ bindings?: LoggerBindings,
118
120
  ) {
119
- super(merkleTree, contractsDB, globalVariables, config);
121
+ super(merkleTree, contractsDB, globalVariables, config, bindings);
120
122
  }
121
123
 
122
124
  public override async simulate(tx: Tx, txLabel: string = 'unlabeledTx'): Promise<PublicTxResult> {
@@ -1,4 +1,4 @@
1
- import { type Logger, createLogger, logLevel } from '@aztec/foundation/log';
1
+ import { type Logger, type LoggerBindings, createLogger, logLevel } from '@aztec/foundation/log';
2
2
  import { avmSimulate } from '@aztec/native';
3
3
  import { ProtocolContractsList } from '@aztec/protocol-contracts';
4
4
  import {
@@ -37,9 +37,10 @@ export class CppVsTsPublicTxSimulator extends PublicTxSimulator implements Publi
37
37
  contractsDB: PublicContractsDB,
38
38
  globalVariables: GlobalVariables,
39
39
  config?: Partial<PublicSimulatorConfig>,
40
+ bindings?: LoggerBindings,
40
41
  ) {
41
- super(merkleTree, contractsDB, globalVariables, config);
42
- this.log = createLogger(`simulator:cpp_vs_public_tx_simulator`);
42
+ super(merkleTree, contractsDB, globalVariables, config, undefined, bindings);
43
+ this.log = createLogger(`simulator:cpp_vs_public_tx_simulator`, bindings);
43
44
  }
44
45
 
45
46
  /**
@@ -103,7 +104,7 @@ export class CppVsTsPublicTxSimulator extends PublicTxSimulator implements Publi
103
104
  );
104
105
 
105
106
  // Create contract provider for callbacks to TypeScript PublicContractsDB from C++
106
- const contractProvider = new ContractProviderForCpp(this.contractsDB, this.globalVariables);
107
+ const contractProvider = new ContractProviderForCpp(this.contractsDB, this.globalVariables, this.bindings);
107
108
 
108
109
  // Serialize to msgpack and call the C++ simulator
109
110
  this.log.debug(`Serializing fast simulation inputs to msgpack...`);
@@ -220,8 +221,9 @@ export class MeasuredCppVsTsPublicTxSimulator
220
221
  globalVariables: GlobalVariables,
221
222
  protected readonly metrics: ExecutorMetricsInterface,
222
223
  config?: Partial<PublicSimulatorConfig>,
224
+ bindings?: LoggerBindings,
223
225
  ) {
224
- super(merkleTree, contractsDB, globalVariables, config);
226
+ super(merkleTree, contractsDB, globalVariables, config, bindings);
225
227
  }
226
228
 
227
229
  public override async simulate(tx: Tx, txLabel: string = 'unlabeledTx'): Promise<PublicTxResult> {
@@ -1,3 +1,4 @@
1
+ import type { LoggerBindings } from '@aztec/foundation/log';
1
2
  import {
2
3
  AvmCircuitInputs,
3
4
  AvmCircuitPublicInputs,
@@ -29,8 +30,9 @@ export class DumpingCppPublicTxSimulator extends CppPublicTxSimulator {
29
30
  globalVariables: GlobalVariables,
30
31
  config: Partial<PublicSimulatorConfig>,
31
32
  outputDir: string,
33
+ bindings?: LoggerBindings,
32
34
  ) {
33
- super(merkleTree, contractsDB, globalVariables, config);
35
+ super(merkleTree, contractsDB, globalVariables, config, bindings);
34
36
  assert(config.collectHints === true, 'collectHints must be enabled to dump AVM circuit inputs');
35
37
  assert(config.collectPublicInputs === true, 'collectPublicInputs must be enabled to dump AVM circuit inputs');
36
38
  this.outputDir = outputDir;
@@ -1,3 +1,4 @@
1
+ import type { LoggerBindings } from '@aztec/foundation/log';
1
2
  import { PublicSimulatorConfig } from '@aztec/stdlib/avm';
2
3
  import type { MerkleTreeWriteOperations } from '@aztec/stdlib/trees';
3
4
  import type { GlobalVariables } from '@aztec/stdlib/tx';
@@ -17,10 +18,12 @@ export function createPublicTxSimulatorForBlockBuilding(
17
18
  contractsDB: PublicContractsDB,
18
19
  globalVariables: GlobalVariables,
19
20
  telemetryClient: TelemetryClient,
21
+ bindings?: LoggerBindings,
22
+ collectDebugLogs = false,
20
23
  ) {
21
24
  const config = PublicSimulatorConfig.from({
22
25
  skipFeeEnforcement: false,
23
- collectDebugLogs: false,
26
+ collectDebugLogs,
24
27
  collectHints: false,
25
28
  collectPublicInputs: false,
26
29
  collectStatistics: false,
@@ -35,7 +38,7 @@ export function createPublicTxSimulatorForBlockBuilding(
35
38
  collectHints: true,
36
39
  collectPublicInputs: true,
37
40
  };
38
- return new DumpingCppPublicTxSimulator(merkleTree, contractsDB, globalVariables, dumpingConfig, dumpDir);
41
+ return new DumpingCppPublicTxSimulator(merkleTree, contractsDB, globalVariables, dumpingConfig, dumpDir, bindings);
39
42
  }
40
- return new TelemetryCppPublicTxSimulator(merkleTree, contractsDB, globalVariables, telemetryClient, config);
43
+ return new TelemetryCppPublicTxSimulator(merkleTree, contractsDB, globalVariables, telemetryClient, config, bindings);
41
44
  }
@@ -7,7 +7,7 @@ import {
7
7
  } from '@aztec/constants';
8
8
  import { padArrayEnd } from '@aztec/foundation/collection';
9
9
  import { Fr } from '@aztec/foundation/curves/bn254';
10
- import { type Logger, createLogger } from '@aztec/foundation/log';
10
+ import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
11
11
  import {
12
12
  AvmAccumulatedData,
13
13
  AvmAccumulatedDataArrayLengths,
@@ -87,8 +87,9 @@ export class PublicTxContext {
87
87
  public readonly revertibleAccumulatedDataFromPrivate: PrivateToPublicAccumulatedData,
88
88
  public readonly feePayer: AztecAddress,
89
89
  private readonly trace: SideEffectTrace,
90
+ bindings?: LoggerBindings,
90
91
  ) {
91
- this.log = createLogger(`simulator:public_tx_context`);
92
+ this.log = createLogger(`simulator:public_tx_context`, bindings);
92
93
  }
93
94
 
94
95
  public static async create(
@@ -98,13 +99,14 @@ export class PublicTxContext {
98
99
  globalVariables: GlobalVariables,
99
100
  protocolContracts: ProtocolContracts,
100
101
  proverId: Fr,
102
+ bindings?: LoggerBindings,
101
103
  ) {
102
104
  const contractDeploymentData = AllContractDeploymentData.fromTx(tx);
103
105
  const nonRevertibleContractDeploymentData = contractDeploymentData.getNonRevertibleContractDeploymentData();
104
106
  const revertibleContractDeploymentData = contractDeploymentData.getRevertibleContractDeploymentData();
105
107
  const nonRevertibleAccumulatedDataFromPrivate = tx.data.forPublic!.nonRevertibleAccumulatedData;
106
108
 
107
- const trace = new SideEffectTrace();
109
+ const trace = new SideEffectTrace(0, bindings);
108
110
 
109
111
  const firstNullifier = nonRevertibleAccumulatedDataFromPrivate.nullifiers[0];
110
112
 
@@ -115,6 +117,7 @@ export class PublicTxContext {
115
117
  trace,
116
118
  firstNullifier,
117
119
  globalVariables.timestamp,
120
+ bindings,
118
121
  );
119
122
 
120
123
  const gasSettings = tx.data.constants.txContext.gasSettings;
@@ -124,7 +127,7 @@ export class PublicTxContext {
124
127
 
125
128
  return new PublicTxContext(
126
129
  tx.getTxHash(),
127
- new PhaseStateManager(txStateManager),
130
+ new PhaseStateManager(txStateManager, bindings),
128
131
  await txStateManager.getTreeSnapshots(),
129
132
  globalVariables,
130
133
  protocolContracts,
@@ -142,6 +145,7 @@ export class PublicTxContext {
142
145
  tx.data.forPublic!.revertibleAccumulatedData,
143
146
  tx.data.feePayer,
144
147
  trace,
148
+ bindings,
145
149
  );
146
150
  }
147
151
 
@@ -441,8 +445,11 @@ class PhaseStateManager {
441
445
 
442
446
  private currentlyActiveStateManager: PublicPersistableStateManager | undefined;
443
447
 
444
- constructor(private readonly txStateManager: PublicPersistableStateManager) {
445
- this.log = createLogger(`simulator:public_phase_state_manager`);
448
+ constructor(
449
+ private readonly txStateManager: PublicPersistableStateManager,
450
+ bindings?: LoggerBindings,
451
+ ) {
452
+ this.log = createLogger(`simulator:public_phase_state_manager`, bindings);
446
453
  }
447
454
 
448
455
  async fork() {