From 5d143d3b8a8f1fe7c3d1df086138628bf60c66d1 Mon Sep 17 00:00:00 2001 From: Santiago Palladino Date: Tue, 17 Dec 2024 10:07:10 -0300 Subject: [PATCH] fix: Race condition when cleaning epoch proof quotes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The test `In-Memory P2P Client › deletes expired proof quotes` was sometimes failing with `epochProofQuotePool.deleteQuotesToEpoch` not being called. This could happen on a race condition where the p2p client reports to have synched to a given block number, but the quotes are deleted *after* the synched block number is set. This PR ensures setting the last block number is the last operation done. --- yarn-project/p2p/src/client/p2p_client.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/yarn-project/p2p/src/client/p2p_client.ts b/yarn-project/p2p/src/client/p2p_client.ts index d138e1e6ceb1..d93718d60f03 100644 --- a/yarn-project/p2p/src/client/p2p_client.ts +++ b/yarn-project/p2p/src/client/p2p_client.ts @@ -659,13 +659,14 @@ export class P2PClient await this.attestationPool?.deleteAttestationsOlderThan(lastBlockSlotMinusKeepAttestationsInPoolFor); } - await this.synchedProvenBlockNumber.set(lastBlockNum); - this.log.debug(`Synched to proven block ${lastBlockNum}`); const provenEpochNumber = await this.l2BlockSource.getProvenL2EpochNumber(); if (provenEpochNumber !== undefined) { this.epochProofQuotePool.deleteQuotesToEpoch(BigInt(provenEpochNumber)); } + await this.synchedProvenBlockNumber.set(lastBlockNum); + this.log.debug(`Synched to proven block ${lastBlockNum}`); + await this.startServiceIfSynched(); }