@aztec/simulator 0.0.1-commit.e61ad554 → 0.0.1-commit.ee80a48

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 (97) hide show
  1. package/dest/private/acvm/acvm.d.ts +4 -2
  2. package/dest/private/acvm/acvm.d.ts.map +1 -1
  3. package/dest/private/acvm/acvm.js +4 -3
  4. package/dest/private/acvm_native.d.ts +5 -3
  5. package/dest/private/acvm_native.d.ts.map +1 -1
  6. package/dest/private/acvm_native.js +8 -6
  7. package/dest/private/acvm_wasm.d.ts +4 -3
  8. package/dest/private/acvm_wasm.d.ts.map +1 -1
  9. package/dest/private/acvm_wasm.js +4 -4
  10. package/dest/private/circuit_recording/circuit_recorder.d.ts +4 -3
  11. package/dest/private/circuit_recording/circuit_recorder.d.ts.map +1 -1
  12. package/dest/private/circuit_recording/circuit_recorder.js +5 -3
  13. package/dest/private/circuit_recording/file_circuit_recorder.d.ts +3 -2
  14. package/dest/private/circuit_recording/file_circuit_recorder.d.ts.map +1 -1
  15. package/dest/private/circuit_recording/file_circuit_recorder.js +2 -2
  16. package/dest/private/circuit_recording/memory_circuit_recorder.d.ts +7 -2
  17. package/dest/private/circuit_recording/memory_circuit_recorder.d.ts.map +1 -1
  18. package/dest/private/circuit_recording/memory_circuit_recorder.js +4 -4
  19. package/dest/private/factory.d.ts +3 -3
  20. package/dest/private/factory.d.ts.map +1 -1
  21. package/dest/private/factory.js +7 -4
  22. package/dest/public/avm/opcodes/accrued_substate.d.ts +3 -4
  23. package/dest/public/avm/opcodes/accrued_substate.d.ts.map +1 -1
  24. package/dest/public/avm/opcodes/accrued_substate.js +8 -12
  25. package/dest/public/executor_metrics.d.ts +1 -1
  26. package/dest/public/executor_metrics.d.ts.map +1 -1
  27. package/dest/public/executor_metrics.js +7 -2
  28. package/dest/public/fixtures/opcode_spammer.d.ts +3 -4
  29. package/dest/public/fixtures/opcode_spammer.d.ts.map +1 -1
  30. package/dest/public/fixtures/opcode_spammer.js +10 -50
  31. package/dest/public/public_db_sources.d.ts +4 -3
  32. package/dest/public/public_db_sources.d.ts.map +1 -1
  33. package/dest/public/public_db_sources.js +4 -4
  34. package/dest/public/public_processor/public_processor.d.ts +5 -3
  35. package/dest/public/public_processor/public_processor.d.ts.map +1 -1
  36. package/dest/public/public_processor/public_processor.js +8 -5
  37. package/dest/public/public_processor/public_processor_metrics.d.ts +2 -2
  38. package/dest/public/public_processor/public_processor_metrics.d.ts.map +1 -1
  39. package/dest/public/public_processor/public_processor_metrics.js +20 -4
  40. package/dest/public/public_tx_simulator/contract_provider_for_cpp.d.ts +3 -2
  41. package/dest/public/public_tx_simulator/contract_provider_for_cpp.d.ts.map +1 -1
  42. package/dest/public/public_tx_simulator/contract_provider_for_cpp.js +2 -2
  43. package/dest/public/public_tx_simulator/cpp_public_tx_simulator.d.ts +5 -5
  44. package/dest/public/public_tx_simulator/cpp_public_tx_simulator.d.ts.map +1 -1
  45. package/dest/public/public_tx_simulator/cpp_public_tx_simulator.js +8 -8
  46. package/dest/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.d.ts +4 -4
  47. package/dest/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.d.ts.map +1 -1
  48. package/dest/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.js +5 -5
  49. package/dest/public/public_tx_simulator/cpp_vs_ts_public_tx_simulator.d.ts +4 -4
  50. package/dest/public/public_tx_simulator/cpp_vs_ts_public_tx_simulator.d.ts.map +1 -1
  51. package/dest/public/public_tx_simulator/cpp_vs_ts_public_tx_simulator.js +6 -6
  52. package/dest/public/public_tx_simulator/dumping_cpp_public_tx_simulator.d.ts +3 -2
  53. package/dest/public/public_tx_simulator/dumping_cpp_public_tx_simulator.d.ts.map +1 -1
  54. package/dest/public/public_tx_simulator/dumping_cpp_public_tx_simulator.js +2 -2
  55. package/dest/public/public_tx_simulator/factories.d.ts +3 -2
  56. package/dest/public/public_tx_simulator/factories.d.ts.map +1 -1
  57. package/dest/public/public_tx_simulator/factories.js +3 -3
  58. package/dest/public/public_tx_simulator/public_tx_context.d.ts +4 -3
  59. package/dest/public/public_tx_simulator/public_tx_context.d.ts.map +1 -1
  60. package/dest/public/public_tx_simulator/public_tx_context.js +8 -8
  61. package/dest/public/public_tx_simulator/public_tx_simulator.d.ts +4 -3
  62. package/dest/public/public_tx_simulator/public_tx_simulator.d.ts.map +1 -1
  63. package/dest/public/public_tx_simulator/public_tx_simulator.js +5 -3
  64. package/dest/public/side_effect_trace.d.ts +4 -4
  65. package/dest/public/side_effect_trace.d.ts.map +1 -1
  66. package/dest/public/side_effect_trace.js +3 -3
  67. package/dest/public/state_manager/state_manager.d.ts +10 -4
  68. package/dest/public/state_manager/state_manager.d.ts.map +1 -1
  69. package/dest/public/state_manager/state_manager.js +12 -5
  70. package/dest/public/test_executor_metrics.d.ts +3 -2
  71. package/dest/public/test_executor_metrics.d.ts.map +1 -1
  72. package/dest/public/test_executor_metrics.js +2 -2
  73. package/package.json +16 -16
  74. package/src/private/acvm/acvm.ts +4 -3
  75. package/src/private/acvm_native.ts +11 -5
  76. package/src/private/acvm_wasm.ts +7 -3
  77. package/src/private/circuit_recording/circuit_recorder.ts +5 -3
  78. package/src/private/circuit_recording/file_circuit_recorder.ts +7 -2
  79. package/src/private/circuit_recording/memory_circuit_recorder.ts +6 -4
  80. package/src/private/factory.ts +7 -4
  81. package/src/public/avm/opcodes/accrued_substate.ts +7 -15
  82. package/src/public/executor_metrics.ts +4 -1
  83. package/src/public/fixtures/opcode_spammer.ts +12 -45
  84. package/src/public/public_db_sources.ts +15 -5
  85. package/src/public/public_processor/public_processor.ts +18 -5
  86. package/src/public/public_processor/public_processor_metrics.ts +10 -4
  87. package/src/public/public_tx_simulator/contract_provider_for_cpp.ts +6 -3
  88. package/src/public/public_tx_simulator/cpp_public_tx_simulator.ts +9 -6
  89. package/src/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.ts +6 -4
  90. package/src/public/public_tx_simulator/cpp_vs_ts_public_tx_simulator.ts +7 -5
  91. package/src/public/public_tx_simulator/dumping_cpp_public_tx_simulator.ts +3 -1
  92. package/src/public/public_tx_simulator/factories.ts +4 -2
  93. package/src/public/public_tx_simulator/public_tx_context.ts +13 -6
  94. package/src/public/public_tx_simulator/public_tx_simulator.ts +6 -2
  95. package/src/public/side_effect_trace.ts +5 -2
  96. package/src/public/state_manager/state_manager.ts +27 -4
  97. package/src/public/test_executor_metrics.ts +3 -3
@@ -48,8 +48,8 @@ export class TestExecutorMetrics {
48
48
  txMetrics = new Map();
49
49
  currentTxLabel;
50
50
  txTimer;
51
- constructor(){
52
- this.logger = createLogger(`simulator:test_executor_metrics`);
51
+ constructor(bindings){
52
+ this.logger = createLogger(`simulator:test_executor_metrics`, bindings);
53
53
  }
54
54
  startRecordingTxSimulation(txLabel) {
55
55
  assert(!this.currentTxLabel, 'Cannot start recording tx simulation when another is live');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/simulator",
3
- "version": "0.0.1-commit.e61ad554",
3
+ "version": "0.0.1-commit.ee80a48",
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.e61ad554",
68
- "@aztec/foundation": "0.0.1-commit.e61ad554",
69
- "@aztec/native": "0.0.1-commit.e61ad554",
70
- "@aztec/noir-acvm_js": "0.0.1-commit.e61ad554",
71
- "@aztec/noir-noirc_abi": "0.0.1-commit.e61ad554",
72
- "@aztec/noir-protocol-circuits-types": "0.0.1-commit.e61ad554",
73
- "@aztec/noir-types": "0.0.1-commit.e61ad554",
74
- "@aztec/protocol-contracts": "0.0.1-commit.e61ad554",
75
- "@aztec/stdlib": "0.0.1-commit.e61ad554",
76
- "@aztec/telemetry-client": "0.0.1-commit.e61ad554",
77
- "@aztec/world-state": "0.0.1-commit.e61ad554",
67
+ "@aztec/constants": "0.0.1-commit.ee80a48",
68
+ "@aztec/foundation": "0.0.1-commit.ee80a48",
69
+ "@aztec/native": "0.0.1-commit.ee80a48",
70
+ "@aztec/noir-acvm_js": "0.0.1-commit.ee80a48",
71
+ "@aztec/noir-noirc_abi": "0.0.1-commit.ee80a48",
72
+ "@aztec/noir-protocol-circuits-types": "0.0.1-commit.ee80a48",
73
+ "@aztec/noir-types": "0.0.1-commit.ee80a48",
74
+ "@aztec/protocol-contracts": "0.0.1-commit.ee80a48",
75
+ "@aztec/stdlib": "0.0.1-commit.ee80a48",
76
+ "@aztec/telemetry-client": "0.0.1-commit.ee80a48",
77
+ "@aztec/world-state": "0.0.1-commit.ee80a48",
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.e61ad554",
84
- "@aztec/merkle-tree": "0.0.1-commit.e61ad554",
85
- "@aztec/noir-contracts.js": "0.0.1-commit.e61ad554",
86
- "@aztec/noir-test-contracts.js": "0.0.1-commit.e61ad554",
83
+ "@aztec/kv-store": "0.0.1-commit.ee80a48",
84
+ "@aztec/merkle-tree": "0.0.1-commit.ee80a48",
85
+ "@aztec/noir-contracts.js": "0.0.1-commit.ee80a48",
86
+ "@aztec/noir-test-contracts.js": "0.0.1-commit.ee80a48",
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.
@@ -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
  }
@@ -88,18 +88,11 @@ export class NullifierExists extends Instruction {
88
88
  static type: string = 'NULLIFIEREXISTS';
89
89
  static readonly opcode: Opcode = Opcode.NULLIFIEREXISTS;
90
90
  // Informs (de)serialization. See Instruction.deserialize.
91
- static readonly wireFormat = [
92
- OperandType.UINT8,
93
- OperandType.UINT8,
94
- OperandType.UINT16,
95
- OperandType.UINT16,
96
- OperandType.UINT16,
97
- ];
91
+ static readonly wireFormat = [OperandType.UINT8, OperandType.UINT8, OperandType.UINT16, OperandType.UINT16];
98
92
 
99
93
  constructor(
100
94
  private addressingMode: number,
101
- private nullifierOffset: number,
102
- private addressOffset: number,
95
+ private siloedNullifierOffset: number,
103
96
  private existsOffset: number,
104
97
  ) {
105
98
  super();
@@ -113,13 +106,12 @@ export class NullifierExists extends Instruction {
113
106
  this.baseGasCost(addressing.indirectOperandsCount(), addressing.relativeOperandsCount()),
114
107
  );
115
108
 
116
- const operands = [this.nullifierOffset, this.addressOffset, this.existsOffset];
117
- const [nullifierOffset, addressOffset, existsOffset] = addressing.resolve(operands, memory);
118
- memory.checkTags(TypeTag.FIELD, nullifierOffset, addressOffset);
109
+ const operands = [this.siloedNullifierOffset, this.existsOffset];
110
+ const [siloedNullifierOffset, existsOffset] = addressing.resolve(operands, memory);
111
+ memory.checkTag(TypeTag.FIELD, siloedNullifierOffset);
119
112
 
120
- const nullifier = memory.get(nullifierOffset).toFr();
121
- const address = memory.get(addressOffset).toAztecAddress();
122
- const exists = await context.persistableState.checkNullifierExists(address, nullifier);
113
+ const siloedNullifier = memory.get(siloedNullifierOffset).toFr();
114
+ const exists = await context.persistableState.checkSiloedNullifierExists(siloedNullifier);
123
115
 
124
116
  memory.set(existsOffset, exists ? new Uint1(1) : new Uint1(0));
125
117
  }
@@ -7,6 +7,7 @@ import {
7
7
  type TelemetryClient,
8
8
  type Tracer,
9
9
  type UpDownCounter,
10
+ createUpDownCounterWithDefault,
10
11
  } from '@aztec/telemetry-client';
11
12
 
12
13
  import type { ExecutorMetricsInterface } from './executor_metrics_interface.js';
@@ -25,7 +26,9 @@ export class ExecutorMetrics implements ExecutorMetricsInterface {
25
26
  this.tracer = client.getTracer(name);
26
27
  const meter = client.getMeter(name);
27
28
 
28
- this.fnCount = meter.createUpDownCounter(Metrics.PUBLIC_EXECUTOR_SIMULATION_COUNT);
29
+ this.fnCount = createUpDownCounterWithDefault(meter, Metrics.PUBLIC_EXECUTOR_SIMULATION_COUNT, {
30
+ [Attributes.OK]: [true, false],
31
+ });
29
32
 
30
33
  this.fnDuration = meter.createHistogram(Metrics.PUBLIC_EXECUTOR_SIMULATION_DURATION);
31
34
 
@@ -164,7 +164,7 @@ import { Fr } from '@aztec/foundation/curves/bn254';
164
164
  import type { Bufferable } from '@aztec/foundation/serialize';
165
165
  import { type CallStackMetadata, PublicDataWrite, type PublicTxResult } from '@aztec/stdlib/avm';
166
166
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
167
- import { computePublicDataTreeLeafSlot, siloNullifier } from '@aztec/stdlib/hash';
167
+ import { computePublicDataTreeLeafSlot } from '@aztec/stdlib/hash';
168
168
  import type { MerkleTreeWriteOperations } from '@aztec/stdlib/interfaces/server';
169
169
  import { MerkleTreeId } from '@aztec/stdlib/trees';
170
170
 
@@ -295,9 +295,8 @@ export interface SpamConfigsForOpcode {
295
295
  export const WARM_NOTE_HASH = new Fr(0xdeadbeefn);
296
296
  export const WARM_L1_TO_L2_MSG = new Fr(0xcafebabedeadbeefn);
297
297
 
298
- /** Warm nullifier constants - uses a fixed address since NULLIFIEREXISTS takes address as parameter */
299
- export const WARM_NULLIFIER = new Fr(0xdeadbeef0001n);
300
- export const WARM_NULLIFIER_ADDRESS = AztecAddress.fromNumber(0xbeef);
298
+ /** Warm nullifier constant - a pre-siloed nullifier value inserted directly into the tree */
299
+ export const WARM_SILOED_NULLIFIER = new Fr(0xdeadbeef0001n);
301
300
 
302
301
  /** Warm storage constants - storage is inserted for the deployed contract's address */
303
302
  export const WARM_STORAGE_SLOT = new Fr(0xdeadbeef0002n);
@@ -331,9 +330,8 @@ export async function insertWarmTreeEntries(
331
330
  // Insert into L1 to L2 message tree
332
331
  await merkleTrees.appendLeaves(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, [WARM_L1_TO_L2_MSG]);
333
332
 
334
- // Insert siloed nullifier into nullifier tree
335
- const siloedNullifier = await siloNullifier(WARM_NULLIFIER_ADDRESS, WARM_NULLIFIER);
336
- await merkleTrees.sequentialInsert(MerkleTreeId.NULLIFIER_TREE, [siloedNullifier.toBuffer()]);
333
+ // Insert siloed nullifier into nullifier tree (already siloed - used directly by NULLIFIEREXISTS)
334
+ await merkleTrees.sequentialInsert(MerkleTreeId.NULLIFIER_TREE, [WARM_SILOED_NULLIFIER.toBuffer()]);
337
335
 
338
336
  // Insert storage value into public data tree
339
337
  const leafSlot = await computePublicDataTreeLeafSlot(contractAddress, WARM_STORAGE_SLOT);
@@ -1060,56 +1058,25 @@ export const SPAM_CONFIGS: Partial<Record<Opcode, SpamConfig[]>> = {
1060
1058
  [Opcode.NULLIFIEREXISTS]: [
1061
1059
  {
1062
1060
  label: 'Non-existent nullifier',
1061
+ // NULLIFIEREXISTS now takes a siloed nullifier directly (no address parameter)
1063
1062
  setup: [
1064
- { offset: 0, value: new Field(Fr.random()) }, // random nullifier
1065
- { offset: 1, value: new Field(Fr.random()) }, // random address
1063
+ { offset: 0, value: new Field(Fr.random()) }, // random siloed nullifier (won't exist)
1066
1064
  ],
1067
1065
  targetInstructions: () => [
1068
- new NullifierExists(/*addressing_mode=*/ 0, /*nullifierOffset=*/ 0, /*addressOffset=*/ 1, /*existsOffset=*/ 2),
1066
+ new NullifierExists(/*addressing_mode=*/ 0, /*siloedNullifierOffset=*/ 0, /*existsOffset=*/ 1),
1069
1067
  ],
1070
1068
  },
1071
1069
  {
1072
1070
  label: 'Existing nullifier (warm - from tree)',
1073
- // Uses pre-inserted nullifier from insertWarmTreeEntries()
1071
+ // Uses pre-inserted siloed nullifier from insertWarmTreeEntries()
1072
+ // NULLIFIEREXISTS now takes a siloed nullifier directly
1074
1073
  setup: [
1075
- { offset: 0, value: new Field(WARM_NULLIFIER) }, // pre-inserted nullifier
1076
- { offset: 1, value: new Field(WARM_NULLIFIER_ADDRESS.toField()) }, // address it was siloed with
1074
+ { offset: 0, value: new Field(WARM_SILOED_NULLIFIER) }, // pre-inserted siloed nullifier
1077
1075
  ],
1078
1076
  targetInstructions: () => [
1079
- new NullifierExists(/*addressing_mode=*/ 0, /*nullifierOffset=*/ 0, /*addressOffset=*/ 1, /*existsOffset=*/ 2),
1077
+ new NullifierExists(/*addressing_mode=*/ 0, /*siloedNullifierOffset=*/ 0, /*existsOffset=*/ 1),
1080
1078
  ],
1081
1079
  },
1082
- {
1083
- label: 'Existing nullifier (warm - EMITNULLIFIER first)',
1084
- // Memory layout: nullifier (incremented), constant 1, current address (from GETENVVAR), revertSize, exists result
1085
- setup: [
1086
- { offset: 0, value: new Field(Fr.random()) }, // nullifier (will be incremented)
1087
- { offset: 1, value: new Field(1n) }, // constant 1 for ADD
1088
- () => [
1089
- // Get current contract address into offset 2
1090
- new GetEnvVar(/*addressing_mode=*/ 0, /*dstOffset=*/ 2, /*varEnum=*/ 0).as(
1091
- Opcode.GETENVVAR_16,
1092
- GetEnvVar.wireFormat16,
1093
- ),
1094
- ],
1095
- { offset: 3, value: new Uint32(0n) }, // revertSize
1096
- ],
1097
- targetInstructions: () => [
1098
- new EmitNullifier(/*addressing_mode=*/ 0, /*nullifierOffset=*/ 0),
1099
- new NullifierExists(/*addressing_mode=*/ 0, /*nullifierOffset=*/ 0, /*addressOffset=*/ 2, /*existsOffset=*/ 4),
1100
- new Add(/*addressing_mode=*/ 0, /*aOffset=*/ 0, /*bOffset=*/ 1, /*dstOffset=*/ 0).as(
1101
- Opcode.ADD_8,
1102
- Add.wireFormat8,
1103
- ), // nullifier++
1104
- ],
1105
- cleanupInstructions: () => [
1106
- new Revert(/*addressing_mode=*/ 0, /*retSizeOffset=*/ 3, /*returnOffset=*/ 0).as(
1107
- Opcode.REVERT_8,
1108
- Revert.wireFormat8,
1109
- ),
1110
- ],
1111
- limit: MAX_NULLIFIERS_PER_TX - 1,
1112
- },
1113
1080
  ],
1114
1081
 
1115
1082
  [Opcode.L1TOL2MSGEXISTS]: [
@@ -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();
@@ -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';
@@ -62,11 +62,15 @@ import { PublicProcessorMetrics } from './public_processor_metrics.js';
62
62
  * Creates new instances of PublicProcessor given the provided merkle tree db and contract data source.
63
63
  */
64
64
  export class PublicProcessorFactory {
65
+ private log: Logger;
65
66
  constructor(
66
67
  private contractDataSource: ContractDataSource,
67
68
  private dateProvider: DateProvider = new DateProvider(),
68
69
  protected telemetryClient: TelemetryClient = getTelemetryClient(),
69
- ) {}
70
+ bindings?: LoggerBindings,
71
+ ) {
72
+ this.log = createLogger('simulator:public-processor-factory', bindings);
73
+ }
70
74
 
71
75
  /**
72
76
  * Creates a new instance of a PublicProcessor.
@@ -79,7 +83,8 @@ export class PublicProcessorFactory {
79
83
  globalVariables: GlobalVariables,
80
84
  config: PublicSimulatorConfig,
81
85
  ): PublicProcessor {
82
- const contractsDB = new PublicContractsDB(this.contractDataSource);
86
+ const bindings = this.log.getBindings();
87
+ const contractsDB = new PublicContractsDB(this.contractDataSource, bindings);
83
88
 
84
89
  const guardedFork = new GuardedMerkleTreeOperations(merkleTree);
85
90
  const publicTxSimulator = this.createPublicTxSimulator(guardedFork, contractsDB, globalVariables, config);
@@ -91,6 +96,7 @@ export class PublicProcessorFactory {
91
96
  publicTxSimulator,
92
97
  this.dateProvider,
93
98
  this.telemetryClient,
99
+ createLogger('simulator:public-processor', bindings),
94
100
  );
95
101
  }
96
102
 
@@ -100,7 +106,14 @@ export class PublicProcessorFactory {
100
106
  globalVariables: GlobalVariables,
101
107
  config?: Partial<PublicTxSimulatorConfig>,
102
108
  ): PublicTxSimulatorInterface {
103
- return new TelemetryCppPublicTxSimulator(merkleTree, contractsDB, globalVariables, this.telemetryClient, config);
109
+ return new TelemetryCppPublicTxSimulator(
110
+ merkleTree,
111
+ contractsDB,
112
+ globalVariables,
113
+ this.telemetryClient,
114
+ config,
115
+ this.log.getBindings(),
116
+ );
104
117
  }
105
118
  }
106
119
 
@@ -125,7 +138,7 @@ 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'> = {},
130
143
  ) {
131
144
  this.metrics = new PublicProcessorMetrics(telemetryClient, 'PublicProcessor');
@@ -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})`);
@@ -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 { 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...`);
@@ -171,8 +172,9 @@ export class MeasuredCppPublicTxSimulator extends CppPublicTxSimulator implement
171
172
  globalVariables: GlobalVariables,
172
173
  protected readonly metrics: ExecutorMetricsInterface,
173
174
  config?: Partial<PublicSimulatorConfig>,
175
+ bindings?: LoggerBindings,
174
176
  ) {
175
- super(merkleTree, contractsDB, globalVariables, config);
177
+ super(merkleTree, contractsDB, globalVariables, config, bindings);
176
178
  }
177
179
 
178
180
  public override async simulate(tx: Tx, txLabel: string = 'unlabeledTx'): Promise<PublicTxResult> {
@@ -200,9 +202,10 @@ export class TelemetryCppPublicTxSimulator extends MeasuredCppPublicTxSimulator
200
202
  globalVariables: GlobalVariables,
201
203
  telemetryClient: TelemetryClient = getTelemetryClient(),
202
204
  config?: Partial<PublicSimulatorConfig>,
205
+ bindings?: LoggerBindings,
203
206
  ) {
204
207
  const metrics = new ExecutorMetrics(telemetryClient, 'CppPublicTxSimulator');
205
- super(merkleTree, contractsDB, globalVariables, metrics, config);
208
+ super(merkleTree, contractsDB, globalVariables, metrics, config, bindings);
206
209
  this.tracer = metrics.tracer;
207
210
  }
208
211
  }