@aztec/pxe 0.79.0 → 0.80.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/index.d.ts.map +1 -1
- package/dest/config/index.js +2 -1
- package/dest/pxe_oracle_interface/pxe_oracle_interface.d.ts.map +1 -1
- package/dest/pxe_oracle_interface/pxe_oracle_interface.js +3 -4
- package/dest/pxe_service/pxe_service.d.ts +1 -0
- package/dest/pxe_service/pxe_service.d.ts.map +1 -1
- package/dest/pxe_service/pxe_service.js +129 -94
- package/package.json +15 -15
- package/src/config/index.ts +1 -0
- package/src/pxe_oracle_interface/pxe_oracle_interface.ts +3 -4
- package/src/pxe_service/pxe_service.ts +170 -117
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,kBAAkB,EAKxB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,KAAK,eAAe,EAAsB,MAAM,wBAAwB,CAAC;AAClF,OAAO,EAAE,KAAK,WAAW,EAAuB,MAAM,sBAAsB,CAAC;AAC7E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAErD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,8CAA8C;IAC9C,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AACD;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,uDAAuD;IACvD,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,kBAAkB,GAAG,cAAc,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GAAG,cAAc,GAAG,eAAe,GAAG,WAAW,CAAC;AAE/G,MAAM,MAAM,aAAa,GAAG;IAC1B,wDAAwD;IACxD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,sDAAsD;IACtD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,2CAA2C;IAC3C,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,kBAAkB,CAAC,gBAAgB,CA0BlE,CAAC;AAEF;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,gBAAgB,CAEtD;AAED,eAAO,MAAM,oBAAoB,EAAE,kBAAkB,CAAC,aAAa,CAclE,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,kBAAkB,CAAC,aAAa,GAAG,gBAAgB,CAWrF,CAAC;AAEF;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,aAAa,GAAG,gBAAgB,CAQnE"}
|
package/dest/config/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pxe_oracle_interface.d.ts","sourceRoot":"","sources":["../../src/pxe_oracle_interface/pxe_oracle_interface.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,wBAAwB,EAI9B,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAG9C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,KAAK,qBAAqB,EAAE,KAAK,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7G,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,EACL,KAAK,gBAAgB,EAErB,gBAAgB,EAKjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAW,OAAO,EAAiB,MAAM,qBAAqB,CA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IAIvG;;;;;OAKG;IACI,UAAU,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;IAI5C;;;;;;;OAOG;IACU,+BAA+B,CAC1C,eAAe,EAAE,YAAY,EAC7B,MAAM,EAAE,YAAY,EACpB,SAAS,EAAE,YAAY,GACtB,OAAO,CAAC,oBAAoB,CAAC;IAShC;;;;;OAKG;IACU,sCAAsC,CACjD,eAAe,EAAE,YAAY,EAC7B,MAAM,EAAE,YAAY,EACpB,SAAS,EAAE,YAAY,GACtB,OAAO,CAAC,IAAI,CAAC;IAwDhB;;;;;;OAMG;IACU,sBAAsB,CACjC,eAAe,EAAE,YAAY,EAC7B,MAAM,EAAE,YAAY,EACpB,SAAS,EAAE,YAAY,GACtB,OAAO,CAAC,IAAI,CAAC;IAwDhB;;;;;;;OAOG;IACU,cAAc,CACzB,eAAe,EAAE,YAAY,EAC7B,cAAc,EAAE,MAAM,EACtB,MAAM,CAAC,EAAE,YAAY,EAAE,GACtB,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,aAAa,EAAE,CAAC,CAAC;IAiMxC;;;;OAIG;IACU,iBAAiB,CAC5B,IAAI,EAAE,aAAa,EAAE,EACrB,SAAS,EAAE,YAAY,EACvB,SAAS,CAAC,EAAE,aAAa,GACxB,OAAO,CAAC,IAAI,CAAC;IA8BH,WAAW,CACtB,eAAe,EAAE,YAAY,EAC7B,WAAW,EAAE,EAAE,EACf,KAAK,EAAE,EAAE,EACT,OAAO,EAAE,EAAE,EAAE,EACb,QAAQ,EAAE,EAAE,EACZ,SAAS,EAAE,EAAE,EACb,MAAM,EAAE,EAAE,EACV,SAAS,EAAE,YAAY,GACtB,OAAO,CAAC,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"pxe_oracle_interface.d.ts","sourceRoot":"","sources":["../../src/pxe_oracle_interface/pxe_oracle_interface.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,wBAAwB,EAI9B,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAE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A8BH,WAAW,CACtB,eAAe,EAAE,YAAY,EAC7B,WAAW,EAAE,EAAE,EACf,KAAK,EAAE,EAAE,EACT,OAAO,EAAE,EAAE,EAAE,EACb,QAAQ,EAAE,EAAE,EACZ,SAAS,EAAE,EAAE,EACb,MAAM,EAAE,EAAE,EACV,SAAS,EAAE,YAAY,GACtB,OAAO,CAAC,IAAI,CAAC;IA4FH,WAAW,CAAC,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IAqCnD,oBAAoB,CAAC,eAAe,EAAE,YAAY;IA8BzD,cAAc,CAClB,eAAe,EAAE,YAAY,EAC7B,YAAY,EAAE,EAAE,EAAE,EAClB,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,EAAE,EAAE,EAChB,cAAc,EAAE,EAAE,EAClB,SAAS,EAAE,YAAY,EACvB,SAAS,CAAC,EAAE,aAAa;IAqC3B,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;IAI1E,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;CAGxG"}
|
|
@@ -533,10 +533,9 @@ import { WINDOW_HALF_SIZE, getIndexedTaggingSecretsForTheWindow, getInitialIndex
|
|
|
533
533
|
// Note that while this technically results in historical queries, we perform it at the latest locally synced block
|
|
534
534
|
// number which *should* be recent enough to be available, even for non-archive nodes.
|
|
535
535
|
const syncedBlockNumber = await this.syncDataProvider.getBlockNumber();
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
//}
|
|
536
|
+
if (syncedBlockNumber === undefined) {
|
|
537
|
+
throw new Error(`Attempted to deliver a note with an unsynchronized PXE - this should never happen`);
|
|
538
|
+
}
|
|
540
539
|
// By computing siloed and unique note hashes ourselves we prevent contracts from interfering with the note storage
|
|
541
540
|
// of other contracts, which would constitute a security breach.
|
|
542
541
|
const uniqueNoteHash = await computeUniqueNoteHash(nonce, await siloNoteHash(contractAddress, noteHash));
|
|
@@ -37,6 +37,7 @@ export declare class PXEService implements PXE {
|
|
|
37
37
|
private proofCreator;
|
|
38
38
|
private protocolContractsProvider;
|
|
39
39
|
private log;
|
|
40
|
+
private jobQueue;
|
|
40
41
|
private constructor();
|
|
41
42
|
/**
|
|
42
43
|
* Creates an instance of a PXE Service by instantiating all the necessary data providers and services.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pxe_service.d.ts","sourceRoot":"","sources":["../../src/pxe_service/pxe_service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,EAAE,EAAE,KAAK,KAAK,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"pxe_service.d.ts","sourceRoot":"","sources":["../../src/pxe_service/pxe_service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,EAAE,EAAE,KAAK,KAAK,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAGlE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC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,OAAO,CAAC;IA6JxB,gBAAgB,CAAC,CAAC,EAC7B,gBAAgB,EAAE,uBAAuB,EACzC,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EAEb,IAAI,EAAE,KAAK,EAAE,GACZ,OAAO,CAAC,CAAC,EAAE,CAAC;IAiET,eAAe,CAAC,CAAC,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC;IA8BxG,iBAAiB;IAIvB,OAAO,CAAC,kBAAkB;CAa3B"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Fr } from '@aztec/foundation/fields';
|
|
2
2
|
import { createLogger } from '@aztec/foundation/log';
|
|
3
|
+
import { SerialQueue } from '@aztec/foundation/queue';
|
|
3
4
|
import { Timer } from '@aztec/foundation/timer';
|
|
4
5
|
import { KeyStore } from '@aztec/key-store';
|
|
5
6
|
import { L2TipsStore } from '@aztec/kv-store/stores';
|
|
@@ -48,7 +49,8 @@ import { enrichPublicSimulationError, enrichSimulationError } from './error_enri
|
|
|
48
49
|
proofCreator;
|
|
49
50
|
protocolContractsProvider;
|
|
50
51
|
log;
|
|
51
|
-
|
|
52
|
+
jobQueue;
|
|
53
|
+
constructor(node, synchronizer, keyStore, contractDataProvider, noteDataProvider, capsuleDataProvider, syncDataProvider, taggingDataProvider, addressDataProvider, authWitnessDataProvider, simulator, packageVersion, proverEnabled, proofCreator, protocolContractsProvider, log, jobQueue){
|
|
52
54
|
this.node = node;
|
|
53
55
|
this.synchronizer = synchronizer;
|
|
54
56
|
this.keyStore = keyStore;
|
|
@@ -65,6 +67,7 @@ import { enrichPublicSimulationError, enrichSimulationError } from './error_enri
|
|
|
65
67
|
this.proofCreator = proofCreator;
|
|
66
68
|
this.protocolContractsProvider = protocolContractsProvider;
|
|
67
69
|
this.log = log;
|
|
70
|
+
this.jobQueue = jobQueue;
|
|
68
71
|
}
|
|
69
72
|
/**
|
|
70
73
|
* Creates an instance of a PXE Service by instantiating all the necessary data providers and services.
|
|
@@ -88,12 +91,26 @@ import { enrichPublicSimulationError, enrichSimulationError } from './error_enri
|
|
|
88
91
|
const synchronizer = new Synchronizer(node, syncDataProvider, noteDataProvider, taggingDataProvider, tipsStore, config, loggerOrSuffix);
|
|
89
92
|
const pxeOracleInterface = new PXEOracleInterface(node, keyStore, simulationProvider, contractDataProvider, noteDataProvider, capsuleDataProvider, syncDataProvider, taggingDataProvider, addressDataProvider, authWitnessDataProvider, log);
|
|
90
93
|
const simulator = new AcirSimulator(pxeOracleInterface, simulationProvider);
|
|
91
|
-
const
|
|
94
|
+
const jobQueue = new SerialQueue();
|
|
95
|
+
const pxeService = new PXEService(node, synchronizer, keyStore, contractDataProvider, noteDataProvider, capsuleDataProvider, syncDataProvider, taggingDataProvider, addressDataProvider, authWitnessDataProvider, simulator, packageVersion, proverEnabled, proofCreator, protocolContractsProvider, log, jobQueue);
|
|
96
|
+
pxeService.jobQueue.start();
|
|
92
97
|
await pxeService.#registerProtocolContracts();
|
|
93
98
|
const info = await pxeService.getNodeInfo();
|
|
94
99
|
log.info(`Started PXE connected to chain ${info.l1ChainId} version ${info.protocolVersion}`);
|
|
95
100
|
return pxeService;
|
|
96
101
|
}
|
|
102
|
+
/**
|
|
103
|
+
* Enqueues a job for execution once no other jobs are running. Returns a promise that will resolve once the job is
|
|
104
|
+
* complete.
|
|
105
|
+
*
|
|
106
|
+
* Useful for tasks that cannot run concurrently, such as contract function simulation.
|
|
107
|
+
*/ #putInJobQueue(fn) {
|
|
108
|
+
// TODO(#12636): relax the conditions under which we forbid concurrency.
|
|
109
|
+
if (this.jobQueue.length() != 0) {
|
|
110
|
+
this.log.warn(`PXE is already processing ${this.jobQueue.length()} jobs, concurrent execution is not supported. Will run once those are complete.`);
|
|
111
|
+
}
|
|
112
|
+
return this.jobQueue.put(fn);
|
|
113
|
+
}
|
|
97
114
|
isL1ToL2MessageSynced(l1ToL2Message) {
|
|
98
115
|
return this.node.isL1ToL2MessageSynced(l1ToL2Message);
|
|
99
116
|
}
|
|
@@ -234,27 +251,31 @@ import { enrichPublicSimulationError, enrichSimulationError } from './error_enri
|
|
|
234
251
|
await this.contractDataProvider.addContractInstance(instance);
|
|
235
252
|
this.log.info(`Added contract ${artifact.name} at ${instance.address.toString()} with class ${instance.currentContractClassId}`);
|
|
236
253
|
}
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
+
updateContract(contractAddress, artifact) {
|
|
255
|
+
// We disable concurrently updating contracts to avoid concurrently syncing with the node, or changing a contract's
|
|
256
|
+
// class while we're simulating it.
|
|
257
|
+
return this.#putInJobQueue(async ()=>{
|
|
258
|
+
const currentInstance = await this.contractDataProvider.getContractInstance(contractAddress);
|
|
259
|
+
const contractClass = await getContractClassFromArtifact(artifact);
|
|
260
|
+
await this.synchronizer.sync();
|
|
261
|
+
const header = await this.syncDataProvider.getBlockHeader();
|
|
262
|
+
const currentClassId = await readCurrentClassId(contractAddress, currentInstance, this.node, header.globalVariables.blockNumber.toNumber());
|
|
263
|
+
if (!contractClass.id.equals(currentClassId)) {
|
|
264
|
+
throw new Error('Could not update contract to a class different from the current one.');
|
|
265
|
+
}
|
|
266
|
+
await this.contractDataProvider.addContractArtifact(contractClass.id, artifact);
|
|
267
|
+
const publicFunctionSignatures = artifact.functions.filter((fn)=>fn.functionType === FunctionType.PUBLIC).map((fn)=>decodeFunctionSignature(fn.name, fn.parameters));
|
|
268
|
+
await this.node.registerContractFunctionSignatures(contractAddress, publicFunctionSignatures);
|
|
269
|
+
// TODO(#10007): Node should get public contract class from the registration event, not from PXE registration
|
|
270
|
+
await this.node.addContractClass({
|
|
271
|
+
...contractClass,
|
|
272
|
+
privateFunctions: [],
|
|
273
|
+
unconstrainedFunctions: []
|
|
274
|
+
});
|
|
275
|
+
currentInstance.currentContractClassId = contractClass.id;
|
|
276
|
+
await this.contractDataProvider.addContractInstance(currentInstance);
|
|
277
|
+
this.log.info(`Updated contract ${artifact.name} at ${contractAddress.toString()} to class ${contractClass.id}`);
|
|
254
278
|
});
|
|
255
|
-
currentInstance.currentContractClassId = contractClass.id;
|
|
256
|
-
await this.contractDataProvider.addContractInstance(currentInstance);
|
|
257
|
-
this.log.info(`Updated contract ${artifact.name} at ${contractAddress.toString()} to class ${contractClass.id}`);
|
|
258
279
|
}
|
|
259
280
|
getContracts() {
|
|
260
281
|
return this.contractDataProvider.getContractsAddresses();
|
|
@@ -295,71 +316,80 @@ import { enrichPublicSimulationError, enrichSimulationError } from './error_enri
|
|
|
295
316
|
async getCurrentBaseFees() {
|
|
296
317
|
return await this.node.getCurrentBaseFees();
|
|
297
318
|
}
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
319
|
+
proveTx(txRequest, privateExecutionResult) {
|
|
320
|
+
// We disable proving concurrently mostly out of caution, since it accesses some of our stores. Proving is so
|
|
321
|
+
// computationally demanding that it'd be rare for someone to try to do it concurrently regardless.
|
|
322
|
+
return this.#putInJobQueue(async ()=>{
|
|
323
|
+
try {
|
|
324
|
+
const { publicInputs, clientIvcProof } = await this.#prove(txRequest, this.proofCreator, privateExecutionResult, {
|
|
325
|
+
simulate: false,
|
|
326
|
+
skipFeeEnforcement: false,
|
|
327
|
+
profile: false
|
|
328
|
+
});
|
|
329
|
+
return new TxProvingResult(privateExecutionResult, publicInputs, clientIvcProof);
|
|
330
|
+
} catch (err) {
|
|
331
|
+
throw this.contextualizeError(err, inspect(txRequest), inspect(privateExecutionResult));
|
|
332
|
+
}
|
|
333
|
+
});
|
|
309
334
|
}
|
|
310
335
|
// TODO(#7456) Prevent msgSender being defined here for the first call
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
if (simulatePublic && publicInputs.forPublic) {
|
|
335
|
-
publicOutput = await this.#simulatePublicCalls(simulatedTx, skipFeeEnforcement);
|
|
336
|
-
}
|
|
337
|
-
if (!skipTxValidation) {
|
|
338
|
-
const validationResult = await this.node.isValidTx(simulatedTx, {
|
|
339
|
-
isSimulation: true,
|
|
340
|
-
skipFeeEnforcement
|
|
336
|
+
simulateTx(txRequest, simulatePublic, msgSender = undefined, skipTxValidation = false, skipFeeEnforcement = false, profile = false, scopes) {
|
|
337
|
+
// We disable concurrent simulations since those might execute oracles which read and write to the PXE stores (e.g.
|
|
338
|
+
// to the capsules), and we need to prevent concurrent runs from interfering with one another (e.g. attempting to
|
|
339
|
+
// delete the same read value, or reading values that another simulation is currently modifying).
|
|
340
|
+
return this.#putInJobQueue(async ()=>{
|
|
341
|
+
try {
|
|
342
|
+
const txInfo = {
|
|
343
|
+
origin: txRequest.origin,
|
|
344
|
+
functionSelector: txRequest.functionSelector,
|
|
345
|
+
simulatePublic,
|
|
346
|
+
msgSender,
|
|
347
|
+
chainId: txRequest.txContext.chainId,
|
|
348
|
+
version: txRequest.txContext.version,
|
|
349
|
+
authWitnesses: txRequest.authWitnesses.map((w)=>w.requestHash)
|
|
350
|
+
};
|
|
351
|
+
this.log.info(`Simulating transaction execution request to ${txRequest.functionSelector} at ${txRequest.origin}`, txInfo);
|
|
352
|
+
const timer = new Timer();
|
|
353
|
+
await this.synchronizer.sync();
|
|
354
|
+
const privateExecutionResult = await this.#executePrivate(txRequest, msgSender, scopes);
|
|
355
|
+
const { publicInputs, profileResult } = await this.#prove(txRequest, this.proofCreator, privateExecutionResult, {
|
|
356
|
+
simulate: !profile,
|
|
357
|
+
skipFeeEnforcement,
|
|
358
|
+
profile
|
|
341
359
|
});
|
|
342
|
-
|
|
343
|
-
|
|
360
|
+
const privateSimulationResult = new PrivateSimulationResult(privateExecutionResult, publicInputs);
|
|
361
|
+
const simulatedTx = privateSimulationResult.toSimulatedTx();
|
|
362
|
+
let publicOutput;
|
|
363
|
+
if (simulatePublic && publicInputs.forPublic) {
|
|
364
|
+
publicOutput = await this.#simulatePublicCalls(simulatedTx, skipFeeEnforcement);
|
|
365
|
+
}
|
|
366
|
+
if (!skipTxValidation) {
|
|
367
|
+
const validationResult = await this.node.isValidTx(simulatedTx, {
|
|
368
|
+
isSimulation: true,
|
|
369
|
+
skipFeeEnforcement
|
|
370
|
+
});
|
|
371
|
+
if (validationResult.result === 'invalid') {
|
|
372
|
+
throw new Error('The simulated transaction is unable to be added to state and is invalid.');
|
|
373
|
+
}
|
|
344
374
|
}
|
|
375
|
+
const txHash = await simulatedTx.getTxHash();
|
|
376
|
+
this.log.info(`Simulation completed for ${txHash.toString()} in ${timer.ms()}ms`, {
|
|
377
|
+
txHash,
|
|
378
|
+
...txInfo,
|
|
379
|
+
...profileResult ? {
|
|
380
|
+
gateCounts: profileResult.gateCounts
|
|
381
|
+
} : {},
|
|
382
|
+
...publicOutput ? {
|
|
383
|
+
gasUsed: publicOutput.gasUsed,
|
|
384
|
+
revertCode: publicOutput.txEffect.revertCode.getCode(),
|
|
385
|
+
revertReason: publicOutput.revertReason
|
|
386
|
+
} : {}
|
|
387
|
+
});
|
|
388
|
+
return TxSimulationResult.fromPrivateSimulationResultAndPublicOutput(privateSimulationResult, publicOutput, profileResult);
|
|
389
|
+
} catch (err) {
|
|
390
|
+
throw this.contextualizeError(err, inspect(txRequest), `simulatePublic=${simulatePublic}`, `msgSender=${msgSender?.toString() ?? 'undefined'}`, `skipTxValidation=${skipTxValidation}`, `profile=${profile}`, `scopes=${scopes?.map((s)=>s.toString()).join(', ') ?? 'undefined'}`);
|
|
345
391
|
}
|
|
346
|
-
|
|
347
|
-
this.log.info(`Simulation completed for ${txHash.toString()} in ${timer.ms()}ms`, {
|
|
348
|
-
txHash,
|
|
349
|
-
...txInfo,
|
|
350
|
-
...profileResult ? {
|
|
351
|
-
gateCounts: profileResult.gateCounts
|
|
352
|
-
} : {},
|
|
353
|
-
...publicOutput ? {
|
|
354
|
-
gasUsed: publicOutput.gasUsed,
|
|
355
|
-
revertCode: publicOutput.txEffect.revertCode.getCode(),
|
|
356
|
-
revertReason: publicOutput.revertReason
|
|
357
|
-
} : {}
|
|
358
|
-
});
|
|
359
|
-
return TxSimulationResult.fromPrivateSimulationResultAndPublicOutput(privateSimulationResult, publicOutput, profileResult);
|
|
360
|
-
} catch (err) {
|
|
361
|
-
throw this.contextualizeError(err, inspect(txRequest), `simulatePublic=${simulatePublic}`, `msgSender=${msgSender?.toString() ?? 'undefined'}`, `skipTxValidation=${skipTxValidation}`, `profile=${profile}`, `scopes=${scopes?.map((s)=>s.toString()).join(', ') ?? 'undefined'}`);
|
|
362
|
-
}
|
|
392
|
+
});
|
|
363
393
|
}
|
|
364
394
|
async sendTx(tx) {
|
|
365
395
|
const txHash = await tx.getTxHash();
|
|
@@ -373,18 +403,23 @@ import { enrichPublicSimulationError, enrichSimulationError } from './error_enri
|
|
|
373
403
|
this.log.info(`Sent transaction ${txHash}`);
|
|
374
404
|
return txHash;
|
|
375
405
|
}
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
406
|
+
simulateUnconstrained(functionName, args, to, _from, scopes) {
|
|
407
|
+
// We disable concurrent simulations since those might execute oracles which read and write to the PXE stores (e.g.
|
|
408
|
+
// to the capsules), and we need to prevent concurrent runs from interfering with one another (e.g. attempting to
|
|
409
|
+
// delete the same read value, or reading values that another simulation is currently modifying).
|
|
410
|
+
return this.#putInJobQueue(async ()=>{
|
|
411
|
+
try {
|
|
412
|
+
await this.synchronizer.sync();
|
|
413
|
+
// TODO - Should check if `from` has the permission to call the view function.
|
|
414
|
+
const functionCall = await this.#getFunctionCall(functionName, args, to);
|
|
415
|
+
const executionResult = await this.#simulateUnconstrained(functionCall, scopes);
|
|
416
|
+
// TODO - Return typed result based on the function artifact.
|
|
417
|
+
return executionResult;
|
|
418
|
+
} catch (err) {
|
|
419
|
+
const stringifiedArgs = args.map((arg)=>arg.toString()).join(', ');
|
|
420
|
+
throw this.contextualizeError(err, `simulateUnconstrained ${to}:${functionName}(${stringifiedArgs})`, `scopes=${scopes?.map((s)=>s.toString()).join(', ') ?? 'undefined'}`);
|
|
421
|
+
}
|
|
422
|
+
});
|
|
388
423
|
}
|
|
389
424
|
getTxReceipt(txHash) {
|
|
390
425
|
return this.node.getTxReceipt(txHash);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/pxe",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.80.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.80.0",
|
|
63
|
+
"@aztec/bb.js": "0.80.0",
|
|
64
|
+
"@aztec/builder": "0.80.0",
|
|
65
|
+
"@aztec/constants": "0.80.0",
|
|
66
|
+
"@aztec/ethereum": "0.80.0",
|
|
67
|
+
"@aztec/foundation": "0.80.0",
|
|
68
|
+
"@aztec/key-store": "0.80.0",
|
|
69
|
+
"@aztec/kv-store": "0.80.0",
|
|
70
|
+
"@aztec/noir-protocol-circuits-types": "0.80.0",
|
|
71
|
+
"@aztec/noir-types": "0.80.0",
|
|
72
|
+
"@aztec/protocol-contracts": "0.80.0",
|
|
73
|
+
"@aztec/simulator": "0.80.0",
|
|
74
|
+
"@aztec/stdlib": "0.80.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.80.0",
|
|
85
85
|
"@jest/globals": "^29.5.0",
|
|
86
86
|
"@types/jest": "^29.5.0",
|
|
87
87
|
"@types/lodash.omit": "^4.5.7",
|
package/src/config/index.ts
CHANGED
|
@@ -107,6 +107,7 @@ export const allPxeConfigMappings: ConfigMappingsType<CliPXEOptions & PXEService
|
|
|
107
107
|
parseEnv: (val: string) => parseBooleanEnv(val) || !!process.env.NETWORK,
|
|
108
108
|
description: 'Enable real proofs',
|
|
109
109
|
isBoolean: true,
|
|
110
|
+
defaultValue: true,
|
|
110
111
|
},
|
|
111
112
|
};
|
|
112
113
|
|
|
@@ -718,10 +718,9 @@ export class PXEOracleInterface implements ExecutionDataProvider {
|
|
|
718
718
|
// Note that while this technically results in historical queries, we perform it at the latest locally synced block
|
|
719
719
|
// number which *should* be recent enough to be available, even for non-archive nodes.
|
|
720
720
|
const syncedBlockNumber = (await this.syncDataProvider.getBlockNumber())!;
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
//}
|
|
721
|
+
if (syncedBlockNumber === undefined) {
|
|
722
|
+
throw new Error(`Attempted to deliver a note with an unsynchronized PXE - this should never happen`);
|
|
723
|
+
}
|
|
725
724
|
|
|
726
725
|
// By computing siloed and unique note hashes ourselves we prevent contracts from interfering with the note storage
|
|
727
726
|
// of other contracts, which would constitute a security breach.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { L1_TO_L2_MSG_TREE_HEIGHT } from '@aztec/constants';
|
|
2
2
|
import { Fr, type Point } from '@aztec/foundation/fields';
|
|
3
3
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
4
|
+
import { SerialQueue } from '@aztec/foundation/queue';
|
|
4
5
|
import { Timer } from '@aztec/foundation/timer';
|
|
5
6
|
import type { SiblingPath } from '@aztec/foundation/trees';
|
|
6
7
|
import { KeyStore } from '@aztec/key-store';
|
|
@@ -103,6 +104,7 @@ export class PXEService implements PXE {
|
|
|
103
104
|
private proofCreator: PrivateKernelProver,
|
|
104
105
|
private protocolContractsProvider: ProtocolContractsProvider,
|
|
105
106
|
private log: Logger,
|
|
107
|
+
private jobQueue: SerialQueue,
|
|
106
108
|
) {}
|
|
107
109
|
|
|
108
110
|
/**
|
|
@@ -160,6 +162,8 @@ export class PXEService implements PXE {
|
|
|
160
162
|
log,
|
|
161
163
|
);
|
|
162
164
|
const simulator = new AcirSimulator(pxeOracleInterface, simulationProvider);
|
|
165
|
+
const jobQueue = new SerialQueue();
|
|
166
|
+
|
|
163
167
|
const pxeService = new PXEService(
|
|
164
168
|
node,
|
|
165
169
|
synchronizer,
|
|
@@ -177,13 +181,34 @@ export class PXEService implements PXE {
|
|
|
177
181
|
proofCreator,
|
|
178
182
|
protocolContractsProvider,
|
|
179
183
|
log,
|
|
184
|
+
jobQueue,
|
|
180
185
|
);
|
|
186
|
+
|
|
187
|
+
pxeService.jobQueue.start();
|
|
188
|
+
|
|
181
189
|
await pxeService.#registerProtocolContracts();
|
|
182
190
|
const info = await pxeService.getNodeInfo();
|
|
183
191
|
log.info(`Started PXE connected to chain ${info.l1ChainId} version ${info.protocolVersion}`);
|
|
184
192
|
return pxeService;
|
|
185
193
|
}
|
|
186
194
|
|
|
195
|
+
/**
|
|
196
|
+
* Enqueues a job for execution once no other jobs are running. Returns a promise that will resolve once the job is
|
|
197
|
+
* complete.
|
|
198
|
+
*
|
|
199
|
+
* Useful for tasks that cannot run concurrently, such as contract function simulation.
|
|
200
|
+
*/
|
|
201
|
+
#putInJobQueue<T>(fn: () => Promise<T>): Promise<T> {
|
|
202
|
+
// TODO(#12636): relax the conditions under which we forbid concurrency.
|
|
203
|
+
if (this.jobQueue.length() != 0) {
|
|
204
|
+
this.log.warn(
|
|
205
|
+
`PXE is already processing ${this.jobQueue.length()} jobs, concurrent execution is not supported. Will run once those are complete.`,
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
return this.jobQueue.put(fn);
|
|
210
|
+
}
|
|
211
|
+
|
|
187
212
|
isL1ToL2MessageSynced(l1ToL2Message: Fr): Promise<boolean> {
|
|
188
213
|
return this.node.isL1ToL2MessageSynced(l1ToL2Message);
|
|
189
214
|
}
|
|
@@ -364,35 +389,39 @@ export class PXEService implements PXE {
|
|
|
364
389
|
);
|
|
365
390
|
}
|
|
366
391
|
|
|
367
|
-
public
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
392
|
+
public updateContract(contractAddress: AztecAddress, artifact: ContractArtifact): Promise<void> {
|
|
393
|
+
// We disable concurrently updating contracts to avoid concurrently syncing with the node, or changing a contract's
|
|
394
|
+
// class while we're simulating it.
|
|
395
|
+
return this.#putInJobQueue(async () => {
|
|
396
|
+
const currentInstance = await this.contractDataProvider.getContractInstance(contractAddress);
|
|
397
|
+
const contractClass = await getContractClassFromArtifact(artifact);
|
|
398
|
+
await this.synchronizer.sync();
|
|
371
399
|
|
|
372
|
-
|
|
400
|
+
const header = await this.syncDataProvider.getBlockHeader();
|
|
373
401
|
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
402
|
+
const currentClassId = await readCurrentClassId(
|
|
403
|
+
contractAddress,
|
|
404
|
+
currentInstance,
|
|
405
|
+
this.node,
|
|
406
|
+
header.globalVariables.blockNumber.toNumber(),
|
|
407
|
+
);
|
|
408
|
+
if (!contractClass.id.equals(currentClassId)) {
|
|
409
|
+
throw new Error('Could not update contract to a class different from the current one.');
|
|
410
|
+
}
|
|
383
411
|
|
|
384
|
-
|
|
412
|
+
await this.contractDataProvider.addContractArtifact(contractClass.id, artifact);
|
|
385
413
|
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
414
|
+
const publicFunctionSignatures = artifact.functions
|
|
415
|
+
.filter(fn => fn.functionType === FunctionType.PUBLIC)
|
|
416
|
+
.map(fn => decodeFunctionSignature(fn.name, fn.parameters));
|
|
417
|
+
await this.node.registerContractFunctionSignatures(contractAddress, publicFunctionSignatures);
|
|
390
418
|
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
419
|
+
// TODO(#10007): Node should get public contract class from the registration event, not from PXE registration
|
|
420
|
+
await this.node.addContractClass({ ...contractClass, privateFunctions: [], unconstrainedFunctions: [] });
|
|
421
|
+
currentInstance.currentContractClassId = contractClass.id;
|
|
422
|
+
await this.contractDataProvider.addContractInstance(currentInstance);
|
|
423
|
+
this.log.info(`Updated contract ${artifact.name} at ${contractAddress.toString()} to class ${contractClass.id}`);
|
|
424
|
+
});
|
|
396
425
|
}
|
|
397
426
|
|
|
398
427
|
public getContracts(): Promise<AztecAddress[]> {
|
|
@@ -456,24 +485,33 @@ export class PXEService implements PXE {
|
|
|
456
485
|
return await this.node.getCurrentBaseFees();
|
|
457
486
|
}
|
|
458
487
|
|
|
459
|
-
public
|
|
488
|
+
public proveTx(
|
|
460
489
|
txRequest: TxExecutionRequest,
|
|
461
490
|
privateExecutionResult: PrivateExecutionResult,
|
|
462
491
|
): Promise<TxProvingResult> {
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
492
|
+
// We disable proving concurrently mostly out of caution, since it accesses some of our stores. Proving is so
|
|
493
|
+
// computationally demanding that it'd be rare for someone to try to do it concurrently regardless.
|
|
494
|
+
return this.#putInJobQueue(async () => {
|
|
495
|
+
try {
|
|
496
|
+
const { publicInputs, clientIvcProof } = await this.#prove(
|
|
497
|
+
txRequest,
|
|
498
|
+
this.proofCreator,
|
|
499
|
+
privateExecutionResult,
|
|
500
|
+
{
|
|
501
|
+
simulate: false,
|
|
502
|
+
skipFeeEnforcement: false,
|
|
503
|
+
profile: false,
|
|
504
|
+
},
|
|
505
|
+
);
|
|
506
|
+
return new TxProvingResult(privateExecutionResult, publicInputs, clientIvcProof!);
|
|
507
|
+
} catch (err: any) {
|
|
508
|
+
throw this.contextualizeError(err, inspect(txRequest), inspect(privateExecutionResult));
|
|
509
|
+
}
|
|
510
|
+
});
|
|
473
511
|
}
|
|
474
512
|
|
|
475
513
|
// TODO(#7456) Prevent msgSender being defined here for the first call
|
|
476
|
-
public
|
|
514
|
+
public simulateTx(
|
|
477
515
|
txRequest: TxExecutionRequest,
|
|
478
516
|
simulatePublic: boolean,
|
|
479
517
|
msgSender: AztecAddress | undefined = undefined,
|
|
@@ -482,74 +520,84 @@ export class PXEService implements PXE {
|
|
|
482
520
|
profile: boolean = false,
|
|
483
521
|
scopes?: AztecAddress[],
|
|
484
522
|
): Promise<TxSimulationResult> {
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
523
|
+
// We disable concurrent simulations since those might execute oracles which read and write to the PXE stores (e.g.
|
|
524
|
+
// to the capsules), and we need to prevent concurrent runs from interfering with one another (e.g. attempting to
|
|
525
|
+
// delete the same read value, or reading values that another simulation is currently modifying).
|
|
526
|
+
return this.#putInJobQueue(async () => {
|
|
527
|
+
try {
|
|
528
|
+
const txInfo = {
|
|
529
|
+
origin: txRequest.origin,
|
|
530
|
+
functionSelector: txRequest.functionSelector,
|
|
531
|
+
simulatePublic,
|
|
532
|
+
msgSender,
|
|
533
|
+
chainId: txRequest.txContext.chainId,
|
|
534
|
+
version: txRequest.txContext.version,
|
|
535
|
+
authWitnesses: txRequest.authWitnesses.map(w => w.requestHash),
|
|
536
|
+
};
|
|
537
|
+
this.log.info(
|
|
538
|
+
`Simulating transaction execution request to ${txRequest.functionSelector} at ${txRequest.origin}`,
|
|
539
|
+
txInfo,
|
|
540
|
+
);
|
|
541
|
+
const timer = new Timer();
|
|
542
|
+
await this.synchronizer.sync();
|
|
543
|
+
const privateExecutionResult = await this.#executePrivate(txRequest, msgSender, scopes);
|
|
544
|
+
|
|
545
|
+
const { publicInputs, profileResult } = await this.#prove(
|
|
546
|
+
txRequest,
|
|
547
|
+
this.proofCreator,
|
|
548
|
+
privateExecutionResult,
|
|
549
|
+
{
|
|
550
|
+
simulate: !profile,
|
|
551
|
+
skipFeeEnforcement,
|
|
552
|
+
profile,
|
|
553
|
+
},
|
|
554
|
+
);
|
|
515
555
|
|
|
516
|
-
|
|
517
|
-
const
|
|
518
|
-
|
|
519
|
-
|
|
556
|
+
const privateSimulationResult = new PrivateSimulationResult(privateExecutionResult, publicInputs);
|
|
557
|
+
const simulatedTx = privateSimulationResult.toSimulatedTx();
|
|
558
|
+
let publicOutput: PublicSimulationOutput | undefined;
|
|
559
|
+
if (simulatePublic && publicInputs.forPublic) {
|
|
560
|
+
publicOutput = await this.#simulatePublicCalls(simulatedTx, skipFeeEnforcement);
|
|
520
561
|
}
|
|
521
|
-
}
|
|
522
562
|
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
? {
|
|
530
|
-
gasUsed: publicOutput.gasUsed,
|
|
531
|
-
revertCode: publicOutput.txEffect.revertCode.getCode(),
|
|
532
|
-
revertReason: publicOutput.revertReason,
|
|
533
|
-
}
|
|
534
|
-
: {}),
|
|
535
|
-
});
|
|
563
|
+
if (!skipTxValidation) {
|
|
564
|
+
const validationResult = await this.node.isValidTx(simulatedTx, { isSimulation: true, skipFeeEnforcement });
|
|
565
|
+
if (validationResult.result === 'invalid') {
|
|
566
|
+
throw new Error('The simulated transaction is unable to be added to state and is invalid.');
|
|
567
|
+
}
|
|
568
|
+
}
|
|
536
569
|
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
570
|
+
const txHash = await simulatedTx.getTxHash();
|
|
571
|
+
this.log.info(`Simulation completed for ${txHash.toString()} in ${timer.ms()}ms`, {
|
|
572
|
+
txHash,
|
|
573
|
+
...txInfo,
|
|
574
|
+
...(profileResult ? { gateCounts: profileResult.gateCounts } : {}),
|
|
575
|
+
...(publicOutput
|
|
576
|
+
? {
|
|
577
|
+
gasUsed: publicOutput.gasUsed,
|
|
578
|
+
revertCode: publicOutput.txEffect.revertCode.getCode(),
|
|
579
|
+
revertReason: publicOutput.revertReason,
|
|
580
|
+
}
|
|
581
|
+
: {}),
|
|
582
|
+
});
|
|
583
|
+
|
|
584
|
+
return TxSimulationResult.fromPrivateSimulationResultAndPublicOutput(
|
|
585
|
+
privateSimulationResult,
|
|
586
|
+
publicOutput,
|
|
587
|
+
profileResult,
|
|
588
|
+
);
|
|
589
|
+
} catch (err: any) {
|
|
590
|
+
throw this.contextualizeError(
|
|
591
|
+
err,
|
|
592
|
+
inspect(txRequest),
|
|
593
|
+
`simulatePublic=${simulatePublic}`,
|
|
594
|
+
`msgSender=${msgSender?.toString() ?? 'undefined'}`,
|
|
595
|
+
`skipTxValidation=${skipTxValidation}`,
|
|
596
|
+
`profile=${profile}`,
|
|
597
|
+
`scopes=${scopes?.map(s => s.toString()).join(', ') ?? 'undefined'}`,
|
|
598
|
+
);
|
|
599
|
+
}
|
|
600
|
+
});
|
|
553
601
|
}
|
|
554
602
|
|
|
555
603
|
public async sendTx(tx: Tx): Promise<TxHash> {
|
|
@@ -565,29 +613,34 @@ export class PXEService implements PXE {
|
|
|
565
613
|
return txHash;
|
|
566
614
|
}
|
|
567
615
|
|
|
568
|
-
public
|
|
616
|
+
public simulateUnconstrained(
|
|
569
617
|
functionName: string,
|
|
570
618
|
args: any[],
|
|
571
619
|
to: AztecAddress,
|
|
572
620
|
_from?: AztecAddress,
|
|
573
621
|
scopes?: AztecAddress[],
|
|
574
622
|
): Promise<AbiDecoded> {
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
623
|
+
// We disable concurrent simulations since those might execute oracles which read and write to the PXE stores (e.g.
|
|
624
|
+
// to the capsules), and we need to prevent concurrent runs from interfering with one another (e.g. attempting to
|
|
625
|
+
// delete the same read value, or reading values that another simulation is currently modifying).
|
|
626
|
+
return this.#putInJobQueue(async () => {
|
|
627
|
+
try {
|
|
628
|
+
await this.synchronizer.sync();
|
|
629
|
+
// TODO - Should check if `from` has the permission to call the view function.
|
|
630
|
+
const functionCall = await this.#getFunctionCall(functionName, args, to);
|
|
631
|
+
const executionResult = await this.#simulateUnconstrained(functionCall, scopes);
|
|
632
|
+
|
|
633
|
+
// TODO - Return typed result based on the function artifact.
|
|
634
|
+
return executionResult;
|
|
635
|
+
} catch (err: any) {
|
|
636
|
+
const stringifiedArgs = args.map(arg => arg.toString()).join(', ');
|
|
637
|
+
throw this.contextualizeError(
|
|
638
|
+
err,
|
|
639
|
+
`simulateUnconstrained ${to}:${functionName}(${stringifiedArgs})`,
|
|
640
|
+
`scopes=${scopes?.map(s => s.toString()).join(', ') ?? 'undefined'}`,
|
|
641
|
+
);
|
|
642
|
+
}
|
|
643
|
+
});
|
|
591
644
|
}
|
|
592
645
|
|
|
593
646
|
public getTxReceipt(txHash: TxHash): Promise<TxReceipt> {
|