diff --git a/yarn-project/archiver/src/archiver/archiver.ts b/yarn-project/archiver/src/archiver/archiver.ts index 1c91607ae4c0..b7b92fb5aed9 100644 --- a/yarn-project/archiver/src/archiver/archiver.ts +++ b/yarn-project/archiver/src/archiver/archiver.ts @@ -1155,6 +1155,7 @@ export class Archiver extends (EventEmitter as new () => ArchiverEmitter) implem // TODO(#13569): Compute proper finalized block number based on L1 finalized block. // We just force it 2 epochs worth of proven data for now. + // NOTE: update end-to-end/src/e2e_epochs/epochs_empty_blocks.test.ts as that uses finalised blocks in computations const finalizedBlockNumber = Math.max(provenBlockNumber - this.l1constants.epochDuration * 2, 0); const [latestBlockHeader, provenBlockHeader, finalizedBlockHeader] = await Promise.all([ diff --git a/yarn-project/end-to-end/src/e2e_epochs/epochs_empty_blocks.test.ts b/yarn-project/end-to-end/src/e2e_epochs/epochs_empty_blocks.test.ts index 7ecc905ea1a5..bebc7d4fd5e0 100644 --- a/yarn-project/end-to-end/src/e2e_epochs/epochs_empty_blocks.test.ts +++ b/yarn-project/end-to-end/src/e2e_epochs/epochs_empty_blocks.test.ts @@ -68,12 +68,15 @@ describe('e2e_epochs/epochs_empty_blocks', () => { epochNumber++; // Verify the state syncs - await test.waitForNodeToSync(provenBlockNumber, 'finalised'); + await test.waitForNodeToSync(provenBlockNumber, 'proven'); await test.verifyHistoricBlock(provenBlockNumber, true); - const expectedOldestHistoricBlock = provenBlockNumber - WORLD_STATE_BLOCK_HISTORY + 1; + + // right now finalisation means a block is two L2 epochs deep. If this rule changes then we need this test needs to be updated + const finalizedBlockNumber = Math.max(provenBlockNumber - context.config.aztecEpochDuration * 2, 0); + const expectedOldestHistoricBlock = Math.max(finalizedBlockNumber - WORLD_STATE_BLOCK_HISTORY + 1, 1); const expectedBlockRemoved = expectedOldestHistoricBlock - 1; await test.waitForNodeToSync(expectedOldestHistoricBlock, 'historic'); - await test.verifyHistoricBlock(Math.max(expectedOldestHistoricBlock, 1), true); + await test.verifyHistoricBlock(expectedOldestHistoricBlock, true); if (expectedBlockRemoved > 0) { await test.verifyHistoricBlock(expectedBlockRemoved, false); } diff --git a/yarn-project/end-to-end/src/e2e_epochs/epochs_test.ts b/yarn-project/end-to-end/src/e2e_epochs/epochs_test.ts index 63c2a4c17f57..50878cf05234 100644 --- a/yarn-project/end-to-end/src/e2e_epochs/epochs_test.ts +++ b/yarn-project/end-to-end/src/e2e_epochs/epochs_test.ts @@ -232,13 +232,19 @@ export class EpochsTestContext { } /** Waits for the aztec node to sync to the target block number. */ - public async waitForNodeToSync(blockNumber: number, type: 'finalised' | 'historic') { + public async waitForNodeToSync(blockNumber: number, type: 'proven' | 'finalised' | 'historic') { const waitTime = ARCHIVER_POLL_INTERVAL + WORLD_STATE_BLOCK_CHECK_INTERVAL; let synched = false; while (!synched) { await sleep(waitTime); - const syncState = await this.context.aztecNode.getWorldStateSyncStatus(); - if (type === 'finalised') { + const [syncState, tips] = await Promise.all([ + this.context.aztecNode.getWorldStateSyncStatus(), + await this.context.aztecNode.getL2Tips(), + ]); + this.logger.info(`Wait for node synch ${blockNumber} ${type}`, { blockNumber, type, syncState, tips }); + if (type === 'proven') { + synched = tips.proven.number >= blockNumber && syncState.latestBlockNumber >= blockNumber; + } else if (type === 'finalised') { synched = syncState.finalisedBlockNumber >= blockNumber; } else { synched = syncState.oldestHistoricBlockNumber >= blockNumber;