@aztec/pxe 5.3.0-nightly.20260924 → 5.3.0-rc.1
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/pxe.d.ts +27 -2
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +200 -127
- package/package.json +17 -17
- package/src/pxe.ts +290 -188
package/dest/pxe.d.ts
CHANGED
|
@@ -58,6 +58,18 @@ export type SimulateTxOpts = {
|
|
|
58
58
|
/** Sender address used to derive discovery tags for private messages (notes, events, logs) this tx emits. */
|
|
59
59
|
senderForTags?: AztecAddress;
|
|
60
60
|
};
|
|
61
|
+
/** Options for PXE.simulateAndProveTx. */
|
|
62
|
+
export type SimulateAndProveTxOpts = SimulateTxOpts & {
|
|
63
|
+
/**
|
|
64
|
+
* Returns the request to prove and its options, given the simulation's result. Runs inside the operation: other PXE
|
|
65
|
+
* operations wait for it to return, and it must not call the PXE itself, since that call would wait for this
|
|
66
|
+
* operation to end.
|
|
67
|
+
*/
|
|
68
|
+
prepareProve: (simulationResult: TxSimulationResult) => Promise<{
|
|
69
|
+
proveTxRequest: TxExecutionRequest;
|
|
70
|
+
proveOpts: ProveTxOpts;
|
|
71
|
+
}>;
|
|
72
|
+
};
|
|
61
73
|
/** Options for PXE.executeUtility. */
|
|
62
74
|
export type ExecuteUtilityOpts = {
|
|
63
75
|
/** The authentication witnesses required for the function call. */
|
|
@@ -336,7 +348,20 @@ export declare class PXE {
|
|
|
336
348
|
*
|
|
337
349
|
* TODO(#7456) Prevent msgSender being defined here for the first call
|
|
338
350
|
*/
|
|
339
|
-
simulateTx(txRequest: TxExecutionRequest,
|
|
351
|
+
simulateTx(txRequest: TxExecutionRequest, opts: SimulateTxOpts): Promise<TxSimulationResult>;
|
|
352
|
+
/**
|
|
353
|
+
* Combination of `simulateTx` and `proveTx`: a simulation is executed, its results inspected to produce a provable
|
|
354
|
+
* transaction, followed by witness generation and proof.
|
|
355
|
+
*
|
|
356
|
+
* The entire sequence runs as a single atomic PXE operation, with no private state sync between simulation and
|
|
357
|
+
* witness generation, resulting in them running over identical environments (e.g. the note store, tagging indices,
|
|
358
|
+
* etc.).
|
|
359
|
+
*
|
|
360
|
+
* The simulation result is passed to a `prepareProve` callback, which then returns the input to the equivalent
|
|
361
|
+
* `proveTx` call. Due to the atomic nature of this function, `prepareProve` must NOT call any PXE function, as that
|
|
362
|
+
* would result in a deadlock.
|
|
363
|
+
*/
|
|
364
|
+
simulateAndProveTx(simulationTxRequest: TxExecutionRequest, { prepareProve, ...simulateOpts }: SimulateAndProveTxOpts): Promise<TxProvingResult>;
|
|
340
365
|
/**
|
|
341
366
|
* Executes a contract utility function.
|
|
342
367
|
* @param call - The function call containing the function details, arguments, and target contract address.
|
|
@@ -361,4 +386,4 @@ export declare class PXE {
|
|
|
361
386
|
*/
|
|
362
387
|
stop(): Promise<void>;
|
|
363
388
|
}
|
|
364
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
389
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHhlLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvcHhlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLGtCQUFrQixFQUFFLE1BQU0sd0JBQXdCLENBQUM7QUFFakUsT0FBTyxFQUFFLEVBQUUsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBQ3BELE9BQU8sRUFBRSxLQUFLLEVBQUUsTUFBTSxtQ0FBbUMsQ0FBQztBQUMxRCxPQUFPLEVBQUUsS0FBSyxNQUFNLEVBQXFDLE1BQU0sdUJBQXVCLENBQUM7QUFJdkYsT0FBTyxLQUFLLEVBQUUsa0JBQWtCLEVBQUUsd0JBQXdCLEVBQUUsTUFBTSxrQkFBa0IsQ0FBQztBQUNyRixPQUFPLEtBQUssRUFBRSxpQkFBaUIsRUFBRSxNQUF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AE,cAAc,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAOlG;IAED;;;;;;;;;;;OAWG;IACI,kBAAkB,CACvB,mBAAmB,EAAE,kBAAkB,EACvC,EAAE,YAAY,EAAE,GAAG,YAAY,EAAE,EAAE,sBAAsB,GACxD,OAAO,CAAC,eAAe,CAAC,CAwD1B;IAED;;;OAGG;IACI,cAAc,CACnB,IAAI,EAAE,YAAY,EAClB,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAE,kBAAmC,GACxD,OAAO,CAAC,sBAAsB,CAAC,CAkEjC;IAED;;;;;;;;;;;;OAYG;IACI,gBAAgB,CAAC,aAAa,EAAE,aAAa,EAAE,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC,CA8B/G;IAED;;OAEG;IACU,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAIjC;CACF"}
|
package/dest/pxe.js
CHANGED
|
@@ -313,6 +313,141 @@ import { persistSenderTaggingIndexRangesForTx } from './tagging/index.js';
|
|
|
313
313
|
this.log.debug(`Executing kernel trace prover (${JSON.stringify(config)})...`);
|
|
314
314
|
return await kernelTraceProver.proveWithKernels(txExecutionRequest.toTxRequest(), privateExecutionResult, config);
|
|
315
315
|
}
|
|
316
|
+
/** Simulates `txRequest` within an already-open operation, using its anchor block and change set. */ async #simulateTx({ changeSetId, syncTime, anchorBlockHeader, recording, totalMs }, txRequest, { simulatePublic, skipTxValidation = false, skipFeeEnforcement = false, skipKernels = true, overrides, scopes, senderForTags }) {
|
|
317
|
+
const txInfo = {
|
|
318
|
+
origin: txRequest.origin,
|
|
319
|
+
functionSelector: txRequest.functionSelector,
|
|
320
|
+
simulatePublic,
|
|
321
|
+
chainId: txRequest.txContext.chainId,
|
|
322
|
+
version: txRequest.txContext.version,
|
|
323
|
+
authWitnesses: txRequest.authWitnesses.map((w)=>w.requestHash)
|
|
324
|
+
};
|
|
325
|
+
this.log.info(`Simulating transaction execution request to ${txRequest.functionSelector} at ${txRequest.origin}`, txInfo);
|
|
326
|
+
if (overrides?.contracts && Object.keys(overrides.contracts).length > 0 && !skipKernels) {
|
|
327
|
+
throw new Error('Simulating with overridden contracts is not compatible with kernel execution. Please set skipKernels to true when simulating with overridden contracts.');
|
|
328
|
+
}
|
|
329
|
+
const contractFunctionSimulator = this.#getSimulatorForTx(overrides);
|
|
330
|
+
// Execution of private functions only; no proving, and no kernel logic.
|
|
331
|
+
const privateExecutionResult = await this.#executePrivate({
|
|
332
|
+
contractFunctionSimulator,
|
|
333
|
+
txRequest,
|
|
334
|
+
anchorBlockHeader,
|
|
335
|
+
scopes,
|
|
336
|
+
changeSetId,
|
|
337
|
+
senderForTags
|
|
338
|
+
});
|
|
339
|
+
let publicInputs;
|
|
340
|
+
let executionSteps = [];
|
|
341
|
+
if (skipKernels) {
|
|
342
|
+
({ publicInputs, executionSteps } = await generateSimulatedProvingResult(privateExecutionResult, (addr, sel)=>this.#getDebugFunctionName(addr, sel, anchorBlockHeader), this.node));
|
|
343
|
+
} else {
|
|
344
|
+
// Kernel logic, plus proving of all private functions and kernels.
|
|
345
|
+
({ publicInputs, executionSteps } = await this.#prove(txRequest, this.proofCreator, privateExecutionResult, anchorBlockHeader, {
|
|
346
|
+
simulate: true,
|
|
347
|
+
skipFeeEnforcement,
|
|
348
|
+
profileMode: 'none'
|
|
349
|
+
}));
|
|
350
|
+
}
|
|
351
|
+
const privateSimulationResult = new PrivateSimulationResult(privateExecutionResult, publicInputs);
|
|
352
|
+
const simulatedTx = await privateSimulationResult.toSimulatedTx();
|
|
353
|
+
let publicSimulationTime;
|
|
354
|
+
let publicOutput;
|
|
355
|
+
if (simulatePublic && publicInputs.forPublic) {
|
|
356
|
+
const publicSimulationTimer = new Timer();
|
|
357
|
+
publicOutput = await this.#simulatePublicCalls(simulatedTx, skipFeeEnforcement, overrides);
|
|
358
|
+
publicSimulationTime = publicSimulationTimer.ms();
|
|
359
|
+
if (publicOutput?.debugLogs?.length) {
|
|
360
|
+
await displayDebugLogs(publicOutput.debugLogs, (addr)=>this.#getDebugContractName(addr, anchorBlockHeader));
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
let validationTime;
|
|
364
|
+
if (!skipTxValidation) {
|
|
365
|
+
const validationTimer = new Timer();
|
|
366
|
+
const validationResult = await this.node.isValidTx(simulatedTx, {
|
|
367
|
+
isSimulation: true,
|
|
368
|
+
skipFeeEnforcement
|
|
369
|
+
});
|
|
370
|
+
validationTime = validationTimer.ms();
|
|
371
|
+
if (validationResult.result === 'invalid') {
|
|
372
|
+
const reason = validationResult.reason.length > 0 ? ` Reason: ${validationResult.reason.join(', ')}` : '';
|
|
373
|
+
throw new Error(`The simulated transaction is unable to be added to state and is invalid.${reason}`);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
const txHash = simulatedTx.getTxHash();
|
|
377
|
+
const totalTime = totalMs();
|
|
378
|
+
const perFunction = executionSteps.map(({ functionName, timings: { witgen, oracles } })=>({
|
|
379
|
+
functionName,
|
|
380
|
+
time: witgen,
|
|
381
|
+
oracles
|
|
382
|
+
}));
|
|
383
|
+
const timings = {
|
|
384
|
+
total: totalTime,
|
|
385
|
+
sync: syncTime,
|
|
386
|
+
publicSimulation: publicSimulationTime,
|
|
387
|
+
validation: validationTime,
|
|
388
|
+
perFunction,
|
|
389
|
+
unaccounted: totalTime - (syncTime + (publicSimulationTime ?? 0) + (validationTime ?? 0) + perFunction.reduce((acc, { time })=>acc + time, 0))
|
|
390
|
+
};
|
|
391
|
+
this.log.info(`Simulation completed for ${txHash.toString()} in ${totalTime}ms`, {
|
|
392
|
+
txHash,
|
|
393
|
+
...txInfo,
|
|
394
|
+
...publicOutput ? {
|
|
395
|
+
gasUsed: publicOutput.gasUsed,
|
|
396
|
+
revertCode: publicOutput.txEffect.revertCode.getCode(),
|
|
397
|
+
revertReason: publicOutput.revertReason
|
|
398
|
+
} : {}
|
|
399
|
+
});
|
|
400
|
+
return TxSimulationResult.fromPrivateSimulationResultAndPublicOutput(privateSimulationResult, publicOutput, {
|
|
401
|
+
timings,
|
|
402
|
+
nodeRPCCalls: recording.stats()
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
/** Describes a simulation of `txRequest` for the errors it throws. */ #simulateTxErrorContext(txRequest, opts) {
|
|
406
|
+
return [
|
|
407
|
+
inspect(txRequest),
|
|
408
|
+
`simulatePublic=${opts.simulatePublic}`,
|
|
409
|
+
`skipTxValidation=${opts.skipTxValidation ?? false}`,
|
|
410
|
+
`scopes=${opts.scopes.map((s)=>s.toString()).join(', ')}`
|
|
411
|
+
];
|
|
412
|
+
}
|
|
413
|
+
/**
|
|
414
|
+
* Proves `privateExecutionResult`, the private execution of `txRequest`, within an already-open operation, and stages
|
|
415
|
+
* the sender tagging indices the tx uses.
|
|
416
|
+
*/ async #proveTx({ changeSetId, syncTime, anchorBlockHeader, recording, totalMs }, txRequest, privateExecutionResult) {
|
|
417
|
+
const { publicInputs, chonkProof, executionSteps, timings: { proving } = {} } = await this.#prove(txRequest, this.proofCreator, privateExecutionResult, anchorBlockHeader, {
|
|
418
|
+
simulate: false,
|
|
419
|
+
skipFeeEnforcement: false,
|
|
420
|
+
profileMode: 'none'
|
|
421
|
+
});
|
|
422
|
+
const totalTime = totalMs();
|
|
423
|
+
const perFunction = executionSteps.map(({ functionName, timings: { witgen, oracles } })=>({
|
|
424
|
+
functionName,
|
|
425
|
+
time: witgen,
|
|
426
|
+
oracles
|
|
427
|
+
}));
|
|
428
|
+
const timings = {
|
|
429
|
+
total: totalTime,
|
|
430
|
+
sync: syncTime,
|
|
431
|
+
proving,
|
|
432
|
+
perFunction,
|
|
433
|
+
unaccounted: totalTime - ((syncTime ?? 0) + (proving ?? 0) + perFunction.reduce((acc, { time })=>acc + time, 0))
|
|
434
|
+
};
|
|
435
|
+
this.log.debug(`Proving completed in ${totalTime}ms`, {
|
|
436
|
+
timings
|
|
437
|
+
});
|
|
438
|
+
const txProvingResult = new TxProvingResult(privateExecutionResult, publicInputs, chonkProof, {
|
|
439
|
+
timings,
|
|
440
|
+
nodeRPCCalls: recording.stats()
|
|
441
|
+
});
|
|
442
|
+
// We keep track of which tagging indices we've used in this tx so that we don't repeat them in future txs
|
|
443
|
+
// (which would link them) without having to rely on this tx being mined (and us seeing the indices being used
|
|
444
|
+
// onchain).
|
|
445
|
+
// Note that this must happen _after_ proving as it requires the proof's public inputs, from which the kernels
|
|
446
|
+
// may have removed some logs due to note-nullifier squashing - this may lead to range of tagging indices we've
|
|
447
|
+
// actually used to being reduced.
|
|
448
|
+
await persistSenderTaggingIndexRangesForTx(this.senderTaggingStore, privateExecutionResult.entrypoint.taggingIndexRanges, publicInputs, ()=>txProvingResult.getTxHash(), changeSetId, this.log);
|
|
449
|
+
return txProvingResult;
|
|
450
|
+
}
|
|
316
451
|
// Public API
|
|
317
452
|
/**
|
|
318
453
|
* Triggers a sync of PXE state with the node, regardless of the `autoSync` config flag. Use this to
|
|
@@ -574,49 +709,17 @@ import { persistSenderTaggingIndexRangesForTx } from './tagging/index.js';
|
|
|
574
709
|
let privateExecutionResult;
|
|
575
710
|
// We disable proving concurrently mostly out of caution, since it accesses some of our stores. Proving is so
|
|
576
711
|
// computationally demanding that it'd be rare for someone to try to do it concurrently regardless.
|
|
577
|
-
return this.operationQueue.runSynced(async (
|
|
712
|
+
return this.operationQueue.runSynced(async (ctx)=>{
|
|
578
713
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
579
714
|
privateExecutionResult = await this.#executePrivate({
|
|
580
715
|
contractFunctionSimulator,
|
|
581
716
|
txRequest,
|
|
582
|
-
anchorBlockHeader,
|
|
717
|
+
anchorBlockHeader: ctx.anchorBlockHeader,
|
|
583
718
|
scopes,
|
|
584
|
-
changeSetId,
|
|
719
|
+
changeSetId: ctx.changeSetId,
|
|
585
720
|
senderForTags
|
|
586
721
|
});
|
|
587
|
-
|
|
588
|
-
simulate: false,
|
|
589
|
-
skipFeeEnforcement: false,
|
|
590
|
-
profileMode: 'none'
|
|
591
|
-
});
|
|
592
|
-
const totalTime = totalMs();
|
|
593
|
-
const perFunction = executionSteps.map(({ functionName, timings: { witgen, oracles } })=>({
|
|
594
|
-
functionName,
|
|
595
|
-
time: witgen,
|
|
596
|
-
oracles
|
|
597
|
-
}));
|
|
598
|
-
const timings = {
|
|
599
|
-
total: totalTime,
|
|
600
|
-
sync: syncTime,
|
|
601
|
-
proving,
|
|
602
|
-
perFunction,
|
|
603
|
-
unaccounted: totalTime - ((syncTime ?? 0) + (proving ?? 0) + perFunction.reduce((acc, { time })=>acc + time, 0))
|
|
604
|
-
};
|
|
605
|
-
this.log.debug(`Proving completed in ${totalTime}ms`, {
|
|
606
|
-
timings
|
|
607
|
-
});
|
|
608
|
-
const txProvingResult = new TxProvingResult(privateExecutionResult, publicInputs, chonkProof, {
|
|
609
|
-
timings,
|
|
610
|
-
nodeRPCCalls: recording.stats()
|
|
611
|
-
});
|
|
612
|
-
// We keep track of which tagging indices we've used in this tx so that we don't repeat them in future txs
|
|
613
|
-
// (which would link them) without having to rely on this tx being mined (and us seeing the indices being used
|
|
614
|
-
// onchain).
|
|
615
|
-
// Note that this must happen _after_ proving as it requires the proof's public inputs, from which the kernels
|
|
616
|
-
// may have removed some logs due to note-nullifier squashing - this may lead to range of tagging indices we've
|
|
617
|
-
// actually used to being reduced.
|
|
618
|
-
await persistSenderTaggingIndexRangesForTx(this.senderTaggingStore, privateExecutionResult.entrypoint.taggingIndexRanges, publicInputs, ()=>txProvingResult.getTxHash(), changeSetId, this.log);
|
|
619
|
-
return txProvingResult;
|
|
722
|
+
return this.#proveTx(ctx, txRequest, privateExecutionResult);
|
|
620
723
|
}, {
|
|
621
724
|
errorContext: ()=>[
|
|
622
725
|
inspect(txRequest),
|
|
@@ -701,104 +804,74 @@ import { persistSenderTaggingIndexRangesForTx } from './tagging/index.js';
|
|
|
701
804
|
* Also throws if simulatePublic is true and public simulation reverts.
|
|
702
805
|
*
|
|
703
806
|
* TODO(#7456) Prevent msgSender being defined here for the first call
|
|
704
|
-
*/ simulateTx(txRequest,
|
|
807
|
+
*/ simulateTx(txRequest, opts) {
|
|
705
808
|
// We disable concurrent simulations since those might execute oracles which read and write to the PXE stores (e.g.
|
|
706
809
|
// to the capsules), and we need to prevent concurrent runs from interfering with one another (e.g. attempting to
|
|
707
810
|
// delete the same read value, or reading values that another simulation is currently modifying).
|
|
708
|
-
return this.operationQueue.runSynced(
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
const
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
const validationTimer = new Timer();
|
|
758
|
-
const validationResult = await this.node.isValidTx(simulatedTx, {
|
|
759
|
-
isSimulation: true,
|
|
760
|
-
skipFeeEnforcement
|
|
811
|
+
return this.operationQueue.runSynced((ctx)=>this.#simulateTx(ctx, txRequest, opts), {
|
|
812
|
+
errorContext: ()=>this.#simulateTxErrorContext(txRequest, opts)
|
|
813
|
+
});
|
|
814
|
+
}
|
|
815
|
+
/**
|
|
816
|
+
* Combination of `simulateTx` and `proveTx`: a simulation is executed, its results inspected to produce a provable
|
|
817
|
+
* transaction, followed by witness generation and proof.
|
|
818
|
+
*
|
|
819
|
+
* The entire sequence runs as a single atomic PXE operation, with no private state sync between simulation and
|
|
820
|
+
* witness generation, resulting in them running over identical environments (e.g. the note store, tagging indices,
|
|
821
|
+
* etc.).
|
|
822
|
+
*
|
|
823
|
+
* The simulation result is passed to a `prepareProve` callback, which then returns the input to the equivalent
|
|
824
|
+
* `proveTx` call. Due to the atomic nature of this function, `prepareProve` must NOT call any PXE function, as that
|
|
825
|
+
* would result in a deadlock.
|
|
826
|
+
*/ simulateAndProveTx(simulationTxRequest, { prepareProve, ...simulateOpts }) {
|
|
827
|
+
let proveTxRequest;
|
|
828
|
+
let privateExecutionResult;
|
|
829
|
+
// We run the entire thing as a single operation, which blocks the queue. There are two other possible paths we
|
|
830
|
+
// could take here:
|
|
831
|
+
// a) decouple the queue from a changeset to commit. This would let us hold the queue and have two changesets, one
|
|
832
|
+
// for the simulation and its corresponding sync, and one for the prove. In case of failure of either the
|
|
833
|
+
// `prepareProve` callback (e.g. user rejection) or the proof itself, we'd still have committed the simulation
|
|
834
|
+
// work, including the private state sync, which could save time in future runs.
|
|
835
|
+
// b) make this be two separate jobs, releasing the queue in between, but holding a second lock which would prevent
|
|
836
|
+
// PXE from updating its anchor block and therefore re-syncing contracts. In the case of a long-running
|
|
837
|
+
// callback, other unrelated operations (e.g. utility call invocations) would still be able to go through.
|
|
838
|
+
//
|
|
839
|
+
// We're not currently taking either of these paths due to uncertainty on this even being a good primitive for PXE
|
|
840
|
+
// to expose to wallets, and to not invest too heavily in this direction (as both approaches would require
|
|
841
|
+
// refactoring). Additionally, the gains those approaches provide are currently not valuable: for a) we expect it to
|
|
842
|
+
// be unlikely for a follow-up simulation to be executed on the same anchor block as the first one, so committing
|
|
843
|
+
// the sync achieves little if anything, and for b) the callback is expected to be fairly quick, and for there to be
|
|
844
|
+
// no need to execute any other PXE calls while it runs.
|
|
845
|
+
return this.operationQueue.runSynced(async (ctx)=>{
|
|
846
|
+
const simulationResult = await this.#simulateTx(ctx, simulationTxRequest, simulateOpts);
|
|
847
|
+
let proveOpts;
|
|
848
|
+
({ proveTxRequest, proveOpts } = await prepareProve(simulationResult));
|
|
849
|
+
// The proving result's timings and node stats must cover proving alone, not the simulation before it.
|
|
850
|
+
const provingTimer = new Timer();
|
|
851
|
+
const recording = this.node.startRecording();
|
|
852
|
+
try {
|
|
853
|
+
privateExecutionResult = await this.#executePrivate({
|
|
854
|
+
contractFunctionSimulator: this.#getSimulatorForTx(),
|
|
855
|
+
txRequest: proveTxRequest,
|
|
856
|
+
anchorBlockHeader: ctx.anchorBlockHeader,
|
|
857
|
+
scopes: proveOpts.scopes,
|
|
858
|
+
changeSetId: ctx.changeSetId,
|
|
859
|
+
senderForTags: proveOpts.senderForTags
|
|
761
860
|
});
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
861
|
+
return await this.#proveTx({
|
|
862
|
+
...ctx,
|
|
863
|
+
syncTime: 0,
|
|
864
|
+
recording,
|
|
865
|
+
totalMs: ()=>provingTimer.ms()
|
|
866
|
+
}, proveTxRequest, privateExecutionResult);
|
|
867
|
+
} finally{
|
|
868
|
+
recording.stop();
|
|
767
869
|
}
|
|
768
|
-
const txHash = simulatedTx.getTxHash();
|
|
769
|
-
const totalTime = totalMs();
|
|
770
|
-
const perFunction = executionSteps.map(({ functionName, timings: { witgen, oracles } })=>({
|
|
771
|
-
functionName,
|
|
772
|
-
time: witgen,
|
|
773
|
-
oracles
|
|
774
|
-
}));
|
|
775
|
-
const timings = {
|
|
776
|
-
total: totalTime,
|
|
777
|
-
sync: syncTime,
|
|
778
|
-
publicSimulation: publicSimulationTime,
|
|
779
|
-
validation: validationTime,
|
|
780
|
-
perFunction,
|
|
781
|
-
unaccounted: totalTime - (syncTime + (publicSimulationTime ?? 0) + (validationTime ?? 0) + perFunction.reduce((acc, { time })=>acc + time, 0))
|
|
782
|
-
};
|
|
783
|
-
this.log.info(`Simulation completed for ${txHash.toString()} in ${totalTime}ms`, {
|
|
784
|
-
txHash,
|
|
785
|
-
...txInfo,
|
|
786
|
-
...publicOutput ? {
|
|
787
|
-
gasUsed: publicOutput.gasUsed,
|
|
788
|
-
revertCode: publicOutput.txEffect.revertCode.getCode(),
|
|
789
|
-
revertReason: publicOutput.revertReason
|
|
790
|
-
} : {}
|
|
791
|
-
});
|
|
792
|
-
return TxSimulationResult.fromPrivateSimulationResultAndPublicOutput(privateSimulationResult, publicOutput, {
|
|
793
|
-
timings,
|
|
794
|
-
nodeRPCCalls: recording.stats()
|
|
795
|
-
});
|
|
796
870
|
}, {
|
|
797
871
|
errorContext: ()=>[
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
`scopes=${scopes.map((s)=>s.toString()).join(', ')}`
|
|
872
|
+
...this.#simulateTxErrorContext(simulationTxRequest, simulateOpts),
|
|
873
|
+
inspect(proveTxRequest),
|
|
874
|
+
inspect(privateExecutionResult)
|
|
802
875
|
]
|
|
803
876
|
});
|
|
804
877
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/pxe",
|
|
3
|
-
"version": "5.3.0-
|
|
3
|
+
"version": "5.3.0-rc.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"typedocOptions": {
|
|
6
6
|
"entryPoints": [
|
|
@@ -71,20 +71,20 @@
|
|
|
71
71
|
]
|
|
72
72
|
},
|
|
73
73
|
"dependencies": {
|
|
74
|
-
"@aztec/bb-prover": "5.3.0-
|
|
75
|
-
"@aztec/bb.js": "5.3.0-
|
|
76
|
-
"@aztec/builder": "5.3.0-
|
|
77
|
-
"@aztec/constants": "5.3.0-
|
|
78
|
-
"@aztec/ethereum": "5.3.0-
|
|
79
|
-
"@aztec/foundation": "5.3.0-
|
|
80
|
-
"@aztec/key-store": "5.3.0-
|
|
81
|
-
"@aztec/kv-store": "5.3.0-
|
|
82
|
-
"@aztec/noir-protocol-circuits-types": "5.3.0-
|
|
83
|
-
"@aztec/noir-types": "5.3.0-
|
|
84
|
-
"@aztec/protocol-contracts": "5.3.0-
|
|
85
|
-
"@aztec/simulator": "5.3.0-
|
|
86
|
-
"@aztec/standard-contracts": "5.3.0-
|
|
87
|
-
"@aztec/stdlib": "5.3.0-
|
|
74
|
+
"@aztec/bb-prover": "5.3.0-rc.1",
|
|
75
|
+
"@aztec/bb.js": "5.3.0-rc.1",
|
|
76
|
+
"@aztec/builder": "5.3.0-rc.1",
|
|
77
|
+
"@aztec/constants": "5.3.0-rc.1",
|
|
78
|
+
"@aztec/ethereum": "5.3.0-rc.1",
|
|
79
|
+
"@aztec/foundation": "5.3.0-rc.1",
|
|
80
|
+
"@aztec/key-store": "5.3.0-rc.1",
|
|
81
|
+
"@aztec/kv-store": "5.3.0-rc.1",
|
|
82
|
+
"@aztec/noir-protocol-circuits-types": "5.3.0-rc.1",
|
|
83
|
+
"@aztec/noir-types": "5.3.0-rc.1",
|
|
84
|
+
"@aztec/protocol-contracts": "5.3.0-rc.1",
|
|
85
|
+
"@aztec/simulator": "5.3.0-rc.1",
|
|
86
|
+
"@aztec/standard-contracts": "5.3.0-rc.1",
|
|
87
|
+
"@aztec/stdlib": "5.3.0-rc.1",
|
|
88
88
|
"koa": "^2.16.1",
|
|
89
89
|
"koa-router": "^13.1.1",
|
|
90
90
|
"lodash.omit": "^4.5.0",
|
|
@@ -93,8 +93,8 @@
|
|
|
93
93
|
"viem": "npm:@aztec/viem@2.38.2"
|
|
94
94
|
},
|
|
95
95
|
"devDependencies": {
|
|
96
|
-
"@aztec/noir-test-contracts.js": "5.3.0-
|
|
97
|
-
"@aztec/world-state": "5.3.0-
|
|
96
|
+
"@aztec/noir-test-contracts.js": "5.3.0-rc.1",
|
|
97
|
+
"@aztec/world-state": "5.3.0-rc.1",
|
|
98
98
|
"@jest/globals": "^30.0.0",
|
|
99
99
|
"@types/jest": "^30.0.0",
|
|
100
100
|
"@types/lodash.omit": "^4.5.7",
|
package/src/pxe.ts
CHANGED
|
@@ -73,7 +73,7 @@ import { PrivateEventFilterValidator } from './events/private_event_filter_valid
|
|
|
73
73
|
import type { ExecutionHooks } from './hooks/index.js';
|
|
74
74
|
import { TxResolverService } from './messages/tx_resolver_service.js';
|
|
75
75
|
import { type CachingAztecNode, withCache } from './node/caching_aztec_node.js';
|
|
76
|
-
import { OperationQueue } from './operation_queue.js';
|
|
76
|
+
import { OperationQueue, type SyncedOperationContext } from './operation_queue.js';
|
|
77
77
|
import {
|
|
78
78
|
PrivateKernelExecutionProver,
|
|
79
79
|
type PrivateKernelExecutionProverConfig,
|
|
@@ -143,6 +143,18 @@ export type SimulateTxOpts = {
|
|
|
143
143
|
senderForTags?: AztecAddress;
|
|
144
144
|
};
|
|
145
145
|
|
|
146
|
+
/** Options for PXE.simulateAndProveTx. */
|
|
147
|
+
export type SimulateAndProveTxOpts = SimulateTxOpts & {
|
|
148
|
+
/**
|
|
149
|
+
* Returns the request to prove and its options, given the simulation's result. Runs inside the operation: other PXE
|
|
150
|
+
* operations wait for it to return, and it must not call the PXE itself, since that call would wait for this
|
|
151
|
+
* operation to end.
|
|
152
|
+
*/
|
|
153
|
+
prepareProve: (
|
|
154
|
+
simulationResult: TxSimulationResult,
|
|
155
|
+
) => Promise<{ proveTxRequest: TxExecutionRequest; proveOpts: ProveTxOpts }>;
|
|
156
|
+
};
|
|
157
|
+
|
|
146
158
|
/** Options for PXE.executeUtility. */
|
|
147
159
|
export type ExecuteUtilityOpts = {
|
|
148
160
|
/** The authentication witnesses required for the function call. */
|
|
@@ -649,6 +661,212 @@ export class PXE {
|
|
|
649
661
|
return await kernelTraceProver.proveWithKernels(txExecutionRequest.toTxRequest(), privateExecutionResult, config);
|
|
650
662
|
}
|
|
651
663
|
|
|
664
|
+
/** Simulates `txRequest` within an already-open operation, using its anchor block and change set. */
|
|
665
|
+
async #simulateTx(
|
|
666
|
+
{ changeSetId, syncTime, anchorBlockHeader, recording, totalMs }: SyncedOperationContext,
|
|
667
|
+
txRequest: TxExecutionRequest,
|
|
668
|
+
{
|
|
669
|
+
simulatePublic,
|
|
670
|
+
skipTxValidation = false,
|
|
671
|
+
skipFeeEnforcement = false,
|
|
672
|
+
skipKernels = true,
|
|
673
|
+
overrides,
|
|
674
|
+
scopes,
|
|
675
|
+
senderForTags,
|
|
676
|
+
}: SimulateTxOpts,
|
|
677
|
+
): Promise<TxSimulationResult> {
|
|
678
|
+
const txInfo = {
|
|
679
|
+
origin: txRequest.origin,
|
|
680
|
+
functionSelector: txRequest.functionSelector,
|
|
681
|
+
simulatePublic,
|
|
682
|
+
chainId: txRequest.txContext.chainId,
|
|
683
|
+
version: txRequest.txContext.version,
|
|
684
|
+
authWitnesses: txRequest.authWitnesses.map(w => w.requestHash),
|
|
685
|
+
};
|
|
686
|
+
this.log.info(
|
|
687
|
+
`Simulating transaction execution request to ${txRequest.functionSelector} at ${txRequest.origin}`,
|
|
688
|
+
txInfo,
|
|
689
|
+
);
|
|
690
|
+
|
|
691
|
+
if (overrides?.contracts && Object.keys(overrides.contracts).length > 0 && !skipKernels) {
|
|
692
|
+
throw new Error(
|
|
693
|
+
'Simulating with overridden contracts is not compatible with kernel execution. Please set skipKernels to true when simulating with overridden contracts.',
|
|
694
|
+
);
|
|
695
|
+
}
|
|
696
|
+
const contractFunctionSimulator = this.#getSimulatorForTx(overrides);
|
|
697
|
+
|
|
698
|
+
// Execution of private functions only; no proving, and no kernel logic.
|
|
699
|
+
const privateExecutionResult = await this.#executePrivate({
|
|
700
|
+
contractFunctionSimulator,
|
|
701
|
+
txRequest,
|
|
702
|
+
anchorBlockHeader,
|
|
703
|
+
scopes,
|
|
704
|
+
changeSetId,
|
|
705
|
+
senderForTags,
|
|
706
|
+
});
|
|
707
|
+
|
|
708
|
+
let publicInputs: PrivateKernelTailCircuitPublicInputs | undefined;
|
|
709
|
+
let executionSteps: PrivateExecutionStep[] = [];
|
|
710
|
+
|
|
711
|
+
if (skipKernels) {
|
|
712
|
+
({ publicInputs, executionSteps } = await generateSimulatedProvingResult(
|
|
713
|
+
privateExecutionResult,
|
|
714
|
+
(addr, sel) => this.#getDebugFunctionName(addr, sel, anchorBlockHeader),
|
|
715
|
+
this.node,
|
|
716
|
+
));
|
|
717
|
+
} else {
|
|
718
|
+
// Kernel logic, plus proving of all private functions and kernels.
|
|
719
|
+
({ publicInputs, executionSteps } = await this.#prove(
|
|
720
|
+
txRequest,
|
|
721
|
+
this.proofCreator,
|
|
722
|
+
privateExecutionResult,
|
|
723
|
+
anchorBlockHeader,
|
|
724
|
+
{
|
|
725
|
+
simulate: true,
|
|
726
|
+
skipFeeEnforcement,
|
|
727
|
+
profileMode: 'none',
|
|
728
|
+
},
|
|
729
|
+
));
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
const privateSimulationResult = new PrivateSimulationResult(privateExecutionResult, publicInputs);
|
|
733
|
+
const simulatedTx = await privateSimulationResult.toSimulatedTx();
|
|
734
|
+
let publicSimulationTime: number | undefined;
|
|
735
|
+
let publicOutput: PublicSimulationOutput | undefined;
|
|
736
|
+
if (simulatePublic && publicInputs.forPublic) {
|
|
737
|
+
const publicSimulationTimer = new Timer();
|
|
738
|
+
publicOutput = await this.#simulatePublicCalls(simulatedTx, skipFeeEnforcement, overrides);
|
|
739
|
+
publicSimulationTime = publicSimulationTimer.ms();
|
|
740
|
+
if (publicOutput?.debugLogs?.length) {
|
|
741
|
+
await displayDebugLogs(publicOutput.debugLogs, addr => this.#getDebugContractName(addr, anchorBlockHeader));
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
let validationTime: number | undefined;
|
|
746
|
+
if (!skipTxValidation) {
|
|
747
|
+
const validationTimer = new Timer();
|
|
748
|
+
const validationResult = await this.node.isValidTx(simulatedTx, { isSimulation: true, skipFeeEnforcement });
|
|
749
|
+
validationTime = validationTimer.ms();
|
|
750
|
+
if (validationResult.result === 'invalid') {
|
|
751
|
+
const reason = validationResult.reason.length > 0 ? ` Reason: ${validationResult.reason.join(', ')}` : '';
|
|
752
|
+
throw new Error(`The simulated transaction is unable to be added to state and is invalid.${reason}`);
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
const txHash = simulatedTx.getTxHash();
|
|
757
|
+
|
|
758
|
+
const totalTime = totalMs();
|
|
759
|
+
|
|
760
|
+
const perFunction = executionSteps.map(({ functionName, timings: { witgen, oracles } }) => ({
|
|
761
|
+
functionName,
|
|
762
|
+
time: witgen,
|
|
763
|
+
oracles,
|
|
764
|
+
}));
|
|
765
|
+
|
|
766
|
+
const timings: SimulationTimings = {
|
|
767
|
+
total: totalTime,
|
|
768
|
+
sync: syncTime,
|
|
769
|
+
publicSimulation: publicSimulationTime,
|
|
770
|
+
validation: validationTime,
|
|
771
|
+
perFunction,
|
|
772
|
+
unaccounted:
|
|
773
|
+
totalTime -
|
|
774
|
+
(syncTime +
|
|
775
|
+
(publicSimulationTime ?? 0) +
|
|
776
|
+
(validationTime ?? 0) +
|
|
777
|
+
perFunction.reduce((acc, { time }) => acc + time, 0)),
|
|
778
|
+
};
|
|
779
|
+
|
|
780
|
+
this.log.info(`Simulation completed for ${txHash.toString()} in ${totalTime}ms`, {
|
|
781
|
+
txHash,
|
|
782
|
+
...txInfo,
|
|
783
|
+
...(publicOutput
|
|
784
|
+
? {
|
|
785
|
+
gasUsed: publicOutput.gasUsed,
|
|
786
|
+
revertCode: publicOutput.txEffect.revertCode.getCode(),
|
|
787
|
+
revertReason: publicOutput.revertReason,
|
|
788
|
+
}
|
|
789
|
+
: {}),
|
|
790
|
+
});
|
|
791
|
+
|
|
792
|
+
return TxSimulationResult.fromPrivateSimulationResultAndPublicOutput(privateSimulationResult, publicOutput, {
|
|
793
|
+
timings,
|
|
794
|
+
nodeRPCCalls: recording.stats(),
|
|
795
|
+
});
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
/** Describes a simulation of `txRequest` for the errors it throws. */
|
|
799
|
+
#simulateTxErrorContext(txRequest: TxExecutionRequest, opts: SimulateTxOpts): string[] {
|
|
800
|
+
return [
|
|
801
|
+
inspect(txRequest),
|
|
802
|
+
`simulatePublic=${opts.simulatePublic}`,
|
|
803
|
+
`skipTxValidation=${opts.skipTxValidation ?? false}`,
|
|
804
|
+
`scopes=${opts.scopes.map(s => s.toString()).join(', ')}`,
|
|
805
|
+
];
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
/**
|
|
809
|
+
* Proves `privateExecutionResult`, the private execution of `txRequest`, within an already-open operation, and stages
|
|
810
|
+
* the sender tagging indices the tx uses.
|
|
811
|
+
*/
|
|
812
|
+
async #proveTx(
|
|
813
|
+
{ changeSetId, syncTime, anchorBlockHeader, recording, totalMs }: SyncedOperationContext,
|
|
814
|
+
txRequest: TxExecutionRequest,
|
|
815
|
+
privateExecutionResult: PrivateExecutionResult,
|
|
816
|
+
): Promise<TxProvingResult> {
|
|
817
|
+
const {
|
|
818
|
+
publicInputs,
|
|
819
|
+
chonkProof,
|
|
820
|
+
executionSteps,
|
|
821
|
+
timings: { proving } = {},
|
|
822
|
+
} = await this.#prove(txRequest, this.proofCreator, privateExecutionResult, anchorBlockHeader, {
|
|
823
|
+
simulate: false,
|
|
824
|
+
skipFeeEnforcement: false,
|
|
825
|
+
profileMode: 'none',
|
|
826
|
+
});
|
|
827
|
+
|
|
828
|
+
const totalTime = totalMs();
|
|
829
|
+
|
|
830
|
+
const perFunction = executionSteps.map(({ functionName, timings: { witgen, oracles } }) => ({
|
|
831
|
+
functionName,
|
|
832
|
+
time: witgen,
|
|
833
|
+
oracles,
|
|
834
|
+
}));
|
|
835
|
+
|
|
836
|
+
const timings: ProvingTimings = {
|
|
837
|
+
total: totalTime,
|
|
838
|
+
sync: syncTime,
|
|
839
|
+
proving,
|
|
840
|
+
perFunction,
|
|
841
|
+
unaccounted:
|
|
842
|
+
totalTime - ((syncTime ?? 0) + (proving ?? 0) + perFunction.reduce((acc, { time }) => acc + time, 0)),
|
|
843
|
+
};
|
|
844
|
+
|
|
845
|
+
this.log.debug(`Proving completed in ${totalTime}ms`, { timings });
|
|
846
|
+
|
|
847
|
+
const txProvingResult = new TxProvingResult(privateExecutionResult, publicInputs, chonkProof!, {
|
|
848
|
+
timings,
|
|
849
|
+
nodeRPCCalls: recording.stats(),
|
|
850
|
+
});
|
|
851
|
+
|
|
852
|
+
// We keep track of which tagging indices we've used in this tx so that we don't repeat them in future txs
|
|
853
|
+
// (which would link them) without having to rely on this tx being mined (and us seeing the indices being used
|
|
854
|
+
// onchain).
|
|
855
|
+
// Note that this must happen _after_ proving as it requires the proof's public inputs, from which the kernels
|
|
856
|
+
// may have removed some logs due to note-nullifier squashing - this may lead to range of tagging indices we've
|
|
857
|
+
// actually used to being reduced.
|
|
858
|
+
await persistSenderTaggingIndexRangesForTx(
|
|
859
|
+
this.senderTaggingStore,
|
|
860
|
+
privateExecutionResult.entrypoint.taggingIndexRanges,
|
|
861
|
+
publicInputs,
|
|
862
|
+
() => txProvingResult.getTxHash(),
|
|
863
|
+
changeSetId,
|
|
864
|
+
this.log,
|
|
865
|
+
);
|
|
866
|
+
|
|
867
|
+
return txProvingResult;
|
|
868
|
+
}
|
|
869
|
+
|
|
652
870
|
// Public API
|
|
653
871
|
|
|
654
872
|
/**
|
|
@@ -977,68 +1195,17 @@ export class PXE {
|
|
|
977
1195
|
// We disable proving concurrently mostly out of caution, since it accesses some of our stores. Proving is so
|
|
978
1196
|
// computationally demanding that it'd be rare for someone to try to do it concurrently regardless.
|
|
979
1197
|
return this.operationQueue.runSynced(
|
|
980
|
-
async
|
|
1198
|
+
async ctx => {
|
|
981
1199
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
982
1200
|
privateExecutionResult = await this.#executePrivate({
|
|
983
1201
|
contractFunctionSimulator,
|
|
984
1202
|
txRequest,
|
|
985
|
-
anchorBlockHeader,
|
|
1203
|
+
anchorBlockHeader: ctx.anchorBlockHeader,
|
|
986
1204
|
scopes,
|
|
987
|
-
changeSetId,
|
|
1205
|
+
changeSetId: ctx.changeSetId,
|
|
988
1206
|
senderForTags,
|
|
989
1207
|
});
|
|
990
|
-
|
|
991
|
-
const {
|
|
992
|
-
publicInputs,
|
|
993
|
-
chonkProof,
|
|
994
|
-
executionSteps,
|
|
995
|
-
timings: { proving } = {},
|
|
996
|
-
} = await this.#prove(txRequest, this.proofCreator, privateExecutionResult, anchorBlockHeader, {
|
|
997
|
-
simulate: false,
|
|
998
|
-
skipFeeEnforcement: false,
|
|
999
|
-
profileMode: 'none',
|
|
1000
|
-
});
|
|
1001
|
-
|
|
1002
|
-
const totalTime = totalMs();
|
|
1003
|
-
|
|
1004
|
-
const perFunction = executionSteps.map(({ functionName, timings: { witgen, oracles } }) => ({
|
|
1005
|
-
functionName,
|
|
1006
|
-
time: witgen,
|
|
1007
|
-
oracles,
|
|
1008
|
-
}));
|
|
1009
|
-
|
|
1010
|
-
const timings: ProvingTimings = {
|
|
1011
|
-
total: totalTime,
|
|
1012
|
-
sync: syncTime,
|
|
1013
|
-
proving,
|
|
1014
|
-
perFunction,
|
|
1015
|
-
unaccounted:
|
|
1016
|
-
totalTime - ((syncTime ?? 0) + (proving ?? 0) + perFunction.reduce((acc, { time }) => acc + time, 0)),
|
|
1017
|
-
};
|
|
1018
|
-
|
|
1019
|
-
this.log.debug(`Proving completed in ${totalTime}ms`, { timings });
|
|
1020
|
-
|
|
1021
|
-
const txProvingResult = new TxProvingResult(privateExecutionResult, publicInputs, chonkProof!, {
|
|
1022
|
-
timings,
|
|
1023
|
-
nodeRPCCalls: recording.stats(),
|
|
1024
|
-
});
|
|
1025
|
-
|
|
1026
|
-
// We keep track of which tagging indices we've used in this tx so that we don't repeat them in future txs
|
|
1027
|
-
// (which would link them) without having to rely on this tx being mined (and us seeing the indices being used
|
|
1028
|
-
// onchain).
|
|
1029
|
-
// Note that this must happen _after_ proving as it requires the proof's public inputs, from which the kernels
|
|
1030
|
-
// may have removed some logs due to note-nullifier squashing - this may lead to range of tagging indices we've
|
|
1031
|
-
// actually used to being reduced.
|
|
1032
|
-
await persistSenderTaggingIndexRangesForTx(
|
|
1033
|
-
this.senderTaggingStore,
|
|
1034
|
-
privateExecutionResult.entrypoint.taggingIndexRanges,
|
|
1035
|
-
publicInputs,
|
|
1036
|
-
() => txProvingResult.getTxHash(),
|
|
1037
|
-
changeSetId,
|
|
1038
|
-
this.log,
|
|
1039
|
-
);
|
|
1040
|
-
|
|
1041
|
-
return txProvingResult;
|
|
1208
|
+
return this.#proveTx(ctx, txRequest, privateExecutionResult);
|
|
1042
1209
|
},
|
|
1043
1210
|
{ errorContext: () => [inspect(txRequest), inspect(privateExecutionResult)] },
|
|
1044
1211
|
);
|
|
@@ -1141,148 +1308,83 @@ export class PXE {
|
|
|
1141
1308
|
*
|
|
1142
1309
|
* TODO(#7456) Prevent msgSender being defined here for the first call
|
|
1143
1310
|
*/
|
|
1144
|
-
public simulateTx(
|
|
1145
|
-
txRequest: TxExecutionRequest,
|
|
1146
|
-
{
|
|
1147
|
-
simulatePublic,
|
|
1148
|
-
skipTxValidation = false,
|
|
1149
|
-
skipFeeEnforcement = false,
|
|
1150
|
-
skipKernels = true,
|
|
1151
|
-
overrides,
|
|
1152
|
-
scopes,
|
|
1153
|
-
senderForTags,
|
|
1154
|
-
}: SimulateTxOpts,
|
|
1155
|
-
): Promise<TxSimulationResult> {
|
|
1311
|
+
public simulateTx(txRequest: TxExecutionRequest, opts: SimulateTxOpts): Promise<TxSimulationResult> {
|
|
1156
1312
|
// We disable concurrent simulations since those might execute oracles which read and write to the PXE stores (e.g.
|
|
1157
1313
|
// to the capsules), and we need to prevent concurrent runs from interfering with one another (e.g. attempting to
|
|
1158
1314
|
// delete the same read value, or reading values that another simulation is currently modifying).
|
|
1159
|
-
return this.operationQueue.runSynced(
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
functionSelector: txRequest.functionSelector,
|
|
1164
|
-
simulatePublic,
|
|
1165
|
-
chainId: txRequest.txContext.chainId,
|
|
1166
|
-
version: txRequest.txContext.version,
|
|
1167
|
-
authWitnesses: txRequest.authWitnesses.map(w => w.requestHash),
|
|
1168
|
-
};
|
|
1169
|
-
this.log.info(
|
|
1170
|
-
`Simulating transaction execution request to ${txRequest.functionSelector} at ${txRequest.origin}`,
|
|
1171
|
-
txInfo,
|
|
1172
|
-
);
|
|
1173
|
-
|
|
1174
|
-
if (overrides?.contracts && Object.keys(overrides.contracts).length > 0 && !skipKernels) {
|
|
1175
|
-
throw new Error(
|
|
1176
|
-
'Simulating with overridden contracts is not compatible with kernel execution. Please set skipKernels to true when simulating with overridden contracts.',
|
|
1177
|
-
);
|
|
1178
|
-
}
|
|
1179
|
-
const contractFunctionSimulator = this.#getSimulatorForTx(overrides);
|
|
1180
|
-
|
|
1181
|
-
// Execution of private functions only; no proving, and no kernel logic.
|
|
1182
|
-
const privateExecutionResult = await this.#executePrivate({
|
|
1183
|
-
contractFunctionSimulator,
|
|
1184
|
-
txRequest,
|
|
1185
|
-
anchorBlockHeader,
|
|
1186
|
-
scopes,
|
|
1187
|
-
changeSetId,
|
|
1188
|
-
senderForTags,
|
|
1189
|
-
});
|
|
1315
|
+
return this.operationQueue.runSynced(ctx => this.#simulateTx(ctx, txRequest, opts), {
|
|
1316
|
+
errorContext: () => this.#simulateTxErrorContext(txRequest, opts),
|
|
1317
|
+
});
|
|
1318
|
+
}
|
|
1190
1319
|
|
|
1191
|
-
|
|
1192
|
-
|
|
1320
|
+
/**
|
|
1321
|
+
* Combination of `simulateTx` and `proveTx`: a simulation is executed, its results inspected to produce a provable
|
|
1322
|
+
* transaction, followed by witness generation and proof.
|
|
1323
|
+
*
|
|
1324
|
+
* The entire sequence runs as a single atomic PXE operation, with no private state sync between simulation and
|
|
1325
|
+
* witness generation, resulting in them running over identical environments (e.g. the note store, tagging indices,
|
|
1326
|
+
* etc.).
|
|
1327
|
+
*
|
|
1328
|
+
* The simulation result is passed to a `prepareProve` callback, which then returns the input to the equivalent
|
|
1329
|
+
* `proveTx` call. Due to the atomic nature of this function, `prepareProve` must NOT call any PXE function, as that
|
|
1330
|
+
* would result in a deadlock.
|
|
1331
|
+
*/
|
|
1332
|
+
public simulateAndProveTx(
|
|
1333
|
+
simulationTxRequest: TxExecutionRequest,
|
|
1334
|
+
{ prepareProve, ...simulateOpts }: SimulateAndProveTxOpts,
|
|
1335
|
+
): Promise<TxProvingResult> {
|
|
1336
|
+
let proveTxRequest: TxExecutionRequest | undefined;
|
|
1337
|
+
let privateExecutionResult: PrivateExecutionResult | undefined;
|
|
1338
|
+
|
|
1339
|
+
// We run the entire thing as a single operation, which blocks the queue. There are two other possible paths we
|
|
1340
|
+
// could take here:
|
|
1341
|
+
// a) decouple the queue from a changeset to commit. This would let us hold the queue and have two changesets, one
|
|
1342
|
+
// for the simulation and its corresponding sync, and one for the prove. In case of failure of either the
|
|
1343
|
+
// `prepareProve` callback (e.g. user rejection) or the proof itself, we'd still have committed the simulation
|
|
1344
|
+
// work, including the private state sync, which could save time in future runs.
|
|
1345
|
+
// b) make this be two separate jobs, releasing the queue in between, but holding a second lock which would prevent
|
|
1346
|
+
// PXE from updating its anchor block and therefore re-syncing contracts. In the case of a long-running
|
|
1347
|
+
// callback, other unrelated operations (e.g. utility call invocations) would still be able to go through.
|
|
1348
|
+
//
|
|
1349
|
+
// We're not currently taking either of these paths due to uncertainty on this even being a good primitive for PXE
|
|
1350
|
+
// to expose to wallets, and to not invest too heavily in this direction (as both approaches would require
|
|
1351
|
+
// refactoring). Additionally, the gains those approaches provide are currently not valuable: for a) we expect it to
|
|
1352
|
+
// be unlikely for a follow-up simulation to be executed on the same anchor block as the first one, so committing
|
|
1353
|
+
// the sync achieves little if anything, and for b) the callback is expected to be fairly quick, and for there to be
|
|
1354
|
+
// no need to execute any other PXE calls while it runs.
|
|
1193
1355
|
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1356
|
+
return this.operationQueue.runSynced(
|
|
1357
|
+
async ctx => {
|
|
1358
|
+
const simulationResult = await this.#simulateTx(ctx, simulationTxRequest, simulateOpts);
|
|
1359
|
+
let proveOpts: ProveTxOpts;
|
|
1360
|
+
({ proveTxRequest, proveOpts } = await prepareProve(simulationResult));
|
|
1361
|
+
|
|
1362
|
+
// The proving result's timings and node stats must cover proving alone, not the simulation before it.
|
|
1363
|
+
const provingTimer = new Timer();
|
|
1364
|
+
const recording = this.node.startRecording();
|
|
1365
|
+
try {
|
|
1366
|
+
privateExecutionResult = await this.#executePrivate({
|
|
1367
|
+
contractFunctionSimulator: this.#getSimulatorForTx(),
|
|
1368
|
+
txRequest: proveTxRequest,
|
|
1369
|
+
anchorBlockHeader: ctx.anchorBlockHeader,
|
|
1370
|
+
scopes: proveOpts.scopes,
|
|
1371
|
+
changeSetId: ctx.changeSetId,
|
|
1372
|
+
senderForTags: proveOpts.senderForTags,
|
|
1373
|
+
});
|
|
1374
|
+
return await this.#proveTx(
|
|
1375
|
+
{ ...ctx, syncTime: 0, recording, totalMs: () => provingTimer.ms() },
|
|
1376
|
+
proveTxRequest,
|
|
1205
1377
|
privateExecutionResult,
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
skipFeeEnforcement,
|
|
1210
|
-
profileMode: 'none',
|
|
1211
|
-
},
|
|
1212
|
-
));
|
|
1213
|
-
}
|
|
1214
|
-
|
|
1215
|
-
const privateSimulationResult = new PrivateSimulationResult(privateExecutionResult, publicInputs);
|
|
1216
|
-
const simulatedTx = await privateSimulationResult.toSimulatedTx();
|
|
1217
|
-
let publicSimulationTime: number | undefined;
|
|
1218
|
-
let publicOutput: PublicSimulationOutput | undefined;
|
|
1219
|
-
if (simulatePublic && publicInputs.forPublic) {
|
|
1220
|
-
const publicSimulationTimer = new Timer();
|
|
1221
|
-
publicOutput = await this.#simulatePublicCalls(simulatedTx, skipFeeEnforcement, overrides);
|
|
1222
|
-
publicSimulationTime = publicSimulationTimer.ms();
|
|
1223
|
-
if (publicOutput?.debugLogs?.length) {
|
|
1224
|
-
await displayDebugLogs(publicOutput.debugLogs, addr => this.#getDebugContractName(addr, anchorBlockHeader));
|
|
1225
|
-
}
|
|
1226
|
-
}
|
|
1227
|
-
|
|
1228
|
-
let validationTime: number | undefined;
|
|
1229
|
-
if (!skipTxValidation) {
|
|
1230
|
-
const validationTimer = new Timer();
|
|
1231
|
-
const validationResult = await this.node.isValidTx(simulatedTx, { isSimulation: true, skipFeeEnforcement });
|
|
1232
|
-
validationTime = validationTimer.ms();
|
|
1233
|
-
if (validationResult.result === 'invalid') {
|
|
1234
|
-
const reason = validationResult.reason.length > 0 ? ` Reason: ${validationResult.reason.join(', ')}` : '';
|
|
1235
|
-
throw new Error(`The simulated transaction is unable to be added to state and is invalid.${reason}`);
|
|
1236
|
-
}
|
|
1378
|
+
);
|
|
1379
|
+
} finally {
|
|
1380
|
+
recording.stop();
|
|
1237
1381
|
}
|
|
1238
|
-
|
|
1239
|
-
const txHash = simulatedTx.getTxHash();
|
|
1240
|
-
|
|
1241
|
-
const totalTime = totalMs();
|
|
1242
|
-
|
|
1243
|
-
const perFunction = executionSteps.map(({ functionName, timings: { witgen, oracles } }) => ({
|
|
1244
|
-
functionName,
|
|
1245
|
-
time: witgen,
|
|
1246
|
-
oracles,
|
|
1247
|
-
}));
|
|
1248
|
-
|
|
1249
|
-
const timings: SimulationTimings = {
|
|
1250
|
-
total: totalTime,
|
|
1251
|
-
sync: syncTime,
|
|
1252
|
-
publicSimulation: publicSimulationTime,
|
|
1253
|
-
validation: validationTime,
|
|
1254
|
-
perFunction,
|
|
1255
|
-
unaccounted:
|
|
1256
|
-
totalTime -
|
|
1257
|
-
(syncTime +
|
|
1258
|
-
(publicSimulationTime ?? 0) +
|
|
1259
|
-
(validationTime ?? 0) +
|
|
1260
|
-
perFunction.reduce((acc, { time }) => acc + time, 0)),
|
|
1261
|
-
};
|
|
1262
|
-
|
|
1263
|
-
this.log.info(`Simulation completed for ${txHash.toString()} in ${totalTime}ms`, {
|
|
1264
|
-
txHash,
|
|
1265
|
-
...txInfo,
|
|
1266
|
-
...(publicOutput
|
|
1267
|
-
? {
|
|
1268
|
-
gasUsed: publicOutput.gasUsed,
|
|
1269
|
-
revertCode: publicOutput.txEffect.revertCode.getCode(),
|
|
1270
|
-
revertReason: publicOutput.revertReason,
|
|
1271
|
-
}
|
|
1272
|
-
: {}),
|
|
1273
|
-
});
|
|
1274
|
-
|
|
1275
|
-
return TxSimulationResult.fromPrivateSimulationResultAndPublicOutput(privateSimulationResult, publicOutput, {
|
|
1276
|
-
timings,
|
|
1277
|
-
nodeRPCCalls: recording.stats(),
|
|
1278
|
-
});
|
|
1279
1382
|
},
|
|
1280
1383
|
{
|
|
1281
1384
|
errorContext: () => [
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
`scopes=${scopes.map(s => s.toString()).join(', ')}`,
|
|
1385
|
+
...this.#simulateTxErrorContext(simulationTxRequest, simulateOpts),
|
|
1386
|
+
inspect(proveTxRequest),
|
|
1387
|
+
inspect(privateExecutionResult),
|
|
1286
1388
|
],
|
|
1287
1389
|
},
|
|
1288
1390
|
);
|