Skip to content

Commit

Permalink
chore(p2p): store received epoch quotes (#9064)
Browse files Browse the repository at this point in the history
## 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
  • Loading branch information
Maddiaa0 authored Oct 8, 2024
1 parent 077a01c commit e3b467f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions yarn-project/p2p/src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export const createP2PClient = async (
peerId,
txPool,
attestationsPool,
epochProofQuotePool,
l2BlockSource,
proofVerifier,
worldStateSynchronizer,
Expand Down
14 changes: 14 additions & 0 deletions yarn-project/p2p/src/service/libp2p_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
BlockAttestation,
BlockProposal,
type ClientProtocolCircuitVerifier,
EpochProofQuote,
type Gossipable,
type L2BlockSource,
MerkleTreeId,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -202,6 +205,7 @@ export class LibP2PService implements P2PService {
peerId: PeerId,
txPool: TxPool,
attestationPool: AttestationPool,
epochProofQuotePool: EpochProofQuotePool,
l2BlockSource: L2BlockSource,
proofVerifier: ClientProtocolCircuitVerifier,
worldStateSynchronizer: WorldStateSynchronizer,
Expand Down Expand Up @@ -291,6 +295,7 @@ export class LibP2PService implements P2PService {
peerDiscoveryService,
txPool,
attestationPool,
epochProofQuotePool,
l2BlockSource,
proofVerifier,
worldStateSynchronizer,
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit e3b467f

Please sign in to comment.