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
Original file line number Diff line number Diff line change
Expand Up @@ -899,6 +899,22 @@ describe('CheckpointProposalJob', () => {
expect(validatorClient.collectAttestations).toHaveBeenCalled();
});

it('aborts checkpoint when syncing proposed block to archiver fails', async () => {
const { txs, block } = await setupTxsAndBlock(p2p, globalVariables, 1, chainId);
checkpointBuilder.seedBlocks([block], [txs]);

// Mock blockSink.addBlock to reject, simulating a consistency error
blockSink.addBlock.mockRejectedValue(new Error('Consistency error: block does not match world state'));

const checkpoint = await job.execute();

// The checkpoint should be aborted since the archiver sync failure now propagates
expect(checkpoint).toBeUndefined();
expect(blockSink.addBlock).toHaveBeenCalledWith(block);
// Should not attempt to collect attestations since the error aborts the loop
expect(validatorClient.collectAttestations).not.toHaveBeenCalled();
});

it('handles empty committee gracefully', async () => {
// Mock empty committee
epochCache.getCommittee.mockResolvedValue({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -464,12 +464,9 @@ export class CheckpointProposalJob implements Traceable {
blocksInCheckpoint.push(block);

// Sync the proposed block to the archiver to make it available
// Note that the checkpoint builder uses its own fork so it should not need to wait for this syncing
// Eventually we should refactor the checkpoint builder to not need a separate long-lived fork
// Fire and forget - don't block the critical path, but log errors
this.syncProposedBlockToArchiver(block).catch(err => {
this.log.error(`Failed to sync proposed block ${block.number} to archiver`, { blockNumber: block.number, err });
});
// We wait for the sync to succeed, as this helps catch consistency errors, even if it means we lose some time for block-building
// If this throws, we abort the entire checkpoint
await this.syncProposedBlockToArchiver(block);

usedTxs.forEach(tx => txHashesAlreadyIncluded.add(tx.txHash.toString()));

Expand Down
Loading