Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions yarn-project/archiver/src/archiver/archiver.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ describe('Archiver', () => {

latestBlockNum = await archiver.getBlockNumber();
expect(latestBlockNum).toEqual(numL2BlocksInTest);
expect(loggerSpy).toHaveBeenCalledWith(`No blocks to retrieve from 1 to 50`);
expect(loggerSpy).toHaveBeenCalledWith(`No blocks to retrieve from 1 to 50, no blocks on chain`);
}, 10_000);

it('handles L2 reorg', async () => {
Expand Down Expand Up @@ -399,7 +399,7 @@ describe('Archiver', () => {
latestBlockNum = await archiver.getBlockNumber();
expect(latestBlockNum).toEqual(numL2BlocksInTest);

expect(loggerSpy).toHaveBeenCalledWith(`No blocks to retrieve from 1 to 50`);
expect(loggerSpy).toHaveBeenCalledWith(`No blocks to retrieve from 1 to 50, no blocks on chain`);

// Lets take a look to see if we can find re-org stuff!
await sleep(1000);
Expand Down
17 changes: 13 additions & 4 deletions yarn-project/archiver/src/archiver/archiver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,9 @@ export class Archiver extends EventEmitter implements ArchiveSource, Traceable {
const noBlocks = localPendingBlockNumber === 0n && pendingBlockNumber === 0n;
if (noBlocks) {
await this.store.setBlockSynchedL1BlockNumber(currentL1BlockNumber);
this.log.debug(`No blocks to retrieve from ${blocksSynchedTo + 1n} to ${currentL1BlockNumber}`);
this.log.debug(
`No blocks to retrieve from ${blocksSynchedTo + 1n} to ${currentL1BlockNumber}, no blocks on chain`,
);
return { provenBlockNumber };
}

Expand All @@ -444,7 +446,14 @@ export class Archiver extends EventEmitter implements ArchiveSource, Traceable {

const noBlockSinceLast = localPendingBlock && pendingArchive === localPendingBlock.archive.root.toString();
if (noBlockSinceLast) {
await this.store.setBlockSynchedL1BlockNumber(currentL1BlockNumber);
// We believe the following line causes a problem when we encounter L1 re-orgs.
// Basically, by setting the synched L1 block number here, we are saying that we have
// processed all blocks up to the current L1 block number and we will not attempt to retrieve logs from
// this block again (or any blocks before).
// However, in the re-org scenario, our L1 node is temporarily lying to us and we end up potentially missing blocks
// We must only set this block number based on actually retrieved logs.
// TODO(https://github.com/AztecProtocol/aztec-packages/issues/8621): Tackle this properly when we handle L1 Re-orgs.
//await this.store.setBlockSynchedL1BlockNumber(currentL1BlockNumber);
this.log.debug(`No blocks to retrieve from ${blocksSynchedTo + 1n} to ${currentL1BlockNumber}`);
return { provenBlockNumber };
}
Expand Down Expand Up @@ -483,7 +492,7 @@ export class Archiver extends EventEmitter implements ArchiveSource, Traceable {
}
}

// Retrieve L2 blocks in batches. Each batch is estimated to acommodate up to L2 'blockBatchSize' blocks,
// Retrieve L2 blocks in batches. Each batch is estimated to accommodate up to L2 'blockBatchSize' blocks,
// computed using the L2 block time vs the L1 block time.
let searchStartBlock: bigint = blocksSynchedTo;
let searchEndBlock: bigint = blocksSynchedTo;
Expand All @@ -493,7 +502,7 @@ export class Archiver extends EventEmitter implements ArchiveSource, Traceable {

this.log.trace(`Retrieving L2 blocks from L1 block ${searchStartBlock} to ${searchEndBlock}`);

// TODO(md): Retreive from blob sink then from consensus client, then from peers
// TODO(md): Retrieve from blob sink then from consensus client, then from peers
const retrievedBlocks = await retrieveBlocksFromRollup(
this.rollup,
this.publicClient,
Expand Down