@aztec/prover-client 0.0.1-commit.24de95ac → 0.0.1-commit.5daedc8
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/block-factory/index.d.ts +1 -1
- package/dest/block-factory/light.d.ts +7 -7
- package/dest/block-factory/light.d.ts.map +1 -1
- package/dest/block-factory/light.js +36 -22
- package/dest/config.d.ts +1 -1
- package/dest/index.d.ts +1 -1
- package/dest/light/lightweight_checkpoint_builder.d.ts +28 -0
- package/dest/light/lightweight_checkpoint_builder.d.ts.map +1 -0
- package/dest/light/lightweight_checkpoint_builder.js +107 -0
- package/dest/mocks/fixtures.d.ts +1 -4
- package/dest/mocks/fixtures.d.ts.map +1 -1
- package/dest/mocks/fixtures.js +4 -14
- package/dest/mocks/test_context.d.ts +26 -45
- package/dest/mocks/test_context.d.ts.map +1 -1
- package/dest/mocks/test_context.js +98 -112
- package/dest/orchestrator/block-building-helpers.d.ts +15 -17
- package/dest/orchestrator/block-building-helpers.d.ts.map +1 -1
- package/dest/orchestrator/block-building-helpers.js +83 -109
- package/dest/orchestrator/block-proving-state.d.ts +13 -8
- package/dest/orchestrator/block-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/block-proving-state.js +81 -20
- package/dest/orchestrator/checkpoint-proving-state.d.ts +4 -5
- package/dest/orchestrator/checkpoint-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/checkpoint-proving-state.js +9 -12
- package/dest/orchestrator/epoch-proving-state.d.ts +6 -5
- package/dest/orchestrator/epoch-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/epoch-proving-state.js +2 -2
- package/dest/orchestrator/index.d.ts +1 -1
- package/dest/orchestrator/orchestrator.d.ts +5 -5
- package/dest/orchestrator/orchestrator.d.ts.map +1 -1
- package/dest/orchestrator/orchestrator.js +19 -27
- package/dest/orchestrator/orchestrator_metrics.d.ts +1 -1
- package/dest/orchestrator/orchestrator_metrics.d.ts.map +1 -1
- package/dest/orchestrator/tx-proving-state.d.ts +1 -1
- package/dest/orchestrator/tx-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/tx-proving-state.js +2 -11
- package/dest/prover-client/factory.d.ts +1 -1
- package/dest/prover-client/index.d.ts +1 -1
- package/dest/prover-client/prover-client.d.ts +1 -1
- package/dest/prover-client/prover-client.d.ts.map +1 -1
- package/dest/prover-client/server-epoch-prover.d.ts +5 -4
- package/dest/prover-client/server-epoch-prover.d.ts.map +1 -1
- package/dest/prover-client/server-epoch-prover.js +2 -2
- package/dest/proving_broker/broker_prover_facade.d.ts +20 -20
- package/dest/proving_broker/broker_prover_facade.d.ts.map +1 -1
- package/dest/proving_broker/broker_prover_facade.js +3 -2
- package/dest/proving_broker/config.d.ts +11 -7
- package/dest/proving_broker/config.d.ts.map +1 -1
- package/dest/proving_broker/config.js +7 -1
- package/dest/proving_broker/factory.d.ts +1 -1
- package/dest/proving_broker/fixtures.d.ts +3 -2
- package/dest/proving_broker/fixtures.d.ts.map +1 -1
- package/dest/proving_broker/fixtures.js +2 -1
- package/dest/proving_broker/index.d.ts +1 -1
- package/dest/proving_broker/proof_store/factory.d.ts +2 -2
- package/dest/proving_broker/proof_store/gcs_proof_store.d.ts +1 -1
- package/dest/proving_broker/proof_store/gcs_proof_store.d.ts.map +1 -1
- package/dest/proving_broker/proof_store/index.d.ts +1 -1
- package/dest/proving_broker/proof_store/inline_proof_store.d.ts +1 -1
- package/dest/proving_broker/proof_store/inline_proof_store.d.ts.map +1 -1
- package/dest/proving_broker/proof_store/proof_store.d.ts +1 -1
- package/dest/proving_broker/proving_agent.d.ts +1 -1
- package/dest/proving_broker/proving_agent.d.ts.map +1 -1
- package/dest/proving_broker/proving_agent_instrumentation.d.ts +1 -1
- package/dest/proving_broker/proving_agent_instrumentation.d.ts.map +1 -1
- 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 +2 -1
- package/dest/proving_broker/proving_broker_database/memory.d.ts +3 -2
- package/dest/proving_broker/proving_broker_database/memory.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker_database/persisted.d.ts +3 -2
- package/dest/proving_broker/proving_broker_database/persisted.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker_database/persisted.js +3 -2
- package/dest/proving_broker/proving_broker_database.d.ts +3 -2
- package/dest/proving_broker/proving_broker_database.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker_instrumentation.d.ts +1 -1
- package/dest/proving_broker/proving_broker_instrumentation.d.ts.map +1 -1
- package/dest/proving_broker/proving_job_controller.d.ts +3 -2
- package/dest/proving_broker/proving_job_controller.d.ts.map +1 -1
- package/dest/proving_broker/rpc.d.ts +4 -4
- package/dest/test/mock_proof_store.d.ts +3 -3
- package/dest/test/mock_proof_store.d.ts.map +1 -1
- package/dest/test/mock_prover.d.ts +3 -4
- package/dest/test/mock_prover.d.ts.map +1 -1
- package/package.json +18 -17
- package/src/block-factory/light.ts +39 -42
- package/src/light/lightweight_checkpoint_builder.ts +142 -0
- package/src/mocks/fixtures.ts +4 -27
- package/src/mocks/test_context.ts +140 -174
- package/src/orchestrator/block-building-helpers.ts +122 -203
- package/src/orchestrator/block-proving-state.ts +100 -23
- package/src/orchestrator/checkpoint-proving-state.ts +15 -13
- package/src/orchestrator/epoch-proving-state.ts +2 -3
- package/src/orchestrator/orchestrator.ts +23 -31
- package/src/orchestrator/tx-proving-state.ts +3 -16
- package/src/prover-client/server-epoch-prover.ts +3 -4
- package/src/proving_broker/broker_prover_facade.ts +21 -20
- package/src/proving_broker/config.ts +7 -0
- package/src/proving_broker/fixtures.ts +7 -2
- package/src/proving_broker/proving_broker.ts +2 -1
- package/src/proving_broker/proving_broker_database/memory.ts +2 -1
- package/src/proving_broker/proving_broker_database/persisted.ts +5 -4
- package/src/proving_broker/proving_broker_database.ts +2 -1
- package/src/proving_broker/proving_job_controller.ts +2 -1
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
BatchedBlobAccumulator,
|
|
3
|
+
type FinalBlobBatchingChallenges,
|
|
4
|
+
SpongeBlob,
|
|
5
|
+
encodeCheckpointBlobDataFromBlocks,
|
|
6
|
+
} from '@aztec/blob-lib';
|
|
2
7
|
import {
|
|
3
8
|
type ARCHIVE_HEIGHT,
|
|
4
|
-
|
|
9
|
+
BLOBS_PER_CHECKPOINT,
|
|
5
10
|
FIELDS_PER_BLOB,
|
|
6
11
|
type L1_TO_L2_MSG_SUBTREE_ROOT_SIBLING_PATH_LENGTH,
|
|
7
12
|
type NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH,
|
|
@@ -11,7 +16,6 @@ import { padArrayEnd } from '@aztec/foundation/collection';
|
|
|
11
16
|
import { BLS12Point, Fr } from '@aztec/foundation/fields';
|
|
12
17
|
import type { Tuple } from '@aztec/foundation/serialize';
|
|
13
18
|
import { type TreeNodeLocation, UnbalancedTreeStore } from '@aztec/foundation/trees';
|
|
14
|
-
import { getCheckpointBlobFields } from '@aztec/stdlib/checkpoint';
|
|
15
19
|
import type { PublicInputsAndRecursiveProof } from '@aztec/stdlib/interfaces/server';
|
|
16
20
|
import { ParityBasePrivateInputs } from '@aztec/stdlib/parity';
|
|
17
21
|
import {
|
|
@@ -50,7 +54,6 @@ export class CheckpointProvingState {
|
|
|
50
54
|
public readonly index: number,
|
|
51
55
|
public readonly constants: CheckpointConstantData,
|
|
52
56
|
public readonly totalNumBlocks: number,
|
|
53
|
-
private readonly totalNumBlobFields: number,
|
|
54
57
|
private readonly finalBlobBatchingChallenges: FinalBlobBatchingChallenges,
|
|
55
58
|
private readonly headerOfLastBlockInPreviousCheckpoint: BlockHeader,
|
|
56
59
|
private readonly lastArchiveSiblingPath: Tuple<Fr, typeof ARCHIVE_HEIGHT>,
|
|
@@ -78,13 +81,13 @@ export class CheckpointProvingState {
|
|
|
78
81
|
return this.parentEpoch.epochNumber;
|
|
79
82
|
}
|
|
80
83
|
|
|
81
|
-
public
|
|
84
|
+
public startNewBlock(
|
|
82
85
|
blockNumber: number,
|
|
83
86
|
timestamp: UInt64,
|
|
84
87
|
totalNumTxs: number,
|
|
85
88
|
lastArchiveTreeSnapshot: AppendOnlyTreeSnapshot,
|
|
86
89
|
lastArchiveSiblingPath: Tuple<Fr, typeof ARCHIVE_HEIGHT>,
|
|
87
|
-
):
|
|
90
|
+
): BlockProvingState {
|
|
88
91
|
const index = blockNumber - this.firstBlockNumber;
|
|
89
92
|
if (index >= this.totalNumBlocks) {
|
|
90
93
|
throw new Error(`Unable to start a new block at index ${index}. Expected at most ${this.totalNumBlocks} blocks.`);
|
|
@@ -98,8 +101,7 @@ export class CheckpointProvingState {
|
|
|
98
101
|
const lastL1ToL2MessageSubtreeRootSiblingPath =
|
|
99
102
|
index === 0 ? this.lastL1ToL2MessageSubtreeRootSiblingPath : this.newL1ToL2MessageSubtreeRootSiblingPath;
|
|
100
103
|
|
|
101
|
-
const startSpongeBlob =
|
|
102
|
-
index === 0 ? await SpongeBlob.init(this.totalNumBlobFields) : this.blocks[index - 1]?.getEndSpongeBlob();
|
|
104
|
+
const startSpongeBlob = index === 0 ? SpongeBlob.init() : this.blocks[index - 1]?.getEndSpongeBlob();
|
|
103
105
|
if (!startSpongeBlob) {
|
|
104
106
|
throw new Error(
|
|
105
107
|
'Cannot start a new block before the trees have progressed from the tx effects in the previous block.',
|
|
@@ -192,12 +194,12 @@ export class CheckpointProvingState {
|
|
|
192
194
|
}
|
|
193
195
|
|
|
194
196
|
public async accumulateBlobs(startBlobAccumulator: BatchedBlobAccumulator) {
|
|
195
|
-
if (this.isAcceptingBlocks() || this.blocks.some(b => b
|
|
197
|
+
if (this.isAcceptingBlocks() || this.blocks.some(b => !b?.hasEndState())) {
|
|
196
198
|
return;
|
|
197
199
|
}
|
|
198
200
|
|
|
199
|
-
this.blobFields =
|
|
200
|
-
this.endBlobAccumulator = await accumulateBlobs(this.blobFields
|
|
201
|
+
this.blobFields = encodeCheckpointBlobDataFromBlocks(this.blocks.map(b => b!.getBlockBlobData()));
|
|
202
|
+
this.endBlobAccumulator = await accumulateBlobs(this.blobFields!, startBlobAccumulator);
|
|
201
203
|
this.startBlobAccumulator = startBlobAccumulator;
|
|
202
204
|
|
|
203
205
|
this.onBlobAccumulatorSet(this);
|
|
@@ -246,8 +248,8 @@ export class CheckpointProvingState {
|
|
|
246
248
|
previousArchiveSiblingPath: this.lastArchiveSiblingPath,
|
|
247
249
|
startBlobAccumulator: this.startBlobAccumulator.toBlobAccumulator(),
|
|
248
250
|
finalBlobChallenges: this.finalBlobBatchingChallenges,
|
|
249
|
-
blobFields: padArrayEnd(blobFields, Fr.ZERO, FIELDS_PER_BLOB *
|
|
250
|
-
blobCommitments: padArrayEnd(blobCommitments, BLS12Point.ZERO,
|
|
251
|
+
blobFields: padArrayEnd(blobFields, Fr.ZERO, FIELDS_PER_BLOB * BLOBS_PER_CHECKPOINT),
|
|
252
|
+
blobCommitments: padArrayEnd(blobCommitments, BLS12Point.ZERO, BLOBS_PER_CHECKPOINT),
|
|
251
253
|
blobsHash,
|
|
252
254
|
});
|
|
253
255
|
|
|
@@ -5,6 +5,7 @@ import type {
|
|
|
5
5
|
NESTED_RECURSIVE_PROOF_LENGTH,
|
|
6
6
|
NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH,
|
|
7
7
|
} from '@aztec/constants';
|
|
8
|
+
import { EpochNumber } from '@aztec/foundation/branded-types';
|
|
8
9
|
import type { Fr } from '@aztec/foundation/fields';
|
|
9
10
|
import type { Tuple } from '@aztec/foundation/serialize';
|
|
10
11
|
import { type TreeNodeLocation, UnbalancedTreeStore } from '@aztec/foundation/trees';
|
|
@@ -66,7 +67,7 @@ export class EpochProvingState {
|
|
|
66
67
|
>();
|
|
67
68
|
|
|
68
69
|
constructor(
|
|
69
|
-
public readonly epochNumber:
|
|
70
|
+
public readonly epochNumber: EpochNumber,
|
|
70
71
|
public readonly totalNumCheckpoints: number,
|
|
71
72
|
private readonly finalBlobBatchingChallenges: FinalBlobBatchingChallenges,
|
|
72
73
|
private onCheckpointBlobAccumulatorSet: (checkpoint: CheckpointProvingState) => void,
|
|
@@ -83,7 +84,6 @@ export class EpochProvingState {
|
|
|
83
84
|
checkpointIndex: number,
|
|
84
85
|
constants: CheckpointConstantData,
|
|
85
86
|
totalNumBlocks: number,
|
|
86
|
-
totalNumBlobFields: number,
|
|
87
87
|
previousBlockHeader: BlockHeader,
|
|
88
88
|
lastArchiveSiblingPath: Tuple<Fr, typeof ARCHIVE_HEIGHT>,
|
|
89
89
|
l1ToL2Messages: Fr[],
|
|
@@ -102,7 +102,6 @@ export class EpochProvingState {
|
|
|
102
102
|
checkpointIndex,
|
|
103
103
|
constants,
|
|
104
104
|
totalNumBlocks,
|
|
105
|
-
totalNumBlobFields,
|
|
106
105
|
this.finalBlobBatchingChallenges,
|
|
107
106
|
previousBlockHeader,
|
|
108
107
|
lastArchiveSiblingPath,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BatchedBlob, FinalBlobBatchingChallenges, SpongeBlob } from '@aztec/blob-lib';
|
|
1
|
+
import { BatchedBlob, FinalBlobBatchingChallenges, SpongeBlob } from '@aztec/blob-lib/types';
|
|
2
2
|
import {
|
|
3
3
|
L1_TO_L2_MSG_SUBTREE_HEIGHT,
|
|
4
4
|
L1_TO_L2_MSG_SUBTREE_ROOT_SIBLING_PATH_LENGTH,
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP,
|
|
7
7
|
NUM_BASE_PARITY_PER_ROOT_PARITY,
|
|
8
8
|
} from '@aztec/constants';
|
|
9
|
+
import { EpochNumber } from '@aztec/foundation/branded-types';
|
|
9
10
|
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
10
11
|
import { AbortError } from '@aztec/foundation/error';
|
|
11
12
|
import { Fr } from '@aztec/foundation/fields';
|
|
@@ -16,7 +17,7 @@ import { pushTestData } from '@aztec/foundation/testing';
|
|
|
16
17
|
import { elapsed } from '@aztec/foundation/timer';
|
|
17
18
|
import type { TreeNodeLocation } from '@aztec/foundation/trees';
|
|
18
19
|
import { readAvmMinimalPublicTxInputsFromFile } from '@aztec/simulator/public/fixtures';
|
|
19
|
-
import { EthAddress
|
|
20
|
+
import { EthAddress } from '@aztec/stdlib/block';
|
|
20
21
|
import type {
|
|
21
22
|
EpochProver,
|
|
22
23
|
ForkMerkleTreeOperations,
|
|
@@ -54,7 +55,6 @@ import {
|
|
|
54
55
|
import { inspect } from 'util';
|
|
55
56
|
|
|
56
57
|
import {
|
|
57
|
-
buildBlockHeaderFromTxs,
|
|
58
58
|
buildHeaderFromCircuitOutputs,
|
|
59
59
|
getLastSiblingPath,
|
|
60
60
|
getPublicChonkVerifierPrivateInputsFromTx,
|
|
@@ -118,7 +118,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
public startNewEpoch(
|
|
121
|
-
epochNumber:
|
|
121
|
+
epochNumber: EpochNumber,
|
|
122
122
|
totalNumCheckpoints: number,
|
|
123
123
|
finalBlobBatchingChallenges: FinalBlobBatchingChallenges,
|
|
124
124
|
) {
|
|
@@ -147,7 +147,6 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
147
147
|
constants: CheckpointConstantData,
|
|
148
148
|
l1ToL2Messages: Fr[],
|
|
149
149
|
totalNumBlocks: number,
|
|
150
|
-
totalNumBlobFields: number,
|
|
151
150
|
headerOfLastBlockInPreviousCheckpoint: BlockHeader,
|
|
152
151
|
) {
|
|
153
152
|
if (!this.provingState) {
|
|
@@ -180,7 +179,6 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
180
179
|
checkpointIndex,
|
|
181
180
|
constants,
|
|
182
181
|
totalNumBlocks,
|
|
183
|
-
totalNumBlobFields,
|
|
184
182
|
headerOfLastBlockInPreviousCheckpoint,
|
|
185
183
|
lastArchiveSiblingPath,
|
|
186
184
|
l1ToL2Messages,
|
|
@@ -216,7 +214,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
216
214
|
}
|
|
217
215
|
|
|
218
216
|
const constants = checkpointProvingState.constants;
|
|
219
|
-
logger.info(`Starting block ${blockNumber} for slot ${constants.slotNumber
|
|
217
|
+
logger.info(`Starting block ${blockNumber} for slot ${constants.slotNumber}.`);
|
|
220
218
|
|
|
221
219
|
// Fork the db only when it's not already set. The db for the first block is set in `startNewCheckpoint`.
|
|
222
220
|
if (!this.dbs.has(blockNumber)) {
|
|
@@ -230,7 +228,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
230
228
|
const lastArchiveTreeSnapshot = await getTreeSnapshot(MerkleTreeId.ARCHIVE, db);
|
|
231
229
|
const lastArchiveSiblingPath = await getRootTreeSiblingPath(MerkleTreeId.ARCHIVE, db);
|
|
232
230
|
|
|
233
|
-
const blockProvingState =
|
|
231
|
+
const blockProvingState = checkpointProvingState.startNewBlock(
|
|
234
232
|
blockNumber,
|
|
235
233
|
timestamp,
|
|
236
234
|
totalNumTxs,
|
|
@@ -248,8 +246,12 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
248
246
|
// Because `addTxs` won't be called for a block without txs, and that's where the sponge blob state is computed.
|
|
249
247
|
// We need to set its end sponge blob here, which will become the start sponge blob for the next block.
|
|
250
248
|
if (totalNumTxs === 0) {
|
|
249
|
+
const endState = await db.getStateReference();
|
|
250
|
+
blockProvingState.setEndState(endState);
|
|
251
|
+
|
|
251
252
|
const endSpongeBlob = blockProvingState.getStartSpongeBlob().clone();
|
|
252
|
-
|
|
253
|
+
const blockEndBlobFields = blockProvingState.getBlockEndBlobFields();
|
|
254
|
+
await endSpongeBlob.absorb(blockEndBlobFields);
|
|
253
255
|
blockProvingState.setEndSpongeBlob(endSpongeBlob);
|
|
254
256
|
|
|
255
257
|
// And also try to accumulate the blobs as far as we can:
|
|
@@ -341,7 +343,11 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
341
343
|
}
|
|
342
344
|
}
|
|
343
345
|
|
|
344
|
-
await
|
|
346
|
+
const endState = await db.getStateReference();
|
|
347
|
+
provingState.setEndState(endState);
|
|
348
|
+
|
|
349
|
+
const blockEndBlobFields = provingState.getBlockEndBlobFields();
|
|
350
|
+
await spongeBlobState.absorb(blockEndBlobFields);
|
|
345
351
|
|
|
346
352
|
provingState.setEndSpongeBlob(spongeBlobState);
|
|
347
353
|
|
|
@@ -408,39 +414,25 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
408
414
|
);
|
|
409
415
|
}
|
|
410
416
|
|
|
411
|
-
//
|
|
417
|
+
// Given we've applied every change from this block, now assemble the block header:
|
|
412
418
|
logger.verbose(`Block ${blockNumber} completed. Assembling header.`);
|
|
413
|
-
const header = await
|
|
414
|
-
|
|
415
|
-
await this.verifyBuiltBlockAgainstSyncedState(provingState);
|
|
416
|
-
|
|
417
|
-
return header;
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
private async buildL2BlockHeader(provingState: BlockProvingState, expectedHeader?: BlockHeader) {
|
|
421
|
-
// Collect all txs in this block to build the header. The function calling this has made sure that all txs have been added.
|
|
422
|
-
const txs = provingState.getProcessedTxs();
|
|
423
|
-
|
|
424
|
-
const startSpongeBlob = provingState.getStartSpongeBlob();
|
|
425
|
-
|
|
426
|
-
// Get db for this block
|
|
427
|
-
const db = this.dbs.get(provingState.blockNumber)!;
|
|
428
|
-
|
|
429
|
-
// Given we've applied every change from this block, now assemble the block header
|
|
430
|
-
// and update the archive tree, so we're ready to start processing the next block
|
|
431
|
-
const header = await buildBlockHeaderFromTxs(txs, provingState.getGlobalVariables(), startSpongeBlob, db);
|
|
419
|
+
const header = await provingState.buildBlockHeader();
|
|
432
420
|
|
|
433
421
|
if (expectedHeader && !header.equals(expectedHeader)) {
|
|
434
422
|
logger.error(`Block header mismatch: header=${header} expectedHeader=${expectedHeader}`);
|
|
435
423
|
throw new Error('Block header mismatch');
|
|
436
424
|
}
|
|
437
425
|
|
|
426
|
+
// Get db for this block
|
|
427
|
+
const db = this.dbs.get(provingState.blockNumber)!;
|
|
428
|
+
|
|
429
|
+
// Update the archive tree, so we're ready to start processing the next block:
|
|
438
430
|
logger.verbose(
|
|
439
431
|
`Updating archive tree with block ${provingState.blockNumber} header ${(await header.hash()).toString()}`,
|
|
440
432
|
);
|
|
441
433
|
await db.updateArchive(header);
|
|
442
434
|
|
|
443
|
-
|
|
435
|
+
await this.verifyBuiltBlockAgainstSyncedState(provingState);
|
|
444
436
|
|
|
445
437
|
return header;
|
|
446
438
|
}
|
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
AVM_V2_PROOF_LENGTH_IN_FIELDS_PADDED,
|
|
3
|
-
AVM_VK_INDEX,
|
|
4
|
-
NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH,
|
|
5
|
-
} from '@aztec/constants';
|
|
1
|
+
import { AVM_V2_PROOF_LENGTH_IN_FIELDS_PADDED, NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH } from '@aztec/constants';
|
|
6
2
|
import type { Fr } from '@aztec/foundation/fields';
|
|
7
|
-
import { getVkData } from '@aztec/noir-protocol-circuits-types/server/vks';
|
|
8
|
-
import { getVKSiblingPath } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
3
|
+
import { getAvmVkData, getVkData } from '@aztec/noir-protocol-circuits-types/server/vks';
|
|
9
4
|
import type { AvmCircuitInputs } from '@aztec/stdlib/avm';
|
|
10
5
|
import type { ProofAndVerificationKey, PublicInputsAndRecursiveProof } from '@aztec/stdlib/interfaces/server';
|
|
11
6
|
import { ProofData } from '@aztec/stdlib/proofs';
|
|
@@ -20,7 +15,6 @@ import {
|
|
|
20
15
|
import type { CircuitName } from '@aztec/stdlib/stats';
|
|
21
16
|
import type { AppendOnlyTreeSnapshot, MerkleTreeId } from '@aztec/stdlib/trees';
|
|
22
17
|
import type { ProcessedTx } from '@aztec/stdlib/tx';
|
|
23
|
-
import { VerificationKeyData, VkData } from '@aztec/stdlib/vks';
|
|
24
18
|
|
|
25
19
|
import {
|
|
26
20
|
getChonkProofFromTx,
|
|
@@ -123,16 +117,9 @@ export class TxProvingState {
|
|
|
123
117
|
const avmProofData = new ProofData(
|
|
124
118
|
this.processedTx.avmProvingRequest.inputs.publicInputs,
|
|
125
119
|
this.avm.proof,
|
|
126
|
-
|
|
120
|
+
getAvmVkData(),
|
|
127
121
|
);
|
|
128
122
|
|
|
129
123
|
return new PublicTxBaseRollupPrivateInputs(publicChonkVerifierProofData, avmProofData, this.baseRollupHints);
|
|
130
124
|
}
|
|
131
|
-
|
|
132
|
-
#getVkData(verificationKey: VerificationKeyData, vkIndex: number) {
|
|
133
|
-
// TODO(#17162): Add avm vk hash to the tree and call `getVkData('AVM')` instead.
|
|
134
|
-
// Below will return a path to an empty leaf.
|
|
135
|
-
const vkPath = getVKSiblingPath(vkIndex);
|
|
136
|
-
return new VkData(verificationKey, vkIndex, vkPath);
|
|
137
|
-
}
|
|
138
125
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { BatchedBlob, FinalBlobBatchingChallenges } from '@aztec/blob-lib';
|
|
1
|
+
import type { BatchedBlob, FinalBlobBatchingChallenges } from '@aztec/blob-lib/types';
|
|
2
|
+
import { EpochNumber } from '@aztec/foundation/branded-types';
|
|
2
3
|
import type { Fr } from '@aztec/foundation/fields';
|
|
3
4
|
import type { EthAddress } from '@aztec/stdlib/block';
|
|
4
5
|
import type { EpochProver } from '@aztec/stdlib/interfaces/server';
|
|
@@ -18,7 +19,7 @@ export class ServerEpochProver implements EpochProver {
|
|
|
18
19
|
) {}
|
|
19
20
|
|
|
20
21
|
startNewEpoch(
|
|
21
|
-
epochNumber:
|
|
22
|
+
epochNumber: EpochNumber,
|
|
22
23
|
totalNumCheckpoints: number,
|
|
23
24
|
finalBlobBatchingChallenges: FinalBlobBatchingChallenges,
|
|
24
25
|
): void {
|
|
@@ -30,7 +31,6 @@ export class ServerEpochProver implements EpochProver {
|
|
|
30
31
|
constants: CheckpointConstantData,
|
|
31
32
|
l1ToL2Messages: Fr[],
|
|
32
33
|
totalNumBlocks: number,
|
|
33
|
-
totalNumBlobFields: number,
|
|
34
34
|
headerOfLastBlockInPreviousCheckpoint: BlockHeader,
|
|
35
35
|
): Promise<void> {
|
|
36
36
|
return this.orchestrator.startNewCheckpoint(
|
|
@@ -38,7 +38,6 @@ export class ServerEpochProver implements EpochProver {
|
|
|
38
38
|
constants,
|
|
39
39
|
l1ToL2Messages,
|
|
40
40
|
totalNumBlocks,
|
|
41
|
-
totalNumBlobFields,
|
|
42
41
|
headerOfLastBlockInPreviousCheckpoint,
|
|
43
42
|
);
|
|
44
43
|
}
|
|
@@ -4,6 +4,7 @@ import type {
|
|
|
4
4
|
NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH,
|
|
5
5
|
RECURSIVE_PROOF_LENGTH,
|
|
6
6
|
} from '@aztec/constants';
|
|
7
|
+
import { EpochNumber } from '@aztec/foundation/branded-types';
|
|
7
8
|
import { sha256 } from '@aztec/foundation/crypto';
|
|
8
9
|
import { Fr } from '@aztec/foundation/fields';
|
|
9
10
|
import { createLogger } from '@aztec/foundation/log';
|
|
@@ -130,7 +131,7 @@ export class BrokerCircuitProverFacade implements ServerCircuitProver {
|
|
|
130
131
|
id: ProvingJobId,
|
|
131
132
|
type: T,
|
|
132
133
|
inputs: ProvingJobInputsMap[T],
|
|
133
|
-
epochNumber =
|
|
134
|
+
epochNumber = EpochNumber.ZERO,
|
|
134
135
|
signal?: AbortSignal,
|
|
135
136
|
): Promise<ProvingJobResultsMap[T]> {
|
|
136
137
|
const { job: job, isEnqueued } = this.getOrCreateProvingJob(id, type, signal);
|
|
@@ -399,7 +400,7 @@ export class BrokerCircuitProverFacade implements ServerCircuitProver {
|
|
|
399
400
|
inputs: AvmCircuitInputs,
|
|
400
401
|
skipPublicInputsValidation?: boolean, // TODO(#14234)[Unconditional PIs validation]: remove this argument
|
|
401
402
|
signal?: AbortSignal,
|
|
402
|
-
epochNumber?:
|
|
403
|
+
epochNumber?: EpochNumber,
|
|
403
404
|
): Promise<ProofAndVerificationKey<typeof AVM_V2_PROOF_LENGTH_IN_FIELDS_PADDED>> {
|
|
404
405
|
this.log.info(`getAvmProof() called with skipPublicInputsValidation: ${skipPublicInputsValidation}`);
|
|
405
406
|
|
|
@@ -420,7 +421,7 @@ export class BrokerCircuitProverFacade implements ServerCircuitProver {
|
|
|
420
421
|
getBaseParityProof(
|
|
421
422
|
inputs: ParityBasePrivateInputs,
|
|
422
423
|
signal?: AbortSignal,
|
|
423
|
-
epochNumber?:
|
|
424
|
+
epochNumber?: EpochNumber,
|
|
424
425
|
): Promise<PublicInputsAndRecursiveProof<ParityPublicInputs, typeof RECURSIVE_PROOF_LENGTH>> {
|
|
425
426
|
return this.enqueueJob(
|
|
426
427
|
this.generateId(ProvingRequestType.PARITY_BASE, inputs, epochNumber),
|
|
@@ -434,7 +435,7 @@ export class BrokerCircuitProverFacade implements ServerCircuitProver {
|
|
|
434
435
|
getTxMergeRollupProof(
|
|
435
436
|
input: TxMergeRollupPrivateInputs,
|
|
436
437
|
signal?: AbortSignal,
|
|
437
|
-
epochNumber?:
|
|
438
|
+
epochNumber?: EpochNumber,
|
|
438
439
|
): Promise<PublicInputsAndRecursiveProof<TxRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>> {
|
|
439
440
|
return this.enqueueJob(
|
|
440
441
|
this.generateId(ProvingRequestType.TX_MERGE_ROLLUP, input, epochNumber),
|
|
@@ -448,7 +449,7 @@ export class BrokerCircuitProverFacade implements ServerCircuitProver {
|
|
|
448
449
|
getPublicChonkVerifierProof(
|
|
449
450
|
inputs: PublicChonkVerifierPrivateInputs,
|
|
450
451
|
signal?: AbortSignal,
|
|
451
|
-
epochNumber?:
|
|
452
|
+
epochNumber?: EpochNumber,
|
|
452
453
|
): Promise<
|
|
453
454
|
PublicInputsAndRecursiveProof<PublicChonkVerifierPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>
|
|
454
455
|
> {
|
|
@@ -464,7 +465,7 @@ export class BrokerCircuitProverFacade implements ServerCircuitProver {
|
|
|
464
465
|
getPrivateTxBaseRollupProof(
|
|
465
466
|
baseRollupInput: PrivateTxBaseRollupPrivateInputs,
|
|
466
467
|
signal?: AbortSignal,
|
|
467
|
-
epochNumber?:
|
|
468
|
+
epochNumber?: EpochNumber,
|
|
468
469
|
): Promise<PublicInputsAndRecursiveProof<TxRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>> {
|
|
469
470
|
return this.enqueueJob(
|
|
470
471
|
this.generateId(ProvingRequestType.PRIVATE_TX_BASE_ROLLUP, baseRollupInput, epochNumber),
|
|
@@ -478,7 +479,7 @@ export class BrokerCircuitProverFacade implements ServerCircuitProver {
|
|
|
478
479
|
getPublicTxBaseRollupProof(
|
|
479
480
|
inputs: PublicTxBaseRollupPrivateInputs,
|
|
480
481
|
signal?: AbortSignal,
|
|
481
|
-
epochNumber?:
|
|
482
|
+
epochNumber?: EpochNumber,
|
|
482
483
|
): Promise<PublicInputsAndRecursiveProof<TxRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>> {
|
|
483
484
|
return this.enqueueJob(
|
|
484
485
|
this.generateId(ProvingRequestType.PUBLIC_TX_BASE_ROLLUP, inputs, epochNumber),
|
|
@@ -492,7 +493,7 @@ export class BrokerCircuitProverFacade implements ServerCircuitProver {
|
|
|
492
493
|
getRootParityProof(
|
|
493
494
|
inputs: ParityRootPrivateInputs,
|
|
494
495
|
signal?: AbortSignal,
|
|
495
|
-
epochNumber?:
|
|
496
|
+
epochNumber?: EpochNumber,
|
|
496
497
|
): Promise<PublicInputsAndRecursiveProof<ParityPublicInputs, typeof NESTED_RECURSIVE_PROOF_LENGTH>> {
|
|
497
498
|
return this.enqueueJob(
|
|
498
499
|
this.generateId(ProvingRequestType.PARITY_ROOT, inputs, epochNumber),
|
|
@@ -506,7 +507,7 @@ export class BrokerCircuitProverFacade implements ServerCircuitProver {
|
|
|
506
507
|
getBlockRootFirstRollupProof(
|
|
507
508
|
input: BlockRootFirstRollupPrivateInputs,
|
|
508
509
|
signal?: AbortSignal,
|
|
509
|
-
epochNumber?:
|
|
510
|
+
epochNumber?: EpochNumber,
|
|
510
511
|
): Promise<PublicInputsAndRecursiveProof<BlockRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>> {
|
|
511
512
|
return this.enqueueJob(
|
|
512
513
|
this.generateId(ProvingRequestType.BLOCK_ROOT_FIRST_ROLLUP, input, epochNumber),
|
|
@@ -520,7 +521,7 @@ export class BrokerCircuitProverFacade implements ServerCircuitProver {
|
|
|
520
521
|
getBlockRootSingleTxFirstRollupProof(
|
|
521
522
|
input: BlockRootSingleTxFirstRollupPrivateInputs,
|
|
522
523
|
signal?: AbortSignal,
|
|
523
|
-
epochNumber?:
|
|
524
|
+
epochNumber?: EpochNumber,
|
|
524
525
|
): Promise<PublicInputsAndRecursiveProof<BlockRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>> {
|
|
525
526
|
return this.enqueueJob(
|
|
526
527
|
this.generateId(ProvingRequestType.BLOCK_ROOT_SINGLE_TX_FIRST_ROLLUP, input, epochNumber),
|
|
@@ -534,7 +535,7 @@ export class BrokerCircuitProverFacade implements ServerCircuitProver {
|
|
|
534
535
|
getBlockRootEmptyTxFirstRollupProof(
|
|
535
536
|
input: BlockRootEmptyTxFirstRollupPrivateInputs,
|
|
536
537
|
signal?: AbortSignal,
|
|
537
|
-
epochNumber?:
|
|
538
|
+
epochNumber?: EpochNumber,
|
|
538
539
|
): Promise<PublicInputsAndRecursiveProof<BlockRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>> {
|
|
539
540
|
return this.enqueueJob(
|
|
540
541
|
this.generateId(ProvingRequestType.BLOCK_ROOT_EMPTY_TX_FIRST_ROLLUP, input, epochNumber),
|
|
@@ -548,7 +549,7 @@ export class BrokerCircuitProverFacade implements ServerCircuitProver {
|
|
|
548
549
|
getBlockRootRollupProof(
|
|
549
550
|
input: BlockRootRollupPrivateInputs,
|
|
550
551
|
signal?: AbortSignal,
|
|
551
|
-
epochNumber?:
|
|
552
|
+
epochNumber?: EpochNumber,
|
|
552
553
|
): Promise<PublicInputsAndRecursiveProof<BlockRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>> {
|
|
553
554
|
return this.enqueueJob(
|
|
554
555
|
this.generateId(ProvingRequestType.BLOCK_ROOT_ROLLUP, input, epochNumber),
|
|
@@ -562,7 +563,7 @@ export class BrokerCircuitProverFacade implements ServerCircuitProver {
|
|
|
562
563
|
getBlockRootSingleTxRollupProof(
|
|
563
564
|
input: BlockRootSingleTxRollupPrivateInputs,
|
|
564
565
|
signal?: AbortSignal,
|
|
565
|
-
epochNumber?:
|
|
566
|
+
epochNumber?: EpochNumber,
|
|
566
567
|
): Promise<PublicInputsAndRecursiveProof<BlockRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>> {
|
|
567
568
|
return this.enqueueJob(
|
|
568
569
|
this.generateId(ProvingRequestType.BLOCK_ROOT_SINGLE_TX_ROLLUP, input, epochNumber),
|
|
@@ -576,7 +577,7 @@ export class BrokerCircuitProverFacade implements ServerCircuitProver {
|
|
|
576
577
|
getBlockMergeRollupProof(
|
|
577
578
|
input: BlockMergeRollupPrivateInputs,
|
|
578
579
|
signal?: AbortSignal,
|
|
579
|
-
epochNumber?:
|
|
580
|
+
epochNumber?: EpochNumber,
|
|
580
581
|
): Promise<PublicInputsAndRecursiveProof<BlockRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>> {
|
|
581
582
|
return this.enqueueJob(
|
|
582
583
|
this.generateId(ProvingRequestType.BLOCK_MERGE_ROLLUP, input, epochNumber),
|
|
@@ -590,7 +591,7 @@ export class BrokerCircuitProverFacade implements ServerCircuitProver {
|
|
|
590
591
|
getCheckpointRootRollupProof(
|
|
591
592
|
input: CheckpointRootRollupPrivateInputs,
|
|
592
593
|
signal?: AbortSignal,
|
|
593
|
-
epochNumber?:
|
|
594
|
+
epochNumber?: EpochNumber,
|
|
594
595
|
): Promise<
|
|
595
596
|
PublicInputsAndRecursiveProof<CheckpointRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>
|
|
596
597
|
> {
|
|
@@ -606,7 +607,7 @@ export class BrokerCircuitProverFacade implements ServerCircuitProver {
|
|
|
606
607
|
getCheckpointRootSingleBlockRollupProof(
|
|
607
608
|
input: CheckpointRootSingleBlockRollupPrivateInputs,
|
|
608
609
|
signal?: AbortSignal,
|
|
609
|
-
epochNumber?:
|
|
610
|
+
epochNumber?: EpochNumber,
|
|
610
611
|
): Promise<
|
|
611
612
|
PublicInputsAndRecursiveProof<CheckpointRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>
|
|
612
613
|
> {
|
|
@@ -622,7 +623,7 @@ export class BrokerCircuitProverFacade implements ServerCircuitProver {
|
|
|
622
623
|
getCheckpointPaddingRollupProof(
|
|
623
624
|
input: CheckpointPaddingRollupPrivateInputs,
|
|
624
625
|
signal?: AbortSignal,
|
|
625
|
-
epochNumber?:
|
|
626
|
+
epochNumber?: EpochNumber,
|
|
626
627
|
): Promise<
|
|
627
628
|
PublicInputsAndRecursiveProof<CheckpointRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>
|
|
628
629
|
> {
|
|
@@ -638,7 +639,7 @@ export class BrokerCircuitProverFacade implements ServerCircuitProver {
|
|
|
638
639
|
getCheckpointMergeRollupProof(
|
|
639
640
|
input: CheckpointMergeRollupPrivateInputs,
|
|
640
641
|
signal?: AbortSignal,
|
|
641
|
-
epochNumber?:
|
|
642
|
+
epochNumber?: EpochNumber,
|
|
642
643
|
): Promise<
|
|
643
644
|
PublicInputsAndRecursiveProof<CheckpointRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>
|
|
644
645
|
> {
|
|
@@ -654,7 +655,7 @@ export class BrokerCircuitProverFacade implements ServerCircuitProver {
|
|
|
654
655
|
getRootRollupProof(
|
|
655
656
|
input: RootRollupPrivateInputs,
|
|
656
657
|
signal?: AbortSignal,
|
|
657
|
-
epochNumber?:
|
|
658
|
+
epochNumber?: EpochNumber,
|
|
658
659
|
): Promise<PublicInputsAndRecursiveProof<RootRollupPublicInputs, typeof RECURSIVE_PROOF_LENGTH>> {
|
|
659
660
|
return this.enqueueJob(
|
|
660
661
|
this.generateId(ProvingRequestType.ROOT_ROLLUP, input, epochNumber),
|
|
@@ -665,7 +666,7 @@ export class BrokerCircuitProverFacade implements ServerCircuitProver {
|
|
|
665
666
|
);
|
|
666
667
|
}
|
|
667
668
|
|
|
668
|
-
private generateId(type: ProvingRequestType, inputs: { toBuffer(): Buffer }, epochNumber =
|
|
669
|
+
private generateId(type: ProvingRequestType, inputs: { toBuffer(): Buffer }, epochNumber = EpochNumber.ZERO) {
|
|
669
670
|
const inputsHash = sha256(inputs.toBuffer());
|
|
670
671
|
return makeProvingJobId(epochNumber, type, inputsHash.toString('hex'));
|
|
671
672
|
}
|
|
@@ -98,6 +98,8 @@ export const ProverAgentConfig = z.object({
|
|
|
98
98
|
proverTestDelayMs: z.number(),
|
|
99
99
|
/** If using realistic delays, what percentage of realistic times to apply. */
|
|
100
100
|
proverTestDelayFactor: z.number(),
|
|
101
|
+
/** The delay (ms) to inject during fake proof verification */
|
|
102
|
+
proverTestVerificationDelayMs: z.number().optional(),
|
|
101
103
|
});
|
|
102
104
|
|
|
103
105
|
export type ProverAgentConfig = z.infer<typeof ProverAgentConfig>;
|
|
@@ -146,4 +148,9 @@ export const proverAgentConfigMappings: ConfigMappingsType<ProverAgentConfig> =
|
|
|
146
148
|
description: 'If using realistic delays, what percentage of realistic times to apply.',
|
|
147
149
|
...numberConfigHelper(1),
|
|
148
150
|
},
|
|
151
|
+
proverTestVerificationDelayMs: {
|
|
152
|
+
env: 'PROVER_TEST_VERIFICATION_DELAY_MS',
|
|
153
|
+
description: 'The delay (ms) to inject during fake proof verification',
|
|
154
|
+
...numberConfigHelper(10),
|
|
155
|
+
},
|
|
149
156
|
};
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
+
import { EpochNumber } from '@aztec/foundation/branded-types';
|
|
1
2
|
import { randomBytes } from '@aztec/foundation/crypto';
|
|
2
3
|
import { type ProofUri, type ProvingJobId, makeProvingJobId } from '@aztec/stdlib/interfaces/server';
|
|
3
4
|
import { ProvingRequestType } from '@aztec/stdlib/proofs';
|
|
4
5
|
|
|
5
|
-
export function makeRandomProvingJobId(epochNumber?:
|
|
6
|
-
return makeProvingJobId(
|
|
6
|
+
export function makeRandomProvingJobId(epochNumber?: EpochNumber): ProvingJobId {
|
|
7
|
+
return makeProvingJobId(
|
|
8
|
+
epochNumber ?? EpochNumber(1),
|
|
9
|
+
ProvingRequestType.PARITY_BASE,
|
|
10
|
+
randomBytes(8).toString('hex'),
|
|
11
|
+
);
|
|
7
12
|
}
|
|
8
13
|
|
|
9
14
|
export function makeInputsUri(): ProofUri {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { EpochNumber } from '@aztec/foundation/branded-types';
|
|
1
2
|
import { createLogger } from '@aztec/foundation/log';
|
|
2
3
|
import { type PromiseWithResolvers, RunningPromise, promiseWithResolvers } from '@aztec/foundation/promise';
|
|
3
4
|
import { PriorityMemoryQueue } from '@aztec/foundation/queue';
|
|
@@ -567,7 +568,7 @@ export class ProvingBroker implements ProvingJobProducer, ProvingJobConsumer, Tr
|
|
|
567
568
|
this.reEnqueueExpiredJobs();
|
|
568
569
|
const oldestEpochToKeep = this.oldestEpochToKeep();
|
|
569
570
|
if (oldestEpochToKeep > 0) {
|
|
570
|
-
await this.database.deleteAllProvingJobsOlderThanEpoch(oldestEpochToKeep);
|
|
571
|
+
await this.database.deleteAllProvingJobsOlderThanEpoch(EpochNumber(oldestEpochToKeep));
|
|
571
572
|
this.logger.trace(`Deleted all epochs older than ${oldestEpochToKeep}`);
|
|
572
573
|
}
|
|
573
574
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { EpochNumber } from '@aztec/foundation/branded-types';
|
|
1
2
|
import {
|
|
2
3
|
type ProofUri,
|
|
3
4
|
type ProvingJob,
|
|
@@ -43,7 +44,7 @@ export class InMemoryBrokerDatabase implements ProvingBrokerDatabase {
|
|
|
43
44
|
return Promise.resolve();
|
|
44
45
|
}
|
|
45
46
|
|
|
46
|
-
deleteAllProvingJobsOlderThanEpoch(epochNumber:
|
|
47
|
+
deleteAllProvingJobsOlderThanEpoch(epochNumber: EpochNumber): Promise<void> {
|
|
47
48
|
const toDelete = [
|
|
48
49
|
...Array.from(this.jobs.keys()).filter(x => getEpochFromProvingJobId(x) < epochNumber),
|
|
49
50
|
...Array.from(this.results.keys()).filter(x => getEpochFromProvingJobId(x) < epochNumber),
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { EpochNumber } from '@aztec/foundation/branded-types';
|
|
1
2
|
import { jsonParseWithSchema, jsonStringify } from '@aztec/foundation/json-rpc';
|
|
2
3
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
3
4
|
import { BatchQueue } from '@aztec/foundation/queue';
|
|
@@ -104,7 +105,7 @@ export class KVBrokerDatabase implements ProvingBrokerDatabase {
|
|
|
104
105
|
const jobsToAdd = items.filter((item): item is ProvingJob => 'id' in item);
|
|
105
106
|
const resultsToAdd = items.filter((item): item is [ProvingJobId, ProvingJobSettledResult] => Array.isArray(item));
|
|
106
107
|
|
|
107
|
-
const db = await this.getEpochDatabase(epochNumber);
|
|
108
|
+
const db = await this.getEpochDatabase(EpochNumber(epochNumber));
|
|
108
109
|
await db.batchWrite(jobsToAdd, resultsToAdd);
|
|
109
110
|
}
|
|
110
111
|
|
|
@@ -164,8 +165,8 @@ export class KVBrokerDatabase implements ProvingBrokerDatabase {
|
|
|
164
165
|
}
|
|
165
166
|
}
|
|
166
167
|
|
|
167
|
-
async deleteAllProvingJobsOlderThanEpoch(epochNumber:
|
|
168
|
-
const oldEpochs = Array.from(this.epochs.keys()).filter(e => e < epochNumber);
|
|
168
|
+
async deleteAllProvingJobsOlderThanEpoch(epochNumber: EpochNumber): Promise<void> {
|
|
169
|
+
const oldEpochs = Array.from(this.epochs.keys()).filter(e => e < Number(epochNumber));
|
|
169
170
|
for (const old of oldEpochs) {
|
|
170
171
|
const db = this.epochs.get(old);
|
|
171
172
|
if (!db) {
|
|
@@ -196,7 +197,7 @@ export class KVBrokerDatabase implements ProvingBrokerDatabase {
|
|
|
196
197
|
return this.batchQueue.put([id, { status: 'fulfilled', value }], getEpochFromProvingJobId(id));
|
|
197
198
|
}
|
|
198
199
|
|
|
199
|
-
private async getEpochDatabase(epochNumber:
|
|
200
|
+
private async getEpochDatabase(epochNumber: EpochNumber): Promise<SingleEpochDatabase> {
|
|
200
201
|
let epochDb = this.epochs.get(epochNumber);
|
|
201
202
|
if (!epochDb) {
|
|
202
203
|
const newEpochDirectory = join(this.config.dataDirectory!, epochNumber.toString());
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { EpochNumber } from '@aztec/foundation/branded-types';
|
|
1
2
|
import type { ProofUri, ProvingJob, ProvingJobId, ProvingJobSettledResult } from '@aztec/stdlib/interfaces/server';
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -14,7 +15,7 @@ export interface ProvingBrokerDatabase {
|
|
|
14
15
|
* Deletes all proving jobs belonging to epochs older than the given epoch
|
|
15
16
|
* @param epochNumber - The epoch number beyond which jobs should be deleted
|
|
16
17
|
*/
|
|
17
|
-
deleteAllProvingJobsOlderThanEpoch(epochNumber:
|
|
18
|
+
deleteAllProvingJobsOlderThanEpoch(epochNumber: EpochNumber): Promise<void>;
|
|
18
19
|
|
|
19
20
|
/**
|
|
20
21
|
* Returns an iterator over all saved proving jobs
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { EpochNumber } from '@aztec/foundation/branded-types';
|
|
1
2
|
import { randomBytes } from '@aztec/foundation/crypto';
|
|
2
3
|
import { AbortError } from '@aztec/foundation/error';
|
|
3
4
|
import { createLogger } from '@aztec/foundation/log';
|
|
@@ -24,7 +25,7 @@ export class ProvingJobController {
|
|
|
24
25
|
constructor(
|
|
25
26
|
private jobId: ProvingJobId,
|
|
26
27
|
private inputs: ProvingJobInputs,
|
|
27
|
-
private epochNumber:
|
|
28
|
+
private epochNumber: EpochNumber,
|
|
28
29
|
private startedAt: number,
|
|
29
30
|
private circuitProver: ServerCircuitProver,
|
|
30
31
|
private onComplete: () => void,
|