@aztec/simulator 0.0.1-commit.cd76b27 → 0.0.1-commit.d0fcfb7f
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/public_tx_simulation_tester.d.ts +6 -5
- package/dest/public/fixtures/public_tx_simulation_tester.d.ts.map +1 -1
- package/dest/public/fixtures/public_tx_simulation_tester.js +9 -9
- package/dest/public/fixtures/utils.d.ts +2 -2
- package/dest/public/fixtures/utils.d.ts.map +1 -1
- package/dest/public/fixtures/utils.js +2 -2
- package/dest/public/hinting_db_sources.d.ts +4 -4
- package/dest/public/hinting_db_sources.d.ts.map +1 -1
- package/dest/public/hinting_db_sources.js +6 -5
- package/dest/public/public_processor/guarded_merkle_tree.d.ts +4 -4
- package/dest/public/public_processor/guarded_merkle_tree.d.ts.map +1 -1
- package/dest/public/public_processor/guarded_merkle_tree.js +4 -4
- package/dest/public/public_processor/public_processor.d.ts +5 -3
- package/dest/public/public_processor/public_processor.d.ts.map +1 -1
- package/dest/public/public_processor/public_processor.js +50 -41
- package/dest/public/public_tx_simulator/cpp_public_tx_simulator.d.ts +1 -1
- package/dest/public/public_tx_simulator/cpp_public_tx_simulator.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/cpp_public_tx_simulator.js +2 -3
- package/dest/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.d.ts +1 -1
- package/dest/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.js +2 -2
- package/dest/public/public_tx_simulator/factories.d.ts +2 -2
- package/dest/public/public_tx_simulator/factories.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/factories.js +2 -2
- package/dest/public/public_tx_simulator/public_tx_simulator.js +2 -2
- package/package.json +16 -16
- package/src/public/fixtures/public_tx_simulation_tester.ts +28 -5
- package/src/public/fixtures/utils.ts +2 -1
- package/src/public/hinting_db_sources.ts +8 -6
- package/src/public/public_processor/guarded_merkle_tree.ts +5 -5
- package/src/public/public_processor/public_processor.ts +64 -53
- package/src/public/public_tx_simulator/cpp_public_tx_simulator.ts +2 -3
- package/src/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.ts +2 -2
- package/src/public/public_tx_simulator/factories.ts +2 -1
- package/src/public/public_tx_simulator/public_tx_simulator.ts +3 -3
|
@@ -383,6 +383,7 @@ import { computeFeePayerBalanceLeafSlot, computeFeePayerBalanceStorageSlot } fro
|
|
|
383
383
|
import { AvmCircuitInputs, AvmExecutionHints, PublicDataWrite } from '@aztec/stdlib/avm';
|
|
384
384
|
import { computeTransactionFee } from '@aztec/stdlib/fees';
|
|
385
385
|
import { Gas } from '@aztec/stdlib/gas';
|
|
386
|
+
import { NullDebugLogStore } from '@aztec/stdlib/logs';
|
|
386
387
|
import { ProvingRequestType } from '@aztec/stdlib/proofs';
|
|
387
388
|
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
388
389
|
import { NestedProcessReturnValues, makeProcessedTxFromPrivateOnlyTx, makeProcessedTxFromTxWithPublicCalls } from '@aztec/stdlib/tx';
|
|
@@ -446,6 +447,7 @@ _dec = trackSpan('PublicProcessor.processTx', (tx)=>({
|
|
|
446
447
|
dateProvider;
|
|
447
448
|
log;
|
|
448
449
|
opts;
|
|
450
|
+
debugLogStore;
|
|
449
451
|
static{
|
|
450
452
|
({ e: [_initProto] } = _apply_decs_2203_r(this, [
|
|
451
453
|
[
|
|
@@ -466,7 +468,7 @@ _dec = trackSpan('PublicProcessor.processTx', (tx)=>({
|
|
|
466
468
|
], []));
|
|
467
469
|
}
|
|
468
470
|
metrics;
|
|
469
|
-
constructor(globalVariables, guardedMerkleTree, contractsDB, publicTxSimulator, dateProvider, telemetryClient = getTelemetryClient(), log, opts = {}){
|
|
471
|
+
constructor(globalVariables, guardedMerkleTree, contractsDB, publicTxSimulator, dateProvider, telemetryClient = getTelemetryClient(), log, opts = {}, debugLogStore = new NullDebugLogStore()){
|
|
470
472
|
this.globalVariables = globalVariables;
|
|
471
473
|
this.guardedMerkleTree = guardedMerkleTree;
|
|
472
474
|
this.contractsDB = contractsDB;
|
|
@@ -474,6 +476,7 @@ _dec = trackSpan('PublicProcessor.processTx', (tx)=>({
|
|
|
474
476
|
this.dateProvider = dateProvider;
|
|
475
477
|
this.log = log;
|
|
476
478
|
this.opts = opts;
|
|
479
|
+
this.debugLogStore = debugLogStore;
|
|
477
480
|
_initProto(this);
|
|
478
481
|
this.metrics = new PublicProcessorMetrics(telemetryClient, 'PublicProcessor');
|
|
479
482
|
}
|
|
@@ -487,11 +490,12 @@ _dec = trackSpan('PublicProcessor.processTx', (tx)=>({
|
|
|
487
490
|
* @param validator - Pre-process validator and nullifier cache to use for processing the txs.
|
|
488
491
|
* @returns The list of processed txs with their circuit simulation outputs.
|
|
489
492
|
*/ async process(txs, limits = {}, validator = {}) {
|
|
490
|
-
const { maxTransactions,
|
|
493
|
+
const { maxTransactions, deadline, maxBlockGas, maxBlobFields, isBuildingProposal } = limits;
|
|
491
494
|
const { preprocessValidator, nullifierCache } = validator;
|
|
492
495
|
const result = [];
|
|
493
496
|
const usedTxs = [];
|
|
494
497
|
const failed = [];
|
|
498
|
+
const debugLogs = [];
|
|
495
499
|
const timer = new Timer();
|
|
496
500
|
let totalSizeInBytes = 0;
|
|
497
501
|
let returns = [];
|
|
@@ -509,21 +513,23 @@ _dec = trackSpan('PublicProcessor.processTx', (tx)=>({
|
|
|
509
513
|
this.log.warn(`Stopping tx processing due to timeout.`);
|
|
510
514
|
break;
|
|
511
515
|
}
|
|
512
|
-
// Skip this tx if it'd exceed max block size
|
|
513
516
|
const txHash = tx.getTxHash().toString();
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
+
// Skip this tx if its estimated blob fields would exceed the limit.
|
|
518
|
+
// Only done during proposal building: during re-execution we must process the exact txs from the proposal.
|
|
519
|
+
const txBlobFields = tx.getPrivateTxEffectsSizeInFields();
|
|
520
|
+
if (isBuildingProposal && maxBlobFields !== undefined && totalBlobFields + txBlobFields > maxBlobFields) {
|
|
521
|
+
this.log.warn(`Skipping tx ${txHash} with ${txBlobFields} fields from private side effects due to blob fields limit`, {
|
|
517
522
|
txHash,
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
523
|
+
txBlobFields,
|
|
524
|
+
totalBlobFields,
|
|
525
|
+
maxBlobFields
|
|
521
526
|
});
|
|
522
527
|
continue;
|
|
523
528
|
}
|
|
524
|
-
// Skip this tx if its gas limit would exceed the block gas limit
|
|
529
|
+
// Skip this tx if its gas limit would exceed the block gas limit (either da or l2).
|
|
530
|
+
// Only done during proposal building: during re-execution we must process the exact txs from the proposal.
|
|
525
531
|
const txGasLimit = tx.data.constants.txContext.gasSettings.gasLimits;
|
|
526
|
-
if (maxBlockGas !== undefined && totalBlockGas.add(txGasLimit).gtAny(maxBlockGas)) {
|
|
532
|
+
if (isBuildingProposal && maxBlockGas !== undefined && totalBlockGas.add(txGasLimit).gtAny(maxBlockGas)) {
|
|
527
533
|
this.log.warn(`Skipping processing of tx ${txHash} due to block gas limit`, {
|
|
528
534
|
txHash,
|
|
529
535
|
txGasLimit,
|
|
@@ -563,28 +569,15 @@ _dec = trackSpan('PublicProcessor.processTx', (tx)=>({
|
|
|
563
569
|
const startStateReference = await this.guardedMerkleTree.getUnderlyingFork().getStateReference();
|
|
564
570
|
this.contractsDB.createCheckpoint();
|
|
565
571
|
try {
|
|
566
|
-
const [processedTx, returnValues] = await this.processTx(tx, deadline);
|
|
572
|
+
const [processedTx, returnValues, txDebugLogs] = await this.processTx(tx, deadline);
|
|
567
573
|
// Inject a fake processing failure after N txs if requested
|
|
568
574
|
const fakeThrowAfter = this.opts.fakeThrowAfterProcessingTxCount;
|
|
569
575
|
if (fakeThrowAfter !== undefined && result.length + failed.length + 1 >= fakeThrowAfter) {
|
|
570
576
|
throw new Error(`Fake error after processing ${fakeThrowAfter} txs`);
|
|
571
577
|
}
|
|
572
578
|
const txBlobFields = processedTx.txEffect.getNumBlobFields();
|
|
573
|
-
// If the actual size of this tx would exceed block size, skip it
|
|
574
579
|
const txSize = txBlobFields * Fr.SIZE_IN_BYTES;
|
|
575
|
-
|
|
576
|
-
this.log.debug(`Skipping processed tx ${txHash} sized ${txSize} due to max block size.`, {
|
|
577
|
-
txHash,
|
|
578
|
-
sizeInBytes: txSize,
|
|
579
|
-
totalSizeInBytes,
|
|
580
|
-
maxBlockSize
|
|
581
|
-
});
|
|
582
|
-
// Need to revert the checkpoint here and don't go any further
|
|
583
|
-
await checkpoint.revert();
|
|
584
|
-
this.contractsDB.revertCheckpoint();
|
|
585
|
-
continue;
|
|
586
|
-
}
|
|
587
|
-
// If the actual blob fields of this tx would exceed the limit, skip it
|
|
580
|
+
// If the actual blob fields of this tx would exceed the limit, skip it.
|
|
588
581
|
// Note: maxBlobFields already accounts for block end blob fields and previous blocks in checkpoint.
|
|
589
582
|
if (maxBlobFields !== undefined && totalBlobFields + txBlobFields > maxBlobFields) {
|
|
590
583
|
this.log.debug(`Skipping processed tx ${txHash} with ${txBlobFields} blob fields due to max blob fields limit.`, {
|
|
@@ -598,12 +591,28 @@ _dec = trackSpan('PublicProcessor.processTx', (tx)=>({
|
|
|
598
591
|
this.contractsDB.revertCheckpoint();
|
|
599
592
|
continue;
|
|
600
593
|
}
|
|
594
|
+
// During re-execution, check if the actual gas used by this tx would push the block over the gas limit.
|
|
595
|
+
// Unlike the proposal-building check (which uses declared gas limits pessimistically before processing),
|
|
596
|
+
// this uses actual gas and stops processing when the limit is exceeded.
|
|
597
|
+
if (!isBuildingProposal && maxBlockGas !== undefined && totalBlockGas.add(processedTx.gasUsed.totalGas).gtAny(maxBlockGas)) {
|
|
598
|
+
this.log.warn(`Stopping re-execution since tx ${txHash} would push block gas over limit`, {
|
|
599
|
+
txHash,
|
|
600
|
+
txGas: processedTx.gasUsed.totalGas,
|
|
601
|
+
totalBlockGas,
|
|
602
|
+
maxBlockGas
|
|
603
|
+
});
|
|
604
|
+
await checkpoint.revert();
|
|
605
|
+
this.contractsDB.revertCheckpoint();
|
|
606
|
+
break;
|
|
607
|
+
}
|
|
601
608
|
// FIXME(fcarreiro): it's ugly to have to notify the validator of nullifiers.
|
|
602
609
|
// I'd rather pass the validators the processedTx as well and let them deal with it.
|
|
603
610
|
nullifierCache?.addNullifiers(processedTx.txEffect.nullifiers.map((n)=>n.toBuffer()));
|
|
604
611
|
result.push(processedTx);
|
|
605
612
|
usedTxs.push(tx);
|
|
606
613
|
returns = returns.concat(returnValues);
|
|
614
|
+
debugLogs.push(...txDebugLogs);
|
|
615
|
+
this.debugLogStore.storeLogs(processedTx.hash.toString(), txDebugLogs);
|
|
607
616
|
totalPublicGas = totalPublicGas.add(processedTx.gasUsed.publicGas);
|
|
608
617
|
totalBlockGas = totalBlockGas.add(processedTx.gasUsed.totalGas);
|
|
609
618
|
totalSizeInBytes += txSize;
|
|
@@ -624,22 +633,19 @@ _dec = trackSpan('PublicProcessor.processTx', (tx)=>({
|
|
|
624
633
|
// We now know there can't be any further access to world state. The fork is in a state where there is:
|
|
625
634
|
// 1. At least one outstanding checkpoint that has not been committed (the one created before we processed the tx).
|
|
626
635
|
// 2. Possible state updates on that checkpoint or any others created during execution.
|
|
627
|
-
//
|
|
628
|
-
//
|
|
629
|
-
//
|
|
630
|
-
await checkpoint.
|
|
631
|
-
// Now we want to revert any/all remaining checkpoints, destroying any outstanding state updates.
|
|
632
|
-
// This needs to be done directly on the underlying fork as the guarded fork has been stopped.
|
|
633
|
-
await this.guardedMerkleTree.getUnderlyingFork().revertAllCheckpoints();
|
|
636
|
+
// Revert all checkpoints at or above this checkpoint's depth (inclusive), destroying any outstanding state
|
|
637
|
+
// updates from this tx and any nested checkpoints created during execution. This preserves any checkpoints
|
|
638
|
+
// created by callers below our depth.
|
|
639
|
+
await checkpoint.revertToCheckpoint();
|
|
634
640
|
// Revert any contracts added to the DB for the tx.
|
|
635
641
|
this.contractsDB.revertCheckpoint();
|
|
636
642
|
// Ensure we're at the same state as when we started processing this tx.
|
|
637
643
|
await this.checkWorldStateUnchanged(startStateReference, txHash, err);
|
|
638
644
|
break;
|
|
639
645
|
}
|
|
640
|
-
// Roll back state to start of TX before proceeding to next TX
|
|
641
|
-
|
|
642
|
-
await
|
|
646
|
+
// Roll back state to start of TX before proceeding to next TX.
|
|
647
|
+
// Reverts all checkpoints at or above this checkpoint's depth, preserving any caller checkpoints below.
|
|
648
|
+
await checkpoint.revertToCheckpoint();
|
|
643
649
|
this.contractsDB.revertCheckpoint();
|
|
644
650
|
const errorMessage = err instanceof Error || err instanceof AssertionError ? err.message : 'Unknown error';
|
|
645
651
|
this.log.warn(`Failed to process tx ${txHash.toString()}: ${errorMessage} ${err?.stack}`);
|
|
@@ -671,7 +677,7 @@ _dec = trackSpan('PublicProcessor.processTx', (tx)=>({
|
|
|
671
677
|
failed,
|
|
672
678
|
usedTxs,
|
|
673
679
|
returns,
|
|
674
|
-
|
|
680
|
+
debugLogs
|
|
675
681
|
];
|
|
676
682
|
}
|
|
677
683
|
async checkWorldStateUnchanged(startStateReference, txHash, cause) {
|
|
@@ -688,7 +694,7 @@ _dec = trackSpan('PublicProcessor.processTx', (tx)=>({
|
|
|
688
694
|
}
|
|
689
695
|
}
|
|
690
696
|
async processTx(tx, deadline) {
|
|
691
|
-
const [time, [processedTx, returnValues]] = await elapsed(()=>this.processTxWithinDeadline(tx, deadline));
|
|
697
|
+
const [time, [processedTx, returnValues, debugLogs]] = await elapsed(()=>this.processTxWithinDeadline(tx, deadline));
|
|
692
698
|
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`, {
|
|
693
699
|
txHash: processedTx.hash,
|
|
694
700
|
txFee: processedTx.txEffect.transactionFee.toBigInt(),
|
|
@@ -706,7 +712,8 @@ _dec = trackSpan('PublicProcessor.processTx', (tx)=>({
|
|
|
706
712
|
});
|
|
707
713
|
return [
|
|
708
714
|
processedTx,
|
|
709
|
-
returnValues ?? []
|
|
715
|
+
returnValues ?? [],
|
|
716
|
+
debugLogs
|
|
710
717
|
];
|
|
711
718
|
}
|
|
712
719
|
async doTreeInsertionsForPrivateOnlyTx(processedTx) {
|
|
@@ -783,7 +790,8 @@ _dec = trackSpan('PublicProcessor.processTx', (tx)=>({
|
|
|
783
790
|
await this.contractsDB.addNewContracts(tx);
|
|
784
791
|
return [
|
|
785
792
|
processedTx,
|
|
786
|
-
undefined
|
|
793
|
+
undefined,
|
|
794
|
+
[]
|
|
787
795
|
];
|
|
788
796
|
}
|
|
789
797
|
async processTxWithPublicCalls(tx) {
|
|
@@ -805,7 +813,8 @@ _dec = trackSpan('PublicProcessor.processTx', (tx)=>({
|
|
|
805
813
|
const processedTx = makeProcessedTxFromTxWithPublicCalls(tx, this.globalVariables, avmProvingRequest, publicTxEffect, gasUsed, revertCode, revertReason);
|
|
806
814
|
return [
|
|
807
815
|
processedTx,
|
|
808
|
-
appLogicReturnValues
|
|
816
|
+
appLogicReturnValues,
|
|
817
|
+
result.logs ?? []
|
|
809
818
|
];
|
|
810
819
|
}
|
|
811
820
|
/**
|
|
@@ -50,4 +50,4 @@ export declare class TelemetryCppPublicTxSimulator extends MeasuredCppPublicTxSi
|
|
|
50
50
|
readonly tracer: Tracer;
|
|
51
51
|
constructor(merkleTree: MerkleTreeWriteOperations, contractsDB: PublicContractsDB, globalVariables: GlobalVariables, telemetryClient?: TelemetryClient, config?: Partial<PublicSimulatorConfig>, bindings?: LoggerBindings);
|
|
52
52
|
}
|
|
53
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
53
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY3BwX3B1YmxpY190eF9zaW11bGF0b3IuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9wdWJsaWMvcHVibGljX3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SxHQUFFLGVBQXNDLEVBQ3ZELE1BQU0sQ0FBQyxFQUFFLE9BQU8sQ0FBQyxxQkFBcUIsQ0FBQyxFQUN2QyxRQUFRLENBQUMsRUFBRSxjQUFjLEVBSzFCO0NBQ0YifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cpp_public_tx_simulator.d.ts","sourceRoot":"","sources":["../../../src/public/public_tx_simulator/cpp_public_tx_simulator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,cAAc,
|
|
1
|
+
{"version":3,"file":"cpp_public_tx_simulator.d.ts","sourceRoot":"","sources":["../../../src/public/public_tx_simulator/cpp_public_tx_simulator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,cAAc,EAAgB,MAAM,uBAAuB,CAAC;AAIvF,OAAO,EAGL,KAAK,qBAAqB,EAC1B,cAAc,EAEf,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,KAAK,EAAE,eAAe,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAE5D,OAAO,EAAE,KAAK,eAAe,EAAE,KAAK,MAAM,EAAsB,MAAM,yBAAyB,CAAC;AAKhG,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AACjF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAEjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,KAAK,EACV,kCAAkC,EAClC,0BAA0B,EAC3B,MAAM,oCAAoC,CAAC;AAE5C;;;;GAIG;AACH,qBAAa,oBAAqB,SAAQ,iBAAkB,YAAW,0BAA0B;IAC/F,UAAmB,GAAG,EAAE,MAAM,CAAC;IAC/B,2DAA2D;IAC3D,OAAO,CAAC,iBAAiB,CAAC,CAAoB;IAC9C,kF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|
3
3
|
import { avmSimulate, cancelSimulation, createCancellationToken } from '@aztec/native';
|
|
4
4
|
import { ProtocolContractsList } from '@aztec/protocol-contracts';
|
|
@@ -51,8 +51,7 @@ import { PublicTxSimulator } from './public_tx_simulator.js';
|
|
|
51
51
|
this.cancellationToken = createCancellationToken();
|
|
52
52
|
// Store the promise so cancel() can wait for it
|
|
53
53
|
this.log.debug(`Calling C++ simulator for tx ${txHash}`);
|
|
54
|
-
this.simulationPromise = avmSimulate(inputBuffer, contractProvider, wsCppHandle,
|
|
55
|
-
undefined, this.cancellationToken);
|
|
54
|
+
this.simulationPromise = avmSimulate(inputBuffer, contractProvider, wsCppHandle, this.log.level, undefined, this.cancellationToken);
|
|
56
55
|
let resultBuffer;
|
|
57
56
|
try {
|
|
58
57
|
resultBuffer = await this.simulationPromise;
|
|
@@ -39,4 +39,4 @@ export declare class MeasuredCppPublicTxSimulatorHintedDbs extends CppPublicTxSi
|
|
|
39
39
|
constructor(merkleTree: MerkleTreeWriteOperations, contractsDB: PublicContractsDB, globalVariables: GlobalVariables, metrics: ExecutorMetricsInterface, config?: Partial<PublicSimulatorConfig>, bindings?: LoggerBindings);
|
|
40
40
|
simulate(tx: Tx, txLabel?: string): Promise<PublicTxResult>;
|
|
41
41
|
}
|
|
42
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
42
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY3BwX3B1YmxpY190eF9zaW11bGF0b3Jfd2l0aF9oaW50ZWRfZGJzLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvcHVibGljL3B1YmxpY190eF9zaW11bGF0b3IvY3BwX3B1YmxpY190eF9zaW11bGF0b3Jfd2l0aF9oaW50ZWRfZGJzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxLQUFLLE1BQU0sRUFBRSxLQUFLLGNBQWMsRU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Vcsa0NBQWtDO0lBTTNDLFNBQVMsQ0FBQyxRQUFRLENBQUMsT0FBTyxFQUFFLHdCQUF3QjtJQUp0RCxZQUNFLFVBQVUsRUFBRSx5QkFBeUIsRUFDckMsV0FBVyxFQUFFLGlCQUFpQixFQUM5QixlQUFlLEVBQUUsZUFBZSxFQUNiLE9BQU8sRUFBRSx3QkFBd0IsRUFDcEQsTUFBTSxDQUFDLEVBQUUsT0FBTyxDQUFDLHFCQUFxQixDQUFDLEVBQ3ZDLFFBQVEsQ0FBQyxFQUFFLGNBQWMsRUFHMUI7SUFFcUIsUUFBUSxDQUFDLEVBQUUsRUFBRSxFQUFFLEVBQUUsT0FBTyxHQUFFLE1BQXNCLEdBQUcsT0FBTyxDQUFDLGNBQWMsQ0FBQyxDQVMvRjtDQUNGIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cpp_public_tx_simulator_with_hinted_dbs.d.ts","sourceRoot":"","sources":["../../../src/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,cAAc,
|
|
1
|
+
{"version":3,"file":"cpp_public_tx_simulator_with_hinted_dbs.d.ts","sourceRoot":"","sources":["../../../src/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,cAAc,EAAgB,MAAM,uBAAuB,CAAC;AAEvF,OAAO,EAEL,KAAK,qBAAqB,EAC1B,cAAc,EAEf,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,KAAK,EAAE,eAAe,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAI5D,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AACjF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,KAAK,EACV,kCAAkC,EAClC,0BAA0B,EAC3B,MAAM,oCAAoC,CAAC;AAE5C;;;;;GAKG;AACH,qBAAa,6BAA8B,SAAQ,iBAAkB,YAAW,0BAA0B;IACxG,UAAmB,GAAG,EAAE,MAAM,CAAC;IAE/B,YACE,UAAU,EAAE,yBAAyB,EACrC,WAAW,EAAE,iBAAiB,EAC9B,eAAe,EAAE,eAAe,EAChC,MAAM,CAAC,EAAE,OAAO,CAAC,qBAAqB,CAAC,EACvC,QAAQ,CAAC,EAAE,cAAc,EAI1B;IAED;;;;;;;;;OASG;IACmB,QAAQ,CAAC,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,cAAc,CAAC,CA8C9D;CACF;AAED;;;;;;GAMG;AACH,qBAAa,qCACX,SAAQ,6BACR,YAAW,kCAAkC;IAM3C,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,wBAAwB;IAJtD,YACE,UAAU,EAAE,yBAAyB,EACrC,WAAW,EAAE,iBAAiB,EAC9B,eAAe,EAAE,eAAe,EACb,OAAO,EAAE,wBAAwB,EACpD,MAAM,CAAC,EAAE,OAAO,CAAC,qBAAqB,CAAC,EACvC,QAAQ,CAAC,EAAE,cAAc,EAG1B;IAEqB,QAAQ,CAAC,EAAE,EAAE,EAAE,EAAE,OAAO,GAAE,MAAsB,GAAG,OAAO,CAAC,cAAc,CAAC,CAS/F;CACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createLogger
|
|
1
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
2
2
|
import { avmSimulateWithHintedDbs } from '@aztec/native';
|
|
3
3
|
import { AvmCircuitInputs, PublicTxResult, deserializeFromMessagePack } from '@aztec/stdlib/avm';
|
|
4
4
|
import { SimulationError } from '@aztec/stdlib/errors';
|
|
@@ -43,7 +43,7 @@ import { PublicTxSimulator } from './public_tx_simulator.js';
|
|
|
43
43
|
const inputBuffer = avmCircuitInputs.serializeWithMessagePack();
|
|
44
44
|
let resultBuffer;
|
|
45
45
|
try {
|
|
46
|
-
resultBuffer = await avmSimulateWithHintedDbs(inputBuffer,
|
|
46
|
+
resultBuffer = await avmSimulateWithHintedDbs(inputBuffer, this.log.level);
|
|
47
47
|
} catch (error) {
|
|
48
48
|
throw new SimulationError(`C++ hinted simulation failed: ${error.message}`, []);
|
|
49
49
|
}
|
|
@@ -10,5 +10,5 @@ import { DumpingCppPublicTxSimulator } from './dumping_cpp_public_tx_simulator.j
|
|
|
10
10
|
* Uses DumpingCppPublicTxSimulator if DUMP_AVM_INPUTS_TO_DIR env var is set (for CI/testing avm circuit),
|
|
11
11
|
* otherwise uses TelemetryCppPublicTxSimulator (for production).
|
|
12
12
|
*/
|
|
13
|
-
export declare function createPublicTxSimulatorForBlockBuilding(merkleTree: MerkleTreeWriteOperations, contractsDB: PublicContractsDB, globalVariables: GlobalVariables, telemetryClient: TelemetryClient, bindings?: LoggerBindings): DumpingCppPublicTxSimulator | TelemetryCppPublicTxSimulator;
|
|
14
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
13
|
+
export declare function createPublicTxSimulatorForBlockBuilding(merkleTree: MerkleTreeWriteOperations, contractsDB: PublicContractsDB, globalVariables: GlobalVariables, telemetryClient: TelemetryClient, bindings?: LoggerBindings, collectDebugLogs?: boolean): DumpingCppPublicTxSimulator | TelemetryCppPublicTxSimulator;
|
|
14
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmFjdG9yaWVzLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvcHVibGljL3B1YmxpY190eF9zaW11bGF0b3IvZmFjdG9yaWVzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLGNBQWMsRUFBRSxNQUFNLHVCQUF1QixDQU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AAsC,CAAC;AAEnF;;;;GAIG;AACH,wBAAgB,uCAAuC,CACrD,UAAU,EAAE,yBAAyB,EACrC,WAAW,EAAE,iBAAiB,EAC9B,eAAe,EAAE,eAAe,EAChC,eAAe,EAAE,eAAe,EAChC,QAAQ,CAAC,EAAE,cAAc,+
|
|
1
|
+
{"version":3,"file":"factories.d.ts","sourceRoot":"","sources":["../../../src/public/public_tx_simulator/factories.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE/D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,6BAA6B,EAAE,MAAM,8BAA8B,CAAC;AAC7E,OAAO,EAAE,2BAA2B,EAAE,MAAM,sCAAsC,CAAC;AAEnF;;;;GAIG;AACH,wBAAgB,uCAAuC,CACrD,UAAU,EAAE,yBAAyB,EACrC,WAAW,EAAE,iBAAiB,EAC9B,eAAe,EAAE,eAAe,EAChC,eAAe,EAAE,eAAe,EAChC,QAAQ,CAAC,EAAE,cAAc,EACzB,gBAAgB,UAAQ,+DAsBzB"}
|
|
@@ -5,10 +5,10 @@ import { DumpingCppPublicTxSimulator } from './dumping_cpp_public_tx_simulator.j
|
|
|
5
5
|
* Creates a public tx simulator for block building.
|
|
6
6
|
* Uses DumpingCppPublicTxSimulator if DUMP_AVM_INPUTS_TO_DIR env var is set (for CI/testing avm circuit),
|
|
7
7
|
* otherwise uses TelemetryCppPublicTxSimulator (for production).
|
|
8
|
-
*/ export function createPublicTxSimulatorForBlockBuilding(merkleTree, contractsDB, globalVariables, telemetryClient, bindings) {
|
|
8
|
+
*/ export function createPublicTxSimulatorForBlockBuilding(merkleTree, contractsDB, globalVariables, telemetryClient, bindings, collectDebugLogs = false) {
|
|
9
9
|
const config = PublicSimulatorConfig.from({
|
|
10
10
|
skipFeeEnforcement: false,
|
|
11
|
-
collectDebugLogs
|
|
11
|
+
collectDebugLogs,
|
|
12
12
|
collectHints: false,
|
|
13
13
|
collectPublicInputs: false,
|
|
14
14
|
collectStatistics: false,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MAX_PROCESSABLE_L2_GAS } from '@aztec/constants';
|
|
2
2
|
import { createLogger } from '@aztec/foundation/log';
|
|
3
3
|
import { ProtocolContractAddress, ProtocolContractsList } from '@aztec/protocol-contracts';
|
|
4
4
|
import { computeFeePayerBalanceStorageSlot } from '@aztec/protocol-contracts/fee-juice';
|
|
@@ -137,7 +137,7 @@ export class PublicTxSimulator {
|
|
|
137
137
|
}
|
|
138
138
|
context.halt();
|
|
139
139
|
// Such transactions should be filtered by GasTxValidator.
|
|
140
|
-
assert(context.getActualGasUsed().l2Gas <=
|
|
140
|
+
assert(context.getActualGasUsed().l2Gas <= MAX_PROCESSABLE_L2_GAS, `Transaction consumes ${context.getActualGasUsed().l2Gas} L2 gas, which exceeds the maximum processable gas of ${MAX_PROCESSABLE_L2_GAS}`);
|
|
141
141
|
await this.payFee(context);
|
|
142
142
|
const publicInputs = await context.generateAvmCircuitPublicInputs();
|
|
143
143
|
const revertCode = context.getFinalRevertCode();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/simulator",
|
|
3
|
-
"version": "0.0.1-commit.
|
|
3
|
+
"version": "0.0.1-commit.d0fcfb7f",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./server": "./dest/server.js",
|
|
@@ -64,26 +64,26 @@
|
|
|
64
64
|
]
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"@aztec/constants": "0.0.1-commit.
|
|
68
|
-
"@aztec/foundation": "0.0.1-commit.
|
|
69
|
-
"@aztec/native": "0.0.1-commit.
|
|
70
|
-
"@aztec/noir-acvm_js": "0.0.1-commit.
|
|
71
|
-
"@aztec/noir-noirc_abi": "0.0.1-commit.
|
|
72
|
-
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.
|
|
73
|
-
"@aztec/noir-types": "0.0.1-commit.
|
|
74
|
-
"@aztec/protocol-contracts": "0.0.1-commit.
|
|
75
|
-
"@aztec/stdlib": "0.0.1-commit.
|
|
76
|
-
"@aztec/telemetry-client": "0.0.1-commit.
|
|
77
|
-
"@aztec/world-state": "0.0.1-commit.
|
|
67
|
+
"@aztec/constants": "0.0.1-commit.d0fcfb7f",
|
|
68
|
+
"@aztec/foundation": "0.0.1-commit.d0fcfb7f",
|
|
69
|
+
"@aztec/native": "0.0.1-commit.d0fcfb7f",
|
|
70
|
+
"@aztec/noir-acvm_js": "0.0.1-commit.d0fcfb7f",
|
|
71
|
+
"@aztec/noir-noirc_abi": "0.0.1-commit.d0fcfb7f",
|
|
72
|
+
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.d0fcfb7f",
|
|
73
|
+
"@aztec/noir-types": "0.0.1-commit.d0fcfb7f",
|
|
74
|
+
"@aztec/protocol-contracts": "0.0.1-commit.d0fcfb7f",
|
|
75
|
+
"@aztec/stdlib": "0.0.1-commit.d0fcfb7f",
|
|
76
|
+
"@aztec/telemetry-client": "0.0.1-commit.d0fcfb7f",
|
|
77
|
+
"@aztec/world-state": "0.0.1-commit.d0fcfb7f",
|
|
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": "0.0.1-commit.
|
|
84
|
-
"@aztec/merkle-tree": "0.0.1-commit.
|
|
85
|
-
"@aztec/noir-contracts.js": "0.0.1-commit.
|
|
86
|
-
"@aztec/noir-test-contracts.js": "0.0.1-commit.
|
|
83
|
+
"@aztec/kv-store": "0.0.1-commit.d0fcfb7f",
|
|
84
|
+
"@aztec/merkle-tree": "0.0.1-commit.d0fcfb7f",
|
|
85
|
+
"@aztec/noir-contracts.js": "0.0.1-commit.d0fcfb7f",
|
|
86
|
+
"@aztec/noir-test-contracts.js": "0.0.1-commit.d0fcfb7f",
|
|
87
87
|
"@jest/globals": "^30.0.0",
|
|
88
88
|
"@types/jest": "^30.0.0",
|
|
89
89
|
"@types/lodash.clonedeep": "^4.5.7",
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
DEFAULT_TEARDOWN_DA_GAS_LIMIT,
|
|
3
|
+
DEFAULT_TEARDOWN_L2_GAS_LIMIT,
|
|
4
|
+
PUBLIC_TX_L2_GAS_OVERHEAD,
|
|
5
|
+
TX_DA_GAS_OVERHEAD,
|
|
6
|
+
} from '@aztec/constants';
|
|
2
7
|
import { asyncMap } from '@aztec/foundation/async-map';
|
|
3
8
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
4
9
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
@@ -112,6 +117,7 @@ export class PublicTxSimulationTester extends BaseAvmSimulationTester {
|
|
|
112
117
|
feePayer: AztecAddress = sender,
|
|
113
118
|
/* need some unique first nullifier for note-nonce computations */
|
|
114
119
|
privateInsertions: TestPrivateInsertions = { nonRevertible: { nullifiers: [new Fr(420000 + this.txCount)] } },
|
|
120
|
+
gasLimits?: Gas,
|
|
115
121
|
): Promise<Tx> {
|
|
116
122
|
const setupCallRequests = await asyncMap(setupCalls, call =>
|
|
117
123
|
this.#createPubicCallRequestForCall(call, call.sender ?? sender),
|
|
@@ -131,9 +137,13 @@ export class PublicTxSimulationTester extends BaseAvmSimulationTester {
|
|
|
131
137
|
teardownCallRequest,
|
|
132
138
|
feePayer,
|
|
133
139
|
/*gasUsedByPrivate*/ teardownCall
|
|
134
|
-
? new Gas(
|
|
135
|
-
|
|
140
|
+
? new Gas(
|
|
141
|
+
DEFAULT_TEARDOWN_DA_GAS_LIMIT + TX_DA_GAS_OVERHEAD,
|
|
142
|
+
DEFAULT_TEARDOWN_L2_GAS_LIMIT + PUBLIC_TX_L2_GAS_OVERHEAD,
|
|
143
|
+
)
|
|
144
|
+
: new Gas(TX_DA_GAS_OVERHEAD, PUBLIC_TX_L2_GAS_OVERHEAD),
|
|
136
145
|
defaultGlobals(),
|
|
146
|
+
gasLimits,
|
|
137
147
|
);
|
|
138
148
|
}
|
|
139
149
|
|
|
@@ -146,8 +156,9 @@ export class PublicTxSimulationTester extends BaseAvmSimulationTester {
|
|
|
146
156
|
/* need some unique first nullifier for note-nonce computations */
|
|
147
157
|
privateInsertions?: TestPrivateInsertions,
|
|
148
158
|
txLabel: string = 'unlabeledTx',
|
|
159
|
+
gasLimits?: Gas,
|
|
149
160
|
): Promise<PublicTxResult> {
|
|
150
|
-
const tx = await this.createTx(sender, setupCalls, appCalls, teardownCall, feePayer, privateInsertions);
|
|
161
|
+
const tx = await this.createTx(sender, setupCalls, appCalls, teardownCall, feePayer, privateInsertions, gasLimits);
|
|
151
162
|
|
|
152
163
|
await this.setFeePayerBalance(feePayer);
|
|
153
164
|
|
|
@@ -190,8 +201,18 @@ export class PublicTxSimulationTester extends BaseAvmSimulationTester {
|
|
|
190
201
|
teardownCall?: TestEnqueuedCall,
|
|
191
202
|
feePayer?: AztecAddress,
|
|
192
203
|
privateInsertions?: TestPrivateInsertions,
|
|
204
|
+
gasLimits?: Gas,
|
|
193
205
|
): Promise<PublicTxResult> {
|
|
194
|
-
return await this.simulateTx(
|
|
206
|
+
return await this.simulateTx(
|
|
207
|
+
sender,
|
|
208
|
+
setupCalls,
|
|
209
|
+
appCalls,
|
|
210
|
+
teardownCall,
|
|
211
|
+
feePayer,
|
|
212
|
+
privateInsertions,
|
|
213
|
+
txLabel,
|
|
214
|
+
gasLimits,
|
|
215
|
+
);
|
|
195
216
|
}
|
|
196
217
|
|
|
197
218
|
/**
|
|
@@ -209,6 +230,7 @@ export class PublicTxSimulationTester extends BaseAvmSimulationTester {
|
|
|
209
230
|
teardownCall?: TestEnqueuedCall,
|
|
210
231
|
feePayer?: AztecAddress,
|
|
211
232
|
privateInsertions?: TestPrivateInsertions,
|
|
233
|
+
gasLimits?: Gas,
|
|
212
234
|
): Promise<PublicTxResult> {
|
|
213
235
|
return await this.simulateTxWithLabel(
|
|
214
236
|
txLabel,
|
|
@@ -218,6 +240,7 @@ export class PublicTxSimulationTester extends BaseAvmSimulationTester {
|
|
|
218
240
|
teardownCall,
|
|
219
241
|
feePayer,
|
|
220
242
|
privateInsertions,
|
|
243
|
+
gasLimits,
|
|
221
244
|
);
|
|
222
245
|
}
|
|
223
246
|
|
|
@@ -62,13 +62,14 @@ export async function createTxForPublicCalls(
|
|
|
62
62
|
feePayer = AztecAddress.zero(),
|
|
63
63
|
gasUsedByPrivate: Gas = Gas.empty(),
|
|
64
64
|
globals: GlobalVariables = GlobalVariables.empty(),
|
|
65
|
+
gasLimits?: Gas,
|
|
65
66
|
): Promise<Tx> {
|
|
66
67
|
assert(
|
|
67
68
|
setupCallRequests.length > 0 || appCallRequests.length > 0 || teardownCallRequest !== undefined,
|
|
68
69
|
"Can't create public tx with no enqueued calls",
|
|
69
70
|
);
|
|
70
71
|
// use max limits
|
|
71
|
-
|
|
72
|
+
gasLimits = gasLimits ?? new Gas(DEFAULT_DA_GAS_LIMIT, DEFAULT_L2_GAS_LIMIT);
|
|
72
73
|
|
|
73
74
|
const forPublic = PartialPrivateTailPublicInputsForPublic.empty();
|
|
74
75
|
|
|
@@ -410,12 +410,12 @@ export class HintingMerkleWriteOperations implements MerkleTreeWriteOperations {
|
|
|
410
410
|
}
|
|
411
411
|
}
|
|
412
412
|
|
|
413
|
-
public async createCheckpoint(): Promise<
|
|
413
|
+
public async createCheckpoint(): Promise<number> {
|
|
414
414
|
const actionCounter = this.checkpointActionCounter++;
|
|
415
415
|
const oldCheckpointId = this.getCurrentCheckpointId();
|
|
416
416
|
const treesStateHash = await this.getTreesStateHash();
|
|
417
417
|
|
|
418
|
-
await this.db.createCheckpoint();
|
|
418
|
+
const depth = await this.db.createCheckpoint();
|
|
419
419
|
this.checkpointStack.push(this.nextCheckpointId++);
|
|
420
420
|
const newCheckpointId = this.getCurrentCheckpointId();
|
|
421
421
|
|
|
@@ -424,14 +424,16 @@ export class HintingMerkleWriteOperations implements MerkleTreeWriteOperations {
|
|
|
424
424
|
HintingMerkleWriteOperations.log.trace(
|
|
425
425
|
`[createCheckpoint:${actionCounter}] Checkpoint evolved ${oldCheckpointId} -> ${newCheckpointId} at trees state ${treesStateHash}.`,
|
|
426
426
|
);
|
|
427
|
+
|
|
428
|
+
return depth;
|
|
427
429
|
}
|
|
428
430
|
|
|
429
|
-
public
|
|
430
|
-
throw new Error('
|
|
431
|
+
public commitAllCheckpointsTo(_depth: number): Promise<void> {
|
|
432
|
+
throw new Error('commitAllCheckpointsTo is not supported in HintingMerkleWriteOperations.');
|
|
431
433
|
}
|
|
432
434
|
|
|
433
|
-
public
|
|
434
|
-
throw new Error('
|
|
435
|
+
public revertAllCheckpointsTo(_depth: number): Promise<void> {
|
|
436
|
+
throw new Error('revertAllCheckpointsTo is not supported in HintingMerkleWriteOperations.');
|
|
435
437
|
}
|
|
436
438
|
|
|
437
439
|
public async commitCheckpoint(): Promise<void> {
|
|
@@ -134,7 +134,7 @@ export class GuardedMerkleTreeOperations implements MerkleTreeWriteOperations {
|
|
|
134
134
|
): Promise<(BlockNumber | undefined)[]> {
|
|
135
135
|
return this.guardAndPush(() => this.target.getBlockNumbersForLeafIndices(treeId, leafIndices));
|
|
136
136
|
}
|
|
137
|
-
createCheckpoint(): Promise<
|
|
137
|
+
createCheckpoint(): Promise<number> {
|
|
138
138
|
return this.guardAndPush(() => this.target.createCheckpoint());
|
|
139
139
|
}
|
|
140
140
|
commitCheckpoint(): Promise<void> {
|
|
@@ -143,11 +143,11 @@ export class GuardedMerkleTreeOperations implements MerkleTreeWriteOperations {
|
|
|
143
143
|
revertCheckpoint(): Promise<void> {
|
|
144
144
|
return this.guardAndPush(() => this.target.revertCheckpoint());
|
|
145
145
|
}
|
|
146
|
-
|
|
147
|
-
return this.guardAndPush(() => this.target.
|
|
146
|
+
commitAllCheckpointsTo(depth: number): Promise<void> {
|
|
147
|
+
return this.guardAndPush(() => this.target.commitAllCheckpointsTo(depth));
|
|
148
148
|
}
|
|
149
|
-
|
|
150
|
-
return this.guardAndPush(() => this.target.
|
|
149
|
+
revertAllCheckpointsTo(depth: number): Promise<void> {
|
|
150
|
+
return this.guardAndPush(() => this.target.revertAllCheckpointsTo(depth));
|
|
151
151
|
}
|
|
152
152
|
findSiblingPaths<ID extends MerkleTreeId>(
|
|
153
153
|
treeId: ID,
|