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
1 change: 1 addition & 0 deletions yarn-project/archiver/src/archiver/archiver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
12 changes: 9 additions & 3 deletions yarn-project/end-to-end/src/e2e_epochs/epochs_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down