@aztec/simulator 0.87.5 → 0.87.7
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.
- package/dest/client.d.ts +5 -3
- package/dest/client.d.ts.map +1 -1
- package/dest/client.js +4 -2
- package/dest/private/acvm/acvm.d.ts +5 -2
- package/dest/private/acvm/acvm.d.ts.map +1 -1
- package/dest/private/acvm/index.d.ts +0 -1
- package/dest/private/acvm/index.d.ts.map +1 -1
- package/dest/private/acvm/index.js +0 -1
- package/dest/private/{providers/acvm_native.d.ts → acvm_native.d.ts} +4 -4
- package/dest/private/acvm_native.d.ts.map +1 -0
- package/dest/private/{providers/acvm_wasm.d.ts → acvm_wasm.d.ts} +4 -4
- package/dest/private/acvm_wasm.d.ts.map +1 -0
- package/dest/private/{providers/acvm_wasm.js → acvm_wasm.js} +2 -2
- package/dest/private/{providers/acvm_wasm_with_blobs.d.ts → acvm_wasm_with_blobs.d.ts} +5 -5
- package/dest/private/acvm_wasm_with_blobs.d.ts.map +1 -0
- package/dest/private/{providers/acvm_wasm_with_blobs.js → acvm_wasm_with_blobs.js} +2 -2
- package/dest/private/{providers/circuit_recording → circuit_recording}/circuit_recorder.d.ts +41 -21
- package/dest/private/circuit_recording/circuit_recorder.d.ts.map +1 -0
- package/dest/private/circuit_recording/circuit_recorder.js +209 -0
- package/dest/private/circuit_recording/file_circuit_recorder.d.ts +31 -0
- package/dest/private/circuit_recording/file_circuit_recorder.d.ts.map +1 -0
- package/dest/private/circuit_recording/file_circuit_recorder.js +135 -0
- package/dest/private/circuit_recording/memory_circuit_recorder.d.ts +5 -0
- package/dest/private/circuit_recording/memory_circuit_recorder.d.ts.map +1 -0
- package/dest/private/circuit_recording/memory_circuit_recorder.js +9 -0
- package/dest/private/{providers/circuit_recording/simulation_provider_recorder_wrapper.d.ts → circuit_recording/simulator_recorder_wrapper.d.ts} +9 -7
- package/dest/private/circuit_recording/simulator_recorder_wrapper.d.ts.map +1 -0
- package/dest/private/{providers/circuit_recording/simulation_provider_recorder_wrapper.js → circuit_recording/simulator_recorder_wrapper.js} +18 -13
- package/dest/private/{providers/simulation_provider.d.ts → circuit_simulator.d.ts} +4 -4
- package/dest/private/circuit_simulator.d.ts.map +1 -0
- package/dest/private/{providers/simulation_provider.js → circuit_simulator.js} +1 -1
- package/dest/private/factory.d.ts +12 -0
- package/dest/private/factory.d.ts.map +1 -0
- package/dest/private/{providers/factory.js → factory.js} +2 -2
- package/dest/public/avm/fixtures/base_avm_simulation_tester.d.ts +1 -0
- package/dest/public/avm/fixtures/base_avm_simulation_tester.d.ts.map +1 -1
- package/dest/public/avm/fixtures/base_avm_simulation_tester.js +6 -0
- package/dest/public/public_tx_simulator/apps_tests/amm_test.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/apps_tests/amm_test.js +27 -55
- package/dest/server.d.ts +6 -3
- package/dest/server.d.ts.map +1 -1
- package/dest/server.js +5 -2
- package/dest/testing.d.ts +1 -1
- package/dest/testing.d.ts.map +1 -1
- package/dest/testing.js +1 -1
- package/package.json +15 -15
- package/src/client.ts +5 -3
- package/src/private/acvm/acvm.ts +5 -3
- package/src/private/acvm/index.ts +0 -1
- package/src/private/{providers/acvm_native.ts → acvm_native.ts} +4 -4
- package/src/private/{providers/acvm_wasm.ts → acvm_wasm.ts} +4 -4
- package/src/private/{providers/acvm_wasm_with_blobs.ts → acvm_wasm_with_blobs.ts} +5 -5
- package/src/private/circuit_recording/circuit_recorder.ts +260 -0
- package/src/private/circuit_recording/file_circuit_recorder.ts +158 -0
- package/src/private/circuit_recording/memory_circuit_recorder.ts +11 -0
- package/src/private/{providers/circuit_recording/simulation_provider_recorder_wrapper.ts → circuit_recording/simulator_recorder_wrapper.ts} +26 -18
- package/src/private/{providers/simulation_provider.ts → circuit_simulator.ts} +3 -3
- package/src/private/{providers/factory.ts → factory.ts} +6 -6
- package/src/public/avm/fixtures/base_avm_simulation_tester.ts +5 -0
- package/src/public/public_tx_simulator/apps_tests/amm_test.ts +49 -44
- package/src/server.ts +6 -3
- package/src/testing.ts +1 -1
- package/dest/private/acvm/oracle/index.d.ts +0 -14
- package/dest/private/acvm/oracle/index.d.ts.map +0 -1
- package/dest/private/acvm/oracle/index.js +0 -2
- package/dest/private/acvm/oracle/oracle.d.ts +0 -52
- package/dest/private/acvm/oracle/oracle.d.ts.map +0 -1
- package/dest/private/acvm/oracle/oracle.js +0 -312
- package/dest/private/acvm/oracle/typed_oracle.d.ts +0 -83
- package/dest/private/acvm/oracle/typed_oracle.d.ts.map +0 -1
- package/dest/private/acvm/oracle/typed_oracle.js +0 -138
- package/dest/private/execution_data_provider.d.ts +0 -301
- package/dest/private/execution_data_provider.d.ts.map +0 -1
- package/dest/private/execution_data_provider.js +0 -14
- package/dest/private/execution_note_cache.d.ts +0 -93
- package/dest/private/execution_note_cache.d.ts.map +0 -1
- package/dest/private/execution_note_cache.js +0 -180
- package/dest/private/hashed_values_cache.d.ts +0 -28
- package/dest/private/hashed_values_cache.d.ts.map +0 -1
- package/dest/private/hashed_values_cache.js +0 -36
- package/dest/private/index.d.ts +0 -16
- package/dest/private/index.d.ts.map +0 -1
- package/dest/private/index.js +0 -15
- package/dest/private/message_load_oracle_inputs.d.ts +0 -19
- package/dest/private/message_load_oracle_inputs.d.ts.map +0 -1
- package/dest/private/message_load_oracle_inputs.js +0 -24
- package/dest/private/pick_notes.d.ts +0 -85
- package/dest/private/pick_notes.d.ts.map +0 -1
- package/dest/private/pick_notes.js +0 -51
- package/dest/private/private_execution.d.ts +0 -25
- package/dest/private/private_execution.d.ts.map +0 -1
- package/dest/private/private_execution.js +0 -95
- package/dest/private/private_execution_oracle.d.ts +0 -187
- package/dest/private/private_execution_oracle.d.ts.map +0 -1
- package/dest/private/private_execution_oracle.js +0 -318
- package/dest/private/providers/acvm_native.d.ts.map +0 -1
- package/dest/private/providers/acvm_wasm.d.ts.map +0 -1
- package/dest/private/providers/acvm_wasm_with_blobs.d.ts.map +0 -1
- package/dest/private/providers/circuit_recording/circuit_recorder.d.ts.map +0 -1
- package/dest/private/providers/circuit_recording/circuit_recorder.js +0 -246
- package/dest/private/providers/circuit_recording/simulation_provider_recorder_wrapper.d.ts.map +0 -1
- package/dest/private/providers/factory.d.ts +0 -12
- package/dest/private/providers/factory.d.ts.map +0 -1
- package/dest/private/providers/simulation_provider.d.ts.map +0 -1
- package/dest/private/simulator.d.ts +0 -36
- package/dest/private/simulator.d.ts.map +0 -1
- package/dest/private/simulator.js +0 -104
- package/dest/private/utility_execution_oracle.d.ts +0 -163
- package/dest/private/utility_execution_oracle.d.ts.map +0 -1
- package/dest/private/utility_execution_oracle.js +0 -257
- package/dest/test/utils.d.ts +0 -13
- package/dest/test/utils.d.ts.map +0 -1
- package/dest/test/utils.js +0 -22
- package/src/private/acvm/oracle/index.ts +0 -16
- package/src/private/acvm/oracle/oracle.ts +0 -523
- package/src/private/acvm/oracle/typed_oracle.ts +0 -273
- package/src/private/execution_data_provider.ts +0 -388
- package/src/private/execution_note_cache.ts +0 -217
- package/src/private/hashed_values_cache.ts +0 -47
- package/src/private/index.ts +0 -19
- package/src/private/message_load_oracle_inputs.ts +0 -23
- package/src/private/pick_notes.ts +0 -141
- package/src/private/private_execution.ts +0 -159
- package/src/private/private_execution_oracle.ts +0 -508
- package/src/private/providers/circuit_recording/circuit_recorder.ts +0 -283
- package/src/private/simulator.ts +0 -170
- package/src/private/utility_execution_oracle.ts +0 -384
- package/src/test/utils.ts +0 -36
- /package/dest/private/{providers/acvm_native.js → acvm_native.js} +0 -0
package/dest/client.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
export * from './private/index.js';
|
|
2
|
-
export { WASMSimulator } from './private/
|
|
3
|
-
export {
|
|
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';
|
|
5
7
|
//# sourceMappingURL=client.d.ts.map
|
package/dest/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,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/client.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
export * from './private/index.js';
|
|
2
|
-
export { WASMSimulator } from './private/
|
|
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';
|
|
3
5
|
export * from './common/index.js';
|
|
@@ -2,11 +2,13 @@ import { type ExecutionError, type ForeignCallInput, type ForeignCallOutput } fr
|
|
|
2
2
|
import type { FunctionDebugMetadata } from '@aztec/stdlib/abi';
|
|
3
3
|
import type { NoirCallStack } from '@aztec/stdlib/errors';
|
|
4
4
|
import type { ACVMWitness } from './acvm_types.js';
|
|
5
|
-
import type { ORACLE_NAMES } from './oracle/index.js';
|
|
6
5
|
/**
|
|
7
6
|
* The callback interface for the ACIR.
|
|
8
7
|
*/
|
|
9
|
-
export type ACIRCallback = Record<
|
|
8
|
+
export type ACIRCallback = Record<string, (...args: ForeignCallInput[]) => Promise<ForeignCallOutput[]>>;
|
|
9
|
+
export type ACIRCallbackStats = {
|
|
10
|
+
times: number[];
|
|
11
|
+
};
|
|
10
12
|
/**
|
|
11
13
|
* The result of executing an ACIR.
|
|
12
14
|
*/
|
|
@@ -18,6 +20,7 @@ export interface ACIRExecutionResult {
|
|
|
18
20
|
*/
|
|
19
21
|
partialWitness: ACVMWitness;
|
|
20
22
|
returnWitness: ACVMWitness;
|
|
23
|
+
oracles?: Record<string, ACIRCallbackStats>;
|
|
21
24
|
}
|
|
22
25
|
/**
|
|
23
26
|
* The function call that executes an ACIR.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"acvm.d.ts","sourceRoot":"","sources":["../../../src/private/acvm/acvm.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EAEvB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAG1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"acvm.d.ts","sourceRoot":"","sources":["../../../src/private/acvm/acvm.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EAEvB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAG1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEnD;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,IAAI,EAAE,gBAAgB,EAAE,KAAK,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAAC,CAAC;AAEzG,MAAM,MAAM,iBAAiB,GAAG;IAAE,KAAK,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC;AAEpD;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;;OAIG;IACH,cAAc,EAAE,WAAW,CAAC;IAC5B,aAAa,EAAE,WAAW,CAAC;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;CAC7C;AAED;;;;;;;GAOG;AACH,wBAAsB,IAAI,CACxB,IAAI,EAAE,MAAM,EACZ,cAAc,EAAE,WAAW,EAC3B,QAAQ,EAAE,YAAY,GACrB,OAAO,CAAC,mBAAmB,CAAC,CAwC9B;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,KAAK,GAAG,cAAc,EAC7B,KAAK,CAAC,EAAE,qBAAqB,GAC5B,aAAa,GAAG,SAAS,CAc3B"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export { extractCallStack, type ACIRCallback, type ACIRExecutionResult } from './acvm.js';
|
|
2
2
|
export * from './acvm_types.js';
|
|
3
3
|
export * from './deserialize.js';
|
|
4
|
-
export * from './oracle/index.js';
|
|
5
4
|
export * from './serialize.js';
|
|
6
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/private/acvm/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,KAAK,YAAY,EAAE,KAAK,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAC1F,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/private/acvm/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,KAAK,YAAY,EAAE,KAAK,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAC1F,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC"}
|
|
@@ -2,9 +2,9 @@ import type { WitnessMap } from '@aztec/noir-acvm_js';
|
|
|
2
2
|
import type { ForeignCallHandler } from '@aztec/noir-protocol-circuits-types/types';
|
|
3
3
|
import type { FunctionArtifactWithContractName } from '@aztec/stdlib/abi';
|
|
4
4
|
import type { NoirCompiledCircuitWithName } from '@aztec/stdlib/noir';
|
|
5
|
-
import type { ACIRCallback, ACIRExecutionResult } from '
|
|
6
|
-
import type { ACVMWitness } from '
|
|
7
|
-
import type {
|
|
5
|
+
import type { ACIRCallback, ACIRExecutionResult } from './acvm/acvm.js';
|
|
6
|
+
import type { ACVMWitness } from './acvm/acvm_types.js';
|
|
7
|
+
import type { CircuitSimulator } from './circuit_simulator.js';
|
|
8
8
|
export declare enum ACVM_RESULT {
|
|
9
9
|
SUCCESS = 0,
|
|
10
10
|
FAILURE = 1
|
|
@@ -29,7 +29,7 @@ export type ACVMResult = ACVMSuccess | ACVMFailure;
|
|
|
29
29
|
* @returns The completed partial witness outputted from the circuit
|
|
30
30
|
*/
|
|
31
31
|
export declare function executeNativeCircuit(inputWitness: WitnessMap, bytecode: Buffer, workingDirectory: string, pathToAcvm: string, outputFilename?: string): Promise<ACVMResult>;
|
|
32
|
-
export declare class NativeACVMSimulator implements
|
|
32
|
+
export declare class NativeACVMSimulator implements CircuitSimulator {
|
|
33
33
|
private workingDirectory;
|
|
34
34
|
private pathToAcvm;
|
|
35
35
|
private witnessFilename?;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"acvm_native.d.ts","sourceRoot":"","sources":["../../src/private/acvm_native.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACtD,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;AAKtE,OAAO,KAAK,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACxE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAI/D,oBAAY,WAAW;IACrB,OAAO,IAAA;IACP,OAAO,IAAA;CACR;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC9B,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC;IAC5B,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,WAAW,GAAG,WAAW,CAAC;AAmBnD;;;;;;;;GAQG;AACH,wBAAsB,oBAAoB,CACxC,YAAY,EAAE,UAAU,EACxB,QAAQ,EAAE,MAAM,EAChB,gBAAgB,EAAE,MAAM,EACxB,UAAU,EAAE,MAAM,EAClB,cAAc,CAAC,EAAE,MAAM,GACtB,OAAO,CAAC,UAAU,CAAC,CAsErB;AAED,qBAAa,mBAAoB,YAAW,gBAAgB;IAExD,OAAO,CAAC,gBAAgB;IACxB,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,eAAe,CAAC;gBAFhB,gBAAgB,EAAE,MAAM,EACxB,UAAU,EAAE,MAAM,EAClB,eAAe,CAAC,EAAE,MAAM,YAAA;IAG5B,sBAAsB,CAC1B,KAAK,EAAE,WAAW,EAClB,QAAQ,EAAE,2BAA2B,EACrC,QAAQ,EAAE,kBAAkB,GAAG,SAAS,GACvC,OAAO,CAAC,WAAW,CAAC;IA6BvB,kBAAkB,CAChB,MAAM,EAAE,WAAW,EACnB,SAAS,EAAE,gCAAgC,EAC3C,SAAS,EAAE,YAAY,GACtB,OAAO,CAAC,mBAAmB,CAAC;CAGhC"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { type ForeignCallHandler } from '@aztec/noir-acvm_js';
|
|
2
2
|
import type { FunctionArtifactWithContractName } from '@aztec/stdlib/abi';
|
|
3
3
|
import type { NoirCompiledCircuitWithName } from '@aztec/stdlib/noir';
|
|
4
|
-
import { type ACIRCallback, type ACIRExecutionResult } from '
|
|
5
|
-
import type { ACVMWitness } from '
|
|
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
|
-
import { type
|
|
8
|
-
export declare class WASMSimulator implements
|
|
7
|
+
import { type CircuitSimulator } from './circuit_simulator.js';
|
|
8
|
+
export declare class WASMSimulator implements CircuitSimulator {
|
|
9
9
|
protected log: import("@aztec/foundation/log").Logger;
|
|
10
10
|
constructor(log?: import("@aztec/foundation/log").Logger);
|
|
11
11
|
init(): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"acvm_wasm.d.ts","sourceRoot":"","sources":["../../src/private/acvm_wasm.ts"],"names":[],"mappings":"AAEA,OAAiB,EAAuB,KAAK,kBAAkB,EAAkB,MAAM,qBAAqB,CAAC;AAE7G,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AAEtE,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,mBAAmB,EAAQ,MAAM,gBAAgB,CAAC;AACnF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,KAAK,gBAAgB,EAAmB,MAAM,wBAAwB,CAAC;AAEhF,qBAAa,aAAc,YAAW,gBAAgB;IACxC,SAAS,CAAC,GAAG;gBAAH,GAAG,yCAAiC;IAEpD,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAUrB,sBAAsB,CAC1B,KAAK,EAAE,WAAW,EAClB,QAAQ,EAAE,2BAA2B,EACrC,QAAQ,EAAE,kBAAkB,GAC3B,OAAO,CAAC,WAAW,CAAC;IAkCjB,kBAAkB,CACtB,KAAK,EAAE,WAAW,EAClB,QAAQ,EAAE,gCAAgC,EAC1C,QAAQ,EAAE,YAAY,GACrB,OAAO,CAAC,mBAAmB,CAAC;CAIhC"}
|
|
@@ -2,8 +2,8 @@ import { createLogger } from '@aztec/foundation/log';
|
|
|
2
2
|
import { Timer } from '@aztec/foundation/timer';
|
|
3
3
|
import initACVM, { executeCircuit } from '@aztec/noir-acvm_js';
|
|
4
4
|
import initAbi from '@aztec/noir-noirc_abi';
|
|
5
|
-
import { acvm } from '
|
|
6
|
-
import { enrichNoirError } from './
|
|
5
|
+
import { acvm } from './acvm/acvm.js';
|
|
6
|
+
import { enrichNoirError } from './circuit_simulator.js';
|
|
7
7
|
export class WASMSimulator {
|
|
8
8
|
log;
|
|
9
9
|
constructor(log = createLogger('wasm-simulator')){
|
|
@@ -2,18 +2,18 @@ import { type ForeignCallHandler } from '@aztec/noir-acvm_js';
|
|
|
2
2
|
import type { WitnessMap } from '@aztec/noir-types';
|
|
3
3
|
import type { FunctionArtifactWithContractName } from '@aztec/stdlib/abi';
|
|
4
4
|
import type { NoirCompiledCircuitWithName } from '@aztec/stdlib/noir';
|
|
5
|
-
import type { ACIRCallback, ACIRExecutionResult } from '
|
|
6
|
-
import type { ACVMWitness } from '
|
|
5
|
+
import type { ACIRCallback, ACIRExecutionResult } from './acvm/acvm.js';
|
|
6
|
+
import type { ACVMWitness } from './acvm/acvm_types.js';
|
|
7
7
|
import type { ACVMSuccess } from './acvm_native.js';
|
|
8
|
-
import { type
|
|
8
|
+
import { type CircuitSimulator } from './circuit_simulator.js';
|
|
9
9
|
/**
|
|
10
|
-
* A
|
|
10
|
+
* A circuit simulator that uses the WASM simulator with the ability to handle blobs via the foreign call handler.
|
|
11
11
|
* This class is temporary while brillig cannot handle the blob math, and it is kept separate
|
|
12
12
|
* because the zkg commitment library used in the blob code is not browser compatible.
|
|
13
13
|
*
|
|
14
14
|
* It is only used in the context of server-side code executing simulated protocol circuits.
|
|
15
15
|
*/
|
|
16
|
-
export declare class WASMSimulatorWithBlobs implements
|
|
16
|
+
export declare class WASMSimulatorWithBlobs implements CircuitSimulator {
|
|
17
17
|
executeProtocolCircuit(input: WitnessMap, artifact: NoirCompiledCircuitWithName, callback: ForeignCallHandler): Promise<ACVMSuccess>;
|
|
18
18
|
executeUserCircuit(_input: ACVMWitness, _artifact: FunctionArtifactWithContractName, _callback: ACIRCallback): Promise<ACIRExecutionResult>;
|
|
19
19
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"acvm_wasm_with_blobs.d.ts","sourceRoot":"","sources":["../../src/private/acvm_wasm_with_blobs.ts"],"names":[],"mappings":"AACA,OAAO,EAAuB,KAAK,kBAAkB,EAAkB,MAAM,qBAAqB,CAAC;AACnG,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AAEtE,OAAO,KAAK,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACxE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,KAAK,gBAAgB,EAAmB,MAAM,wBAAwB,CAAC;AAEhF;;;;;;GAMG;AACH,qBAAa,sBAAuB,YAAW,gBAAgB;IACvD,sBAAsB,CAC1B,KAAK,EAAE,UAAU,EACjB,QAAQ,EAAE,2BAA2B,EACrC,QAAQ,EAAE,kBAAkB,GAC3B,OAAO,CAAC,WAAW,CAAC;IAuBvB,kBAAkB,CAChB,MAAM,EAAE,WAAW,EACnB,SAAS,EAAE,gCAAgC,EAC3C,SAAS,EAAE,YAAY,GACtB,OAAO,CAAC,mBAAmB,CAAC;CAGhC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Timer } from '@aztec/foundation/timer';
|
|
2
2
|
import { executeCircuit } from '@aztec/noir-acvm_js';
|
|
3
|
-
import { enrichNoirError } from './
|
|
3
|
+
import { enrichNoirError } from './circuit_simulator.js';
|
|
4
4
|
/**
|
|
5
|
-
* A
|
|
5
|
+
* A circuit simulator that uses the WASM simulator with the ability to handle blobs via the foreign call handler.
|
|
6
6
|
* This class is temporary while brillig cannot handle the blob math, and it is kept separate
|
|
7
7
|
* because the zkg commitment library used in the blob code is not browser compatible.
|
|
8
8
|
*
|
package/dest/private/{providers/circuit_recording → circuit_recording}/circuit_recorder.d.ts
RENAMED
|
@@ -1,20 +1,35 @@
|
|
|
1
1
|
import type { ForeignCallHandler } from '@aztec/noir-acvm_js';
|
|
2
|
-
import type { ACIRCallback } from '
|
|
3
|
-
import type { ACVMWitness } from '
|
|
2
|
+
import type { ACIRCallback } from '../acvm/acvm.js';
|
|
3
|
+
import type { ACVMWitness } from '../acvm/acvm_types.js';
|
|
4
|
+
export type OracleCall = {
|
|
5
|
+
name: string;
|
|
6
|
+
inputs: unknown[];
|
|
7
|
+
outputs: unknown;
|
|
8
|
+
time: number;
|
|
9
|
+
stackDepth: number;
|
|
10
|
+
};
|
|
11
|
+
export declare class CircuitRecording {
|
|
12
|
+
circuitName: string;
|
|
13
|
+
functionName: string;
|
|
14
|
+
bytecodeSHA512Hash: string;
|
|
15
|
+
timestamp: number;
|
|
16
|
+
inputs: Record<string, string>;
|
|
17
|
+
oracleCalls: OracleCall[];
|
|
18
|
+
error?: string;
|
|
19
|
+
parent?: CircuitRecording;
|
|
20
|
+
constructor(circuitName: string, functionName: string, bytecodeSHA512Hash: string, inputs: Record<string, string>);
|
|
21
|
+
setParent(recording?: CircuitRecording): void;
|
|
22
|
+
}
|
|
4
23
|
/**
|
|
5
24
|
* Class responsible for recording circuit inputs necessary to replay the circuit. These inputs are the initial witness
|
|
6
25
|
* map and the oracle calls made during the circuit execution/witness generation.
|
|
7
26
|
*
|
|
8
|
-
*
|
|
9
|
-
* a counter to ensure unique filenames. The file is stored in the `recordDir` directory provided as a parameter to
|
|
10
|
-
* CircuitRecorder.start().
|
|
11
|
-
*
|
|
12
|
-
* Example recording file:
|
|
27
|
+
* Example recording object:
|
|
13
28
|
* ```json
|
|
14
29
|
* {
|
|
15
30
|
* "circuitName": "AMM",
|
|
16
31
|
* "functionName": "add_liquidity",
|
|
17
|
-
* "
|
|
32
|
+
* "bytecodeSHA512Hash": "b46c640ed38f20eac5f61a5e41d8dd1e",
|
|
18
33
|
* "timestamp": 1740691464360,
|
|
19
34
|
* "inputs": {
|
|
20
35
|
* "0": "0x1e89de1f0ad5204263733b7ddf65bec45b8f44714a4da85a46474dad677679ef",
|
|
@@ -43,7 +58,7 @@ import type { ACVMWitness } from '../../acvm/acvm_types.js';
|
|
|
43
58
|
* ]
|
|
44
59
|
* },
|
|
45
60
|
* {
|
|
46
|
-
* "name": "
|
|
61
|
+
* "name": "fetchTaggedLogs",
|
|
47
62
|
* "inputs": []
|
|
48
63
|
* }
|
|
49
64
|
* ]
|
|
@@ -52,10 +67,11 @@ import type { ACVMWitness } from '../../acvm/acvm_types.js';
|
|
|
52
67
|
*/
|
|
53
68
|
export declare class CircuitRecorder {
|
|
54
69
|
#private;
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
private
|
|
58
|
-
private
|
|
70
|
+
protected readonly logger: import("@aztec/foundation/log").Logger;
|
|
71
|
+
protected recording?: CircuitRecording;
|
|
72
|
+
private stackDepth;
|
|
73
|
+
private newCircuit;
|
|
74
|
+
protected constructor();
|
|
59
75
|
/**
|
|
60
76
|
* Initializes a new circuit recording session.
|
|
61
77
|
* @param recordDir - Directory to store the recording
|
|
@@ -64,9 +80,8 @@ export declare class CircuitRecorder {
|
|
|
64
80
|
* @param circuitName - Name of the circuit
|
|
65
81
|
* @param functionName - Name of the circuit function (defaults to 'main'). This is meaningful only for
|
|
66
82
|
* contracts as protocol circuits artifacts always contain a single entrypoint function called 'main'.
|
|
67
|
-
* @returns A new CircuitRecorder instance
|
|
68
83
|
*/
|
|
69
|
-
|
|
84
|
+
start(input: ACVMWitness, circuitBytecode: Buffer, circuitName: string, functionName: string): Promise<void>;
|
|
70
85
|
/**
|
|
71
86
|
* Wraps a callback to record all oracle/foreign calls.
|
|
72
87
|
* @param callback - The original callback to wrap, either a user circuit callback or protocol circuit callback.
|
|
@@ -74,15 +89,20 @@ export declare class CircuitRecorder {
|
|
|
74
89
|
*/
|
|
75
90
|
wrapCallback(callback: ACIRCallback | ForeignCallHandler | undefined): ACIRCallback | ForeignCallHandler | undefined;
|
|
76
91
|
/**
|
|
77
|
-
*
|
|
78
|
-
*
|
|
92
|
+
* Records a single oracle/foreign call with its inputs and outputs.
|
|
93
|
+
* @param name - Name of the call
|
|
94
|
+
* @param inputs - Input arguments
|
|
95
|
+
* @param outputs - Output results
|
|
96
|
+
*/
|
|
97
|
+
recordCall(name: string, inputs: unknown[], outputs: unknown, time: number, stackDepth: number): Promise<OracleCall>;
|
|
98
|
+
/**
|
|
99
|
+
* Finalizes the recording by resetting the state and returning the recording object.
|
|
79
100
|
*/
|
|
80
|
-
finish(): Promise<
|
|
101
|
+
finish(): Promise<CircuitRecording>;
|
|
81
102
|
/**
|
|
82
|
-
* Finalizes the recording
|
|
83
|
-
* the recording file is incomplete and it fails to parse.
|
|
103
|
+
* Finalizes the recording by resetting the state and returning the recording object with an attached error.
|
|
84
104
|
* @param error - The error that occurred during circuit execution
|
|
85
105
|
*/
|
|
86
|
-
finishWithError(error: unknown): Promise<
|
|
106
|
+
finishWithError(error: unknown): Promise<CircuitRecording>;
|
|
87
107
|
}
|
|
88
108
|
//# sourceMappingURL=circuit_recorder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"circuit_recorder.d.ts","sourceRoot":"","sources":["../../../src/private/circuit_recording/circuit_recorder.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAuC,MAAM,qBAAqB,CAAC;AAEnG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEzD,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,OAAO,EAAE,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IAMb,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,qBAAa,gBAAgB;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,gBAAgB,CAAC;gBAEd,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IASjH,SAAS,CAAC,SAAS,CAAC,EAAE,gBAAgB,GAAG,IAAI;CAG9C;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,qBAAa,eAAe;;IAC1B,SAAS,CAAC,QAAQ,CAAC,MAAM,yCAA4C;IAErE,SAAS,CAAC,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAEvC,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,UAAU,CAAiB;IAEnC,SAAS;IAET;;;;;;;;OAQG;IACH,KAAK,CAAC,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAe5G;;;;OAIG;IACH,YAAY,CAAC,QAAQ,EAAE,YAAY,GAAG,kBAAkB,GAAG,SAAS,GAAG,YAAY,GAAG,kBAAkB,GAAG,SAAS;IAqFpH;;;;;OAKG;IACH,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAYpH;;OAEG;IACH,MAAM,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAUnC;;;OAGG;IACH,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,gBAAgB,CAAC;CAU3D"}
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { sha512 } from '@aztec/foundation/crypto';
|
|
2
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
3
|
+
import { Timer } from '@aztec/foundation/timer';
|
|
4
|
+
export class CircuitRecording {
|
|
5
|
+
circuitName;
|
|
6
|
+
functionName;
|
|
7
|
+
bytecodeSHA512Hash;
|
|
8
|
+
timestamp;
|
|
9
|
+
inputs;
|
|
10
|
+
oracleCalls;
|
|
11
|
+
error;
|
|
12
|
+
parent;
|
|
13
|
+
constructor(circuitName, functionName, bytecodeSHA512Hash, inputs){
|
|
14
|
+
this.circuitName = circuitName;
|
|
15
|
+
this.functionName = functionName;
|
|
16
|
+
this.bytecodeSHA512Hash = bytecodeSHA512Hash;
|
|
17
|
+
this.timestamp = Date.now();
|
|
18
|
+
this.inputs = inputs;
|
|
19
|
+
this.oracleCalls = [];
|
|
20
|
+
}
|
|
21
|
+
setParent(recording) {
|
|
22
|
+
this.parent = recording;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Class responsible for recording circuit inputs necessary to replay the circuit. These inputs are the initial witness
|
|
27
|
+
* map and the oracle calls made during the circuit execution/witness generation.
|
|
28
|
+
*
|
|
29
|
+
* Example recording object:
|
|
30
|
+
* ```json
|
|
31
|
+
* {
|
|
32
|
+
* "circuitName": "AMM",
|
|
33
|
+
* "functionName": "add_liquidity",
|
|
34
|
+
* "bytecodeSHA512Hash": "b46c640ed38f20eac5f61a5e41d8dd1e",
|
|
35
|
+
* "timestamp": 1740691464360,
|
|
36
|
+
* "inputs": {
|
|
37
|
+
* "0": "0x1e89de1f0ad5204263733b7ddf65bec45b8f44714a4da85a46474dad677679ef",
|
|
38
|
+
* "1": "0x00f4d59c0ff773427bb0fed5b422557ca4dc5655abe53d31fa9408cb3c5a672f",
|
|
39
|
+
* "5": "0x000000000000000000000000000000000000000000000000000000000000000f"
|
|
40
|
+
* },
|
|
41
|
+
* "oracleCalls": [
|
|
42
|
+
* {
|
|
43
|
+
* "name": "loadCapsule",
|
|
44
|
+
* "inputs": [
|
|
45
|
+
* [
|
|
46
|
+
* "0x102422483bad6abd385948435667e144ac4c272576e325e7563608876cd446fd"
|
|
47
|
+
* ],
|
|
48
|
+
* [
|
|
49
|
+
* "0x000000000000000000000000000000000000000000000000000000000000004d"
|
|
50
|
+
* ],
|
|
51
|
+
* [
|
|
52
|
+
* "0x0000000000000000000000000000000000000000000000000000000000000001"
|
|
53
|
+
* ]
|
|
54
|
+
* ],
|
|
55
|
+
* "outputs": [
|
|
56
|
+
* "0x0000000000000000000000000000000000000000000000000000000000000000",
|
|
57
|
+
* [
|
|
58
|
+
* "0x0000000000000000000000000000000000000000000000000000000000000000"
|
|
59
|
+
* ]
|
|
60
|
+
* ]
|
|
61
|
+
* },
|
|
62
|
+
* {
|
|
63
|
+
* "name": "fetchTaggedLogs",
|
|
64
|
+
* "inputs": []
|
|
65
|
+
* }
|
|
66
|
+
* ]
|
|
67
|
+
* }
|
|
68
|
+
* ```
|
|
69
|
+
*/ export class CircuitRecorder {
|
|
70
|
+
logger = createLogger('simulator:acvm:recording');
|
|
71
|
+
recording;
|
|
72
|
+
stackDepth = 0;
|
|
73
|
+
newCircuit = true;
|
|
74
|
+
constructor(){}
|
|
75
|
+
/**
|
|
76
|
+
* Initializes a new circuit recording session.
|
|
77
|
+
* @param recordDir - Directory to store the recording
|
|
78
|
+
* @param input - Circuit input witness
|
|
79
|
+
* @param circuitBytecode - Compiled circuit bytecode
|
|
80
|
+
* @param circuitName - Name of the circuit
|
|
81
|
+
* @param functionName - Name of the circuit function (defaults to 'main'). This is meaningful only for
|
|
82
|
+
* contracts as protocol circuits artifacts always contain a single entrypoint function called 'main'.
|
|
83
|
+
*/ start(input, circuitBytecode, circuitName, functionName) {
|
|
84
|
+
const parentRef = this.recording;
|
|
85
|
+
if (this.newCircuit) {
|
|
86
|
+
this.recording = new CircuitRecording(circuitName, functionName, sha512(circuitBytecode).toString('hex'), Object.fromEntries(input));
|
|
87
|
+
}
|
|
88
|
+
this.recording.setParent(parentRef);
|
|
89
|
+
return Promise.resolve();
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Wraps a callback to record all oracle/foreign calls.
|
|
93
|
+
* @param callback - The original callback to wrap, either a user circuit callback or protocol circuit callback.
|
|
94
|
+
* @returns A wrapped callback that records all oracle interactions.
|
|
95
|
+
*/ wrapCallback(callback) {
|
|
96
|
+
if (!callback) {
|
|
97
|
+
return undefined;
|
|
98
|
+
}
|
|
99
|
+
if (this.#isACIRCallback(callback)) {
|
|
100
|
+
return this.#wrapUserCircuitCallback(callback);
|
|
101
|
+
}
|
|
102
|
+
return this.#wrapProtocolCircuitCallback(callback);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Type guard to check if a callback is an ACIRCallback.
|
|
106
|
+
*/ #isACIRCallback(callback) {
|
|
107
|
+
return typeof callback === 'object' && callback !== null && !('call' in callback);
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Wraps a user circuit callback to record all oracle calls.
|
|
111
|
+
* @param callback - The original circuit callback.
|
|
112
|
+
* @returns A wrapped callback that records all oracle interactions which is to be provided to the ACVM.
|
|
113
|
+
*/ #wrapUserCircuitCallback(callback) {
|
|
114
|
+
const recordingCallback = {};
|
|
115
|
+
const oracleMethods = Object.keys(callback);
|
|
116
|
+
for (const name of oracleMethods){
|
|
117
|
+
const fn = callback[name];
|
|
118
|
+
if (!fn || typeof fn !== 'function') {
|
|
119
|
+
throw new Error(`Oracle method ${name} not found when setting up recording callback`);
|
|
120
|
+
}
|
|
121
|
+
const isExternalCall = name === 'callPrivateFunction';
|
|
122
|
+
recordingCallback[name] = (...args)=>{
|
|
123
|
+
const timer = new Timer();
|
|
124
|
+
// If we're entering another circuit via `callPrivateFunction`, we increase the stack depth and set the
|
|
125
|
+
// newCircuit variable to ensure we are creating a new recording object.
|
|
126
|
+
if (isExternalCall) {
|
|
127
|
+
this.stackDepth++;
|
|
128
|
+
this.newCircuit = true;
|
|
129
|
+
}
|
|
130
|
+
const result = fn.call(callback, ...args);
|
|
131
|
+
if (result instanceof Promise) {
|
|
132
|
+
return result.then(async (r)=>{
|
|
133
|
+
// Once we leave the nested circuit, we decrease the stack depth and set newCircuit to false
|
|
134
|
+
// since we are going back to the "parent" circuit which can never be new
|
|
135
|
+
if (isExternalCall) {
|
|
136
|
+
this.stackDepth--;
|
|
137
|
+
this.newCircuit = false;
|
|
138
|
+
this.recording = this.recording.parent;
|
|
139
|
+
}
|
|
140
|
+
await this.recordCall(name, args, r, timer.ms(), this.stackDepth);
|
|
141
|
+
return r;
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
// Once we leave the nested circuit, we decrease the stack depth and set newCircuit to false
|
|
145
|
+
// since we are going back to the "parent" circuit which can never be new
|
|
146
|
+
if (isExternalCall) {
|
|
147
|
+
this.stackDepth--;
|
|
148
|
+
this.newCircuit = false;
|
|
149
|
+
this.recording = this.recording.parent;
|
|
150
|
+
}
|
|
151
|
+
void this.recordCall(name, args, result, timer.ms(), this.stackDepth);
|
|
152
|
+
return result;
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
return recordingCallback;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Wraps a protocol circuit callback to record all oracle calls.
|
|
159
|
+
* @param callback - The original oracle circuit callback.
|
|
160
|
+
* @returns A wrapped handler that records all oracle interactions which is to be provided to the ACVM.
|
|
161
|
+
*/ #wrapProtocolCircuitCallback(callback) {
|
|
162
|
+
return async (name, inputs)=>{
|
|
163
|
+
const timer = new Timer();
|
|
164
|
+
const result = await callback(name, inputs);
|
|
165
|
+
await this.recordCall(name, inputs, result, timer.ms(), 0);
|
|
166
|
+
return result;
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Records a single oracle/foreign call with its inputs and outputs.
|
|
171
|
+
* @param name - Name of the call
|
|
172
|
+
* @param inputs - Input arguments
|
|
173
|
+
* @param outputs - Output results
|
|
174
|
+
*/ recordCall(name, inputs, outputs, time, stackDepth) {
|
|
175
|
+
const entry = {
|
|
176
|
+
name,
|
|
177
|
+
inputs,
|
|
178
|
+
outputs,
|
|
179
|
+
time,
|
|
180
|
+
stackDepth
|
|
181
|
+
};
|
|
182
|
+
this.recording.oracleCalls.push(entry);
|
|
183
|
+
return Promise.resolve(entry);
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Finalizes the recording by resetting the state and returning the recording object.
|
|
187
|
+
*/ finish() {
|
|
188
|
+
const result = this.recording;
|
|
189
|
+
// If this is the top-level circuit recording, we reset the state for the next simulator call
|
|
190
|
+
if (!result.parent) {
|
|
191
|
+
this.newCircuit = true;
|
|
192
|
+
this.recording = undefined;
|
|
193
|
+
}
|
|
194
|
+
return Promise.resolve(result);
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Finalizes the recording by resetting the state and returning the recording object with an attached error.
|
|
198
|
+
* @param error - The error that occurred during circuit execution
|
|
199
|
+
*/ finishWithError(error) {
|
|
200
|
+
const result = this.recording;
|
|
201
|
+
// If this is the top-level circuit recording, we reset the state for the next simulator call
|
|
202
|
+
if (!result.parent) {
|
|
203
|
+
this.newCircuit = true;
|
|
204
|
+
this.recording = undefined;
|
|
205
|
+
}
|
|
206
|
+
result.error = JSON.stringify(error);
|
|
207
|
+
return Promise.resolve(result);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { ACVMWitness } from '../acvm/acvm_types.js';
|
|
2
|
+
import { CircuitRecorder, type CircuitRecording } from './circuit_recorder.js';
|
|
3
|
+
export declare class FileCircuitRecorder extends CircuitRecorder {
|
|
4
|
+
#private;
|
|
5
|
+
private readonly recordDir;
|
|
6
|
+
recording?: CircuitRecording & {
|
|
7
|
+
filePath: string;
|
|
8
|
+
isFirstCall: boolean;
|
|
9
|
+
};
|
|
10
|
+
constructor(recordDir: string);
|
|
11
|
+
start(input: ACVMWitness, circuitBytecode: Buffer, circuitName: string, functionName?: string): Promise<void>;
|
|
12
|
+
/**
|
|
13
|
+
* Records a single oracle/foreign call with its inputs and outputs.
|
|
14
|
+
* @param name - Name of the call
|
|
15
|
+
* @param inputs - Input arguments
|
|
16
|
+
* @param outputs - Output results
|
|
17
|
+
*/
|
|
18
|
+
recordCall(name: string, inputs: unknown[], outputs: unknown, time: number, stackDepth: number): Promise<import("./circuit_recorder.js").OracleCall>;
|
|
19
|
+
/**
|
|
20
|
+
* Finalizes the recording file by adding closing brackets. Without calling this method, the recording file is
|
|
21
|
+
* incomplete and it fails to parse.
|
|
22
|
+
*/
|
|
23
|
+
finish(): Promise<CircuitRecording>;
|
|
24
|
+
/**
|
|
25
|
+
* Finalizes the recording file by adding the error and closing brackets. Without calling this method or `finish`,
|
|
26
|
+
* the recording file is incomplete and it fails to parse.
|
|
27
|
+
* @param error - The error that occurred during circuit execution
|
|
28
|
+
*/
|
|
29
|
+
finishWithError(error: unknown): Promise<CircuitRecording>;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=file_circuit_recorder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file_circuit_recorder.d.ts","sourceRoot":"","sources":["../../../src/private/circuit_recording/file_circuit_recorder.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,KAAK,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE/E,qBAAa,mBAAoB,SAAQ,eAAe;;IAG1C,OAAO,CAAC,QAAQ,CAAC,SAAS;IAF9B,SAAS,CAAC,EAAE,gBAAgB,GAAG;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,OAAO,CAAA;KAAE,CAAC;gBAErD,SAAS,EAAE,MAAM;IAI/B,KAAK,CAClB,KAAK,EAAE,WAAW,EAClB,eAAe,EAAE,MAAM,EACvB,WAAW,EAAE,MAAM,EACnB,YAAY,GAAE,MAAe;IAqE/B;;;;;OAKG;IACY,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM;IAY7G;;;OAGG;IACY,MAAM,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAalD;;;;OAIG;IACY,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,gBAAgB,CAAC;CAc1E"}
|