From e3b467f70ca1d41bd27ac7231e257f1329ed0896 Mon Sep 17 00:00:00 2001 From: Maddiaa <47148561+Maddiaa0@users.noreply.github.com> Date: Tue, 8 Oct 2024 13:35:20 +0100 Subject: [PATCH] chore(p2p): store received epoch quotes (#9064) ## Overview Receive epoch quotes through the p2p client and add them to the store. Testing this to see if it fixes a halt with x validators when progression halts past the first epoch --- yarn-project/p2p/src/client/index.ts | 1 + yarn-project/p2p/src/service/libp2p_service.ts | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/yarn-project/p2p/src/client/index.ts b/yarn-project/p2p/src/client/index.ts index aaafccba9f1..237bc151801 100644 --- a/yarn-project/p2p/src/client/index.ts +++ b/yarn-project/p2p/src/client/index.ts @@ -53,6 +53,7 @@ export const createP2PClient = async ( peerId, txPool, attestationsPool, + epochProofQuotePool, l2BlockSource, proofVerifier, worldStateSynchronizer, diff --git a/yarn-project/p2p/src/service/libp2p_service.ts b/yarn-project/p2p/src/service/libp2p_service.ts index c72a21b57a0..1180dffdc9f 100644 --- a/yarn-project/p2p/src/service/libp2p_service.ts +++ b/yarn-project/p2p/src/service/libp2p_service.ts @@ -2,6 +2,7 @@ import { BlockAttestation, BlockProposal, type ClientProtocolCircuitVerifier, + EpochProofQuote, type Gossipable, type L2BlockSource, MerkleTreeId, @@ -33,6 +34,7 @@ import { createLibp2p } from 'libp2p'; import { type AttestationPool } from '../attestation_pool/attestation_pool.js'; import { type P2PConfig } from '../config.js'; +import { type EpochProofQuotePool } from '../epoch_proof_quote_pool/epoch_proof_quote_pool.js'; import { type TxPool } from '../tx_pool/index.js'; import { DataTxValidator, @@ -98,6 +100,7 @@ export class LibP2PService implements P2PService { private peerDiscoveryService: PeerDiscoveryService, private txPool: TxPool, private attestationPool: AttestationPool, + private epochProofQuotePool: EpochProofQuotePool, private l2BlockSource: L2BlockSource, private proofVerifier: ClientProtocolCircuitVerifier, private worldStateSynchronizer: WorldStateSynchronizer, @@ -202,6 +205,7 @@ export class LibP2PService implements P2PService { peerId: PeerId, txPool: TxPool, attestationPool: AttestationPool, + epochProofQuotePool: EpochProofQuotePool, l2BlockSource: L2BlockSource, proofVerifier: ClientProtocolCircuitVerifier, worldStateSynchronizer: WorldStateSynchronizer, @@ -291,6 +295,7 @@ export class LibP2PService implements P2PService { peerDiscoveryService, txPool, attestationPool, + epochProofQuotePool, l2BlockSource, proofVerifier, worldStateSynchronizer, @@ -372,6 +377,10 @@ export class LibP2PService implements P2PService { const block = BlockProposal.fromBuffer(Buffer.from(message.data)); await this.processBlockFromPeer(block); } + if (message.topic == EpochProofQuote.p2pTopic) { + const epochProofQuote = EpochProofQuote.fromBuffer(Buffer.from(message.data)); + this.processEpochProofQuoteFromPeer(epochProofQuote); + } return; } @@ -404,6 +413,11 @@ export class LibP2PService implements P2PService { } } + private processEpochProofQuoteFromPeer(epochProofQuote: EpochProofQuote): void { + this.logger.verbose(`Received epoch proof quote ${epochProofQuote.p2pMessageIdentifier()} from external peer.`); + this.epochProofQuotePool.addQuote(epochProofQuote); + } + /** * Propagates provided message to peers. * @param message - The message to propagate.