@aztec/simulator 0.78.1 → 0.79.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/client.d.ts +1 -1
- package/dest/client.d.ts.map +1 -1
- package/dest/common/errors.d.ts +1 -1
- package/dest/common/errors.d.ts.map +1 -1
- package/dest/common/errors.js +1 -1
- package/dest/private/acvm/acvm.d.ts +1 -1
- package/dest/private/acvm/acvm.d.ts.map +1 -1
- package/dest/private/acvm/acvm.js +1 -1
- package/dest/private/acvm/acvm_types.d.ts +1 -1
- package/dest/private/acvm/acvm_types.d.ts.map +1 -1
- package/dest/private/providers/acvm_native.d.ts +1 -1
- package/dest/private/providers/acvm_native.d.ts.map +1 -1
- package/dest/private/providers/acvm_wasm.d.ts +1 -1
- package/dest/private/providers/acvm_wasm.d.ts.map +1 -1
- package/dest/private/providers/acvm_wasm.js +4 -4
- package/dest/private/providers/acvm_wasm_with_blobs.d.ts +1 -1
- package/dest/private/providers/acvm_wasm_with_blobs.d.ts.map +1 -1
- package/dest/private/providers/acvm_wasm_with_blobs.js +3 -3
- package/dest/private/providers/simulation_provider.d.ts +6 -5
- package/dest/private/providers/simulation_provider.d.ts.map +1 -1
- package/dest/private/providers/simulation_provider.js +25 -4
- package/package.json +16 -16
- package/src/client.ts +1 -1
- package/src/common/errors.ts +2 -3
- package/src/private/acvm/acvm.ts +3 -4
- package/src/private/acvm/acvm_types.ts +1 -1
- package/src/private/providers/acvm_native.ts +1 -1
- package/src/private/providers/acvm_wasm.ts +5 -6
- package/src/private/providers/acvm_wasm_with_blobs.ts +4 -5
- package/src/private/providers/simulation_provider.ts +31 -10
package/dest/client.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export * from './private/index.js';
|
|
2
2
|
export { WASMSimulator } from './private/providers/acvm_wasm.js';
|
|
3
|
-
export { type SimulationProvider } from './private/providers/simulation_provider.js';
|
|
3
|
+
export { type SimulationProvider, type DecodedError } from './private/providers/simulation_provider.js';
|
|
4
4
|
export * from './common/index.js';
|
|
5
5
|
//# 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,oBAAoB,CAAC;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACjE,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,4CAA4C,CAAC;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACjE,OAAO,EAAE,KAAK,kBAAkB,EAAE,KAAK,YAAY,EAAE,MAAM,4CAA4C,CAAC;AACxG,cAAc,mBAAmB,CAAC"}
|
package/dest/common/errors.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Fr } from '@aztec/foundation/fields';
|
|
2
|
+
import type { RawAssertionPayload } from '@aztec/noir-acvm_js';
|
|
2
3
|
import type { BrilligFunctionId, FunctionAbi, FunctionDebugMetadata, OpcodeLocation } from '@aztec/stdlib/abi';
|
|
3
4
|
import { type FailingFunction, type NoirCallStack, SimulationError, type SourceCodeLocation } from '@aztec/stdlib/errors';
|
|
4
|
-
import type { RawAssertionPayload } from '@noir-lang/acvm_js';
|
|
5
5
|
/**
|
|
6
6
|
* An error that occurred during the execution of a function.
|
|
7
7
|
* @param message - the error message
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/common/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAEnD,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,qBAAqB,EAAE,cAAc,EAAE,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,EAAE,GAAG,EAAE,WAAW,GAAG,MAAM,GAAG,SAAS,CAW/G;AAED,wBAAgB,qCAAqC,CAAC,UAAU,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,WAAW,GAAG,MAAM,GAAG,SAAS,CAc5G;AAED,wBAAgB,gCAAgC,CAAC,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,WAAW,GAAG,MAAM,CAMrF"}
|
package/dest/common/errors.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsonStringify } from '@aztec/foundation/json-rpc';
|
|
2
|
+
import { abiDecodeError } from '@aztec/noir-noirc_abi';
|
|
2
3
|
import { SimulationError } from '@aztec/stdlib/errors';
|
|
3
|
-
import { abiDecodeError } from '@noir-lang/noirc_abi';
|
|
4
4
|
/**
|
|
5
5
|
* An error that occurred during the execution of a function.
|
|
6
6
|
* @param message - the error message
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/// <reference types="node" resolution-mode="require"/>
|
|
2
2
|
/// <reference types="node" resolution-mode="require"/>
|
|
3
|
+
import { type ExecutionError, type ForeignCallInput, type ForeignCallOutput } from '@aztec/noir-acvm_js';
|
|
3
4
|
import type { FunctionDebugMetadata } from '@aztec/stdlib/abi';
|
|
4
5
|
import type { NoirCallStack } from '@aztec/stdlib/errors';
|
|
5
|
-
import { type ExecutionError, type ForeignCallInput, type ForeignCallOutput } from '@noir-lang/acvm_js';
|
|
6
6
|
import type { ACVMWitness } from './acvm_types.js';
|
|
7
7
|
import type { ORACLE_NAMES } from './oracle/index.js';
|
|
8
8
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"acvm.d.ts","sourceRoot":"","sources":["../../../src/private/acvm/acvm.ts"],"names":[],"mappings":";;AACA,OAAO,KAAK,
|
|
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;AACnD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,CAC/B,YAAY,EACZ,CACE,GAAG,IAAI,EAAE,gBAAgB,EAAE,KAEzB,IAAI,GACJ,OAAO,CAAC,IAAI,CAAC,GACb,iBAAiB,GACjB,iBAAiB,EAAE,GACnB,OAAO,CAAC,iBAAiB,CAAC,GAC1B,OAAO,CAAC,iBAAiB,EAAE,CAAC,CACjC,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;;OAIG;IACH,cAAc,EAAE,WAAW,CAAC;IAC5B,aAAa,EAAE,WAAW,CAAC;CAC5B;AAED;;GAEG;AACH,wBAAsB,IAAI,CACxB,IAAI,EAAE,MAAM,EACZ,cAAc,EAAE,WAAW,EAC3B,QAAQ,EAAE,YAAY,GACrB,OAAO,CAAC,mBAAmB,CAAC,CAkD9B;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,KAAK,GAAG,cAAc,EAC7B,KAAK,CAAC,EAAE,qBAAqB,GAC5B,aAAa,GAAG,SAAS,CAc3B"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createLogger } from '@aztec/foundation/log';
|
|
2
|
-
import { executeCircuitWithReturnWitness } from '@noir-
|
|
2
|
+
import { executeCircuitWithReturnWitness } from '@aztec/noir-acvm_js';
|
|
3
3
|
import { resolveOpcodeLocations, traverseCauseChain } from '../../common/errors.js';
|
|
4
4
|
/**
|
|
5
5
|
* The function call that executes an ACIR.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"acvm_types.d.ts","sourceRoot":"","sources":["../../../src/private/acvm/acvm_types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"acvm_types.d.ts","sourceRoot":"","sources":["../../../src/private/acvm/acvm_types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEtD;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC;AAE/B;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" resolution-mode="require"/>
|
|
2
2
|
/// <reference types="node" resolution-mode="require"/>
|
|
3
|
+
import type { WitnessMap } from '@aztec/noir-types';
|
|
3
4
|
import type { NoirCompiledCircuit } from '@aztec/stdlib/noir';
|
|
4
|
-
import type { WitnessMap } from '@noir-lang/types';
|
|
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';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"acvm_native.d.ts","sourceRoot":"","sources":["../../../src/private/providers/acvm_native.ts"],"names":[],"mappings":";;AAGA,OAAO,KAAK,EAAE,
|
|
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,mBAAmB,CAAC;AACpD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAK9D,OAAO,KAAK,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACzE,OAAO,KAAK,EAAE,WAAW,EAAE,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type { WitnessMap } from '@aztec/noir-types';
|
|
3
4
|
import type { NoirCompiledCircuit } from '@aztec/stdlib/noir';
|
|
4
|
-
import type { WitnessMap } from '@noir-lang/types';
|
|
5
5
|
import { type ACIRCallback } from '../acvm/acvm.js';
|
|
6
6
|
import type { ACVMWitness } from '../acvm/acvm_types.js';
|
|
7
7
|
import { type SimulationProvider } from './simulation_provider.js';
|
|
@@ -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":";;AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAE9D,OAAO,EAAE,KAAK,YAAY,EAAQ,MAAM,iBAAiB,CAAC;AAC1D,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,CAAC,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,mBAAmB,GAAG,OAAO,CAAC,UAAU,CAAC;IAiCpG,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,cAAc,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY;CAI3F"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { createLogger } from '@aztec/foundation/log';
|
|
2
|
+
import initACVM, { executeCircuit } from '@aztec/noir-acvm_js';
|
|
3
|
+
import initAbi from '@aztec/noir-noirc_abi';
|
|
2
4
|
import { foreignCallHandler } from '@aztec/noir-protocol-circuits-types/client';
|
|
3
|
-
import initACVM, { executeCircuit } from '@noir-lang/acvm_js';
|
|
4
|
-
import initAbi from '@noir-lang/noirc_abi';
|
|
5
5
|
import { acvm } from '../acvm/acvm.js';
|
|
6
|
-
import {
|
|
6
|
+
import { enrichNoirError } from './simulation_provider.js';
|
|
7
7
|
export class WASMSimulator {
|
|
8
8
|
log;
|
|
9
9
|
constructor(log = createLogger('wasm-simulator')){
|
|
@@ -40,7 +40,7 @@ export class WASMSimulator {
|
|
|
40
40
|
} catch (err) {
|
|
41
41
|
// Typescript types catched errors as unknown or any, so we need to narrow its type to check if it has raw assertion payload.
|
|
42
42
|
if (typeof err === 'object' && err !== null && 'rawAssertionPayload' in err) {
|
|
43
|
-
const parsed =
|
|
43
|
+
const parsed = enrichNoirError(compiledCircuit, err);
|
|
44
44
|
this.log.debug('execution failed', {
|
|
45
45
|
hash: compiledCircuit.hash,
|
|
46
46
|
error: parsed,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" resolution-mode="require"/>
|
|
2
2
|
/// <reference types="node" resolution-mode="require"/>
|
|
3
|
+
import type { WitnessMap } from '@aztec/noir-types';
|
|
3
4
|
import type { NoirCompiledCircuit } from '@aztec/stdlib/noir';
|
|
4
|
-
import type { WitnessMap } from '@noir-lang/types';
|
|
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';
|
|
@@ -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":";;AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAE9D,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,CAAC,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,mBAAmB,GAAG,OAAO,CAAC,UAAU,CAAC;IAwB1G,kBAAkB,CAChB,KAAK,EAAE,MAAM,EACb,eAAe,EAAE,WAAW,EAC5B,SAAS,EAAE,YAAY,GACtB,OAAO,CAAC,mBAAmB,CAAC;CAGhC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { executeCircuit } from '@aztec/noir-acvm_js';
|
|
1
2
|
import { foreignCallHandler } from '@aztec/noir-protocol-circuits-types/server';
|
|
2
|
-
import {
|
|
3
|
-
import { parseErrorPayload } from './simulation_provider.js';
|
|
3
|
+
import { enrichNoirError } from './simulation_provider.js';
|
|
4
4
|
/**
|
|
5
5
|
* A simulation provider 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
|
|
@@ -21,7 +21,7 @@ import { parseErrorPayload } from './simulation_provider.js';
|
|
|
21
21
|
} catch (err) {
|
|
22
22
|
// Typescript types catched errors as unknown or any, so we need to narrow its type to check if it has raw assertion payload.
|
|
23
23
|
if (typeof err === 'object' && err !== null && 'rawAssertionPayload' in err) {
|
|
24
|
-
throw
|
|
24
|
+
throw enrichNoirError(compiledCircuit, err);
|
|
25
25
|
}
|
|
26
26
|
throw new Error(`Circuit execution failed: ${err}`);
|
|
27
27
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/// <reference types="node" resolution-mode="require"/>
|
|
2
2
|
/// <reference types="node" resolution-mode="require"/>
|
|
3
|
+
import type { ExecutionError } from '@aztec/noir-acvm_js';
|
|
4
|
+
import type { WitnessMap } from '@aztec/noir-types';
|
|
3
5
|
import type { NoirCompiledCircuit } from '@aztec/stdlib/noir';
|
|
4
|
-
import type
|
|
5
|
-
import type { Abi, WitnessMap } from '@noir-lang/types';
|
|
6
|
-
import type { ACIRCallback, ACIRExecutionResult } from '../acvm/acvm.js';
|
|
6
|
+
import { type ACIRCallback, type ACIRExecutionResult } from '../acvm/acvm.js';
|
|
7
7
|
import type { ACVMWitness } from '../acvm/acvm_types.js';
|
|
8
8
|
/**
|
|
9
9
|
* Low level simulation interface
|
|
@@ -12,8 +12,9 @@ export interface SimulationProvider {
|
|
|
12
12
|
executeProtocolCircuit(input: WitnessMap, compiledCircuit: NoirCompiledCircuit): Promise<WitnessMap>;
|
|
13
13
|
executeUserCircuit(acir: Buffer, initialWitness: ACVMWitness, callback: ACIRCallback): Promise<ACIRExecutionResult>;
|
|
14
14
|
}
|
|
15
|
-
export type
|
|
15
|
+
export type DecodedError = ExecutionError & {
|
|
16
16
|
decodedAssertionPayload?: any;
|
|
17
|
+
noirCallStack?: string[];
|
|
17
18
|
};
|
|
18
|
-
export declare function
|
|
19
|
+
export declare function enrichNoirError(artifact: NoirCompiledCircuit, originalError: ExecutionError): DecodedError;
|
|
19
20
|
//# sourceMappingURL=simulation_provider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"simulation_provider.d.ts","sourceRoot":"","sources":["../../../src/private/providers/simulation_provider.ts"],"names":[],"mappings":";;AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"simulation_provider.d.ts","sourceRoot":"","sources":["../../../src/private/providers/simulation_provider.ts"],"names":[],"mappings":";;AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAE9D,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,mBAAmB,EAAoB,MAAM,iBAAiB,CAAC;AAChG,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEzD;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,sBAAsB,CAAC,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,mBAAmB,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IACrG,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,cAAc,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;CACrH;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,CA4C1G"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { abiDecodeError } from '@noir-
|
|
2
|
-
|
|
1
|
+
import { abiDecodeError } from '@aztec/noir-noirc_abi';
|
|
2
|
+
import { parseDebugSymbols } from '@aztec/stdlib/abi';
|
|
3
|
+
import { extractCallStack } from '../acvm/acvm.js';
|
|
4
|
+
// Payload parsing taken from noir/noir-repo/tooling/noir_js/src/witness_generation.ts.
|
|
3
5
|
// TODO: import this in isolation without having to import noir_js in its entirety.
|
|
4
|
-
export function
|
|
6
|
+
export function enrichNoirError(artifact, originalError) {
|
|
5
7
|
const payload = originalError.rawAssertionPayload;
|
|
6
8
|
if (!payload) {
|
|
7
9
|
return originalError;
|
|
@@ -9,7 +11,7 @@ export function parseErrorPayload(abi, originalError) {
|
|
|
9
11
|
const enrichedError = originalError;
|
|
10
12
|
try {
|
|
11
13
|
// Decode the payload
|
|
12
|
-
const decodedPayload = abiDecodeError(abi, payload);
|
|
14
|
+
const decodedPayload = abiDecodeError(artifact.abi, payload);
|
|
13
15
|
if (typeof decodedPayload === 'string') {
|
|
14
16
|
// If it's a string, just add it to the error message
|
|
15
17
|
enrichedError.message = `Circuit execution failed: ${decodedPayload}`;
|
|
@@ -20,5 +22,24 @@ export function parseErrorPayload(abi, originalError) {
|
|
|
20
22
|
} catch (_errorDecoding) {
|
|
21
23
|
// Ignore errors decoding the payload
|
|
22
24
|
}
|
|
25
|
+
try {
|
|
26
|
+
// Decode the callstack
|
|
27
|
+
const callStack = extractCallStack(originalError, {
|
|
28
|
+
// TODO(https://github.com/AztecProtocol/aztec-packages/issues/5813)
|
|
29
|
+
// We only support handling debug info for the circuit entry point.
|
|
30
|
+
// So for now we simply index into the first debug info.
|
|
31
|
+
debugSymbols: parseDebugSymbols(artifact.debug_symbols)[0],
|
|
32
|
+
files: artifact.file_map
|
|
33
|
+
});
|
|
34
|
+
enrichedError.noirCallStack = callStack?.map((errorLocation)=>{
|
|
35
|
+
if (typeof errorLocation === 'string') {
|
|
36
|
+
return `at opcode ${errorLocation}`;
|
|
37
|
+
} else {
|
|
38
|
+
return `at ${errorLocation.locationText} (${errorLocation.filePath}:${errorLocation.line}:${errorLocation.column})`;
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
} catch (_errorResolving) {
|
|
42
|
+
// Ignore errors resolving the callstack
|
|
43
|
+
}
|
|
23
44
|
return enrichedError;
|
|
24
45
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/simulator",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.79.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./server": "./dest/server.js",
|
|
@@ -59,26 +59,26 @@
|
|
|
59
59
|
]
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"@aztec/constants": "0.
|
|
63
|
-
"@aztec/foundation": "0.
|
|
64
|
-
"@aztec/noir-
|
|
65
|
-
"@aztec/
|
|
66
|
-
"@aztec/
|
|
67
|
-
"@aztec/
|
|
68
|
-
"@aztec/
|
|
62
|
+
"@aztec/constants": "0.79.0",
|
|
63
|
+
"@aztec/foundation": "0.79.0",
|
|
64
|
+
"@aztec/noir-acvm_js": "0.79.0",
|
|
65
|
+
"@aztec/noir-noirc_abi": "0.79.0",
|
|
66
|
+
"@aztec/noir-protocol-circuits-types": "0.79.0",
|
|
67
|
+
"@aztec/noir-types": "0.79.0",
|
|
68
|
+
"@aztec/protocol-contracts": "0.79.0",
|
|
69
|
+
"@aztec/stdlib": "0.79.0",
|
|
70
|
+
"@aztec/telemetry-client": "0.79.0",
|
|
71
|
+
"@aztec/world-state": "0.79.0",
|
|
69
72
|
"levelup": "^5.1.1",
|
|
70
73
|
"lodash.clonedeep": "^4.5.0",
|
|
71
74
|
"lodash.merge": "^4.6.2",
|
|
72
75
|
"memdown": "^6.1.1",
|
|
73
|
-
"tslib": "^2.4.0"
|
|
74
|
-
"@aztec/noir-acvm_js": "0.78.1",
|
|
75
|
-
"@aztec/noir-noirc_abi": "0.78.1",
|
|
76
|
-
"@aztec/noir-types": "0.78.1"
|
|
76
|
+
"tslib": "^2.4.0"
|
|
77
77
|
},
|
|
78
78
|
"devDependencies": {
|
|
79
|
-
"@aztec/kv-store": "0.
|
|
80
|
-
"@aztec/merkle-tree": "0.
|
|
81
|
-
"@aztec/noir-contracts.js": "0.
|
|
79
|
+
"@aztec/kv-store": "0.79.0",
|
|
80
|
+
"@aztec/merkle-tree": "0.79.0",
|
|
81
|
+
"@aztec/noir-contracts.js": "0.79.0",
|
|
82
82
|
"@jest/globals": "^29.5.0",
|
|
83
83
|
"@types/jest": "^29.5.0",
|
|
84
84
|
"@types/levelup": "^5.1.3",
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
"jest-mock-extended": "^3.0.4",
|
|
91
91
|
"ts-node": "^10.9.1",
|
|
92
92
|
"typescript": "^5.0.4",
|
|
93
|
-
"viem": "2.
|
|
93
|
+
"viem": "2.23.7"
|
|
94
94
|
},
|
|
95
95
|
"files": [
|
|
96
96
|
"dest",
|
package/src/client.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export * from './private/index.js';
|
|
2
2
|
export { WASMSimulator } from './private/providers/acvm_wasm.js';
|
|
3
|
-
export { type SimulationProvider } from './private/providers/simulation_provider.js';
|
|
3
|
+
export { type SimulationProvider, type DecodedError } from './private/providers/simulation_provider.js';
|
|
4
4
|
export * from './common/index.js';
|
package/src/common/errors.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { Fr } from '@aztec/foundation/fields';
|
|
2
2
|
import { jsonStringify } from '@aztec/foundation/json-rpc';
|
|
3
|
+
import type { RawAssertionPayload } from '@aztec/noir-acvm_js';
|
|
4
|
+
import { abiDecodeError } from '@aztec/noir-noirc_abi';
|
|
3
5
|
import type { BrilligFunctionId, FunctionAbi, FunctionDebugMetadata, OpcodeLocation } from '@aztec/stdlib/abi';
|
|
4
6
|
import {
|
|
5
7
|
type FailingFunction,
|
|
@@ -8,9 +10,6 @@ import {
|
|
|
8
10
|
type SourceCodeLocation,
|
|
9
11
|
} from '@aztec/stdlib/errors';
|
|
10
12
|
|
|
11
|
-
import type { RawAssertionPayload } from '@noir-lang/acvm_js';
|
|
12
|
-
import { abiDecodeError } from '@noir-lang/noirc_abi';
|
|
13
|
-
|
|
14
13
|
/**
|
|
15
14
|
* An error that occurred during the execution of a function.
|
|
16
15
|
* @param message - the error message
|
package/src/private/acvm/acvm.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { createLogger } from '@aztec/foundation/log';
|
|
2
|
-
import type { FunctionDebugMetadata } from '@aztec/stdlib/abi';
|
|
3
|
-
import type { NoirCallStack } from '@aztec/stdlib/errors';
|
|
4
|
-
|
|
5
2
|
import {
|
|
6
3
|
type ExecutionError,
|
|
7
4
|
type ForeignCallInput,
|
|
8
5
|
type ForeignCallOutput,
|
|
9
6
|
executeCircuitWithReturnWitness,
|
|
10
|
-
} from '@noir-
|
|
7
|
+
} from '@aztec/noir-acvm_js';
|
|
8
|
+
import type { FunctionDebugMetadata } from '@aztec/stdlib/abi';
|
|
9
|
+
import type { NoirCallStack } from '@aztec/stdlib/errors';
|
|
11
10
|
|
|
12
11
|
import { resolveOpcodeLocations, traverseCauseChain } from '../../common/errors.js';
|
|
13
12
|
import type { ACVMWitness } from './acvm_types.js';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { runInDirectory } from '@aztec/foundation/fs';
|
|
2
2
|
import { createLogger } from '@aztec/foundation/log';
|
|
3
3
|
import { Timer } from '@aztec/foundation/timer';
|
|
4
|
+
import type { WitnessMap } from '@aztec/noir-types';
|
|
4
5
|
import type { NoirCompiledCircuit } from '@aztec/stdlib/noir';
|
|
5
6
|
|
|
6
|
-
import type { WitnessMap } from '@noir-lang/types';
|
|
7
7
|
import * as proc from 'child_process';
|
|
8
8
|
import { promises as fs } from 'fs';
|
|
9
9
|
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { createLogger } from '@aztec/foundation/log';
|
|
2
|
+
import initACVM, { type ExecutionError, executeCircuit } from '@aztec/noir-acvm_js';
|
|
3
|
+
import initAbi from '@aztec/noir-noirc_abi';
|
|
2
4
|
import { foreignCallHandler } from '@aztec/noir-protocol-circuits-types/client';
|
|
5
|
+
import type { WitnessMap } from '@aztec/noir-types';
|
|
3
6
|
import type { NoirCompiledCircuit } from '@aztec/stdlib/noir';
|
|
4
7
|
|
|
5
|
-
import initACVM, { type ExecutionError, executeCircuit } from '@noir-lang/acvm_js';
|
|
6
|
-
import initAbi from '@noir-lang/noirc_abi';
|
|
7
|
-
import type { WitnessMap } from '@noir-lang/types';
|
|
8
|
-
|
|
9
8
|
import { type ACIRCallback, acvm } from '../acvm/acvm.js';
|
|
10
9
|
import type { ACVMWitness } from '../acvm/acvm_types.js';
|
|
11
|
-
import { type SimulationProvider,
|
|
10
|
+
import { type SimulationProvider, enrichNoirError } from './simulation_provider.js';
|
|
12
11
|
|
|
13
12
|
export class WASMSimulator implements SimulationProvider {
|
|
14
13
|
constructor(protected log = createLogger('wasm-simulator')) {}
|
|
@@ -43,7 +42,7 @@ export class WASMSimulator implements SimulationProvider {
|
|
|
43
42
|
} catch (err) {
|
|
44
43
|
// Typescript types catched errors as unknown or any, so we need to narrow its type to check if it has raw assertion payload.
|
|
45
44
|
if (typeof err === 'object' && err !== null && 'rawAssertionPayload' in err) {
|
|
46
|
-
const parsed =
|
|
45
|
+
const parsed = enrichNoirError(compiledCircuit, err as ExecutionError);
|
|
47
46
|
this.log.debug('execution failed', {
|
|
48
47
|
hash: compiledCircuit.hash,
|
|
49
48
|
error: parsed,
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
+
import { type ExecutionError, executeCircuit } from '@aztec/noir-acvm_js';
|
|
1
2
|
import { foreignCallHandler } from '@aztec/noir-protocol-circuits-types/server';
|
|
3
|
+
import type { WitnessMap } from '@aztec/noir-types';
|
|
2
4
|
import type { NoirCompiledCircuit } from '@aztec/stdlib/noir';
|
|
3
5
|
|
|
4
|
-
import { type ExecutionError, executeCircuit } from '@noir-lang/acvm_js';
|
|
5
|
-
import type { WitnessMap } from '@noir-lang/types';
|
|
6
|
-
|
|
7
6
|
import type { ACIRCallback, ACIRExecutionResult } from '../acvm/acvm.js';
|
|
8
7
|
import type { ACVMWitness } from '../acvm/acvm_types.js';
|
|
9
|
-
import { type SimulationProvider,
|
|
8
|
+
import { type SimulationProvider, enrichNoirError } from './simulation_provider.js';
|
|
10
9
|
|
|
11
10
|
/**
|
|
12
11
|
* A simulation provider that uses the WASM simulator with the ability to handle blobs via the foreign call handler.
|
|
@@ -34,7 +33,7 @@ export class WASMSimulatorWithBlobs implements SimulationProvider {
|
|
|
34
33
|
} catch (err) {
|
|
35
34
|
// Typescript types catched errors as unknown or any, so we need to narrow its type to check if it has raw assertion payload.
|
|
36
35
|
if (typeof err === 'object' && err !== null && 'rawAssertionPayload' in err) {
|
|
37
|
-
throw
|
|
36
|
+
throw enrichNoirError(compiledCircuit, err as ExecutionError);
|
|
38
37
|
}
|
|
39
38
|
throw new Error(`Circuit execution failed: ${err}`);
|
|
40
39
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import type { ExecutionError } from '@aztec/noir-acvm_js';
|
|
2
|
+
import { abiDecodeError } from '@aztec/noir-noirc_abi';
|
|
3
|
+
import type { WitnessMap } from '@aztec/noir-types';
|
|
4
|
+
import { parseDebugSymbols } from '@aztec/stdlib/abi';
|
|
1
5
|
import type { NoirCompiledCircuit } from '@aztec/stdlib/noir';
|
|
2
6
|
|
|
3
|
-
import type
|
|
4
|
-
import { abiDecodeError } from '@noir-lang/noirc_abi';
|
|
5
|
-
import type { Abi, WitnessMap } from '@noir-lang/types';
|
|
6
|
-
|
|
7
|
-
import type { ACIRCallback, ACIRExecutionResult } from '../acvm/acvm.js';
|
|
7
|
+
import { type ACIRCallback, type ACIRExecutionResult, extractCallStack } from '../acvm/acvm.js';
|
|
8
8
|
import type { ACVMWitness } from '../acvm/acvm_types.js';
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -15,20 +15,20 @@ export interface SimulationProvider {
|
|
|
15
15
|
executeUserCircuit(acir: Buffer, initialWitness: ACVMWitness, callback: ACIRCallback): Promise<ACIRExecutionResult>;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
export type
|
|
18
|
+
export type DecodedError = ExecutionError & { decodedAssertionPayload?: any; noirCallStack?: string[] };
|
|
19
19
|
|
|
20
|
-
//
|
|
20
|
+
// Payload parsing taken from noir/noir-repo/tooling/noir_js/src/witness_generation.ts.
|
|
21
21
|
// TODO: import this in isolation without having to import noir_js in its entirety.
|
|
22
|
-
export function
|
|
22
|
+
export function enrichNoirError(artifact: NoirCompiledCircuit, originalError: ExecutionError): DecodedError {
|
|
23
23
|
const payload = originalError.rawAssertionPayload;
|
|
24
24
|
if (!payload) {
|
|
25
25
|
return originalError;
|
|
26
26
|
}
|
|
27
|
-
const enrichedError = originalError as
|
|
27
|
+
const enrichedError = originalError as DecodedError;
|
|
28
28
|
|
|
29
29
|
try {
|
|
30
30
|
// Decode the payload
|
|
31
|
-
const decodedPayload = abiDecodeError(abi, payload);
|
|
31
|
+
const decodedPayload = abiDecodeError(artifact.abi, payload);
|
|
32
32
|
|
|
33
33
|
if (typeof decodedPayload === 'string') {
|
|
34
34
|
// If it's a string, just add it to the error message
|
|
@@ -41,5 +41,26 @@ export function parseErrorPayload(abi: Abi, originalError: ExecutionError): Erro
|
|
|
41
41
|
// Ignore errors decoding the payload
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
try {
|
|
45
|
+
// Decode the callstack
|
|
46
|
+
const callStack = extractCallStack(originalError, {
|
|
47
|
+
// TODO(https://github.com/AztecProtocol/aztec-packages/issues/5813)
|
|
48
|
+
// We only support handling debug info for the circuit entry point.
|
|
49
|
+
// So for now we simply index into the first debug info.
|
|
50
|
+
debugSymbols: parseDebugSymbols(artifact.debug_symbols)[0],
|
|
51
|
+
files: artifact.file_map,
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
enrichedError.noirCallStack = callStack?.map(errorLocation => {
|
|
55
|
+
if (typeof errorLocation === 'string') {
|
|
56
|
+
return `at opcode ${errorLocation}`;
|
|
57
|
+
} else {
|
|
58
|
+
return `at ${errorLocation.locationText} (${errorLocation.filePath}:${errorLocation.line}:${errorLocation.column})`;
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
} catch (_errorResolving) {
|
|
62
|
+
// Ignore errors resolving the callstack
|
|
63
|
+
}
|
|
64
|
+
|
|
44
65
|
return enrichedError;
|
|
45
66
|
}
|