Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Maddiaa0 committed Dec 13, 2024
1 parent e78a0dd commit aaba427
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions yarn-project/p2p/src/services/libp2p/libp2p_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ import {
} from '../reqresp/interface.js';
import { ReqResp } from '../reqresp/reqresp.js';
import type { P2PService, PeerDiscoveryService } from '../service.js';
import { Timer } from '@aztec/foundation/timer';

/**
* Lib P2P implementation of the P2PService interface.
Expand Down Expand Up @@ -480,9 +479,7 @@ export class LibP2PService<T extends P2PClientType> extends WithTracer implement
const txHashString = txHash.toString();
this.logger.verbose(`Received tx ${txHashString} from external peer.`);

const timer = new Timer();
const isValidTx = await this.validatePropagatedTx(tx, peerId);
this.logger.info(`\n\n\n validatePropagatedTx took ${timer.ms()}ms`);

if (isValidTx) {
await this.mempools.txPool.addTxs([tx]);
Expand All @@ -503,6 +500,9 @@ export class LibP2PService<T extends P2PClientType> extends WithTracer implement
* @param peerId - The peer ID of the peer that sent the tx.
* @returns True if the tx is valid, false otherwise.
*/
@trackSpan('Libp2pService.validateRequestedTx', (requestedTxHash, _responseTx) => ({
[Attributes.TX_HASH]: requestedTxHash.toString(),
}))
private async validateRequestedTx(requestedTxHash: TxHash, responseTx: Tx, peerId: PeerId): Promise<boolean> {


Expand All @@ -525,6 +525,9 @@ export class LibP2PService<T extends P2PClientType> extends WithTracer implement
return true;
}

@trackSpan('Libp2pService.validatePropagatedTx', tx => ({
[Attributes.TX_HASH]: tx.getTxHash().toString(),
}))
private async validatePropagatedTx(tx: Tx, peerId: PeerId): Promise<boolean> {
const blockNumber = (await this.l2BlockSource.getBlockNumber()) + 1;
// basic data validation
Expand Down

0 comments on commit aaba427

Please sign in to comment.