@aztec/prover-client 0.0.1-commit.2448fdb → 0.0.1-commit.2606882
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/config.d.ts +1 -1
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +16 -2
- package/dest/light/lightweight_checkpoint_builder.d.ts +5 -2
- package/dest/light/lightweight_checkpoint_builder.d.ts.map +1 -1
- package/dest/light/lightweight_checkpoint_builder.js +33 -11
- package/dest/mocks/test_context.d.ts +3 -1
- package/dest/mocks/test_context.d.ts.map +1 -1
- package/dest/mocks/test_context.js +13 -7
- package/dest/orchestrator/block-building-helpers.d.ts +1 -1
- package/dest/orchestrator/checkpoint-proving-state.d.ts +8 -1
- package/dest/orchestrator/checkpoint-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/checkpoint-proving-state.js +10 -1
- package/dest/orchestrator/checkpoint-sub-tree-orchestrator.d.ts +107 -0
- package/dest/orchestrator/checkpoint-sub-tree-orchestrator.d.ts.map +1 -0
- package/dest/orchestrator/checkpoint-sub-tree-orchestrator.js +151 -0
- package/dest/orchestrator/epoch-proving-context.d.ts +51 -0
- package/dest/orchestrator/epoch-proving-context.d.ts.map +1 -0
- package/dest/orchestrator/epoch-proving-context.js +81 -0
- package/dest/orchestrator/epoch-proving-state.d.ts +1 -1
- package/dest/orchestrator/index.d.ts +4 -1
- package/dest/orchestrator/index.d.ts.map +1 -1
- package/dest/orchestrator/index.js +3 -0
- package/dest/orchestrator/orchestrator.d.ts +14 -26
- package/dest/orchestrator/orchestrator.d.ts.map +1 -1
- package/dest/orchestrator/orchestrator.js +32 -169
- package/dest/orchestrator/proving-scheduler.d.ts +72 -0
- package/dest/orchestrator/proving-scheduler.d.ts.map +1 -0
- package/dest/orchestrator/proving-scheduler.js +117 -0
- package/dest/orchestrator/top-tree-orchestrator.d.ts +83 -0
- package/dest/orchestrator/top-tree-orchestrator.d.ts.map +1 -0
- package/dest/orchestrator/top-tree-orchestrator.js +182 -0
- package/dest/orchestrator/top-tree-proving-scheduler.d.ts +62 -0
- package/dest/orchestrator/top-tree-proving-scheduler.d.ts.map +1 -0
- package/dest/orchestrator/top-tree-proving-scheduler.js +73 -0
- package/dest/orchestrator/top-tree-proving-state.d.ts +61 -0
- package/dest/orchestrator/top-tree-proving-state.d.ts.map +1 -0
- package/dest/orchestrator/top-tree-proving-state.js +185 -0
- package/dest/prover-client/prover-client.d.ts +61 -2
- package/dest/prover-client/prover-client.d.ts.map +1 -1
- package/dest/prover-client/prover-client.js +49 -1
- package/dest/proving_broker/broker_prover_facade.d.ts +1 -1
- package/dest/proving_broker/broker_prover_facade.d.ts.map +1 -1
- package/dest/proving_broker/broker_prover_facade.js +10 -16
- package/dest/proving_broker/config.d.ts +9 -73
- package/dest/proving_broker/config.d.ts.map +1 -1
- package/dest/proving_broker/config.js +3 -3
- package/dest/proving_broker/index.d.ts +2 -1
- package/dest/proving_broker/index.d.ts.map +1 -1
- package/dest/proving_broker/index.js +1 -0
- package/dest/proving_broker/proving_broker.d.ts +2 -2
- package/dest/proving_broker/proving_broker.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker.js +32 -7
- package/dest/proving_broker/proving_broker_database/persisted.js +2 -2
- package/dest/proving_broker/rpc.d.ts +1 -1
- package/dest/proving_broker/rpc.d.ts.map +1 -1
- package/dest/proving_broker/rpc.js +64 -9
- package/dest/test/mock_prover.d.ts +3 -3
- package/package.json +18 -18
- package/src/config.ts +18 -2
- package/src/light/lightweight_checkpoint_builder.ts +35 -20
- package/src/mocks/test_context.ts +11 -8
- package/src/orchestrator/checkpoint-proving-state.ts +14 -1
- package/src/orchestrator/checkpoint-sub-tree-orchestrator.ts +271 -0
- package/src/orchestrator/epoch-proving-context.ts +101 -0
- package/src/orchestrator/index.ts +8 -0
- package/src/orchestrator/orchestrator.ts +46 -225
- package/src/orchestrator/proving-scheduler.ts +156 -0
- package/src/orchestrator/top-tree-orchestrator.ts +314 -0
- package/src/orchestrator/top-tree-proving-scheduler.ts +154 -0
- package/src/orchestrator/top-tree-proving-state.ts +220 -0
- package/src/prover-client/prover-client.ts +125 -1
- package/src/proving_broker/broker_prover_facade.ts +8 -16
- package/src/proving_broker/config.ts +3 -2
- package/src/proving_broker/index.ts +1 -0
- package/src/proving_broker/proving_broker.ts +27 -5
- package/src/proving_broker/proving_broker_database/persisted.ts +2 -2
- package/src/proving_broker/rpc.ts +24 -21
|
@@ -371,18 +371,13 @@ function _apply_decs_2203_r(targetClass, memberDecs, classDecs, parentClass) {
|
|
|
371
371
|
return (_apply_decs_2203_r = applyDecs2203RFactory())(targetClass, memberDecs, classDecs, parentClass);
|
|
372
372
|
}
|
|
373
373
|
var _dec, _dec1, _dec2, _dec3, _dec4, _initProto;
|
|
374
|
-
import { L1_TO_L2_MSG_SUBTREE_HEIGHT, L1_TO_L2_MSG_SUBTREE_ROOT_SIBLING_PATH_LENGTH,
|
|
374
|
+
import { L1_TO_L2_MSG_SUBTREE_HEIGHT, L1_TO_L2_MSG_SUBTREE_ROOT_SIBLING_PATH_LENGTH, NUM_BASE_PARITY_PER_ROOT_PARITY } from '@aztec/constants';
|
|
375
375
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
376
|
-
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
377
|
-
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
378
|
-
import { AbortError } from '@aztec/foundation/error';
|
|
379
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
380
376
|
import { promiseWithResolvers } from '@aztec/foundation/promise';
|
|
381
|
-
import { SerialQueue } from '@aztec/foundation/queue';
|
|
382
377
|
import { assertLength } from '@aztec/foundation/serialize';
|
|
383
|
-
import { sleep } from '@aztec/foundation/sleep';
|
|
384
378
|
import { pushTestData } from '@aztec/foundation/testing';
|
|
385
379
|
import { elapsed } from '@aztec/foundation/timer';
|
|
380
|
+
import { appendL1ToL2MessagesToTree } from '@aztec/stdlib/messaging';
|
|
386
381
|
import { BlockRootEmptyTxFirstRollupPrivateInputs, BlockRootFirstRollupPrivateInputs, BlockRootSingleTxFirstRollupPrivateInputs, BlockRootSingleTxRollupPrivateInputs, CheckpointRootSingleBlockRollupPrivateInputs, PrivateTxBaseRollupPrivateInputs } from '@aztec/stdlib/rollup';
|
|
387
382
|
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
388
383
|
import { Attributes, getTelemetryClient, trackSpan, wrapCallbackInSpan } from '@aztec/telemetry-client';
|
|
@@ -390,6 +385,7 @@ import { inspect } from 'util';
|
|
|
390
385
|
import { buildHeaderFromCircuitOutputs, getLastSiblingPath, getPublicChonkVerifierPrivateInputsFromTx, getRootTreeSiblingPath, getSubtreeSiblingPath, getTreeSnapshot, insertSideEffectsAndBuildBaseRollupHints, validatePartialState, validateTx } from './block-building-helpers.js';
|
|
391
386
|
import { EpochProvingState } from './epoch-proving-state.js';
|
|
392
387
|
import { ProvingOrchestratorMetrics } from './orchestrator_metrics.js';
|
|
388
|
+
import { TopTreeProvingScheduler } from './top-tree-proving-scheduler.js';
|
|
393
389
|
import { TxProvingState } from './tx-proving-state.js';
|
|
394
390
|
_dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
395
391
|
[Attributes.BLOCK_NUMBER]: blockNumber
|
|
@@ -411,12 +407,10 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
411
407
|
* The proving implementation is determined by the provided prover. This could be for example a local prover or a remote prover pool.
|
|
412
408
|
*/ /**
|
|
413
409
|
* The orchestrator, managing the flow of recursive proving operations required to build the rollup proof tree.
|
|
414
|
-
*/ export class ProvingOrchestrator {
|
|
410
|
+
*/ export class ProvingOrchestrator extends TopTreeProvingScheduler {
|
|
415
411
|
dbProvider;
|
|
416
|
-
prover;
|
|
417
412
|
proverId;
|
|
418
413
|
cancelJobsOnStop;
|
|
419
|
-
enqueueConcurrency;
|
|
420
414
|
static{
|
|
421
415
|
({ e: [_initProto] } = _apply_decs_2203_r(this, [
|
|
422
416
|
[
|
|
@@ -447,27 +441,12 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
447
441
|
], []));
|
|
448
442
|
}
|
|
449
443
|
provingState;
|
|
450
|
-
pendingProvingJobs;
|
|
451
444
|
provingPromise;
|
|
452
445
|
metrics;
|
|
453
|
-
// eslint-disable-next-line aztec-custom/no-non-primitive-in-collections
|
|
454
446
|
dbs;
|
|
455
|
-
logger;
|
|
456
|
-
deferredJobQueue;
|
|
457
447
|
constructor(dbProvider, prover, proverId, cancelJobsOnStop = false, enqueueConcurrency, telemetryClient = getTelemetryClient(), bindings){
|
|
458
|
-
this.dbProvider = dbProvider;
|
|
459
|
-
this.prover = prover;
|
|
460
|
-
this.proverId = proverId;
|
|
461
|
-
this.cancelJobsOnStop = cancelJobsOnStop;
|
|
462
|
-
this.enqueueConcurrency = enqueueConcurrency;
|
|
463
|
-
this.provingState = (_initProto(this), undefined);
|
|
464
|
-
this.pendingProvingJobs = [];
|
|
465
|
-
this.provingPromise = undefined;
|
|
466
|
-
this.dbs = new Map();
|
|
467
|
-
this.deferredJobQueue = new SerialQueue();
|
|
468
|
-
this.logger = createLogger('prover-client:orchestrator', bindings);
|
|
448
|
+
super(prover, enqueueConcurrency, 'prover-client:orchestrator', bindings), this.dbProvider = dbProvider, this.proverId = proverId, this.cancelJobsOnStop = cancelJobsOnStop, this.provingState = (_initProto(this), undefined), this.provingPromise = undefined, this.dbs = new Map();
|
|
469
449
|
this.metrics = new ProvingOrchestratorMetrics(telemetryClient, 'ProvingOrchestrator');
|
|
470
|
-
this.deferredJobQueue.start(this.enqueueConcurrency);
|
|
471
450
|
}
|
|
472
451
|
get tracer() {
|
|
473
452
|
return this.metrics.tracer;
|
|
@@ -478,11 +457,18 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
478
457
|
getNumActiveForks() {
|
|
479
458
|
return this.dbs.size;
|
|
480
459
|
}
|
|
481
|
-
|
|
482
|
-
// Grab the old queue before cancel() replaces it, so we can await its draining.
|
|
483
|
-
const oldQueue = this.deferredJobQueue;
|
|
460
|
+
cancelInternal() {
|
|
484
461
|
this.cancel();
|
|
485
|
-
|
|
462
|
+
}
|
|
463
|
+
wrapCircuitCall(circuitName, fn) {
|
|
464
|
+
return wrapCallbackInSpan(this.tracer, `ProvingOrchestrator.prover.${circuitName}`, {
|
|
465
|
+
[Attributes.PROTOCOL_CIRCUIT_NAME]: circuitName
|
|
466
|
+
}, fn);
|
|
467
|
+
}
|
|
468
|
+
onRootRollupComplete(state) {
|
|
469
|
+
state.resolve({
|
|
470
|
+
status: 'success'
|
|
471
|
+
});
|
|
486
472
|
}
|
|
487
473
|
startNewEpoch(epochNumber, totalNumCheckpoints, finalBlobBatchingChallenges) {
|
|
488
474
|
if (this.provingState?.verifyState()) {
|
|
@@ -742,15 +728,7 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
742
728
|
* If cancelJobsOnStop is true, aborts all pending jobs with the broker (which marks them as 'Aborted').
|
|
743
729
|
* If cancelJobsOnStop is false (default), jobs remain in the broker queue and can be reused on restart/reorg.
|
|
744
730
|
*/ cancel() {
|
|
745
|
-
|
|
746
|
-
// Recreate the queue so it can accept jobs for subsequent epochs.
|
|
747
|
-
this.deferredJobQueue = new SerialQueue();
|
|
748
|
-
this.deferredJobQueue.start(this.enqueueConcurrency);
|
|
749
|
-
if (this.cancelJobsOnStop) {
|
|
750
|
-
for (const controller of this.pendingProvingJobs){
|
|
751
|
-
controller.abort();
|
|
752
|
-
}
|
|
753
|
-
}
|
|
731
|
+
this.resetSchedulerState(this.cancelJobsOnStop);
|
|
754
732
|
this.provingState?.cancel();
|
|
755
733
|
for (const [blockNumber, db] of this.dbs.entries()){
|
|
756
734
|
void db.close().catch((err)=>this.logger.error(`Error closing db for block ${blockNumber}`, err));
|
|
@@ -782,64 +760,11 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
782
760
|
});
|
|
783
761
|
return epochProofResult;
|
|
784
762
|
}
|
|
785
|
-
/**
|
|
786
|
-
* Enqueue a job to be scheduled
|
|
787
|
-
* @param provingState - The proving state object being operated on
|
|
788
|
-
* @param jobType - The type of job to be queued
|
|
789
|
-
* @param job - The actual job, returns a promise notifying of the job's completion
|
|
790
|
-
*/ deferredProving(provingState, request, callback) {
|
|
791
|
-
if (!provingState.verifyState()) {
|
|
792
|
-
this.logger.debug(`Not enqueuing job, state no longer valid`);
|
|
793
|
-
return;
|
|
794
|
-
}
|
|
795
|
-
const controller = new AbortController();
|
|
796
|
-
this.pendingProvingJobs.push(controller);
|
|
797
|
-
// We use a 'safeJob'. We don't want promise rejections in the proving pool, we want to capture the error here
|
|
798
|
-
// and reject the proving job whilst keeping the event loop free of rejections
|
|
799
|
-
const safeJob = async ()=>{
|
|
800
|
-
try {
|
|
801
|
-
// there's a delay between enqueueing this job and it actually running
|
|
802
|
-
if (controller.signal.aborted) {
|
|
803
|
-
return;
|
|
804
|
-
}
|
|
805
|
-
const result = await request(controller.signal);
|
|
806
|
-
if (!provingState.verifyState()) {
|
|
807
|
-
this.logger.debug(`State no longer valid, discarding result`);
|
|
808
|
-
return;
|
|
809
|
-
}
|
|
810
|
-
// we could have been cancelled whilst waiting for the result
|
|
811
|
-
// and the prover ignored the signal. Drop the result in that case
|
|
812
|
-
if (controller.signal.aborted) {
|
|
813
|
-
return;
|
|
814
|
-
}
|
|
815
|
-
await callback(result);
|
|
816
|
-
} catch (err) {
|
|
817
|
-
if (err instanceof AbortError) {
|
|
818
|
-
// operation was cancelled, probably because the block was cancelled
|
|
819
|
-
// drop this result
|
|
820
|
-
return;
|
|
821
|
-
}
|
|
822
|
-
this.logger.error(`Error thrown when proving job`, err);
|
|
823
|
-
provingState.reject(`${err}`);
|
|
824
|
-
} finally{
|
|
825
|
-
const index = this.pendingProvingJobs.indexOf(controller);
|
|
826
|
-
if (index > -1) {
|
|
827
|
-
this.pendingProvingJobs.splice(index, 1);
|
|
828
|
-
}
|
|
829
|
-
}
|
|
830
|
-
};
|
|
831
|
-
void this.deferredJobQueue.put(async ()=>{
|
|
832
|
-
void safeJob();
|
|
833
|
-
// we yield here to the macro task queue such to give Nodejs a chance to run other operatoins in between enqueues
|
|
834
|
-
await sleep(0);
|
|
835
|
-
});
|
|
836
|
-
}
|
|
837
763
|
async updateL1ToL2MessageTree(l1ToL2Messages, db) {
|
|
838
|
-
const l1ToL2MessagesPadded = padArrayEnd(l1ToL2Messages, Fr.ZERO, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP, 'Too many L1 to L2 messages');
|
|
839
764
|
const lastL1ToL2MessageTreeSnapshot = await getTreeSnapshot(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, db);
|
|
840
765
|
const lastL1ToL2MessageSubtreeRootSiblingPath = assertLength(await getSubtreeSiblingPath(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, L1_TO_L2_MSG_SUBTREE_HEIGHT, db), L1_TO_L2_MSG_SUBTREE_ROOT_SIBLING_PATH_LENGTH);
|
|
841
766
|
// Update the local trees to include the new l1 to l2 messages
|
|
842
|
-
await db
|
|
767
|
+
await appendL1ToL2MessagesToTree(db, l1ToL2Messages);
|
|
843
768
|
const newL1ToL2MessageTreeSnapshot = await getTreeSnapshot(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, db);
|
|
844
769
|
const newL1ToL2MessageSubtreeRootSiblingPath = assertLength(await getSubtreeSiblingPath(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, L1_TO_L2_MSG_SUBTREE_HEIGHT, db), L1_TO_L2_MSG_SUBTREE_ROOT_SIBLING_PATH_LENGTH);
|
|
845
770
|
return {
|
|
@@ -918,7 +843,6 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
918
843
|
}
|
|
919
844
|
const txProvingState = provingState.getTxProvingState(txIndex);
|
|
920
845
|
const txHash = txProvingState.processedTx.hash.toString();
|
|
921
|
-
NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH;
|
|
922
846
|
const handleResult = (result)=>{
|
|
923
847
|
this.logger.debug(`Got chonk verifier proof for tx index: ${txIndex}`, {
|
|
924
848
|
txHash
|
|
@@ -993,7 +917,11 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
993
917
|
return this.prover.getBlockRootRollupProof(inputs, signal, provingState.epochNumber);
|
|
994
918
|
}
|
|
995
919
|
}), async (result)=>{
|
|
996
|
-
this.logger.debug(`Completed ${rollupType} proof for block ${provingState.blockNumber}
|
|
920
|
+
this.logger.debug(`Completed ${rollupType} proof for block ${provingState.blockNumber}`, {
|
|
921
|
+
blockNumber: provingState.blockNumber,
|
|
922
|
+
checkpointIndex: provingState.parentCheckpoint.index,
|
|
923
|
+
...result.inputs.toInspect()
|
|
924
|
+
});
|
|
997
925
|
const leafLocation = provingState.setBlockRootRollupProof(result);
|
|
998
926
|
const checkpointProvingState = provingState.parentCheckpoint;
|
|
999
927
|
// Verification is called from both here and setBlockCompleted. Whichever runs last
|
|
@@ -1065,6 +993,11 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
1065
993
|
this.deferredProving(provingState, wrapCallbackInSpan(this.tracer, 'ProvingOrchestrator.prover.getBlockMergeRollupProof', {
|
|
1066
994
|
[Attributes.PROTOCOL_CIRCUIT_NAME]: 'rollup-block-merge'
|
|
1067
995
|
}, (signal)=>this.prover.getBlockMergeRollupProof(inputs, signal, provingState.epochNumber)), async (result)=>{
|
|
996
|
+
this.logger.debug(`Completed block merge rollup proof for checkpoint ${provingState.index}`, {
|
|
997
|
+
checkpointIndex: provingState.index,
|
|
998
|
+
mergeLocation: location,
|
|
999
|
+
...result.inputs.toInspect()
|
|
1000
|
+
});
|
|
1068
1001
|
provingState.setBlockMergeRollupProof(location, result);
|
|
1069
1002
|
await this.checkAndEnqueueNextBlockMergeRollup(provingState, location);
|
|
1070
1003
|
});
|
|
@@ -1097,7 +1030,10 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
1097
1030
|
provingState.reject(`Blob accumulator state mismatch.`);
|
|
1098
1031
|
return;
|
|
1099
1032
|
}
|
|
1100
|
-
this.logger.debug(`Completed ${rollupType} proof for checkpoint ${provingState.index}
|
|
1033
|
+
this.logger.debug(`Completed ${rollupType} proof for checkpoint ${provingState.index}`, {
|
|
1034
|
+
checkpointIndex: provingState.index,
|
|
1035
|
+
...result.inputs.toInspect()
|
|
1036
|
+
});
|
|
1101
1037
|
const leafLocation = provingState.setCheckpointRootRollupProof(result);
|
|
1102
1038
|
const epochProvingState = provingState.parentEpoch;
|
|
1103
1039
|
if (epochProvingState.totalNumCheckpoints === 1) {
|
|
@@ -1107,61 +1043,6 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
1107
1043
|
}
|
|
1108
1044
|
});
|
|
1109
1045
|
}
|
|
1110
|
-
enqueueCheckpointMergeRollup(provingState, location) {
|
|
1111
|
-
if (!provingState.verifyState()) {
|
|
1112
|
-
this.logger.debug('Not running checkpoint merge rollup. State no longer valid.');
|
|
1113
|
-
return;
|
|
1114
|
-
}
|
|
1115
|
-
if (!provingState.tryStartProvingCheckpointMerge(location)) {
|
|
1116
|
-
this.logger.debug('Checkpoint merge rollup already started.');
|
|
1117
|
-
return;
|
|
1118
|
-
}
|
|
1119
|
-
const inputs = provingState.getCheckpointMergeRollupInputs(location);
|
|
1120
|
-
this.deferredProving(provingState, wrapCallbackInSpan(this.tracer, 'ProvingOrchestrator.prover.getCheckpointMergeRollupProof', {
|
|
1121
|
-
[Attributes.PROTOCOL_CIRCUIT_NAME]: 'rollup-checkpoint-merge'
|
|
1122
|
-
}, (signal)=>this.prover.getCheckpointMergeRollupProof(inputs, signal, provingState.epochNumber)), (result)=>{
|
|
1123
|
-
this.logger.debug('Completed proof for checkpoint merge rollup.');
|
|
1124
|
-
provingState.setCheckpointMergeRollupProof(location, result);
|
|
1125
|
-
this.checkAndEnqueueNextCheckpointMergeRollup(provingState, location);
|
|
1126
|
-
});
|
|
1127
|
-
}
|
|
1128
|
-
enqueueEpochPadding(provingState) {
|
|
1129
|
-
if (!provingState.verifyState()) {
|
|
1130
|
-
this.logger.debug('Not running epoch padding. State no longer valid.');
|
|
1131
|
-
return;
|
|
1132
|
-
}
|
|
1133
|
-
if (!provingState.tryStartProvingPaddingCheckpoint()) {
|
|
1134
|
-
this.logger.debug('Padding checkpoint already started.');
|
|
1135
|
-
return;
|
|
1136
|
-
}
|
|
1137
|
-
this.logger.debug('Padding epoch proof with a padding block root proof.');
|
|
1138
|
-
const inputs = provingState.getPaddingCheckpointInputs();
|
|
1139
|
-
this.deferredProving(provingState, wrapCallbackInSpan(this.tracer, 'ProvingOrchestrator.prover.getCheckpointPaddingRollupProof', {
|
|
1140
|
-
[Attributes.PROTOCOL_CIRCUIT_NAME]: 'rollup-checkpoint-padding'
|
|
1141
|
-
}, (signal)=>this.prover.getCheckpointPaddingRollupProof(inputs, signal, provingState.epochNumber)), (result)=>{
|
|
1142
|
-
this.logger.debug('Completed proof for padding checkpoint.');
|
|
1143
|
-
provingState.setCheckpointPaddingProof(result);
|
|
1144
|
-
this.checkAndEnqueueRootRollup(provingState);
|
|
1145
|
-
});
|
|
1146
|
-
}
|
|
1147
|
-
// Executes the root rollup circuit
|
|
1148
|
-
enqueueRootRollup(provingState) {
|
|
1149
|
-
if (!provingState.verifyState()) {
|
|
1150
|
-
this.logger.debug('Not running root rollup, state no longer valid');
|
|
1151
|
-
return;
|
|
1152
|
-
}
|
|
1153
|
-
this.logger.debug(`Preparing root rollup`);
|
|
1154
|
-
const inputs = provingState.getRootRollupInputs();
|
|
1155
|
-
this.deferredProving(provingState, wrapCallbackInSpan(this.tracer, 'ProvingOrchestrator.prover.getRootRollupProof', {
|
|
1156
|
-
[Attributes.PROTOCOL_CIRCUIT_NAME]: 'rollup-root'
|
|
1157
|
-
}, (signal)=>this.prover.getRootRollupProof(inputs, signal, provingState.epochNumber)), (result)=>{
|
|
1158
|
-
this.logger.verbose(`Orchestrator completed root rollup for epoch ${provingState.epochNumber}`);
|
|
1159
|
-
provingState.setRootRollupProof(result);
|
|
1160
|
-
provingState.resolve({
|
|
1161
|
-
status: 'success'
|
|
1162
|
-
});
|
|
1163
|
-
});
|
|
1164
|
-
}
|
|
1165
1046
|
checkAndEnqueueNextMergeRollup(provingState, currentLocation) {
|
|
1166
1047
|
if (!provingState.isReadyForMergeRollup(currentLocation)) {
|
|
1167
1048
|
return;
|
|
@@ -1197,24 +1078,6 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
1197
1078
|
}
|
|
1198
1079
|
await this.enqueueCheckpointRootRollup(provingState);
|
|
1199
1080
|
}
|
|
1200
|
-
checkAndEnqueueNextCheckpointMergeRollup(provingState, currentLocation) {
|
|
1201
|
-
if (!provingState.isReadyForCheckpointMerge(currentLocation)) {
|
|
1202
|
-
return;
|
|
1203
|
-
}
|
|
1204
|
-
const parentLocation = provingState.getParentLocation(currentLocation);
|
|
1205
|
-
if (parentLocation.level === 0) {
|
|
1206
|
-
this.checkAndEnqueueRootRollup(provingState);
|
|
1207
|
-
} else {
|
|
1208
|
-
this.enqueueCheckpointMergeRollup(provingState, parentLocation);
|
|
1209
|
-
}
|
|
1210
|
-
}
|
|
1211
|
-
checkAndEnqueueRootRollup(provingState) {
|
|
1212
|
-
if (!provingState.isReadyForRootRollup()) {
|
|
1213
|
-
this.logger.debug('Not ready for root rollup');
|
|
1214
|
-
return;
|
|
1215
|
-
}
|
|
1216
|
-
this.enqueueRootRollup(provingState);
|
|
1217
|
-
}
|
|
1218
1081
|
/**
|
|
1219
1082
|
* Executes the VM circuit for a public function, will enqueue the corresponding kernel if the
|
|
1220
1083
|
* previous kernel is ready
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { type Logger, type LoggerBindings } from '@aztec/foundation/log';
|
|
2
|
+
/**
|
|
3
|
+
* Minimal surface a deferred-proving state must expose. Both `EpochProvingState` /
|
|
4
|
+
* `CheckpointProvingState` / `BlockProvingState` (used by `ProvingOrchestrator`) and
|
|
5
|
+
* `TopTreeProvingState` (used by `TopTreeOrchestrator`) satisfy it.
|
|
6
|
+
*/
|
|
7
|
+
export interface ProvingStateLike {
|
|
8
|
+
/** Returns false once the state has been cancelled or otherwise invalidated. */
|
|
9
|
+
verifyState(): boolean;
|
|
10
|
+
/** Surfaces a proving error to the state's owner. */
|
|
11
|
+
reject(reason: string): void;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Common scheduling infrastructure shared by every orchestrator that drives broker
|
|
15
|
+
* proving jobs:
|
|
16
|
+
*
|
|
17
|
+
* - One `SerialQueue` (`deferredJobQueue`) acting as the enqueue-throttle.
|
|
18
|
+
* - A list of `AbortController`s (`pendingProvingJobs`) so a `cancel()` can abort
|
|
19
|
+
* in-flight broker jobs when needed.
|
|
20
|
+
* - A `deferredProving<T>(state, request, callback, isCancelled?)` method that wraps
|
|
21
|
+
* a broker request in the standard "submit, drop result if state invalidated, push
|
|
22
|
+
* errors to state.reject" envelope.
|
|
23
|
+
*
|
|
24
|
+
* Subclasses own their own concrete proving state and define `cancelInternal()` for
|
|
25
|
+
* the rest of the cleanup work (closing world-state forks, marking sub-trees
|
|
26
|
+
* cancelled, etc.). `stop()` lives on the base class and follows the standard pattern
|
|
27
|
+
* of grabbing the old queue, calling `cancelInternal()` (which recreates the queue),
|
|
28
|
+
* and awaiting the old queue's drain.
|
|
29
|
+
*/
|
|
30
|
+
export declare abstract class ProvingScheduler {
|
|
31
|
+
private readonly enqueueConcurrency;
|
|
32
|
+
protected pendingProvingJobs: AbortController[];
|
|
33
|
+
protected logger: Logger;
|
|
34
|
+
private deferredJobQueue;
|
|
35
|
+
constructor(enqueueConcurrency: number, loggerName?: string, bindings?: LoggerBindings);
|
|
36
|
+
/** Number of broker jobs currently in flight. */
|
|
37
|
+
getNumPendingProvingJobs(): number;
|
|
38
|
+
/**
|
|
39
|
+
* Drains the deferred-job queue, recreates it (so the subclass can be reused), and
|
|
40
|
+
* optionally aborts every in-flight broker job. Aborting is the right choice on
|
|
41
|
+
* reorg-driven cancel (where the in-flight inputs are no longer valid) and the
|
|
42
|
+
* wrong choice on shutdown (where leaving jobs in the broker queue lets a restart
|
|
43
|
+
* pick them up).
|
|
44
|
+
*/
|
|
45
|
+
protected resetSchedulerState(abortJobs: boolean): void;
|
|
46
|
+
/**
|
|
47
|
+
* Subclass-defined cancellation. Implementations call `resetSchedulerState(...)`
|
|
48
|
+
* and then do their own cleanup (close world-state forks, propagate cancel into
|
|
49
|
+
* the proving state, etc.).
|
|
50
|
+
*/
|
|
51
|
+
protected abstract cancelInternal(): void;
|
|
52
|
+
/**
|
|
53
|
+
* Standard stop: grab the old queue, cancel (which recreates the queue), then
|
|
54
|
+
* await the old queue's drain so any final job tear-down has unwound before we
|
|
55
|
+
* return.
|
|
56
|
+
*/
|
|
57
|
+
stop(): Promise<void>;
|
|
58
|
+
/**
|
|
59
|
+
* Submits a broker request. The returned-via-callback result is dropped if the
|
|
60
|
+
* state has become invalid (re-org, cancellation) by the time it lands. Errors
|
|
61
|
+
* are routed to `state.reject` unless they are abort-driven or the state is
|
|
62
|
+
* already invalid (in which case they're a stale echo of the cancel).
|
|
63
|
+
*
|
|
64
|
+
* @param state - Object exposing `verifyState()` and `reject()`.
|
|
65
|
+
* @param request - The broker call. Receives the controller's signal.
|
|
66
|
+
* @param callback - Runs on success, after `verifyState()` is checked.
|
|
67
|
+
* @param isCancelled - Optional extra cancellation predicate (e.g. a `cancelled`
|
|
68
|
+
* flag the subclass maintains independently of the state). Defaults to never.
|
|
69
|
+
*/
|
|
70
|
+
protected deferredProving<S extends ProvingStateLike, T>(state: S, request: (signal: AbortSignal) => Promise<T>, callback: (result: T) => void | Promise<void>, isCancelled?: () => boolean): void;
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=data:application/json;base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AI,MAAM,CAExC;IAED;;;;;;OAMG;IACH,SAAS,CAAC,mBAAmB,CAAC,SAAS,EAAE,OAAO,GAAG,IAAI,CAStD;IAED;;;;OAIG;IACH,SAAS,CAAC,QAAQ,CAAC,cAAc,IAAI,IAAI,CAAC;IAE1C;;;;OAIG;IACU,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAIjC;IAED;;;;;;;;;;;OAWG;IACH,SAAS,CAAC,eAAe,CAAC,CAAC,SAAS,gBAAgB,EAAE,CAAC,EACrD,KAAK,EAAE,CAAC,EACR,OAAO,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,OAAO,CAAC,CAAC,CAAC,EAC5C,QAAQ,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,EAC7C,WAAW,GAAE,MAAM,OAAqB,GACvC,IAAI,CA+CN;CACF"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { AbortError } from '@aztec/foundation/error';
|
|
2
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
3
|
+
import { SerialQueue } from '@aztec/foundation/queue';
|
|
4
|
+
import { sleep } from '@aztec/foundation/sleep';
|
|
5
|
+
/**
|
|
6
|
+
* Common scheduling infrastructure shared by every orchestrator that drives broker
|
|
7
|
+
* proving jobs:
|
|
8
|
+
*
|
|
9
|
+
* - One `SerialQueue` (`deferredJobQueue`) acting as the enqueue-throttle.
|
|
10
|
+
* - A list of `AbortController`s (`pendingProvingJobs`) so a `cancel()` can abort
|
|
11
|
+
* in-flight broker jobs when needed.
|
|
12
|
+
* - A `deferredProving<T>(state, request, callback, isCancelled?)` method that wraps
|
|
13
|
+
* a broker request in the standard "submit, drop result if state invalidated, push
|
|
14
|
+
* errors to state.reject" envelope.
|
|
15
|
+
*
|
|
16
|
+
* Subclasses own their own concrete proving state and define `cancelInternal()` for
|
|
17
|
+
* the rest of the cleanup work (closing world-state forks, marking sub-trees
|
|
18
|
+
* cancelled, etc.). `stop()` lives on the base class and follows the standard pattern
|
|
19
|
+
* of grabbing the old queue, calling `cancelInternal()` (which recreates the queue),
|
|
20
|
+
* and awaiting the old queue's drain.
|
|
21
|
+
*/ export class ProvingScheduler {
|
|
22
|
+
enqueueConcurrency;
|
|
23
|
+
pendingProvingJobs;
|
|
24
|
+
logger;
|
|
25
|
+
deferredJobQueue;
|
|
26
|
+
constructor(enqueueConcurrency, loggerName = 'prover-client:proving-scheduler', bindings){
|
|
27
|
+
this.enqueueConcurrency = enqueueConcurrency;
|
|
28
|
+
this.pendingProvingJobs = [];
|
|
29
|
+
this.logger = createLogger(loggerName, bindings);
|
|
30
|
+
this.deferredJobQueue = new SerialQueue();
|
|
31
|
+
this.deferredJobQueue.start(this.enqueueConcurrency);
|
|
32
|
+
}
|
|
33
|
+
/** Number of broker jobs currently in flight. */ getNumPendingProvingJobs() {
|
|
34
|
+
return this.pendingProvingJobs.length;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Drains the deferred-job queue, recreates it (so the subclass can be reused), and
|
|
38
|
+
* optionally aborts every in-flight broker job. Aborting is the right choice on
|
|
39
|
+
* reorg-driven cancel (where the in-flight inputs are no longer valid) and the
|
|
40
|
+
* wrong choice on shutdown (where leaving jobs in the broker queue lets a restart
|
|
41
|
+
* pick them up).
|
|
42
|
+
*/ resetSchedulerState(abortJobs) {
|
|
43
|
+
void this.deferredJobQueue.cancel();
|
|
44
|
+
this.deferredJobQueue = new SerialQueue();
|
|
45
|
+
this.deferredJobQueue.start(this.enqueueConcurrency);
|
|
46
|
+
if (abortJobs) {
|
|
47
|
+
for (const controller of this.pendingProvingJobs){
|
|
48
|
+
controller.abort();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Standard stop: grab the old queue, cancel (which recreates the queue), then
|
|
54
|
+
* await the old queue's drain so any final job tear-down has unwound before we
|
|
55
|
+
* return.
|
|
56
|
+
*/ async stop() {
|
|
57
|
+
const oldQueue = this.deferredJobQueue;
|
|
58
|
+
this.cancelInternal();
|
|
59
|
+
await oldQueue.cancel();
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Submits a broker request. The returned-via-callback result is dropped if the
|
|
63
|
+
* state has become invalid (re-org, cancellation) by the time it lands. Errors
|
|
64
|
+
* are routed to `state.reject` unless they are abort-driven or the state is
|
|
65
|
+
* already invalid (in which case they're a stale echo of the cancel).
|
|
66
|
+
*
|
|
67
|
+
* @param state - Object exposing `verifyState()` and `reject()`.
|
|
68
|
+
* @param request - The broker call. Receives the controller's signal.
|
|
69
|
+
* @param callback - Runs on success, after `verifyState()` is checked.
|
|
70
|
+
* @param isCancelled - Optional extra cancellation predicate (e.g. a `cancelled`
|
|
71
|
+
* flag the subclass maintains independently of the state). Defaults to never.
|
|
72
|
+
*/ deferredProving(state, request, callback, isCancelled = ()=>false) {
|
|
73
|
+
if (!state.verifyState()) {
|
|
74
|
+
this.logger.debug(`Not enqueuing job, state no longer valid`);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const controller = new AbortController();
|
|
78
|
+
this.pendingProvingJobs.push(controller);
|
|
79
|
+
// We use a 'safeJob'. We don't want promise rejections in the proving pool — we
|
|
80
|
+
// want to capture the error here and reject the proving state while keeping the
|
|
81
|
+
// event loop free of rejections.
|
|
82
|
+
const safeJob = async ()=>{
|
|
83
|
+
try {
|
|
84
|
+
if (controller.signal.aborted) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
const result = await request(controller.signal);
|
|
88
|
+
if (controller.signal.aborted || !state.verifyState() || isCancelled()) {
|
|
89
|
+
this.logger.debug(`State no longer valid, discarding result`);
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
await callback(result);
|
|
93
|
+
} catch (err) {
|
|
94
|
+
if (err instanceof AbortError || isCancelled()) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
if (!state.verifyState()) {
|
|
98
|
+
this.logger.debug(`State no longer valid, discarding error from proving job`, err);
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
this.logger.error(`Error thrown when proving job`, err);
|
|
102
|
+
state.reject(`${err}`);
|
|
103
|
+
} finally{
|
|
104
|
+
const idx = this.pendingProvingJobs.indexOf(controller);
|
|
105
|
+
if (idx > -1) {
|
|
106
|
+
this.pendingProvingJobs.splice(idx, 1);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
void this.deferredJobQueue.put(async ()=>{
|
|
111
|
+
void safeJob();
|
|
112
|
+
// Yield to the macrotask queue so Node has a chance to interleave other work
|
|
113
|
+
// between enqueues.
|
|
114
|
+
await sleep(0);
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { type FinalBlobBatchingChallenges } from '@aztec/blob-lib';
|
|
2
|
+
import type { BatchedBlob } from '@aztec/blob-lib/types';
|
|
3
|
+
import { type ARCHIVE_HEIGHT, type NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH } from '@aztec/constants';
|
|
4
|
+
import type { EpochNumber } from '@aztec/foundation/branded-types';
|
|
5
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
6
|
+
import type { LoggerBindings } from '@aztec/foundation/log';
|
|
7
|
+
import type { Tuple } from '@aztec/foundation/serialize';
|
|
8
|
+
import type { EthAddress } from '@aztec/stdlib/block';
|
|
9
|
+
import type { PublicInputsAndRecursiveProof, ServerCircuitProver } from '@aztec/stdlib/interfaces/server';
|
|
10
|
+
import type { Proof } from '@aztec/stdlib/proofs';
|
|
11
|
+
import { type BlockRollupPublicInputs, type RootRollupPublicInputs } from '@aztec/stdlib/rollup';
|
|
12
|
+
import type { BlockHeader } from '@aztec/stdlib/tx';
|
|
13
|
+
import { type TelemetryClient } from '@aztec/telemetry-client';
|
|
14
|
+
import { TopTreeProvingScheduler } from './top-tree-proving-scheduler.js';
|
|
15
|
+
import { TopTreeProvingState } from './top-tree-proving-state.js';
|
|
16
|
+
/** Per-checkpoint data fed into the top tree. */
|
|
17
|
+
export type CheckpointTopTreeData = {
|
|
18
|
+
/**
|
|
19
|
+
* Block-rollup proof outputs from the checkpoint's sub-tree. Passed as a Promise so the
|
|
20
|
+
* top tree can start (compute hints, pipeline merges) while sub-trees are still proving.
|
|
21
|
+
* The promise resolves to 1 entry for a single-block checkpoint, 2 for multi-block.
|
|
22
|
+
*/
|
|
23
|
+
blockProofs: Promise<PublicInputsAndRecursiveProof<BlockRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>[]>;
|
|
24
|
+
/** L2-to-L1 messages per block in the checkpoint, used to compute the out hash. */
|
|
25
|
+
l2ToL1MsgsPerBlock: Fr[][][];
|
|
26
|
+
/** Blob fields encoding the checkpoint's tx effects, used to compute the blob accumulator. */
|
|
27
|
+
blobFields: Fr[];
|
|
28
|
+
/** Header of the last block in the previous checkpoint (or the epoch's predecessor for index 0). */
|
|
29
|
+
previousBlockHeader: BlockHeader;
|
|
30
|
+
/** Sibling path of the archive tree before any block in this checkpoint landed. */
|
|
31
|
+
previousArchiveSiblingPath: Tuple<Fr, typeof ARCHIVE_HEIGHT>;
|
|
32
|
+
};
|
|
33
|
+
/** Result of proving the top tree. */
|
|
34
|
+
export type TopTreeResult = {
|
|
35
|
+
publicInputs: RootRollupPublicInputs;
|
|
36
|
+
proof: Proof;
|
|
37
|
+
batchedBlobInputs: BatchedBlob;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Sentinel thrown by `cancel` so callers can distinguish reorg-driven cancellation from
|
|
41
|
+
* a genuine proving failure (and choose to rebuild + retry instead of failing the epoch).
|
|
42
|
+
*/
|
|
43
|
+
export declare class TopTreeCancelledError extends Error {
|
|
44
|
+
constructor(reason?: string);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Drives proving from checkpoint root rollups through the epoch root rollup. Owns no
|
|
48
|
+
* world-state forks or tx processing — every input is supplied by the caller.
|
|
49
|
+
*
|
|
50
|
+
* Pipelined start: `prove()` does not wait for block-level proving. It pre-computes the
|
|
51
|
+
* out-hash and blob-accumulator hint chains immediately from archiver-derivable data,
|
|
52
|
+
* and each checkpoint's root rollup fires the moment its sub-tree's `blockProofs`
|
|
53
|
+
* promise resolves. Later checkpoints can still be block-level proving in parallel.
|
|
54
|
+
*/
|
|
55
|
+
export declare class TopTreeOrchestrator extends TopTreeProvingScheduler {
|
|
56
|
+
private readonly proverId;
|
|
57
|
+
private state;
|
|
58
|
+
private cancelled;
|
|
59
|
+
constructor(prover: ServerCircuitProver, proverId: EthAddress, enqueueConcurrency: number, _telemetryClient?: TelemetryClient, bindings?: LoggerBindings);
|
|
60
|
+
getProverId(): EthAddress;
|
|
61
|
+
/**
|
|
62
|
+
* Proves the top tree from per-checkpoint data and pending block-proofs promises.
|
|
63
|
+
* Resolves with the final epoch proof, or rejects with `TopTreeCancelledError` if
|
|
64
|
+
* `cancel()` is invoked, or any other error if a circuit fails.
|
|
65
|
+
*/
|
|
66
|
+
prove(epochNumber: EpochNumber, totalNumCheckpoints: number, finalBlobBatchingChallenges: FinalBlobBatchingChallenges, checkpointData: CheckpointTopTreeData[]): Promise<TopTreeResult>;
|
|
67
|
+
/**
|
|
68
|
+
* Cancels in-flight proving. If `abortJobs` is true, each pending broker job is aborted
|
|
69
|
+
* (used on reorg, when the surviving checkpoint set differs and the in-flight jobs'
|
|
70
|
+
* inputs are no longer valid). On shutdown the caller passes `false` so jobs remain in
|
|
71
|
+
* the broker queue for reuse on restart.
|
|
72
|
+
*/
|
|
73
|
+
cancel({ abortJobs }: {
|
|
74
|
+
abortJobs: boolean;
|
|
75
|
+
}): void;
|
|
76
|
+
/** Standard shutdown — preserve the broker queue (`abortJobs: false`). */
|
|
77
|
+
protected cancelInternal(): void;
|
|
78
|
+
protected onRootRollupComplete(state: TopTreeProvingState): void;
|
|
79
|
+
private enqueueCheckpointRoot;
|
|
80
|
+
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