Skip to content

Commit

Permalink
fix: Race condition when cleaning epoch proof quotes (#10795)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
spalladino authored Dec 17, 2024
1 parent 5f11cf4 commit f540fbe
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions yarn-project/p2p/src/client/p2p_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -659,13 +659,14 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
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();
}

Expand Down

0 comments on commit f540fbe

Please sign in to comment.