@aztec/prover-client 0.0.1-commit.7b97ef96e → 0.0.1-commit.7cbc774
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 +6 -2
- package/dest/light/lightweight_checkpoint_builder.d.ts.map +1 -1
- package/dest/light/lightweight_checkpoint_builder.js +40 -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 +14 -8
- 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 +15 -25
- package/dest/orchestrator/orchestrator.d.ts.map +1 -1
- package/dest/orchestrator/orchestrator.js +33 -154
- 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 +62 -3
- package/dest/prover-client/prover-client.d.ts.map +1 -1
- package/dest/prover-client/prover-client.js +50 -2
- 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 +13 -19
- 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 +39 -10
- package/dest/proving_broker/proving_broker_database/persisted.js +2 -2
- package/dest/proving_broker/proving_broker_instrumentation.d.ts +3 -1
- package/dest/proving_broker/proving_broker_instrumentation.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker_instrumentation.js +7 -0
- package/dest/proving_broker/rpc.d.ts +3 -1
- package/dest/proving_broker/rpc.d.ts.map +1 -1
- package/dest/proving_broker/rpc.js +80 -24
- package/dest/test/mock_prover.d.ts +3 -3
- package/package.json +18 -19
- package/src/config.ts +18 -2
- package/src/light/lightweight_checkpoint_builder.ts +46 -20
- package/src/mocks/test_context.ts +12 -9
- 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 -210
- 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 +127 -2
- package/src/proving_broker/broker_prover_facade.ts +17 -20
- package/src/proving_broker/config.ts +3 -2
- package/src/proving_broker/index.ts +1 -0
- package/src/proving_broker/proving_broker.ts +34 -7
- package/src/proving_broker/proving_broker_database/persisted.ts +2 -2
- package/src/proving_broker/proving_broker_instrumentation.ts +9 -0
- package/src/proving_broker/rpc.ts +36 -24
|
@@ -371,16 +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
377
|
import { assertLength } from '@aztec/foundation/serialize';
|
|
382
378
|
import { pushTestData } from '@aztec/foundation/testing';
|
|
383
379
|
import { elapsed } from '@aztec/foundation/timer';
|
|
380
|
+
import { appendL1ToL2MessagesToTree } from '@aztec/stdlib/messaging';
|
|
384
381
|
import { BlockRootEmptyTxFirstRollupPrivateInputs, BlockRootFirstRollupPrivateInputs, BlockRootSingleTxFirstRollupPrivateInputs, BlockRootSingleTxRollupPrivateInputs, CheckpointRootSingleBlockRollupPrivateInputs, PrivateTxBaseRollupPrivateInputs } from '@aztec/stdlib/rollup';
|
|
385
382
|
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
386
383
|
import { Attributes, getTelemetryClient, trackSpan, wrapCallbackInSpan } from '@aztec/telemetry-client';
|
|
@@ -388,6 +385,7 @@ import { inspect } from 'util';
|
|
|
388
385
|
import { buildHeaderFromCircuitOutputs, getLastSiblingPath, getPublicChonkVerifierPrivateInputsFromTx, getRootTreeSiblingPath, getSubtreeSiblingPath, getTreeSnapshot, insertSideEffectsAndBuildBaseRollupHints, validatePartialState, validateTx } from './block-building-helpers.js';
|
|
389
386
|
import { EpochProvingState } from './epoch-proving-state.js';
|
|
390
387
|
import { ProvingOrchestratorMetrics } from './orchestrator_metrics.js';
|
|
388
|
+
import { TopTreeProvingScheduler } from './top-tree-proving-scheduler.js';
|
|
391
389
|
import { TxProvingState } from './tx-proving-state.js';
|
|
392
390
|
_dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
393
391
|
[Attributes.BLOCK_NUMBER]: blockNumber
|
|
@@ -409,9 +407,8 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
409
407
|
* The proving implementation is determined by the provided prover. This could be for example a local prover or a remote prover pool.
|
|
410
408
|
*/ /**
|
|
411
409
|
* The orchestrator, managing the flow of recursive proving operations required to build the rollup proof tree.
|
|
412
|
-
*/ export class ProvingOrchestrator {
|
|
410
|
+
*/ export class ProvingOrchestrator extends TopTreeProvingScheduler {
|
|
413
411
|
dbProvider;
|
|
414
|
-
prover;
|
|
415
412
|
proverId;
|
|
416
413
|
cancelJobsOnStop;
|
|
417
414
|
static{
|
|
@@ -444,22 +441,11 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
444
441
|
], []));
|
|
445
442
|
}
|
|
446
443
|
provingState;
|
|
447
|
-
pendingProvingJobs;
|
|
448
444
|
provingPromise;
|
|
449
445
|
metrics;
|
|
450
|
-
// eslint-disable-next-line aztec-custom/no-non-primitive-in-collections
|
|
451
446
|
dbs;
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
this.dbProvider = dbProvider;
|
|
455
|
-
this.prover = prover;
|
|
456
|
-
this.proverId = proverId;
|
|
457
|
-
this.cancelJobsOnStop = cancelJobsOnStop;
|
|
458
|
-
this.provingState = (_initProto(this), undefined);
|
|
459
|
-
this.pendingProvingJobs = [];
|
|
460
|
-
this.provingPromise = undefined;
|
|
461
|
-
this.dbs = new Map();
|
|
462
|
-
this.logger = createLogger('prover-client:orchestrator', bindings);
|
|
447
|
+
constructor(dbProvider, prover, proverId, cancelJobsOnStop = false, enqueueConcurrency, telemetryClient = getTelemetryClient(), 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();
|
|
463
449
|
this.metrics = new ProvingOrchestratorMetrics(telemetryClient, 'ProvingOrchestrator');
|
|
464
450
|
}
|
|
465
451
|
get tracer() {
|
|
@@ -471,9 +457,18 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
471
457
|
getNumActiveForks() {
|
|
472
458
|
return this.dbs.size;
|
|
473
459
|
}
|
|
474
|
-
|
|
460
|
+
cancelInternal() {
|
|
475
461
|
this.cancel();
|
|
476
|
-
|
|
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
|
+
});
|
|
477
472
|
}
|
|
478
473
|
startNewEpoch(epochNumber, totalNumCheckpoints, finalBlobBatchingChallenges) {
|
|
479
474
|
if (this.provingState?.verifyState()) {
|
|
@@ -733,11 +728,7 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
733
728
|
* If cancelJobsOnStop is true, aborts all pending jobs with the broker (which marks them as 'Aborted').
|
|
734
729
|
* If cancelJobsOnStop is false (default), jobs remain in the broker queue and can be reused on restart/reorg.
|
|
735
730
|
*/ cancel() {
|
|
736
|
-
|
|
737
|
-
for (const controller of this.pendingProvingJobs){
|
|
738
|
-
controller.abort();
|
|
739
|
-
}
|
|
740
|
-
}
|
|
731
|
+
this.resetSchedulerState(this.cancelJobsOnStop);
|
|
741
732
|
this.provingState?.cancel();
|
|
742
733
|
for (const [blockNumber, db] of this.dbs.entries()){
|
|
743
734
|
void db.close().catch((err)=>this.logger.error(`Error closing db for block ${blockNumber}`, err));
|
|
@@ -769,61 +760,11 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
769
760
|
});
|
|
770
761
|
return epochProofResult;
|
|
771
762
|
}
|
|
772
|
-
/**
|
|
773
|
-
* Enqueue a job to be scheduled
|
|
774
|
-
* @param provingState - The proving state object being operated on
|
|
775
|
-
* @param jobType - The type of job to be queued
|
|
776
|
-
* @param job - The actual job, returns a promise notifying of the job's completion
|
|
777
|
-
*/ deferredProving(provingState, request, callback) {
|
|
778
|
-
if (!provingState.verifyState()) {
|
|
779
|
-
this.logger.debug(`Not enqueuing job, state no longer valid`);
|
|
780
|
-
return;
|
|
781
|
-
}
|
|
782
|
-
const controller = new AbortController();
|
|
783
|
-
this.pendingProvingJobs.push(controller);
|
|
784
|
-
// We use a 'safeJob'. We don't want promise rejections in the proving pool, we want to capture the error here
|
|
785
|
-
// and reject the proving job whilst keeping the event loop free of rejections
|
|
786
|
-
const safeJob = async ()=>{
|
|
787
|
-
try {
|
|
788
|
-
// there's a delay between enqueueing this job and it actually running
|
|
789
|
-
if (controller.signal.aborted) {
|
|
790
|
-
return;
|
|
791
|
-
}
|
|
792
|
-
const result = await request(controller.signal);
|
|
793
|
-
if (!provingState.verifyState()) {
|
|
794
|
-
this.logger.debug(`State no longer valid, discarding result`);
|
|
795
|
-
return;
|
|
796
|
-
}
|
|
797
|
-
// we could have been cancelled whilst waiting for the result
|
|
798
|
-
// and the prover ignored the signal. Drop the result in that case
|
|
799
|
-
if (controller.signal.aborted) {
|
|
800
|
-
return;
|
|
801
|
-
}
|
|
802
|
-
await callback(result);
|
|
803
|
-
} catch (err) {
|
|
804
|
-
if (err instanceof AbortError) {
|
|
805
|
-
// operation was cancelled, probably because the block was cancelled
|
|
806
|
-
// drop this result
|
|
807
|
-
return;
|
|
808
|
-
}
|
|
809
|
-
this.logger.error(`Error thrown when proving job`, err);
|
|
810
|
-
provingState.reject(`${err}`);
|
|
811
|
-
} finally{
|
|
812
|
-
const index = this.pendingProvingJobs.indexOf(controller);
|
|
813
|
-
if (index > -1) {
|
|
814
|
-
this.pendingProvingJobs.splice(index, 1);
|
|
815
|
-
}
|
|
816
|
-
}
|
|
817
|
-
};
|
|
818
|
-
// let the callstack unwind before adding the job to the queue
|
|
819
|
-
setImmediate(()=>void safeJob());
|
|
820
|
-
}
|
|
821
763
|
async updateL1ToL2MessageTree(l1ToL2Messages, db) {
|
|
822
|
-
const l1ToL2MessagesPadded = padArrayEnd(l1ToL2Messages, Fr.ZERO, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP, 'Too many L1 to L2 messages');
|
|
823
764
|
const lastL1ToL2MessageTreeSnapshot = await getTreeSnapshot(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, db);
|
|
824
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);
|
|
825
766
|
// Update the local trees to include the new l1 to l2 messages
|
|
826
|
-
await db
|
|
767
|
+
await appendL1ToL2MessagesToTree(db, l1ToL2Messages);
|
|
827
768
|
const newL1ToL2MessageTreeSnapshot = await getTreeSnapshot(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, db);
|
|
828
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);
|
|
829
770
|
return {
|
|
@@ -902,7 +843,6 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
902
843
|
}
|
|
903
844
|
const txProvingState = provingState.getTxProvingState(txIndex);
|
|
904
845
|
const txHash = txProvingState.processedTx.hash.toString();
|
|
905
|
-
NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH;
|
|
906
846
|
const handleResult = (result)=>{
|
|
907
847
|
this.logger.debug(`Got chonk verifier proof for tx index: ${txIndex}`, {
|
|
908
848
|
txHash
|
|
@@ -977,7 +917,11 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
977
917
|
return this.prover.getBlockRootRollupProof(inputs, signal, provingState.epochNumber);
|
|
978
918
|
}
|
|
979
919
|
}), async (result)=>{
|
|
980
|
-
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
|
+
});
|
|
981
925
|
const leafLocation = provingState.setBlockRootRollupProof(result);
|
|
982
926
|
const checkpointProvingState = provingState.parentCheckpoint;
|
|
983
927
|
// Verification is called from both here and setBlockCompleted. Whichever runs last
|
|
@@ -1049,6 +993,11 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
1049
993
|
this.deferredProving(provingState, wrapCallbackInSpan(this.tracer, 'ProvingOrchestrator.prover.getBlockMergeRollupProof', {
|
|
1050
994
|
[Attributes.PROTOCOL_CIRCUIT_NAME]: 'rollup-block-merge'
|
|
1051
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
|
+
});
|
|
1052
1001
|
provingState.setBlockMergeRollupProof(location, result);
|
|
1053
1002
|
await this.checkAndEnqueueNextBlockMergeRollup(provingState, location);
|
|
1054
1003
|
});
|
|
@@ -1081,7 +1030,10 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
1081
1030
|
provingState.reject(`Blob accumulator state mismatch.`);
|
|
1082
1031
|
return;
|
|
1083
1032
|
}
|
|
1084
|
-
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
|
+
});
|
|
1085
1037
|
const leafLocation = provingState.setCheckpointRootRollupProof(result);
|
|
1086
1038
|
const epochProvingState = provingState.parentEpoch;
|
|
1087
1039
|
if (epochProvingState.totalNumCheckpoints === 1) {
|
|
@@ -1091,61 +1043,6 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
1091
1043
|
}
|
|
1092
1044
|
});
|
|
1093
1045
|
}
|
|
1094
|
-
enqueueCheckpointMergeRollup(provingState, location) {
|
|
1095
|
-
if (!provingState.verifyState()) {
|
|
1096
|
-
this.logger.debug('Not running checkpoint merge rollup. State no longer valid.');
|
|
1097
|
-
return;
|
|
1098
|
-
}
|
|
1099
|
-
if (!provingState.tryStartProvingCheckpointMerge(location)) {
|
|
1100
|
-
this.logger.debug('Checkpoint merge rollup already started.');
|
|
1101
|
-
return;
|
|
1102
|
-
}
|
|
1103
|
-
const inputs = provingState.getCheckpointMergeRollupInputs(location);
|
|
1104
|
-
this.deferredProving(provingState, wrapCallbackInSpan(this.tracer, 'ProvingOrchestrator.prover.getCheckpointMergeRollupProof', {
|
|
1105
|
-
[Attributes.PROTOCOL_CIRCUIT_NAME]: 'rollup-checkpoint-merge'
|
|
1106
|
-
}, (signal)=>this.prover.getCheckpointMergeRollupProof(inputs, signal, provingState.epochNumber)), (result)=>{
|
|
1107
|
-
this.logger.debug('Completed proof for checkpoint merge rollup.');
|
|
1108
|
-
provingState.setCheckpointMergeRollupProof(location, result);
|
|
1109
|
-
this.checkAndEnqueueNextCheckpointMergeRollup(provingState, location);
|
|
1110
|
-
});
|
|
1111
|
-
}
|
|
1112
|
-
enqueueEpochPadding(provingState) {
|
|
1113
|
-
if (!provingState.verifyState()) {
|
|
1114
|
-
this.logger.debug('Not running epoch padding. State no longer valid.');
|
|
1115
|
-
return;
|
|
1116
|
-
}
|
|
1117
|
-
if (!provingState.tryStartProvingPaddingCheckpoint()) {
|
|
1118
|
-
this.logger.debug('Padding checkpoint already started.');
|
|
1119
|
-
return;
|
|
1120
|
-
}
|
|
1121
|
-
this.logger.debug('Padding epoch proof with a padding block root proof.');
|
|
1122
|
-
const inputs = provingState.getPaddingCheckpointInputs();
|
|
1123
|
-
this.deferredProving(provingState, wrapCallbackInSpan(this.tracer, 'ProvingOrchestrator.prover.getCheckpointPaddingRollupProof', {
|
|
1124
|
-
[Attributes.PROTOCOL_CIRCUIT_NAME]: 'rollup-checkpoint-padding'
|
|
1125
|
-
}, (signal)=>this.prover.getCheckpointPaddingRollupProof(inputs, signal, provingState.epochNumber)), (result)=>{
|
|
1126
|
-
this.logger.debug('Completed proof for padding checkpoint.');
|
|
1127
|
-
provingState.setCheckpointPaddingProof(result);
|
|
1128
|
-
this.checkAndEnqueueRootRollup(provingState);
|
|
1129
|
-
});
|
|
1130
|
-
}
|
|
1131
|
-
// Executes the root rollup circuit
|
|
1132
|
-
enqueueRootRollup(provingState) {
|
|
1133
|
-
if (!provingState.verifyState()) {
|
|
1134
|
-
this.logger.debug('Not running root rollup, state no longer valid');
|
|
1135
|
-
return;
|
|
1136
|
-
}
|
|
1137
|
-
this.logger.debug(`Preparing root rollup`);
|
|
1138
|
-
const inputs = provingState.getRootRollupInputs();
|
|
1139
|
-
this.deferredProving(provingState, wrapCallbackInSpan(this.tracer, 'ProvingOrchestrator.prover.getRootRollupProof', {
|
|
1140
|
-
[Attributes.PROTOCOL_CIRCUIT_NAME]: 'rollup-root'
|
|
1141
|
-
}, (signal)=>this.prover.getRootRollupProof(inputs, signal, provingState.epochNumber)), (result)=>{
|
|
1142
|
-
this.logger.verbose(`Orchestrator completed root rollup for epoch ${provingState.epochNumber}`);
|
|
1143
|
-
provingState.setRootRollupProof(result);
|
|
1144
|
-
provingState.resolve({
|
|
1145
|
-
status: 'success'
|
|
1146
|
-
});
|
|
1147
|
-
});
|
|
1148
|
-
}
|
|
1149
1046
|
checkAndEnqueueNextMergeRollup(provingState, currentLocation) {
|
|
1150
1047
|
if (!provingState.isReadyForMergeRollup(currentLocation)) {
|
|
1151
1048
|
return;
|
|
@@ -1181,24 +1078,6 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
1181
1078
|
}
|
|
1182
1079
|
await this.enqueueCheckpointRootRollup(provingState);
|
|
1183
1080
|
}
|
|
1184
|
-
checkAndEnqueueNextCheckpointMergeRollup(provingState, currentLocation) {
|
|
1185
|
-
if (!provingState.isReadyForCheckpointMerge(currentLocation)) {
|
|
1186
|
-
return;
|
|
1187
|
-
}
|
|
1188
|
-
const parentLocation = provingState.getParentLocation(currentLocation);
|
|
1189
|
-
if (parentLocation.level === 0) {
|
|
1190
|
-
this.checkAndEnqueueRootRollup(provingState);
|
|
1191
|
-
} else {
|
|
1192
|
-
this.enqueueCheckpointMergeRollup(provingState, parentLocation);
|
|
1193
|
-
}
|
|
1194
|
-
}
|
|
1195
|
-
checkAndEnqueueRootRollup(provingState) {
|
|
1196
|
-
if (!provingState.isReadyForRootRollup()) {
|
|
1197
|
-
this.logger.debug('Not ready for root rollup');
|
|
1198
|
-
return;
|
|
1199
|
-
}
|
|
1200
|
-
this.enqueueRootRollup(provingState);
|
|
1201
|
-
}
|
|
1202
1081
|
/**
|
|
1203
1082
|
* Executes the VM circuit for a public function, will enqueue the corresponding kernel if the
|
|
1204
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;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJvdmluZy1zY2hlZHVsZXIuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9vcmNoZXN0cmF0b3IvcHJvdmluZy1zY2hlZHVsZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsT0FBTyxFQUFFLEtBQUssTUFBTSxFQUFFLEtBQUssY0FBYyxFQUFnQixNQUFNLHVCQUF1QixDQUFDO0FBSXZGOzs7O0dBSUc7QUFDSCxNQUFNLFdBQVcsZ0JBQWdCO0lBQy9CLGdGQUFnRjtJQUNoRixXQUFXLElBQUksT0FBTyxDQUFDO0lBQ3ZCLHFEQUFxRDtJQUNyRCxNQUFNLENBQU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AAC,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
|
+
private buildCheckpointRootInputs;
|
|
81
|
+
private computeOutHashHints;
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidG9wLXRyZWUtb3JjaGVzdHJhdG9yLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvb3JjaGVzdHJhdG9yL3RvcC10cmVlLW9yY2hlc3RyYXRvci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQTBCLEtBQUssMkJBQTJCLEVBQUUsTUFBTSxpQkFBaUIsQ0FBQztBQUMzRixPQUFPLEtBQUssRUFBRSxXQUFXLEVBQUUsTUFBTSx1QkFBdUIsQ0FBQztBQUN6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