Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
Maddiaa0 committed Dec 18, 2024
1 parent e5ee117 commit 9f4f1e1
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type P2PValidator, PeerErrorSeverity , type BlockAttestation } from '@aztec/circuit-types';
import { type BlockAttestation, type P2PValidator, PeerErrorSeverity } from '@aztec/circuit-types';
import { type EpochCache } from '@aztec/epoch-cache';

export class AttestationValidator implements P2PValidator<BlockAttestation> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EpochProofQuote, type P2PValidator, PeerErrorSeverity } from '@aztec/circuit-types';
import { EpochCache } from '@aztec/epoch-cache';
import { type EpochProofQuote, type P2PValidator, PeerErrorSeverity } from '@aztec/circuit-types';
import { type EpochCache } from '@aztec/epoch-cache';

export class EpochProofQuoteValidator implements P2PValidator<EpochProofQuote> {
private epochCache: EpochCache;
Expand All @@ -8,15 +8,15 @@ export class EpochProofQuoteValidator implements P2PValidator<EpochProofQuote> {
this.epochCache = epochCache;
}

async validate(message: EpochProofQuote): Promise<PeerErrorSeverity | undefined> {
validate(message: EpochProofQuote): Promise<PeerErrorSeverity | undefined> {
const { epoch } = this.epochCache.getEpochAndSlotNow();

// Check that the epoch proof quote is for the current epoch
const epochToProve = message.payload.epochToProve;
if (epochToProve !== epoch && epochToProve !== epoch - 1n) {
return PeerErrorSeverity.HighToleranceError;
return Promise.resolve(PeerErrorSeverity.HighToleranceError);
}

return undefined;
return Promise.resolve(undefined);
}
}
1 change: 1 addition & 0 deletions yarn-project/p2p/src/services/libp2p/libp2p_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ export class LibP2PService<T extends P2PClientType> extends WithTracer implement

this.attestationValidator = new AttestationValidator(epochCache);
this.blockProposalValidator = new BlockProposalValidator(epochCache);
this.epochProofQuoteValidator = new EpochProofQuoteValidator(epochCache);

this.blockReceivedCallback = (block: BlockProposal): Promise<BlockAttestation | undefined> => {
this.logger.verbose(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
type ClientProtocolCircuitVerifier,
P2PClientType,
PeerErrorSeverity,
Tx,
type Tx,
type WorldStateSynchronizer,
mockTx,
} from '@aztec/circuit-types';
Expand Down Expand Up @@ -62,7 +62,9 @@ describe('Req Resp p2p client integration', () => {
epochProofQuotePool = mock<EpochProofQuotePool>();
epochCache = mock<EpochCache>();

txPool.getAllTxs.mockResolvedValue([] as unknown as Tx[]);
txPool.getAllTxs.mockImplementation(() => {
return [] as Tx[];
});
});

const getPorts = (numberOfPeers: number) => Promise.all(Array.from({ length: numberOfPeers }, () => getPort()));
Expand Down

0 comments on commit 9f4f1e1

Please sign in to comment.