@aztec/simulator 0.83.1 → 0.84.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/private/execution_data_provider.d.ts +1 -1
- package/dest/private/index.d.ts +0 -1
- package/dest/private/index.d.ts.map +1 -1
- package/dest/private/index.js +0 -1
- package/dest/private/private_execution_oracle.d.ts +2 -2
- package/dest/private/private_execution_oracle.d.ts.map +1 -1
- package/dest/private/private_execution_oracle.js +2 -2
- package/dest/private/simulator.d.ts +7 -6
- package/dest/private/simulator.d.ts.map +1 -1
- package/dest/private/simulator.js +34 -16
- package/dest/private/{unconstrained_execution_oracle.d.ts → utility_execution_oracle.d.ts} +3 -3
- package/dest/private/utility_execution_oracle.d.ts.map +1 -0
- package/dest/private/{unconstrained_execution_oracle.js → utility_execution_oracle.js} +2 -2
- package/dest/public/avm/fixtures/base_avm_simulation_tester.js +1 -1
- package/dest/public/public_tx_simulator/public_tx_context.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/public_tx_context.js +2 -2
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/public_tx_simulator.js +1 -5
- package/package.json +14 -14
- package/src/private/execution_data_provider.ts +1 -1
- package/src/private/index.ts +0 -1
- package/src/private/private_execution_oracle.ts +2 -2
- package/src/private/simulator.ts +42 -36
- package/src/private/{unconstrained_execution_oracle.ts → utility_execution_oracle.ts} +2 -2
- package/src/public/avm/fixtures/base_avm_simulation_tester.ts +1 -1
- package/src/public/public_tx_simulator/public_tx_context.ts +8 -2
- package/src/public/public_tx_simulator/public_tx_simulator.ts +1 -12
- package/dest/private/unconstrained_execution.d.ts +0 -10
- package/dest/private/unconstrained_execution.d.ts.map +0 -1
- package/dest/private/unconstrained_execution.js +0 -26
- package/dest/private/unconstrained_execution_oracle.d.ts.map +0 -1
- package/src/private/unconstrained_execution.ts +0 -54
|
@@ -23,7 +23,7 @@ export declare class ContractClassNotFoundError extends Error {
|
|
|
23
23
|
constructor(contractClassId: string);
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
|
-
* The interface for the data layer required to perform private and
|
|
26
|
+
* The interface for the data layer required to perform private and utility execution.
|
|
27
27
|
*/
|
|
28
28
|
export interface ExecutionDataProvider extends CommitmentsDBInterface {
|
|
29
29
|
/**
|
package/dest/private/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export { AcirSimulator } from './simulator.js';
|
|
2
|
-
export { UnconstrainedExecutionOracle } from './unconstrained_execution_oracle.js';
|
|
3
2
|
export { type ExecutionDataProvider, ContractClassNotFoundError, ContractNotFoundError, } from './execution_data_provider.js';
|
|
4
3
|
export * from './pick_notes.js';
|
|
5
4
|
export { ExecutionNoteCache } from './execution_note_cache.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/private/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/private/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EACL,KAAK,qBAAqB,EAC1B,0BAA0B,EAC1B,qBAAqB,GACtB,MAAM,8BAA8B,CAAC;AACtC,cAAc,iBAAiB,CAAC;AAChC,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,iCAAiC,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC/F,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,KAAK,QAAQ,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC3E,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC"}
|
package/dest/private/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export { AcirSimulator } from './simulator.js';
|
|
2
|
-
export { UnconstrainedExecutionOracle } from './unconstrained_execution_oracle.js';
|
|
3
2
|
export { ContractClassNotFoundError, ContractNotFoundError } from './execution_data_provider.js';
|
|
4
3
|
export * from './pick_notes.js';
|
|
5
4
|
export { ExecutionNoteCache } from './execution_note_cache.js';
|
|
@@ -10,11 +10,11 @@ import type { ExecutionDataProvider } from './execution_data_provider.js';
|
|
|
10
10
|
import type { ExecutionNoteCache } from './execution_note_cache.js';
|
|
11
11
|
import type { HashedValuesCache } from './hashed_values_cache.js';
|
|
12
12
|
import type { SimulationProvider } from './providers/simulation_provider.js';
|
|
13
|
-
import {
|
|
13
|
+
import { UtilityExecutionOracle } from './utility_execution_oracle.js';
|
|
14
14
|
/**
|
|
15
15
|
* The execution oracle for the private part of a transaction.
|
|
16
16
|
*/
|
|
17
|
-
export declare class PrivateExecutionOracle extends
|
|
17
|
+
export declare class PrivateExecutionOracle extends UtilityExecutionOracle {
|
|
18
18
|
#private;
|
|
19
19
|
private readonly argsHash;
|
|
20
20
|
private readonly txContext;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"private_execution_oracle.d.ts","sourceRoot":"","sources":["../../src/private/private_execution_oracle.ts"],"names":[],"mappings":"AACA,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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Ac,EAAE,EAAE;IAIzD;;;;;;OAMG;IACa,6BAA6B,CAAC,GAAG,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM;IAoBpF;;;;;;;;OAQG;IACY,mBAAmB,CAChC,qBAAqB,EAAE,YAAY,EACnC,gBAAgB,EAAE,gBAAgB,EAClC,QAAQ,EAAE,EAAE,EACZ,iBAAiB,EAAE,MAAM,EACzB,YAAY,EAAE,OAAO;;;;IAyEvB;;;;;;OAMG;IACa,gCAAgC,CAC9C,sBAAsB,EAAE,YAAY,EACpC,YAAY,EAAE,EAAE,EAChB,kBAAkB,EAAE,MAAM,EAC1B,aAAa,EAAE,OAAO;IAMxB;;;;;;OAMG;IACa,mCAAmC,CACjD,sBAAsB,EAAE,YAAY,EACpC,YAAY,EAAE,EAAE,EAChB,kBAAkB,EAAE,MAAM,EAC1B,aAAa,EAAE,OAAO;IAMR,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,CAAC,6BAA6B,EAAE,EAAE;CAKlE"}
|
|
@@ -9,10 +9,10 @@ import { CallContext, CountedContractClassLog, NoteAndSlot } from '@aztec/stdlib
|
|
|
9
9
|
import { toACVMWitness } from './acvm/index.js';
|
|
10
10
|
import { pickNotes } from './pick_notes.js';
|
|
11
11
|
import { executePrivateFunction, verifyCurrentClassId } from './private_execution.js';
|
|
12
|
-
import {
|
|
12
|
+
import { UtilityExecutionOracle } from './utility_execution_oracle.js';
|
|
13
13
|
/**
|
|
14
14
|
* The execution oracle for the private part of a transaction.
|
|
15
|
-
*/ export class PrivateExecutionOracle extends
|
|
15
|
+
*/ export class PrivateExecutionOracle extends UtilityExecutionOracle {
|
|
16
16
|
argsHash;
|
|
17
17
|
txContext;
|
|
18
18
|
callContext;
|
|
@@ -24,12 +24,13 @@ export declare class AcirSimulator {
|
|
|
24
24
|
*/
|
|
25
25
|
run(request: TxExecutionRequest, contractAddress: AztecAddress, selector: FunctionSelector, msgSender?: AztecAddress, scopes?: AztecAddress[]): Promise<PrivateExecutionResult>;
|
|
26
26
|
/**
|
|
27
|
-
* Runs
|
|
28
|
-
* @param
|
|
29
|
-
* @param
|
|
30
|
-
* @param
|
|
31
|
-
*
|
|
27
|
+
* Runs a utility function.
|
|
28
|
+
* @param call - The function call to execute.
|
|
29
|
+
* @param authwits - Authentication witnesses required for the function call.
|
|
30
|
+
* @param scopes - Optional array of account addresses whose notes can be accessed in this call. Defaults to all
|
|
31
|
+
* accounts if not specified.
|
|
32
|
+
* @returns A decoded ABI value containing the function's return data.
|
|
32
33
|
*/
|
|
33
|
-
|
|
34
|
+
runUtility(call: FunctionCall, authwits: AuthWitness[], scopes?: AztecAddress[]): Promise<AbiDecoded>;
|
|
34
35
|
}
|
|
35
36
|
//# sourceMappingURL=simulator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"simulator.d.ts","sourceRoot":"","sources":["../../src/private/simulator.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,gBAAgB,
|
|
1
|
+
{"version":3,"file":"simulator.d.ts","sourceRoot":"","sources":["../../src/private/simulator.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAA+B,MAAM,mBAAmB,CAAC;AAClF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAA6B,sBAAsB,EAAE,kBAAkB,EAAiB,MAAM,kBAAkB,CAAC;AAIxH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAK1E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAG7E;;GAEG;AACH,qBAAa,aAAa;IAGZ,OAAO,CAAC,qBAAqB;IAAyB,OAAO,CAAC,kBAAkB;IAF5F,OAAO,CAAC,GAAG,CAAS;gBAEA,qBAAqB,EAAE,qBAAqB,EAAU,kBAAkB,EAAE,kBAAkB;IAIhH;;;;;;;;OAQG;IACU,GAAG,CACd,OAAO,EAAE,kBAAkB,EAC3B,eAAe,EAAE,YAAY,EAC7B,QAAQ,EAAE,gBAAgB,EAC1B,SAAS,eAA6C,EACtD,MAAM,CAAC,EAAE,YAAY,EAAE,GACtB,OAAO,CAAC,sBAAsB,CAAC;IA2ElC;;;;;;;OAOG;IACU,UAAU,CAAC,IAAI,EAAE,YAAY,EAAE,QAAQ,EAAE,WAAW,EAAE,EAAE,MAAM,CAAC,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC;CAwCnH"}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { Fr } from '@aztec/foundation/fields';
|
|
2
2
|
import { createLogger } from '@aztec/foundation/log';
|
|
3
|
-
import { FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
|
|
3
|
+
import { FunctionSelector, FunctionType, decodeFromAbi } from '@aztec/stdlib/abi';
|
|
4
4
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
5
|
import { CallContext, HashedValues, PrivateExecutionResult, collectNested } from '@aztec/stdlib/tx';
|
|
6
|
-
import { createSimulationError } from '../common/errors.js';
|
|
6
|
+
import { ExecutionError, createSimulationError, resolveAssertionMessageFromError } from '../common/errors.js';
|
|
7
|
+
import { Oracle, extractCallStack, toACVMWitness, witnessMapToFields } from './acvm/index.js';
|
|
7
8
|
import { ExecutionNoteCache } from './execution_note_cache.js';
|
|
8
9
|
import { HashedValuesCache } from './hashed_values_cache.js';
|
|
9
10
|
import { executePrivateFunction, verifyCurrentClassId } from './private_execution.js';
|
|
10
11
|
import { PrivateExecutionOracle } from './private_execution_oracle.js';
|
|
11
|
-
import {
|
|
12
|
-
import { UnconstrainedExecutionOracle } from './unconstrained_execution_oracle.js';
|
|
12
|
+
import { UtilityExecutionOracle } from './utility_execution_oracle.js';
|
|
13
13
|
/**
|
|
14
14
|
* The ACIR simulator.
|
|
15
15
|
*/ export class AcirSimulator {
|
|
@@ -64,21 +64,39 @@ import { UnconstrainedExecutionOracle } from './unconstrained_execution_oracle.j
|
|
|
64
64
|
throw createSimulationError(err instanceof Error ? err : new Error('Unknown error during private execution'));
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
|
+
// docs:start:execute_unconstrained_function
|
|
67
68
|
/**
|
|
68
|
-
* Runs
|
|
69
|
-
* @param
|
|
70
|
-
* @param
|
|
71
|
-
* @param
|
|
72
|
-
*
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
69
|
+
* Runs a utility function.
|
|
70
|
+
* @param call - The function call to execute.
|
|
71
|
+
* @param authwits - Authentication witnesses required for the function call.
|
|
72
|
+
* @param scopes - Optional array of account addresses whose notes can be accessed in this call. Defaults to all
|
|
73
|
+
* accounts if not specified.
|
|
74
|
+
* @returns A decoded ABI value containing the function's return data.
|
|
75
|
+
*/ async runUtility(call, authwits, scopes) {
|
|
76
|
+
await verifyCurrentClassId(call.to, this.executionDataProvider);
|
|
77
|
+
const entryPointArtifact = await this.executionDataProvider.getFunctionArtifact(call.to, call.selector);
|
|
78
|
+
if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
|
|
79
|
+
throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
|
|
78
80
|
}
|
|
79
|
-
const
|
|
81
|
+
const oracle = new UtilityExecutionOracle(call.to, authwits, [], this.executionDataProvider, undefined, scopes);
|
|
80
82
|
try {
|
|
81
|
-
|
|
83
|
+
this.log.verbose(`Executing utility function ${entryPointArtifact.name}`, {
|
|
84
|
+
contract: call.to,
|
|
85
|
+
selector: call.selector
|
|
86
|
+
});
|
|
87
|
+
const initialWitness = toACVMWitness(0, call.args);
|
|
88
|
+
const acirExecutionResult = await this.simulationProvider.executeUserCircuit(initialWitness, entryPointArtifact, new Oracle(oracle)).catch((err)=>{
|
|
89
|
+
err.message = resolveAssertionMessageFromError(err, entryPointArtifact);
|
|
90
|
+
throw new ExecutionError(err.message, {
|
|
91
|
+
contractAddress: call.to,
|
|
92
|
+
functionSelector: call.selector
|
|
93
|
+
}, extractCallStack(err, entryPointArtifact.debug), {
|
|
94
|
+
cause: err
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
const returnWitness = witnessMapToFields(acirExecutionResult.returnWitness);
|
|
98
|
+
this.log.verbose(`Utility simulation for ${call.to}.${call.selector} completed`);
|
|
99
|
+
return decodeFromAbi(entryPointArtifact.returnTypes, returnWitness);
|
|
82
100
|
} catch (err) {
|
|
83
101
|
throw createSimulationError(err instanceof Error ? err : new Error('Unknown error during private execution'));
|
|
84
102
|
}
|
|
@@ -13,9 +13,9 @@ import type { BlockHeader, Capsule, TxHash } from '@aztec/stdlib/tx';
|
|
|
13
13
|
import { type NoteData, TypedOracle } from './acvm/index.js';
|
|
14
14
|
import type { ExecutionDataProvider } from './execution_data_provider.js';
|
|
15
15
|
/**
|
|
16
|
-
* The oracle for an
|
|
16
|
+
* The oracle for an execution of utility contract functions.
|
|
17
17
|
*/
|
|
18
|
-
export declare class
|
|
18
|
+
export declare class UtilityExecutionOracle extends TypedOracle {
|
|
19
19
|
protected readonly contractAddress: AztecAddress;
|
|
20
20
|
/** List of transient auth witnesses to be used during this simulation */
|
|
21
21
|
protected readonly authWitnesses: AuthWitness[];
|
|
@@ -162,4 +162,4 @@ export declare class UnconstrainedExecutionOracle extends TypedOracle {
|
|
|
162
162
|
getSharedSecret(address: AztecAddress, ephPk: Point): Promise<Point>;
|
|
163
163
|
storePrivateEventLog(contractAddress: AztecAddress, recipient: AztecAddress, eventSelector: EventSelector, logContent: Fr[], txHash: TxHash, logIndexInTx: number): Promise<void>;
|
|
164
164
|
}
|
|
165
|
-
//# sourceMappingURL=
|
|
165
|
+
//# sourceMappingURL=utility_execution_oracle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utility_execution_oracle.d.ts","sourceRoot":"","sources":["../../src/private/utility_execution_oracle.ts"],"names":[],"mappings":";;AACA,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AAErD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAEhF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACzE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,0BAA0B,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC5G,OAAO,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAErE,OAAO,EAAE,KAAK,QAAQ,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAG1E;;GAEG;AACH,qBAAa,sBAAuB,SAAQ,WAAW;IAEnD,SAAS,CAAC,QAAQ,CAAC,eAAe,EAAE,YAAY;IAChD,yEAAyE;IACzE,SAAS,CAAC,QAAQ,CAAC,aAAa,EAAE,WAAW,EAAE;IAC/C,SAAS,CAAC,QAAQ,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siloNullifier } from '@aztec/stdlib/hash';
|
|
|
5
5
|
import { TypedOracle } from './acvm/index.js';
|
|
6
6
|
import { pickNotes } from './pick_notes.js';
|
|
7
7
|
/**
|
|
8
|
-
* The oracle for an
|
|
9
|
-
*/ export class
|
|
8
|
+
* The oracle for an execution of utility contract functions.
|
|
9
|
+
*/ export class UtilityExecutionOracle extends TypedOracle {
|
|
10
10
|
contractAddress;
|
|
11
11
|
authWitnesses;
|
|
12
12
|
capsules;
|
|
@@ -58,7 +58,7 @@ import { createContractClassAndInstance } from './index.js';
|
|
|
58
58
|
const feeJuiceContractClassPublic = {
|
|
59
59
|
...feeJuice.contractClass,
|
|
60
60
|
privateFunctions: [],
|
|
61
|
-
|
|
61
|
+
utilityFunctions: []
|
|
62
62
|
};
|
|
63
63
|
await this.contractDataSource.addNewContract(feeJuice.artifact, feeJuiceContractClassPublic, feeJuice.instance);
|
|
64
64
|
return feeJuice.instance;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public_tx_context.d.ts","sourceRoot":"","sources":["../../../src/public/public_tx_simulator/public_tx_context.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAG9C,OAAO,
|
|
1
|
+
{"version":3,"file":"public_tx_context.d.ts","sourceRoot":"","sources":["../../../src/public/public_tx_simulator/public_tx_context.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAG9C,OAAO,EACL,KAAK,sBAAsB,EAC3B,iBAAiB,EAGjB,UAAU,EACX,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D,OAAO,EAAE,GAAG,EAAe,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAGL,KAAK,8BAA8B,EAIpC,MAAM,sBAAsB,CAAC;AAE9B,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AM,CAAC,KAAK,EAAE,gBAAgB,EAAE,YAAY,GAAE,eAAe,GAAG,SAAqB,EAAE,OAAO,SAAK;IA0BnG;;;OAGG;IACH,kBAAkB,IAAI,UAAU;IAKhC;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO;IAW1C;;OAEG;IACH,uBAAuB,CAAC,KAAK,EAAE,gBAAgB,GAAG,6BAA6B,EAAE;IAWjF;;OAEG;IACH,iBAAiB,CAAC,KAAK,EAAE,gBAAgB,GAAG,GAAG;IAS/C;;OAEG;IACH,UAAU,CAAC,KAAK,EAAE,gBAAgB,EAAE,GAAG,EAAE,GAAG;IAQ5C;;;OAGG;IACH,eAAe,IAAI,GAAG;IAItB;;;;;OAKG;IACH,gBAAgB,IAAI,GAAG;IAOvB;;;OAGG;IACH,sBAAsB,IAAI,GAAG;IAK7B;;;OAGG;IACH,iBAAiB,CAAC,KAAK,EAAE,gBAAgB,GAAG,EAAE;IAQ9C;;;OAGG;IACH,OAAO,CAAC,uBAAuB;IAa/B;;OAEG;IACU,8BAA8B,IAAI,OAAO,CAAC,sBAAsB,CAAC;CAqG/E;AAED;;;;;;;;;GASG;AACH,cAAM,iBAAiB;IAKT,OAAO,CAAC,QAAQ,CAAC,cAAc;IAJ3C,OAAO,CAAC,GAAG,CAAS;IAEpB,OAAO,CAAC,2BAA2B,CAA4C;gBAElD,cAAc,EAAE,6BAA6B;IAIpE,IAAI;IAMV,qBAAqB;IAIrB,QAAQ;IAIF,gBAAgB;IAQhB,kBAAkB;CAOzB"}
|
|
@@ -3,7 +3,7 @@ import { padArrayEnd } from '@aztec/foundation/collection';
|
|
|
3
3
|
import { Fr } from '@aztec/foundation/fields';
|
|
4
4
|
import { createLogger } from '@aztec/foundation/log';
|
|
5
5
|
import { assertLength } from '@aztec/foundation/serialize';
|
|
6
|
-
import { AvmExecutionHints, PublicDataWrite, RevertCode } from '@aztec/stdlib/avm';
|
|
6
|
+
import { AvmExecutionHints, AvmTxHint, PublicDataWrite, RevertCode } from '@aztec/stdlib/avm';
|
|
7
7
|
import { computeTransactionFee } from '@aztec/stdlib/fees';
|
|
8
8
|
import { Gas } from '@aztec/stdlib/gas';
|
|
9
9
|
import { PrivateToAvmAccumulatedData, PrivateToAvmAccumulatedDataArrayLengths, PublicCallRequest, countAccumulatedItems, mergeAccumulatedData } from '@aztec/stdlib/kernel';
|
|
@@ -67,7 +67,7 @@ import { getCallRequestsWithCalldataByPhase } from '../utils.js';
|
|
|
67
67
|
const trace = new SideEffectTrace(/*startSideEffectCounter=*/ 0, previousAccumulatedDataArrayLengths);
|
|
68
68
|
const firstNullifier = nonRevertibleAccumulatedDataFromPrivate.nullifiers[0];
|
|
69
69
|
// We wrap the DB to collect AVM hints.
|
|
70
|
-
const hints = new AvmExecutionHints();
|
|
70
|
+
const hints = new AvmExecutionHints(AvmTxHint.fromTx(tx));
|
|
71
71
|
const hintingContractsDB = new HintingPublicContractsDB(contractsDB, hints);
|
|
72
72
|
const hintingTreesDB = new HintingPublicTreesDB(treesDB, hints);
|
|
73
73
|
// Transaction level state manager that will be forked for revertible phases.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public_tx_simulator.d.ts","sourceRoot":"","sources":["../../../src/public/public_tx_simulator/public_tx_simulator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAGlE,OAAO,
|
|
1
|
+
{"version":3,"file":"public_tx_simulator.d.ts","sourceRoot":"","sources":["../../../src/public/public_tx_simulator/public_tx_simulator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAGlE,OAAO,EAIL,KAAK,iBAAiB,EACtB,KAAK,UAAU,EAChB,MAAM,mBAAm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ChC,kBAAkB,GAAE,OAAe,EACnC,kBAAkB,GAAE,OAAe;IAK7C;;;;OAIG;IACU,QAAQ,CAAC,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,cAAc,CAAC;cA6EtC,aAAa,CAAC,EAAE,EAAE,EAAE;IAIpC;;;;OAIG;YACW,kBAAkB;IAIhC;;;;OAIG;YACW,qBAAqB;IAkBnC;;;;OAIG;YACW,qBAAqB;IAoBnC;;;;;OAKG;cACa,aAAa,CAAC,KAAK,EAAE,gBAAgB,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,cAAc,CAAC;IAqCzG;;;;;;OAMG;cACa,oBAAoB,CAClC,KAAK,EAAE,gBAAgB,EACvB,OAAO,EAAE,eAAe,EACxB,WAAW,EAAE,6BAA6B,GACzC,OAAO,CAAC,sBAAsB,CAAC;IA+BlC;;;;;;;;;;;;OAYG;cACa,4BAA4B,CAC1C,YAAY,EAAE,6BAA6B,EAC3C,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,6BAA6B,EACpD,YAAY,EAAE,GAAG,EACjB,cAAc,EAAE,EAAE,EAClB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,sBAAsB,CAAC;IAsBlC;;OAEG;cACa,+BAA+B,CAAC,OAAO,EAAE,eAAe,EAAE,EAAE,EAAE,EAAE;IAuBhF;;;OAGG;cACa,4BAA4B,CAAC,OAAO,EAAE,eAAe,EAAE,EAAE,EAAE,EAAE,GAAgB,OAAO,CAAC,OAAO,CAAC;YAoC/F,MAAM;IAgCpB;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,sBAAsB;CAStC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createLogger } from '@aztec/foundation/log';
|
|
2
2
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
3
3
|
import { computeFeePayerBalanceStorageSlot } from '@aztec/protocol-contracts/fee-juice';
|
|
4
|
-
import { AvmCircuitInputs
|
|
4
|
+
import { AvmCircuitInputs } from '@aztec/stdlib/avm';
|
|
5
5
|
import { SimulationError } from '@aztec/stdlib/errors';
|
|
6
6
|
import { ProvingRequestType } from '@aztec/stdlib/proofs';
|
|
7
7
|
import { NestedProcessReturnValues, TxExecutionPhase } from '@aztec/stdlib/tx';
|
|
@@ -183,11 +183,7 @@ export class PublicTxSimulator {
|
|
|
183
183
|
const contractAddress = callRequest.request.contractAddress;
|
|
184
184
|
const fnName = await getPublicFunctionDebugName(this.contractsDB, contractAddress, callRequest.calldata);
|
|
185
185
|
const allocatedGas = context.getGasLeftAtPhase(phase);
|
|
186
|
-
// The reason we need enqueued hints at all (and cannot just use the public inputs) is
|
|
187
|
-
// because they don't have the actual calldata, just the hash of it.
|
|
188
|
-
// If/when we pass the whole TX to C++, we can remove this class of hints.
|
|
189
186
|
stateManager.traceEnqueuedCall(callRequest.request);
|
|
190
|
-
context.hints.enqueuedCalls.push(new AvmEnqueuedCallHint(callRequest.request.msgSender, contractAddress, callRequest.calldata, callRequest.request.isStaticCall));
|
|
191
187
|
const result = await this.simulateEnqueuedCallInternal(context.state.getActiveStateManager(), callRequest, allocatedGas, /*transactionFee=*/ context.getTransactionFee(phase), fnName);
|
|
192
188
|
const gasUsed = allocatedGas.sub(result.gasLeft); // by enqueued call
|
|
193
189
|
context.consumeGas(phase, gasUsed);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/simulator",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.84.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./server": "./dest/server.js",
|
|
@@ -60,16 +60,16 @@
|
|
|
60
60
|
]
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@aztec/constants": "0.
|
|
64
|
-
"@aztec/foundation": "0.
|
|
65
|
-
"@aztec/noir-acvm_js": "0.
|
|
66
|
-
"@aztec/noir-noirc_abi": "0.
|
|
67
|
-
"@aztec/noir-protocol-circuits-types": "0.
|
|
68
|
-
"@aztec/noir-types": "0.
|
|
69
|
-
"@aztec/protocol-contracts": "0.
|
|
70
|
-
"@aztec/stdlib": "0.
|
|
71
|
-
"@aztec/telemetry-client": "0.
|
|
72
|
-
"@aztec/world-state": "0.
|
|
63
|
+
"@aztec/constants": "0.84.0",
|
|
64
|
+
"@aztec/foundation": "0.84.0",
|
|
65
|
+
"@aztec/noir-acvm_js": "0.84.0",
|
|
66
|
+
"@aztec/noir-noirc_abi": "0.84.0",
|
|
67
|
+
"@aztec/noir-protocol-circuits-types": "0.84.0",
|
|
68
|
+
"@aztec/noir-types": "0.84.0",
|
|
69
|
+
"@aztec/protocol-contracts": "0.84.0",
|
|
70
|
+
"@aztec/stdlib": "0.84.0",
|
|
71
|
+
"@aztec/telemetry-client": "0.84.0",
|
|
72
|
+
"@aztec/world-state": "0.84.0",
|
|
73
73
|
"levelup": "^5.1.1",
|
|
74
74
|
"lodash.clonedeep": "^4.5.0",
|
|
75
75
|
"lodash.merge": "^4.6.2",
|
|
@@ -77,9 +77,9 @@
|
|
|
77
77
|
"tslib": "^2.4.0"
|
|
78
78
|
},
|
|
79
79
|
"devDependencies": {
|
|
80
|
-
"@aztec/kv-store": "0.
|
|
81
|
-
"@aztec/merkle-tree": "0.
|
|
82
|
-
"@aztec/noir-contracts.js": "0.
|
|
80
|
+
"@aztec/kv-store": "0.84.0",
|
|
81
|
+
"@aztec/merkle-tree": "0.84.0",
|
|
82
|
+
"@aztec/noir-contracts.js": "0.84.0",
|
|
83
83
|
"@jest/globals": "^29.5.0",
|
|
84
84
|
"@types/jest": "^29.5.0",
|
|
85
85
|
"@types/levelup": "^5.1.3",
|
|
@@ -36,7 +36,7 @@ export class ContractClassNotFoundError extends Error {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
|
-
* The interface for the data layer required to perform private and
|
|
39
|
+
* The interface for the data layer required to perform private and utility execution.
|
|
40
40
|
*/
|
|
41
41
|
export interface ExecutionDataProvider extends CommitmentsDBInterface {
|
|
42
42
|
/**
|
package/src/private/index.ts
CHANGED
|
@@ -31,12 +31,12 @@ import type { HashedValuesCache } from './hashed_values_cache.js';
|
|
|
31
31
|
import { pickNotes } from './pick_notes.js';
|
|
32
32
|
import { executePrivateFunction, verifyCurrentClassId } from './private_execution.js';
|
|
33
33
|
import type { SimulationProvider } from './providers/simulation_provider.js';
|
|
34
|
-
import {
|
|
34
|
+
import { UtilityExecutionOracle } from './utility_execution_oracle.js';
|
|
35
35
|
|
|
36
36
|
/**
|
|
37
37
|
* The execution oracle for the private part of a transaction.
|
|
38
38
|
*/
|
|
39
|
-
export class PrivateExecutionOracle extends
|
|
39
|
+
export class PrivateExecutionOracle extends UtilityExecutionOracle {
|
|
40
40
|
/**
|
|
41
41
|
* New notes created during this execution.
|
|
42
42
|
* It's possible that a note in this list has been nullified (in the same or other executions) and doesn't exist in the ExecutionNoteCache and the final proof data.
|
package/src/private/simulator.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { Fr } from '@aztec/foundation/fields';
|
|
2
2
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
3
3
|
import type { AbiDecoded, FunctionCall } from '@aztec/stdlib/abi';
|
|
4
|
-
import { FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
|
|
4
|
+
import { FunctionSelector, FunctionType, decodeFromAbi } from '@aztec/stdlib/abi';
|
|
5
5
|
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
6
6
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
7
7
|
import { CallContext, HashedValues, PrivateExecutionResult, TxExecutionRequest, collectNested } from '@aztec/stdlib/tx';
|
|
8
8
|
|
|
9
|
-
import { createSimulationError } from '../common/errors.js';
|
|
9
|
+
import { ExecutionError, createSimulationError, resolveAssertionMessageFromError } from '../common/errors.js';
|
|
10
|
+
import { Oracle, extractCallStack, toACVMWitness, witnessMapToFields } from './acvm/index.js';
|
|
10
11
|
import type { ExecutionDataProvider } from './execution_data_provider.js';
|
|
11
12
|
import { ExecutionNoteCache } from './execution_note_cache.js';
|
|
12
13
|
import { HashedValuesCache } from './hashed_values_cache.js';
|
|
13
14
|
import { executePrivateFunction, verifyCurrentClassId } from './private_execution.js';
|
|
14
15
|
import { PrivateExecutionOracle } from './private_execution_oracle.js';
|
|
15
16
|
import type { SimulationProvider } from './providers/simulation_provider.js';
|
|
16
|
-
import {
|
|
17
|
-
import { UnconstrainedExecutionOracle } from './unconstrained_execution_oracle.js';
|
|
17
|
+
import { UtilityExecutionOracle } from './utility_execution_oracle.js';
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* The ACIR simulator.
|
|
@@ -115,47 +115,53 @@ export class AcirSimulator {
|
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
+
// docs:start:execute_unconstrained_function
|
|
118
119
|
/**
|
|
119
|
-
* Runs
|
|
120
|
-
* @param
|
|
121
|
-
* @param
|
|
122
|
-
* @param
|
|
123
|
-
*
|
|
120
|
+
* Runs a utility function.
|
|
121
|
+
* @param call - The function call to execute.
|
|
122
|
+
* @param authwits - Authentication witnesses required for the function call.
|
|
123
|
+
* @param scopes - Optional array of account addresses whose notes can be accessed in this call. Defaults to all
|
|
124
|
+
* accounts if not specified.
|
|
125
|
+
* @returns A decoded ABI value containing the function's return data.
|
|
124
126
|
*/
|
|
125
|
-
public async
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
selector: FunctionSelector,
|
|
129
|
-
authwits: AuthWitness[],
|
|
130
|
-
scopes?: AztecAddress[],
|
|
131
|
-
): Promise<AbiDecoded> {
|
|
132
|
-
await verifyCurrentClassId(contractAddress, this.executionDataProvider);
|
|
133
|
-
const entryPointArtifact = await this.executionDataProvider.getFunctionArtifact(contractAddress, selector);
|
|
127
|
+
public async runUtility(call: FunctionCall, authwits: AuthWitness[], scopes?: AztecAddress[]): Promise<AbiDecoded> {
|
|
128
|
+
await verifyCurrentClassId(call.to, this.executionDataProvider);
|
|
129
|
+
const entryPointArtifact = await this.executionDataProvider.getFunctionArtifact(call.to, call.selector);
|
|
134
130
|
|
|
135
|
-
if (entryPointArtifact.functionType !== FunctionType.
|
|
136
|
-
throw new Error(`Cannot run ${entryPointArtifact.functionType} function as
|
|
131
|
+
if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
|
|
132
|
+
throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
|
|
137
133
|
}
|
|
138
134
|
|
|
139
|
-
const
|
|
140
|
-
contractAddress,
|
|
141
|
-
authwits,
|
|
142
|
-
[],
|
|
143
|
-
this.executionDataProvider,
|
|
144
|
-
undefined,
|
|
145
|
-
scopes,
|
|
146
|
-
);
|
|
135
|
+
const oracle = new UtilityExecutionOracle(call.to, authwits, [], this.executionDataProvider, undefined, scopes);
|
|
147
136
|
|
|
148
137
|
try {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
138
|
+
this.log.verbose(`Executing utility function ${entryPointArtifact.name}`, {
|
|
139
|
+
contract: call.to,
|
|
140
|
+
selector: call.selector,
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
const initialWitness = toACVMWitness(0, call.args);
|
|
144
|
+
const acirExecutionResult = await this.simulationProvider
|
|
145
|
+
.executeUserCircuit(initialWitness, entryPointArtifact, new Oracle(oracle))
|
|
146
|
+
.catch((err: Error) => {
|
|
147
|
+
err.message = resolveAssertionMessageFromError(err, entryPointArtifact);
|
|
148
|
+
throw new ExecutionError(
|
|
149
|
+
err.message,
|
|
150
|
+
{
|
|
151
|
+
contractAddress: call.to,
|
|
152
|
+
functionSelector: call.selector,
|
|
153
|
+
},
|
|
154
|
+
extractCallStack(err, entryPointArtifact.debug),
|
|
155
|
+
{ cause: err },
|
|
156
|
+
);
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
const returnWitness = witnessMapToFields(acirExecutionResult.returnWitness);
|
|
160
|
+
this.log.verbose(`Utility simulation for ${call.to}.${call.selector} completed`);
|
|
161
|
+
return decodeFromAbi(entryPointArtifact.returnTypes, returnWitness);
|
|
157
162
|
} catch (err) {
|
|
158
163
|
throw createSimulationError(err instanceof Error ? err : new Error('Unknown error during private execution'));
|
|
159
164
|
}
|
|
160
165
|
}
|
|
166
|
+
// docs:end:execute_unconstrained_function
|
|
161
167
|
}
|
|
@@ -17,9 +17,9 @@ import type { ExecutionDataProvider } from './execution_data_provider.js';
|
|
|
17
17
|
import { pickNotes } from './pick_notes.js';
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
|
-
* The oracle for an
|
|
20
|
+
* The oracle for an execution of utility contract functions.
|
|
21
21
|
*/
|
|
22
|
-
export class
|
|
22
|
+
export class UtilityExecutionOracle extends TypedOracle {
|
|
23
23
|
constructor(
|
|
24
24
|
protected readonly contractAddress: AztecAddress,
|
|
25
25
|
/** List of transient auth witnesses to be used during this simulation */
|
|
@@ -80,7 +80,7 @@ export abstract class BaseAvmSimulationTester {
|
|
|
80
80
|
const feeJuiceContractClassPublic = {
|
|
81
81
|
...feeJuice.contractClass,
|
|
82
82
|
privateFunctions: [],
|
|
83
|
-
|
|
83
|
+
utilityFunctions: [],
|
|
84
84
|
};
|
|
85
85
|
await this.contractDataSource.addNewContract(feeJuice.artifact, feeJuiceContractClassPublic, feeJuice.instance);
|
|
86
86
|
return feeJuice.instance;
|
|
@@ -10,7 +10,13 @@ import { padArrayEnd } from '@aztec/foundation/collection';
|
|
|
10
10
|
import { Fr } from '@aztec/foundation/fields';
|
|
11
11
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
12
12
|
import { assertLength } from '@aztec/foundation/serialize';
|
|
13
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
type AvmCircuitPublicInputs,
|
|
15
|
+
AvmExecutionHints,
|
|
16
|
+
AvmTxHint,
|
|
17
|
+
PublicDataWrite,
|
|
18
|
+
RevertCode,
|
|
19
|
+
} from '@aztec/stdlib/avm';
|
|
14
20
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
15
21
|
import type { SimulationError } from '@aztec/stdlib/errors';
|
|
16
22
|
import { computeTransactionFee } from '@aztec/stdlib/fees';
|
|
@@ -105,7 +111,7 @@ export class PublicTxContext {
|
|
|
105
111
|
const firstNullifier = nonRevertibleAccumulatedDataFromPrivate.nullifiers[0];
|
|
106
112
|
|
|
107
113
|
// We wrap the DB to collect AVM hints.
|
|
108
|
-
const hints = new AvmExecutionHints();
|
|
114
|
+
const hints = new AvmExecutionHints(AvmTxHint.fromTx(tx));
|
|
109
115
|
const hintingContractsDB = new HintingPublicContractsDB(contractsDB, hints);
|
|
110
116
|
const hintingTreesDB = new HintingPublicTreesDB(treesDB, hints);
|
|
111
117
|
|
|
@@ -5,7 +5,6 @@ import { computeFeePayerBalanceStorageSlot } from '@aztec/protocol-contracts/fee
|
|
|
5
5
|
import {
|
|
6
6
|
AvmCircuitInputs,
|
|
7
7
|
AvmCircuitPublicInputs,
|
|
8
|
-
AvmEnqueuedCallHint,
|
|
9
8
|
AvmExecutionHints,
|
|
10
9
|
type AvmProvingRequest,
|
|
11
10
|
type RevertCode,
|
|
@@ -72,6 +71,7 @@ export class PublicTxSimulator {
|
|
|
72
71
|
const txHash = await this.computeTxHash(tx);
|
|
73
72
|
|
|
74
73
|
this.log.debug(`Simulating ${tx.publicFunctionCalldata.length} public calls for tx ${txHash}`, { txHash });
|
|
74
|
+
|
|
75
75
|
const context = await PublicTxContext.create(
|
|
76
76
|
this.treesDB,
|
|
77
77
|
this.contractsDB,
|
|
@@ -265,18 +265,7 @@ export class PublicTxSimulator {
|
|
|
265
265
|
|
|
266
266
|
const allocatedGas = context.getGasLeftAtPhase(phase);
|
|
267
267
|
|
|
268
|
-
// The reason we need enqueued hints at all (and cannot just use the public inputs) is
|
|
269
|
-
// because they don't have the actual calldata, just the hash of it.
|
|
270
|
-
// If/when we pass the whole TX to C++, we can remove this class of hints.
|
|
271
268
|
stateManager.traceEnqueuedCall(callRequest.request);
|
|
272
|
-
context.hints.enqueuedCalls.push(
|
|
273
|
-
new AvmEnqueuedCallHint(
|
|
274
|
-
callRequest.request.msgSender,
|
|
275
|
-
contractAddress,
|
|
276
|
-
callRequest.calldata,
|
|
277
|
-
callRequest.request.isStaticCall,
|
|
278
|
-
),
|
|
279
|
-
);
|
|
280
269
|
|
|
281
270
|
const result = await this.simulateEnqueuedCallInternal(
|
|
282
271
|
context.state.getActiveStateManager(),
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { Fr } from '@aztec/foundation/fields';
|
|
2
|
-
import { type AbiDecoded, type FunctionArtifactWithContractName, type FunctionSelector } from '@aztec/stdlib/abi';
|
|
3
|
-
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
|
-
import type { SimulationProvider } from './providers/simulation_provider.js';
|
|
5
|
-
import type { UnconstrainedExecutionOracle } from './unconstrained_execution_oracle.js';
|
|
6
|
-
/**
|
|
7
|
-
* Execute an unconstrained function and return the decoded values.
|
|
8
|
-
*/
|
|
9
|
-
export declare function executeUnconstrainedFunction(simulatorProvider: SimulationProvider, oracle: UnconstrainedExecutionOracle, artifact: FunctionArtifactWithContractName, contractAddress: AztecAddress, functionSelector: FunctionSelector, args: Fr[], log?: import("@aztec/foundation/log").Logger): Promise<AbiDecoded>;
|
|
10
|
-
//# sourceMappingURL=unconstrained_execution.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"unconstrained_execution.d.ts","sourceRoot":"","sources":["../../src/private/unconstrained_execution.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAEnD,OAAO,EACL,KAAK,UAAU,EACf,KAAK,gCAAgC,EACrC,KAAK,gBAAgB,EAEtB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAKhE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAC7E,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,qCAAqC,CAAC;AAGxF;;GAEG;AACH,wBAAsB,4BAA4B,CAChD,iBAAiB,EAAE,kBAAkB,EACrC,MAAM,EAAE,4BAA4B,EACpC,QAAQ,EAAE,gCAAgC,EAC1C,eAAe,EAAE,YAAY,EAC7B,gBAAgB,EAAE,gBAAgB,EAClC,IAAI,EAAE,EAAE,EAAE,EACV,GAAG,yCAAoD,GACtD,OAAO,CAAC,UAAU,CAAC,CAwBrB"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
2
|
-
import { decodeFromAbi } from '@aztec/stdlib/abi';
|
|
3
|
-
import { ExecutionError, resolveAssertionMessageFromError } from '../common/errors.js';
|
|
4
|
-
import { witnessMapToFields } from './acvm/deserialize.js';
|
|
5
|
-
import { Oracle, extractCallStack, toACVMWitness } from './acvm/index.js';
|
|
6
|
-
// docs:start:execute_unconstrained_function
|
|
7
|
-
/**
|
|
8
|
-
* Execute an unconstrained function and return the decoded values.
|
|
9
|
-
*/ export async function executeUnconstrainedFunction(simulatorProvider, oracle, artifact, contractAddress, functionSelector, args, log = createLogger('simulator:unconstrained_execution')) {
|
|
10
|
-
log.verbose(`Executing unconstrained function ${artifact.name}`, {
|
|
11
|
-
contract: contractAddress,
|
|
12
|
-
selector: functionSelector
|
|
13
|
-
});
|
|
14
|
-
const initialWitness = toACVMWitness(0, args);
|
|
15
|
-
const acirExecutionResult = await simulatorProvider.executeUserCircuit(initialWitness, artifact, new Oracle(oracle)).catch((err)=>{
|
|
16
|
-
err.message = resolveAssertionMessageFromError(err, artifact);
|
|
17
|
-
throw new ExecutionError(err.message, {
|
|
18
|
-
contractAddress,
|
|
19
|
-
functionSelector
|
|
20
|
-
}, extractCallStack(err, artifact.debug), {
|
|
21
|
-
cause: err
|
|
22
|
-
});
|
|
23
|
-
});
|
|
24
|
-
const returnWitness = witnessMapToFields(acirExecutionResult.returnWitness);
|
|
25
|
-
return decodeFromAbi(artifact.returnTypes, returnWitness);
|
|
26
|
-
} // docs:end:execute_unconstrained_function
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"unconstrained_execution_oracle.d.ts","sourceRoot":"","sources":["../../src/private/unconstrained_execution_oracle.ts"],"names":[],"mappings":";;AACA,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AAErD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAEhF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACzE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,0BAA0B,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC5G,OAAO,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAErE,OAAO,EAAE,KAAK,QAAQ,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAG1E;;GAEG;AACH,qBAAa,4BAA6B,SAAQ,WAAW;IAEzD,SAAS,CAAC,QAAQ,CAAC,eAAe,EAAE,YAAY;IAChD,yEAAyE;IACzE,SAAS,CAAC,QAAQ,CAAC,aAAa,EAAE,WAAW,EAAE;IAC/C,SAAS,CAAC,QAA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
|
|
|
1
|
-
import type { Fr } from '@aztec/foundation/fields';
|
|
2
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
3
|
-
import {
|
|
4
|
-
type AbiDecoded,
|
|
5
|
-
type FunctionArtifactWithContractName,
|
|
6
|
-
type FunctionSelector,
|
|
7
|
-
decodeFromAbi,
|
|
8
|
-
} from '@aztec/stdlib/abi';
|
|
9
|
-
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
10
|
-
|
|
11
|
-
import { ExecutionError, resolveAssertionMessageFromError } from '../common/errors.js';
|
|
12
|
-
import { witnessMapToFields } from './acvm/deserialize.js';
|
|
13
|
-
import { Oracle, extractCallStack, toACVMWitness } from './acvm/index.js';
|
|
14
|
-
import type { SimulationProvider } from './providers/simulation_provider.js';
|
|
15
|
-
import type { UnconstrainedExecutionOracle } from './unconstrained_execution_oracle.js';
|
|
16
|
-
|
|
17
|
-
// docs:start:execute_unconstrained_function
|
|
18
|
-
/**
|
|
19
|
-
* Execute an unconstrained function and return the decoded values.
|
|
20
|
-
*/
|
|
21
|
-
export async function executeUnconstrainedFunction(
|
|
22
|
-
simulatorProvider: SimulationProvider,
|
|
23
|
-
oracle: UnconstrainedExecutionOracle,
|
|
24
|
-
artifact: FunctionArtifactWithContractName,
|
|
25
|
-
contractAddress: AztecAddress,
|
|
26
|
-
functionSelector: FunctionSelector,
|
|
27
|
-
args: Fr[],
|
|
28
|
-
log = createLogger('simulator:unconstrained_execution'),
|
|
29
|
-
): Promise<AbiDecoded> {
|
|
30
|
-
log.verbose(`Executing unconstrained function ${artifact.name}`, {
|
|
31
|
-
contract: contractAddress,
|
|
32
|
-
selector: functionSelector,
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
const initialWitness = toACVMWitness(0, args);
|
|
36
|
-
const acirExecutionResult = await simulatorProvider
|
|
37
|
-
.executeUserCircuit(initialWitness, artifact, new Oracle(oracle))
|
|
38
|
-
.catch((err: Error) => {
|
|
39
|
-
err.message = resolveAssertionMessageFromError(err, artifact);
|
|
40
|
-
throw new ExecutionError(
|
|
41
|
-
err.message,
|
|
42
|
-
{
|
|
43
|
-
contractAddress,
|
|
44
|
-
functionSelector,
|
|
45
|
-
},
|
|
46
|
-
extractCallStack(err, artifact.debug),
|
|
47
|
-
{ cause: err },
|
|
48
|
-
);
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
const returnWitness = witnessMapToFields(acirExecutionResult.returnWitness);
|
|
52
|
-
return decodeFromAbi(artifact.returnTypes, returnWitness);
|
|
53
|
-
}
|
|
54
|
-
// docs:end:execute_unconstrained_function
|