From 3eb6fcca1b7505a2d308623b3e7e658fc00d06e3 Mon Sep 17 00:00:00 2001 From: Maddiaa0 <47148561+Maddiaa0@users.noreply.github.com> Date: Mon, 7 Oct 2024 22:53:48 +0000 Subject: [PATCH 1/2] feat: store received epoch quotes --- 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 755439b5f2e..97ff650dfce 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, @@ -57,6 +58,7 @@ import { } from './reqresp/interface.js'; import { ReqResp } from './reqresp/reqresp.js'; import type { P2PService, PeerDiscoveryService } from './service.js'; +import { EpochProofQuotePool } from '../epoch_proof_quote_pool/epoch_proof_quote_pool.js'; /** * Create a libp2p peer ID from the private key if provided, otherwise creates a new random ID. @@ -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. From 2f3a3c0e3ee376698a1d7ab284d0d1b6404b57d3 Mon Sep 17 00:00:00 2001 From: Maddiaa0 <47148561+Maddiaa0@users.noreply.github.com> Date: Mon, 7 Oct 2024 22:56:04 +0000 Subject: [PATCH 2/2] fmt --- yarn-project/p2p/src/service/libp2p_service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yarn-project/p2p/src/service/libp2p_service.ts b/yarn-project/p2p/src/service/libp2p_service.ts index 97ff650dfce..b432f6eb49e 100644 --- a/yarn-project/p2p/src/service/libp2p_service.ts +++ b/yarn-project/p2p/src/service/libp2p_service.ts @@ -34,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, @@ -58,7 +59,6 @@ import { } from './reqresp/interface.js'; import { ReqResp } from './reqresp/reqresp.js'; import type { P2PService, PeerDiscoveryService } from './service.js'; -import { EpochProofQuotePool } from '../epoch_proof_quote_pool/epoch_proof_quote_pool.js'; /** * Create a libp2p peer ID from the private key if provided, otherwise creates a new random ID.