@aztec/prover-client 0.0.1-commit.e6bd8901 → 0.0.1-commit.ec7ac5448
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 +13 -5
- package/dest/light/lightweight_checkpoint_builder.d.ts.map +1 -1
- package/dest/light/lightweight_checkpoint_builder.js +49 -20
- package/dest/mocks/fixtures.d.ts +1 -1
- package/dest/mocks/fixtures.d.ts.map +1 -1
- package/dest/mocks/fixtures.js +2 -1
- 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 +17 -9
- 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 +3 -3
- 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 +7 -3
- package/dest/orchestrator/orchestrator.d.ts.map +1 -1
- package/dest/orchestrator/orchestrator.js +125 -117
- 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 +15 -10
- package/dest/proving_broker/broker_prover_facade.d.ts +4 -3
- package/dest/proving_broker/broker_prover_facade.d.ts.map +1 -1
- package/dest/proving_broker/broker_prover_facade.js +16 -22
- 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_agent.d.ts +4 -3
- package/dest/proving_broker/proving_agent.d.ts.map +1 -1
- package/dest/proving_broker/proving_agent.js +4 -4
- 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 +56 -8
- 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 +18 -7
- package/dest/proving_broker/proving_job_controller.d.ts +4 -3
- package/dest/proving_broker/proving_job_controller.d.ts.map +1 -1
- package/dest/proving_broker/proving_job_controller.js +6 -3
- package/dest/proving_broker/rpc.d.ts +6 -2
- package/dest/proving_broker/rpc.d.ts.map +1 -1
- package/dest/proving_broker/rpc.js +24 -15
- 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 +59 -21
- package/src/mocks/fixtures.ts +2 -1
- package/src/mocks/test_context.ts +12 -10
- package/src/orchestrator/block-building-helpers.ts +3 -3
- 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 +135 -125
- package/src/prover-client/prover-client.ts +24 -14
- package/src/proving_broker/broker_prover_facade.ts +23 -23
- 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_agent.ts +5 -2
- package/src/proving_broker/proving_broker.ts +55 -5
- package/src/proving_broker/proving_broker_instrumentation.ts +19 -6
- package/src/proving_broker/proving_job_controller.ts +9 -3
- package/src/proving_broker/rpc.ts +26 -3
- 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
|
@@ -3,7 +3,8 @@ import { NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP } from '@aztec/constants';
|
|
|
3
3
|
import { type CheckpointNumber, IndexWithinCheckpoint } from '@aztec/foundation/branded-types';
|
|
4
4
|
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
5
5
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
6
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
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';
|
|
@@ -34,7 +35,7 @@ import {
|
|
|
34
35
|
* Finally completes the checkpoint by computing its header.
|
|
35
36
|
*/
|
|
36
37
|
export class LightweightCheckpointBuilder {
|
|
37
|
-
private readonly logger
|
|
38
|
+
private readonly logger: Logger;
|
|
38
39
|
|
|
39
40
|
private lastArchives: AppendOnlyTreeSnapshot[] = [];
|
|
40
41
|
private spongeBlob: SpongeBlob;
|
|
@@ -44,12 +45,18 @@ 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,
|
|
52
|
+
bindings?: LoggerBindings,
|
|
50
53
|
) {
|
|
54
|
+
this.logger = createLogger('checkpoint-builder', {
|
|
55
|
+
...bindings,
|
|
56
|
+
instanceId: `checkpoint-${checkpointNumber}`,
|
|
57
|
+
});
|
|
51
58
|
this.spongeBlob = SpongeBlob.init();
|
|
52
|
-
this.logger.debug('Starting new checkpoint', { constants, l1ToL2Messages });
|
|
59
|
+
this.logger.debug('Starting new checkpoint', { constants, l1ToL2Messages, feeAssetPriceModifier });
|
|
53
60
|
}
|
|
54
61
|
|
|
55
62
|
static async startNewCheckpoint(
|
|
@@ -58,6 +65,8 @@ export class LightweightCheckpointBuilder {
|
|
|
58
65
|
l1ToL2Messages: Fr[],
|
|
59
66
|
previousCheckpointOutHashes: Fr[],
|
|
60
67
|
db: MerkleTreeWriteOperations,
|
|
68
|
+
bindings?: LoggerBindings,
|
|
69
|
+
feeAssetPriceModifier: bigint = 0n,
|
|
61
70
|
): Promise<LightweightCheckpointBuilder> {
|
|
62
71
|
// Insert l1-to-l2 messages into the tree.
|
|
63
72
|
await db.appendLeaves(
|
|
@@ -68,9 +77,11 @@ export class LightweightCheckpointBuilder {
|
|
|
68
77
|
return new LightweightCheckpointBuilder(
|
|
69
78
|
checkpointNumber,
|
|
70
79
|
constants,
|
|
80
|
+
feeAssetPriceModifier,
|
|
71
81
|
l1ToL2Messages,
|
|
72
82
|
previousCheckpointOutHashes,
|
|
73
83
|
db,
|
|
84
|
+
bindings,
|
|
74
85
|
);
|
|
75
86
|
}
|
|
76
87
|
|
|
@@ -83,17 +94,21 @@ export class LightweightCheckpointBuilder {
|
|
|
83
94
|
static async resumeCheckpoint(
|
|
84
95
|
checkpointNumber: CheckpointNumber,
|
|
85
96
|
constants: CheckpointGlobalVariables,
|
|
97
|
+
feeAssetPriceModifier: bigint,
|
|
86
98
|
l1ToL2Messages: Fr[],
|
|
87
99
|
previousCheckpointOutHashes: Fr[],
|
|
88
100
|
db: MerkleTreeWriteOperations,
|
|
89
101
|
existingBlocks: L2Block[],
|
|
102
|
+
bindings?: LoggerBindings,
|
|
90
103
|
): Promise<LightweightCheckpointBuilder> {
|
|
91
104
|
const builder = new LightweightCheckpointBuilder(
|
|
92
105
|
checkpointNumber,
|
|
93
106
|
constants,
|
|
107
|
+
feeAssetPriceModifier,
|
|
94
108
|
l1ToL2Messages,
|
|
95
109
|
previousCheckpointOutHashes,
|
|
96
110
|
db,
|
|
111
|
+
bindings,
|
|
97
112
|
);
|
|
98
113
|
|
|
99
114
|
builder.logger.debug('Resuming checkpoint from existing blocks', {
|
|
@@ -134,6 +149,15 @@ export class LightweightCheckpointBuilder {
|
|
|
134
149
|
return builder;
|
|
135
150
|
}
|
|
136
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
|
+
|
|
137
161
|
/**
|
|
138
162
|
* Adds a new block to the checkpoint. The tx effects must have already been inserted into the db if
|
|
139
163
|
* this is called after tx processing, if that's not the case, then set `insertTxsEffects` to true.
|
|
@@ -142,7 +166,8 @@ export class LightweightCheckpointBuilder {
|
|
|
142
166
|
globalVariables: GlobalVariables,
|
|
143
167
|
txs: ProcessedTx[],
|
|
144
168
|
opts: { insertTxsEffects?: boolean; expectedEndState?: StateReference } = {},
|
|
145
|
-
): Promise<L2Block> {
|
|
169
|
+
): Promise<{ block: L2Block; timings: Record<string, number> }> {
|
|
170
|
+
const timings: Record<string, number> = {};
|
|
146
171
|
const isFirstBlock = this.blocks.length === 0;
|
|
147
172
|
|
|
148
173
|
// Empty blocks are only allowed as the first block in a checkpoint
|
|
@@ -151,7 +176,9 @@ export class LightweightCheckpointBuilder {
|
|
|
151
176
|
}
|
|
152
177
|
|
|
153
178
|
if (isFirstBlock) {
|
|
154
|
-
|
|
179
|
+
const [msGetInitialArchive, initialArchive] = await elapsed(() => getTreeSnapshot(MerkleTreeId.ARCHIVE, this.db));
|
|
180
|
+
this.lastArchives.push(initialArchive);
|
|
181
|
+
timings.getInitialArchive = msGetInitialArchive;
|
|
155
182
|
}
|
|
156
183
|
|
|
157
184
|
const lastArchive = this.lastArchives.at(-1)!;
|
|
@@ -161,12 +188,17 @@ export class LightweightCheckpointBuilder {
|
|
|
161
188
|
`Inserting side effects for ${txs.length} txs for block ${globalVariables.blockNumber} into db`,
|
|
162
189
|
{ txs: txs.map(tx => tx.hash.toString()) },
|
|
163
190
|
);
|
|
191
|
+
let msInsertSideEffects = 0;
|
|
164
192
|
for (const tx of txs) {
|
|
165
|
-
await insertSideEffects(tx, this.db);
|
|
193
|
+
const [ms] = await elapsed(() => insertSideEffects(tx, this.db));
|
|
194
|
+
msInsertSideEffects += ms;
|
|
166
195
|
}
|
|
196
|
+
timings.insertSideEffects = msInsertSideEffects;
|
|
167
197
|
}
|
|
168
198
|
|
|
169
|
-
const endState = await this.db.getStateReference();
|
|
199
|
+
const [msGetEndState, endState] = await elapsed(() => this.db.getStateReference());
|
|
200
|
+
timings.getEndState = msGetEndState;
|
|
201
|
+
|
|
170
202
|
if (opts.expectedEndState && !endState.equals(opts.expectedEndState)) {
|
|
171
203
|
this.logger.error('End state after processing txs does not match expected end state', {
|
|
172
204
|
globalVariables: globalVariables.toInspect(),
|
|
@@ -176,26 +208,31 @@ export class LightweightCheckpointBuilder {
|
|
|
176
208
|
throw new Error(`End state does not match expected end state when building block ${globalVariables.blockNumber}`);
|
|
177
209
|
}
|
|
178
210
|
|
|
179
|
-
const { header, body, blockBlobFields } = await
|
|
180
|
-
txs,
|
|
181
|
-
lastArchive,
|
|
182
|
-
endState,
|
|
183
|
-
globalVariables,
|
|
184
|
-
this.spongeBlob,
|
|
185
|
-
isFirstBlock,
|
|
211
|
+
const [msBuildHeaderAndBody, { header, body, blockBlobFields }] = await elapsed(() =>
|
|
212
|
+
buildHeaderAndBodyFromTxs(txs, lastArchive, endState, globalVariables, this.spongeBlob, isFirstBlock),
|
|
186
213
|
);
|
|
214
|
+
timings.buildHeaderAndBody = msBuildHeaderAndBody;
|
|
187
215
|
|
|
188
216
|
header.state.validate();
|
|
189
217
|
|
|
190
218
|
await this.db.updateArchive(header);
|
|
191
|
-
const newArchive = await getTreeSnapshot(MerkleTreeId.ARCHIVE, this.db);
|
|
219
|
+
const [msUpdateArchive, newArchive] = await elapsed(() => getTreeSnapshot(MerkleTreeId.ARCHIVE, this.db));
|
|
220
|
+
timings.updateArchive = msUpdateArchive;
|
|
192
221
|
this.lastArchives.push(newArchive);
|
|
193
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
|
+
|
|
194
230
|
const indexWithinCheckpoint = IndexWithinCheckpoint(this.blocks.length);
|
|
195
231
|
const block = new L2Block(newArchive, header, body, this.checkpointNumber, indexWithinCheckpoint);
|
|
196
232
|
this.blocks.push(block);
|
|
197
233
|
|
|
198
|
-
await this.spongeBlob.absorb(blockBlobFields);
|
|
234
|
+
const [msSpongeAbsorb] = await elapsed(() => this.spongeBlob.absorb(blockBlobFields));
|
|
235
|
+
timings.spongeAbsorb = msSpongeAbsorb;
|
|
199
236
|
this.blobFields.push(...blockBlobFields);
|
|
200
237
|
|
|
201
238
|
this.logger.debug(`Built block ${header.getBlockNumber()}`, {
|
|
@@ -206,7 +243,7 @@ export class LightweightCheckpointBuilder {
|
|
|
206
243
|
txs: block.body.txEffects.map(tx => tx.txHash.toString()),
|
|
207
244
|
});
|
|
208
245
|
|
|
209
|
-
return block;
|
|
246
|
+
return { block, timings };
|
|
210
247
|
}
|
|
211
248
|
|
|
212
249
|
async completeCheckpoint(): Promise<Checkpoint> {
|
|
@@ -223,7 +260,7 @@ export class LightweightCheckpointBuilder {
|
|
|
223
260
|
|
|
224
261
|
const newArchive = this.lastArchives[this.lastArchives.length - 1];
|
|
225
262
|
|
|
226
|
-
const blobs = getBlobsPerL1Block(this.blobFields);
|
|
263
|
+
const blobs = await getBlobsPerL1Block(this.blobFields);
|
|
227
264
|
const blobsHash = computeBlobsHashFromBlobs(blobs);
|
|
228
265
|
|
|
229
266
|
const inHash = computeInHashFromL1ToL2Messages(this.l1ToL2Messages);
|
|
@@ -234,8 +271,7 @@ export class LightweightCheckpointBuilder {
|
|
|
234
271
|
);
|
|
235
272
|
const epochOutHash = accumulateCheckpointOutHashes([...this.previousCheckpointOutHashes, checkpointOutHash]);
|
|
236
273
|
|
|
237
|
-
//
|
|
238
|
-
// timestamp of a checkpoint is the timestamp of the last block in the checkpoint.
|
|
274
|
+
// All blocks in the checkpoint have the same timestamp
|
|
239
275
|
const timestamp = blocks[blocks.length - 1].timestamp;
|
|
240
276
|
|
|
241
277
|
const totalManaUsed = blocks.reduce((acc, block) => acc.add(block.header.totalManaUsed), Fr.ZERO);
|
|
@@ -254,16 +290,18 @@ export class LightweightCheckpointBuilder {
|
|
|
254
290
|
totalManaUsed,
|
|
255
291
|
});
|
|
256
292
|
|
|
257
|
-
return new Checkpoint(newArchive, header, blocks, this.checkpointNumber);
|
|
293
|
+
return new Checkpoint(newArchive, header, blocks, this.checkpointNumber, this.feeAssetPriceModifier);
|
|
258
294
|
}
|
|
259
295
|
|
|
260
296
|
clone() {
|
|
261
297
|
const clone = new LightweightCheckpointBuilder(
|
|
262
298
|
this.checkpointNumber,
|
|
263
299
|
this.constants,
|
|
300
|
+
this.feeAssetPriceModifier,
|
|
264
301
|
[...this.l1ToL2Messages],
|
|
265
302
|
[...this.previousCheckpointOutHashes],
|
|
266
303
|
this.db,
|
|
304
|
+
this.logger.getBindings(),
|
|
267
305
|
);
|
|
268
306
|
clone.lastArchives = [...this.lastArchives];
|
|
269
307
|
clone.spongeBlob = this.spongeBlob.clone();
|
package/src/mocks/fixtures.ts
CHANGED
|
@@ -75,7 +75,8 @@ export async function getSimulator(
|
|
|
75
75
|
logger?.info(
|
|
76
76
|
`Using native ACVM at ${config.acvmBinaryPath} and working directory ${config.acvmWorkingDirectory}`,
|
|
77
77
|
);
|
|
78
|
-
|
|
78
|
+
const acvmLogger = logger?.createChild('acvm-native');
|
|
79
|
+
return new NativeACVMSimulator(config.acvmWorkingDirectory, config.acvmBinaryPath, undefined, acvmLogger);
|
|
79
80
|
} catch {
|
|
80
81
|
logger?.warn(`Failed to access ACVM at ${config.acvmBinaryPath}, falling back to WASM`);
|
|
81
82
|
}
|
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
StateReference,
|
|
25
25
|
TreeSnapshots,
|
|
26
26
|
} from '@aztec/stdlib/tx';
|
|
27
|
+
import type { GenesisData } from '@aztec/stdlib/world-state';
|
|
27
28
|
import type { MerkleTreeAdminDatabase } from '@aztec/world-state';
|
|
28
29
|
import { NativeWorldStateService } from '@aztec/world-state/native';
|
|
29
30
|
|
|
@@ -84,14 +85,13 @@ export class TestContext {
|
|
|
84
85
|
const feePayer = AztecAddress.fromNumber(42222);
|
|
85
86
|
const initialFeePayerBalance = new Fr(10n ** 20n);
|
|
86
87
|
const feePayerSlot = await computeFeePayerBalanceLeafSlot(feePayer);
|
|
87
|
-
const
|
|
88
|
+
const genesis: GenesisData = {
|
|
89
|
+
prefilledPublicData: [new PublicDataTreeLeaf(feePayerSlot, initialFeePayerBalance)],
|
|
90
|
+
genesisTimestamp: 0n,
|
|
91
|
+
};
|
|
88
92
|
|
|
89
93
|
// Separated dbs for public processor and prover - see public_processor for context
|
|
90
|
-
const ws = await NativeWorldStateService.tmp(
|
|
91
|
-
/*rollupAddress=*/ undefined,
|
|
92
|
-
/*cleanupTmpDir=*/ true,
|
|
93
|
-
prefilledPublicData,
|
|
94
|
-
);
|
|
94
|
+
const ws = await NativeWorldStateService.tmp(/*rollupAddress=*/ undefined, /*cleanupTmpDir=*/ true, genesis);
|
|
95
95
|
|
|
96
96
|
let localProver: ServerCircuitProver;
|
|
97
97
|
const config = await getEnvironmentConfig(logger);
|
|
@@ -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
|
});
|
|
@@ -99,7 +99,7 @@ export const insertSideEffectsAndBuildBaseRollupHints = runInSpan(
|
|
|
99
99
|
|
|
100
100
|
const blockHash = await tx.data.constants.anchorBlockHeader.hash();
|
|
101
101
|
const anchorBlockArchiveSiblingPath = (
|
|
102
|
-
await getMembershipWitnessFor(blockHash, MerkleTreeId.ARCHIVE, ARCHIVE_HEIGHT, db)
|
|
102
|
+
await getMembershipWitnessFor(blockHash.toFr(), MerkleTreeId.ARCHIVE, ARCHIVE_HEIGHT, db)
|
|
103
103
|
).siblingPath;
|
|
104
104
|
|
|
105
105
|
const contractClassLogsFields = makeTuple(
|
|
@@ -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
|
|