@aztec/prover-client 0.0.1-commit.c2595eba → 0.0.1-commit.c2eed6949
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 +12 -2
- package/dest/light/lightweight_checkpoint_builder.d.ts +12 -5
- package/dest/light/lightweight_checkpoint_builder.d.ts.map +1 -1
- package/dest/light/lightweight_checkpoint_builder.js +44 -18
- package/dest/mocks/test_context.d.ts +1 -1
- package/dest/mocks/test_context.d.ts.map +1 -1
- package/dest/mocks/test_context.js +10 -5
- package/dest/orchestrator/block-building-helpers.d.ts +4 -4
- package/dest/orchestrator/block-building-helpers.d.ts.map +1 -1
- package/dest/orchestrator/block-building-helpers.js +2 -2
- package/dest/orchestrator/block-proving-state.d.ts +4 -1
- package/dest/orchestrator/block-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/block-proving-state.js +7 -0
- package/dest/orchestrator/checkpoint-proving-state.d.ts +3 -3
- package/dest/orchestrator/checkpoint-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/checkpoint-proving-state.js +3 -3
- package/dest/orchestrator/epoch-proving-state.d.ts +3 -3
- package/dest/orchestrator/epoch-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/epoch-proving-state.js +5 -3
- package/dest/orchestrator/orchestrator.d.ts +5 -3
- package/dest/orchestrator/orchestrator.d.ts.map +1 -1
- package/dest/orchestrator/orchestrator.js +64 -57
- package/dest/prover-client/prover-client.d.ts +4 -4
- package/dest/prover-client/prover-client.d.ts.map +1 -1
- package/dest/prover-client/prover-client.js +9 -7
- 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 +10 -2
- package/dest/proving_broker/config.d.ts.map +1 -1
- package/dest/proving_broker/config.js +14 -3
- package/dest/proving_broker/proof_store/factory.d.ts +2 -5
- package/dest/proving_broker/proof_store/factory.d.ts.map +1 -1
- package/dest/proving_broker/proof_store/factory.js +7 -30
- package/dest/proving_broker/proof_store/file_store_proof_store.d.ts +18 -0
- package/dest/proving_broker/proof_store/file_store_proof_store.d.ts.map +1 -0
- package/dest/proving_broker/proof_store/file_store_proof_store.js +60 -0
- package/dest/proving_broker/proof_store/index.d.ts +2 -2
- package/dest/proving_broker/proof_store/index.d.ts.map +1 -1
- package/dest/proving_broker/proof_store/index.js +1 -1
- package/dest/proving_broker/proving_broker.d.ts +7 -4
- package/dest/proving_broker/proving_broker.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker.js +36 -4
- 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 +4 -2
- package/dest/proving_broker/rpc.d.ts.map +1 -1
- package/dest/proving_broker/rpc.js +8 -0
- package/dest/test/mock_prover.d.ts +4 -4
- package/package.json +17 -18
- package/src/config.ts +13 -2
- package/src/light/lightweight_checkpoint_builder.ts +47 -19
- package/src/mocks/test_context.ts +6 -4
- package/src/orchestrator/block-building-helpers.ts +2 -2
- package/src/orchestrator/block-proving-state.ts +9 -0
- package/src/orchestrator/checkpoint-proving-state.ts +4 -4
- package/src/orchestrator/epoch-proving-state.ts +6 -4
- package/src/orchestrator/orchestrator.ts +72 -63
- package/src/prover-client/prover-client.ts +8 -9
- package/src/proving_broker/broker_prover_facade.ts +17 -20
- package/src/proving_broker/config.ts +14 -1
- package/src/proving_broker/proof_store/factory.ts +10 -32
- package/src/proving_broker/proof_store/file_store_proof_store.ts +78 -0
- package/src/proving_broker/proof_store/index.ts +1 -1
- package/src/proving_broker/proving_broker.ts +37 -3
- package/src/proving_broker/proving_broker_instrumentation.ts +9 -0
- package/src/proving_broker/rpc.ts +14 -0
- package/dest/proving_broker/proof_store/gcs_proof_store.d.ts +0 -14
- package/dest/proving_broker/proof_store/gcs_proof_store.d.ts.map +0 -1
- package/dest/proving_broker/proof_store/gcs_proof_store.js +0 -52
- package/src/proving_broker/proof_store/gcs_proof_store.ts +0 -76
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { EpochNumberSchema } from '@aztec/foundation/branded-types';
|
|
1
2
|
import { createSafeJsonRpcClient } from '@aztec/foundation/json-rpc/client';
|
|
2
3
|
import { ProofUri, ProvingJob, ProvingJobId, ProvingJobStatus } from '@aztec/stdlib/interfaces/server';
|
|
3
4
|
import { ProvingRequestType } from '@aztec/stdlib/proofs';
|
|
@@ -28,6 +29,13 @@ export const ProvingJobBrokerSchema = {
|
|
|
28
29
|
...ProvingJobConsumerSchema,
|
|
29
30
|
...ProvingJobProducerSchema
|
|
30
31
|
};
|
|
32
|
+
export const ProvingJobBrokerDebugSchema = {
|
|
33
|
+
replayProvingJob: z.function().args(ProvingJobId, z.nativeEnum(ProvingRequestType), EpochNumberSchema, ProofUri).returns(ProvingJobStatus)
|
|
34
|
+
};
|
|
35
|
+
export const ProvingJobBrokerSchemaWithDebug = {
|
|
36
|
+
...ProvingJobBrokerSchema,
|
|
37
|
+
...ProvingJobBrokerDebugSchema
|
|
38
|
+
};
|
|
31
39
|
export function createProvingJobBrokerClient(url, versions, fetch = makeTracedFetch([
|
|
32
40
|
1,
|
|
33
41
|
2,
|
|
@@ -19,9 +19,9 @@ export declare class TestBroker implements ProvingJobProducer {
|
|
|
19
19
|
}
|
|
20
20
|
export declare class MockProver implements ServerCircuitProver {
|
|
21
21
|
constructor();
|
|
22
|
-
getAvmProof(_inputs: AvmCircuitInputs, _signal?: AbortSignal, _epochNumber?: number): Promise<import("@aztec/stdlib/proofs").RecursiveProof<
|
|
23
|
-
getBaseParityProof(_inputs: ParityBasePrivateInputs, _signal?: AbortSignal, _epochNumber?: number): Promise<PublicInputsAndRecursiveProof<import("@aztec/stdlib/parity").ParityPublicInputs,
|
|
24
|
-
getRootParityProof(_inputs: ParityRootPrivateInputs, _signal?: AbortSignal, _epochNumber?: number): Promise<PublicInputsAndRecursiveProof<import("@aztec/stdlib/parity").ParityPublicInputs,
|
|
22
|
+
getAvmProof(_inputs: AvmCircuitInputs, _signal?: AbortSignal, _epochNumber?: number): Promise<import("@aztec/stdlib/proofs").RecursiveProof<16400>>;
|
|
23
|
+
getBaseParityProof(_inputs: ParityBasePrivateInputs, _signal?: AbortSignal, _epochNumber?: number): Promise<PublicInputsAndRecursiveProof<import("@aztec/stdlib/parity").ParityPublicInputs, 410>>;
|
|
24
|
+
getRootParityProof(_inputs: ParityRootPrivateInputs, _signal?: AbortSignal, _epochNumber?: number): Promise<PublicInputsAndRecursiveProof<import("@aztec/stdlib/parity").ParityPublicInputs, 410>>;
|
|
25
25
|
getPublicChonkVerifierProof(_inputs: PublicChonkVerifierPrivateInputs, _signal?: AbortSignal, _epochNumber?: number): Promise<PublicInputsAndRecursiveProof<PublicChonkVerifierPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>>;
|
|
26
26
|
getPrivateTxBaseRollupProof(_baseRollupInput: PrivateTxBaseRollupPrivateInputs, _signal?: AbortSignal, _epochNumber?: number): Promise<PublicInputsAndRecursiveProof<TxRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>>;
|
|
27
27
|
getPublicTxBaseRollupProof(_inputs: PublicTxBaseRollupPrivateInputs, _signal?: AbortSignal, _epochNumber?: number): Promise<PublicInputsAndRecursiveProof<TxRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>>;
|
|
@@ -31,7 +31,7 @@ export declare class MockProver implements ServerCircuitProver {
|
|
|
31
31
|
getBlockRootEmptyTxFirstRollupProof(_input: BlockRootEmptyTxFirstRollupPrivateInputs, _signal?: AbortSignal, _epochNumber?: number): Promise<PublicInputsAndRecursiveProof<BlockRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>>;
|
|
32
32
|
getBlockRootRollupProof(_input: BlockRootRollupPrivateInputs, _signal?: AbortSignal, _epochNumber?: number): Promise<PublicInputsAndRecursiveProof<BlockRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>>;
|
|
33
33
|
getBlockRootSingleTxRollupProof(_input: BlockRootSingleTxRollupPrivateInputs, _signal?: AbortSignal, _epochNumber?: number): Promise<PublicInputsAndRecursiveProof<BlockRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>>;
|
|
34
|
-
getBlockMergeRollupProof(_input: BlockMergeRollupPrivateInputs, _signal?: AbortSignal, _epochNumber?: number): Promise<PublicInputsAndRecursiveProof<BlockRollupPublicInputs,
|
|
34
|
+
getBlockMergeRollupProof(_input: BlockMergeRollupPrivateInputs, _signal?: AbortSignal, _epochNumber?: number): Promise<PublicInputsAndRecursiveProof<BlockRollupPublicInputs, 480>>;
|
|
35
35
|
getCheckpointRootRollupProof(_input: CheckpointRootRollupPrivateInputs, _signal?: AbortSignal, _epochNumber?: number): Promise<PublicInputsAndRecursiveProof<CheckpointRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>>;
|
|
36
36
|
getCheckpointRootSingleBlockRollupProof(_input: CheckpointRootSingleBlockRollupPrivateInputs, _signal?: AbortSignal, _epochNumber?: number): Promise<PublicInputsAndRecursiveProof<CheckpointRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>>;
|
|
37
37
|
getCheckpointMergeRollupProof(_input: CheckpointMergeRollupPrivateInputs, _signal?: AbortSignal, _epochNumber?: number): Promise<PublicInputsAndRecursiveProof<CheckpointRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/prover-client",
|
|
3
|
-
"version": "0.0.1-commit.
|
|
3
|
+
"version": "0.0.1-commit.c2eed6949",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"build:dev": "../scripts/tsc.sh --watch",
|
|
28
28
|
"clean": "rm -rf ./dest .tsbuildinfo",
|
|
29
29
|
"bb": "node --no-warnings ./dest/bb/index.js",
|
|
30
|
-
"test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --testTimeout=3500000
|
|
31
|
-
"test:debug": "LOG_LEVEL=debug NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --testTimeout=1500000 --
|
|
30
|
+
"test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --testTimeout=3500000",
|
|
31
|
+
"test:debug": "LOG_LEVEL=debug NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --testTimeout=1500000 --testNamePattern prover/bb_prover/parity"
|
|
32
32
|
},
|
|
33
33
|
"jest": {
|
|
34
34
|
"moduleNameMapper": {
|
|
@@ -68,20 +68,19 @@
|
|
|
68
68
|
]
|
|
69
69
|
},
|
|
70
70
|
"dependencies": {
|
|
71
|
-
"@aztec/bb-prover": "0.0.1-commit.
|
|
72
|
-
"@aztec/blob-lib": "0.0.1-commit.
|
|
73
|
-
"@aztec/constants": "0.0.1-commit.
|
|
74
|
-
"@aztec/ethereum": "0.0.1-commit.
|
|
75
|
-
"@aztec/foundation": "0.0.1-commit.
|
|
76
|
-
"@aztec/kv-store": "0.0.1-commit.
|
|
77
|
-
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.
|
|
78
|
-
"@aztec/noir-types": "0.0.1-commit.
|
|
79
|
-
"@aztec/protocol-contracts": "0.0.1-commit.
|
|
80
|
-
"@aztec/simulator": "0.0.1-commit.
|
|
81
|
-
"@aztec/stdlib": "0.0.1-commit.
|
|
82
|
-
"@aztec/telemetry-client": "0.0.1-commit.
|
|
83
|
-
"@aztec/world-state": "0.0.1-commit.
|
|
84
|
-
"@google-cloud/storage": "^7.15.0",
|
|
71
|
+
"@aztec/bb-prover": "0.0.1-commit.c2eed6949",
|
|
72
|
+
"@aztec/blob-lib": "0.0.1-commit.c2eed6949",
|
|
73
|
+
"@aztec/constants": "0.0.1-commit.c2eed6949",
|
|
74
|
+
"@aztec/ethereum": "0.0.1-commit.c2eed6949",
|
|
75
|
+
"@aztec/foundation": "0.0.1-commit.c2eed6949",
|
|
76
|
+
"@aztec/kv-store": "0.0.1-commit.c2eed6949",
|
|
77
|
+
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.c2eed6949",
|
|
78
|
+
"@aztec/noir-types": "0.0.1-commit.c2eed6949",
|
|
79
|
+
"@aztec/protocol-contracts": "0.0.1-commit.c2eed6949",
|
|
80
|
+
"@aztec/simulator": "0.0.1-commit.c2eed6949",
|
|
81
|
+
"@aztec/stdlib": "0.0.1-commit.c2eed6949",
|
|
82
|
+
"@aztec/telemetry-client": "0.0.1-commit.c2eed6949",
|
|
83
|
+
"@aztec/world-state": "0.0.1-commit.c2eed6949",
|
|
85
84
|
"@iarna/toml": "^2.2.5",
|
|
86
85
|
"commander": "^12.1.0",
|
|
87
86
|
"lodash.chunk": "^4.2.0",
|
|
@@ -90,7 +89,7 @@
|
|
|
90
89
|
"zod": "^3.23.8"
|
|
91
90
|
},
|
|
92
91
|
"devDependencies": {
|
|
93
|
-
"@aztec/noir-contracts.js": "0.0.1-commit.
|
|
92
|
+
"@aztec/noir-contracts.js": "0.0.1-commit.c2eed6949",
|
|
94
93
|
"@jest/globals": "^30.0.0",
|
|
95
94
|
"@types/jest": "^30.0.0",
|
|
96
95
|
"@types/node": "^22.15.17",
|
package/src/config.ts
CHANGED
|
@@ -44,14 +44,25 @@ export const bbConfigMappings: ConfigMappingsType<BBConfig & ACVMConfig> = {
|
|
|
44
44
|
},
|
|
45
45
|
numConcurrentIVCVerifiers: {
|
|
46
46
|
env: 'BB_NUM_IVC_VERIFIERS',
|
|
47
|
-
description: 'Max
|
|
47
|
+
description: 'Max concurrent verifications for the RPC verifier (QueuedIVCVerifier).',
|
|
48
48
|
...numberConfigHelper(8),
|
|
49
49
|
},
|
|
50
50
|
bbIVCConcurrency: {
|
|
51
51
|
env: 'BB_IVC_CONCURRENCY',
|
|
52
|
-
description: '
|
|
52
|
+
description: 'Thread count for the RPC IVC verifier.',
|
|
53
53
|
...numberConfigHelper(1),
|
|
54
54
|
},
|
|
55
|
+
bbChonkVerifyMaxBatch: {
|
|
56
|
+
env: 'BB_CHONK_VERIFY_MAX_BATCH',
|
|
57
|
+
description:
|
|
58
|
+
'Upper bound on proofs per batch for the peer chonk batch verifier. Proofs are verified immediately as they arrive; this only caps how many can accumulate while a batch is already being processed.',
|
|
59
|
+
...numberConfigHelper(16),
|
|
60
|
+
},
|
|
61
|
+
bbChonkVerifyConcurrency: {
|
|
62
|
+
env: 'BB_CHONK_VERIFY_BATCH_CONCURRENCY',
|
|
63
|
+
description: 'Thread count for the peer batch verifier parallel reduce. 0 = auto.',
|
|
64
|
+
...numberConfigHelper(6),
|
|
65
|
+
},
|
|
55
66
|
};
|
|
56
67
|
|
|
57
68
|
export const proverClientConfigMappings: ConfigMappingsType<ProverClientUserConfig> = {
|
|
@@ -4,6 +4,7 @@ import { type CheckpointNumber, IndexWithinCheckpoint } from '@aztec/foundation/
|
|
|
4
4
|
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
5
5
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
6
6
|
import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
7
|
+
import { elapsed } from '@aztec/foundation/timer';
|
|
7
8
|
import { L2Block } from '@aztec/stdlib/block';
|
|
8
9
|
import { Checkpoint } from '@aztec/stdlib/checkpoint';
|
|
9
10
|
import type { MerkleTreeWriteOperations } from '@aztec/stdlib/interfaces/server';
|
|
@@ -44,6 +45,7 @@ export class LightweightCheckpointBuilder {
|
|
|
44
45
|
constructor(
|
|
45
46
|
public readonly checkpointNumber: CheckpointNumber,
|
|
46
47
|
public readonly constants: CheckpointGlobalVariables,
|
|
48
|
+
public feeAssetPriceModifier: bigint,
|
|
47
49
|
public readonly l1ToL2Messages: Fr[],
|
|
48
50
|
private readonly previousCheckpointOutHashes: Fr[],
|
|
49
51
|
public readonly db: MerkleTreeWriteOperations,
|
|
@@ -54,7 +56,7 @@ export class LightweightCheckpointBuilder {
|
|
|
54
56
|
instanceId: `checkpoint-${checkpointNumber}`,
|
|
55
57
|
});
|
|
56
58
|
this.spongeBlob = SpongeBlob.init();
|
|
57
|
-
this.logger.debug('Starting new checkpoint', { constants, l1ToL2Messages });
|
|
59
|
+
this.logger.debug('Starting new checkpoint', { constants, l1ToL2Messages, feeAssetPriceModifier });
|
|
58
60
|
}
|
|
59
61
|
|
|
60
62
|
static async startNewCheckpoint(
|
|
@@ -64,6 +66,7 @@ export class LightweightCheckpointBuilder {
|
|
|
64
66
|
previousCheckpointOutHashes: Fr[],
|
|
65
67
|
db: MerkleTreeWriteOperations,
|
|
66
68
|
bindings?: LoggerBindings,
|
|
69
|
+
feeAssetPriceModifier: bigint = 0n,
|
|
67
70
|
): Promise<LightweightCheckpointBuilder> {
|
|
68
71
|
// Insert l1-to-l2 messages into the tree.
|
|
69
72
|
await db.appendLeaves(
|
|
@@ -74,6 +77,7 @@ export class LightweightCheckpointBuilder {
|
|
|
74
77
|
return new LightweightCheckpointBuilder(
|
|
75
78
|
checkpointNumber,
|
|
76
79
|
constants,
|
|
80
|
+
feeAssetPriceModifier,
|
|
77
81
|
l1ToL2Messages,
|
|
78
82
|
previousCheckpointOutHashes,
|
|
79
83
|
db,
|
|
@@ -90,6 +94,7 @@ export class LightweightCheckpointBuilder {
|
|
|
90
94
|
static async resumeCheckpoint(
|
|
91
95
|
checkpointNumber: CheckpointNumber,
|
|
92
96
|
constants: CheckpointGlobalVariables,
|
|
97
|
+
feeAssetPriceModifier: bigint,
|
|
93
98
|
l1ToL2Messages: Fr[],
|
|
94
99
|
previousCheckpointOutHashes: Fr[],
|
|
95
100
|
db: MerkleTreeWriteOperations,
|
|
@@ -99,6 +104,7 @@ export class LightweightCheckpointBuilder {
|
|
|
99
104
|
const builder = new LightweightCheckpointBuilder(
|
|
100
105
|
checkpointNumber,
|
|
101
106
|
constants,
|
|
107
|
+
feeAssetPriceModifier,
|
|
102
108
|
l1ToL2Messages,
|
|
103
109
|
previousCheckpointOutHashes,
|
|
104
110
|
db,
|
|
@@ -143,6 +149,15 @@ export class LightweightCheckpointBuilder {
|
|
|
143
149
|
return builder;
|
|
144
150
|
}
|
|
145
151
|
|
|
152
|
+
/** Returns how many blocks have been added to this checkpoint so far */
|
|
153
|
+
public getBlockCount() {
|
|
154
|
+
return this.blocks.length;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
public getBlocks() {
|
|
158
|
+
return this.blocks;
|
|
159
|
+
}
|
|
160
|
+
|
|
146
161
|
/**
|
|
147
162
|
* Adds a new block to the checkpoint. The tx effects must have already been inserted into the db if
|
|
148
163
|
* this is called after tx processing, if that's not the case, then set `insertTxsEffects` to true.
|
|
@@ -151,7 +166,8 @@ export class LightweightCheckpointBuilder {
|
|
|
151
166
|
globalVariables: GlobalVariables,
|
|
152
167
|
txs: ProcessedTx[],
|
|
153
168
|
opts: { insertTxsEffects?: boolean; expectedEndState?: StateReference } = {},
|
|
154
|
-
): Promise<L2Block> {
|
|
169
|
+
): Promise<{ block: L2Block; timings: Record<string, number> }> {
|
|
170
|
+
const timings: Record<string, number> = {};
|
|
155
171
|
const isFirstBlock = this.blocks.length === 0;
|
|
156
172
|
|
|
157
173
|
// Empty blocks are only allowed as the first block in a checkpoint
|
|
@@ -160,7 +176,9 @@ export class LightweightCheckpointBuilder {
|
|
|
160
176
|
}
|
|
161
177
|
|
|
162
178
|
if (isFirstBlock) {
|
|
163
|
-
|
|
179
|
+
const [msGetInitialArchive, initialArchive] = await elapsed(() => getTreeSnapshot(MerkleTreeId.ARCHIVE, this.db));
|
|
180
|
+
this.lastArchives.push(initialArchive);
|
|
181
|
+
timings.getInitialArchive = msGetInitialArchive;
|
|
164
182
|
}
|
|
165
183
|
|
|
166
184
|
const lastArchive = this.lastArchives.at(-1)!;
|
|
@@ -170,12 +188,17 @@ export class LightweightCheckpointBuilder {
|
|
|
170
188
|
`Inserting side effects for ${txs.length} txs for block ${globalVariables.blockNumber} into db`,
|
|
171
189
|
{ txs: txs.map(tx => tx.hash.toString()) },
|
|
172
190
|
);
|
|
191
|
+
let msInsertSideEffects = 0;
|
|
173
192
|
for (const tx of txs) {
|
|
174
|
-
await insertSideEffects(tx, this.db);
|
|
193
|
+
const [ms] = await elapsed(() => insertSideEffects(tx, this.db));
|
|
194
|
+
msInsertSideEffects += ms;
|
|
175
195
|
}
|
|
196
|
+
timings.insertSideEffects = msInsertSideEffects;
|
|
176
197
|
}
|
|
177
198
|
|
|
178
|
-
const endState = await this.db.getStateReference();
|
|
199
|
+
const [msGetEndState, endState] = await elapsed(() => this.db.getStateReference());
|
|
200
|
+
timings.getEndState = msGetEndState;
|
|
201
|
+
|
|
179
202
|
if (opts.expectedEndState && !endState.equals(opts.expectedEndState)) {
|
|
180
203
|
this.logger.error('End state after processing txs does not match expected end state', {
|
|
181
204
|
globalVariables: globalVariables.toInspect(),
|
|
@@ -185,26 +208,31 @@ export class LightweightCheckpointBuilder {
|
|
|
185
208
|
throw new Error(`End state does not match expected end state when building block ${globalVariables.blockNumber}`);
|
|
186
209
|
}
|
|
187
210
|
|
|
188
|
-
const { header, body, blockBlobFields } = await
|
|
189
|
-
txs,
|
|
190
|
-
lastArchive,
|
|
191
|
-
endState,
|
|
192
|
-
globalVariables,
|
|
193
|
-
this.spongeBlob,
|
|
194
|
-
isFirstBlock,
|
|
211
|
+
const [msBuildHeaderAndBody, { header, body, blockBlobFields }] = await elapsed(() =>
|
|
212
|
+
buildHeaderAndBodyFromTxs(txs, lastArchive, endState, globalVariables, this.spongeBlob, isFirstBlock),
|
|
195
213
|
);
|
|
214
|
+
timings.buildHeaderAndBody = msBuildHeaderAndBody;
|
|
196
215
|
|
|
197
216
|
header.state.validate();
|
|
198
217
|
|
|
199
218
|
await this.db.updateArchive(header);
|
|
200
|
-
const newArchive = await getTreeSnapshot(MerkleTreeId.ARCHIVE, this.db);
|
|
219
|
+
const [msUpdateArchive, newArchive] = await elapsed(() => getTreeSnapshot(MerkleTreeId.ARCHIVE, this.db));
|
|
220
|
+
timings.updateArchive = msUpdateArchive;
|
|
201
221
|
this.lastArchives.push(newArchive);
|
|
202
222
|
|
|
223
|
+
const expectedNextLeafIndex = Number(globalVariables.blockNumber) + 1;
|
|
224
|
+
if (newArchive.nextAvailableLeafIndex !== expectedNextLeafIndex) {
|
|
225
|
+
throw new Error(
|
|
226
|
+
`Archive tree next leaf index mismatch after building block ${globalVariables.blockNumber} (expected ${expectedNextLeafIndex} but got ${newArchive.nextAvailableLeafIndex})`,
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
|
|
203
230
|
const indexWithinCheckpoint = IndexWithinCheckpoint(this.blocks.length);
|
|
204
231
|
const block = new L2Block(newArchive, header, body, this.checkpointNumber, indexWithinCheckpoint);
|
|
205
232
|
this.blocks.push(block);
|
|
206
233
|
|
|
207
|
-
await this.spongeBlob.absorb(blockBlobFields);
|
|
234
|
+
const [msSpongeAbsorb] = await elapsed(() => this.spongeBlob.absorb(blockBlobFields));
|
|
235
|
+
timings.spongeAbsorb = msSpongeAbsorb;
|
|
208
236
|
this.blobFields.push(...blockBlobFields);
|
|
209
237
|
|
|
210
238
|
this.logger.debug(`Built block ${header.getBlockNumber()}`, {
|
|
@@ -215,7 +243,7 @@ export class LightweightCheckpointBuilder {
|
|
|
215
243
|
txs: block.body.txEffects.map(tx => tx.txHash.toString()),
|
|
216
244
|
});
|
|
217
245
|
|
|
218
|
-
return block;
|
|
246
|
+
return { block, timings };
|
|
219
247
|
}
|
|
220
248
|
|
|
221
249
|
async completeCheckpoint(): Promise<Checkpoint> {
|
|
@@ -232,7 +260,7 @@ export class LightweightCheckpointBuilder {
|
|
|
232
260
|
|
|
233
261
|
const newArchive = this.lastArchives[this.lastArchives.length - 1];
|
|
234
262
|
|
|
235
|
-
const blobs = getBlobsPerL1Block(this.blobFields);
|
|
263
|
+
const blobs = await getBlobsPerL1Block(this.blobFields);
|
|
236
264
|
const blobsHash = computeBlobsHashFromBlobs(blobs);
|
|
237
265
|
|
|
238
266
|
const inHash = computeInHashFromL1ToL2Messages(this.l1ToL2Messages);
|
|
@@ -243,8 +271,7 @@ export class LightweightCheckpointBuilder {
|
|
|
243
271
|
);
|
|
244
272
|
const epochOutHash = accumulateCheckpointOutHashes([...this.previousCheckpointOutHashes, checkpointOutHash]);
|
|
245
273
|
|
|
246
|
-
//
|
|
247
|
-
// timestamp of a checkpoint is the timestamp of the last block in the checkpoint.
|
|
274
|
+
// All blocks in the checkpoint have the same timestamp
|
|
248
275
|
const timestamp = blocks[blocks.length - 1].timestamp;
|
|
249
276
|
|
|
250
277
|
const totalManaUsed = blocks.reduce((acc, block) => acc.add(block.header.totalManaUsed), Fr.ZERO);
|
|
@@ -263,13 +290,14 @@ export class LightweightCheckpointBuilder {
|
|
|
263
290
|
totalManaUsed,
|
|
264
291
|
});
|
|
265
292
|
|
|
266
|
-
return new Checkpoint(newArchive, header, blocks, this.checkpointNumber);
|
|
293
|
+
return new Checkpoint(newArchive, header, blocks, this.checkpointNumber, this.feeAssetPriceModifier);
|
|
267
294
|
}
|
|
268
295
|
|
|
269
296
|
clone() {
|
|
270
297
|
const clone = new LightweightCheckpointBuilder(
|
|
271
298
|
this.checkpointNumber,
|
|
272
299
|
this.constants,
|
|
300
|
+
this.feeAssetPriceModifier,
|
|
273
301
|
[...this.l1ToL2Messages],
|
|
274
302
|
[...this.previousCheckpointOutHashes],
|
|
275
303
|
this.db,
|
|
@@ -104,8 +104,10 @@ export class TestContext {
|
|
|
104
104
|
bbBinaryPath: config.expectedBBPath,
|
|
105
105
|
bbWorkingDirectory: config.bbWorkingDirectory,
|
|
106
106
|
bbSkipCleanup: config.bbSkipCleanup,
|
|
107
|
-
numConcurrentIVCVerifiers:
|
|
107
|
+
numConcurrentIVCVerifiers: 8,
|
|
108
108
|
bbIVCConcurrency: 1,
|
|
109
|
+
bbChonkVerifyMaxBatch: 16,
|
|
110
|
+
bbChonkVerifyConcurrency: 6,
|
|
109
111
|
};
|
|
110
112
|
localProver = await createProver(bbConfig);
|
|
111
113
|
}
|
|
@@ -116,7 +118,7 @@ export class TestContext {
|
|
|
116
118
|
|
|
117
119
|
const broker = new TestBroker(proverCount, localProver);
|
|
118
120
|
const facade = new BrokerCircuitProverFacade(broker);
|
|
119
|
-
const orchestrator = new TestProvingOrchestrator(ws, facade, EthAddress.ZERO);
|
|
121
|
+
const orchestrator = new TestProvingOrchestrator(ws, facade, EthAddress.ZERO, false, 10);
|
|
120
122
|
|
|
121
123
|
await broker.start();
|
|
122
124
|
facade.start();
|
|
@@ -250,7 +252,7 @@ export class TestContext {
|
|
|
250
252
|
const previousCheckpointOutHashes = this.checkpointOutHashes;
|
|
251
253
|
const builder = await LightweightCheckpointBuilder.startNewCheckpoint(
|
|
252
254
|
checkpointNumber,
|
|
253
|
-
constants,
|
|
255
|
+
{ ...constants, timestamp },
|
|
254
256
|
l1ToL2Messages,
|
|
255
257
|
previousCheckpointOutHashes,
|
|
256
258
|
cleanFork,
|
|
@@ -262,7 +264,7 @@ export class TestContext {
|
|
|
262
264
|
const txs = blockTxs[i];
|
|
263
265
|
const state = blockEndStates[i];
|
|
264
266
|
|
|
265
|
-
const block = await builder.addBlock(blockGlobalVariables[i], txs, {
|
|
267
|
+
const { block } = await builder.addBlock(blockGlobalVariables[i], txs, {
|
|
266
268
|
expectedEndState: state,
|
|
267
269
|
insertTxsEffects: true,
|
|
268
270
|
});
|
|
@@ -253,8 +253,8 @@ export function getPublicChonkVerifierPrivateInputsFromTx(tx: Tx | ProcessedTx,
|
|
|
253
253
|
// Build "hints" as the private inputs for the checkpoint root rollup circuit.
|
|
254
254
|
// The `blobCommitments` will be accumulated and checked in the root rollup against the `finalBlobChallenges`.
|
|
255
255
|
// The `blobsHash` will be validated on L1 against the submitted blob data.
|
|
256
|
-
export const buildBlobHints = (blobFields: Fr[]) => {
|
|
257
|
-
const blobs = getBlobsPerL1Block(blobFields);
|
|
256
|
+
export const buildBlobHints = async (blobFields: Fr[]) => {
|
|
257
|
+
const blobs = await getBlobsPerL1Block(blobFields);
|
|
258
258
|
const blobCommitments = getBlobCommitmentsFromBlobs(blobs);
|
|
259
259
|
const blobsHash = computeBlobsHashFromBlobs(blobs);
|
|
260
260
|
return { blobCommitments, blobs, blobsHash };
|
|
@@ -55,6 +55,7 @@ export class BlockProvingState {
|
|
|
55
55
|
| ProofState<BlockRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>
|
|
56
56
|
| undefined;
|
|
57
57
|
private builtBlockHeader: BlockHeader | undefined;
|
|
58
|
+
private builtArchive: AppendOnlyTreeSnapshot | undefined;
|
|
58
59
|
private endState: StateReference | undefined;
|
|
59
60
|
private endSpongeBlob: SpongeBlob | undefined;
|
|
60
61
|
private txs: TxProvingState[] = [];
|
|
@@ -232,6 +233,14 @@ export class BlockProvingState {
|
|
|
232
233
|
return this.builtBlockHeader;
|
|
233
234
|
}
|
|
234
235
|
|
|
236
|
+
public setBuiltArchive(archive: AppendOnlyTreeSnapshot) {
|
|
237
|
+
this.builtArchive = archive;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
public getBuiltArchive() {
|
|
241
|
+
return this.builtArchive;
|
|
242
|
+
}
|
|
243
|
+
|
|
235
244
|
public getStartSpongeBlob() {
|
|
236
245
|
return this.startSpongeBlob;
|
|
237
246
|
}
|
|
@@ -85,7 +85,7 @@ export class CheckpointProvingState {
|
|
|
85
85
|
typeof L1_TO_L2_MSG_SUBTREE_ROOT_SIBLING_PATH_LENGTH
|
|
86
86
|
>,
|
|
87
87
|
public parentEpoch: EpochProvingState,
|
|
88
|
-
private onBlobAccumulatorSet: (checkpoint: CheckpointProvingState) => void
|
|
88
|
+
private onBlobAccumulatorSet: (checkpoint: CheckpointProvingState) => Promise<void>,
|
|
89
89
|
) {
|
|
90
90
|
this.blockProofs = new UnbalancedTreeStore(totalNumBlocks);
|
|
91
91
|
this.firstBlockNumber = BlockNumber(headerOfLastBlockInPreviousCheckpoint.globalVariables.blockNumber + 1);
|
|
@@ -245,7 +245,7 @@ export class CheckpointProvingState {
|
|
|
245
245
|
this.endBlobAccumulator = await accumulateBlobs(this.blobFields!, startBlobAccumulator);
|
|
246
246
|
this.startBlobAccumulator = startBlobAccumulator;
|
|
247
247
|
|
|
248
|
-
this.onBlobAccumulatorSet(this);
|
|
248
|
+
await this.onBlobAccumulatorSet(this);
|
|
249
249
|
|
|
250
250
|
return this.endBlobAccumulator;
|
|
251
251
|
}
|
|
@@ -271,7 +271,7 @@ export class CheckpointProvingState {
|
|
|
271
271
|
return this.totalNumBlocks === 1 ? 'rollup-checkpoint-root-single-block' : 'rollup-checkpoint-root';
|
|
272
272
|
}
|
|
273
273
|
|
|
274
|
-
public getCheckpointRootRollupInputs() {
|
|
274
|
+
public async getCheckpointRootRollupInputs() {
|
|
275
275
|
const proofs = this.#getChildProofsForRoot();
|
|
276
276
|
const nonEmptyProofs = proofs.filter(p => !!p);
|
|
277
277
|
if (proofs.length !== nonEmptyProofs.length) {
|
|
@@ -287,7 +287,7 @@ export class CheckpointProvingState {
|
|
|
287
287
|
// `blobFields` must've been set if `startBlobAccumulator` is set (in `accumulateBlobs`).
|
|
288
288
|
const blobFields = this.blobFields!;
|
|
289
289
|
|
|
290
|
-
const { blobCommitments, blobsHash } = buildBlobHints(blobFields);
|
|
290
|
+
const { blobCommitments, blobsHash } = await buildBlobHints(blobFields);
|
|
291
291
|
|
|
292
292
|
const hints = CheckpointRootRollupHints.from({
|
|
293
293
|
previousBlockHeader: this.headerOfLastBlockInPreviousCheckpoint,
|
|
@@ -76,7 +76,7 @@ export class EpochProvingState {
|
|
|
76
76
|
public readonly epochNumber: EpochNumber,
|
|
77
77
|
public readonly totalNumCheckpoints: number,
|
|
78
78
|
private readonly finalBlobBatchingChallenges: FinalBlobBatchingChallenges,
|
|
79
|
-
private onCheckpointBlobAccumulatorSet: (checkpoint: CheckpointProvingState) => void
|
|
79
|
+
private onCheckpointBlobAccumulatorSet: (checkpoint: CheckpointProvingState) => Promise<void>,
|
|
80
80
|
private completionCallback: (result: ProvingResult) => void,
|
|
81
81
|
private rejectionCallback: (reason: string) => void,
|
|
82
82
|
) {
|
|
@@ -254,9 +254,11 @@ export class EpochProvingState {
|
|
|
254
254
|
}
|
|
255
255
|
outHashes.push(outHash);
|
|
256
256
|
|
|
257
|
-
//
|
|
258
|
-
|
|
259
|
-
|
|
257
|
+
// If this is NOT the last checkpoint, get or create the hint for the next checkpoint.
|
|
258
|
+
if (i !== this.totalNumCheckpoints - 1) {
|
|
259
|
+
hint = checkpoint.getOutHashHintForNextCheckpoint() ?? (await computeOutHashHint(outHashes));
|
|
260
|
+
checkpoint.setOutHashHintForNextCheckpoint(hint);
|
|
261
|
+
}
|
|
260
262
|
}
|
|
261
263
|
}
|
|
262
264
|
|