@aztec/simulator 0.80.0 → 0.82.0
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/common/db_interfaces.d.ts +30 -17
- package/dest/common/db_interfaces.d.ts.map +1 -1
- package/dest/common/db_interfaces.js +1 -1
- package/dest/common/debug_fn_name.d.ts +2 -2
- package/dest/common/debug_fn_name.d.ts.map +1 -1
- package/dest/common/message_load_oracle_inputs.d.ts +4 -0
- package/dest/common/message_load_oracle_inputs.d.ts.map +1 -1
- package/dest/common/message_load_oracle_inputs.js +9 -0
- package/dest/private/acvm/acvm.d.ts +6 -1
- package/dest/private/acvm/acvm.d.ts.map +1 -1
- package/dest/private/acvm/acvm.js +7 -13
- package/dest/private/acvm/deserialize.d.ts +19 -18
- package/dest/private/acvm/deserialize.d.ts.map +1 -1
- package/dest/private/acvm/deserialize.js +31 -23
- package/dest/private/acvm/oracle/oracle.d.ts +36 -34
- package/dest/private/acvm/oracle/oracle.d.ts.map +1 -1
- package/dest/private/acvm/oracle/oracle.js +134 -79
- package/dest/private/acvm/oracle/typed_oracle.d.ts +3 -2
- package/dest/private/acvm/oracle/typed_oracle.d.ts.map +1 -1
- package/dest/private/acvm/oracle/typed_oracle.js +5 -2
- package/dest/private/acvm/serialize.d.ts +11 -0
- package/dest/private/acvm/serialize.d.ts.map +1 -1
- package/dest/private/acvm/serialize.js +27 -0
- package/dest/private/execution_data_provider.d.ts +15 -13
- package/dest/private/execution_data_provider.d.ts.map +1 -1
- package/dest/private/private_execution.d.ts +2 -2
- package/dest/private/private_execution.d.ts.map +1 -1
- package/dest/private/private_execution.js +4 -5
- package/dest/private/private_execution_oracle.d.ts.map +1 -1
- package/dest/private/private_execution_oracle.js +1 -1
- package/dest/private/providers/acvm_native.d.ts +6 -4
- package/dest/private/providers/acvm_native.d.ts.map +1 -1
- package/dest/private/providers/acvm_native.js +6 -3
- package/dest/private/providers/acvm_wasm.d.ts +6 -7
- package/dest/private/providers/acvm_wasm.d.ts.map +1 -1
- package/dest/private/providers/acvm_wasm.js +13 -15
- package/dest/private/providers/acvm_wasm_with_blobs.d.ts +5 -5
- package/dest/private/providers/acvm_wasm_with_blobs.d.ts.map +1 -1
- package/dest/private/providers/acvm_wasm_with_blobs.js +7 -9
- package/dest/private/providers/circuit_recording/circuit_recorder.d.ts +90 -0
- package/dest/private/providers/circuit_recording/circuit_recorder.d.ts.map +1 -0
- package/dest/private/providers/circuit_recording/circuit_recorder.js +246 -0
- package/dest/private/providers/circuit_recording/simulation_provider_recorder_wrapper.d.ts +18 -0
- package/dest/private/providers/circuit_recording/simulation_provider_recorder_wrapper.d.ts.map +1 -0
- package/dest/private/providers/circuit_recording/simulation_provider_recorder_wrapper.js +39 -0
- package/dest/private/providers/simulation_provider.d.ts +21 -7
- package/dest/private/providers/simulation_provider.d.ts.map +1 -1
- package/dest/private/simulator.d.ts +3 -2
- package/dest/private/simulator.d.ts.map +1 -1
- package/dest/private/simulator.js +2 -2
- package/dest/private/unconstrained_execution.d.ts +2 -2
- package/dest/private/unconstrained_execution.d.ts.map +1 -1
- package/dest/private/unconstrained_execution.js +1 -2
- package/dest/private/unconstrained_execution_oracle.d.ts +5 -3
- package/dest/private/unconstrained_execution_oracle.d.ts.map +1 -1
- package/dest/private/unconstrained_execution_oracle.js +9 -5
- package/dest/public/avm/avm_simulator.d.ts.map +1 -1
- package/dest/public/avm/avm_simulator.js +0 -2
- package/dest/public/avm/fixtures/avm_simulation_tester.d.ts.map +1 -1
- package/dest/public/avm/fixtures/avm_simulation_tester.js +5 -5
- package/dest/public/avm/fixtures/index.d.ts +4 -4
- package/dest/public/avm/fixtures/index.d.ts.map +1 -1
- package/dest/public/avm/fixtures/index.js +9 -6
- package/dest/public/avm/fixtures/simple_contract_data_source.d.ts +1 -2
- package/dest/public/avm/fixtures/simple_contract_data_source.d.ts.map +1 -1
- package/dest/public/avm/fixtures/simple_contract_data_source.js +0 -3
- package/dest/public/avm/journal/journal.d.ts +16 -70
- package/dest/public/avm/journal/journal.d.ts.map +1 -1
- package/dest/public/avm/journal/journal.js +88 -210
- package/dest/public/avm/journal/nullifiers.d.ts +2 -2
- package/dest/public/avm/journal/nullifiers.d.ts.map +1 -1
- package/dest/public/avm/journal/public_storage.d.ts +2 -2
- package/dest/public/avm/journal/public_storage.d.ts.map +1 -1
- package/dest/public/avm/test_utils.d.ts +10 -13
- package/dest/public/avm/test_utils.d.ts.map +1 -1
- package/dest/public/avm/test_utils.js +8 -13
- package/dest/public/fixtures/public_tx_simulation_tester.d.ts +3 -3
- package/dest/public/fixtures/public_tx_simulation_tester.d.ts.map +1 -1
- package/dest/public/fixtures/public_tx_simulation_tester.js +10 -9
- package/dest/public/hinting_db_sources.d.ts +19 -0
- package/dest/public/hinting_db_sources.d.ts.map +1 -0
- package/dest/public/hinting_db_sources.js +36 -0
- package/dest/public/public_db_sources.d.ts +46 -22
- package/dest/public/public_db_sources.d.ts.map +1 -1
- package/dest/public/public_db_sources.js +82 -27
- package/dest/public/public_processor/public_processor.d.ts +5 -5
- package/dest/public/public_processor/public_processor.d.ts.map +1 -1
- package/dest/public/public_processor/public_processor.js +21 -20
- package/dest/public/public_tx_simulator/public_tx_context.d.ts +9 -14
- package/dest/public/public_tx_simulator/public_tx_context.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/public_tx_context.js +15 -19
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts +9 -6
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/public_tx_simulator.js +28 -14
- package/dest/public/side_effect_trace.d.ts +6 -22
- package/dest/public/side_effect_trace.d.ts.map +1 -1
- package/dest/public/side_effect_trace.js +11 -70
- package/dest/public/side_effect_trace_interface.d.ts +5 -19
- package/dest/public/side_effect_trace_interface.d.ts.map +1 -1
- package/dest/testing.d.ts +2 -0
- package/dest/testing.d.ts.map +1 -0
- package/dest/testing.js +1 -0
- package/package.json +15 -14
- package/src/common/db_interfaces.ts +32 -18
- package/src/common/debug_fn_name.ts +2 -2
- package/src/common/message_load_oracle_inputs.ts +8 -0
- package/src/private/acvm/acvm.ts +8 -24
- package/src/private/acvm/deserialize.ts +35 -29
- package/src/private/acvm/oracle/oracle.ts +171 -129
- package/src/private/acvm/oracle/typed_oracle.ts +7 -3
- package/src/private/acvm/serialize.ts +28 -0
- package/src/private/execution_data_provider.ts +19 -14
- package/src/private/private_execution.ts +11 -7
- package/src/private/private_execution_oracle.ts +5 -1
- package/src/private/providers/acvm_native.ts +17 -6
- package/src/private/providers/acvm_wasm.ts +27 -20
- package/src/private/providers/acvm_wasm_with_blobs.ts +15 -12
- package/src/private/providers/circuit_recording/circuit_recorder.ts +283 -0
- package/src/private/providers/circuit_recording/simulation_provider_recorder_wrapper.ts +82 -0
- package/src/private/providers/simulation_provider.ts +30 -5
- package/src/private/simulator.ts +5 -3
- package/src/private/unconstrained_execution.ts +8 -4
- package/src/private/unconstrained_execution_oracle.ts +15 -9
- package/src/public/avm/avm_simulator.ts +0 -2
- package/src/public/avm/fixtures/avm_simulation_tester.ts +8 -5
- package/src/public/avm/fixtures/index.ts +16 -10
- package/src/public/avm/fixtures/simple_contract_data_source.ts +1 -10
- package/src/public/avm/journal/journal.ts +119 -353
- package/src/public/avm/journal/nullifiers.ts +2 -2
- package/src/public/avm/journal/public_storage.ts +2 -2
- package/src/public/avm/test_utils.ts +20 -29
- package/src/public/fixtures/public_tx_simulation_tester.ts +9 -12
- package/src/public/hinting_db_sources.ts +71 -0
- package/src/public/public_db_sources.ts +134 -32
- package/src/public/public_processor/public_processor.ts +22 -21
- package/src/public/public_tx_simulator/public_tx_context.ts +30 -38
- package/src/public/public_tx_simulator/public_tx_simulator.ts +47 -17
- package/src/public/side_effect_trace.ts +8 -172
- package/src/public/side_effect_trace_interface.ts +4 -55
- package/src/testing.ts +1 -0
- package/dest/public/avm/bytecode_utils.d.ts +0 -5
- package/dest/public/avm/bytecode_utils.d.ts.map +0 -1
- package/dest/public/avm/bytecode_utils.js +0 -17
- package/src/public/avm/bytecode_utils.ts +0 -17
|
@@ -8,7 +8,7 @@ import { PrivateCircuitPublicInputs } from '@aztec/stdlib/kernel';
|
|
|
8
8
|
import { SharedMutableValues, SharedMutableValuesWithHash } from '@aztec/stdlib/shared-mutable';
|
|
9
9
|
import { PrivateCallExecutionResult } from '@aztec/stdlib/tx';
|
|
10
10
|
import { ExecutionError, resolveAssertionMessageFromError } from '../common/errors.js';
|
|
11
|
-
import {
|
|
11
|
+
import { witnessMapToFields } from './acvm/deserialize.js';
|
|
12
12
|
import { Oracle, extractCallStack } from './acvm/index.js';
|
|
13
13
|
/**
|
|
14
14
|
* Execute a private function and return the execution result.
|
|
@@ -17,11 +17,10 @@ import { Oracle, extractCallStack } from './acvm/index.js';
|
|
|
17
17
|
log.verbose(`Executing private function ${functionName}`, {
|
|
18
18
|
contract: contractAddress
|
|
19
19
|
});
|
|
20
|
-
const acir = artifact.bytecode;
|
|
21
20
|
const initialWitness = privateExecutionOracle.getInitialWitness(artifact);
|
|
22
21
|
const acvmCallback = new Oracle(privateExecutionOracle);
|
|
23
22
|
const timer = new Timer();
|
|
24
|
-
const acirExecutionResult = await simulator.executeUserCircuit(
|
|
23
|
+
const acirExecutionResult = await simulator.executeUserCircuit(initialWitness, artifact, acvmCallback).catch((err)=>{
|
|
25
24
|
err.message = resolveAssertionMessageFromError(err, artifact);
|
|
26
25
|
throw new ExecutionError(err.message, {
|
|
27
26
|
contractAddress,
|
|
@@ -52,7 +51,7 @@ import { Oracle, extractCallStack } from './acvm/index.js';
|
|
|
52
51
|
const enqueuedPublicFunctionCalls = privateExecutionOracle.getEnqueuedPublicFunctionCalls();
|
|
53
52
|
const publicTeardownFunctionCall = privateExecutionOracle.getPublicTeardownFunctionCall();
|
|
54
53
|
log.debug(`Returning from call to ${contractAddress.toString()}:${functionSelector}`);
|
|
55
|
-
return new PrivateCallExecutionResult(
|
|
54
|
+
return new PrivateCallExecutionResult(artifact.bytecode, Buffer.from(artifact.verificationKey, 'base64'), partialWitness, publicInputs, noteHashLeafIndexMap, newNotes, noteHashNullifierCounterMap, rawReturnValues, nestedExecutions, enqueuedPublicFunctionCalls, publicTeardownFunctionCall, contractClassLogs);
|
|
56
55
|
}
|
|
57
56
|
/**
|
|
58
57
|
* Get the private circuit public inputs from the partial witness.
|
|
@@ -69,7 +68,7 @@ import { Oracle, extractCallStack } from './acvm/index.js';
|
|
|
69
68
|
if (returnedField === undefined) {
|
|
70
69
|
throw new Error(`Missing return value for index ${i}`);
|
|
71
70
|
}
|
|
72
|
-
returnData.push(
|
|
71
|
+
returnData.push(Fr.fromString(returnedField));
|
|
73
72
|
}
|
|
74
73
|
return PrivateCircuitPublicInputs.fromFields(returnData);
|
|
75
74
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"private_execution_oracle.d.ts","sourceRoot":"","sources":["../../src/private/private_execution_oracle.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAE9C,OAAO,EACL,KAAK,WAAW,EAEhB,gBAAgB,EAChB,KAAK,YAAY,EAElB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAG3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAQ,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EACL,KAAK,WAAW,EAChB,WAAW,EACX,OAAO,EACP,uBAAuB,EACvB,6BAA6B,EAC7B,WAAW,EACX,0BAA0B,EAC1B,sBAAsB,EACtB,KAAK,SAAS,EACf,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,KAAK,QAAQ,EAAiB,MAAM,iBAAiB,CAAC;AAC/D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAA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AAY,EAAE,OAAO;IAgCvB;;;;;;;;;;OAUG;IACmB,yBAAyB,CAC7C,qBAAqB,EAAE,YAAY,EACnC,gBAAgB,EAAE,gBAAgB,EAClC,QAAQ,EAAE,EAAE,EACZ,iBAAiB,EAAE,MAAM,EACzB,YAAY,EAAE,OAAO,GACpB,OAAO,CAAC,EAAE,CAAC;IAwBd;;;;;;;;;;OAUG;IACmB,6BAA6B,CACjD,qBAAqB,EAAE,YAAY,EACnC,gBAAgB,EAAE,gBAAgB,EAClC,QAAQ,EAAE,EAAE,EACZ,iBAAiB,EAAE,MAAM,EACzB,YAAY,EAAE,OAAO,GACpB,OAAO,CAAC,EAAE,CAAC;IAsBE,uCAAuC,CAAC,8BAA8B,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI9G;;;;;;OAMG;YACW,iBAAiB;IAaxB,oBAAoB;IAIL,sCAAsC,CAAC,MAAM,EAAE,YAAY,EAAE,SAAS,EAAE,YAAY;IAIpF,SAAS;CAgBhC"}
|
|
@@ -375,7 +375,7 @@ import { UnconstrainedExecutionOracle } from './unconstrained_execution_oracle.j
|
|
|
375
375
|
async syncNotes() {
|
|
376
376
|
const taggedLogsByRecipient = await this.executionDataProvider.syncTaggedLogs(this.contractAddress, this.historicalHeader.globalVariables.blockNumber.toNumber(), this.scopes);
|
|
377
377
|
for (const [recipient, taggedLogs] of taggedLogsByRecipient.entries()){
|
|
378
|
-
await this.executionDataProvider.processTaggedLogs(taggedLogs, AztecAddress.fromString(recipient));
|
|
378
|
+
await this.executionDataProvider.processTaggedLogs(this.contractAddress, taggedLogs, AztecAddress.fromString(recipient));
|
|
379
379
|
}
|
|
380
380
|
await this.executionDataProvider.removeNullifiedNotes(this.contractAddress);
|
|
381
381
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/// <reference types="node" resolution-mode="require"/>
|
|
2
2
|
/// <reference types="node" resolution-mode="require"/>
|
|
3
|
-
import type { WitnessMap } from '@aztec/noir-
|
|
4
|
-
import type {
|
|
3
|
+
import type { WitnessMap } from '@aztec/noir-acvm_js';
|
|
4
|
+
import type { ForeignCallHandler } from '@aztec/noir-protocol-circuits-types/types';
|
|
5
|
+
import type { FunctionArtifactWithContractName } from '@aztec/stdlib/abi';
|
|
6
|
+
import type { NoirCompiledCircuitWithName } from '@aztec/stdlib/noir';
|
|
5
7
|
import type { ACIRCallback, ACIRExecutionResult } from '../acvm/acvm.js';
|
|
6
8
|
import type { ACVMWitness } from '../acvm/acvm_types.js';
|
|
7
9
|
import type { SimulationProvider } from './simulation_provider.js';
|
|
@@ -34,7 +36,7 @@ export declare class NativeACVMSimulator implements SimulationProvider {
|
|
|
34
36
|
private pathToAcvm;
|
|
35
37
|
private witnessFilename?;
|
|
36
38
|
constructor(workingDirectory: string, pathToAcvm: string, witnessFilename?: string | undefined);
|
|
37
|
-
executeProtocolCircuit(input:
|
|
38
|
-
executeUserCircuit(
|
|
39
|
+
executeProtocolCircuit(input: ACVMWitness, artifact: NoirCompiledCircuitWithName, callback: ForeignCallHandler | undefined): Promise<ACVMWitness>;
|
|
40
|
+
executeUserCircuit(_input: ACVMWitness, _artifact: FunctionArtifactWithContractName, _callback: ACIRCallback): Promise<ACIRExecutionResult>;
|
|
39
41
|
}
|
|
40
42
|
//# sourceMappingURL=acvm_native.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"acvm_native.d.ts","sourceRoot":"","sources":["../../../src/private/providers/acvm_native.ts"],"names":[],"mappings":";;AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"acvm_native.d.ts","sourceRoot":"","sources":["../../../src/private/providers/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,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,EAAE,WAAW,EACnB,SAAS,EAAE,gCAAgC,EAC3C,SAAS,EAAE,YAAY,GACtB,OAAO,CAAC,mBAAmB,CAAC;CAGhC"}
|
|
@@ -119,11 +119,14 @@ export class NativeACVMSimulator {
|
|
|
119
119
|
this.pathToAcvm = pathToAcvm;
|
|
120
120
|
this.witnessFilename = witnessFilename;
|
|
121
121
|
}
|
|
122
|
-
async executeProtocolCircuit(input,
|
|
122
|
+
async executeProtocolCircuit(input, artifact, callback) {
|
|
123
123
|
// Execute the circuit on those initial witness values
|
|
124
|
+
if (callback) {
|
|
125
|
+
throw new Error('Native ACVM simulator does not support foreign calls. Ignoring callback.');
|
|
126
|
+
}
|
|
124
127
|
const operation = async (directory)=>{
|
|
125
128
|
// Decode the bytecode from base64 since the acvm does not know about base64 encoding
|
|
126
|
-
const decodedBytecode = Buffer.from(
|
|
129
|
+
const decodedBytecode = Buffer.from(artifact.bytecode, 'base64');
|
|
127
130
|
// Execute the circuit
|
|
128
131
|
const result = await executeNativeCircuit(input, decodedBytecode, directory, this.pathToAcvm, this.witnessFilename);
|
|
129
132
|
if (result.status == 1) {
|
|
@@ -133,7 +136,7 @@ export class NativeACVMSimulator {
|
|
|
133
136
|
};
|
|
134
137
|
return await runInDirectory(this.workingDirectory, operation, false, logger);
|
|
135
138
|
}
|
|
136
|
-
executeUserCircuit(
|
|
139
|
+
executeUserCircuit(_input, _artifact, _callback) {
|
|
137
140
|
throw new Error('Not implemented');
|
|
138
141
|
}
|
|
139
142
|
}
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import type {
|
|
4
|
-
import type
|
|
5
|
-
import { type ACIRCallback } from '../acvm/acvm.js';
|
|
1
|
+
import { type ForeignCallHandler } from '@aztec/noir-acvm_js';
|
|
2
|
+
import type { FunctionArtifactWithContractName } from '@aztec/stdlib/abi';
|
|
3
|
+
import type { NoirCompiledCircuitWithName } from '@aztec/stdlib/noir';
|
|
4
|
+
import { type ACIRCallback, type ACIRExecutionResult } from '../acvm/acvm.js';
|
|
6
5
|
import type { ACVMWitness } from '../acvm/acvm_types.js';
|
|
7
6
|
import { type SimulationProvider } from './simulation_provider.js';
|
|
8
7
|
export declare class WASMSimulator implements SimulationProvider {
|
|
9
8
|
protected log: import("@aztec/foundation/log").Logger;
|
|
10
9
|
constructor(log?: import("@aztec/foundation/log").Logger);
|
|
11
10
|
init(): Promise<void>;
|
|
12
|
-
executeProtocolCircuit(input:
|
|
13
|
-
executeUserCircuit(
|
|
11
|
+
executeProtocolCircuit(input: ACVMWitness, artifact: NoirCompiledCircuitWithName, callback: ForeignCallHandler): Promise<ACVMWitness>;
|
|
12
|
+
executeUserCircuit(input: ACVMWitness, artifact: FunctionArtifactWithContractName, callback: ACIRCallback): Promise<ACIRExecutionResult>;
|
|
14
13
|
}
|
|
15
14
|
//# sourceMappingURL=acvm_wasm.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"acvm_wasm.d.ts","sourceRoot":"","sources":["../../../src/private/providers/acvm_wasm.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"acvm_wasm.d.ts","sourceRoot":"","sources":["../../../src/private/providers/acvm_wasm.ts"],"names":[],"mappings":"AACA,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,iBAAiB,CAAC;AACpF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,KAAK,kBAAkB,EAAmB,MAAM,0BAA0B,CAAC;AAEpF,qBAAa,aAAc,YAAW,kBAAkB;IAC1C,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;IAiCjB,kBAAkB,CACtB,KAAK,EAAE,WAAW,EAClB,QAAQ,EAAE,gCAAgC,EAC1C,QAAQ,EAAE,YAAY,GACrB,OAAO,CAAC,mBAAmB,CAAC;CAIhC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { createLogger } from '@aztec/foundation/log';
|
|
2
2
|
import initACVM, { executeCircuit } from '@aztec/noir-acvm_js';
|
|
3
3
|
import initAbi from '@aztec/noir-noirc_abi';
|
|
4
|
-
import { foreignCallHandler } from '@aztec/noir-protocol-circuits-types/client';
|
|
5
4
|
import { acvm } from '../acvm/acvm.js';
|
|
6
5
|
import { enrichNoirError } from './simulation_provider.js';
|
|
7
6
|
export class WASMSimulator {
|
|
@@ -20,43 +19,42 @@ export class WASMSimulator {
|
|
|
20
19
|
]);
|
|
21
20
|
}
|
|
22
21
|
}
|
|
23
|
-
async executeProtocolCircuit(input,
|
|
22
|
+
async executeProtocolCircuit(input, artifact, callback) {
|
|
24
23
|
this.log.debug('init', {
|
|
25
|
-
hash:
|
|
24
|
+
hash: artifact.hash
|
|
26
25
|
});
|
|
27
26
|
await this.init();
|
|
28
|
-
// Execute the circuit on those initial witness values
|
|
29
|
-
//
|
|
30
27
|
// Decode the bytecode from base64 since the acvm does not know about base64 encoding
|
|
31
|
-
const decodedBytecode = Buffer.from(
|
|
28
|
+
const decodedBytecode = Buffer.from(artifact.bytecode, 'base64');
|
|
32
29
|
//
|
|
33
30
|
// Execute the circuit
|
|
34
31
|
try {
|
|
35
|
-
const
|
|
32
|
+
const result = await executeCircuit(decodedBytecode, input, callback);
|
|
36
33
|
this.log.debug('execution successful', {
|
|
37
|
-
hash:
|
|
34
|
+
hash: artifact.hash
|
|
38
35
|
});
|
|
39
|
-
return
|
|
36
|
+
return result;
|
|
40
37
|
} catch (err) {
|
|
41
|
-
// Typescript types
|
|
38
|
+
// Typescript types caught errors as unknown or any, so we need to narrow its type to check if it has raw
|
|
39
|
+
// assertion payload.
|
|
42
40
|
if (typeof err === 'object' && err !== null && 'rawAssertionPayload' in err) {
|
|
43
|
-
const parsed = enrichNoirError(
|
|
41
|
+
const parsed = enrichNoirError(artifact, err);
|
|
44
42
|
this.log.debug('execution failed', {
|
|
45
|
-
hash:
|
|
43
|
+
hash: artifact.hash,
|
|
46
44
|
error: parsed,
|
|
47
45
|
message: parsed.message
|
|
48
46
|
});
|
|
49
47
|
throw parsed;
|
|
50
48
|
}
|
|
51
49
|
this.log.debug('execution failed', {
|
|
52
|
-
hash:
|
|
50
|
+
hash: artifact.hash,
|
|
53
51
|
error: err
|
|
54
52
|
});
|
|
55
53
|
throw new Error(`Circuit execution failed: ${err}`);
|
|
56
54
|
}
|
|
57
55
|
}
|
|
58
|
-
async executeUserCircuit(
|
|
56
|
+
async executeUserCircuit(input, artifact, callback) {
|
|
59
57
|
await this.init();
|
|
60
|
-
return acvm(
|
|
58
|
+
return acvm(artifact.bytecode, input, callback);
|
|
61
59
|
}
|
|
62
60
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
1
|
+
import { type ForeignCallHandler } from '@aztec/noir-acvm_js';
|
|
3
2
|
import type { WitnessMap } from '@aztec/noir-types';
|
|
4
|
-
import type {
|
|
3
|
+
import type { FunctionArtifactWithContractName } from '@aztec/stdlib/abi';
|
|
4
|
+
import type { NoirCompiledCircuitWithName } from '@aztec/stdlib/noir';
|
|
5
5
|
import type { ACIRCallback, ACIRExecutionResult } from '../acvm/acvm.js';
|
|
6
6
|
import type { ACVMWitness } from '../acvm/acvm_types.js';
|
|
7
7
|
import { type SimulationProvider } from './simulation_provider.js';
|
|
@@ -13,7 +13,7 @@ import { type SimulationProvider } from './simulation_provider.js';
|
|
|
13
13
|
* It is only used in the context of server-side code executing simulated protocol circuits.
|
|
14
14
|
*/
|
|
15
15
|
export declare class WASMSimulatorWithBlobs implements SimulationProvider {
|
|
16
|
-
executeProtocolCircuit(input: WitnessMap,
|
|
17
|
-
executeUserCircuit(
|
|
16
|
+
executeProtocolCircuit(input: WitnessMap, artifact: NoirCompiledCircuitWithName, callback: ForeignCallHandler): Promise<WitnessMap>;
|
|
17
|
+
executeUserCircuit(_input: ACVMWitness, _artifact: FunctionArtifactWithContractName, _callback: ACIRCallback): Promise<ACIRExecutionResult>;
|
|
18
18
|
}
|
|
19
19
|
//# sourceMappingURL=acvm_wasm_with_blobs.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"acvm_wasm_with_blobs.d.ts","sourceRoot":"","sources":["../../../src/private/providers/acvm_wasm_with_blobs.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"acvm_wasm_with_blobs.d.ts","sourceRoot":"","sources":["../../../src/private/providers/acvm_wasm_with_blobs.ts"],"names":[],"mappings":"AAAA,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,iBAAiB,CAAC;AACzE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,KAAK,kBAAkB,EAAmB,MAAM,0BAA0B,CAAC;AAEpF;;;;;;GAMG;AACH,qBAAa,sBAAuB,YAAW,kBAAkB;IACzD,sBAAsB,CAC1B,KAAK,EAAE,UAAU,EACjB,QAAQ,EAAE,2BAA2B,EACrC,QAAQ,EAAE,kBAAkB,GAC3B,OAAO,CAAC,UAAU,CAAC;IAuBtB,kBAAkB,CAChB,MAAM,EAAE,WAAW,EACnB,SAAS,EAAE,gCAAgC,EAC3C,SAAS,EAAE,YAAY,GACtB,OAAO,CAAC,mBAAmB,CAAC;CAGhC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { executeCircuit } from '@aztec/noir-acvm_js';
|
|
2
|
-
import { foreignCallHandler } from '@aztec/noir-protocol-circuits-types/server';
|
|
3
2
|
import { enrichNoirError } from './simulation_provider.js';
|
|
4
3
|
/**
|
|
5
4
|
* A simulation provider that uses the WASM simulator with the ability to handle blobs via the foreign call handler.
|
|
@@ -8,25 +7,24 @@ import { enrichNoirError } from './simulation_provider.js';
|
|
|
8
7
|
*
|
|
9
8
|
* It is only used in the context of server-side code executing simulated protocol circuits.
|
|
10
9
|
*/ export class WASMSimulatorWithBlobs {
|
|
11
|
-
async executeProtocolCircuit(input,
|
|
12
|
-
// Execute the circuit on those initial witness values
|
|
13
|
-
//
|
|
10
|
+
async executeProtocolCircuit(input, artifact, callback) {
|
|
14
11
|
// Decode the bytecode from base64 since the acvm does not know about base64 encoding
|
|
15
|
-
const decodedBytecode = Buffer.from(
|
|
12
|
+
const decodedBytecode = Buffer.from(artifact.bytecode, 'base64');
|
|
16
13
|
//
|
|
17
14
|
// Execute the circuit
|
|
18
15
|
try {
|
|
19
|
-
const _witnessMap = await executeCircuit(decodedBytecode, input,
|
|
16
|
+
const _witnessMap = await executeCircuit(decodedBytecode, input, callback);
|
|
20
17
|
return _witnessMap;
|
|
21
18
|
} catch (err) {
|
|
22
|
-
// Typescript types
|
|
19
|
+
// Typescript types caught errors as unknown or any, so we need to narrow its type to check if it has raw
|
|
20
|
+
// assertion payload.
|
|
23
21
|
if (typeof err === 'object' && err !== null && 'rawAssertionPayload' in err) {
|
|
24
|
-
throw enrichNoirError(
|
|
22
|
+
throw enrichNoirError(artifact, err);
|
|
25
23
|
}
|
|
26
24
|
throw new Error(`Circuit execution failed: ${err}`);
|
|
27
25
|
}
|
|
28
26
|
}
|
|
29
|
-
executeUserCircuit(
|
|
27
|
+
executeUserCircuit(_input, _artifact, _callback) {
|
|
30
28
|
throw new Error('Not implemented');
|
|
31
29
|
}
|
|
32
30
|
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
3
|
+
import type { ForeignCallHandler } from '@aztec/noir-acvm_js';
|
|
4
|
+
import type { ACIRCallback } from '../../acvm/acvm.js';
|
|
5
|
+
import type { ACVMWitness } from '../../acvm/acvm_types.js';
|
|
6
|
+
/**
|
|
7
|
+
* Class responsible for recording circuit inputs necessary to replay the circuit. These inputs are the initial witness
|
|
8
|
+
* map and the oracle calls made during the circuit execution/witness generation.
|
|
9
|
+
*
|
|
10
|
+
* The recording is stored in a JSON file called `circuit_name_circuit_function_name_YYYY-MM-DD_N.json` where N is
|
|
11
|
+
* a counter to ensure unique filenames. The file is stored in the `recordDir` directory provided as a parameter to
|
|
12
|
+
* CircuitRecorder.start().
|
|
13
|
+
*
|
|
14
|
+
* Example recording file:
|
|
15
|
+
* ```json
|
|
16
|
+
* {
|
|
17
|
+
* "circuitName": "AMM",
|
|
18
|
+
* "functionName": "add_liquidity",
|
|
19
|
+
* "bytecodeMd5Hash": "b46c640ed38f20eac5f61a5e41d8dd1e",
|
|
20
|
+
* "timestamp": 1740691464360,
|
|
21
|
+
* "inputs": {
|
|
22
|
+
* "0": "0x1e89de1f0ad5204263733b7ddf65bec45b8f44714a4da85a46474dad677679ef",
|
|
23
|
+
* "1": "0x00f4d59c0ff773427bb0fed5b422557ca4dc5655abe53d31fa9408cb3c5a672f",
|
|
24
|
+
* "5": "0x000000000000000000000000000000000000000000000000000000000000000f"
|
|
25
|
+
* },
|
|
26
|
+
* "oracleCalls": [
|
|
27
|
+
* {
|
|
28
|
+
* "name": "loadCapsule",
|
|
29
|
+
* "inputs": [
|
|
30
|
+
* [
|
|
31
|
+
* "0x102422483bad6abd385948435667e144ac4c272576e325e7563608876cd446fd"
|
|
32
|
+
* ],
|
|
33
|
+
* [
|
|
34
|
+
* "0x000000000000000000000000000000000000000000000000000000000000004d"
|
|
35
|
+
* ],
|
|
36
|
+
* [
|
|
37
|
+
* "0x0000000000000000000000000000000000000000000000000000000000000001"
|
|
38
|
+
* ]
|
|
39
|
+
* ],
|
|
40
|
+
* "outputs": [
|
|
41
|
+
* "0x0000000000000000000000000000000000000000000000000000000000000000",
|
|
42
|
+
* [
|
|
43
|
+
* "0x0000000000000000000000000000000000000000000000000000000000000000"
|
|
44
|
+
* ]
|
|
45
|
+
* ]
|
|
46
|
+
* },
|
|
47
|
+
* {
|
|
48
|
+
* "name": "syncNotes",
|
|
49
|
+
* "inputs": []
|
|
50
|
+
* }
|
|
51
|
+
* ]
|
|
52
|
+
* }
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
export declare class CircuitRecorder {
|
|
56
|
+
#private;
|
|
57
|
+
private readonly filePath;
|
|
58
|
+
private readonly logger;
|
|
59
|
+
private isFirstCall;
|
|
60
|
+
private constructor();
|
|
61
|
+
/**
|
|
62
|
+
* Initializes a new circuit recording session.
|
|
63
|
+
* @param recordDir - Directory to store the recording
|
|
64
|
+
* @param input - Circuit input witness
|
|
65
|
+
* @param circuitBytecode - Compiled circuit bytecode
|
|
66
|
+
* @param circuitName - Name of the circuit
|
|
67
|
+
* @param functionName - Name of the circuit function (defaults to 'main'). This is meaningful only for
|
|
68
|
+
* contracts as protocol circuits artifacts always contain a single entrypoint function called 'main'.
|
|
69
|
+
* @returns A new CircuitRecorder instance
|
|
70
|
+
*/
|
|
71
|
+
static start(recordDir: string, input: ACVMWitness, circuitBytecode: Buffer, circuitName: string, functionName?: string): Promise<CircuitRecorder>;
|
|
72
|
+
/**
|
|
73
|
+
* Wraps a callback to record all oracle/foreign calls.
|
|
74
|
+
* @param callback - The original callback to wrap, either a user circuit callback or protocol circuit callback.
|
|
75
|
+
* @returns A wrapped callback that records all oracle interactions.
|
|
76
|
+
*/
|
|
77
|
+
wrapCallback(callback: ACIRCallback | ForeignCallHandler | undefined): ACIRCallback | ForeignCallHandler | undefined;
|
|
78
|
+
/**
|
|
79
|
+
* Finalizes the recording file by adding closing brackets. Without calling this method, the recording file is
|
|
80
|
+
* incomplete and it fails to parse.
|
|
81
|
+
*/
|
|
82
|
+
finish(): Promise<void>;
|
|
83
|
+
/**
|
|
84
|
+
* Finalizes the recording file by adding the error and closing brackets. Without calling this method or `finish`,
|
|
85
|
+
* the recording file is incomplete and it fails to parse.
|
|
86
|
+
* @param error - The error that occurred during circuit execution
|
|
87
|
+
*/
|
|
88
|
+
finishWithError(error: unknown): Promise<void>;
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=circuit_recorder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"circuit_recorder.d.ts","sourceRoot":"","sources":["../../../../src/private/providers/circuit_recording/circuit_recorder.ts"],"names":[],"mappings":";;AACA,OAAO,KAAK,EAAE,kBAAkB,EAAuC,MAAM,qBAAqB,CAAC;AAMnG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAG5D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,qBAAa,eAAe;;IAIN,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAH7C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA4C;IACnE,OAAO,CAAC,WAAW,CAAQ;IAE3B,OAAO;IAEP;;;;;;;;;OASG;WACU,KAAK,CAChB,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,WAAW,EAClB,eAAe,EAAE,MAAM,EACvB,WAAW,EAAE,MAAM,EACnB,YAAY,GAAE,MAAe,GAC5B,OAAO,CAAC,eAAe,CAAC;IAsE3B;;;;OAIG;IACH,YAAY,CAAC,QAAQ,EAAE,YAAY,GAAG,kBAAkB,GAAG,SAAS,GAAG,YAAY,GAAG,kBAAkB,GAAG,SAAS;IAkFpH;;;OAGG;IACG,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAQ7B;;;;OAIG;IACG,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;CASrD"}
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
2
|
+
import { createHash } from 'crypto';
|
|
3
|
+
import fs from 'fs/promises';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import { Oracle } from '../../acvm/oracle/oracle.js';
|
|
6
|
+
/**
|
|
7
|
+
* Class responsible for recording circuit inputs necessary to replay the circuit. These inputs are the initial witness
|
|
8
|
+
* map and the oracle calls made during the circuit execution/witness generation.
|
|
9
|
+
*
|
|
10
|
+
* The recording is stored in a JSON file called `circuit_name_circuit_function_name_YYYY-MM-DD_N.json` where N is
|
|
11
|
+
* a counter to ensure unique filenames. The file is stored in the `recordDir` directory provided as a parameter to
|
|
12
|
+
* CircuitRecorder.start().
|
|
13
|
+
*
|
|
14
|
+
* Example recording file:
|
|
15
|
+
* ```json
|
|
16
|
+
* {
|
|
17
|
+
* "circuitName": "AMM",
|
|
18
|
+
* "functionName": "add_liquidity",
|
|
19
|
+
* "bytecodeMd5Hash": "b46c640ed38f20eac5f61a5e41d8dd1e",
|
|
20
|
+
* "timestamp": 1740691464360,
|
|
21
|
+
* "inputs": {
|
|
22
|
+
* "0": "0x1e89de1f0ad5204263733b7ddf65bec45b8f44714a4da85a46474dad677679ef",
|
|
23
|
+
* "1": "0x00f4d59c0ff773427bb0fed5b422557ca4dc5655abe53d31fa9408cb3c5a672f",
|
|
24
|
+
* "5": "0x000000000000000000000000000000000000000000000000000000000000000f"
|
|
25
|
+
* },
|
|
26
|
+
* "oracleCalls": [
|
|
27
|
+
* {
|
|
28
|
+
* "name": "loadCapsule",
|
|
29
|
+
* "inputs": [
|
|
30
|
+
* [
|
|
31
|
+
* "0x102422483bad6abd385948435667e144ac4c272576e325e7563608876cd446fd"
|
|
32
|
+
* ],
|
|
33
|
+
* [
|
|
34
|
+
* "0x000000000000000000000000000000000000000000000000000000000000004d"
|
|
35
|
+
* ],
|
|
36
|
+
* [
|
|
37
|
+
* "0x0000000000000000000000000000000000000000000000000000000000000001"
|
|
38
|
+
* ]
|
|
39
|
+
* ],
|
|
40
|
+
* "outputs": [
|
|
41
|
+
* "0x0000000000000000000000000000000000000000000000000000000000000000",
|
|
42
|
+
* [
|
|
43
|
+
* "0x0000000000000000000000000000000000000000000000000000000000000000"
|
|
44
|
+
* ]
|
|
45
|
+
* ]
|
|
46
|
+
* },
|
|
47
|
+
* {
|
|
48
|
+
* "name": "syncNotes",
|
|
49
|
+
* "inputs": []
|
|
50
|
+
* }
|
|
51
|
+
* ]
|
|
52
|
+
* }
|
|
53
|
+
* ```
|
|
54
|
+
*/ export class CircuitRecorder {
|
|
55
|
+
filePath;
|
|
56
|
+
logger;
|
|
57
|
+
isFirstCall;
|
|
58
|
+
constructor(filePath){
|
|
59
|
+
this.filePath = filePath;
|
|
60
|
+
this.logger = createLogger('simulator:acvm:recording');
|
|
61
|
+
this.isFirstCall = true;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Initializes a new circuit recording session.
|
|
65
|
+
* @param recordDir - Directory to store the recording
|
|
66
|
+
* @param input - Circuit input witness
|
|
67
|
+
* @param circuitBytecode - Compiled circuit bytecode
|
|
68
|
+
* @param circuitName - Name of the circuit
|
|
69
|
+
* @param functionName - Name of the circuit function (defaults to 'main'). This is meaningful only for
|
|
70
|
+
* contracts as protocol circuits artifacts always contain a single entrypoint function called 'main'.
|
|
71
|
+
* @returns A new CircuitRecorder instance
|
|
72
|
+
*/ static async start(recordDir, input, circuitBytecode, circuitName, functionName = 'main') {
|
|
73
|
+
const recording = {
|
|
74
|
+
circuitName: circuitName,
|
|
75
|
+
functionName: functionName,
|
|
76
|
+
bytecodeMd5Hash: createHash('md5').update(circuitBytecode).digest('hex'),
|
|
77
|
+
timestamp: Date.now(),
|
|
78
|
+
inputs: Object.fromEntries(input)
|
|
79
|
+
};
|
|
80
|
+
const recordingStringWithoutClosingBracket = JSON.stringify(recording, null, 2).slice(0, -2);
|
|
81
|
+
try {
|
|
82
|
+
// Check if the recording directory exists and is a directory
|
|
83
|
+
const stats = await fs.stat(recordDir);
|
|
84
|
+
if (!stats.isDirectory()) {
|
|
85
|
+
throw new Error(`Recording path ${recordDir} exists but is not a directory`);
|
|
86
|
+
}
|
|
87
|
+
} catch (err) {
|
|
88
|
+
if (err.code === 'ENOENT') {
|
|
89
|
+
// The directory does not exist so we create it
|
|
90
|
+
await fs.mkdir(recordDir, {
|
|
91
|
+
recursive: true
|
|
92
|
+
});
|
|
93
|
+
} else {
|
|
94
|
+
throw err;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
const filePath = await CircuitRecorder.#computeFilePathAndStoreInitialRecording(recordDir, circuitName, functionName, recordingStringWithoutClosingBracket);
|
|
98
|
+
return new CircuitRecorder(filePath);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Computes a unique file path for the recording by trying different counter values.
|
|
102
|
+
* This is needed because multiple recordings of the same circuit could be happening simultaneously or an older
|
|
103
|
+
* recording might be present.
|
|
104
|
+
* @param recordDir - Directory to store the recording
|
|
105
|
+
* @param circuitName - Name of the circuit
|
|
106
|
+
* @param functionName - Name of the circuit function
|
|
107
|
+
* @param recordingContent - Initial recording content
|
|
108
|
+
* @returns A unique file path for the recording
|
|
109
|
+
*/ static async #computeFilePathAndStoreInitialRecording(recordDir, circuitName, functionName, recordingContent) {
|
|
110
|
+
let counter = 0;
|
|
111
|
+
while(true){
|
|
112
|
+
try {
|
|
113
|
+
const filePath = getFilePath(recordDir, circuitName, functionName, counter);
|
|
114
|
+
// Write the initial recording content to the file
|
|
115
|
+
await fs.writeFile(filePath, recordingContent + ',\n "oracleCalls": [\n', {
|
|
116
|
+
flag: 'wx'
|
|
117
|
+
});
|
|
118
|
+
return filePath;
|
|
119
|
+
} catch (err) {
|
|
120
|
+
if (err.code === 'EEXIST') {
|
|
121
|
+
counter++;
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
throw err;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Wraps a callback to record all oracle/foreign calls.
|
|
130
|
+
* @param callback - The original callback to wrap, either a user circuit callback or protocol circuit callback.
|
|
131
|
+
* @returns A wrapped callback that records all oracle interactions.
|
|
132
|
+
*/ wrapCallback(callback) {
|
|
133
|
+
if (!callback) {
|
|
134
|
+
return undefined;
|
|
135
|
+
}
|
|
136
|
+
if (this.#isACIRCallback(callback)) {
|
|
137
|
+
return this.#wrapUserCircuitCallback(callback);
|
|
138
|
+
}
|
|
139
|
+
return this.#wrapProtocolCircuitCallback(callback);
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Type guard to check if a callback is an ACIRCallback.
|
|
143
|
+
*/ #isACIRCallback(callback) {
|
|
144
|
+
return typeof callback === 'object' && callback !== null && !('call' in callback);
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Wraps a user circuit callback to record all oracle calls.
|
|
148
|
+
* @param callback - The original circuit callback.
|
|
149
|
+
* @returns A wrapped callback that records all oracle interactions which is to be provided to the ACVM.
|
|
150
|
+
*/ #wrapUserCircuitCallback(callback) {
|
|
151
|
+
const recordingCallback = {};
|
|
152
|
+
const oracleMethods = Object.getOwnPropertyNames(Oracle.prototype).filter((name)=>name !== 'constructor');
|
|
153
|
+
for (const name of oracleMethods){
|
|
154
|
+
const fn = callback[name];
|
|
155
|
+
if (!fn) {
|
|
156
|
+
throw new Error(`Oracle method ${name} not found when setting up recording callback`);
|
|
157
|
+
}
|
|
158
|
+
recordingCallback[name] = (...args)=>{
|
|
159
|
+
const result = fn.call(callback, ...args);
|
|
160
|
+
if (result instanceof Promise) {
|
|
161
|
+
return result.then(async (r)=>{
|
|
162
|
+
await this.#recordCall(name, args, r);
|
|
163
|
+
return r;
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
void this.#recordCall(name, args, result);
|
|
167
|
+
return result;
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
return recordingCallback;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Wraps a protocol circuit callback to record all oracle calls.
|
|
174
|
+
* @param callback - The original oracle circuit callback.
|
|
175
|
+
* @returns A wrapped handler that records all oracle interactions which is to be provided to the ACVM.
|
|
176
|
+
*/ #wrapProtocolCircuitCallback(callback) {
|
|
177
|
+
return async (name, inputs)=>{
|
|
178
|
+
const result = await callback(name, inputs);
|
|
179
|
+
await this.#recordCall(name, inputs, result);
|
|
180
|
+
return result;
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Records a single oracle/foreign call with its inputs and outputs.
|
|
185
|
+
* @param name - Name of the call
|
|
186
|
+
* @param inputs - Input arguments
|
|
187
|
+
* @param outputs - Output results
|
|
188
|
+
*/ async #recordCall(name, inputs, outputs) {
|
|
189
|
+
try {
|
|
190
|
+
const entry = {
|
|
191
|
+
name,
|
|
192
|
+
inputs,
|
|
193
|
+
outputs
|
|
194
|
+
};
|
|
195
|
+
const prefix = this.isFirstCall ? ' ' : ' ,';
|
|
196
|
+
this.isFirstCall = false;
|
|
197
|
+
await fs.appendFile(this.filePath, prefix + JSON.stringify(entry) + '\n');
|
|
198
|
+
} catch (err) {
|
|
199
|
+
this.logger.error('Failed to log circuit call', {
|
|
200
|
+
error: err
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Finalizes the recording file by adding closing brackets. Without calling this method, the recording file is
|
|
206
|
+
* incomplete and it fails to parse.
|
|
207
|
+
*/ async finish() {
|
|
208
|
+
try {
|
|
209
|
+
await fs.appendFile(this.filePath, ' ]\n}\n');
|
|
210
|
+
} catch (err) {
|
|
211
|
+
this.logger.error('Failed to finalize recording file', {
|
|
212
|
+
error: err
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Finalizes the recording file by adding the error and closing brackets. Without calling this method or `finish`,
|
|
218
|
+
* the recording file is incomplete and it fails to parse.
|
|
219
|
+
* @param error - The error that occurred during circuit execution
|
|
220
|
+
*/ async finishWithError(error) {
|
|
221
|
+
try {
|
|
222
|
+
await fs.appendFile(this.filePath, ' ],\n');
|
|
223
|
+
await fs.appendFile(this.filePath, ` "error": ${JSON.stringify(error)}\n`);
|
|
224
|
+
await fs.appendFile(this.filePath, '}\n');
|
|
225
|
+
} catch (err) {
|
|
226
|
+
this.logger.error('Failed to finalize recording file with error', {
|
|
227
|
+
error: err
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Generates a file path for storing circuit recordings. The format of the filename is:
|
|
234
|
+
* `circuit_name_circuit_function_name_YYYY-MM-DD_N.json` where N is a counter to ensure unique filenames.
|
|
235
|
+
* @param recordDir - Base directory for recordings
|
|
236
|
+
* @param circuitName - Name of the circuit
|
|
237
|
+
* @param functionName - Name of the circuit function
|
|
238
|
+
* @param counter - Counter to ensure unique filenames. This is expected to be incremented in a loop until there is no
|
|
239
|
+
* existing file with the same name.
|
|
240
|
+
* @returns A file path for the recording.
|
|
241
|
+
*/ function getFilePath(recordDir, circuitName, functionName, counter) {
|
|
242
|
+
const date = new Date();
|
|
243
|
+
const formattedDate = date.toISOString().split('T')[0];
|
|
244
|
+
const filename = `${circuitName}_${functionName}_${formattedDate}_${counter}.json`;
|
|
245
|
+
return path.join(recordDir, filename);
|
|
246
|
+
}
|