Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion yarn-project/p2p/src/client/p2p_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,17 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
* Uses the batched Request Response protocol to request a set of transactions from the network.
*/
public async requestTxsByHash(txHashes: TxHash[]): Promise<(Tx | undefined)[]> {
const txs = await this.p2pService.sendBatchRequest(ReqRespSubProtocol.TX, txHashes);
const timeoutMs = 8000; // Longer timeout for now
const maxPeers = Math.min(Math.ceil(txHashes.length / 3), 10);
const maxRetryAttempts = 10; // Keep retrying within the timeout

const txs = await this.p2pService.sendBatchRequest(
ReqRespSubProtocol.TX,
txHashes,
timeoutMs,
maxPeers,
maxRetryAttempts,
);

// Some transactions may return undefined, so we filter them out
const filteredTxs = txs.filter((tx): tx is Tx => !!tx);
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/p2p/src/services/reqresp/reqresp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ export class ReqResp {
subProtocol: SubProtocol,
requests: InstanceType<SubProtocolMap[SubProtocol]['request']>[],
timeoutMs = 10000,
maxPeers = Math.min(10, requests.length),
maxPeers = Math.max(10, Math.ceil(requests.length / 3)),
maxRetryAttempts = 3,
): Promise<(InstanceType<SubProtocolMap[SubProtocol]['response']> | undefined)[]> {
const responseValidator = this.subProtocolValidators[subProtocol];
Expand Down
3 changes: 3 additions & 0 deletions yarn-project/p2p/src/services/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ export interface P2PService {
sendBatchRequest<Protocol extends ReqRespSubProtocol>(
protocol: Protocol,
requests: InstanceType<SubProtocolMap[Protocol]['request']>[],
timeoutMs?: number,
maxPeers?: number,
maxRetryAttempts?: number,
): Promise<(InstanceType<SubProtocolMap[Protocol]['response']> | undefined)[]>;

// Leaky abstraction: fix https://github.com/AztecProtocol/aztec-packages/issues/7963
Expand Down