@@ -14,7 +14,6 @@ import { ChonkCache } from '@aztec/prover-client/orchestrator';
1414import { type AvmSimulator , PublicProcessorFactory } from '@aztec/simulator/server' ;
1515import {
1616 EventDrivenL2BlockStream ,
17- type L2Block ,
1817 type L2BlockId ,
1918 type L2BlockSource ,
2019 type L2BlockStreamEvent ,
@@ -38,7 +37,6 @@ import {
3837import type { DataStoreConfig } from '@aztec/stdlib/kv-store' ;
3938import type { L1ToL2MessageSource } from '@aztec/stdlib/messaging' ;
4039import { MerkleTreeId } from '@aztec/stdlib/trees' ;
41- import type { BlockHeader } from '@aztec/stdlib/tx' ;
4240import {
4341 L1Metrics ,
4442 type TelemetryClient ,
@@ -352,9 +350,13 @@ export class ProverNode implements L2BlockStreamEventHandler, ProverNodeApi, Tra
352350 const previousBlockNumber = BlockNumber ( checkpoint . blocks [ 0 ] . number - 1 ) ;
353351 const previousBlockHeader = await this . gatherPreviousBlockHeader ( previousBlockNumber ) ;
354352 const lastBlock = checkpoint . blocks . at ( - 1 ) ! ;
355- // Streaming Inbox (AZIP-22 Fast Inbox): the checkpoint's consumed messages are those in the Inbox buckets between
356- // the parent checkpoint's consumed position and this checkpoint's last block (compact leaf-count range).
357- const l1ToL2Messages = await this . deriveCheckpointConsumedMessages ( previousBlockHeader , lastBlock ) ;
353+ // Streaming Inbox (AZIP-22 Fast Inbox): the checkpoint's consumed messages are those between the parent
354+ // checkpoint's consumed position and this checkpoint's last block, as a compact leaf-count range. The prover
355+ // slices them per block.
356+ const l1ToL2Messages = await this . l1ToL2MessageSource . getL1ToL2MessagesBetweenLeafCounts (
357+ BigInt ( previousBlockHeader . state . l1ToL2MessageTree . nextAvailableLeafIndex ) ,
358+ BigInt ( lastBlock . header . state . l1ToL2MessageTree . nextAvailableLeafIndex ) ,
359+ ) ;
358360 const previousInboxRollingHash = await this . gatherPreviousInboxRollingHash ( checkpoint . number ) ;
359361 const lastBlockHash = await lastBlock . header . hash ( ) ;
360362 await this . worldState . syncImmediate ( lastBlock . number , lastBlockHash ) ;
@@ -371,27 +373,6 @@ export class ProverNode implements L2BlockStreamEventHandler, ProverNodeApi, Tra
371373 } ;
372374 }
373375
374- /**
375- * Derives a checkpoint's consumed L1-to-L2 messages, in order, from the Inbox buckets between the parent
376- * checkpoint's consumed position (the block before the checkpoint's first block) and the checkpoint's last block
377- * (compact leaf counts), for the prover to slice per block (AZIP-22 Fast Inbox).
378- */
379- private async deriveCheckpointConsumedMessages ( previousBlockHeader : BlockHeader , lastBlock : L2Block ) : Promise < Fr [ ] > {
380- const startLeafCount = BigInt ( previousBlockHeader . state . l1ToL2MessageTree . nextAvailableLeafIndex ) ;
381- const endLeafCount = BigInt ( lastBlock . header . state . l1ToL2MessageTree . nextAvailableLeafIndex ) ;
382- if ( endLeafCount <= startLeafCount ) {
383- return [ ] ;
384- }
385- const startBucket = await this . l1ToL2MessageSource . getInboxBucketByTotalMsgCount ( startLeafCount ) ;
386- const endBucket = await this . l1ToL2MessageSource . getInboxBucketByTotalMsgCount ( endLeafCount ) ;
387- if ( startBucket === undefined || endBucket === undefined ) {
388- throw new Error (
389- `Cannot resolve consumed messages for checkpoint ending at block ${ lastBlock . number } from the Inbox buckets` ,
390- ) ;
391- }
392- return this . l1ToL2MessageSource . getL1ToL2MessagesBetweenBuckets ( startBucket . seq , endBucket . seq ) ;
393- }
394-
395376 /**
396377 * Sources the inbox rolling hash chain-start for a checkpoint: the previous checkpoint's `inboxRollingHash`, or zero
397378 * for the genesis checkpoint. The prover threads this into the base parity circuits so the rebuilt checkpoint header
0 commit comments