@aztec/simulator 5.0.0-nightly.20260524 → 5.0.0-nightly.20260526
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/public/fixtures/bulk_test.d.ts +1 -1
- package/dest/public/fixtures/bulk_test.d.ts.map +1 -1
- package/dest/public/fixtures/bulk_test.js +24 -0
- package/dest/public/public_processor/public_processor.d.ts +2 -1
- package/dest/public/public_processor/public_processor.d.ts.map +1 -1
- package/dest/public/public_processor/public_processor.js +39 -19
- package/package.json +15 -15
- package/src/public/fixtures/bulk_test.ts +24 -0
- package/src/public/public_processor/public_processor.ts +46 -22
|
@@ -3,4 +3,4 @@ import type { ContractArtifact } from '@aztec/stdlib/abi';
|
|
|
3
3
|
import { PublicTxSimulationTester } from './public_tx_simulation_tester.js';
|
|
4
4
|
export declare function bulkTest(tester: PublicTxSimulationTester, logger: Logger, avmTestContractArtifact: ContractArtifact): Promise<import("@aztec/stdlib/avm").PublicTxResult>;
|
|
5
5
|
export declare function megaBulkTest(tester: PublicTxSimulationTester, logger: Logger, avmTestContractArtifact: ContractArtifact): Promise<import("@aztec/stdlib/avm").PublicTxResult>;
|
|
6
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
6
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYnVsa190ZXN0LmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvcHVibGljL2ZpeHR1cmVzL2J1bGtfdGVzdC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFDQSxPQUFPLEtBQUssRUFBRSxNQUFNLEVBQUUsTUFBTSx1QkFBdUIsQ0FBQztBQUVwRCxPQUFPLEtBQUssRUFBRSxnQkFBZ0IsRUFBRSxNQUFNLG1CQUFtQixDQUFDO0FBRzFELE9BQU8sRUFBRSx3QkFBd0IsRUFBRSxNQUFNLGtDQUFrQyxDQUFDO0FBRTVFLHdCQUFzQixRQUFRLENBQzVCLE1BQU0sRUFBRSx3QkFBd0IsRUFDaEMsTUFBTSxFQUFFLE1BQU0sRUFDZCx1QkFBdUIsRUFBRSxnQkFBZ0IsdURBK0YxQztBQUVELHdCQUFzQixZQUFZLENBQ2hDLE1BQU0sRUFBRSx3QkFBd0IsRUFDaEMsTUFBTSxFQUFFLE1BQU0sRUFDZCx1QkFBdUIsRUFBRSxnQkFBZ0IsdURBaUYxQyJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bulk_test.d.ts","sourceRoot":"","sources":["../../../src/public/fixtures/bulk_test.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAEpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAG1D,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAE5E,wBAAsB,QAAQ,CAC5B,MAAM,EAAE,wBAAwB,EAChC,MAAM,EAAE,MAAM,EACd,uBAAuB,EAAE,gBAAgB,
|
|
1
|
+
{"version":3,"file":"bulk_test.d.ts","sourceRoot":"","sources":["../../../src/public/fixtures/bulk_test.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAEpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAG1D,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAE5E,wBAAsB,QAAQ,CAC5B,MAAM,EAAE,wBAAwB,EAChC,MAAM,EAAE,MAAM,EACd,uBAAuB,EAAE,gBAAgB,uDA+F1C;AAED,wBAAsB,YAAY,CAChC,MAAM,EAAE,wBAAwB,EAChC,MAAM,EAAE,MAAM,EACd,uBAAuB,EAAE,gBAAgB,uDAiF1C"}
|
|
@@ -37,6 +37,19 @@ export async function bulkTest(tester, logger, avmTestContractArtifact) {
|
|
|
37
37
|
9,
|
|
38
38
|
10
|
|
39
39
|
].map((x)=>new Fr(x));
|
|
40
|
+
// Pinned grumpkin-Poseidon2 Schnorr signature (mirrors the C++ `pinned_test_vector_large`
|
|
41
|
+
// and noir-lang/schnorr v0.4.0's `pinned_vector_large`). Passing these in as calldata
|
|
42
|
+
// (rather than baking them into Noir as constants) keeps MSM + Poseidon2 from being folded
|
|
43
|
+
// by the Noir compiler.
|
|
44
|
+
const schnorrInputs = [
|
|
45
|
+
Fr.fromHexString('0x065812e335a97c2108ea8cf4ccfe2f9dd6b117a0714f5e18461575be93f61da6'),
|
|
46
|
+
Fr.fromHexString('0x1a915003e8ec534f9a15d926a7ded478e178468ccc4f28e236e67450a55ac622'),
|
|
47
|
+
Fr.fromHexString('0xf3bc3b7147acb9c621fd9f72dbf15ffa'),
|
|
48
|
+
Fr.fromHexString('0x08599f379f0301dfefdbd0272554454d'),
|
|
49
|
+
Fr.fromHexString('0x97065383ebbbd76620398792bd259bc2'),
|
|
50
|
+
Fr.fromHexString('0x2ceaee87f45b7a417f0ffb05451a8c92'),
|
|
51
|
+
Fr.fromHexString('0x0123456789abcdef0fedcba9876543210123456789abcdef0fedcba987654321')
|
|
52
|
+
];
|
|
40
53
|
const args = [
|
|
41
54
|
argsField,
|
|
42
55
|
argsU8,
|
|
@@ -45,6 +58,7 @@ export async function bulkTest(tester, logger, avmTestContractArtifact) {
|
|
|
45
58
|
/*expectedClassId=*/ expectContractInstance.currentContractClassId,
|
|
46
59
|
/*expectedInitializationHash=*/ expectContractInstance.initializationHash,
|
|
47
60
|
/*expectedImmutablesHash=*/ expectContractInstance.immutablesHash,
|
|
61
|
+
/*schnorrInputs=*/ schnorrInputs,
|
|
48
62
|
/*skip_strictly_limited_side_effects=*/ false
|
|
49
63
|
];
|
|
50
64
|
const bulkResult = await tester.executeTxWithLabel(/*txLabel=*/ 'AvmTest/bulk_testing', /*sender=*/ deployer, /*setupCalls=*/ [], /*appCalls=*/ [
|
|
@@ -204,6 +218,15 @@ export async function megaBulkTest(tester, logger, avmTestContractArtifact) {
|
|
|
204
218
|
9,
|
|
205
219
|
10
|
|
206
220
|
].map((x)=>new Fr(x));
|
|
221
|
+
const schnorrInputs = [
|
|
222
|
+
Fr.fromHexString('0x065812e335a97c2108ea8cf4ccfe2f9dd6b117a0714f5e18461575be93f61da6'),
|
|
223
|
+
Fr.fromHexString('0x1a915003e8ec534f9a15d926a7ded478e178468ccc4f28e236e67450a55ac622'),
|
|
224
|
+
Fr.fromHexString('0xf3bc3b7147acb9c621fd9f72dbf15ffa'),
|
|
225
|
+
Fr.fromHexString('0x08599f379f0301dfefdbd0272554454d'),
|
|
226
|
+
Fr.fromHexString('0x97065383ebbbd76620398792bd259bc2'),
|
|
227
|
+
Fr.fromHexString('0x2ceaee87f45b7a417f0ffb05451a8c92'),
|
|
228
|
+
Fr.fromHexString('0x0123456789abcdef0fedcba9876543210123456789abcdef0fedcba987654321')
|
|
229
|
+
];
|
|
207
230
|
const genArgs = (argsField)=>[
|
|
208
231
|
argsField,
|
|
209
232
|
argsU8,
|
|
@@ -212,6 +235,7 @@ export async function megaBulkTest(tester, logger, avmTestContractArtifact) {
|
|
|
212
235
|
/*expectedClassId=*/ expectContractInstance.currentContractClassId.toField(),
|
|
213
236
|
/*expectedInitializationHash=*/ expectContractInstance.initializationHash.toField(),
|
|
214
237
|
/*expectedImmutablesHash=*/ expectContractInstance.immutablesHash.toField(),
|
|
238
|
+
/*schnorrInputs=*/ schnorrInputs,
|
|
215
239
|
// Must skip strictly limited side effects (logs, messages) so we can spam the bulk test several times.
|
|
216
240
|
/*skip_strictly_limited_side_effects=*/ true
|
|
217
241
|
];
|
|
@@ -55,6 +55,7 @@ export declare class PublicProcessor implements Traceable {
|
|
|
55
55
|
private processTx;
|
|
56
56
|
private doTreeInsertionsForPrivateOnlyTx;
|
|
57
57
|
private processTxWithinDeadline;
|
|
58
|
+
private getProcessingSignal;
|
|
58
59
|
private performFeePaymentPublicDataWrite;
|
|
59
60
|
private processPrivateOnlyTx;
|
|
60
61
|
private processTxWithPublicCalls;
|
|
@@ -63,4 +64,4 @@ export declare class PublicProcessor implements Traceable {
|
|
|
63
64
|
*/
|
|
64
65
|
private static generateProvingRequest;
|
|
65
66
|
}
|
|
66
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
67
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGljX3Byb2Nlc3Nvci5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL3B1YmxpYy9wdWJsaWNfcHJvY2Vzc29yL3B1YmxpY19wcm9jZXNzb3IudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBR0EsT0FBTyxFQUFFLEtBQUssTUFBTSxFQUFFLEtBQUssY0FBYyxFQUFnQixNQUFNLHVCQUF1QixDQUFDO0FBRXZGLE9BQU8sRUFBRSxZQUFZLEVBQWtDLE1BQU0seUJBQXlCLENBQUM7QUFJdkYsT0FBTyxFQU1MLHFCQUFxQixFQUN0QixNQUFNLG1CQUFtQixDQUFDO0FBRTNCLE9BQU8sS0FBSyxFQUFFLGtCQUFrQixFQUFFLE1BQU0sd0JBQXdCLENBQUM7QUFHakUsT0FBTyxLQUFLLEVBQ1YseUJBQXlCLEVBQ3pCLHFCQUFxQixFQUNyQix3QkFBd0IsRUFDeEIsZUFBZSxFQUNoQixNQUFNLGlDQUFpQyxDQUFDO0FBQ3pDLE9BQU8sRUFBRSxLQUFLLFFBQVEsRUFBRSxLQUFLLGFBQWEsRUFBcUIsTUFBTSxvQkFBb0IsQ0FBQztBQUcxRixPQUFPLEVBQ0wsS0FBSyxRQUFRLEVBQ2IsZUFBZSxFQUNmLHlCQUF5QixFQUN6QixLQUFLLFdBQVcsRUFFaEIsRUFBRSxFQUdILE1BQU0sa0JBQWtCLENBQUM7QUFDMUIsT0FBTyxFQUVMLEtBQUssZUFBZSxFQUNwQixLQUFLLFNBQV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dDQUFnQztZQTRCaEMsdUJBQXVCO0lBaUNyQyxPQUFPLENBQUMsbUJBQW1CO1lBMEJiLGdDQUFnQztZQTBCaEMsb0JBQW9CO1lBK0JwQix3QkFBd0I7SUF5Q3RDOztPQUVHO0lBQ0gsT0FBTyxDQUFDLE1BQU0sQ0FBQyxzQkFBc0I7Q0FTdEMifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public_processor.d.ts","sourceRoot":"","sources":["../../../src/public/public_processor/public_processor.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,cAAc,EAAgB,MAAM,uBAAuB,CAAC;AAEvF,OAAO,EAAE,YAAY,EAAkC,MAAM,yBAAyB,CAAC;AAIvF,OAAO,EAML,qBAAqB,EACtB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAGjE,OAAO,KAAK,EACV,yBAAyB,EACzB,qBAAqB,EACrB,wBAAwB,EACxB,eAAe,EAChB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,aAAa,EAAqB,MAAM,oBAAoB,CAAC;AAG1F,OAAO,EACL,KAAK,QAAQ,EACb,eAAe,EACf,yBAAyB,EACzB,KAAK,WAAW,EAEhB,EAAE,EAGH,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,SAAS,EACd,KAAK,MAAM,EAGZ,MAAM,yBAAyB,CAAC;AAKjC,OAAO,EAAE,iBAAiB,EAAiB,MAAM,yBAAyB,CAAC;AAC3E,OAAO,EACL,KAAK,uBAAuB,EAC5B,KAAK,0BAA0B,EAEhC,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AAGvE;;GAEG;AACH,qBAAa,sBAAsB;IAG/B,OAAO,CAAC,kBAAkB;IAC1B,OAAO,CAAC,YAAY;IACpB,SAAS,CAAC,eAAe,EAAE,eAAe;IAJ5C,OAAO,CAAC,GAAG,CAAS;IACpB,YACU,kBAAkB,EAAE,kBAAkB,EACtC,YAAY,GAAE,YAAiC,EAC7C,eAAe,GAAE,eAAsC,EACjE,QAAQ,CAAC,EAAE,cAAc,EAG1B;IAED;;;;;OAKG;IACI,MAAM,CACX,UAAU,EAAE,yBAAyB,EACrC,eAAe,EAAE,eAAe,EAChC,MAAM,EAAE,qBAAqB,EAC7B,WAAW,GAAE,iBAA0F,GACtG,eAAe,CAajB;IAED,SAAS,CAAC,uBAAuB,CAC/B,UAAU,EAAE,yBAAyB,EACrC,WAAW,EAAE,iBAAiB,EAC9B,eAAe,EAAE,eAAe,EAChC,MAAM,CAAC,EAAE,OAAO,CAAC,uBAAuB,CAAC,GACxC,0BAA0B,CAS5B;CACF;
|
|
1
|
+
{"version":3,"file":"public_processor.d.ts","sourceRoot":"","sources":["../../../src/public/public_processor/public_processor.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,cAAc,EAAgB,MAAM,uBAAuB,CAAC;AAEvF,OAAO,EAAE,YAAY,EAAkC,MAAM,yBAAyB,CAAC;AAIvF,OAAO,EAML,qBAAqB,EACtB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAGjE,OAAO,KAAK,EACV,yBAAyB,EACzB,qBAAqB,EACrB,wBAAwB,EACxB,eAAe,EAChB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,aAAa,EAAqB,MAAM,oBAAoB,CAAC;AAG1F,OAAO,EACL,KAAK,QAAQ,EACb,eAAe,EACf,yBAAyB,EACzB,KAAK,WAAW,EAEhB,EAAE,EAGH,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,SAAS,EACd,KAAK,MAAM,EAGZ,MAAM,y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B,EAAE,0BAA0B,EAC/C,YAAY,EAAE,YAAY,EAClC,eAAe,6BAAwC,EAC/C,GAAG,EAAE,MAAM,EACX,IAAI,GAAE,IAAI,CAAC,eAAe,EAAE,4BAA4B,GAAG,iCAAiC,CAAM,EAClG,aAAa,GAAE,aAAuC,EAG/D;IAED,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED;;;;;;OAMG;IACU,OAAO,CAClB,GAAG,EAAE,QAAQ,CAAC,EAAE,CAAC,GAAG,aAAa,CAAC,EAAE,CAAC,EACrC,MAAM,GAAE,qBAA0B,EAClC,SAAS,GAAE,wBAA6B,GACvC,OAAO,CAAC,CAAC,WAAW,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,EAAE,EAAE,yBAAyB,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC,CAmOrF;YAEa,wBAAwB;YAiBxB,SAAS;YAiCT,gCAAgC;YA4BhC,uBAAuB;IAiCrC,OAAO,CAAC,mBAAmB;YA0Bb,gCAAgC;YA0BhC,oBAAoB;YA+BpB,wBAAwB;IAyCtC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,sBAAsB;CAStC"}
|
|
@@ -376,7 +376,7 @@ import { padArrayEnd } from '@aztec/foundation/collection';
|
|
|
376
376
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
377
377
|
import { createLogger } from '@aztec/foundation/log';
|
|
378
378
|
import { sleep } from '@aztec/foundation/sleep';
|
|
379
|
-
import { DateProvider, Timer, elapsed,
|
|
379
|
+
import { DateProvider, Timer, elapsed, execWithSignal } from '@aztec/foundation/timer';
|
|
380
380
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
381
381
|
import { ContractClassPublishedEvent } from '@aztec/protocol-contracts/class-registry';
|
|
382
382
|
import { computeFeePayerBalanceLeafSlot, computeFeePayerBalanceStorageSlot } from '@aztec/protocol-contracts/fee-juice';
|
|
@@ -427,6 +427,15 @@ class PublicProcessorTimeoutError extends Error {
|
|
|
427
427
|
this.name = 'PublicProcessorTimeoutError';
|
|
428
428
|
}
|
|
429
429
|
}
|
|
430
|
+
class PublicProcessorAbortError extends Error {
|
|
431
|
+
constructor(message = 'Aborted while processing tx'){
|
|
432
|
+
super(message);
|
|
433
|
+
this.name = 'PublicProcessorAbortError';
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
function isPublicProcessorInterruptError(err) {
|
|
437
|
+
return err?.name === 'PublicProcessorTimeoutError' || err?.name === 'PublicProcessorAbortError';
|
|
438
|
+
}
|
|
430
439
|
_dec = trackSpan('PublicProcessor.processTx', (tx)=>({
|
|
431
440
|
[Attributes.TX_HASH]: tx.getTxHash().toString()
|
|
432
441
|
})), _dec1 = trackSpan('PublicProcessor.processPrivateOnlyTx', (tx)=>({
|
|
@@ -488,7 +497,7 @@ _dec = trackSpan('PublicProcessor.processTx', (tx)=>({
|
|
|
488
497
|
* @param validator - Pre-process validator and nullifier cache to use for processing the txs.
|
|
489
498
|
* @returns The list of processed txs with their circuit simulation outputs.
|
|
490
499
|
*/ async process(txs, limits = {}, validator = {}) {
|
|
491
|
-
const { maxTransactions, deadline, maxBlockGas, maxBlobFields, isBuildingProposal } = limits;
|
|
500
|
+
const { maxTransactions, deadline, maxBlockGas, maxBlobFields, isBuildingProposal, signal } = limits;
|
|
492
501
|
const { preprocessValidator, nullifierCache } = validator;
|
|
493
502
|
const result = [];
|
|
494
503
|
const usedTxs = [];
|
|
@@ -508,11 +517,15 @@ _dec = trackSpan('PublicProcessor.processTx', (tx)=>({
|
|
|
508
517
|
this.log.debug(`Stopping tx processing due to reaching the max tx limit.`);
|
|
509
518
|
break;
|
|
510
519
|
}
|
|
511
|
-
// Bail if we've hit the deadline
|
|
520
|
+
// Bail if we've hit the deadline or have been interrupted.
|
|
512
521
|
if (deadline && this.dateProvider.now() > +deadline) {
|
|
513
522
|
this.log.warn(`Stopping tx processing due to timeout.`);
|
|
514
523
|
break;
|
|
515
524
|
}
|
|
525
|
+
if (signal?.aborted) {
|
|
526
|
+
this.log.warn(`Stopping tx processing due to abort signal.`);
|
|
527
|
+
break;
|
|
528
|
+
}
|
|
516
529
|
const txHash = tx.getTxHash().toString();
|
|
517
530
|
// Skip this tx if its estimated blob fields would exceed the limit.
|
|
518
531
|
// Only done during proposal building: during re-execution we must process the exact txs from the proposal.
|
|
@@ -564,7 +577,7 @@ _dec = trackSpan('PublicProcessor.processTx', (tx)=>({
|
|
|
564
577
|
const startStateReference = await this.guardedMerkleTree.getUnderlyingFork().getStateReference();
|
|
565
578
|
this.contractsDB.createCheckpoint();
|
|
566
579
|
try {
|
|
567
|
-
const [txProcessingTimeMs, [processedTx, returnValues, txDebugLogs]] = await elapsed(()=>this.processTx(tx, deadline));
|
|
580
|
+
const [txProcessingTimeMs, [processedTx, returnValues, txDebugLogs]] = await elapsed(()=>this.processTx(tx, deadline, signal));
|
|
568
581
|
// Inject a fake processing failure after N txs if requested
|
|
569
582
|
const fakeThrowAfter = this.opts.fakeThrowAfterProcessingTxCount;
|
|
570
583
|
if (fakeThrowAfter !== undefined && result.length + failed.length + 1 >= fakeThrowAfter) {
|
|
@@ -619,15 +632,11 @@ _dec = trackSpan('PublicProcessor.processTx', (tx)=>({
|
|
|
619
632
|
// Commit the tx-level contracts checkpoint on success
|
|
620
633
|
this.contractsDB.commitCheckpoint();
|
|
621
634
|
} catch (err) {
|
|
622
|
-
if (err
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
//
|
|
626
|
-
// Signal cancellation AND WAIT for the simulation to actually stop.
|
|
627
|
-
// This is critical because C++ might be in the middle of a slow operation (e.g., pad_trees)
|
|
628
|
-
// and won't check the cancellation flag until that operation completes.
|
|
629
|
-
// Without waiting, we'd proceed to revert checkpoints while C++ is still writing to state.
|
|
630
|
-
// Wait for C++ to stop gracefully.
|
|
635
|
+
if (isPublicProcessorInterruptError(err)) {
|
|
636
|
+
const interruptReason = err.name === 'PublicProcessorTimeoutError' ? 'timeout' : 'abort signal';
|
|
637
|
+
this.log.warn(`Stopping tx processing due to ${interruptReason}.`);
|
|
638
|
+
// The tx may still be executing on a worker thread (C++ via NAPI).
|
|
639
|
+
// Signal cancellation AND WAIT for the simulation to actually stop before touching fork checkpoints.
|
|
631
640
|
await this.publicTxSimulator.cancel?.();
|
|
632
641
|
// Now stop the guarded fork to prevent any further TS-side access to the world state.
|
|
633
642
|
await this.guardedMerkleTree.stop();
|
|
@@ -699,8 +708,8 @@ _dec = trackSpan('PublicProcessor.processTx', (tx)=>({
|
|
|
699
708
|
});
|
|
700
709
|
}
|
|
701
710
|
}
|
|
702
|
-
async processTx(tx, deadline) {
|
|
703
|
-
const [time, [processedTx, returnValues, debugLogs]] = await elapsed(()=>this.processTxWithinDeadline(tx, deadline));
|
|
711
|
+
async processTx(tx, deadline, signal) {
|
|
712
|
+
const [time, [processedTx, returnValues, debugLogs]] = await elapsed(()=>this.processTxWithinDeadline(tx, deadline, signal));
|
|
704
713
|
this.log.verbose(!tx.hasPublicCalls() ? `Processed tx ${processedTx.hash} with no public calls in ${time}ms` : `Processed tx ${processedTx.hash} with ${tx.numberOfPublicCalls()} public calls in ${time}ms`, {
|
|
705
714
|
txHash: processedTx.hash,
|
|
706
715
|
txFee: processedTx.txEffect.transactionFee.toBigInt(),
|
|
@@ -741,7 +750,7 @@ _dec = trackSpan('PublicProcessor.processTx', (tx)=>({
|
|
|
741
750
|
const treeInsertionEnd = process.hrtime.bigint();
|
|
742
751
|
this.metrics.recordTreeInsertions(Number(treeInsertionEnd - treeInsertionStart) / 1_000);
|
|
743
752
|
}
|
|
744
|
-
/** Processes the given tx within deadline
|
|
753
|
+
/** Processes the given tx within deadline or until the signal is aborted. */ async processTxWithinDeadline(tx, deadline, signal) {
|
|
745
754
|
const innerProcessFn = tx.hasPublicCalls() ? ()=>this.processTxWithPublicCalls(tx) : ()=>this.processPrivateOnlyTx(tx);
|
|
746
755
|
// Fake a delay per tx if instructed (used for tests)
|
|
747
756
|
const fakeDelayPerTxMs = this.opts.fakeProcessingDelayPerTxMs;
|
|
@@ -751,20 +760,31 @@ _dec = trackSpan('PublicProcessor.processTx', (tx)=>({
|
|
|
751
760
|
await sleep(fakeDelayPerTxMs);
|
|
752
761
|
return result;
|
|
753
762
|
} : innerProcessFn;
|
|
754
|
-
|
|
763
|
+
const processingSignal = this.getProcessingSignal(tx, deadline, signal);
|
|
764
|
+
if (!processingSignal) {
|
|
755
765
|
return await processFn();
|
|
756
766
|
}
|
|
757
|
-
|
|
767
|
+
return await execWithSignal(()=>processFn(), processingSignal, (signal)=>signal.reason?.name === 'TimeoutError' ? new PublicProcessorTimeoutError() : new PublicProcessorAbortError());
|
|
768
|
+
}
|
|
769
|
+
getProcessingSignal(tx, deadline, signal) {
|
|
770
|
+
if (!deadline) {
|
|
771
|
+
return signal;
|
|
772
|
+
}
|
|
758
773
|
const timeout = +deadline - this.dateProvider.now();
|
|
759
774
|
if (timeout <= 0) {
|
|
760
775
|
throw new PublicProcessorTimeoutError();
|
|
761
776
|
}
|
|
777
|
+
const txHash = tx.getTxHash();
|
|
762
778
|
this.log.debug(`Processing tx ${txHash.toString()} within ${timeout}ms`, {
|
|
763
779
|
deadline: deadline.toISOString(),
|
|
764
780
|
now: new Date(this.dateProvider.now()).toISOString(),
|
|
765
781
|
txHash
|
|
766
782
|
});
|
|
767
|
-
|
|
783
|
+
const timeoutSignal = AbortSignal.timeout(timeout);
|
|
784
|
+
return signal ? AbortSignal.any([
|
|
785
|
+
signal,
|
|
786
|
+
timeoutSignal
|
|
787
|
+
]) : timeoutSignal;
|
|
768
788
|
}
|
|
769
789
|
/**
|
|
770
790
|
* Creates the public data write for paying the tx fee.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/simulator",
|
|
3
|
-
"version": "5.0.0-nightly.
|
|
3
|
+
"version": "5.0.0-nightly.20260526",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./server": "./dest/server.js",
|
|
@@ -64,25 +64,25 @@
|
|
|
64
64
|
]
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"@aztec/constants": "5.0.0-nightly.
|
|
68
|
-
"@aztec/foundation": "5.0.0-nightly.
|
|
69
|
-
"@aztec/native": "5.0.0-nightly.
|
|
70
|
-
"@aztec/noir-acvm_js": "5.0.0-nightly.
|
|
71
|
-
"@aztec/noir-noirc_abi": "5.0.0-nightly.
|
|
72
|
-
"@aztec/noir-protocol-circuits-types": "5.0.0-nightly.
|
|
73
|
-
"@aztec/noir-types": "5.0.0-nightly.
|
|
74
|
-
"@aztec/protocol-contracts": "5.0.0-nightly.
|
|
75
|
-
"@aztec/stdlib": "5.0.0-nightly.
|
|
76
|
-
"@aztec/telemetry-client": "5.0.0-nightly.
|
|
77
|
-
"@aztec/world-state": "5.0.0-nightly.
|
|
67
|
+
"@aztec/constants": "5.0.0-nightly.20260526",
|
|
68
|
+
"@aztec/foundation": "5.0.0-nightly.20260526",
|
|
69
|
+
"@aztec/native": "5.0.0-nightly.20260526",
|
|
70
|
+
"@aztec/noir-acvm_js": "5.0.0-nightly.20260526",
|
|
71
|
+
"@aztec/noir-noirc_abi": "5.0.0-nightly.20260526",
|
|
72
|
+
"@aztec/noir-protocol-circuits-types": "5.0.0-nightly.20260526",
|
|
73
|
+
"@aztec/noir-types": "5.0.0-nightly.20260526",
|
|
74
|
+
"@aztec/protocol-contracts": "5.0.0-nightly.20260526",
|
|
75
|
+
"@aztec/stdlib": "5.0.0-nightly.20260526",
|
|
76
|
+
"@aztec/telemetry-client": "5.0.0-nightly.20260526",
|
|
77
|
+
"@aztec/world-state": "5.0.0-nightly.20260526",
|
|
78
78
|
"lodash.clonedeep": "^4.5.0",
|
|
79
79
|
"lodash.merge": "^4.6.2",
|
|
80
80
|
"tslib": "^2.4.0"
|
|
81
81
|
},
|
|
82
82
|
"devDependencies": {
|
|
83
|
-
"@aztec/kv-store": "5.0.0-nightly.
|
|
84
|
-
"@aztec/noir-contracts.js": "5.0.0-nightly.
|
|
85
|
-
"@aztec/noir-test-contracts.js": "5.0.0-nightly.
|
|
83
|
+
"@aztec/kv-store": "5.0.0-nightly.20260526",
|
|
84
|
+
"@aztec/noir-contracts.js": "5.0.0-nightly.20260526",
|
|
85
|
+
"@aztec/noir-test-contracts.js": "5.0.0-nightly.20260526",
|
|
86
86
|
"@jest/globals": "^30.0.0",
|
|
87
87
|
"@types/jest": "^30.0.0",
|
|
88
88
|
"@types/lodash.clonedeep": "^4.5.7",
|
|
@@ -31,6 +31,19 @@ export async function bulkTest(
|
|
|
31
31
|
const expectContractInstance = avmTestContract;
|
|
32
32
|
const argsField = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10].map(x => new Fr(x));
|
|
33
33
|
const argsU8 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10].map(x => new Fr(x));
|
|
34
|
+
// Pinned grumpkin-Poseidon2 Schnorr signature (mirrors the C++ `pinned_test_vector_large`
|
|
35
|
+
// and noir-lang/schnorr v0.4.0's `pinned_vector_large`). Passing these in as calldata
|
|
36
|
+
// (rather than baking them into Noir as constants) keeps MSM + Poseidon2 from being folded
|
|
37
|
+
// by the Noir compiler.
|
|
38
|
+
const schnorrInputs = [
|
|
39
|
+
Fr.fromHexString('0x065812e335a97c2108ea8cf4ccfe2f9dd6b117a0714f5e18461575be93f61da6'), // pubkey.x
|
|
40
|
+
Fr.fromHexString('0x1a915003e8ec534f9a15d926a7ded478e178468ccc4f28e236e67450a55ac622'), // pubkey.y
|
|
41
|
+
Fr.fromHexString('0xf3bc3b7147acb9c621fd9f72dbf15ffa'), // sig_s.lo
|
|
42
|
+
Fr.fromHexString('0x08599f379f0301dfefdbd0272554454d'), // sig_s.hi
|
|
43
|
+
Fr.fromHexString('0x97065383ebbbd76620398792bd259bc2'), // sig_e.lo
|
|
44
|
+
Fr.fromHexString('0x2ceaee87f45b7a417f0ffb05451a8c92'), // sig_e.hi
|
|
45
|
+
Fr.fromHexString('0x0123456789abcdef0fedcba9876543210123456789abcdef0fedcba987654321'), // message
|
|
46
|
+
];
|
|
34
47
|
const args = [
|
|
35
48
|
argsField,
|
|
36
49
|
argsU8,
|
|
@@ -39,6 +52,7 @@ export async function bulkTest(
|
|
|
39
52
|
/*expectedClassId=*/ expectContractInstance.currentContractClassId,
|
|
40
53
|
/*expectedInitializationHash=*/ expectContractInstance.initializationHash,
|
|
41
54
|
/*expectedImmutablesHash=*/ expectContractInstance.immutablesHash,
|
|
55
|
+
/*schnorrInputs=*/ schnorrInputs,
|
|
42
56
|
/*skip_strictly_limited_side_effects=*/ false,
|
|
43
57
|
];
|
|
44
58
|
|
|
@@ -122,6 +136,15 @@ export async function megaBulkTest(
|
|
|
122
136
|
//const argsField7 = [15, 2, 3, 4, 5, 6, 7, 8, 9, 10].map(x => new Fr(x));
|
|
123
137
|
//const argsField8 = [17, 2, 3, 4, 5, 6, 7, 8, 9, 10].map(x => new Fr(x));
|
|
124
138
|
const argsU8 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10].map(x => new Fr(x));
|
|
139
|
+
const schnorrInputs = [
|
|
140
|
+
Fr.fromHexString('0x065812e335a97c2108ea8cf4ccfe2f9dd6b117a0714f5e18461575be93f61da6'), // pubkey.x
|
|
141
|
+
Fr.fromHexString('0x1a915003e8ec534f9a15d926a7ded478e178468ccc4f28e236e67450a55ac622'), // pubkey.y
|
|
142
|
+
Fr.fromHexString('0xf3bc3b7147acb9c621fd9f72dbf15ffa'), // sig_s.lo
|
|
143
|
+
Fr.fromHexString('0x08599f379f0301dfefdbd0272554454d'), // sig_s.hi
|
|
144
|
+
Fr.fromHexString('0x97065383ebbbd76620398792bd259bc2'), // sig_e.lo
|
|
145
|
+
Fr.fromHexString('0x2ceaee87f45b7a417f0ffb05451a8c92'), // sig_e.hi
|
|
146
|
+
Fr.fromHexString('0x0123456789abcdef0fedcba9876543210123456789abcdef0fedcba987654321'), // message
|
|
147
|
+
];
|
|
125
148
|
const genArgs = (argsField: Fr[]) => [
|
|
126
149
|
argsField,
|
|
127
150
|
argsU8,
|
|
@@ -130,6 +153,7 @@ export async function megaBulkTest(
|
|
|
130
153
|
/*expectedClassId=*/ expectContractInstance.currentContractClassId.toField(),
|
|
131
154
|
/*expectedInitializationHash=*/ expectContractInstance.initializationHash.toField(),
|
|
132
155
|
/*expectedImmutablesHash=*/ expectContractInstance.immutablesHash.toField(),
|
|
156
|
+
/*schnorrInputs=*/ schnorrInputs,
|
|
133
157
|
// Must skip strictly limited side effects (logs, messages) so we can spam the bulk test several times.
|
|
134
158
|
/*skip_strictly_limited_side_effects=*/ true,
|
|
135
159
|
];
|
|
@@ -3,7 +3,7 @@ import { padArrayEnd } from '@aztec/foundation/collection';
|
|
|
3
3
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
4
|
import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
5
5
|
import { sleep } from '@aztec/foundation/sleep';
|
|
6
|
-
import { DateProvider, Timer, elapsed,
|
|
6
|
+
import { DateProvider, Timer, elapsed, execWithSignal } from '@aztec/foundation/timer';
|
|
7
7
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
8
8
|
import { ContractClassPublishedEvent } from '@aztec/protocol-contracts/class-registry';
|
|
9
9
|
import { computeFeePayerBalanceLeafSlot, computeFeePayerBalanceStorageSlot } from '@aztec/protocol-contracts/fee-juice';
|
|
@@ -123,6 +123,17 @@ class PublicProcessorTimeoutError extends Error {
|
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
+
class PublicProcessorAbortError extends Error {
|
|
127
|
+
constructor(message: string = 'Aborted while processing tx') {
|
|
128
|
+
super(message);
|
|
129
|
+
this.name = 'PublicProcessorAbortError';
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function isPublicProcessorInterruptError(err: any) {
|
|
134
|
+
return err?.name === 'PublicProcessorTimeoutError' || err?.name === 'PublicProcessorAbortError';
|
|
135
|
+
}
|
|
136
|
+
|
|
126
137
|
/**
|
|
127
138
|
* Converts Txs lifted from the P2P module into ProcessedTx objects by executing
|
|
128
139
|
* any public function calls in them. Txs with private calls only are unaffected.
|
|
@@ -159,7 +170,7 @@ export class PublicProcessor implements Traceable {
|
|
|
159
170
|
limits: PublicProcessorLimits = {},
|
|
160
171
|
validator: PublicProcessorValidator = {},
|
|
161
172
|
): Promise<[ProcessedTx[], FailedTx[], Tx[], NestedProcessReturnValues[], DebugLog[]]> {
|
|
162
|
-
const { maxTransactions, deadline, maxBlockGas, maxBlobFields, isBuildingProposal } = limits;
|
|
173
|
+
const { maxTransactions, deadline, maxBlockGas, maxBlobFields, isBuildingProposal, signal } = limits;
|
|
163
174
|
const { preprocessValidator, nullifierCache } = validator;
|
|
164
175
|
const result: ProcessedTx[] = [];
|
|
165
176
|
const usedTxs: Tx[] = [];
|
|
@@ -182,11 +193,15 @@ export class PublicProcessor implements Traceable {
|
|
|
182
193
|
break;
|
|
183
194
|
}
|
|
184
195
|
|
|
185
|
-
// Bail if we've hit the deadline
|
|
196
|
+
// Bail if we've hit the deadline or have been interrupted.
|
|
186
197
|
if (deadline && this.dateProvider.now() > +deadline) {
|
|
187
198
|
this.log.warn(`Stopping tx processing due to timeout.`);
|
|
188
199
|
break;
|
|
189
200
|
}
|
|
201
|
+
if (signal?.aborted) {
|
|
202
|
+
this.log.warn(`Stopping tx processing due to abort signal.`);
|
|
203
|
+
break;
|
|
204
|
+
}
|
|
190
205
|
|
|
191
206
|
const txHash = tx.getTxHash().toString();
|
|
192
207
|
|
|
@@ -240,7 +255,7 @@ export class PublicProcessor implements Traceable {
|
|
|
240
255
|
|
|
241
256
|
try {
|
|
242
257
|
const [txProcessingTimeMs, [processedTx, returnValues, txDebugLogs]] = await elapsed(() =>
|
|
243
|
-
this.processTx(tx, deadline),
|
|
258
|
+
this.processTx(tx, deadline, signal),
|
|
244
259
|
);
|
|
245
260
|
|
|
246
261
|
// Inject a fake processing failure after N txs if requested
|
|
@@ -311,15 +326,11 @@ export class PublicProcessor implements Traceable {
|
|
|
311
326
|
// Commit the tx-level contracts checkpoint on success
|
|
312
327
|
this.contractsDB.commitCheckpoint();
|
|
313
328
|
} catch (err: any) {
|
|
314
|
-
if (err
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
//
|
|
318
|
-
// Signal cancellation AND WAIT for the simulation to actually stop.
|
|
319
|
-
// This is critical because C++ might be in the middle of a slow operation (e.g., pad_trees)
|
|
320
|
-
// and won't check the cancellation flag until that operation completes.
|
|
321
|
-
// Without waiting, we'd proceed to revert checkpoints while C++ is still writing to state.
|
|
322
|
-
// Wait for C++ to stop gracefully.
|
|
329
|
+
if (isPublicProcessorInterruptError(err)) {
|
|
330
|
+
const interruptReason = err.name === 'PublicProcessorTimeoutError' ? 'timeout' : 'abort signal';
|
|
331
|
+
this.log.warn(`Stopping tx processing due to ${interruptReason}.`);
|
|
332
|
+
// The tx may still be executing on a worker thread (C++ via NAPI).
|
|
333
|
+
// Signal cancellation AND WAIT for the simulation to actually stop before touching fork checkpoints.
|
|
323
334
|
await this.publicTxSimulator.cancel?.();
|
|
324
335
|
|
|
325
336
|
// Now stop the guarded fork to prevent any further TS-side access to the world state.
|
|
@@ -407,9 +418,10 @@ export class PublicProcessor implements Traceable {
|
|
|
407
418
|
private async processTx(
|
|
408
419
|
tx: Tx,
|
|
409
420
|
deadline: Date | undefined,
|
|
421
|
+
signal: AbortSignal | undefined,
|
|
410
422
|
): Promise<[ProcessedTx, NestedProcessReturnValues[], DebugLog[]]> {
|
|
411
423
|
const [time, [processedTx, returnValues, debugLogs]] = await elapsed(() =>
|
|
412
|
-
this.processTxWithinDeadline(tx, deadline),
|
|
424
|
+
this.processTxWithinDeadline(tx, deadline, signal),
|
|
413
425
|
);
|
|
414
426
|
|
|
415
427
|
this.log.verbose(
|
|
@@ -463,10 +475,11 @@ export class PublicProcessor implements Traceable {
|
|
|
463
475
|
this.metrics.recordTreeInsertions(Number(treeInsertionEnd - treeInsertionStart) / 1_000);
|
|
464
476
|
}
|
|
465
477
|
|
|
466
|
-
/** Processes the given tx within deadline
|
|
478
|
+
/** Processes the given tx within deadline or until the signal is aborted. */
|
|
467
479
|
private async processTxWithinDeadline(
|
|
468
480
|
tx: Tx,
|
|
469
481
|
deadline: Date | undefined,
|
|
482
|
+
signal: AbortSignal | undefined,
|
|
470
483
|
): Promise<[ProcessedTx, NestedProcessReturnValues[] | undefined, DebugLog[]]> {
|
|
471
484
|
const innerProcessFn: () => Promise<[ProcessedTx, NestedProcessReturnValues[] | undefined, DebugLog[]]> =
|
|
472
485
|
tx.hasPublicCalls() ? () => this.processTxWithPublicCalls(tx) : () => this.processPrivateOnlyTx(tx);
|
|
@@ -483,27 +496,38 @@ export class PublicProcessor implements Traceable {
|
|
|
483
496
|
}
|
|
484
497
|
: innerProcessFn;
|
|
485
498
|
|
|
486
|
-
|
|
499
|
+
const processingSignal = this.getProcessingSignal(tx, deadline, signal);
|
|
500
|
+
if (!processingSignal) {
|
|
487
501
|
return await processFn();
|
|
488
502
|
}
|
|
489
503
|
|
|
490
|
-
|
|
504
|
+
return await execWithSignal(
|
|
505
|
+
() => processFn(),
|
|
506
|
+
processingSignal,
|
|
507
|
+
signal =>
|
|
508
|
+
signal.reason?.name === 'TimeoutError' ? new PublicProcessorTimeoutError() : new PublicProcessorAbortError(),
|
|
509
|
+
);
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
private getProcessingSignal(tx: Tx, deadline: Date | undefined, signal: AbortSignal | undefined) {
|
|
513
|
+
if (!deadline) {
|
|
514
|
+
return signal;
|
|
515
|
+
}
|
|
516
|
+
|
|
491
517
|
const timeout = +deadline - this.dateProvider.now();
|
|
492
518
|
if (timeout <= 0) {
|
|
493
519
|
throw new PublicProcessorTimeoutError();
|
|
494
520
|
}
|
|
495
521
|
|
|
522
|
+
const txHash = tx.getTxHash();
|
|
496
523
|
this.log.debug(`Processing tx ${txHash.toString()} within ${timeout}ms`, {
|
|
497
524
|
deadline: deadline.toISOString(),
|
|
498
525
|
now: new Date(this.dateProvider.now()).toISOString(),
|
|
499
526
|
txHash,
|
|
500
527
|
});
|
|
501
528
|
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
timeout,
|
|
505
|
-
() => new PublicProcessorTimeoutError(),
|
|
506
|
-
);
|
|
529
|
+
const timeoutSignal = AbortSignal.timeout(timeout);
|
|
530
|
+
return signal ? AbortSignal.any([signal, timeoutSignal]) : timeoutSignal;
|
|
507
531
|
}
|
|
508
532
|
|
|
509
533
|
/**
|