From e17f9b87a45c8c00521291c59db948f79cbf7e82 Mon Sep 17 00:00:00 2001 From: Santiago Palladino Date: Mon, 9 Dec 2024 19:15:16 -0300 Subject: [PATCH] fix: Do not attempt proof quote on empty epoch --- yarn-project/prover-node/src/prover-node.test.ts | 6 ++++++ yarn-project/prover-node/src/prover-node.ts | 7 ++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/yarn-project/prover-node/src/prover-node.test.ts b/yarn-project/prover-node/src/prover-node.test.ts index a9f4be5f2e0..98714c2e1d0 100644 --- a/yarn-project/prover-node/src/prover-node.test.ts +++ b/yarn-project/prover-node/src/prover-node.test.ts @@ -175,6 +175,12 @@ describe('prover-node', () => { expect(coordination.addEpochProofQuote).toHaveBeenCalledWith(toExpectedQuote(10n)); }); + it('does not send a quote if there are no blocks in the epoch', async () => { + l2BlockSource.getBlocksForEpoch.mockResolvedValue([]); + await proverNode.handleEpochCompleted(10n); + expect(coordination.addEpochProofQuote).not.toHaveBeenCalled(); + }); + it('does not send a quote on a finished epoch if the provider does not return one', async () => { quoteProvider.getQuote.mockResolvedValue(undefined); await proverNode.handleEpochCompleted(10n); diff --git a/yarn-project/prover-node/src/prover-node.ts b/yarn-project/prover-node/src/prover-node.ts index d4ea397d245..7f2ce07d768 100644 --- a/yarn-project/prover-node/src/prover-node.ts +++ b/yarn-project/prover-node/src/prover-node.ts @@ -128,9 +128,14 @@ export class ProverNode implements ClaimsMonitorHandler, EpochMonitorHandler, Pr try { // Construct a quote for the epoch const blocks = await this.l2BlockSource.getBlocksForEpoch(epochNumber); + if (blocks.length === 0) { + this.log.info(`No blocks found for epoch ${epochNumber}`); + return; + } + const partialQuote = await this.quoteProvider.getQuote(Number(epochNumber), blocks); if (!partialQuote) { - this.log.verbose(`No quote produced for epoch ${epochNumber}`); + this.log.info(`No quote produced for epoch ${epochNumber}`); return; }