@aztec/simulator 0.87.5 → 0.87.6

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 (129) hide show
  1. package/dest/client.d.ts +5 -3
  2. package/dest/client.d.ts.map +1 -1
  3. package/dest/client.js +4 -2
  4. package/dest/private/acvm/acvm.d.ts +5 -2
  5. package/dest/private/acvm/acvm.d.ts.map +1 -1
  6. package/dest/private/acvm/index.d.ts +0 -1
  7. package/dest/private/acvm/index.d.ts.map +1 -1
  8. package/dest/private/acvm/index.js +0 -1
  9. package/dest/private/{providers/acvm_native.d.ts → acvm_native.d.ts} +4 -4
  10. package/dest/private/acvm_native.d.ts.map +1 -0
  11. package/dest/private/{providers/acvm_wasm.d.ts → acvm_wasm.d.ts} +4 -4
  12. package/dest/private/acvm_wasm.d.ts.map +1 -0
  13. package/dest/private/{providers/acvm_wasm.js → acvm_wasm.js} +2 -2
  14. package/dest/private/{providers/acvm_wasm_with_blobs.d.ts → acvm_wasm_with_blobs.d.ts} +5 -5
  15. package/dest/private/acvm_wasm_with_blobs.d.ts.map +1 -0
  16. package/dest/private/{providers/acvm_wasm_with_blobs.js → acvm_wasm_with_blobs.js} +2 -2
  17. package/dest/private/{providers/circuit_recording → circuit_recording}/circuit_recorder.d.ts +41 -21
  18. package/dest/private/circuit_recording/circuit_recorder.d.ts.map +1 -0
  19. package/dest/private/circuit_recording/circuit_recorder.js +209 -0
  20. package/dest/private/circuit_recording/file_circuit_recorder.d.ts +31 -0
  21. package/dest/private/circuit_recording/file_circuit_recorder.d.ts.map +1 -0
  22. package/dest/private/circuit_recording/file_circuit_recorder.js +135 -0
  23. package/dest/private/circuit_recording/memory_circuit_recorder.d.ts +5 -0
  24. package/dest/private/circuit_recording/memory_circuit_recorder.d.ts.map +1 -0
  25. package/dest/private/circuit_recording/memory_circuit_recorder.js +9 -0
  26. package/dest/private/{providers/circuit_recording/simulation_provider_recorder_wrapper.d.ts → circuit_recording/simulator_recorder_wrapper.d.ts} +9 -7
  27. package/dest/private/circuit_recording/simulator_recorder_wrapper.d.ts.map +1 -0
  28. package/dest/private/{providers/circuit_recording/simulation_provider_recorder_wrapper.js → circuit_recording/simulator_recorder_wrapper.js} +18 -13
  29. package/dest/private/{providers/simulation_provider.d.ts → circuit_simulator.d.ts} +4 -4
  30. package/dest/private/circuit_simulator.d.ts.map +1 -0
  31. package/dest/private/{providers/simulation_provider.js → circuit_simulator.js} +1 -1
  32. package/dest/private/factory.d.ts +12 -0
  33. package/dest/private/factory.d.ts.map +1 -0
  34. package/dest/private/{providers/factory.js → factory.js} +2 -2
  35. package/dest/public/avm/fixtures/base_avm_simulation_tester.d.ts +1 -0
  36. package/dest/public/avm/fixtures/base_avm_simulation_tester.d.ts.map +1 -1
  37. package/dest/public/avm/fixtures/base_avm_simulation_tester.js +6 -0
  38. package/dest/public/public_tx_simulator/apps_tests/amm_test.d.ts.map +1 -1
  39. package/dest/public/public_tx_simulator/apps_tests/amm_test.js +27 -55
  40. package/dest/server.d.ts +6 -3
  41. package/dest/server.d.ts.map +1 -1
  42. package/dest/server.js +5 -2
  43. package/dest/testing.d.ts +1 -1
  44. package/dest/testing.d.ts.map +1 -1
  45. package/dest/testing.js +1 -1
  46. package/package.json +15 -15
  47. package/src/client.ts +5 -3
  48. package/src/private/acvm/acvm.ts +5 -3
  49. package/src/private/acvm/index.ts +0 -1
  50. package/src/private/{providers/acvm_native.ts → acvm_native.ts} +4 -4
  51. package/src/private/{providers/acvm_wasm.ts → acvm_wasm.ts} +4 -4
  52. package/src/private/{providers/acvm_wasm_with_blobs.ts → acvm_wasm_with_blobs.ts} +5 -5
  53. package/src/private/circuit_recording/circuit_recorder.ts +260 -0
  54. package/src/private/circuit_recording/file_circuit_recorder.ts +158 -0
  55. package/src/private/circuit_recording/memory_circuit_recorder.ts +11 -0
  56. package/src/private/{providers/circuit_recording/simulation_provider_recorder_wrapper.ts → circuit_recording/simulator_recorder_wrapper.ts} +26 -18
  57. package/src/private/{providers/simulation_provider.ts → circuit_simulator.ts} +3 -3
  58. package/src/private/{providers/factory.ts → factory.ts} +6 -6
  59. package/src/public/avm/fixtures/base_avm_simulation_tester.ts +5 -0
  60. package/src/public/public_tx_simulator/apps_tests/amm_test.ts +49 -44
  61. package/src/server.ts +6 -3
  62. package/src/testing.ts +1 -1
  63. package/dest/private/acvm/oracle/index.d.ts +0 -14
  64. package/dest/private/acvm/oracle/index.d.ts.map +0 -1
  65. package/dest/private/acvm/oracle/index.js +0 -2
  66. package/dest/private/acvm/oracle/oracle.d.ts +0 -52
  67. package/dest/private/acvm/oracle/oracle.d.ts.map +0 -1
  68. package/dest/private/acvm/oracle/oracle.js +0 -312
  69. package/dest/private/acvm/oracle/typed_oracle.d.ts +0 -83
  70. package/dest/private/acvm/oracle/typed_oracle.d.ts.map +0 -1
  71. package/dest/private/acvm/oracle/typed_oracle.js +0 -138
  72. package/dest/private/execution_data_provider.d.ts +0 -301
  73. package/dest/private/execution_data_provider.d.ts.map +0 -1
  74. package/dest/private/execution_data_provider.js +0 -14
  75. package/dest/private/execution_note_cache.d.ts +0 -93
  76. package/dest/private/execution_note_cache.d.ts.map +0 -1
  77. package/dest/private/execution_note_cache.js +0 -180
  78. package/dest/private/hashed_values_cache.d.ts +0 -28
  79. package/dest/private/hashed_values_cache.d.ts.map +0 -1
  80. package/dest/private/hashed_values_cache.js +0 -36
  81. package/dest/private/index.d.ts +0 -16
  82. package/dest/private/index.d.ts.map +0 -1
  83. package/dest/private/index.js +0 -15
  84. package/dest/private/message_load_oracle_inputs.d.ts +0 -19
  85. package/dest/private/message_load_oracle_inputs.d.ts.map +0 -1
  86. package/dest/private/message_load_oracle_inputs.js +0 -24
  87. package/dest/private/pick_notes.d.ts +0 -85
  88. package/dest/private/pick_notes.d.ts.map +0 -1
  89. package/dest/private/pick_notes.js +0 -51
  90. package/dest/private/private_execution.d.ts +0 -25
  91. package/dest/private/private_execution.d.ts.map +0 -1
  92. package/dest/private/private_execution.js +0 -95
  93. package/dest/private/private_execution_oracle.d.ts +0 -187
  94. package/dest/private/private_execution_oracle.d.ts.map +0 -1
  95. package/dest/private/private_execution_oracle.js +0 -318
  96. package/dest/private/providers/acvm_native.d.ts.map +0 -1
  97. package/dest/private/providers/acvm_wasm.d.ts.map +0 -1
  98. package/dest/private/providers/acvm_wasm_with_blobs.d.ts.map +0 -1
  99. package/dest/private/providers/circuit_recording/circuit_recorder.d.ts.map +0 -1
  100. package/dest/private/providers/circuit_recording/circuit_recorder.js +0 -246
  101. package/dest/private/providers/circuit_recording/simulation_provider_recorder_wrapper.d.ts.map +0 -1
  102. package/dest/private/providers/factory.d.ts +0 -12
  103. package/dest/private/providers/factory.d.ts.map +0 -1
  104. package/dest/private/providers/simulation_provider.d.ts.map +0 -1
  105. package/dest/private/simulator.d.ts +0 -36
  106. package/dest/private/simulator.d.ts.map +0 -1
  107. package/dest/private/simulator.js +0 -104
  108. package/dest/private/utility_execution_oracle.d.ts +0 -163
  109. package/dest/private/utility_execution_oracle.d.ts.map +0 -1
  110. package/dest/private/utility_execution_oracle.js +0 -257
  111. package/dest/test/utils.d.ts +0 -13
  112. package/dest/test/utils.d.ts.map +0 -1
  113. package/dest/test/utils.js +0 -22
  114. package/src/private/acvm/oracle/index.ts +0 -16
  115. package/src/private/acvm/oracle/oracle.ts +0 -523
  116. package/src/private/acvm/oracle/typed_oracle.ts +0 -273
  117. package/src/private/execution_data_provider.ts +0 -388
  118. package/src/private/execution_note_cache.ts +0 -217
  119. package/src/private/hashed_values_cache.ts +0 -47
  120. package/src/private/index.ts +0 -19
  121. package/src/private/message_load_oracle_inputs.ts +0 -23
  122. package/src/private/pick_notes.ts +0 -141
  123. package/src/private/private_execution.ts +0 -159
  124. package/src/private/private_execution_oracle.ts +0 -508
  125. package/src/private/providers/circuit_recording/circuit_recorder.ts +0 -283
  126. package/src/private/simulator.ts +0 -170
  127. package/src/private/utility_execution_oracle.ts +0 -384
  128. package/src/test/utils.ts +0 -36
  129. /package/dest/private/{providers/acvm_native.js → acvm_native.js} +0 -0
@@ -0,0 +1,135 @@
1
+ import fs from 'fs/promises';
2
+ import path from 'path';
3
+ import { CircuitRecorder } from './circuit_recorder.js';
4
+ export class FileCircuitRecorder extends CircuitRecorder {
5
+ recordDir;
6
+ constructor(recordDir){
7
+ super(), this.recordDir = recordDir;
8
+ }
9
+ async start(input, circuitBytecode, circuitName, functionName = 'main') {
10
+ await super.start(input, circuitBytecode, circuitName, functionName);
11
+ const recordingStringWithoutClosingBracket = JSON.stringify({
12
+ ...this.recording,
13
+ isFirstCall: undefined,
14
+ parent: undefined,
15
+ oracleCalls: undefined,
16
+ filePath: undefined
17
+ }, null, 2).slice(0, -2);
18
+ try {
19
+ // Check if the recording directory exists and is a directory
20
+ const stats = await fs.stat(this.recordDir);
21
+ if (!stats.isDirectory()) {
22
+ throw new Error(`Recording path ${this.recordDir} exists but is not a directory`);
23
+ }
24
+ } catch (err) {
25
+ if (err.code === 'ENOENT') {
26
+ // The directory does not exist so we create it
27
+ await fs.mkdir(this.recordDir, {
28
+ recursive: true
29
+ });
30
+ } else {
31
+ throw err;
32
+ }
33
+ }
34
+ this.recording.isFirstCall = true;
35
+ this.recording.filePath = await FileCircuitRecorder.#computeFilePathAndStoreInitialRecording(this.recordDir, this.recording.circuitName, this.recording.functionName, recordingStringWithoutClosingBracket);
36
+ }
37
+ /**
38
+ * Computes a unique file path for the recording by trying different counter values.
39
+ * This is needed because multiple recordings of the same circuit could be happening simultaneously or an older
40
+ * recording might be present.
41
+ * @param recordDir - Directory to store the recording
42
+ * @param circuitName - Name of the circuit
43
+ * @param functionName - Name of the circuit function
44
+ * @param recordingContent - Initial recording content
45
+ * @returns A unique file path for the recording
46
+ */ static async #computeFilePathAndStoreInitialRecording(recordDir, circuitName, functionName, recordingContent) {
47
+ let counter = 0;
48
+ while(true){
49
+ try {
50
+ const filePath = getFilePath(recordDir, circuitName, functionName, counter);
51
+ // Write the initial recording content to the file
52
+ await fs.writeFile(filePath, recordingContent + ',\n "oracleCalls": [\n', {
53
+ flag: 'wx'
54
+ });
55
+ return filePath;
56
+ } catch (err) {
57
+ if (err.code === 'EEXIST') {
58
+ counter++;
59
+ continue;
60
+ }
61
+ throw err;
62
+ }
63
+ }
64
+ }
65
+ /**
66
+ * Records a single oracle/foreign call with its inputs and outputs.
67
+ * @param name - Name of the call
68
+ * @param inputs - Input arguments
69
+ * @param outputs - Output results
70
+ */ async recordCall(name, inputs, outputs, time, stackDepth) {
71
+ const entry = await super.recordCall(name, inputs, outputs, time, stackDepth);
72
+ try {
73
+ const prefix = this.recording.isFirstCall ? ' ' : ' ,';
74
+ this.recording.isFirstCall = false;
75
+ await fs.appendFile(this.recording.filePath, prefix + JSON.stringify(entry) + '\n');
76
+ } catch (err) {
77
+ this.logger.error('Failed to log circuit call', {
78
+ error: err
79
+ });
80
+ }
81
+ return entry;
82
+ }
83
+ /**
84
+ * Finalizes the recording file by adding closing brackets. Without calling this method, the recording file is
85
+ * incomplete and it fails to parse.
86
+ */ async finish() {
87
+ // Finish sets the recording to undefined if we are at the topmost circuit,
88
+ // so we save the current file path before that
89
+ const filePath = this.recording.filePath;
90
+ const result = await super.finish();
91
+ try {
92
+ await fs.appendFile(filePath, ' ]\n}\n');
93
+ } catch (err) {
94
+ this.logger.error('Failed to finalize recording file', {
95
+ error: err
96
+ });
97
+ }
98
+ return result;
99
+ }
100
+ /**
101
+ * Finalizes the recording file by adding the error and closing brackets. Without calling this method or `finish`,
102
+ * the recording file is incomplete and it fails to parse.
103
+ * @param error - The error that occurred during circuit execution
104
+ */ async finishWithError(error) {
105
+ // Finish sets the recording to undefined if we are at the topmost circuit,
106
+ // so we save the current file path before that
107
+ const filePath = this.recording.filePath;
108
+ const result = await super.finishWithError(error);
109
+ try {
110
+ await fs.appendFile(filePath, ' ],\n');
111
+ await fs.appendFile(filePath, ` "error": ${JSON.stringify(error)}\n`);
112
+ await fs.appendFile(filePath, '}\n');
113
+ } catch (err) {
114
+ this.logger.error('Failed to finalize recording file with error', {
115
+ error: err
116
+ });
117
+ }
118
+ return result;
119
+ }
120
+ }
121
+ /**
122
+ * Generates a file path for storing circuit recordings. The format of the filename is:
123
+ * `circuit_name_circuit_function_name_YYYY-MM-DD_N.json` where N is a counter to ensure unique filenames.
124
+ * @param recordDir - Base directory for recordings
125
+ * @param circuitName - Name of the circuit
126
+ * @param functionName - Name of the circuit function
127
+ * @param counter - Counter to ensure unique filenames. This is expected to be incremented in a loop until there is no
128
+ * existing file with the same name.
129
+ * @returns A file path for the recording.
130
+ */ function getFilePath(recordDir, circuitName, functionName, counter) {
131
+ const date = new Date();
132
+ const formattedDate = date.toISOString().split('T')[0];
133
+ const filename = `${circuitName}_${functionName}_${formattedDate}_${counter}.json`;
134
+ return path.join(recordDir, filename);
135
+ }
@@ -0,0 +1,5 @@
1
+ import { CircuitRecorder } from './circuit_recorder.js';
2
+ export declare class MemoryCircuitRecorder extends CircuitRecorder {
3
+ constructor();
4
+ }
5
+ //# sourceMappingURL=memory_circuit_recorder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory_circuit_recorder.d.ts","sourceRoot":"","sources":["../../../src/private/circuit_recording/memory_circuit_recorder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAMxD,qBAAa,qBAAsB,SAAQ,eAAe;;CAIzD"}
@@ -0,0 +1,9 @@
1
+ import { CircuitRecorder } from './circuit_recorder.js';
2
+ /*
3
+ * In memory circuit recorder uses the default implementation. This is kept
4
+ * while we decide the fate of the FileCircuitRecorder
5
+ */ export class MemoryCircuitRecorder extends CircuitRecorder {
6
+ constructor(){
7
+ super();
8
+ }
9
+ }
@@ -1,19 +1,21 @@
1
1
  import type { ForeignCallHandler } from '@aztec/noir-protocol-circuits-types/types';
2
2
  import type { FunctionArtifactWithContractName } from '@aztec/stdlib/abi';
3
3
  import type { NoirCompiledCircuitWithName } from '@aztec/stdlib/noir';
4
- import type { ACIRCallback, ACIRExecutionResult } from '../../acvm/acvm.js';
5
- import type { ACVMWitness } from '../../acvm/acvm_types.js';
4
+ import type { ACIRCallback, ACIRExecutionResult } from '../acvm/acvm.js';
5
+ import type { ACVMWitness } from '../acvm/acvm_types.js';
6
6
  import type { ACVMSuccess } from '../acvm_native.js';
7
- import type { SimulationProvider } from '../simulation_provider.js';
7
+ import type { CircuitSimulator } from '../circuit_simulator.js';
8
+ import type { CircuitRecorder } from './circuit_recorder.js';
8
9
  /**
9
- * Takes a simulation provider and wraps it in a circuit recorder. See CircuitRecorder for more details on how circuit
10
+ * Takes a circuit simulator and wraps it in a circuit recorder. See CircuitRecorder for more details on how circuit
10
11
  * recording works.
11
12
  */
12
- export declare class SimulationProviderRecorderWrapper implements SimulationProvider {
13
+ export declare class SimulatorRecorderWrapper implements CircuitSimulator {
13
14
  #private;
14
15
  private simulator;
15
- constructor(simulator: SimulationProvider);
16
+ private recorder;
17
+ constructor(simulator: CircuitSimulator, recorder: CircuitRecorder);
16
18
  executeProtocolCircuit(input: ACVMWitness, artifact: NoirCompiledCircuitWithName, callback: ForeignCallHandler | undefined): Promise<ACVMSuccess>;
17
19
  executeUserCircuit(input: ACVMWitness, artifact: FunctionArtifactWithContractName, callback: ACIRCallback): Promise<ACIRExecutionResult>;
18
20
  }
19
- //# sourceMappingURL=simulation_provider_recorder_wrapper.d.ts.map
21
+ //# sourceMappingURL=simulator_recorder_wrapper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"simulator_recorder_wrapper.d.ts","sourceRoot":"","sources":["../../../src/private/circuit_recording/simulator_recorder_wrapper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2CAA2C,CAAC;AACpF,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AAEtE,OAAO,KAAK,EAAE,YAAY,EAAqB,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAC5F,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D;;;GAGG;AACH,qBAAa,wBAAyB,YAAW,gBAAgB;;IAE7D,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,QAAQ;gBADR,SAAS,EAAE,gBAAgB,EAC3B,QAAQ,EAAE,eAAe;IAGnC,sBAAsB,CACpB,KAAK,EAAE,WAAW,EAClB,QAAQ,EAAE,2BAA2B,EACrC,QAAQ,EAAE,kBAAkB,GAAG,SAAS,GACvC,OAAO,CAAC,WAAW,CAAC;IAavB,kBAAkB,CAChB,KAAK,EAAE,WAAW,EAClB,QAAQ,EAAE,gCAAgC,EAC1C,QAAQ,EAAE,YAAY,GACrB,OAAO,CAAC,mBAAmB,CAAC;CAiDhC"}
@@ -1,11 +1,12 @@
1
- import { CircuitRecorder } from './circuit_recorder.js';
2
1
  /**
3
- * Takes a simulation provider and wraps it in a circuit recorder. See CircuitRecorder for more details on how circuit
2
+ * Takes a circuit simulator and wraps it in a circuit recorder. See CircuitRecorder for more details on how circuit
4
3
  * recording works.
5
- */ export class SimulationProviderRecorderWrapper {
4
+ */ export class SimulatorRecorderWrapper {
6
5
  simulator;
7
- constructor(simulator){
6
+ recorder;
7
+ constructor(simulator, recorder){
8
8
  this.simulator = simulator;
9
+ this.recorder = recorder;
9
10
  }
10
11
  executeProtocolCircuit(input, artifact, callback) {
11
12
  const bytecode = Buffer.from(artifact.bytecode, 'base64');
@@ -15,25 +16,29 @@ import { CircuitRecorder } from './circuit_recorder.js';
15
16
  return this.#simulate((wrappedCallback)=>this.simulator.executeUserCircuit(input, artifact, wrappedCallback), input, artifact.bytecode, artifact.contractName, artifact.name, callback);
16
17
  }
17
18
  async #simulate(simulateFn, input, bytecode, contractName, functionName, callback) {
18
- const recordDir = process.env.CIRCUIT_RECORD_DIR;
19
- if (!recordDir) {
20
- // Recording is not enabled so we just execute the circuit
21
- return simulateFn(callback);
22
- }
23
19
  // Start recording circuit execution
24
- const recorder = await CircuitRecorder.start(recordDir, input, bytecode, contractName, functionName);
20
+ await this.recorder.start(input, bytecode, contractName, functionName);
25
21
  // If callback was provided, we wrap it in a circuit recorder callback wrapper
26
- const wrappedCallback = recorder.wrapCallback(callback);
22
+ const wrappedCallback = this.recorder.wrapCallback(callback);
27
23
  let result;
28
24
  try {
29
25
  result = await simulateFn(wrappedCallback);
30
26
  } catch (error) {
31
27
  // If an error occurs, we finalize the recording file with the error
32
- await recorder.finishWithError(error);
28
+ await this.recorder.finishWithError(error);
33
29
  throw error;
34
30
  }
35
31
  // Witness generation is complete so we finish the circuit recorder
36
- await recorder.finish();
32
+ const recording = await this.recorder.finish();
33
+ result.oracles = recording.oracleCalls?.reduce((acc, { time, name })=>{
34
+ if (!acc[name]) {
35
+ acc[name] = {
36
+ times: []
37
+ };
38
+ }
39
+ acc[name].times.push(time);
40
+ return acc;
41
+ }, {});
37
42
  return result;
38
43
  }
39
44
  }
@@ -1,13 +1,13 @@
1
1
  import type { ExecutionError, ForeignCallHandler } from '@aztec/noir-acvm_js';
2
2
  import type { FunctionArtifactWithContractName } from '@aztec/stdlib/abi';
3
3
  import type { NoirCompiledCircuit, NoirCompiledCircuitWithName } from '@aztec/stdlib/noir';
4
- import { type ACIRCallback, type ACIRExecutionResult } from '../acvm/acvm.js';
5
- import type { ACVMWitness } from '../acvm/acvm_types.js';
4
+ import { type ACIRCallback, type ACIRExecutionResult } from './acvm/acvm.js';
5
+ import type { ACVMWitness } from './acvm/acvm_types.js';
6
6
  import type { ACVMSuccess } from './acvm_native.js';
7
7
  /**
8
8
  * Low level simulation interface
9
9
  */
10
- export interface SimulationProvider {
10
+ export interface CircuitSimulator {
11
11
  /**
12
12
  * Execute a protocol circuit/generate a witness
13
13
  * @param input - The initial witness map defining all of the inputs to `circuit`.
@@ -32,4 +32,4 @@ export type DecodedError = ExecutionError & {
32
32
  noirCallStack?: string[];
33
33
  };
34
34
  export declare function enrichNoirError(artifact: NoirCompiledCircuit, originalError: ExecutionError): DecodedError;
35
- //# sourceMappingURL=simulation_provider.d.ts.map
35
+ //# sourceMappingURL=circuit_simulator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"circuit_simulator.d.ts","sourceRoot":"","sources":["../../src/private/circuit_simulator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAG9E,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,KAAK,EAAE,mBAAmB,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AAE3F,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,mBAAmB,EAAoB,MAAM,gBAAgB,CAAC;AAC/F,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;;;;;OAOG;IACH,sBAAsB,CACpB,KAAK,EAAE,WAAW,EAClB,QAAQ,EAAE,2BAA2B,EACrC,QAAQ,EAAE,kBAAkB,GAAG,SAAS,GACvC,OAAO,CAAC,WAAW,CAAC,CAAC;IAExB;;;;;;;OAOG;IACH,kBAAkB,CAChB,KAAK,EAAE,WAAW,EAClB,QAAQ,EAAE,gCAAgC,EAC1C,QAAQ,EAAE,YAAY,GACrB,OAAO,CAAC,mBAAmB,CAAC,CAAC;CACjC;AAED,MAAM,MAAM,YAAY,GAAG,cAAc,GAAG;IAAE,uBAAuB,CAAC,EAAE,GAAG,CAAC;IAAC,aAAa,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC;AAIxG,wBAAgB,eAAe,CAAC,QAAQ,EAAE,mBAAmB,EAAE,aAAa,EAAE,cAAc,GAAG,YAAY,CA0C1G"}
@@ -1,6 +1,6 @@
1
1
  import { abiDecodeError } from '@aztec/noir-noirc_abi';
2
2
  import { parseDebugSymbols } from '@aztec/stdlib/abi';
3
- import { extractCallStack } from '../acvm/acvm.js';
3
+ import { extractCallStack } from './acvm/acvm.js';
4
4
  // Payload parsing taken from noir/noir-repo/tooling/noir_js/src/witness_generation.ts.
5
5
  // TODO: import this in isolation without having to import noir_js in its entirety.
6
6
  export function enrichNoirError(artifact, originalError) {
@@ -0,0 +1,12 @@
1
+ import { type Logger } from '@aztec/foundation/log';
2
+ import type { CircuitSimulator } from './circuit_simulator.js';
3
+ export type SimulatorConfig = {
4
+ acvmBinaryPath?: string;
5
+ acvmWorkingDirectory?: string;
6
+ };
7
+ export declare function getSimulatorConfigFromEnv(): {
8
+ acvmWorkingDirectory: string | undefined;
9
+ acvmBinaryPath: string | undefined;
10
+ };
11
+ export declare function createSimulator(config: SimulatorConfig, logger?: Logger): Promise<CircuitSimulator>;
12
+ //# sourceMappingURL=factory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../src/private/factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAMlE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE/D,MAAM,MAAM,eAAe,GAAG;IAC5B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B,CAAC;AAEF,wBAAgB,yBAAyB;;;EAMxC;AAED,wBAAsB,eAAe,CACnC,MAAM,EAAE,eAAe,EACvB,MAAM,GAAE,MAAkC,GACzC,OAAO,CAAC,gBAAgB,CAAC,CAa3B"}
@@ -2,14 +2,14 @@ import { createLogger } from '@aztec/foundation/log';
2
2
  import { promises as fs } from 'fs';
3
3
  import { NativeACVMSimulator } from './acvm_native.js';
4
4
  import { WASMSimulator } from './acvm_wasm.js';
5
- export function getSimulationProviderConfigFromEnv() {
5
+ export function getSimulatorConfigFromEnv() {
6
6
  const { ACVM_BINARY_PATH, ACVM_WORKING_DIRECTORY } = process.env;
7
7
  return {
8
8
  acvmWorkingDirectory: ACVM_WORKING_DIRECTORY ? ACVM_WORKING_DIRECTORY : undefined,
9
9
  acvmBinaryPath: ACVM_BINARY_PATH ? ACVM_BINARY_PATH : undefined
10
10
  };
11
11
  }
12
- export async function createSimulationProvider(config, logger = createLogger('simulator')) {
12
+ export async function createSimulator(config, logger = createLogger('simulator')) {
13
13
  if (config.acvmBinaryPath && config.acvmWorkingDirectory) {
14
14
  try {
15
15
  await fs.access(config.acvmBinaryPath, fs.constants.R_OK);
@@ -31,5 +31,6 @@ export declare abstract class BaseAvmSimulationTester {
31
31
  registerFeeJuiceContract(): Promise<ContractInstanceWithAddress>;
32
32
  addContractInstance(contractInstance: ContractInstanceWithAddress, skipNullifierInsertion?: boolean): Promise<void>;
33
33
  private insertContractAddressNullifier;
34
+ insertNullifier(contractThatEmitted: AztecAddress, nullifier: Fr): Promise<void>;
34
35
  }
35
36
  //# sourceMappingURL=base_avm_simulation_tester.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"base_avm_simulation_tester.d.ts","sourceRoot":"","sources":["../../../../src/public/avm/fixtures/base_avm_simulation_tester.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAI9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE1D,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAE1E,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AAGjF,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,+CAA+C,CAAC;AAG9F;;;;;;;;;;GAUG;AACH,8BAAsB,uBAAuB;IAIlC,kBAAkB,EAAE,wBAAwB;IAC5C,WAAW,EAAE,yBAAyB;IAC7C,OAAO,CAAC,sBAAsB;IALzB,MAAM,yCAAyC;gBAG7C,kBAAkB,EAAE,wBAAwB,EAC5C,WAAW,EAAE,yBAAyB,EACrC,sBAAsB,KAAmB;IAG7C,kBAAkB,CAAC,QAAQ,EAAE,YAAY,EAAE,OAAO,KAA8B;IAMhF,gBAAgB,CAAC,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE;IAOjE;;;OAGG;IACG,yBAAyB,CAC7B,eAAe,EAAE,GAAG,EAAE,EACtB,QAAQ,EAAE,YAAY,EACtB,gBAAgB,EAAE,gBAAgB,EAClC,sBAAsB,UAAQ,EAC9B,IAAI,SAAI,EACR,uBAAuB,CAAC,EAAE,EAAE,GAC3B,OAAO,CAAC,2BAA2B,CAAC;IAiBjC,wBAAwB,IAAI,OAAO,CAAC,2BAA2B,CAAC;IAWhE,mBAAmB,CAAC,gBAAgB,EAAE,2BAA2B,EAAE,sBAAsB,UAAQ;YAOzF,8BAA8B;CAO7C"}
1
+ {"version":3,"file":"base_avm_simulation_tester.d.ts","sourceRoot":"","sources":["../../../../src/public/avm/fixtures/base_avm_simulation_tester.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAI9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE1D,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAE1E,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AAGjF,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,+CAA+C,CAAC;AAG9F;;;;;;;;;;GAUG;AACH,8BAAsB,uBAAuB;IAIlC,kBAAkB,EAAE,wBAAwB;IAC5C,WAAW,EAAE,yBAAyB;IAC7C,OAAO,CAAC,sBAAsB;IALzB,MAAM,yCAAyC;gBAG7C,kBAAkB,EAAE,wBAAwB,EAC5C,WAAW,EAAE,yBAAyB,EACrC,sBAAsB,KAAmB;IAG7C,kBAAkB,CAAC,QAAQ,EAAE,YAAY,EAAE,OAAO,KAA8B;IAMhF,gBAAgB,CAAC,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE;IAOjE;;;OAGG;IACG,yBAAyB,CAC7B,eAAe,EAAE,GAAG,EAAE,EACtB,QAAQ,EAAE,YAAY,EACtB,gBAAgB,EAAE,gBAAgB,EAClC,sBAAsB,UAAQ,EAC9B,IAAI,SAAI,EACR,uBAAuB,CAAC,EAAE,EAAE,GAC3B,OAAO,CAAC,2BAA2B,CAAC;IAiBjC,wBAAwB,IAAI,OAAO,CAAC,2BAA2B,CAAC;IAWhE,mBAAmB,CAAC,gBAAgB,EAAE,2BAA2B,EAAE,sBAAsB,UAAQ;YAOzF,8BAA8B;IAQtC,eAAe,CAAC,mBAAmB,EAAE,YAAY,EAAE,SAAS,EAAE,EAAE;CAIvE"}
@@ -75,4 +75,10 @@ import { createContractClassAndInstance } from './index.js';
75
75
  contractAddressNullifier.toBuffer()
76
76
  ]);
77
77
  }
78
+ async insertNullifier(contractThatEmitted, nullifier) {
79
+ const siloedNullifier = await siloNullifier(contractThatEmitted, nullifier);
80
+ await this.merkleTrees.sequentialInsert(MerkleTreeId.NULLIFIER_TREE, [
81
+ siloedNullifier.toBuffer()
82
+ ]);
83
+ }
78
84
  }
@@ -1 +1 @@
1
- {"version":3,"file":"amm_test.d.ts","sourceRoot":"","sources":["../../../../src/public/public_tx_simulator/apps_tests/amm_test.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAKpD,OAAO,EAAE,wBAAwB,EAAE,MAAM,+CAA+C,CAAC;AAIzF;;;;GAIG;AACH,wBAAsB,OAAO,CAAC,MAAM,EAAE,wBAAwB,EAAE,MAAM,EAAE,MAAM,iBAoG7E"}
1
+ {"version":3,"file":"amm_test.d.ts","sourceRoot":"","sources":["../../../../src/public/public_tx_simulator/apps_tests/amm_test.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAKpD,OAAO,EAAE,wBAAwB,EAAE,MAAM,+CAA+C,CAAC;AAIzF;;;;GAIG;AACH,wBAAsB,OAAO,CAAC,MAAM,EAAE,wBAAwB,EAAE,MAAM,EAAE,MAAM,iBAoG7E"}
@@ -1,3 +1,5 @@
1
+ import { GeneratorIndex } from '@aztec/constants';
2
+ import { poseidon2HashWithSeparator } from '@aztec/foundation/crypto';
1
3
  import { Fr } from '@aztec/foundation/fields';
2
4
  import { AMMContractArtifact } from '@aztec/noir-contracts.js/AMM';
3
5
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
@@ -69,6 +71,14 @@ async function addLiquidity(tester, sender, amm, token0, token1, liquidityToken,
69
71
  const liquidityPartialNote = {
70
72
  commitment: new Fr(99)
71
73
  };
74
+ const refundToken0PartialNoteValidityCommitment = await computePartialNoteValidityCommitment(refundToken0PartialNote, amm.address);
75
+ const refundToken1PartialNoteValidityCommitment = await computePartialNoteValidityCommitment(refundToken1PartialNote, amm.address);
76
+ const liquidityPartialNoteValidityCommitment = await computePartialNoteValidityCommitment(liquidityPartialNote, amm.address);
77
+ // We need to inject the validity commitments into the nullifier tree as that would be performed by the private token
78
+ // functions that are not invoked in this test.
79
+ await tester.insertNullifier(token0.address, refundToken0PartialNoteValidityCommitment);
80
+ await tester.insertNullifier(token1.address, refundToken1PartialNoteValidityCommitment);
81
+ await tester.insertNullifier(liquidityToken.address, liquidityPartialNoteValidityCommitment);
72
82
  return await tester.simulateTxWithLabel(/*txLabel=*/ 'AMM/add_liquidity', /*sender=*/ sender, /*setupCalls=*/ [], /*appCalls=*/ [
73
83
  // token0.transfer_to_public enqueues a call to _increase_public_balance
74
84
  {
@@ -80,15 +90,6 @@ async function addLiquidity(tester, sender, amm, token0, token1, liquidityToken,
80
90
  ],
81
91
  address: token0.address
82
92
  },
83
- // token0.prepare_private_balance_increase enqueues a call to _store_balances_set_partial_note
84
- {
85
- sender: token0.address,
86
- fnName: '_store_balances_set_partial_note',
87
- args: [
88
- refundToken0PartialNote
89
- ],
90
- address: token0.address
91
- },
92
93
  // token1.transfer_to_public enqueues a call to _increase_public_balance
93
94
  {
94
95
  sender: token1.address,
@@ -99,24 +100,6 @@ async function addLiquidity(tester, sender, amm, token0, token1, liquidityToken,
99
100
  ],
100
101
  address: token1.address
101
102
  },
102
- // token1.prepare_private_balance_increase enqueues a call to _store_balances_set_partial_note
103
- {
104
- sender: token1.address,
105
- fnName: '_store_balances_set_partial_note',
106
- args: [
107
- refundToken1PartialNote
108
- ],
109
- address: token1.address
110
- },
111
- // liquidityToken.prepare_private_balance_increase enqueues a call to _store_balances_set_partial_note
112
- {
113
- sender: liquidityToken.address,
114
- fnName: '_store_balances_set_partial_note',
115
- args: [
116
- liquidityPartialNote
117
- ],
118
- address: liquidityToken.address
119
- },
120
103
  // amm.add_liquidity enqueues a call to _add_liquidity
121
104
  {
122
105
  sender: amm.address,
@@ -142,8 +125,12 @@ async function addLiquidity(tester, sender, amm, token0, token1, liquidityToken,
142
125
  }
143
126
  async function swapExactTokensForTokens(tester, sender, amm, tokenIn, tokenOut, amountIn, amountOutMin, _nonce) {
144
127
  const tokenOutPartialNote = {
145
- commitment: new Fr(66)
128
+ commitment: new Fr(166)
146
129
  };
130
+ const tokenOutPartialNoteValidityCommitment = await computePartialNoteValidityCommitment(tokenOutPartialNote, amm.address);
131
+ // We need to inject the validity commitment into the nullifier tree as that would be performed by the private token
132
+ // function that is not invoked in this test.
133
+ await tester.insertNullifier(tokenOut.address, tokenOutPartialNoteValidityCommitment);
147
134
  return await tester.simulateTxWithLabel(/*txLabel=*/ 'AMM/swap_exact_tokens_for_tokens', /*sender=*/ sender, /*setupCalls=*/ [], /*appCalls=*/ [
148
135
  // tokenIn.transfer_to_public enqueues a call to _increase_public_balance
149
136
  {
@@ -155,15 +142,6 @@ async function swapExactTokensForTokens(tester, sender, amm, tokenIn, tokenOut,
155
142
  ],
156
143
  address: tokenIn.address
157
144
  },
158
- // tokenOut.prepare_private_balance_increase enqueues a call to _store_balances_set_partial_note
159
- {
160
- sender: tokenOut.address,
161
- fnName: '_store_balances_set_partial_note',
162
- args: [
163
- tokenOutPartialNote
164
- ],
165
- address: tokenOut.address
166
- },
167
145
  {
168
146
  sender: amm.address,
169
147
  fnName: '_swap_exact_tokens_for_tokens',
@@ -185,6 +163,12 @@ async function removeLiquidity(tester, sender, amm, token0, token1, liquidityTok
185
163
  const token1PartialNote = {
186
164
  commitment: new Fr(222)
187
165
  };
166
+ const token0PartialNoteValidityCommitment = await computePartialNoteValidityCommitment(token0PartialNote, amm.address);
167
+ const token1PartialNoteValidityCommitment = await computePartialNoteValidityCommitment(token1PartialNote, amm.address);
168
+ // We need to inject the validity commitments into the nullifier tree as that would be performed by the private token
169
+ // functions that are not invoked in this test.
170
+ await tester.insertNullifier(token0.address, token0PartialNoteValidityCommitment);
171
+ await tester.insertNullifier(token1.address, token1PartialNoteValidityCommitment);
188
172
  return await tester.simulateTxWithLabel(/*txLabel=*/ 'AMM/remove_liquidity', /*sender=*/ sender, /*setupCalls=*/ [], /*appCalls=*/ [
189
173
  // liquidityToken.transfer_to_public enqueues a call to _increase_public_balance
190
174
  {
@@ -196,24 +180,6 @@ async function removeLiquidity(tester, sender, amm, token0, token1, liquidityTok
196
180
  ],
197
181
  address: liquidityToken.address
198
182
  },
199
- // token0.prepare_private_balance_increase enqueues a call to _store_balances_set_partial_note
200
- {
201
- sender: token0.address,
202
- fnName: '_store_balances_set_partial_note',
203
- args: [
204
- token0PartialNote
205
- ],
206
- address: token0.address
207
- },
208
- // token1.prepare_private_balance_increase enqueues a call to _store_balances_set_partial_note
209
- {
210
- sender: token1.address,
211
- fnName: '_store_balances_set_partial_note',
212
- args: [
213
- token1PartialNote
214
- ],
215
- address: token1.address
216
- },
217
183
  // amm.remove_liquidity enqueues a call to _remove_liquidity
218
184
  {
219
185
  sender: amm.address,
@@ -235,3 +201,9 @@ async function removeLiquidity(tester, sender, amm, token0, token1, liquidityTok
235
201
  }
236
202
  ]);
237
203
  }
204
+ async function computePartialNoteValidityCommitment(partialNote, completer) {
205
+ return await poseidon2HashWithSeparator([
206
+ partialNote.commitment,
207
+ completer
208
+ ], GeneratorIndex.PARTIAL_NOTE_VALIDITY_COMMITMENT);
209
+ }
package/dest/server.d.ts CHANGED
@@ -1,6 +1,9 @@
1
1
  export * from './public/index.js';
2
- export { WASMSimulatorWithBlobs } from './private/providers/acvm_wasm_with_blobs.js';
3
- export { NativeACVMSimulator } from './private/providers/acvm_native.js';
4
- export { type SimulationProvider } from './private/providers/simulation_provider.js';
2
+ export * from './private/acvm/index.js';
3
+ export { WASMSimulatorWithBlobs } from './private/acvm_wasm_with_blobs.js';
4
+ export { NativeACVMSimulator } from './private/acvm_native.js';
5
+ export { SimulatorRecorderWrapper } from './private/circuit_recording/simulator_recorder_wrapper.js';
6
+ export { MemoryCircuitRecorder } from './private/circuit_recording/memory_circuit_recorder.js';
7
+ export { type CircuitSimulator, type DecodedError } from './private/circuit_simulator.js';
5
8
  export * from './common/index.js';
6
9
  //# sourceMappingURL=server.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,OAAO,EAAE,sBAAsB,EAAE,MAAM,6CAA6C,CAAC;AACrF,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,4CAA4C,CAAC;AACrF,cAAc,mBAAmB,CAAC"}
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAC3E,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,wBAAwB,EAAE,MAAM,2DAA2D,CAAC;AACrG,OAAO,EAAE,qBAAqB,EAAE,MAAM,wDAAwD,CAAC;AAC/F,OAAO,EAAE,KAAK,gBAAgB,EAAE,KAAK,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC1F,cAAc,mBAAmB,CAAC"}
package/dest/server.js CHANGED
@@ -1,4 +1,7 @@
1
1
  export * from './public/index.js';
2
- export { WASMSimulatorWithBlobs } from './private/providers/acvm_wasm_with_blobs.js';
3
- export { NativeACVMSimulator } from './private/providers/acvm_native.js';
2
+ export * from './private/acvm/index.js';
3
+ export { WASMSimulatorWithBlobs } from './private/acvm_wasm_with_blobs.js';
4
+ export { NativeACVMSimulator } from './private/acvm_native.js';
5
+ export { SimulatorRecorderWrapper } from './private/circuit_recording/simulator_recorder_wrapper.js';
6
+ export { MemoryCircuitRecorder } from './private/circuit_recording/memory_circuit_recorder.js';
4
7
  export * from './common/index.js';
package/dest/testing.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export { SimulationProviderRecorderWrapper } from './private/providers/circuit_recording/simulation_provider_recorder_wrapper.js';
1
+ export { FileCircuitRecorder } from './private/circuit_recording/file_circuit_recorder.js';
2
2
  //# sourceMappingURL=testing.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iCAAiC,EAAE,MAAM,+EAA+E,CAAC"}
1
+ {"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,sDAAsD,CAAC"}
package/dest/testing.js CHANGED
@@ -1 +1 @@
1
- export { SimulationProviderRecorderWrapper } from './private/providers/circuit_recording/simulation_provider_recorder_wrapper.js';
1
+ export { FileCircuitRecorder } from './private/circuit_recording/file_circuit_recorder.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/simulator",
3
- "version": "0.87.5",
3
+ "version": "0.87.6",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  "./server": "./dest/server.js",
@@ -58,25 +58,25 @@
58
58
  ]
59
59
  },
60
60
  "dependencies": {
61
- "@aztec/constants": "0.87.5",
62
- "@aztec/foundation": "0.87.5",
63
- "@aztec/noir-acvm_js": "0.87.5",
64
- "@aztec/noir-noirc_abi": "0.87.5",
65
- "@aztec/noir-protocol-circuits-types": "0.87.5",
66
- "@aztec/noir-types": "0.87.5",
67
- "@aztec/protocol-contracts": "0.87.5",
68
- "@aztec/stdlib": "0.87.5",
69
- "@aztec/telemetry-client": "0.87.5",
70
- "@aztec/world-state": "0.87.5",
61
+ "@aztec/constants": "0.87.6",
62
+ "@aztec/foundation": "0.87.6",
63
+ "@aztec/noir-acvm_js": "0.87.6",
64
+ "@aztec/noir-noirc_abi": "0.87.6",
65
+ "@aztec/noir-protocol-circuits-types": "0.87.6",
66
+ "@aztec/noir-types": "0.87.6",
67
+ "@aztec/protocol-contracts": "0.87.6",
68
+ "@aztec/stdlib": "0.87.6",
69
+ "@aztec/telemetry-client": "0.87.6",
70
+ "@aztec/world-state": "0.87.6",
71
71
  "lodash.clonedeep": "^4.5.0",
72
72
  "lodash.merge": "^4.6.2",
73
73
  "tslib": "^2.4.0"
74
74
  },
75
75
  "devDependencies": {
76
- "@aztec/kv-store": "0.87.5",
77
- "@aztec/merkle-tree": "0.87.5",
78
- "@aztec/noir-contracts.js": "0.87.5",
79
- "@aztec/noir-test-contracts.js": "0.87.5",
76
+ "@aztec/kv-store": "0.87.6",
77
+ "@aztec/merkle-tree": "0.87.6",
78
+ "@aztec/noir-contracts.js": "0.87.6",
79
+ "@aztec/noir-test-contracts.js": "0.87.6",
80
80
  "@jest/globals": "^29.5.0",
81
81
  "@types/jest": "^29.5.0",
82
82
  "@types/lodash.clonedeep": "^4.5.7",
package/src/client.ts CHANGED
@@ -1,4 +1,6 @@
1
- export * from './private/index.js';
2
- export { WASMSimulator } from './private/providers/acvm_wasm.js';
3
- export { type SimulationProvider, type DecodedError } from './private/providers/simulation_provider.js';
1
+ export * from './private/acvm/index.js';
2
+ export { WASMSimulator } from './private/acvm_wasm.js';
3
+ export { SimulatorRecorderWrapper } from './private/circuit_recording/simulator_recorder_wrapper.js';
4
+ export { MemoryCircuitRecorder } from './private/circuit_recording/memory_circuit_recorder.js';
5
+ export { type CircuitSimulator, type DecodedError } from './private/circuit_simulator.js';
4
6
  export * from './common/index.js';
@@ -10,12 +10,13 @@ import type { NoirCallStack } from '@aztec/stdlib/errors';
10
10
 
11
11
  import { resolveOpcodeLocations, traverseCauseChain } from '../../common/errors.js';
12
12
  import type { ACVMWitness } from './acvm_types.js';
13
- import type { ORACLE_NAMES } from './oracle/index.js';
14
13
 
15
14
  /**
16
15
  * The callback interface for the ACIR.
17
16
  */
18
- export type ACIRCallback = Record<ORACLE_NAMES, (...args: ForeignCallInput[]) => Promise<ForeignCallOutput[]>>;
17
+ export type ACIRCallback = Record<string, (...args: ForeignCallInput[]) => Promise<ForeignCallOutput[]>>;
18
+
19
+ export type ACIRCallbackStats = { times: number[] };
19
20
 
20
21
  /**
21
22
  * The result of executing an ACIR.
@@ -28,6 +29,7 @@ export interface ACIRExecutionResult {
28
29
  */
29
30
  partialWitness: ACVMWitness;
30
31
  returnWitness: ACVMWitness;
32
+ oracles?: Record<string, ACIRCallbackStats>;
31
33
  }
32
34
 
33
35
  /**
@@ -51,7 +53,7 @@ export async function acvm(
51
53
  (name: string, args: ForeignCallInput[]) => {
52
54
  try {
53
55
  logger.debug(`Oracle callback ${name}`);
54
- const oracleFunction = callback[name as ORACLE_NAMES];
56
+ const oracleFunction = callback[name];
55
57
  if (!oracleFunction) {
56
58
  throw new Error(`Oracle callback ${name} not found`);
57
59
  }