@aztec/pxe 0.83.1 → 0.84.0-alpha-testnet.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/config/package_info.js +1 -1
- package/dest/pxe_service/pxe_service.d.ts +1 -1
- package/dest/pxe_service/pxe_service.d.ts.map +1 -1
- package/dest/pxe_service/pxe_service.js +12 -17
- package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts +2 -2
- package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts.map +1 -1
- package/dest/storage/capsule_data_provider/capsule_data_provider.js +4 -4
- package/dest/test/pxe_test_suite.js +2 -2
- package/package.json +15 -15
- package/src/config/package_info.ts +1 -1
- package/src/pxe_service/pxe_service.ts +12 -25
- package/src/storage/capsule_data_provider/capsule_data_provider.ts +4 -4
- package/src/test/pxe_test_suite.ts +2 -2
|
@@ -89,7 +89,7 @@ export declare class PXEService implements PXE {
|
|
|
89
89
|
profileTx(txRequest: TxExecutionRequest, profileMode: 'full' | 'execution-steps' | 'gates', msgSender?: AztecAddress): Promise<TxProfileResult>;
|
|
90
90
|
simulateTx(txRequest: TxExecutionRequest, simulatePublic: boolean, msgSender?: AztecAddress | undefined, skipTxValidation?: boolean, skipFeeEnforcement?: boolean, scopes?: AztecAddress[]): Promise<TxSimulationResult>;
|
|
91
91
|
sendTx(tx: Tx): Promise<TxHash>;
|
|
92
|
-
|
|
92
|
+
simulateUtility(functionName: string, args: any[], to: AztecAddress, authwits?: AuthWitness[], _from?: AztecAddress, scopes?: AztecAddress[]): Promise<AbiDecoded>;
|
|
93
93
|
getNodeInfo(): Promise<NodeInfo>;
|
|
94
94
|
getPXEInfo(): Promise<PXEInfo>;
|
|
95
95
|
getPrivateEvents<T>(contractAddress: AztecAddress, eventMetadataDef: EventMetadataDefinition, from: number, numBlocks: number, recipients: AztecAddress[]): Promise<T[]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pxe_service.d.ts","sourceR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|
208
208
|
}
|
|
209
209
|
/**
|
|
210
|
-
* Simulate
|
|
211
|
-
*
|
|
212
|
-
*
|
|
213
|
-
*
|
|
214
|
-
*
|
|
215
|
-
* @
|
|
216
|
-
|
|
217
|
-
*/ async #simulateUnconstrained(execRequest, authWitnesses, scopes) {
|
|
218
|
-
const { to: contractAddress, selector: functionSelector } = execRequest;
|
|
219
|
-
this.log.debug('Executing unconstrained simulator...');
|
|
210
|
+
* Simulate a utility function call on the given contract.
|
|
211
|
+
* @param call - The function call to execute.
|
|
212
|
+
* @param authWitnesses - Authentication witnesses required for the function call.
|
|
213
|
+
* @param scopes - Optional array of account addresses whose notes can be accessed in this call. Defaults to all
|
|
214
|
+
* accounts if not specified.
|
|
215
|
+
* @returns The simulation result containing the outputs of the utility function.
|
|
216
|
+
*/ async #simulateUtility(call, authWitnesses, scopes) {
|
|
220
217
|
try {
|
|
221
|
-
|
|
222
|
-
this.log.verbose(`Unconstrained simulation for ${contractAddress}.${functionSelector} completed`);
|
|
223
|
-
return result;
|
|
218
|
+
return this.simulator.runUtility(call, authWitnesses ?? [], scopes);
|
|
224
219
|
} catch (err) {
|
|
225
220
|
if (err instanceof SimulationError) {
|
|
226
221
|
await enrichSimulationError(err, this.contractDataProvider, this.log);
|
|
@@ -555,7 +550,7 @@ import { enrichPublicSimulationError, enrichSimulationError } from './error_enri
|
|
|
555
550
|
this.log.info(`Sent transaction ${txHash}`);
|
|
556
551
|
return txHash;
|
|
557
552
|
}
|
|
558
|
-
|
|
553
|
+
simulateUtility(functionName, args, to, authwits, _from, scopes) {
|
|
559
554
|
// We disable concurrent simulations since those might execute oracles which read and write to the PXE stores (e.g.
|
|
560
555
|
// to the capsules), and we need to prevent concurrent runs from interfering with one another (e.g. attempting to
|
|
561
556
|
// delete the same read value, or reading values that another simulation is currently modifying).
|
|
@@ -564,12 +559,12 @@ import { enrichPublicSimulationError, enrichSimulationError } from './error_enri
|
|
|
564
559
|
await this.synchronizer.sync();
|
|
565
560
|
// TODO - Should check if `from` has the permission to call the view function.
|
|
566
561
|
const functionCall = await this.#getFunctionCall(functionName, args, to);
|
|
567
|
-
const executionResult = await this.#
|
|
562
|
+
const executionResult = await this.#simulateUtility(functionCall, authwits ?? [], scopes);
|
|
568
563
|
// TODO - Return typed result based on the function artifact.
|
|
569
564
|
return executionResult;
|
|
570
565
|
} catch (err) {
|
|
571
566
|
const stringifiedArgs = args.map((arg)=>arg.toString()).join(', ');
|
|
572
|
-
throw this.#contextualizeError(err, `
|
|
567
|
+
throw this.#contextualizeError(err, `simulateUtility ${to}:${functionName}(${stringifiedArgs})`, `scopes=${scopes?.map((s)=>s.toString()).join(', ') ?? 'undefined'}`);
|
|
573
568
|
}
|
|
574
569
|
});
|
|
575
570
|
}
|
|
@@ -609,7 +604,7 @@ import { enrichPublicSimulationError, enrichSimulationError } from './error_enri
|
|
|
609
604
|
}
|
|
610
605
|
this.log.verbose(`Getting private events for ${contractAddress.toString()} from ${from} to ${from + numBlocks}`);
|
|
611
606
|
// TODO(#13113): This is a temporary hack to ensure that the notes are synced before getting the events.
|
|
612
|
-
await this.
|
|
607
|
+
await this.simulateUtility('sync_notes', [], contractAddress);
|
|
613
608
|
const events = await this.privateEventDataProvider.getPrivateEvents(contractAddress, from, numBlocks, recipients, eventMetadataDef.eventSelector);
|
|
614
609
|
const decodedEvents = events.map((event)=>decodeFromAbi([
|
|
615
610
|
eventMetadataDef.abiType
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Fr } from '@aztec/foundation/fields';
|
|
2
|
-
import { type
|
|
2
|
+
import { type Logger } from '@aztec/foundation/log';
|
|
3
3
|
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
4
4
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
5
|
import type { DataProvider } from '../data_provider.js';
|
|
6
6
|
export declare class CapsuleDataProvider implements DataProvider {
|
|
7
7
|
#private;
|
|
8
|
-
|
|
8
|
+
logger: Logger;
|
|
9
9
|
constructor(store: AztecAsyncKVStore);
|
|
10
10
|
storeCapsule(contractAddress: AztecAddress, slot: Fr, capsule: Fr[]): Promise<void>;
|
|
11
11
|
loadCapsule(contractAddress: AztecAddress, slot: Fr): Promise<Fr[] | null>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capsule_data_provider.d.ts","sourceRoot":"","sources":["../../../src/storage/capsule_data_provider/capsule_data_provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAE9C,OAAO,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"capsule_data_provider.d.ts","sourceRoot":"","sources":["../../../src/storage/capsule_data_provider/capsule_data_provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAE9C,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAClE,OAAO,KAAK,EAAE,iBAAiB,EAAiB,MAAM,iBAAiB,CAAC;AACxE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAEhE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD,qBAAa,mBAAoB,YAAW,YAAY;;IAMtD,MAAM,EAAE,MAAM,CAAC;gBAEH,KAAK,EAAE,iBAAiB;IAQ9B,YAAY,CAAC,eAAe,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAInF,WAAW,CAAC,eAAe,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,GAAG,OAAO,CAAC,EAAE,EAAE,GAAG,IAAI,CAAC;IAa1E,aAAa,CAAC,eAAe,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAIrE,WAAW,CAAC,eAAe,EAAE,YAAY,EAAE,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAwB7G;;;;;;;OAOG;IACH,oBAAoB,CAAC,eAAe,EAAE,YAAY,EAAE,QAAQ,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAkBrF,OAAO;CAMrB"}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { Fr } from '@aztec/foundation/fields';
|
|
2
2
|
import { toArray } from '@aztec/foundation/iterable';
|
|
3
|
-
import {
|
|
3
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
4
4
|
export class CapsuleDataProvider {
|
|
5
5
|
#store;
|
|
6
6
|
// Arbitrary data stored by contracts. Key is computed as `${contractAddress}:${key}`
|
|
7
7
|
#capsules;
|
|
8
|
-
|
|
8
|
+
logger;
|
|
9
9
|
constructor(store){
|
|
10
10
|
this.#store = store;
|
|
11
11
|
this.#capsules = this.#store.openMap('capsules');
|
|
12
|
-
this.
|
|
12
|
+
this.logger = createLogger('pxe:capsule-data-provider');
|
|
13
13
|
}
|
|
14
14
|
async storeCapsule(contractAddress, slot, capsule) {
|
|
15
15
|
await this.#capsules.set(dbSlotToKey(contractAddress, slot), Buffer.concat(capsule.map((value)=>value.toBuffer())));
|
|
@@ -17,7 +17,7 @@ export class CapsuleDataProvider {
|
|
|
17
17
|
async loadCapsule(contractAddress, slot) {
|
|
18
18
|
const dataBuffer = await this.#capsules.getAsync(dbSlotToKey(contractAddress, slot));
|
|
19
19
|
if (!dataBuffer) {
|
|
20
|
-
this.debug(`Data not found for contract ${contractAddress.toString()} and slot ${slot.toString()}`);
|
|
20
|
+
this.logger.debug(`Data not found for contract ${contractAddress.toString()} and slot ${slot.toString()}`);
|
|
21
21
|
return null;
|
|
22
22
|
}
|
|
23
23
|
const capsule = [];
|
|
@@ -79,8 +79,8 @@ export const pxeTestSuite = (testName, pxeSetup)=>{
|
|
|
79
79
|
artifact
|
|
80
80
|
})).rejects.toThrow(/Artifact does not match/i);
|
|
81
81
|
});
|
|
82
|
-
// Note: Not testing a successful run of `proveTx`, `sendTx`, `getTxReceipt` and `
|
|
83
|
-
// a larger setup and it's sufficiently tested in the e2e tests.
|
|
82
|
+
// Note: Not testing a successful run of `proveTx`, `sendTx`, `getTxReceipt` and `simulateUtility` here as it
|
|
83
|
+
// requires a larger setup and it's sufficiently tested in the e2e tests.
|
|
84
84
|
// Note: Not testing `getContractData`, `getPublicLogs` and `getPublicStorageAt` here as these
|
|
85
85
|
// functions only call AztecNode and these methods are frequently used by the e2e tests.
|
|
86
86
|
it('successfully gets a block number', async ()=>{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/pxe",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.84.0-alpha-testnet.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./server": "./dest/entrypoints/server/index.js",
|
|
@@ -59,19 +59,19 @@
|
|
|
59
59
|
]
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"@aztec/bb-prover": "0.
|
|
63
|
-
"@aztec/bb.js": "0.
|
|
64
|
-
"@aztec/builder": "0.
|
|
65
|
-
"@aztec/constants": "0.
|
|
66
|
-
"@aztec/ethereum": "0.
|
|
67
|
-
"@aztec/foundation": "0.
|
|
68
|
-
"@aztec/key-store": "0.
|
|
69
|
-
"@aztec/kv-store": "0.
|
|
70
|
-
"@aztec/noir-protocol-circuits-types": "0.
|
|
71
|
-
"@aztec/noir-types": "0.
|
|
72
|
-
"@aztec/protocol-contracts": "0.
|
|
73
|
-
"@aztec/simulator": "0.
|
|
74
|
-
"@aztec/stdlib": "0.
|
|
62
|
+
"@aztec/bb-prover": "0.84.0-alpha-testnet.0",
|
|
63
|
+
"@aztec/bb.js": "0.84.0-alpha-testnet.0",
|
|
64
|
+
"@aztec/builder": "0.84.0-alpha-testnet.0",
|
|
65
|
+
"@aztec/constants": "0.84.0-alpha-testnet.0",
|
|
66
|
+
"@aztec/ethereum": "0.84.0-alpha-testnet.0",
|
|
67
|
+
"@aztec/foundation": "0.84.0-alpha-testnet.0",
|
|
68
|
+
"@aztec/key-store": "0.84.0-alpha-testnet.0",
|
|
69
|
+
"@aztec/kv-store": "0.84.0-alpha-testnet.0",
|
|
70
|
+
"@aztec/noir-protocol-circuits-types": "0.84.0-alpha-testnet.0",
|
|
71
|
+
"@aztec/noir-types": "0.84.0-alpha-testnet.0",
|
|
72
|
+
"@aztec/protocol-contracts": "0.84.0-alpha-testnet.0",
|
|
73
|
+
"@aztec/simulator": "0.84.0-alpha-testnet.0",
|
|
74
|
+
"@aztec/stdlib": "0.84.0-alpha-testnet.0",
|
|
75
75
|
"@msgpack/msgpack": "^3.0.0-beta2",
|
|
76
76
|
"koa": "^2.14.2",
|
|
77
77
|
"koa-router": "^12.0.0",
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
"viem": "2.23.7"
|
|
82
82
|
},
|
|
83
83
|
"devDependencies": {
|
|
84
|
-
"@aztec/noir-contracts.js": "0.
|
|
84
|
+
"@aztec/noir-contracts.js": "0.84.0-alpha-testnet.0",
|
|
85
85
|
"@jest/globals": "^29.5.0",
|
|
86
86
|
"@types/jest": "^29.5.0",
|
|
87
87
|
"@types/lodash.omit": "^4.5.7",
|
|
@@ -343,29 +343,16 @@ export class PXEService implements PXE {
|
|
|
343
343
|
}
|
|
344
344
|
|
|
345
345
|
/**
|
|
346
|
-
* Simulate
|
|
347
|
-
*
|
|
348
|
-
*
|
|
349
|
-
*
|
|
350
|
-
*
|
|
351
|
-
* @
|
|
352
|
-
* @returns The simulation result containing the outputs of the unconstrained function.
|
|
346
|
+
* Simulate a utility function call on the given contract.
|
|
347
|
+
* @param call - The function call to execute.
|
|
348
|
+
* @param authWitnesses - Authentication witnesses required for the function call.
|
|
349
|
+
* @param scopes - Optional array of account addresses whose notes can be accessed in this call. Defaults to all
|
|
350
|
+
* accounts if not specified.
|
|
351
|
+
* @returns The simulation result containing the outputs of the utility function.
|
|
353
352
|
*/
|
|
354
|
-
async #
|
|
355
|
-
const { to: contractAddress, selector: functionSelector } = execRequest;
|
|
356
|
-
|
|
357
|
-
this.log.debug('Executing unconstrained simulator...');
|
|
353
|
+
async #simulateUtility(call: FunctionCall, authWitnesses?: AuthWitness[], scopes?: AztecAddress[]) {
|
|
358
354
|
try {
|
|
359
|
-
|
|
360
|
-
execRequest,
|
|
361
|
-
contractAddress,
|
|
362
|
-
functionSelector,
|
|
363
|
-
authWitnesses ?? [],
|
|
364
|
-
scopes,
|
|
365
|
-
);
|
|
366
|
-
this.log.verbose(`Unconstrained simulation for ${contractAddress}.${functionSelector} completed`);
|
|
367
|
-
|
|
368
|
-
return result;
|
|
355
|
+
return this.simulator.runUtility(call, authWitnesses ?? [], scopes);
|
|
369
356
|
} catch (err) {
|
|
370
357
|
if (err instanceof SimulationError) {
|
|
371
358
|
await enrichSimulationError(err, this.contractDataProvider, this.log);
|
|
@@ -817,7 +804,7 @@ export class PXEService implements PXE {
|
|
|
817
804
|
return txHash;
|
|
818
805
|
}
|
|
819
806
|
|
|
820
|
-
public
|
|
807
|
+
public simulateUtility(
|
|
821
808
|
functionName: string,
|
|
822
809
|
args: any[],
|
|
823
810
|
to: AztecAddress,
|
|
@@ -833,7 +820,7 @@ export class PXEService implements PXE {
|
|
|
833
820
|
await this.synchronizer.sync();
|
|
834
821
|
// TODO - Should check if `from` has the permission to call the view function.
|
|
835
822
|
const functionCall = await this.#getFunctionCall(functionName, args, to);
|
|
836
|
-
const executionResult = await this.#
|
|
823
|
+
const executionResult = await this.#simulateUtility(functionCall, authwits ?? [], scopes);
|
|
837
824
|
|
|
838
825
|
// TODO - Return typed result based on the function artifact.
|
|
839
826
|
return executionResult;
|
|
@@ -841,7 +828,7 @@ export class PXEService implements PXE {
|
|
|
841
828
|
const stringifiedArgs = args.map(arg => arg.toString()).join(', ');
|
|
842
829
|
throw this.#contextualizeError(
|
|
843
830
|
err,
|
|
844
|
-
`
|
|
831
|
+
`simulateUtility ${to}:${functionName}(${stringifiedArgs})`,
|
|
845
832
|
`scopes=${scopes?.map(s => s.toString()).join(', ') ?? 'undefined'}`,
|
|
846
833
|
);
|
|
847
834
|
}
|
|
@@ -896,7 +883,7 @@ export class PXEService implements PXE {
|
|
|
896
883
|
this.log.verbose(`Getting private events for ${contractAddress.toString()} from ${from} to ${from + numBlocks}`);
|
|
897
884
|
|
|
898
885
|
// TODO(#13113): This is a temporary hack to ensure that the notes are synced before getting the events.
|
|
899
|
-
await this.
|
|
886
|
+
await this.simulateUtility('sync_notes', [], contractAddress);
|
|
900
887
|
|
|
901
888
|
const events = await this.privateEventDataProvider.getPrivateEvents(
|
|
902
889
|
contractAddress,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Fr } from '@aztec/foundation/fields';
|
|
2
2
|
import { toArray } from '@aztec/foundation/iterable';
|
|
3
|
-
import { type
|
|
3
|
+
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
4
4
|
import type { AztecAsyncKVStore, AztecAsyncMap } from '@aztec/kv-store';
|
|
5
5
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
6
6
|
|
|
@@ -12,14 +12,14 @@ export class CapsuleDataProvider implements DataProvider {
|
|
|
12
12
|
// Arbitrary data stored by contracts. Key is computed as `${contractAddress}:${key}`
|
|
13
13
|
#capsules: AztecAsyncMap<string, Buffer>;
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
logger: Logger;
|
|
16
16
|
|
|
17
17
|
constructor(store: AztecAsyncKVStore) {
|
|
18
18
|
this.#store = store;
|
|
19
19
|
|
|
20
20
|
this.#capsules = this.#store.openMap('capsules');
|
|
21
21
|
|
|
22
|
-
this.
|
|
22
|
+
this.logger = createLogger('pxe:capsule-data-provider');
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
async storeCapsule(contractAddress: AztecAddress, slot: Fr, capsule: Fr[]): Promise<void> {
|
|
@@ -29,7 +29,7 @@ export class CapsuleDataProvider implements DataProvider {
|
|
|
29
29
|
async loadCapsule(contractAddress: AztecAddress, slot: Fr): Promise<Fr[] | null> {
|
|
30
30
|
const dataBuffer = await this.#capsules.getAsync(dbSlotToKey(contractAddress, slot));
|
|
31
31
|
if (!dataBuffer) {
|
|
32
|
-
this.debug(`Data not found for contract ${contractAddress.toString()} and slot ${slot.toString()}`);
|
|
32
|
+
this.logger.debug(`Data not found for contract ${contractAddress.toString()} and slot ${slot.toString()}`);
|
|
33
33
|
return null;
|
|
34
34
|
}
|
|
35
35
|
const capsule: Fr[] = [];
|
|
@@ -92,8 +92,8 @@ export const pxeTestSuite = (testName: string, pxeSetup: () => Promise<PXE>) =>
|
|
|
92
92
|
await expect(pxe.registerContract({ instance, artifact })).rejects.toThrow(/Artifact does not match/i);
|
|
93
93
|
});
|
|
94
94
|
|
|
95
|
-
// Note: Not testing a successful run of `proveTx`, `sendTx`, `getTxReceipt` and `
|
|
96
|
-
// a larger setup and it's sufficiently tested in the e2e tests.
|
|
95
|
+
// Note: Not testing a successful run of `proveTx`, `sendTx`, `getTxReceipt` and `simulateUtility` here as it
|
|
96
|
+
// requires a larger setup and it's sufficiently tested in the e2e tests.
|
|
97
97
|
|
|
98
98
|
// Note: Not testing `getContractData`, `getPublicLogs` and `getPublicStorageAt` here as these
|
|
99
99
|
// functions only call AztecNode and these methods are frequently used by the e2e tests.
|