@aztec/pxe 3.0.0-nightly.20251111 → 3.0.0-nightly.20251113
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/contract_function_simulator/contract_function_simulator.d.ts +3 -3
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +3 -4
- package/dest/pxe.d.ts +3 -6
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +10 -11
- package/package.json +16 -16
- package/src/contract_function_simulator/contract_function_simulator.ts +5 -6
- package/src/pxe.ts +10 -19
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Fr } from '@aztec/foundation/fields';
|
|
2
2
|
import { type CircuitSimulator } from '@aztec/simulator/client';
|
|
3
|
-
import type {
|
|
3
|
+
import type { FunctionCall } from '@aztec/stdlib/abi';
|
|
4
4
|
import { FunctionSelector } from '@aztec/stdlib/abi';
|
|
5
5
|
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
6
6
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
@@ -35,9 +35,9 @@ export declare class ContractFunctionSimulator {
|
|
|
35
35
|
* @param authwits - Authentication witnesses required for the function call.
|
|
36
36
|
* @param scopes - Optional array of account addresses whose notes can be accessed in this call. Defaults to all
|
|
37
37
|
* accounts if not specified.
|
|
38
|
-
* @returns A
|
|
38
|
+
* @returns A return value of the utility function in a form as returned by the simulator (Noir fields)
|
|
39
39
|
*/
|
|
40
|
-
runUtility(call: FunctionCall, authwits: AuthWitness[], scopes?: AztecAddress[]): Promise<
|
|
40
|
+
runUtility(call: FunctionCall, authwits: AuthWitness[], scopes?: AztecAddress[]): Promise<Fr[]>;
|
|
41
41
|
getStats(): import("./execution_data_provider.js").ExecutionStats;
|
|
42
42
|
}
|
|
43
43
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract_function_simulator.d.ts","sourceRoot":"","sources":["../../src/contract_function_simulator/contract_function_simulator.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAK9C,OAAO,EACL,KAAK,gBAAgB,EAOtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"contract_function_simulator.d.ts","sourceRoot":"","sources":["../../src/contract_function_simulator/contract_function_simulator.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAK9C,OAAO,EACL,KAAK,gBAAgB,EAOtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAgB,MAAM,mBAAmB,CAAC;AACnE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAS3D,OAAO,EAIL,KAAK,iCAAiC,EACtC,oCAAoC,EAKrC,MAAM,sBAAsB,CAAC;AAI9B,OAAO,EAGL,sBAAsB,EAEtB,kBAAkB,EAGnB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAS1E;;GAEG;AACH,qBAAa,yBAAyB;IAIlC,OAAO,CAAC,qBAAqB;IAC7B,OAAO,CAAC,SAAS;IAJnB,OAAO,CAAC,GAAG,CAAS;gBAGV,qBAAqB,EAAE,qBAAqB,EAC5C,SAAS,EAAE,gBAAgB;IAKrC;;;;;;;;;;;OAWG;IACU,GAAG,CACd,OAAO,EAAE,kBAAkB,EAC3B,eAAe,EAAE,YAAY,EAC7B,QAAQ,EAAE,gBAAgB,EAC1B,SAAS,eAA6C,EACtD,aAAa,CAAC,EAAE,YAAY,EAC5B,MAAM,CAAC,EAAE,YAAY,EAAE,GACtB,OAAO,CAAC,sBAAsB,CAAC;IAmGlC;;;;;;;OAOG;IACU,UAAU,CAAC,IAAI,EAAE,YAAY,EAAE,QAAQ,EAAE,WAAW,EAAE,EAAE,MAAM,CAAC,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,EAAE,EAAE,CAAC;IAyC5G,QAAQ;CAGT;AAYD;;;;;;;;;;;GAWG;AACH,wBAAsB,8BAA8B,CAClD,sBAAsB,EAAE,sBAAsB,EAC9C,cAAc,EAAE,EAAE,EAClB,oBAAoB,EAAE,oBAAoB,GACzC,OAAO,CAAC,iCAAiC,CAAC,oCAAoC,CAAC,CAAC,CAgNlF"}
|
|
@@ -7,7 +7,7 @@ import { Timer } from '@aztec/foundation/timer';
|
|
|
7
7
|
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
8
8
|
import { protocolContractsHash } from '@aztec/protocol-contracts';
|
|
9
9
|
import { ExecutionError, createSimulationError, extractCallStack, resolveAssertionMessageFromError, toACVMWitness, witnessMapToFields } from '@aztec/simulator/client';
|
|
10
|
-
import { FunctionSelector, FunctionType
|
|
10
|
+
import { FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
|
|
11
11
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
12
12
|
import { Gas } from '@aztec/stdlib/gas';
|
|
13
13
|
import { computeNoteHashNonce, computeProtocolNullifier, computeUniqueNoteHash, siloNoteHash, siloNullifier } from '@aztec/stdlib/hash';
|
|
@@ -102,7 +102,7 @@ import { UtilityExecutionOracle } from './oracle/utility_execution_oracle.js';
|
|
|
102
102
|
* @param authwits - Authentication witnesses required for the function call.
|
|
103
103
|
* @param scopes - Optional array of account addresses whose notes can be accessed in this call. Defaults to all
|
|
104
104
|
* accounts if not specified.
|
|
105
|
-
* @returns A
|
|
105
|
+
* @returns A return value of the utility function in a form as returned by the simulator (Noir fields)
|
|
106
106
|
*/ async runUtility(call, authwits, scopes) {
|
|
107
107
|
await verifyCurrentClassId(call.to, this.executionDataProvider);
|
|
108
108
|
const entryPointArtifact = await this.executionDataProvider.getFunctionArtifact(call.to, call.selector);
|
|
@@ -125,9 +125,8 @@ import { UtilityExecutionOracle } from './oracle/utility_execution_oracle.js';
|
|
|
125
125
|
cause: err
|
|
126
126
|
});
|
|
127
127
|
});
|
|
128
|
-
const returnWitness = witnessMapToFields(acirExecutionResult.returnWitness);
|
|
129
128
|
this.log.verbose(`Utility simulation for ${call.to}.${call.selector} completed`);
|
|
130
|
-
return
|
|
129
|
+
return witnessMapToFields(acirExecutionResult.returnWitness);
|
|
131
130
|
} catch (err) {
|
|
132
131
|
throw createSimulationError(err instanceof Error ? err : new Error('Unknown error during private execution'));
|
|
133
132
|
}
|
package/dest/pxe.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { type Logger } from '@aztec/foundation/log';
|
|
|
3
3
|
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
4
4
|
import { type ProtocolContractsProvider } from '@aztec/protocol-contracts';
|
|
5
5
|
import type { CircuitSimulator } from '@aztec/simulator/client';
|
|
6
|
-
import { type ContractArtifact, EventSelector } from '@aztec/stdlib/abi';
|
|
6
|
+
import { type ContractArtifact, EventSelector, FunctionCall } from '@aztec/stdlib/abi';
|
|
7
7
|
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
8
8
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
9
9
|
import type { L2BlockHash } from '@aztec/stdlib/block';
|
|
@@ -214,16 +214,13 @@ export declare class PXE {
|
|
|
214
214
|
/**
|
|
215
215
|
* Simulate the execution of a contract utility function.
|
|
216
216
|
*
|
|
217
|
-
* @param
|
|
218
|
-
* @param args - The arguments to be provided to the function.
|
|
219
|
-
* @param to - The address of the contract to be called.
|
|
217
|
+
* @param call - The function call containing the function details, arguments, and target contract address.
|
|
220
218
|
* @param authwits - (Optional) The authentication witnesses required for the function call.
|
|
221
|
-
* @param from - (Optional) The msg sender to set for the call.
|
|
222
219
|
* @param scopes - (Optional) The accounts whose notes we can access in this call. Currently optional and will
|
|
223
220
|
* default to all.
|
|
224
221
|
* @returns The result of the utility function call, structured based on the function ABI.
|
|
225
222
|
*/
|
|
226
|
-
simulateUtility(
|
|
223
|
+
simulateUtility(call: FunctionCall, authwits?: AuthWitness[], scopes?: AztecAddress[]): Promise<UtilitySimulationResult>;
|
|
227
224
|
/**
|
|
228
225
|
* Returns the private events given search parameters.
|
|
229
226
|
* @param contractAddress - The address of the contract to get events from.
|
package/dest/pxe.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pxe.d.ts","sourceRoot":"","sources":["../src/pxe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAIlE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEzD,OAAO,EAAE,KAAK,yBAAyB,EAAyB,MAAM,2BAA2B,CAAC;AAClG,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EACL,KAAK,gBAAgB,EACrB,aAAa,
|
|
1
|
+
{"version":3,"file":"pxe.d.ts","sourceRoot":"","sources":["../src/pxe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAIlE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEzD,OAAO,EAAE,KAAK,yBAAyB,EAAyB,MAAM,2BAA2B,CAAC;AAClG,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EACL,KAAK,gBAAgB,EACrB,aAAa,EACb,YAAY,EAKb,MAAM,mBAAm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eAAe,EAAE,YAAY,EAC7B,aAAa,EAAE,aAAa,EAC5B,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,YAAY,EAAE,GACzB,OAAO,CAAC,YAAY,EAAE,CAAC;IAc1B;;OAEG;IACI,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAG7B"}
|
package/dest/pxe.js
CHANGED
|
@@ -454,7 +454,8 @@ import { Synchronizer } from './synchronizer/index.js';
|
|
|
454
454
|
* @returns The requested notes.
|
|
455
455
|
*/ async getNotes(filter) {
|
|
456
456
|
// We need to manually trigger private state sync to have a guarantee that all the notes are available.
|
|
457
|
-
await this
|
|
457
|
+
const call = await this.#getFunctionCall('sync_private_state', [], filter.contractAddress);
|
|
458
|
+
await this.simulateUtility(call);
|
|
458
459
|
const noteDaos = await this.noteDataProvider.getNotes(filter);
|
|
459
460
|
const uniqueNotes = noteDaos.map(async (dao)=>{
|
|
460
461
|
const completeAddresses = await this.addressDataProvider.getCompleteAddresses();
|
|
@@ -709,15 +710,12 @@ import { Synchronizer } from './synchronizer/index.js';
|
|
|
709
710
|
/**
|
|
710
711
|
* Simulate the execution of a contract utility function.
|
|
711
712
|
*
|
|
712
|
-
* @param
|
|
713
|
-
* @param args - The arguments to be provided to the function.
|
|
714
|
-
* @param to - The address of the contract to be called.
|
|
713
|
+
* @param call - The function call containing the function details, arguments, and target contract address.
|
|
715
714
|
* @param authwits - (Optional) The authentication witnesses required for the function call.
|
|
716
|
-
* @param from - (Optional) The msg sender to set for the call.
|
|
717
715
|
* @param scopes - (Optional) The accounts whose notes we can access in this call. Currently optional and will
|
|
718
716
|
* default to all.
|
|
719
717
|
* @returns The result of the utility function call, structured based on the function ABI.
|
|
720
|
-
*/ simulateUtility(
|
|
718
|
+
*/ simulateUtility(call, authwits, scopes) {
|
|
721
719
|
// We disable concurrent simulations since those might execute oracles which read and write to the PXE stores (e.g.
|
|
722
720
|
// to the capsules), and we need to prevent concurrent runs from interfering with one another (e.g. attempting to
|
|
723
721
|
// delete the same read value, or reading values that another simulation is currently modifying).
|
|
@@ -727,15 +725,14 @@ import { Synchronizer } from './synchronizer/index.js';
|
|
|
727
725
|
const syncTimer = new Timer();
|
|
728
726
|
await this.synchronizer.sync();
|
|
729
727
|
const syncTime = syncTimer.ms();
|
|
730
|
-
const functionCall = await this.#getFunctionCall(functionName, args, to);
|
|
731
728
|
const functionTimer = new Timer();
|
|
732
729
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
733
|
-
const executionResult = await this.#simulateUtility(contractFunctionSimulator,
|
|
730
|
+
const executionResult = await this.#simulateUtility(contractFunctionSimulator, call, authwits ?? [], scopes);
|
|
734
731
|
const functionTime = functionTimer.ms();
|
|
735
732
|
const totalTime = totalTimer.ms();
|
|
736
733
|
const perFunction = [
|
|
737
734
|
{
|
|
738
|
-
functionName,
|
|
735
|
+
functionName: call.name,
|
|
739
736
|
time: functionTime
|
|
740
737
|
}
|
|
741
738
|
];
|
|
@@ -754,8 +751,9 @@ import { Synchronizer } from './synchronizer/index.js';
|
|
|
754
751
|
}
|
|
755
752
|
};
|
|
756
753
|
} catch (err) {
|
|
754
|
+
const { to, name, args } = call;
|
|
757
755
|
const stringifiedArgs = args.map((arg)=>arg.toString()).join(', ');
|
|
758
|
-
throw this.#contextualizeError(err, `simulateUtility ${to}:${
|
|
756
|
+
throw this.#contextualizeError(err, `simulateUtility ${to}:${name}(${stringifiedArgs})`, `scopes=${scopes?.map((s)=>s.toString()).join(', ') ?? 'undefined'}`);
|
|
759
757
|
}
|
|
760
758
|
});
|
|
761
759
|
}
|
|
@@ -773,7 +771,8 @@ import { Synchronizer } from './synchronizer/index.js';
|
|
|
773
771
|
}
|
|
774
772
|
this.log.verbose(`Getting private events for ${contractAddress.toString()} from ${from} to ${from + numBlocks}`);
|
|
775
773
|
// We need to manually trigger private state sync to have a guarantee that all the events are available.
|
|
776
|
-
await this
|
|
774
|
+
const call = await this.#getFunctionCall('sync_private_state', [], contractAddress);
|
|
775
|
+
await this.simulateUtility(call);
|
|
777
776
|
return this.privateEventDataProvider.getPrivateEvents(contractAddress, from, numBlocks, recipients, eventSelector);
|
|
778
777
|
}
|
|
779
778
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/pxe",
|
|
3
|
-
"version": "3.0.0-nightly.
|
|
3
|
+
"version": "3.0.0-nightly.20251113",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./server": "./dest/entrypoints/server/index.js",
|
|
@@ -61,19 +61,19 @@
|
|
|
61
61
|
]
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
|
-
"@aztec/bb-prover": "3.0.0-nightly.
|
|
65
|
-
"@aztec/bb.js": "3.0.0-nightly.
|
|
66
|
-
"@aztec/builder": "3.0.0-nightly.
|
|
67
|
-
"@aztec/constants": "3.0.0-nightly.
|
|
68
|
-
"@aztec/ethereum": "3.0.0-nightly.
|
|
69
|
-
"@aztec/foundation": "3.0.0-nightly.
|
|
70
|
-
"@aztec/key-store": "3.0.0-nightly.
|
|
71
|
-
"@aztec/kv-store": "3.0.0-nightly.
|
|
72
|
-
"@aztec/noir-protocol-circuits-types": "3.0.0-nightly.
|
|
73
|
-
"@aztec/noir-types": "3.0.0-nightly.
|
|
74
|
-
"@aztec/protocol-contracts": "3.0.0-nightly.
|
|
75
|
-
"@aztec/simulator": "3.0.0-nightly.
|
|
76
|
-
"@aztec/stdlib": "3.0.0-nightly.
|
|
64
|
+
"@aztec/bb-prover": "3.0.0-nightly.20251113",
|
|
65
|
+
"@aztec/bb.js": "3.0.0-nightly.20251113",
|
|
66
|
+
"@aztec/builder": "3.0.0-nightly.20251113",
|
|
67
|
+
"@aztec/constants": "3.0.0-nightly.20251113",
|
|
68
|
+
"@aztec/ethereum": "3.0.0-nightly.20251113",
|
|
69
|
+
"@aztec/foundation": "3.0.0-nightly.20251113",
|
|
70
|
+
"@aztec/key-store": "3.0.0-nightly.20251113",
|
|
71
|
+
"@aztec/kv-store": "3.0.0-nightly.20251113",
|
|
72
|
+
"@aztec/noir-protocol-circuits-types": "3.0.0-nightly.20251113",
|
|
73
|
+
"@aztec/noir-types": "3.0.0-nightly.20251113",
|
|
74
|
+
"@aztec/protocol-contracts": "3.0.0-nightly.20251113",
|
|
75
|
+
"@aztec/simulator": "3.0.0-nightly.20251113",
|
|
76
|
+
"@aztec/stdlib": "3.0.0-nightly.20251113",
|
|
77
77
|
"koa": "^2.16.1",
|
|
78
78
|
"koa-router": "^13.1.1",
|
|
79
79
|
"lodash.omit": "^4.5.0",
|
|
@@ -82,8 +82,8 @@
|
|
|
82
82
|
"viem": "npm:@spalladino/viem@2.38.2-eip7594.0"
|
|
83
83
|
},
|
|
84
84
|
"devDependencies": {
|
|
85
|
-
"@aztec/merkle-tree": "3.0.0-nightly.
|
|
86
|
-
"@aztec/noir-test-contracts.js": "3.0.0-nightly.
|
|
85
|
+
"@aztec/merkle-tree": "3.0.0-nightly.20251113",
|
|
86
|
+
"@aztec/noir-test-contracts.js": "3.0.0-nightly.20251113",
|
|
87
87
|
"@jest/globals": "^30.0.0",
|
|
88
88
|
"@types/jest": "^30.0.0",
|
|
89
89
|
"@types/lodash.omit": "^4.5.7",
|
|
@@ -32,8 +32,8 @@ import {
|
|
|
32
32
|
toACVMWitness,
|
|
33
33
|
witnessMapToFields,
|
|
34
34
|
} from '@aztec/simulator/client';
|
|
35
|
-
import type {
|
|
36
|
-
import { FunctionSelector, FunctionType
|
|
35
|
+
import type { FunctionCall } from '@aztec/stdlib/abi';
|
|
36
|
+
import { FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
|
|
37
37
|
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
38
38
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
39
39
|
import { Gas } from '@aztec/stdlib/gas';
|
|
@@ -215,9 +215,9 @@ export class ContractFunctionSimulator {
|
|
|
215
215
|
* @param authwits - Authentication witnesses required for the function call.
|
|
216
216
|
* @param scopes - Optional array of account addresses whose notes can be accessed in this call. Defaults to all
|
|
217
217
|
* accounts if not specified.
|
|
218
|
-
* @returns A
|
|
218
|
+
* @returns A return value of the utility function in a form as returned by the simulator (Noir fields)
|
|
219
219
|
*/
|
|
220
|
-
public async runUtility(call: FunctionCall, authwits: AuthWitness[], scopes?: AztecAddress[]): Promise<
|
|
220
|
+
public async runUtility(call: FunctionCall, authwits: AuthWitness[], scopes?: AztecAddress[]): Promise<Fr[]> {
|
|
221
221
|
await verifyCurrentClassId(call.to, this.executionDataProvider);
|
|
222
222
|
|
|
223
223
|
const entryPointArtifact = await this.executionDataProvider.getFunctionArtifact(call.to, call.selector);
|
|
@@ -250,9 +250,8 @@ export class ContractFunctionSimulator {
|
|
|
250
250
|
);
|
|
251
251
|
});
|
|
252
252
|
|
|
253
|
-
const returnWitness = witnessMapToFields(acirExecutionResult.returnWitness);
|
|
254
253
|
this.log.verbose(`Utility simulation for ${call.to}.${call.selector} completed`);
|
|
255
|
-
return
|
|
254
|
+
return witnessMapToFields(acirExecutionResult.returnWitness);
|
|
256
255
|
} catch (err) {
|
|
257
256
|
throw createSimulationError(err instanceof Error ? err : new Error('Unknown error during private execution'));
|
|
258
257
|
}
|
package/src/pxe.ts
CHANGED
|
@@ -674,7 +674,8 @@ export class PXE {
|
|
|
674
674
|
*/
|
|
675
675
|
public async getNotes(filter: NotesFilter): Promise<UniqueNote[]> {
|
|
676
676
|
// We need to manually trigger private state sync to have a guarantee that all the notes are available.
|
|
677
|
-
await this
|
|
677
|
+
const call = await this.#getFunctionCall('sync_private_state', [], filter.contractAddress);
|
|
678
|
+
await this.simulateUtility(call);
|
|
678
679
|
|
|
679
680
|
const noteDaos = await this.noteDataProvider.getNotes(filter);
|
|
680
681
|
|
|
@@ -1009,21 +1010,15 @@ export class PXE {
|
|
|
1009
1010
|
/**
|
|
1010
1011
|
* Simulate the execution of a contract utility function.
|
|
1011
1012
|
*
|
|
1012
|
-
* @param
|
|
1013
|
-
* @param args - The arguments to be provided to the function.
|
|
1014
|
-
* @param to - The address of the contract to be called.
|
|
1013
|
+
* @param call - The function call containing the function details, arguments, and target contract address.
|
|
1015
1014
|
* @param authwits - (Optional) The authentication witnesses required for the function call.
|
|
1016
|
-
* @param from - (Optional) The msg sender to set for the call.
|
|
1017
1015
|
* @param scopes - (Optional) The accounts whose notes we can access in this call. Currently optional and will
|
|
1018
1016
|
* default to all.
|
|
1019
1017
|
* @returns The result of the utility function call, structured based on the function ABI.
|
|
1020
1018
|
*/
|
|
1021
1019
|
public simulateUtility(
|
|
1022
|
-
|
|
1023
|
-
args: any[],
|
|
1024
|
-
to: AztecAddress,
|
|
1020
|
+
call: FunctionCall,
|
|
1025
1021
|
authwits?: AuthWitness[],
|
|
1026
|
-
_from?: AztecAddress,
|
|
1027
1022
|
scopes?: AztecAddress[],
|
|
1028
1023
|
): Promise<UtilitySimulationResult> {
|
|
1029
1024
|
// We disable concurrent simulations since those might execute oracles which read and write to the PXE stores (e.g.
|
|
@@ -1035,20 +1030,14 @@ export class PXE {
|
|
|
1035
1030
|
const syncTimer = new Timer();
|
|
1036
1031
|
await this.synchronizer.sync();
|
|
1037
1032
|
const syncTime = syncTimer.ms();
|
|
1038
|
-
const functionCall = await this.#getFunctionCall(functionName, args, to);
|
|
1039
1033
|
const functionTimer = new Timer();
|
|
1040
1034
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
1041
|
-
const executionResult = await this.#simulateUtility(
|
|
1042
|
-
contractFunctionSimulator,
|
|
1043
|
-
functionCall,
|
|
1044
|
-
authwits ?? [],
|
|
1045
|
-
scopes,
|
|
1046
|
-
);
|
|
1035
|
+
const executionResult = await this.#simulateUtility(contractFunctionSimulator, call, authwits ?? [], scopes);
|
|
1047
1036
|
const functionTime = functionTimer.ms();
|
|
1048
1037
|
|
|
1049
1038
|
const totalTime = totalTimer.ms();
|
|
1050
1039
|
|
|
1051
|
-
const perFunction = [{ functionName, time: functionTime }];
|
|
1040
|
+
const perFunction = [{ functionName: call.name, time: functionTime }];
|
|
1052
1041
|
|
|
1053
1042
|
const timings: SimulationTimings = {
|
|
1054
1043
|
total: totalTime,
|
|
@@ -1060,10 +1049,11 @@ export class PXE {
|
|
|
1060
1049
|
const simulationStats = contractFunctionSimulator.getStats();
|
|
1061
1050
|
return { result: executionResult, stats: { timings, nodeRPCCalls: simulationStats.nodeRPCCalls } };
|
|
1062
1051
|
} catch (err: any) {
|
|
1052
|
+
const { to, name, args } = call;
|
|
1063
1053
|
const stringifiedArgs = args.map(arg => arg.toString()).join(', ');
|
|
1064
1054
|
throw this.#contextualizeError(
|
|
1065
1055
|
err,
|
|
1066
|
-
`simulateUtility ${to}:${
|
|
1056
|
+
`simulateUtility ${to}:${name}(${stringifiedArgs})`,
|
|
1067
1057
|
`scopes=${scopes?.map(s => s.toString()).join(', ') ?? 'undefined'}`,
|
|
1068
1058
|
);
|
|
1069
1059
|
}
|
|
@@ -1093,7 +1083,8 @@ export class PXE {
|
|
|
1093
1083
|
this.log.verbose(`Getting private events for ${contractAddress.toString()} from ${from} to ${from + numBlocks}`);
|
|
1094
1084
|
|
|
1095
1085
|
// We need to manually trigger private state sync to have a guarantee that all the events are available.
|
|
1096
|
-
await this
|
|
1086
|
+
const call = await this.#getFunctionCall('sync_private_state', [], contractAddress);
|
|
1087
|
+
await this.simulateUtility(call);
|
|
1097
1088
|
|
|
1098
1089
|
return this.privateEventDataProvider.getPrivateEvents(contractAddress, from, numBlocks, recipients, eventSelector);
|
|
1099
1090
|
}
|