@aztec/simulator 0.0.1-commit.2ed92850 → 0.0.1-commit.343b43af6

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 (130) hide show
  1. package/README.md +4 -4
  2. package/dest/private/acvm/acvm.d.ts +4 -2
  3. package/dest/private/acvm/acvm.d.ts.map +1 -1
  4. package/dest/private/acvm/acvm.js +4 -3
  5. package/dest/private/acvm_native.d.ts +5 -3
  6. package/dest/private/acvm_native.d.ts.map +1 -1
  7. package/dest/private/acvm_native.js +8 -6
  8. package/dest/private/acvm_wasm.d.ts +4 -3
  9. package/dest/private/acvm_wasm.d.ts.map +1 -1
  10. package/dest/private/acvm_wasm.js +4 -4
  11. package/dest/private/circuit_recording/circuit_recorder.d.ts +4 -3
  12. package/dest/private/circuit_recording/circuit_recorder.d.ts.map +1 -1
  13. package/dest/private/circuit_recording/circuit_recorder.js +7 -5
  14. package/dest/private/circuit_recording/file_circuit_recorder.d.ts +3 -2
  15. package/dest/private/circuit_recording/file_circuit_recorder.d.ts.map +1 -1
  16. package/dest/private/circuit_recording/file_circuit_recorder.js +2 -2
  17. package/dest/private/circuit_recording/memory_circuit_recorder.d.ts +7 -2
  18. package/dest/private/circuit_recording/memory_circuit_recorder.d.ts.map +1 -1
  19. package/dest/private/circuit_recording/memory_circuit_recorder.js +4 -4
  20. package/dest/private/factory.d.ts +3 -3
  21. package/dest/private/factory.d.ts.map +1 -1
  22. package/dest/private/factory.js +7 -4
  23. package/dest/public/avm/avm_gas.js +3 -3
  24. package/dest/public/avm/fixtures/account_proof_fetcher.d.ts +2 -0
  25. package/dest/public/avm/fixtures/account_proof_fetcher.d.ts.map +1 -0
  26. package/dest/public/avm/fixtures/account_proof_fetcher.js +152 -0
  27. package/dest/public/avm/opcodes/accrued_substate.d.ts +4 -5
  28. package/dest/public/avm/opcodes/accrued_substate.d.ts.map +1 -1
  29. package/dest/public/avm/opcodes/accrued_substate.js +11 -16
  30. package/dest/public/avm/serialization/bytecode_serialization.js +3 -3
  31. package/dest/public/avm/serialization/instruction_serialization.d.ts +2 -2
  32. package/dest/public/avm/serialization/instruction_serialization.d.ts.map +1 -1
  33. package/dest/public/avm/serialization/instruction_serialization.js +1 -1
  34. package/dest/public/executor_metrics.d.ts +1 -1
  35. package/dest/public/executor_metrics.d.ts.map +1 -1
  36. package/dest/public/executor_metrics.js +7 -2
  37. package/dest/public/fixtures/amm_test.js +2 -2
  38. package/dest/public/fixtures/opcode_spammer.d.ts +3 -4
  39. package/dest/public/fixtures/opcode_spammer.d.ts.map +1 -1
  40. package/dest/public/fixtures/opcode_spammer.js +16 -56
  41. package/dest/public/fixtures/public_tx_simulation_tester.d.ts +6 -5
  42. package/dest/public/fixtures/public_tx_simulation_tester.d.ts.map +1 -1
  43. package/dest/public/fixtures/public_tx_simulation_tester.js +36 -9
  44. package/dest/public/fixtures/utils.d.ts +2 -2
  45. package/dest/public/fixtures/utils.d.ts.map +1 -1
  46. package/dest/public/fixtures/utils.js +6 -6
  47. package/dest/public/hinting_db_sources.d.ts +2 -2
  48. package/dest/public/hinting_db_sources.d.ts.map +1 -1
  49. package/dest/public/hinting_db_sources.js +1 -1
  50. package/dest/public/public_db_sources.d.ts +4 -3
  51. package/dest/public/public_db_sources.d.ts.map +1 -1
  52. package/dest/public/public_db_sources.js +4 -4
  53. package/dest/public/public_processor/guarded_merkle_tree.d.ts +2 -2
  54. package/dest/public/public_processor/guarded_merkle_tree.d.ts.map +1 -1
  55. package/dest/public/public_processor/guarded_merkle_tree.js +1 -1
  56. package/dest/public/public_processor/public_processor.d.ts +8 -4
  57. package/dest/public/public_processor/public_processor.d.ts.map +1 -1
  58. package/dest/public/public_processor/public_processor.js +50 -35
  59. package/dest/public/public_processor/public_processor_metrics.d.ts +2 -2
  60. package/dest/public/public_processor/public_processor_metrics.d.ts.map +1 -1
  61. package/dest/public/public_processor/public_processor_metrics.js +20 -4
  62. package/dest/public/public_tx_simulator/contract_provider_for_cpp.d.ts +3 -2
  63. package/dest/public/public_tx_simulator/contract_provider_for_cpp.d.ts.map +1 -1
  64. package/dest/public/public_tx_simulator/contract_provider_for_cpp.js +2 -2
  65. package/dest/public/public_tx_simulator/cpp_public_tx_simulator.d.ts +5 -5
  66. package/dest/public/public_tx_simulator/cpp_public_tx_simulator.d.ts.map +1 -1
  67. package/dest/public/public_tx_simulator/cpp_public_tx_simulator.js +10 -11
  68. package/dest/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.d.ts +4 -4
  69. package/dest/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.d.ts.map +1 -1
  70. package/dest/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.js +7 -7
  71. package/dest/public/public_tx_simulator/cpp_vs_ts_public_tx_simulator.d.ts +4 -4
  72. package/dest/public/public_tx_simulator/cpp_vs_ts_public_tx_simulator.d.ts.map +1 -1
  73. package/dest/public/public_tx_simulator/cpp_vs_ts_public_tx_simulator.js +6 -6
  74. package/dest/public/public_tx_simulator/dumping_cpp_public_tx_simulator.d.ts +3 -2
  75. package/dest/public/public_tx_simulator/dumping_cpp_public_tx_simulator.d.ts.map +1 -1
  76. package/dest/public/public_tx_simulator/dumping_cpp_public_tx_simulator.js +2 -2
  77. package/dest/public/public_tx_simulator/factories.d.ts +3 -2
  78. package/dest/public/public_tx_simulator/factories.d.ts.map +1 -1
  79. package/dest/public/public_tx_simulator/factories.js +4 -4
  80. package/dest/public/public_tx_simulator/public_tx_context.d.ts +4 -3
  81. package/dest/public/public_tx_simulator/public_tx_context.d.ts.map +1 -1
  82. package/dest/public/public_tx_simulator/public_tx_context.js +8 -8
  83. package/dest/public/public_tx_simulator/public_tx_simulator.d.ts +4 -3
  84. package/dest/public/public_tx_simulator/public_tx_simulator.d.ts.map +1 -1
  85. package/dest/public/public_tx_simulator/public_tx_simulator.js +7 -5
  86. package/dest/public/side_effect_trace.d.ts +4 -4
  87. package/dest/public/side_effect_trace.d.ts.map +1 -1
  88. package/dest/public/side_effect_trace.js +3 -3
  89. package/dest/public/state_manager/state_manager.d.ts +10 -4
  90. package/dest/public/state_manager/state_manager.d.ts.map +1 -1
  91. package/dest/public/state_manager/state_manager.js +12 -5
  92. package/dest/public/test_executor_metrics.d.ts +8 -2
  93. package/dest/public/test_executor_metrics.d.ts.map +1 -1
  94. package/dest/public/test_executor_metrics.js +24 -2
  95. package/package.json +16 -16
  96. package/src/private/acvm/acvm.ts +4 -3
  97. package/src/private/acvm_native.ts +11 -5
  98. package/src/private/acvm_wasm.ts +7 -3
  99. package/src/private/circuit_recording/circuit_recorder.ts +7 -5
  100. package/src/private/circuit_recording/file_circuit_recorder.ts +7 -2
  101. package/src/private/circuit_recording/memory_circuit_recorder.ts +6 -4
  102. package/src/private/factory.ts +7 -4
  103. package/src/public/avm/avm_gas.ts +2 -2
  104. package/src/public/avm/fixtures/account_proof.json +553 -0
  105. package/src/public/avm/fixtures/account_proof_fetcher.ts +166 -0
  106. package/src/public/avm/opcodes/accrued_substate.ts +10 -19
  107. package/src/public/avm/serialization/bytecode_serialization.ts +2 -2
  108. package/src/public/avm/serialization/instruction_serialization.ts +1 -1
  109. package/src/public/executor_metrics.ts +4 -1
  110. package/src/public/fixtures/amm_test.ts +2 -2
  111. package/src/public/fixtures/opcode_spammer.ts +18 -55
  112. package/src/public/fixtures/public_tx_simulation_tester.ts +51 -5
  113. package/src/public/fixtures/utils.ts +6 -5
  114. package/src/public/fuzzing/avm_fuzzer_simulator.ts +1 -1
  115. package/src/public/hinting_db_sources.ts +1 -1
  116. package/src/public/public_db_sources.ts +15 -5
  117. package/src/public/public_processor/guarded_merkle_tree.ts +1 -1
  118. package/src/public/public_processor/public_processor.ts +75 -47
  119. package/src/public/public_processor/public_processor_metrics.ts +10 -4
  120. package/src/public/public_tx_simulator/contract_provider_for_cpp.ts +6 -3
  121. package/src/public/public_tx_simulator/cpp_public_tx_simulator.ts +10 -8
  122. package/src/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.ts +7 -5
  123. package/src/public/public_tx_simulator/cpp_vs_ts_public_tx_simulator.ts +7 -5
  124. package/src/public/public_tx_simulator/dumping_cpp_public_tx_simulator.ts +3 -1
  125. package/src/public/public_tx_simulator/factories.ts +6 -3
  126. package/src/public/public_tx_simulator/public_tx_context.ts +13 -6
  127. package/src/public/public_tx_simulator/public_tx_simulator.ts +9 -5
  128. package/src/public/side_effect_trace.ts +5 -2
  129. package/src/public/state_manager/state_manager.ts +27 -4
  130. package/src/public/test_executor_metrics.ts +27 -3
@@ -24,6 +24,7 @@ function createEmptyTxMetrics() {
24
24
  totalDurationMs: 0,
25
25
  manaUsed: 0,
26
26
  totalInstructionsExecuted: 0,
27
+ bytecodeSizes: [],
27
28
  nonRevertiblePrivateInsertionsUs: undefined,
28
29
  revertiblePrivateInsertionsUs: undefined,
29
30
  enqueuedCalls: [],
@@ -48,8 +49,8 @@ export class TestExecutorMetrics {
48
49
  txMetrics = new Map();
49
50
  currentTxLabel;
50
51
  txTimer;
51
- constructor(){
52
- this.logger = createLogger(`simulator:test_executor_metrics`);
52
+ constructor(bindings){
53
+ this.logger = createLogger(`simulator:test_executor_metrics`, bindings);
53
54
  }
54
55
  startRecordingTxSimulation(txLabel) {
55
56
  assert(!this.currentTxLabel, 'Cannot start recording tx simulation when another is live');
@@ -99,6 +100,14 @@ export class TestExecutorMetrics {
99
100
  txMetrics.nonRevertiblePrivateInsertionsUs = durationUs;
100
101
  }
101
102
  }
103
+ recordBytecodeSize(txLabel, contractName, sizeBytes) {
104
+ const txMetrics = this.txMetrics.get(txLabel);
105
+ assert(txMetrics, `Cannot record bytecode size for unknown tx label: ${txLabel}`);
106
+ txMetrics.bytecodeSizes.push({
107
+ contractName,
108
+ sizeBytes
109
+ });
110
+ }
102
111
  recordProverMetrics(txLabel, metrics) {
103
112
  if (!this.txMetrics.has(txLabel)) {
104
113
  this.txMetrics.set(txLabel, createEmptyTxMetrics());
@@ -132,6 +141,12 @@ export class TestExecutorMetrics {
132
141
  if (filter === 3 || filter === 1 || filter === 0) {
133
142
  pretty += `${INDENT0}Total instructions executed: ${fmtNum(txMetrics.totalInstructionsExecuted)}\n`;
134
143
  }
144
+ if ((filter === 1 || filter === 0) && txMetrics.bytecodeSizes.length > 0) {
145
+ pretty += `${INDENT0}Bytecode sizes:\n`;
146
+ for (const { contractName, sizeBytes } of txMetrics.bytecodeSizes){
147
+ pretty += `${INDENT1}${contractName}: ${fmtNum(sizeBytes, 'bytes')}\n`;
148
+ }
149
+ }
135
150
  if (filter === 2 || filter === 0) {
136
151
  pretty += `${INDENT0}Private insertions:\n`;
137
152
  pretty += `${INDENT1}Non-revertible: ${fmtNum(txMetrics.nonRevertiblePrivateInsertionsUs / 1_000, 'ms')}\n`;
@@ -298,6 +313,13 @@ export class TestExecutorMetrics {
298
313
  });
299
314
  }
300
315
  }
316
+ for (const { contractName, sizeBytes } of txMetrics.bytecodeSizes){
317
+ data.push({
318
+ name: `${txLabel}/bytecodeSizeBytes/${contractName}`,
319
+ value: sizeBytes,
320
+ unit: 'bytes'
321
+ });
322
+ }
301
323
  }
302
324
  return JSON.stringify(data, null, indent);
303
325
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/simulator",
3
- "version": "0.0.1-commit.2ed92850",
3
+ "version": "0.0.1-commit.343b43af6",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  "./server": "./dest/server.js",
@@ -64,26 +64,26 @@
64
64
  ]
65
65
  },
66
66
  "dependencies": {
67
- "@aztec/constants": "0.0.1-commit.2ed92850",
68
- "@aztec/foundation": "0.0.1-commit.2ed92850",
69
- "@aztec/native": "0.0.1-commit.2ed92850",
70
- "@aztec/noir-acvm_js": "0.0.1-commit.2ed92850",
71
- "@aztec/noir-noirc_abi": "0.0.1-commit.2ed92850",
72
- "@aztec/noir-protocol-circuits-types": "0.0.1-commit.2ed92850",
73
- "@aztec/noir-types": "0.0.1-commit.2ed92850",
74
- "@aztec/protocol-contracts": "0.0.1-commit.2ed92850",
75
- "@aztec/stdlib": "0.0.1-commit.2ed92850",
76
- "@aztec/telemetry-client": "0.0.1-commit.2ed92850",
77
- "@aztec/world-state": "0.0.1-commit.2ed92850",
67
+ "@aztec/constants": "0.0.1-commit.343b43af6",
68
+ "@aztec/foundation": "0.0.1-commit.343b43af6",
69
+ "@aztec/native": "0.0.1-commit.343b43af6",
70
+ "@aztec/noir-acvm_js": "0.0.1-commit.343b43af6",
71
+ "@aztec/noir-noirc_abi": "0.0.1-commit.343b43af6",
72
+ "@aztec/noir-protocol-circuits-types": "0.0.1-commit.343b43af6",
73
+ "@aztec/noir-types": "0.0.1-commit.343b43af6",
74
+ "@aztec/protocol-contracts": "0.0.1-commit.343b43af6",
75
+ "@aztec/stdlib": "0.0.1-commit.343b43af6",
76
+ "@aztec/telemetry-client": "0.0.1-commit.343b43af6",
77
+ "@aztec/world-state": "0.0.1-commit.343b43af6",
78
78
  "lodash.clonedeep": "^4.5.0",
79
79
  "lodash.merge": "^4.6.2",
80
80
  "tslib": "^2.4.0"
81
81
  },
82
82
  "devDependencies": {
83
- "@aztec/kv-store": "0.0.1-commit.2ed92850",
84
- "@aztec/merkle-tree": "0.0.1-commit.2ed92850",
85
- "@aztec/noir-contracts.js": "0.0.1-commit.2ed92850",
86
- "@aztec/noir-test-contracts.js": "0.0.1-commit.2ed92850",
83
+ "@aztec/kv-store": "0.0.1-commit.343b43af6",
84
+ "@aztec/merkle-tree": "0.0.1-commit.343b43af6",
85
+ "@aztec/noir-contracts.js": "0.0.1-commit.343b43af6",
86
+ "@aztec/noir-test-contracts.js": "0.0.1-commit.343b43af6",
87
87
  "@jest/globals": "^30.0.0",
88
88
  "@types/jest": "^30.0.0",
89
89
  "@types/lodash.clonedeep": "^4.5.7",
@@ -1,4 +1,4 @@
1
- import { createLogger } from '@aztec/foundation/log';
1
+ import { type Logger, type LoggerBindings, resolveLogger } from '@aztec/foundation/log';
2
2
  import {
3
3
  type ExecutionError,
4
4
  type ForeignCallInput,
@@ -37,6 +37,7 @@ export interface ACIRExecutionResult {
37
37
  * @param acir - The ACIR circuit bytecode to execute.
38
38
  * @param initialWitness - The initial witness map defining all of the inputs to `circuit`.
39
39
  * @param callback - A callback to process any foreign calls from the circuit.
40
+ * @param logger - Optional logger for ACVM execution logs.
40
41
  * @returns The solved witness calculated by executing the circuit on the provided inputs, as well as the return
41
42
  * witness indices as specified by the circuit.
42
43
  */
@@ -44,9 +45,9 @@ export async function acvm(
44
45
  acir: Buffer,
45
46
  initialWitness: ACVMWitness,
46
47
  callback: ACIRCallback,
48
+ loggerOrBindings?: Logger | LoggerBindings,
47
49
  ): Promise<ACIRExecutionResult> {
48
- const logger = createLogger('simulator:acvm');
49
-
50
+ const logger = resolveLogger('simulator:acvm', loggerOrBindings);
50
51
  const solvedAndReturnWitness = await executeCircuitWithReturnWitness(
51
52
  acir,
52
53
  initialWitness,
@@ -1,5 +1,5 @@
1
1
  import { runInDirectory } from '@aztec/foundation/fs';
2
- import { createLogger } from '@aztec/foundation/log';
2
+ import { type Logger, type LoggerBindings, resolveLogger } from '@aztec/foundation/log';
3
3
  import { Timer } from '@aztec/foundation/timer';
4
4
  import type { ForeignCallHandler, WitnessMap } from '@aztec/noir-acvm_js';
5
5
  import type { FunctionArtifactWithContractName } from '@aztec/stdlib/abi';
@@ -12,8 +12,6 @@ import type { ACIRCallback, ACIRExecutionResult } from './acvm/acvm.js';
12
12
  import type { ACVMWitness } from './acvm/acvm_types.js';
13
13
  import type { CircuitSimulator } from './circuit_simulator.js';
14
14
 
15
- const logger = createLogger('simulator:acvm-native');
16
-
17
15
  export enum ACVM_RESULT {
18
16
  SUCCESS,
19
17
  FAILURE,
@@ -64,7 +62,9 @@ export async function executeNativeCircuit(
64
62
  workingDirectory: string,
65
63
  pathToAcvm: string,
66
64
  outputFilename?: string,
65
+ loggerOrBindings?: Logger | LoggerBindings,
67
66
  ): Promise<ACVMResult> {
67
+ const logger = resolveLogger('simulator:acvm-native', loggerOrBindings);
68
68
  const bytecodeFilename = 'bytecode';
69
69
  const witnessFilename = 'input_witness.toml';
70
70
 
@@ -145,11 +145,16 @@ export async function executeNativeCircuit(
145
145
  }
146
146
 
147
147
  export class NativeACVMSimulator implements CircuitSimulator {
148
+ private logger: Logger;
149
+
148
150
  constructor(
149
151
  private workingDirectory: string,
150
152
  private pathToAcvm: string,
151
153
  private witnessFilename?: string,
152
- ) {}
154
+ loggerOrBindings?: Logger | LoggerBindings,
155
+ ) {
156
+ this.logger = resolveLogger('simulator:acvm-native', loggerOrBindings);
157
+ }
153
158
 
154
159
  async executeProtocolCircuit(
155
160
  input: ACVMWitness,
@@ -172,6 +177,7 @@ export class NativeACVMSimulator implements CircuitSimulator {
172
177
  directory,
173
178
  this.pathToAcvm,
174
179
  this.witnessFilename,
180
+ this.logger,
175
181
  );
176
182
 
177
183
  if (result.status == ACVM_RESULT.FAILURE) {
@@ -181,7 +187,7 @@ export class NativeACVMSimulator implements CircuitSimulator {
181
187
  return result;
182
188
  };
183
189
 
184
- return await runInDirectory(this.workingDirectory, operation, false, logger);
190
+ return await runInDirectory(this.workingDirectory, operation, false, this.logger);
185
191
  }
186
192
 
187
193
  executeUserCircuit(
@@ -1,4 +1,4 @@
1
- import { createLogger } from '@aztec/foundation/log';
1
+ import { type Logger, type LoggerBindings, resolveLogger } from '@aztec/foundation/log';
2
2
  import { Timer } from '@aztec/foundation/timer';
3
3
  import initACVM, { type ExecutionError, type ForeignCallHandler, executeCircuit } from '@aztec/noir-acvm_js';
4
4
  import initAbi from '@aztec/noir-noirc_abi';
@@ -11,7 +11,11 @@ import type { ACVMSuccess } from './acvm_native.js';
11
11
  import { type CircuitSimulator, enrichNoirError } from './circuit_simulator.js';
12
12
 
13
13
  export class WASMSimulator implements CircuitSimulator {
14
- constructor(protected log = createLogger('wasm-simulator')) {}
14
+ protected log: Logger;
15
+
16
+ constructor(loggerOrBindings?: Logger | LoggerBindings) {
17
+ this.log = resolveLogger('wasm-simulator', loggerOrBindings);
18
+ }
15
19
 
16
20
  async init(): Promise<void> {
17
21
  // If these are available, then we are in the
@@ -67,6 +71,6 @@ export class WASMSimulator implements CircuitSimulator {
67
71
  callback: ACIRCallback,
68
72
  ): Promise<ACIRExecutionResult> {
69
73
  await this.init();
70
- return acvm(artifact.bytecode, input, callback);
74
+ return acvm(artifact.bytecode, input, callback, this.log.createChild('acvm'));
71
75
  }
72
76
  }
@@ -1,5 +1,5 @@
1
1
  import { sha512 } from '@aztec/foundation/crypto/sha512';
2
- import { createLogger } from '@aztec/foundation/log';
2
+ import { type Logger, type LoggerBindings, resolveLogger } from '@aztec/foundation/log';
3
3
  import { Timer } from '@aztec/foundation/timer';
4
4
  import type { ForeignCallHandler, ForeignCallInput, ForeignCallOutput } from '@aztec/noir-acvm_js';
5
5
 
@@ -89,14 +89,16 @@ export class CircuitRecording {
89
89
  * ```
90
90
  */
91
91
  export class CircuitRecorder {
92
- protected readonly logger = createLogger('simulator:acvm:recording');
92
+ protected readonly logger: Logger;
93
93
 
94
94
  protected recording?: CircuitRecording;
95
95
 
96
96
  private stackDepth: number = 0;
97
97
  private newCircuit: boolean = true;
98
98
 
99
- protected constructor() {}
99
+ protected constructor(loggerOrBindings?: Logger | LoggerBindings) {
100
+ this.logger = resolveLogger('simulator:acvm:recording', loggerOrBindings);
101
+ }
100
102
 
101
103
  /**
102
104
  * Initializes a new circuit recording session.
@@ -159,11 +161,11 @@ export class CircuitRecorder {
159
161
  throw new Error(`Oracle method ${name} not found when setting up recording callback`);
160
162
  }
161
163
 
162
- const isExternalCall = (name as keyof ACIRCallback) === 'privateCallPrivateFunction';
164
+ const isExternalCall = (name as keyof ACIRCallback) === 'aztec_prv_callPrivateFunction';
163
165
 
164
166
  recordingCallback[name as keyof ACIRCallback] = (...args: ForeignCallInput[]): ReturnType<typeof fn> => {
165
167
  const timer = new Timer();
166
- // If we're entering another circuit via `privateCallPrivateFunction`, we increase the stack depth and set the
168
+ // If we're entering another circuit via `aztec_prv_callPrivateFunction`, we increase the stack depth and set the
167
169
  // newCircuit variable to ensure we are creating a new recording object.
168
170
  if (isExternalCall) {
169
171
  this.stackDepth++;
@@ -1,3 +1,5 @@
1
+ import type { Logger } from '@aztec/foundation/log';
2
+
1
3
  import fs from 'fs/promises';
2
4
  import path from 'path';
3
5
 
@@ -7,8 +9,11 @@ import { CircuitRecorder, type CircuitRecording } from './circuit_recorder.js';
7
9
  export class FileCircuitRecorder extends CircuitRecorder {
8
10
  declare recording?: CircuitRecording & { filePath: string; isFirstCall: boolean };
9
11
 
10
- constructor(private readonly recordDir: string) {
11
- super();
12
+ constructor(
13
+ private readonly recordDir: string,
14
+ logger?: Logger,
15
+ ) {
16
+ super(logger);
12
17
  }
13
18
 
14
19
  override async start(
@@ -1,11 +1,13 @@
1
+ import type { Logger } from '@aztec/foundation/log';
2
+
1
3
  import { CircuitRecorder } from './circuit_recorder.js';
2
4
 
3
- /*
5
+ /**
4
6
  * In memory circuit recorder uses the default implementation. This is kept
5
- * while we decide the fate of the FileCircuitRecorder
7
+ * while we decide the fate of the FileCircuitRecorder.
6
8
  */
7
9
  export class MemoryCircuitRecorder extends CircuitRecorder {
8
- constructor() {
9
- super();
10
+ constructor(logger?: Logger) {
11
+ super(logger);
10
12
  }
11
13
  }
@@ -1,4 +1,4 @@
1
- import { type Logger, createLogger } from '@aztec/foundation/log';
1
+ import { type Logger, type LoggerBindings, resolveLogger } from '@aztec/foundation/log';
2
2
 
3
3
  import { promises as fs } from 'fs';
4
4
 
@@ -21,18 +21,21 @@ export function getSimulatorConfigFromEnv() {
21
21
 
22
22
  export async function createSimulator(
23
23
  config: SimulatorConfig,
24
- logger: Logger = createLogger('simulator'),
24
+ loggerOrBindings?: Logger | LoggerBindings,
25
25
  ): Promise<CircuitSimulator> {
26
+ const logger = resolveLogger('simulator', loggerOrBindings);
26
27
  if (config.acvmBinaryPath && config.acvmWorkingDirectory) {
27
28
  try {
28
29
  await fs.access(config.acvmBinaryPath, fs.constants.R_OK);
29
30
  await fs.mkdir(config.acvmWorkingDirectory, { recursive: true });
30
31
  logger.info(`Using native ACVM at ${config.acvmBinaryPath} and working directory ${config.acvmWorkingDirectory}`);
31
- return new NativeACVMSimulator(config.acvmWorkingDirectory, config.acvmBinaryPath);
32
+ const acvmLogger = logger.createChild('acvm-native');
33
+ return new NativeACVMSimulator(config.acvmWorkingDirectory, config.acvmBinaryPath, undefined, acvmLogger);
32
34
  } catch {
33
35
  logger.warn(`Failed to access ACVM at ${config.acvmBinaryPath}, falling back to WASM`);
34
36
  }
35
37
  }
36
38
  logger.info('Using WASM ACVM simulation');
37
- return new WASMSimulator();
39
+ const wasmLogger = logger.createChild('wasm');
40
+ return new WASMSimulator(wasmLogger);
38
41
  }
@@ -110,7 +110,7 @@ const BASE_GAS_COSTS: Record<Opcode, Gas> = {
110
110
  [Opcode.NULLIFIEREXISTS]: makeCost(c.AVM_NULLIFIEREXISTS_BASE_L2_GAS, 0),
111
111
  [Opcode.EMITNULLIFIER]: makeCost(c.AVM_EMITNULLIFIER_BASE_L2_GAS, c.AVM_EMITNULLIFIER_BASE_DA_GAS),
112
112
  [Opcode.L1TOL2MSGEXISTS]: makeCost(c.AVM_L1TOL2MSGEXISTS_BASE_L2_GAS, 0),
113
- [Opcode.EMITUNENCRYPTEDLOG]: makeCost(c.AVM_EMITUNENCRYPTEDLOG_BASE_L2_GAS, c.AVM_EMITUNENCRYPTEDLOG_BASE_DA_GAS),
113
+ [Opcode.EMITPUBLICLOG]: makeCost(c.AVM_EMITPUBLICLOG_BASE_L2_GAS, c.AVM_EMITPUBLICLOG_BASE_DA_GAS),
114
114
  [Opcode.SENDL2TOL1MSG]: makeCost(c.AVM_SENDL2TOL1MSG_BASE_L2_GAS, c.AVM_SENDL2TOL1MSG_BASE_DA_GAS),
115
115
  [Opcode.GETCONTRACTINSTANCE]: makeCost(c.AVM_GETCONTRACTINSTANCE_BASE_L2_GAS, 0),
116
116
  [Opcode.CALL]: makeCost(c.AVM_CALL_BASE_L2_GAS, 0),
@@ -130,7 +130,7 @@ const DYNAMIC_GAS_COSTS = new Map<Opcode, Gas>([
130
130
  [Opcode.CALLDATACOPY, makeCost(c.AVM_CALLDATACOPY_DYN_L2_GAS, 0)],
131
131
  [Opcode.RETURNDATACOPY, makeCost(c.AVM_RETURNDATACOPY_DYN_L2_GAS, 0)],
132
132
  // TODO: Call and static call based on bytecode length
133
- [Opcode.EMITUNENCRYPTEDLOG, makeCost(c.AVM_EMITUNENCRYPTEDLOG_DYN_L2_GAS, c.AVM_EMITUNENCRYPTEDLOG_DYN_DA_GAS)],
133
+ [Opcode.EMITPUBLICLOG, makeCost(c.AVM_EMITPUBLICLOG_DYN_L2_GAS, c.AVM_EMITPUBLICLOG_DYN_DA_GAS)],
134
134
  [Opcode.TORADIXBE, makeCost(c.AVM_TORADIXBE_DYN_L2_GAS, 0)],
135
135
  [Opcode.AND_8, makeCost(c.AVM_BITWISE_DYN_L2_GAS, 0)],
136
136
  [Opcode.AND_16, makeCost(c.AVM_BITWISE_DYN_L2_GAS, 0)],