@aztec/p2p 0.87.4 → 0.87.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/client/interface.d.ts +8 -4
- package/dest/client/interface.d.ts.map +1 -1
- package/dest/client/p2p_client.d.ts +4 -3
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +17 -10
- package/dest/config.d.ts +10 -0
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +12 -2
- package/dest/index.d.ts +1 -0
- package/dest/index.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts +5 -6
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.js +37 -12
- package/dest/mem_pools/tx_pool/memory_tx_pool.d.ts +2 -2
- package/dest/mem_pools/tx_pool/memory_tx_pool.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/memory_tx_pool.js +1 -3
- package/dest/mem_pools/tx_pool/tx_pool.d.ts +6 -1
- package/dest/mem_pools/tx_pool/tx_pool.d.ts.map +1 -1
- package/dest/msg_validators/msg_seen_validator/msg_seen_validator.d.ts +10 -0
- package/dest/msg_validators/msg_seen_validator/msg_seen_validator.d.ts.map +1 -0
- package/dest/msg_validators/msg_seen_validator/msg_seen_validator.js +36 -0
- package/dest/services/dummy_service.d.ts +1 -1
- package/dest/services/dummy_service.d.ts.map +1 -1
- package/dest/services/dummy_service.js +1 -1
- package/dest/services/index.d.ts +1 -0
- package/dest/services/index.d.ts.map +1 -1
- package/dest/services/index.js +1 -0
- package/dest/services/libp2p/libp2p_service.d.ts +5 -3
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +42 -8
- package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts +1 -1
- package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts.map +1 -1
- package/dest/services/reqresp/connection-sampler/batch_connection_sampler.js +7 -3
- package/dest/services/reqresp/connection-sampler/connection_sampler.d.ts +2 -1
- package/dest/services/reqresp/connection-sampler/connection_sampler.d.ts.map +1 -1
- package/dest/services/reqresp/connection-sampler/connection_sampler.js +8 -3
- package/dest/services/reqresp/protocols/goodbye.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/goodbye.js +3 -1
- package/dest/services/reqresp/rate-limiter/rate_limiter.d.ts +4 -2
- package/dest/services/reqresp/rate-limiter/rate_limiter.d.ts.map +1 -1
- package/dest/services/reqresp/rate-limiter/rate_limiter.js +10 -2
- package/dest/services/reqresp/rate-limiter/rate_limits.js +1 -1
- package/dest/services/reqresp/reqresp.d.ts +3 -3
- package/dest/services/reqresp/reqresp.d.ts.map +1 -1
- package/dest/services/reqresp/reqresp.js +39 -13
- package/dest/services/service.d.ts +3 -2
- package/dest/services/service.d.ts.map +1 -1
- package/dest/services/tx_collector.d.ts +14 -0
- package/dest/services/tx_collector.d.ts.map +1 -0
- package/dest/services/tx_collector.js +73 -0
- package/dest/test-helpers/reqresp-nodes.d.ts +3 -3
- package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
- package/dest/test-helpers/reqresp-nodes.js +4 -4
- package/dest/testbench/p2p_client_testbench_worker.js +1 -1
- package/package.json +12 -12
- package/src/client/interface.ts +8 -4
- package/src/client/p2p_client.ts +22 -10
- package/src/config.ts +22 -1
- package/src/index.ts +2 -0
- package/src/mem_pools/tx_pool/aztec_kv_tx_pool.ts +45 -18
- package/src/mem_pools/tx_pool/memory_tx_pool.ts +2 -4
- package/src/mem_pools/tx_pool/tx_pool.ts +7 -1
- package/src/msg_validators/msg_seen_validator/msg_seen_validator.ts +36 -0
- package/src/services/dummy_service.ts +3 -1
- package/src/services/index.ts +1 -0
- package/src/services/libp2p/libp2p_service.ts +51 -9
- package/src/services/reqresp/connection-sampler/batch_connection_sampler.ts +4 -2
- package/src/services/reqresp/connection-sampler/connection_sampler.ts +8 -3
- package/src/services/reqresp/protocols/goodbye.ts +3 -1
- package/src/services/reqresp/rate-limiter/rate_limiter.ts +9 -3
- package/src/services/reqresp/rate-limiter/rate_limits.ts +1 -1
- package/src/services/reqresp/reqresp.ts +44 -16
- package/src/services/service.ts +4 -1
- package/src/services/tx_collector.ts +98 -0
- package/src/test-helpers/reqresp-nodes.ts +13 -8
- package/src/testbench/p2p_client_testbench_worker.ts +1 -1
|
@@ -14,7 +14,7 @@ import type { MemPools } from '../../mem_pools/interface.js';
|
|
|
14
14
|
import { type PubSubLibp2p } from '../../util.js';
|
|
15
15
|
import { ReqRespSubProtocol, type SubProtocolMap } from '../reqresp/interface.js';
|
|
16
16
|
import { ReqResp } from '../reqresp/reqresp.js';
|
|
17
|
-
import type { P2PService, PeerDiscoveryService } from '../service.js';
|
|
17
|
+
import type { P2PBlockReceivedCallback, P2PService, PeerDiscoveryService } from '../service.js';
|
|
18
18
|
/**
|
|
19
19
|
* Lib P2P implementation of the P2PService interface.
|
|
20
20
|
*/
|
|
@@ -31,6 +31,7 @@ export declare class LibP2PService<T extends P2PClientType = P2PClientType.Full>
|
|
|
31
31
|
private jobQueue;
|
|
32
32
|
private peerManager;
|
|
33
33
|
private discoveryRunningPromise?;
|
|
34
|
+
private msgIdSeenValidators;
|
|
34
35
|
private attestationValidator;
|
|
35
36
|
private blockProposalValidator;
|
|
36
37
|
private protocolVersion;
|
|
@@ -82,13 +83,13 @@ export declare class LibP2PService<T extends P2PClientType = P2PClientType.Full>
|
|
|
82
83
|
* @param requests - The requests to send to the peers
|
|
83
84
|
* @returns The responses to the requests
|
|
84
85
|
*/
|
|
85
|
-
sendBatchRequest<SubProtocol extends ReqRespSubProtocol>(protocol: SubProtocol, requests: InstanceType<SubProtocolMap[SubProtocol]['request']>[]): Promise<(InstanceType<SubProtocolMap[SubProtocol]['response']> | undefined)[]>;
|
|
86
|
+
sendBatchRequest<SubProtocol extends ReqRespSubProtocol>(protocol: SubProtocol, requests: InstanceType<SubProtocolMap[SubProtocol]['request']>[], pinnedPeerId: PeerId | undefined): Promise<(InstanceType<SubProtocolMap[SubProtocol]['response']> | undefined)[]>;
|
|
86
87
|
/**
|
|
87
88
|
* Get the ENR of the node
|
|
88
89
|
* @returns The ENR of the node
|
|
89
90
|
*/
|
|
90
91
|
getEnr(): ENR | undefined;
|
|
91
|
-
registerBlockReceivedCallback(callback:
|
|
92
|
+
registerBlockReceivedCallback(callback: P2PBlockReceivedCallback): void;
|
|
92
93
|
/**
|
|
93
94
|
* Subscribes to a topic.
|
|
94
95
|
* @param topic - The topic to subscribe to.
|
|
@@ -101,6 +102,7 @@ export declare class LibP2PService<T extends P2PClientType = P2PClientType.Full>
|
|
|
101
102
|
* @returns The number of recipients the data was sent to.
|
|
102
103
|
*/
|
|
103
104
|
private publishToTopic;
|
|
105
|
+
protected preValidateReceivedMessage(msg: Message, msgId: string, source: PeerId): boolean;
|
|
104
106
|
/**
|
|
105
107
|
* Handles a new gossip message that was received by the client.
|
|
106
108
|
* @param topic - The message's topic.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"libp2p_service.d.ts","sourceRoot":"","sources":["../../../src/services/libp2p/libp2p_service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAI9D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAEjE,OAAO,KAAK,EAAE,6BAA6B,EAAE,QAAQ,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AACvH,OAAO,EACL,gBAAgB,EAChB,aAAa,EACb,KAAK,UAAU,EACf,aAAa,EAOd,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,EAAE,EAAwC,MAAM,kBAAkB,CAAC;AAE5E,OAAO,EAAkC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G;YACW,wBAAwB;IAuBtC;;;;;OAKG;IAOU,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC;IAUjG;;;;;OAKG;IAIU,qBAAqB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC;IAWnF,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;YAI7B,WAAW;YAcX,UAAU;CAYzB"}
|
|
@@ -27,6 +27,7 @@ import { mplex } from '@libp2p/mplex';
|
|
|
27
27
|
import { tcp } from '@libp2p/tcp';
|
|
28
28
|
import { createLibp2p } from 'libp2p';
|
|
29
29
|
import { AttestationValidator, BlockProposalValidator } from '../../msg_validators/index.js';
|
|
30
|
+
import { MessageSeenValidator } from '../../msg_validators/msg_seen_validator/msg_seen_validator.js';
|
|
30
31
|
import { getDefaultAllowedSetupFunctions } from '../../msg_validators/tx_validator/allowed_public_setup.js';
|
|
31
32
|
import { createTxMessageValidators } from '../../msg_validators/tx_validator/factory.js';
|
|
32
33
|
import { DoubleSpendTxValidator, TxProofValidator } from '../../msg_validators/tx_validator/index.js';
|
|
@@ -57,6 +58,7 @@ import { ReqResp } from '../reqresp/reqresp.js';
|
|
|
57
58
|
jobQueue;
|
|
58
59
|
peerManager;
|
|
59
60
|
discoveryRunningPromise;
|
|
61
|
+
msgIdSeenValidators;
|
|
60
62
|
// Message validators
|
|
61
63
|
attestationValidator;
|
|
62
64
|
blockProposalValidator;
|
|
@@ -74,7 +76,10 @@ import { ReqResp } from '../reqresp/reqresp.js';
|
|
|
74
76
|
*/ blockReceivedCallback;
|
|
75
77
|
gossipSubEventHandler;
|
|
76
78
|
constructor(clientType, config, node, peerDiscoveryService, mempools, archiver, epochCache, proofVerifier, worldStateSynchronizer, telemetry, logger = createLogger('p2p:libp2p_service')){
|
|
77
|
-
super(telemetry, 'LibP2PService'), this.clientType = clientType, this.config = config, this.node = node, this.peerDiscoveryService = peerDiscoveryService, this.mempools = mempools, this.archiver = archiver, this.proofVerifier = proofVerifier, this.worldStateSynchronizer = worldStateSynchronizer, this.logger = logger, this.jobQueue = new SerialQueue(), this.protocolVersion = '', this.topicStrings = {}, this.trustedPeersIds = [];
|
|
79
|
+
super(telemetry, 'LibP2PService'), this.clientType = clientType, this.config = config, this.node = node, this.peerDiscoveryService = peerDiscoveryService, this.mempools = mempools, this.archiver = archiver, this.proofVerifier = proofVerifier, this.worldStateSynchronizer = worldStateSynchronizer, this.logger = logger, this.jobQueue = new SerialQueue(), this.msgIdSeenValidators = {}, this.protocolVersion = '', this.topicStrings = {}, this.trustedPeersIds = [];
|
|
80
|
+
this.msgIdSeenValidators[TopicType.tx] = new MessageSeenValidator(config.seenMessageCacheSize);
|
|
81
|
+
this.msgIdSeenValidators[TopicType.block_proposal] = new MessageSeenValidator(config.seenMessageCacheSize);
|
|
82
|
+
this.msgIdSeenValidators[TopicType.block_attestation] = new MessageSeenValidator(config.seenMessageCacheSize);
|
|
78
83
|
const versions = getVersions(config);
|
|
79
84
|
this.protocolVersion = compressComponentVersions(versions);
|
|
80
85
|
logger.info(`Started libp2p service with protocol version ${this.protocolVersion}`);
|
|
@@ -322,8 +327,8 @@ import { ReqResp } from '../reqresp/reqresp.js';
|
|
|
322
327
|
* @param protocol - The request response protocol to use
|
|
323
328
|
* @param requests - The requests to send to the peers
|
|
324
329
|
* @returns The responses to the requests
|
|
325
|
-
*/ sendBatchRequest(protocol, requests) {
|
|
326
|
-
return this.reqresp.sendBatchRequest(protocol, requests);
|
|
330
|
+
*/ sendBatchRequest(protocol, requests, pinnedPeerId) {
|
|
331
|
+
return this.reqresp.sendBatchRequest(protocol, requests, pinnedPeerId);
|
|
327
332
|
}
|
|
328
333
|
/**
|
|
329
334
|
* Get the ENR of the node
|
|
@@ -333,7 +338,6 @@ import { ReqResp } from '../reqresp/reqresp.js';
|
|
|
333
338
|
}
|
|
334
339
|
registerBlockReceivedCallback(callback) {
|
|
335
340
|
this.blockReceivedCallback = callback;
|
|
336
|
-
this.logger.verbose('Block received callback registered');
|
|
337
341
|
}
|
|
338
342
|
/**
|
|
339
343
|
* Subscribes to a topic.
|
|
@@ -361,6 +365,26 @@ import { ReqResp } from '../reqresp/reqresp.js';
|
|
|
361
365
|
const result = await this.node.services.pubsub.publish(topic, p2pMessage.toMessageData());
|
|
362
366
|
return result.recipients.length;
|
|
363
367
|
}
|
|
368
|
+
preValidateReceivedMessage(msg, msgId, source) {
|
|
369
|
+
const getValidator = ()=>{
|
|
370
|
+
if (msg.topic === this.topicStrings[TopicType.tx]) {
|
|
371
|
+
return this.msgIdSeenValidators[TopicType.tx];
|
|
372
|
+
}
|
|
373
|
+
if (msg.topic === this.topicStrings[TopicType.block_attestation]) {
|
|
374
|
+
return this.msgIdSeenValidators[TopicType.block_attestation];
|
|
375
|
+
}
|
|
376
|
+
if (msg.topic === this.topicStrings[TopicType.block_proposal]) {
|
|
377
|
+
return this.msgIdSeenValidators[TopicType.block_proposal];
|
|
378
|
+
}
|
|
379
|
+
this.logger.error(`Received message on unknown topic: ${msg.topic}`);
|
|
380
|
+
};
|
|
381
|
+
const validator = getValidator();
|
|
382
|
+
if (!validator || !validator.addMessage(msgId)) {
|
|
383
|
+
this.node.services.pubsub.reportMessageValidationResult(msgId, source.toString(), TopicValidatorResult.Ignore);
|
|
384
|
+
return false;
|
|
385
|
+
}
|
|
386
|
+
return true;
|
|
387
|
+
}
|
|
364
388
|
/**
|
|
365
389
|
* Handles a new gossip message that was received by the client.
|
|
366
390
|
* @param topic - The message's topic.
|
|
@@ -374,6 +398,9 @@ import { ReqResp } from '../reqresp/reqresp.js';
|
|
|
374
398
|
messageId: p2pMessage.id,
|
|
375
399
|
messageLatency
|
|
376
400
|
});
|
|
401
|
+
if (!this.preValidateReceivedMessage(msg, msgId, source)) {
|
|
402
|
+
return;
|
|
403
|
+
}
|
|
377
404
|
if (msg.topic === this.topicStrings[TopicType.tx]) {
|
|
378
405
|
await this.handleGossipedTx(p2pMessage.payload, msgId, source);
|
|
379
406
|
}
|
|
@@ -467,19 +494,26 @@ import { ReqResp } from '../reqresp/reqresp.js';
|
|
|
467
494
|
if (!result || !block) {
|
|
468
495
|
return;
|
|
469
496
|
}
|
|
470
|
-
await this.processValidBlockProposal(block);
|
|
497
|
+
await this.processValidBlockProposal(block, source);
|
|
471
498
|
}
|
|
472
499
|
// REVIEW: callback pattern https://github.com/AztecProtocol/aztec-packages/issues/7963
|
|
473
|
-
async processValidBlockProposal(block) {
|
|
474
|
-
|
|
500
|
+
async processValidBlockProposal(block, sender) {
|
|
501
|
+
const slot = block.slotNumber.toBigInt();
|
|
502
|
+
const previousSlot = slot - 1n;
|
|
503
|
+
const epoch = slot / 32n;
|
|
504
|
+
this.logger.verbose(`Received block ${block.blockNumber.toNumber()} for slot ${slot}, epoch ${epoch} from external peer.`, {
|
|
475
505
|
p2pMessageIdentifier: await block.p2pMessageIdentifier(),
|
|
476
506
|
slot: block.slotNumber.toNumber(),
|
|
477
507
|
archive: block.archive.toString(),
|
|
478
508
|
block: block.blockNumber.toNumber()
|
|
479
509
|
});
|
|
510
|
+
const attestationsForPreviousSlot = await this.mempools.attestationPool?.getAttestationsForSlot(previousSlot);
|
|
511
|
+
if (attestationsForPreviousSlot !== undefined) {
|
|
512
|
+
this.logger.verbose(`Received ${attestationsForPreviousSlot.length} attestations for slot ${previousSlot}`);
|
|
513
|
+
}
|
|
480
514
|
// Mark the txs in this proposal as non-evictable
|
|
481
515
|
await this.mempools.txPool.markTxsAsNonEvictable(block.payload.txHashes);
|
|
482
|
-
const attestation = await this.blockReceivedCallback(block);
|
|
516
|
+
const attestation = await this.blockReceivedCallback(block, sender);
|
|
483
517
|
// TODO: fix up this pattern - the abstraction is not nice
|
|
484
518
|
// The attestation can be undefined if no handler is registered / the validator deems the block invalid
|
|
485
519
|
if (attestation != undefined) {
|
|
@@ -18,7 +18,7 @@ export declare class BatchConnectionSampler {
|
|
|
18
18
|
private readonly logger;
|
|
19
19
|
private readonly batch;
|
|
20
20
|
private readonly requestsPerPeer;
|
|
21
|
-
constructor(connectionSampler: ConnectionSampler, batchSize: number, maxPeers: number);
|
|
21
|
+
constructor(connectionSampler: ConnectionSampler, batchSize: number, maxPeers: number, exclude?: PeerId[]);
|
|
22
22
|
/**
|
|
23
23
|
* Gets the peer responsible for handling a specific request index
|
|
24
24
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"batch_connection_sampler.d.ts","sourceRoot":"","sources":["../../../../src/services/reqresp/connection-sampler/batch_connection_sampler.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAEjE;;;;;;;;;;;;GAYG;AACH,qBAAa,sBAAsB;IAM/B,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IALpC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAwD;IAC/E,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAgB;IACtC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAS;gBAGtB,iBAAiB,EAAE,iBAAiB,EACrD,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM;
|
|
1
|
+
{"version":3,"file":"batch_connection_sampler.d.ts","sourceRoot":"","sources":["../../../../src/services/reqresp/connection-sampler/batch_connection_sampler.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAEjE;;;;;;;;;;;;GAYG;AACH,qBAAa,sBAAsB;IAM/B,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IALpC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAwD;IAC/E,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAgB;IACtC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAS;gBAGtB,iBAAiB,EAAE,iBAAiB,EACrD,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,MAAM,EAAE;IAiBpB;;;;;OAKG;IACH,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAUpD;;;;;OAKG;IACH,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAmB1C;;OAEG;IACH,IAAI,eAAe,IAAI,MAAM,CAE5B;IAED;;OAEG;IACH,IAAI,iBAAiB,IAAI,MAAM,CAE9B;CACF"}
|
|
@@ -16,7 +16,7 @@ import { createLogger } from '@aztec/foundation/log';
|
|
|
16
16
|
logger;
|
|
17
17
|
batch;
|
|
18
18
|
requestsPerPeer;
|
|
19
|
-
constructor(connectionSampler, batchSize, maxPeers){
|
|
19
|
+
constructor(connectionSampler, batchSize, maxPeers, exclude){
|
|
20
20
|
this.connectionSampler = connectionSampler;
|
|
21
21
|
this.logger = createLogger('p2p:reqresp:batch-connection-sampler');
|
|
22
22
|
this.batch = [];
|
|
@@ -29,7 +29,11 @@ import { createLogger } from '@aztec/foundation/log';
|
|
|
29
29
|
// Calculate how many requests each peer should handle, cannot be 0
|
|
30
30
|
this.requestsPerPeer = Math.max(1, Math.floor(batchSize / maxPeers));
|
|
31
31
|
// Sample initial peers
|
|
32
|
-
|
|
32
|
+
const excluding = exclude && new Map(exclude.map((peerId)=>[
|
|
33
|
+
peerId.toString(),
|
|
34
|
+
true
|
|
35
|
+
]));
|
|
36
|
+
this.batch = this.connectionSampler.samplePeersBatch(maxPeers, excluding);
|
|
33
37
|
}
|
|
34
38
|
/**
|
|
35
39
|
* Gets the peer responsible for handling a specific request index
|
|
@@ -60,7 +64,7 @@ import { createLogger } from '@aztec/foundation/log';
|
|
|
60
64
|
true
|
|
61
65
|
]
|
|
62
66
|
]);
|
|
63
|
-
const newPeer = this.connectionSampler.getPeer(excluding);
|
|
67
|
+
const newPeer = this.connectionSampler.getPeer(excluding); // Q: Shouldn't we accumulate all excluded peers? Otherwise the sampler could return us a previously excluded peer?
|
|
64
68
|
if (newPeer) {
|
|
65
69
|
this.batch[index] = newPeer;
|
|
66
70
|
this.logger.trace('Replaced peer', {
|
|
@@ -52,9 +52,10 @@ export declare class ConnectionSampler {
|
|
|
52
52
|
* Samples a batch of unique peers from the libp2p node, prioritizing peers without active connections
|
|
53
53
|
*
|
|
54
54
|
* @param numberToSample - The number of peers to sample
|
|
55
|
+
* @param excluding - The peers to exclude from the sampling
|
|
55
56
|
* @returns Array of unique sampled peers, prioritizing those without active connections
|
|
56
57
|
*/
|
|
57
|
-
samplePeersBatch(numberToSample: number): PeerId[];
|
|
58
|
+
samplePeersBatch(numberToSample: number, excluding?: Map<string, boolean>): PeerId[];
|
|
58
59
|
/**
|
|
59
60
|
* Dials a protocol and returns the stream
|
|
60
61
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection_sampler.d.ts","sourceRoot":"","sources":["../../../../src/services/reqresp/connection-sampler/connection_sampler.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAShE,qBAAa,aAAa;IACxB,MAAM,CAAC,GAAG,EAAE,MAAM;CAGnB;AAED;;;;;;GAMG;AACH,qBAAa,iBAAiB;IAY1B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IAClC,OAAO,CAAC,QAAQ,CAAC,OAAO;IAb1B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAkD;IACzE,OAAO,CAAC,eAAe,CAAiB;IACxC,OAAO,CAAC,YAAY,CAAyB;IAE7C,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAAkC;IACzE,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA2C;IAGnE,OAAO,CAAC,SAAS,CAAkC;gBAGhC,MAAM,EAAE,MAAM,EACd,iBAAiB,GAAE,MAAc,EAAE,sBAAsB;IACzD,OAAO,GAAE,aAAmC;IAO/D;;OAEG;IACG,IAAI;IAgBV;;;;;OAKG;IACH,OAAO,CAAC,SAAS,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,GAAG,SAAS;IAO7D;;;;;;;;;;;OAWG;IACH,eAAe,CACb,KAAK,EAAE,MAAM,EAAE,EACf,SAAS,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B;QACD,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;QACzB,YAAY,EAAE,MAAM,EAAE,CAAC;KACxB;IAuCD
|
|
1
|
+
{"version":3,"file":"connection_sampler.d.ts","sourceRoot":"","sources":["../../../../src/services/reqresp/connection-sampler/connection_sampler.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAShE,qBAAa,aAAa;IACxB,MAAM,CAAC,GAAG,EAAE,MAAM;CAGnB;AAED;;;;;;GAMG;AACH,qBAAa,iBAAiB;IAY1B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IAClC,OAAO,CAAC,QAAQ,CAAC,OAAO;IAb1B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAkD;IACzE,OAAO,CAAC,eAAe,CAAiB;IACxC,OAAO,CAAC,YAAY,CAAyB;IAE7C,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAAkC;IACzE,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA2C;IAGnE,OAAO,CAAC,SAAS,CAAkC;gBAGhC,MAAM,EAAE,MAAM,EACd,iBAAiB,GAAE,MAAc,EAAE,sBAAsB;IACzD,OAAO,GAAE,aAAmC;IAO/D;;OAEG;IACG,IAAI;IAgBV;;;;;OAKG;IACH,OAAO,CAAC,SAAS,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,GAAG,SAAS;IAO7D;;;;;;;;;;;OAWG;IACH,eAAe,CACb,KAAK,EAAE,MAAM,EAAE,EACf,SAAS,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B;QACD,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;QACzB,YAAY,EAAE,MAAM,EAAE,CAAC;KACxB;IAuCD;;;;;;OAMG;IACH,gBAAgB,CAAC,cAAc,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,EAAE;IAyCpF;;;;;;OAMG;IACG,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAwCvF;;;;OAIG;IACG,KAAK,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAgC5C;;OAEG;YACW,uBAAuB;CAetC"}
|
|
@@ -117,8 +117,9 @@ export class RandomSampler {
|
|
|
117
117
|
* Samples a batch of unique peers from the libp2p node, prioritizing peers without active connections
|
|
118
118
|
*
|
|
119
119
|
* @param numberToSample - The number of peers to sample
|
|
120
|
+
* @param excluding - The peers to exclude from the sampling
|
|
120
121
|
* @returns Array of unique sampled peers, prioritizing those without active connections
|
|
121
|
-
*/ samplePeersBatch(numberToSample) {
|
|
122
|
+
*/ samplePeersBatch(numberToSample, excluding) {
|
|
122
123
|
const peers = this.libp2p.getPeers();
|
|
123
124
|
this.logger.debug('Sampling peers batch', {
|
|
124
125
|
numberToSample,
|
|
@@ -129,7 +130,7 @@ export class RandomSampler {
|
|
|
129
130
|
const batch = [];
|
|
130
131
|
const withActiveConnections = new Set();
|
|
131
132
|
for(let i = 0; i < numberToSample; i++){
|
|
132
|
-
const { peer, sampledPeers } = this.getPeerFromList(peers,
|
|
133
|
+
const { peer, sampledPeers } = this.getPeerFromList(peers, excluding);
|
|
133
134
|
if (peer) {
|
|
134
135
|
batch.push(peer);
|
|
135
136
|
}
|
|
@@ -217,7 +218,11 @@ export class RandomSampler {
|
|
|
217
218
|
protocol: stream.protocol,
|
|
218
219
|
activeConnectionsCount: updatedActiveConnectionsCount
|
|
219
220
|
});
|
|
220
|
-
|
|
221
|
+
//NOTE: All other status codes indicate closed stream.
|
|
222
|
+
//Either graceful close (closed/closing) or forced close (aborted/reset)
|
|
223
|
+
if (stream.status === 'open') {
|
|
224
|
+
await stream?.close();
|
|
225
|
+
}
|
|
221
226
|
} catch (error) {
|
|
222
227
|
this.logger.error(`Failed to close connection to peer with stream id ${streamId}`, error);
|
|
223
228
|
} finally{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"goodbye.d.ts","sourceRoot":"","sources":["../../../../src/services/reqresp/protocols/goodbye.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,EAAsB,KAAK,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AACrF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAE7C;;GAEG;AACH,oBAAY,aAAa;IACvB,0FAA0F;IAC1F,QAAQ,IAAM;IACd,sIAAsI;IACtI,SAAS,IAAM;IACf,gFAAgF;IAChF,SAAS,IAAM;IACf,2EAA2E;IAC3E,MAAM,IAAM;IACZ,2BAA2B;IAC3B,aAAa,IAAM;IACnB,qBAAqB;IACrB,OAAO,IAAM;CACd;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CAEjE;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa,CASjE;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,M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AC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;CAQ/E;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,WAAW,GAAG,yBAAyB,CAWrF"}
|
|
@@ -79,7 +79,9 @@ export function decodeGoodbyeReason(buffer) {
|
|
|
79
79
|
return (peerId, _msg)=>{
|
|
80
80
|
const reason = decodeGoodbyeReason(_msg);
|
|
81
81
|
peerManager.goodbyeReceived(peerId, reason);
|
|
82
|
-
//
|
|
82
|
+
// NOTE: In the current implementation this won't be sent to peer,
|
|
83
|
+
// as the connection to peer has been already closed by peerManager.goodbyeReceived
|
|
84
|
+
// We have this just to satisfy interface
|
|
83
85
|
return Promise.resolve(Buffer.from([
|
|
84
86
|
0x0
|
|
85
87
|
]));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { PeerId } from '@libp2p/interface';
|
|
2
2
|
import type { PeerScoring } from '../../peer-manager/peer_scoring.js';
|
|
3
|
-
import type { ReqRespSubProtocol, ReqRespSubProtocolRateLimits } from '../interface.js';
|
|
3
|
+
import type { ProtocolRateLimitQuota, ReqRespSubProtocol, ReqRespSubProtocolRateLimits } from '../interface.js';
|
|
4
4
|
/**
|
|
5
5
|
* GCRARateLimiter: A Generic Cell Rate Algorithm (GCRA) based rate limiter.
|
|
6
6
|
*
|
|
@@ -89,8 +89,9 @@ export declare class SubProtocolRateLimiter {
|
|
|
89
89
|
export declare class RequestResponseRateLimiter {
|
|
90
90
|
private peerScoring;
|
|
91
91
|
private subProtocolRateLimiters;
|
|
92
|
+
private rateLimits;
|
|
92
93
|
private cleanupInterval;
|
|
93
|
-
constructor(peerScoring: PeerScoring, rateLimits?: ReqRespSubProtocolRateLimits);
|
|
94
|
+
constructor(peerScoring: PeerScoring, rateLimits?: Partial<ReqRespSubProtocolRateLimits>);
|
|
94
95
|
start(): void;
|
|
95
96
|
allow(subProtocol: ReqRespSubProtocol, peerId: PeerId): RateLimitStatus;
|
|
96
97
|
cleanupInactivePeers(): void;
|
|
@@ -98,5 +99,6 @@ export declare class RequestResponseRateLimiter {
|
|
|
98
99
|
* Make sure to call destroy on each of the sub protocol rate limiters when cleaning up
|
|
99
100
|
*/
|
|
100
101
|
stop(): void;
|
|
102
|
+
getRateLimits(protocol: ReqRespSubProtocol): ProtocolRateLimitQuota;
|
|
101
103
|
}
|
|
102
104
|
//# sourceMappingURL=rate_limiter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rate_limiter.d.ts","sourceRoot":"","sources":["../../../../src/services/reqresp/rate-limiter/rate_limiter.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,KAAK,EAAE,kBAAkB,EAAE,4BAA4B,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"rate_limiter.d.ts","sourceRoot":"","sources":["../../../../src/services/reqresp/rate-limiter/rate_limiter.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,KAAK,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,4BAA4B,EAAE,MAAM,iBAAiB,CAAC;AAMhH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,eAAe;IAE1B,OAAO,CAAC,GAAG,CAAS;IAEpB,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAS;IAE1C,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAS;IAEvC;;;OAGG;gBACS,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM;IAMnD,KAAK,IAAI,OAAO;CAWjB;AASD,oBAAY,eAAe;IACzB,YAAY,IAAA;IACZ,UAAU,IAAA;IACV,OAAO,IAAA;CACR;AAED,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,eAAe,6CASjE;AAED;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,sBAAsB;IACjC,OAAO,CAAC,YAAY,CAA2C;IAC/D,OAAO,CAAC,aAAa,CAAkB;IACvC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAS;IACxC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAS;gBAE7B,cAAc,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM;IAOhH,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,eAAe;IAwBtC,oBAAoB;CAQrB;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,qBAAa,0BAA0B;IAOnC,OAAO,CAAC,WAAW;IANrB,OAAO,CAAC,uBAAuB,CAAkD;IACjF,OAAO,CAAC,UAAU,CAA+B;IAEjD,OAAO,CAAC,eAAe,CAAyC;gBAGtD,WAAW,EAAE,WAAW,EAChC,UAAU,GAAE,OAAO,CAAC,4BAA4B,CAAM;IAkBxD,KAAK;IAML,KAAK,CAAC,WAAW,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,GAAG,eAAe;IAavE,oBAAoB;IAIpB;;OAEG;IACH,IAAI;IAIJ,aAAa,CAAC,QAAQ,EAAE,kBAAkB,GAAG,sBAAsB;CAGpE"}
|
|
@@ -148,12 +148,17 @@ export function prettyPrintRateLimitStatus(status) {
|
|
|
148
148
|
*/ export class RequestResponseRateLimiter {
|
|
149
149
|
peerScoring;
|
|
150
150
|
subProtocolRateLimiters;
|
|
151
|
+
rateLimits;
|
|
151
152
|
cleanupInterval;
|
|
152
|
-
constructor(peerScoring, rateLimits =
|
|
153
|
+
constructor(peerScoring, rateLimits = {}){
|
|
153
154
|
this.peerScoring = peerScoring;
|
|
154
155
|
this.cleanupInterval = undefined;
|
|
155
156
|
this.subProtocolRateLimiters = new Map();
|
|
156
|
-
|
|
157
|
+
this.rateLimits = {
|
|
158
|
+
...DEFAULT_RATE_LIMITS,
|
|
159
|
+
...rateLimits
|
|
160
|
+
};
|
|
161
|
+
for (const [subProtocol, protocolLimits] of Object.entries(this.rateLimits)){
|
|
157
162
|
this.subProtocolRateLimiters.set(subProtocol, new SubProtocolRateLimiter(protocolLimits.peerLimit.quotaCount, protocolLimits.peerLimit.quotaTimeMs, protocolLimits.globalLimit.quotaCount, protocolLimits.globalLimit.quotaTimeMs));
|
|
158
163
|
}
|
|
159
164
|
}
|
|
@@ -181,4 +186,7 @@ export function prettyPrintRateLimitStatus(status) {
|
|
|
181
186
|
*/ stop() {
|
|
182
187
|
clearInterval(this.cleanupInterval);
|
|
183
188
|
}
|
|
189
|
+
getRateLimits(protocol) {
|
|
190
|
+
return this.rateLimits[protocol];
|
|
191
|
+
}
|
|
184
192
|
}
|
|
@@ -4,7 +4,7 @@ import type { PeerId } from '@libp2p/interface';
|
|
|
4
4
|
import type { Libp2p } from 'libp2p';
|
|
5
5
|
import type { PeerScoring } from '../peer-manager/peer_scoring.js';
|
|
6
6
|
import type { P2PReqRespConfig } from './config.js';
|
|
7
|
-
import { type ReqRespResponse, ReqRespSubProtocol, type ReqRespSubProtocolHandlers, type ReqRespSubProtocolValidators, type SubProtocolMap } from './interface.js';
|
|
7
|
+
import { type ReqRespResponse, ReqRespSubProtocol, type ReqRespSubProtocolHandlers, type ReqRespSubProtocolRateLimits, type ReqRespSubProtocolValidators, type SubProtocolMap } from './interface.js';
|
|
8
8
|
/**
|
|
9
9
|
* The Request Response Service
|
|
10
10
|
*
|
|
@@ -31,7 +31,7 @@ export declare class ReqResp {
|
|
|
31
31
|
private rateLimiter;
|
|
32
32
|
private snappyTransform;
|
|
33
33
|
private metrics;
|
|
34
|
-
constructor(config: P2PReqRespConfig, libp2p: Libp2p, peerScoring: PeerScoring, telemetryClient?: TelemetryClient);
|
|
34
|
+
constructor(config: P2PReqRespConfig, libp2p: Libp2p, peerScoring: PeerScoring, rateLimits?: Partial<ReqRespSubProtocolRateLimits>, telemetryClient?: TelemetryClient);
|
|
35
35
|
get tracer(): import("@aztec/telemetry-client").Tracer;
|
|
36
36
|
/**
|
|
37
37
|
* Start the reqresp service
|
|
@@ -93,7 +93,7 @@ export declare class ReqResp {
|
|
|
93
93
|
*
|
|
94
94
|
* @throws {CollectiveReqRespTimeoutError} - If the request batch exceeds the specified timeout (`timeoutMs`).
|
|
95
95
|
*/
|
|
96
|
-
sendBatchRequest<SubProtocol extends ReqRespSubProtocol>(subProtocol: SubProtocol, requests: InstanceType<SubProtocolMap[SubProtocol]['request']>[], timeoutMs?: number, maxPeers?: number, maxRetryAttempts?: number): Promise<(InstanceType<SubProtocolMap[SubProtocol]['response']> | undefined)[]>;
|
|
96
|
+
sendBatchRequest<SubProtocol extends ReqRespSubProtocol>(subProtocol: SubProtocol, requests: InstanceType<SubProtocolMap[SubProtocol]['request']>[], pinnedPeer: PeerId | undefined, timeoutMs?: number, maxPeers?: number, maxRetryAttempts?: number): Promise<(InstanceType<SubProtocolMap[SubProtocol]['response']> | undefined)[]>;
|
|
97
97
|
/**
|
|
98
98
|
* Sends a request to a specific peer
|
|
99
99
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reqresp.d.ts","sourceRoot":"","sources":["../../../src/services/reqresp/reqresp.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"reqresp.d.ts","sourceRoot":"","sources":["../../../src/services/reqresp/reqresp.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAGlE,OAAO,EAAc,KAAK,eAAe,EAAiC,MAAM,yBAAyB,CAAC;AAE1G,OAAO,KAAK,EAAsB,MAAM,EAAU,MAAM,mBAAmB,CAAC;AAE5E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AASrC,OAAO,KAAK,EAAE,WAAW,EAA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;;;;;;;;;;;;OAqBG;IAQG,gBAAgB,CAAC,WAAW,SAAS,kBAAkB,EAC3D,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,YAAY,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,EAChE,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,SAAS,SAAQ,EACjB,QAAQ,SAA+C,EACvD,gBAAgB,SAAI,GACnB,OAAO,CAAC,CAAC,YAAY,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC,UAAU,CAAC,CAAC,GAAG,SAAS,CAAC,EAAE,CAAC;IA4IjF;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IAKU,iBAAiB,CAC5B,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,kBAAkB,EAC/B,OAAO,EAAE,MAAM,EACf,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,eAAe,CAAC;IAsC3B;;;;;;;;;OASG;IACH,OAAO,CAAC,mBAAmB;IAO3B;;OAEG;IACH,OAAO,CAAC,eAAe;IAoDvB;;;;;;OAMG;YACW,WAAW;IAoCzB;;;;;;;;;;;;;;;OAeG;YAKW,aAAa;YA0EZ,cAAc;CAI9B"}
|
|
@@ -5,6 +5,7 @@ function _ts_decorate(decorators, target, key, desc) {
|
|
|
5
5
|
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
7
|
}
|
|
8
|
+
import { compactArray } from '@aztec/foundation/collection';
|
|
8
9
|
import { createLogger } from '@aztec/foundation/log';
|
|
9
10
|
import { executeTimeout } from '@aztec/foundation/timer';
|
|
10
11
|
import { PeerErrorSeverity } from '@aztec/stdlib/p2p';
|
|
@@ -44,7 +45,7 @@ import { ReqRespStatus, ReqRespStatusError, parseStatusChunk, prettyPrintReqResp
|
|
|
44
45
|
rateLimiter;
|
|
45
46
|
snappyTransform;
|
|
46
47
|
metrics;
|
|
47
|
-
constructor(config, libp2p, peerScoring, telemetryClient = getTelemetryClient()){
|
|
48
|
+
constructor(config, libp2p, peerScoring, rateLimits = {}, telemetryClient = getTelemetryClient()){
|
|
48
49
|
this.libp2p = libp2p;
|
|
49
50
|
this.peerScoring = peerScoring;
|
|
50
51
|
this.subProtocolHandlers = DEFAULT_SUB_PROTOCOL_HANDLERS;
|
|
@@ -52,7 +53,7 @@ import { ReqRespStatus, ReqRespStatusError, parseStatusChunk, prettyPrintReqResp
|
|
|
52
53
|
this.logger = createLogger('p2p:reqresp');
|
|
53
54
|
this.overallRequestTimeoutMs = config.overallRequestTimeoutMs;
|
|
54
55
|
this.individualRequestTimeoutMs = config.individualRequestTimeoutMs;
|
|
55
|
-
this.rateLimiter = new RequestResponseRateLimiter(peerScoring);
|
|
56
|
+
this.rateLimiter = new RequestResponseRateLimiter(peerScoring, rateLimits);
|
|
56
57
|
// Connection sampler is used to sample our connected peers
|
|
57
58
|
this.connectionSampler = new ConnectionSampler(libp2p);
|
|
58
59
|
this.snappyTransform = new SnappyTransform();
|
|
@@ -185,7 +186,7 @@ import { ReqRespStatus, ReqRespStatusError, parseStatusChunk, prettyPrintReqResp
|
|
|
185
186
|
* @returns
|
|
186
187
|
*
|
|
187
188
|
* @throws {CollectiveReqRespTimeoutError} - If the request batch exceeds the specified timeout (`timeoutMs`).
|
|
188
|
-
*/ async sendBatchRequest(subProtocol, requests, timeoutMs = 10000, maxPeers = Math.max(10, Math.ceil(requests.length / 3)), maxRetryAttempts = 3) {
|
|
189
|
+
*/ async sendBatchRequest(subProtocol, requests, pinnedPeer, timeoutMs = 10000, maxPeers = Math.max(10, Math.ceil(requests.length / 3)), maxRetryAttempts = 3) {
|
|
189
190
|
const responseValidator = this.subProtocolValidators[subProtocol];
|
|
190
191
|
const responses = new Array(requests.length);
|
|
191
192
|
const requestBuffers = requests.map((req)=>req.toBuffer());
|
|
@@ -193,9 +194,11 @@ import { ReqRespStatus, ReqRespStatusError, parseStatusChunk, prettyPrintReqResp
|
|
|
193
194
|
// Track which requests still need to be processed
|
|
194
195
|
const pendingRequestIndices = new Set(requestBuffers.map((_, i)=>i));
|
|
195
196
|
// Create batch sampler with the total number of requests and max peers
|
|
196
|
-
const batchSampler = new BatchConnectionSampler(this.connectionSampler, requests.length, maxPeers
|
|
197
|
-
|
|
198
|
-
|
|
197
|
+
const batchSampler = new BatchConnectionSampler(this.connectionSampler, requests.length, maxPeers, compactArray([
|
|
198
|
+
pinnedPeer
|
|
199
|
+
]));
|
|
200
|
+
if (batchSampler.activePeerCount === 0 && !pinnedPeer) {
|
|
201
|
+
this.logger.warn('No active peers to send requests to');
|
|
199
202
|
return [];
|
|
200
203
|
}
|
|
201
204
|
// This is where it gets fun
|
|
@@ -222,6 +225,15 @@ import { ReqRespStatus, ReqRespStatusError, parseStatusChunk, prettyPrintReqResp
|
|
|
222
225
|
}
|
|
223
226
|
requestBatches.get(peerAsString).indices.push(requestIndex);
|
|
224
227
|
}
|
|
228
|
+
// If there is a pinned peer, we will always send every request to that peer
|
|
229
|
+
// We use the default limits for the subprotocol to avoid hitting the rate limiter
|
|
230
|
+
if (pinnedPeer) {
|
|
231
|
+
const limit = this.rateLimiter.getRateLimits(subProtocol).peerLimit.quotaCount;
|
|
232
|
+
requestBatches.set(pinnedPeer.toString(), {
|
|
233
|
+
peerId: pinnedPeer,
|
|
234
|
+
indices: Array.from(pendingRequestIndices.values()).slice(0, limit)
|
|
235
|
+
});
|
|
236
|
+
}
|
|
225
237
|
// Make parallel requests for each peer's batch
|
|
226
238
|
// A batch entry will look something like this:
|
|
227
239
|
// PeerId0: [0, 1, 2, 3]
|
|
@@ -233,6 +245,7 @@ import { ReqRespStatus, ReqRespStatusError, parseStatusChunk, prettyPrintReqResp
|
|
|
233
245
|
// Requests all going to the same peer are sent synchronously
|
|
234
246
|
const peerResults = [];
|
|
235
247
|
for (const index of indices){
|
|
248
|
+
this.logger.trace(`Sending request ${index} to peer ${peerAsString}`);
|
|
236
249
|
const response = await this.sendRequestToPeer(peer, subProtocol, requestBuffers[index]);
|
|
237
250
|
// Check the status of the response buffer
|
|
238
251
|
if (response.status !== ReqRespStatus.SUCCESS) {
|
|
@@ -468,8 +481,9 @@ import { ReqRespStatus, ReqRespStatusError, parseStatusChunk, prettyPrintReqResp
|
|
|
468
481
|
const msg = Buffer.from(chunkList.subarray());
|
|
469
482
|
const response = await handler(connection.remotePeer, msg);
|
|
470
483
|
if (protocol === ReqRespSubProtocol.GOODBYE) {
|
|
484
|
+
// NOTE: The stream was already closed by Goodbye handler
|
|
485
|
+
// peerManager.goodbyeReceived(peerId, reason); will call libp2p.hangUp closing all active streams and connections
|
|
471
486
|
// Don't respond
|
|
472
|
-
await stream.close();
|
|
473
487
|
return;
|
|
474
488
|
}
|
|
475
489
|
// Send success code first, then the response
|
|
@@ -488,13 +502,25 @@ import { ReqRespStatus, ReqRespStatusError, parseStatusChunk, prettyPrintReqResp
|
|
|
488
502
|
if (e instanceof ReqRespStatusError) {
|
|
489
503
|
errorStatus = e.status;
|
|
490
504
|
}
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
505
|
+
if (stream.status === 'open') {
|
|
506
|
+
const sendErrorChunk = this.sendErrorChunk(errorStatus);
|
|
507
|
+
// Return and yield the response chunk
|
|
508
|
+
await pipe(stream, async function*(_source) {
|
|
509
|
+
yield* sendErrorChunk;
|
|
510
|
+
}, stream);
|
|
511
|
+
} else {
|
|
512
|
+
this.logger.debug('Stream already closed, not sending error response', {
|
|
513
|
+
protocol,
|
|
514
|
+
err: e,
|
|
515
|
+
errorStatus
|
|
516
|
+
});
|
|
517
|
+
}
|
|
496
518
|
} finally{
|
|
497
|
-
|
|
519
|
+
//NOTE: All other status codes indicate closed stream.
|
|
520
|
+
//Either graceful close (closed/closing) or forced close (aborted/reset)
|
|
521
|
+
if (stream.status === 'open') {
|
|
522
|
+
await stream.close();
|
|
523
|
+
}
|
|
498
524
|
}
|
|
499
525
|
}
|
|
500
526
|
async *sendErrorChunk(error) {
|
|
@@ -9,6 +9,7 @@ export declare enum PeerDiscoveryState {
|
|
|
9
9
|
RUNNING = "running",
|
|
10
10
|
STOPPED = "stopped"
|
|
11
11
|
}
|
|
12
|
+
export type P2PBlockReceivedCallback = (block: BlockProposal, sender: PeerId) => Promise<BlockAttestation | undefined>;
|
|
12
13
|
/**
|
|
13
14
|
* The interface for a P2P service implementation.
|
|
14
15
|
*/
|
|
@@ -43,8 +44,8 @@ export interface P2PService {
|
|
|
43
44
|
* @param requests - The requests to send to the peers
|
|
44
45
|
* @returns The responses to the requests
|
|
45
46
|
*/
|
|
46
|
-
sendBatchRequest<Protocol extends ReqRespSubProtocol>(protocol: Protocol, requests: InstanceType<SubProtocolMap[Protocol]['request']>[], timeoutMs?: number, maxPeers?: number, maxRetryAttempts?: number): Promise<(InstanceType<SubProtocolMap[Protocol]['response']> | undefined)[]>;
|
|
47
|
-
registerBlockReceivedCallback(callback:
|
|
47
|
+
sendBatchRequest<Protocol extends ReqRespSubProtocol>(protocol: Protocol, requests: InstanceType<SubProtocolMap[Protocol]['request']>[], pinnedPeerId?: PeerId, timeoutMs?: number, maxPeers?: number, maxRetryAttempts?: number): Promise<(InstanceType<SubProtocolMap[Protocol]['response']> | undefined)[]>;
|
|
48
|
+
registerBlockReceivedCallback(callback: P2PBlockReceivedCallback): void;
|
|
48
49
|
getEnr(): ENR | undefined;
|
|
49
50
|
getPeers(includePending?: boolean): PeerInfo[];
|
|
50
51
|
validate(txs: Tx[]): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../src/services/service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,mBAAmB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AAK,IAAI,GAAG,IAAI,CAAC;IACjE,IAAI,CAAC,KAAK,EAAE,iBAAiB,EAAE,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC;IAElD,SAAS,IAAI,kBAAkB,CAAC;IAEhC,MAAM,IAAI,GAAG,GAAG,SAAS,CAAC;IAE1B,iBAAiB,EAAE,GAAG,EAAE,CAAC;CAC1B"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type Logger } from '@aztec/foundation/log';
|
|
2
|
+
import type { BlockProposal } from '@aztec/stdlib/p2p';
|
|
3
|
+
import type { Tx, TxHash } from '@aztec/stdlib/tx';
|
|
4
|
+
import type { P2PClient } from '../client/p2p_client.js';
|
|
5
|
+
export declare class TxCollector {
|
|
6
|
+
private p2pClient;
|
|
7
|
+
private log;
|
|
8
|
+
constructor(p2pClient: Pick<P2PClient, 'getTxsByHashFromPool' | 'hasTxsInPool' | 'getTxsByHash' | 'validate' | 'requestTxsByHash'>, log?: Logger);
|
|
9
|
+
collectForBlockProposal(proposal: BlockProposal, peerWhoSentTheProposal: any): Promise<{
|
|
10
|
+
txs: Tx[];
|
|
11
|
+
missing?: TxHash[];
|
|
12
|
+
}>;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=tx_collector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tx_collector.d.ts","sourceRoot":"","sources":["../../src/services/tx_collector.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAClE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEzD,qBAAa,WAAW;IAEpB,OAAO,CAAC,SAAS;IAIjB,OAAO,CAAC,GAAG;gBAJH,SAAS,EAAE,IAAI,CACrB,SAAS,EACT,sBAAsB,GAAG,cAAc,GAAG,cAAc,GAAG,UAAU,GAAG,kBAAkB,CAC3F,EACO,GAAG,GAAE,MAAyC;IAGlD,uBAAuB,CAC3B,QAAQ,EAAE,aAAa,EACvB,sBAAsB,EAAE,GAAG,GAC1B,OAAO,CAAC;QAAE,GAAG,EAAE,EAAE,EAAE,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;CA8E9C"}
|