@aztec/p2p 0.0.1-commit.b2a5d0dd1 → 0.0.1-commit.b3d3157a
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/bootstrap/bootstrap.d.ts +1 -1
- package/dest/bootstrap/bootstrap.d.ts.map +1 -1
- package/dest/bootstrap/bootstrap.js +9 -1
- package/dest/client/factory.d.ts +3 -3
- package/dest/client/factory.d.ts.map +1 -1
- package/dest/client/factory.js +12 -9
- package/dest/client/interface.d.ts +6 -4
- package/dest/client/interface.d.ts.map +1 -1
- package/dest/client/p2p_client.d.ts +11 -8
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +53 -17
- package/dest/config.d.ts +43 -17
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +48 -8
- package/dest/errors/reqresp.error.d.ts +1 -20
- package/dest/errors/reqresp.error.d.ts.map +1 -1
- package/dest/errors/reqresp.error.js +0 -21
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +93 -55
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool.js +258 -195
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.js +175 -59
- package/dest/mem_pools/attestation_pool/mocks.d.ts +1 -1
- package/dest/mem_pools/attestation_pool/mocks.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/mocks.js +6 -4
- package/dest/mem_pools/instrumentation.d.ts +1 -1
- package/dest/mem_pools/instrumentation.d.ts.map +1 -1
- package/dest/mem_pools/instrumentation.js +17 -1
- package/dest/mem_pools/tx_pool_v2/archive/tx_archive.d.ts +1 -5
- package/dest/mem_pools/tx_pool_v2/archive/tx_archive.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/archive/tx_archive.js +1 -7
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.js +73 -83
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts +5 -2
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts.map +1 -1
- package/dest/msg_validators/attestation_validator/attestation_validator.js +18 -2
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts +5 -3
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts.map +1 -1
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.js +3 -4
- package/dest/msg_validators/clock_tolerance.d.ts +1 -1
- package/dest/msg_validators/clock_tolerance.d.ts.map +1 -1
- package/dest/msg_validators/clock_tolerance.js +13 -11
- package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts +5 -2
- package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts +5 -2
- package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/proposal_validator.d.ts +8 -2
- package/dest/msg_validators/proposal_validator/proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/proposal_validator.js +28 -2
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts +1 -1
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.js +8 -15
- package/dest/msg_validators/tx_validator/allowed_public_setup.js +3 -3
- package/dest/msg_validators/tx_validator/cached_tx_validator.d.ts +15 -0
- package/dest/msg_validators/tx_validator/cached_tx_validator.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/cached_tx_validator.js +19 -0
- package/dest/msg_validators/tx_validator/data_validator.d.ts +2 -1
- package/dest/msg_validators/tx_validator/data_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/data_validator.js +1 -0
- package/dest/msg_validators/tx_validator/factory.d.ts +5 -4
- package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/factory.js +11 -7
- package/dest/msg_validators/tx_validator/index.d.ts +3 -1
- package/dest/msg_validators/tx_validator/index.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/index.js +2 -0
- package/dest/msg_validators/tx_validator/tx_proof_validator.d.ts +2 -1
- package/dest/msg_validators/tx_validator/tx_proof_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/tx_proof_validator.js +2 -0
- package/dest/msg_validators/tx_validator/tx_validation_cache.d.ts +48 -0
- package/dest/msg_validators/tx_validator/tx_validation_cache.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/tx_validation_cache.js +68 -0
- package/dest/services/discv5/discV5_service.d.ts +2 -1
- package/dest/services/discv5/discV5_service.d.ts.map +1 -1
- package/dest/services/discv5/discV5_service.js +35 -8
- package/dest/services/dummy_service.d.ts +10 -17
- package/dest/services/dummy_service.d.ts.map +1 -1
- package/dest/services/dummy_service.js +9 -18
- package/dest/services/libp2p/libp2p_service.d.ts +19 -21
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +147 -148
- package/dest/services/peer-manager/peer_manager.d.ts +1 -1
- package/dest/services/peer-manager/peer_manager.d.ts.map +1 -1
- package/dest/services/peer-manager/peer_manager.js +1 -0
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts +1 -8
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.js +35 -44
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts +8 -5
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/tx_validator.d.ts +5 -14
- package/dest/services/reqresp/batch-tx-requester/tx_validator.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/tx_validator.js +6 -20
- package/dest/services/reqresp/interface.d.ts +3 -10
- package/dest/services/reqresp/interface.d.ts.map +1 -1
- package/dest/services/reqresp/interface.js +0 -9
- package/dest/services/reqresp/protocols/block_txs/bitvector.d.ts +4 -3
- package/dest/services/reqresp/protocols/block_txs/bitvector.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/block_txs/bitvector.js +3 -2
- package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts +1 -1
- package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/block_txs/block_txs_handler.js +31 -28
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts +12 -7
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.js +42 -24
- package/dest/services/reqresp/reqresp.d.ts +5 -29
- package/dest/services/reqresp/reqresp.d.ts.map +1 -1
- package/dest/services/reqresp/reqresp.js +16 -206
- package/dest/services/service.d.ts +7 -13
- package/dest/services/service.d.ts.map +1 -1
- package/dest/services/tx_collection/config.d.ts +2 -23
- package/dest/services/tx_collection/config.d.ts.map +1 -1
- package/dest/services/tx_collection/config.js +2 -55
- package/dest/services/tx_collection/file_store_tx_collection.d.ts +12 -28
- package/dest/services/tx_collection/file_store_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/file_store_tx_collection.js +43 -83
- package/dest/services/tx_collection/index.d.ts +2 -3
- package/dest/services/tx_collection/index.d.ts.map +1 -1
- package/dest/services/tx_collection/index.js +0 -1
- package/dest/services/tx_collection/instrumentation.d.ts +1 -1
- package/dest/services/tx_collection/instrumentation.d.ts.map +1 -1
- package/dest/services/tx_collection/instrumentation.js +0 -2
- package/dest/services/tx_collection/tx_collection.d.ts +35 -51
- package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_collection.js +275 -119
- package/dest/services/tx_collection/tx_collection_sink.d.ts +1 -1
- package/dest/services/tx_collection/tx_collection_sink.js +2 -2
- package/dest/services/tx_file_store/tx_file_store.d.ts +1 -3
- package/dest/services/tx_file_store/tx_file_store.d.ts.map +1 -1
- package/dest/services/tx_file_store/tx_file_store.js +4 -14
- package/dest/services/tx_provider.d.ts +3 -1
- package/dest/services/tx_provider.d.ts.map +1 -1
- package/dest/services/tx_provider.js +3 -0
- package/dest/test-helpers/make-test-p2p-clients.d.ts +1 -1
- package/dest/test-helpers/make-test-p2p-clients.d.ts.map +1 -1
- package/dest/test-helpers/make-test-p2p-clients.js +1 -1
- package/dest/test-helpers/mock-pubsub.d.ts +13 -7
- package/dest/test-helpers/mock-pubsub.d.ts.map +1 -1
- package/dest/test-helpers/mock-pubsub.js +12 -37
- package/dest/test-helpers/reqresp-nodes.d.ts +4 -5
- package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
- package/dest/test-helpers/reqresp-nodes.js +11 -15
- package/dest/test-helpers/test_tx_provider.d.ts +3 -1
- package/dest/test-helpers/test_tx_provider.d.ts.map +1 -1
- package/dest/test-helpers/test_tx_provider.js +3 -0
- package/dest/test-helpers/testbench-utils.d.ts +12 -14
- package/dest/test-helpers/testbench-utils.d.ts.map +1 -1
- package/dest/test-helpers/testbench-utils.js +19 -14
- package/dest/testbench/p2p_client_testbench_worker.d.ts +3 -5
- package/dest/testbench/p2p_client_testbench_worker.d.ts.map +1 -1
- package/dest/testbench/p2p_client_testbench_worker.js +13 -24
- package/dest/testbench/worker_client_manager.d.ts +3 -6
- package/dest/testbench/worker_client_manager.d.ts.map +1 -1
- package/dest/testbench/worker_client_manager.js +2 -8
- package/dest/util.d.ts +11 -6
- package/dest/util.d.ts.map +1 -1
- package/dest/util.js +35 -14
- package/dest/versioning.d.ts +3 -6
- package/dest/versioning.d.ts.map +1 -1
- package/dest/versioning.js +3 -24
- package/package.json +15 -14
- package/src/bootstrap/bootstrap.ts +9 -1
- package/src/client/factory.ts +20 -5
- package/src/client/interface.ts +6 -10
- package/src/client/p2p_client.ts +61 -36
- package/src/client/test/{tx_proposal_collector/README.md → p2p_client.batch_tx_requester.bench.README.md} +23 -53
- package/src/config.ts +94 -6
- package/src/errors/reqresp.error.ts +0 -25
- package/src/mem_pools/attestation_pool/attestation_pool.ts +309 -238
- package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +198 -62
- package/src/mem_pools/attestation_pool/mocks.ts +13 -8
- package/src/mem_pools/instrumentation.ts +5 -1
- package/src/mem_pools/tx_pool_v2/archive/tx_archive.ts +1 -9
- package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +73 -90
- package/src/msg_validators/attestation_validator/attestation_validator.ts +21 -1
- package/src/msg_validators/attestation_validator/fisherman_attestation_validator.ts +11 -7
- package/src/msg_validators/clock_tolerance.ts +13 -12
- package/src/msg_validators/proposal_validator/block_proposal_validator.ts +9 -2
- package/src/msg_validators/proposal_validator/checkpoint_proposal_validator.ts +14 -2
- package/src/msg_validators/proposal_validator/proposal_validator.ts +39 -2
- package/src/msg_validators/tx_validator/aggregate_tx_validator.ts +3 -12
- package/src/msg_validators/tx_validator/allowed_public_setup.ts +3 -3
- package/src/msg_validators/tx_validator/cached_tx_validator.ts +31 -0
- package/src/msg_validators/tx_validator/data_validator.ts +2 -0
- package/src/msg_validators/tx_validator/factory.ts +15 -6
- package/src/msg_validators/tx_validator/index.ts +2 -0
- package/src/msg_validators/tx_validator/tx_proof_validator.ts +2 -0
- package/src/msg_validators/tx_validator/tx_validation_cache.ts +101 -0
- package/src/services/discv5/discV5_service.ts +38 -5
- package/src/services/dummy_service.ts +12 -43
- package/src/services/libp2p/libp2p_service.ts +169 -167
- package/src/services/peer-manager/peer_manager.ts +1 -0
- package/src/services/reqresp/README.md +0 -14
- package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +39 -52
- package/src/services/reqresp/batch-tx-requester/interface.ts +11 -4
- package/src/services/reqresp/batch-tx-requester/tx_validator.ts +12 -25
- package/src/services/reqresp/interface.ts +2 -38
- package/src/services/reqresp/protocols/block_txs/bitvector.ts +3 -2
- package/src/services/reqresp/protocols/block_txs/block_txs_handler.ts +34 -30
- package/src/services/reqresp/protocols/block_txs/block_txs_reqresp.ts +47 -20
- package/src/services/reqresp/reqresp.ts +11 -251
- package/src/services/service.ts +9 -30
- package/src/services/tx_collection/config.ts +3 -80
- package/src/services/tx_collection/file_store_tx_collection.ts +54 -103
- package/src/services/tx_collection/index.ts +1 -6
- package/src/services/tx_collection/instrumentation.ts +1 -7
- package/src/services/tx_collection/tx_collection.ts +330 -173
- package/src/services/tx_collection/tx_collection_sink.ts +2 -2
- package/src/services/tx_file_store/tx_file_store.ts +5 -17
- package/src/services/tx_provider.ts +5 -0
- package/src/test-helpers/make-test-p2p-clients.ts +1 -0
- package/src/test-helpers/mock-pubsub.ts +17 -60
- package/src/test-helpers/reqresp-nodes.ts +8 -20
- package/src/test-helpers/test_tx_provider.ts +5 -0
- package/src/test-helpers/testbench-utils.ts +23 -27
- package/src/testbench/p2p_client_testbench_worker.ts +16 -42
- package/src/testbench/worker_client_manager.ts +4 -19
- package/src/util.ts +32 -17
- package/src/versioning.ts +3 -33
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.d.ts +0 -2
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.d.ts.map +0 -1
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +0 -318
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.d.ts +0 -73
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.d.ts.map +0 -1
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.js +0 -8
- package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts +0 -64
- package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts.map +0 -1
- package/dest/services/reqresp/connection-sampler/batch_connection_sampler.js +0 -151
- package/dest/services/tx_collection/fast_tx_collection.d.ts +0 -51
- package/dest/services/tx_collection/fast_tx_collection.d.ts.map +0 -1
- package/dest/services/tx_collection/fast_tx_collection.js +0 -311
- package/dest/services/tx_collection/proposal_tx_collector.d.ts +0 -48
- package/dest/services/tx_collection/proposal_tx_collector.d.ts.map +0 -1
- package/dest/services/tx_collection/proposal_tx_collector.js +0 -50
- package/dest/services/tx_collection/slow_tx_collection.d.ts +0 -57
- package/dest/services/tx_collection/slow_tx_collection.d.ts.map +0 -1
- package/dest/services/tx_collection/slow_tx_collection.js +0 -211
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +0 -357
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.ts +0 -43
- package/src/services/reqresp/connection-sampler/batch_connection_sampler.ts +0 -161
- package/src/services/tx_collection/fast_tx_collection.ts +0 -361
- package/src/services/tx_collection/proposal_tx_collector.ts +0 -108
- package/src/services/tx_collection/slow_tx_collection.ts +0 -266
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
// @attribution: lodestar impl for inspiration
|
|
2
|
-
import { compactArray } from '@aztec/foundation/collection';
|
|
3
2
|
import { AbortError, TimeoutError } from '@aztec/foundation/error';
|
|
4
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
5
4
|
import { executeTimeout } from '@aztec/foundation/timer';
|
|
@@ -11,11 +10,7 @@ import type { Libp2p } from 'libp2p';
|
|
|
11
10
|
import { pipeline } from 'node:stream/promises';
|
|
12
11
|
import type { Uint8ArrayList } from 'uint8arraylist';
|
|
13
12
|
|
|
14
|
-
import {
|
|
15
|
-
CollectiveReqRespTimeoutError,
|
|
16
|
-
IndividualReqRespTimeoutError,
|
|
17
|
-
InvalidResponseError,
|
|
18
|
-
} from '../../errors/reqresp.error.js';
|
|
13
|
+
import { IndividualReqRespTimeoutError } from '../../errors/reqresp.error.js';
|
|
19
14
|
import { OversizedSnappyResponseError, SnappyTransform } from '../encoding.js';
|
|
20
15
|
import type { PeerScoring } from '../peer-manager/peer_scoring.js';
|
|
21
16
|
import {
|
|
@@ -23,21 +18,16 @@ import {
|
|
|
23
18
|
DEFAULT_REQRESP_DIAL_TIMEOUT_MS,
|
|
24
19
|
type P2PReqRespConfig,
|
|
25
20
|
} from './config.js';
|
|
26
|
-
import { BatchConnectionSampler } from './connection-sampler/batch_connection_sampler.js';
|
|
27
21
|
import { ConnectionSampler, RandomSampler } from './connection-sampler/connection_sampler.js';
|
|
28
22
|
import {
|
|
29
|
-
DEFAULT_SUB_PROTOCOL_VALIDATORS,
|
|
30
23
|
type ReqRespInterface,
|
|
31
24
|
type ReqRespResponse,
|
|
32
25
|
ReqRespSubProtocol,
|
|
33
26
|
type ReqRespSubProtocolHandler,
|
|
34
27
|
type ReqRespSubProtocolHandlers,
|
|
35
28
|
type ReqRespSubProtocolRateLimits,
|
|
36
|
-
type ReqRespSubProtocolValidators,
|
|
37
29
|
type ShouldRejectPeer,
|
|
38
|
-
type SubProtocolMap,
|
|
39
30
|
UNAUTHENTICATED_ALLOWED_PROTOCOLS,
|
|
40
|
-
responseFromBuffer,
|
|
41
31
|
subProtocolSizeCalculators,
|
|
42
32
|
} from './interface.js';
|
|
43
33
|
import { ReqRespMetrics } from './metrics.js';
|
|
@@ -46,13 +36,13 @@ import {
|
|
|
46
36
|
RequestResponseRateLimiter,
|
|
47
37
|
prettyPrintRateLimitStatus,
|
|
48
38
|
} from './rate-limiter/rate_limiter.js';
|
|
49
|
-
import { ReqRespStatus, ReqRespStatusError, parseStatusChunk
|
|
39
|
+
import { ReqRespStatus, ReqRespStatusError, parseStatusChunk } from './status.js';
|
|
50
40
|
|
|
51
41
|
/**
|
|
52
42
|
* The Request Response Service
|
|
53
43
|
*
|
|
54
44
|
* It allows nodes to request specific information from their peers, its use case covers recovering
|
|
55
|
-
* information that was missed during a
|
|
45
|
+
* information that was missed during a synchronisation or a gossip event.
|
|
56
46
|
*
|
|
57
47
|
* This service implements the request response sub protocol, it is heavily inspired from
|
|
58
48
|
* ethereum implementations of the same name.
|
|
@@ -67,7 +57,6 @@ export class ReqResp implements ReqRespInterface {
|
|
|
67
57
|
private dialTimeoutMs: number = DEFAULT_REQRESP_DIAL_TIMEOUT_MS;
|
|
68
58
|
|
|
69
59
|
private subProtocolHandlers: Partial<ReqRespSubProtocolHandlers> = {};
|
|
70
|
-
private subProtocolValidators: Partial<ReqRespSubProtocolValidators> = {};
|
|
71
60
|
|
|
72
61
|
private connectionSampler: ConnectionSampler;
|
|
73
62
|
private rateLimiter: RequestResponseRateLimiter;
|
|
@@ -130,11 +119,11 @@ export class ReqResp implements ReqRespInterface {
|
|
|
130
119
|
/**
|
|
131
120
|
* Start the reqresp service
|
|
132
121
|
*/
|
|
133
|
-
async start(subProtocolHandlers: ReqRespSubProtocolHandlers
|
|
122
|
+
async start(subProtocolHandlers: ReqRespSubProtocolHandlers) {
|
|
134
123
|
Object.assign(this.subProtocolHandlers, subProtocolHandlers);
|
|
135
|
-
Object.assign(this.subProtocolValidators, subProtocolValidators);
|
|
136
124
|
|
|
137
|
-
// Register
|
|
125
|
+
// Register streamHandler with libp2p.
|
|
126
|
+
// The streamHandler is responsible for reading the incoming stream, determining the protocol, then triggering the appropriate handler.
|
|
138
127
|
for (const subProtocol of Object.keys(subProtocolHandlers)) {
|
|
139
128
|
this.logger.debug(`Registering handler for sub protocol ${subProtocol}`);
|
|
140
129
|
await this.libp2p.handle(
|
|
@@ -148,13 +137,8 @@ export class ReqResp implements ReqRespInterface {
|
|
|
148
137
|
this.rateLimiter.start();
|
|
149
138
|
}
|
|
150
139
|
|
|
151
|
-
async addSubProtocol(
|
|
152
|
-
subProtocol: ReqRespSubProtocol,
|
|
153
|
-
handler: ReqRespSubProtocolHandler,
|
|
154
|
-
validator: ReqRespSubProtocolValidators[ReqRespSubProtocol] = DEFAULT_SUB_PROTOCOL_VALIDATORS[subProtocol],
|
|
155
|
-
): Promise<void> {
|
|
140
|
+
async addSubProtocol(subProtocol: ReqRespSubProtocol, handler: ReqRespSubProtocolHandler): Promise<void> {
|
|
156
141
|
this.subProtocolHandlers[subProtocol] = handler;
|
|
157
|
-
this.subProtocolValidators[subProtocol] = validator;
|
|
158
142
|
this.logger.debug(`Registering handler for sub protocol ${subProtocol}`);
|
|
159
143
|
await this.libp2p.handle(
|
|
160
144
|
subProtocol,
|
|
@@ -188,225 +172,6 @@ export class ReqResp implements ReqRespInterface {
|
|
|
188
172
|
// NOTE: We assume libp2p instance is managed by the caller
|
|
189
173
|
}
|
|
190
174
|
|
|
191
|
-
/**
|
|
192
|
-
* Request multiple messages over the same sub protocol, balancing the requests across peers.
|
|
193
|
-
*
|
|
194
|
-
* @devnote
|
|
195
|
-
* - The function prioritizes sending requests to free peers using a batch sampling strategy.
|
|
196
|
-
* - If a peer fails to respond or returns an invalid response, it is removed from the sampling pool and replaced.
|
|
197
|
-
* - The function stops retrying once all requests are processed, no active peers remain, or the maximum retry attempts are reached.
|
|
198
|
-
* - Responses are validated using a custom validator for the sub-protocol.*
|
|
199
|
-
*
|
|
200
|
-
* Requests are sent in parallel to each peer, but multiple requests are sent to the same peer in series
|
|
201
|
-
* - If a peer fails to respond or returns an invalid response, it is removed from the sampling pool and replaced.
|
|
202
|
-
* - The function stops retrying once all requests are processed, no active peers remain, or the maximum retry attempts are reached.
|
|
203
|
-
* - Responses are validated using a custom validator for the sub-protocol.*
|
|
204
|
-
*
|
|
205
|
-
* @param subProtocol
|
|
206
|
-
* @param requests
|
|
207
|
-
* @param timeoutMs
|
|
208
|
-
* @param maxPeers
|
|
209
|
-
* @returns
|
|
210
|
-
*
|
|
211
|
-
* @throws {CollectiveReqRespTimeoutError} - If the request batch exceeds the specified timeout (`timeoutMs`).
|
|
212
|
-
*/
|
|
213
|
-
@trackSpan(
|
|
214
|
-
'ReqResp.sendBatchRequest',
|
|
215
|
-
(subProtocol: ReqRespSubProtocol, requests: InstanceType<SubProtocolMap[ReqRespSubProtocol]['request']>[]) => ({
|
|
216
|
-
[Attributes.P2P_REQ_RESP_PROTOCOL]: subProtocol,
|
|
217
|
-
[Attributes.P2P_REQ_RESP_BATCH_REQUESTS_COUNT]: requests.length,
|
|
218
|
-
}),
|
|
219
|
-
)
|
|
220
|
-
async sendBatchRequest<SubProtocol extends ReqRespSubProtocol>(
|
|
221
|
-
subProtocol: SubProtocol,
|
|
222
|
-
requests: InstanceType<SubProtocolMap[SubProtocol]['request']>[],
|
|
223
|
-
pinnedPeer: PeerId | undefined,
|
|
224
|
-
timeoutMs = 10000,
|
|
225
|
-
maxPeers = Math.max(10, Math.ceil(requests.length / 3)),
|
|
226
|
-
maxRetryAttempts = 3,
|
|
227
|
-
): Promise<InstanceType<SubProtocolMap[SubProtocol]['response']>[]> {
|
|
228
|
-
const responseValidator = this.subProtocolValidators[subProtocol] ?? DEFAULT_SUB_PROTOCOL_VALIDATORS[subProtocol];
|
|
229
|
-
const responses: InstanceType<SubProtocolMap[SubProtocol]['response']>[] = new Array(requests.length);
|
|
230
|
-
const requestBuffers = requests.map(req => req.toBuffer());
|
|
231
|
-
const isEmptyResponse = (value: unknown): boolean => {
|
|
232
|
-
// Some responses serialize to a non-empty buffer even when they contain no items (e.g., empty TxArray).
|
|
233
|
-
if (!value || typeof value !== 'object') {
|
|
234
|
-
return false;
|
|
235
|
-
}
|
|
236
|
-
const length = (value as { length?: number }).length;
|
|
237
|
-
return typeof length === 'number' && length === 0;
|
|
238
|
-
};
|
|
239
|
-
|
|
240
|
-
const requestFunction = async (signal: AbortSignal) => {
|
|
241
|
-
// Track which requests still need to be processed
|
|
242
|
-
const pendingRequestIndices = new Set(requestBuffers.map((_, i) => i));
|
|
243
|
-
|
|
244
|
-
// Create batch sampler with the total number of requests and max peers
|
|
245
|
-
const batchSampler = new BatchConnectionSampler(
|
|
246
|
-
this.connectionSampler,
|
|
247
|
-
requests.length,
|
|
248
|
-
maxPeers,
|
|
249
|
-
compactArray([pinnedPeer]), // Exclude pinned peer from sampling, we will forcefully send all requests to it
|
|
250
|
-
createLogger(`${this.logger.module}:batch-connection-sampler`),
|
|
251
|
-
);
|
|
252
|
-
|
|
253
|
-
if (batchSampler.activePeerCount === 0 && !pinnedPeer) {
|
|
254
|
-
this.logger.warn('No active peers to send requests to');
|
|
255
|
-
return [];
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
// This is where it gets fun
|
|
259
|
-
// The outer loop is the retry loop, we will continue to retry until we process all indices we have
|
|
260
|
-
// not received a response for, or we have reached the max retry attempts
|
|
261
|
-
|
|
262
|
-
// The inner loop is the batch loop, we will process all requests for each peer in parallel
|
|
263
|
-
// We will then process the results of the requests, and resample any peers that failed to respond
|
|
264
|
-
// We will continue to retry until we have processed all indices, or we have reached the max retry attempts
|
|
265
|
-
|
|
266
|
-
let retryAttempts = 0;
|
|
267
|
-
while (pendingRequestIndices.size > 0 && batchSampler.activePeerCount > 0 && retryAttempts < maxRetryAttempts) {
|
|
268
|
-
if (signal.aborted) {
|
|
269
|
-
throw new AbortError('Batch request aborted');
|
|
270
|
-
}
|
|
271
|
-
// Process requests in parallel for each available peer
|
|
272
|
-
type BatchEntry = { peerId: PeerId; indices: number[] };
|
|
273
|
-
const requestBatches = new Map<string, BatchEntry>();
|
|
274
|
-
|
|
275
|
-
// Group requests by peer
|
|
276
|
-
for (const requestIndex of pendingRequestIndices) {
|
|
277
|
-
const peer = batchSampler.getPeerForRequest(requestIndex);
|
|
278
|
-
if (!peer) {
|
|
279
|
-
// No peer available for this specific index (all peers exhausted for it)
|
|
280
|
-
// Skip this index for now - it stays in pendingRequestIndices for retry
|
|
281
|
-
continue;
|
|
282
|
-
}
|
|
283
|
-
const peerAsString = peer.toString();
|
|
284
|
-
if (!requestBatches.has(peerAsString)) {
|
|
285
|
-
requestBatches.set(peerAsString, { peerId: peer, indices: [] });
|
|
286
|
-
}
|
|
287
|
-
requestBatches.get(peerAsString)!.indices.push(requestIndex);
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
// If there is a pinned peer, we will always send every request to that peer
|
|
291
|
-
// We use the default limits for the subprotocol to avoid hitting the rate limiter
|
|
292
|
-
if (pinnedPeer) {
|
|
293
|
-
const limit = this.rateLimiter.getRateLimits(subProtocol).peerLimit.quotaCount;
|
|
294
|
-
requestBatches.set(pinnedPeer.toString(), {
|
|
295
|
-
peerId: pinnedPeer,
|
|
296
|
-
indices: Array.from(pendingRequestIndices.values()).slice(0, limit),
|
|
297
|
-
});
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
// If no requests could be assigned (all peers exhausted for all indices), exit early
|
|
301
|
-
if (requestBatches.size === 0) {
|
|
302
|
-
this.logger.warn('No peers available for any pending request indices, stopping batch request');
|
|
303
|
-
break;
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
// Make parallel requests for each peer's batch
|
|
307
|
-
// A batch entry will look something like this:
|
|
308
|
-
// PeerId0: [0, 1, 2, 3]
|
|
309
|
-
// PeerId1: [4, 5, 6, 7]
|
|
310
|
-
|
|
311
|
-
// Peer Id 0 will send requests 0, 1, 2, 3 in serial
|
|
312
|
-
// while simultaneously Peer Id 1 will send requests 4, 5, 6, 7 in serial
|
|
313
|
-
|
|
314
|
-
const batchResults = await Promise.all(
|
|
315
|
-
Array.from(requestBatches.entries()).map(async ([peerAsString, { peerId: peer, indices }]) => {
|
|
316
|
-
try {
|
|
317
|
-
const markIndexFailed = (index: number) => batchSampler.markPeerFailedForIndex(peer, index);
|
|
318
|
-
// Requests all going to the same peer are sent synchronously
|
|
319
|
-
const peerResults: { index: number; response: InstanceType<SubProtocolMap[SubProtocol]['response']> }[] =
|
|
320
|
-
[];
|
|
321
|
-
let shouldReplacePeer = false;
|
|
322
|
-
const handleFailure = (status: ReqRespStatus, index: number) => {
|
|
323
|
-
this.logger.warn(
|
|
324
|
-
`Request to peer ${peerAsString} failed with status ${prettyPrintReqRespStatus(status)}`,
|
|
325
|
-
);
|
|
326
|
-
markIndexFailed(index);
|
|
327
|
-
return status === ReqRespStatus.RATE_LIMIT_EXCEEDED;
|
|
328
|
-
};
|
|
329
|
-
|
|
330
|
-
for (const index of indices) {
|
|
331
|
-
this.logger.trace(`Sending request ${index} to peer ${peerAsString}`);
|
|
332
|
-
const response = await this.sendRequestToPeer(peer, subProtocol, requestBuffers[index]);
|
|
333
|
-
|
|
334
|
-
// Check the status of the response buffer
|
|
335
|
-
if (response.status !== ReqRespStatus.SUCCESS) {
|
|
336
|
-
shouldReplacePeer = handleFailure(response.status, index);
|
|
337
|
-
if (shouldReplacePeer) {
|
|
338
|
-
break;
|
|
339
|
-
}
|
|
340
|
-
continue;
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
if (response.data.length === 0) {
|
|
344
|
-
markIndexFailed(index);
|
|
345
|
-
continue;
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
const object = responseFromBuffer(subProtocol, response.data);
|
|
349
|
-
if (isEmptyResponse(object)) {
|
|
350
|
-
markIndexFailed(index);
|
|
351
|
-
continue;
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
const isValid = await responseValidator(requests[index], object, peer);
|
|
355
|
-
if (!isValid) {
|
|
356
|
-
markIndexFailed(index);
|
|
357
|
-
continue;
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
peerResults.push({ index, response: object });
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
// If peer had a hard failure (rate limit), replace it for future iterations
|
|
364
|
-
if (shouldReplacePeer) {
|
|
365
|
-
this.logger.warn(`Peer ${peerAsString} hit a hard failure, removing from sampler`);
|
|
366
|
-
batchSampler.removePeerAndReplace(peer);
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
return { peer, results: peerResults };
|
|
370
|
-
} catch (error) {
|
|
371
|
-
this.logger.warn(`Failed batch request to peer ${peerAsString}:`, error);
|
|
372
|
-
batchSampler.removePeerAndReplace(peer);
|
|
373
|
-
return { peer, results: [] };
|
|
374
|
-
}
|
|
375
|
-
}),
|
|
376
|
-
);
|
|
377
|
-
|
|
378
|
-
// Process results
|
|
379
|
-
for (const { results } of batchResults) {
|
|
380
|
-
for (const { index, response } of results) {
|
|
381
|
-
if (response) {
|
|
382
|
-
responses[index] = response;
|
|
383
|
-
pendingRequestIndices.delete(index);
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
retryAttempts++;
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
if (retryAttempts >= maxRetryAttempts) {
|
|
392
|
-
this.logger.warn(`Max retry attempts ${maxRetryAttempts} reached for batch request`);
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
return responses;
|
|
396
|
-
};
|
|
397
|
-
|
|
398
|
-
try {
|
|
399
|
-
return await executeTimeout<InstanceType<SubProtocolMap[SubProtocol]['response']>[]>(
|
|
400
|
-
requestFunction,
|
|
401
|
-
timeoutMs,
|
|
402
|
-
() => new CollectiveReqRespTimeoutError(),
|
|
403
|
-
);
|
|
404
|
-
} catch (e: any) {
|
|
405
|
-
this.logger.warn(`${e.message} | subProtocol: ${subProtocol}`);
|
|
406
|
-
return [];
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
|
|
410
175
|
/**
|
|
411
176
|
* Sends a request to a specific peer
|
|
412
177
|
*
|
|
@@ -757,13 +522,13 @@ export class ReqResp implements ReqRespInterface {
|
|
|
757
522
|
): PeerErrorSeverity | undefined {
|
|
758
523
|
const logTags = { peerId: peerId.toString(), subProtocol };
|
|
759
524
|
|
|
760
|
-
//Punishable error - peer should never send badly formed request
|
|
525
|
+
// Punishable error - peer should never send badly formed request
|
|
761
526
|
if (e instanceof ReqRespStatusError && e.status === ReqRespStatus.BADLY_FORMED_REQUEST) {
|
|
762
527
|
this.logger.debug(`Punishable error in ${subProtocol}: ${e.cause}`, logTags);
|
|
763
528
|
return PeerErrorSeverity.LowToleranceError;
|
|
764
529
|
}
|
|
765
530
|
|
|
766
|
-
//TODO: (mralj): think if we should penalize peer here based on connection errors
|
|
531
|
+
// TODO: (mralj): think if we should penalize peer here based on connection errors
|
|
767
532
|
return undefined;
|
|
768
533
|
}
|
|
769
534
|
|
|
@@ -785,12 +550,6 @@ export class ReqResp implements ReqRespInterface {
|
|
|
785
550
|
return undefined;
|
|
786
551
|
}
|
|
787
552
|
|
|
788
|
-
// We do not punish a collective timeout, as the node triggers this interupt, independent of the peer's behaviour
|
|
789
|
-
if (e instanceof CollectiveReqRespTimeoutError || e instanceof InvalidResponseError) {
|
|
790
|
-
this.logger.debug(`Non-punishable error in ${subProtocol}: ${e.message}`, logTags);
|
|
791
|
-
return undefined;
|
|
792
|
-
}
|
|
793
|
-
|
|
794
553
|
// Invalid status byte: the peer sent a status byte that doesn't match any known status code.
|
|
795
554
|
// This is a protocol violation, penalize harshly.
|
|
796
555
|
if (e instanceof ReqRespStatusError) {
|
|
@@ -810,7 +569,8 @@ export class ReqResp implements ReqRespInterface {
|
|
|
810
569
|
|
|
811
570
|
/*
|
|
812
571
|
* Errors specific to connection handling
|
|
813
|
-
* These can happen both when sending request and response
|
|
572
|
+
* These can happen both when sending request and response.
|
|
573
|
+
*/
|
|
814
574
|
private categorizeConnectionErrors(
|
|
815
575
|
e: any,
|
|
816
576
|
peerId: PeerId,
|
package/src/services/service.ts
CHANGED
|
@@ -17,12 +17,7 @@ import type EventEmitter from 'events';
|
|
|
17
17
|
import type { BatchTxRequesterLibP2PService } from './reqresp/batch-tx-requester/interface.js';
|
|
18
18
|
import type { P2PReqRespConfig } from './reqresp/config.js';
|
|
19
19
|
import type { StatusMessage } from './reqresp/index.js';
|
|
20
|
-
import type {
|
|
21
|
-
ReqRespSubProtocol,
|
|
22
|
-
ReqRespSubProtocolHandler,
|
|
23
|
-
ReqRespSubProtocolValidators,
|
|
24
|
-
SubProtocolMap,
|
|
25
|
-
} from './reqresp/interface.js';
|
|
20
|
+
import type { ReqRespSubProtocol, ReqRespSubProtocolHandler } from './reqresp/interface.js';
|
|
26
21
|
import type { AuthRequest, AuthResponse } from './reqresp/protocols/auth.js';
|
|
27
22
|
|
|
28
23
|
export enum PeerDiscoveryState {
|
|
@@ -76,6 +71,8 @@ export type DuplicateAttestationInfo = {
|
|
|
76
71
|
*/
|
|
77
72
|
export type P2PDuplicateAttestationCallback = (info: DuplicateAttestationInfo) => void;
|
|
78
73
|
|
|
74
|
+
export type P2PCheckpointAttestationCallback = (attestation: CheckpointAttestation) => void;
|
|
75
|
+
|
|
79
76
|
/**
|
|
80
77
|
* The interface for a P2P service implementation.
|
|
81
78
|
*/
|
|
@@ -98,22 +95,6 @@ export interface P2PService {
|
|
|
98
95
|
*/
|
|
99
96
|
propagate<T extends Gossipable>(message: T): Promise<void>;
|
|
100
97
|
|
|
101
|
-
/**
|
|
102
|
-
* Send a batch of requests to peers, and return the responses
|
|
103
|
-
*
|
|
104
|
-
* @param protocol - The request response protocol to use
|
|
105
|
-
* @param requests - The requests to send to the peers
|
|
106
|
-
* @returns The responses to the requests
|
|
107
|
-
*/
|
|
108
|
-
sendBatchRequest<Protocol extends ReqRespSubProtocol>(
|
|
109
|
-
protocol: Protocol,
|
|
110
|
-
requests: InstanceType<SubProtocolMap[Protocol]['request']>[],
|
|
111
|
-
pinnedPeerId?: PeerId,
|
|
112
|
-
timeoutMs?: number,
|
|
113
|
-
maxPeers?: number,
|
|
114
|
-
maxRetryAttempts?: number,
|
|
115
|
-
): Promise<InstanceType<SubProtocolMap[Protocol]['response']>[]>;
|
|
116
|
-
|
|
117
98
|
// Leaky abstraction: fix https://github.com/AztecProtocol/aztec-packages/issues/7963
|
|
118
99
|
registerBlockReceivedCallback(callback: P2PBlockReceivedCallback): void;
|
|
119
100
|
|
|
@@ -121,9 +102,6 @@ export interface P2PService {
|
|
|
121
102
|
|
|
122
103
|
registerAllNodesCheckpointReceivedCallback(callback: P2PCheckpointReceivedCallback): void;
|
|
123
104
|
|
|
124
|
-
/** Fires the all-nodes checkpoint callback for our own proposal (gossipsub doesn't deliver own messages). */
|
|
125
|
-
notifyOwnCheckpointProposal(checkpoint: CheckpointProposalCore): Promise<void>;
|
|
126
|
-
|
|
127
105
|
/**
|
|
128
106
|
* Registers a callback invoked when a duplicate proposal is detected (equivocation).
|
|
129
107
|
* The callback is triggered on the first duplicate (when count goes from 1 to 2).
|
|
@@ -137,6 +115,8 @@ export interface P2PService {
|
|
|
137
115
|
*/
|
|
138
116
|
registerDuplicateAttestationCallback(callback: P2PDuplicateAttestationCallback): void;
|
|
139
117
|
|
|
118
|
+
registerCheckpointAttestationCallback(callback: P2PCheckpointAttestationCallback): void;
|
|
119
|
+
|
|
140
120
|
getEnr(): ENR | undefined;
|
|
141
121
|
|
|
142
122
|
getPeers(includePending?: boolean): PeerInfo[];
|
|
@@ -146,11 +126,7 @@ export interface P2PService {
|
|
|
146
126
|
|
|
147
127
|
validateTxsReceivedInBlockProposal(txs: Tx[]): Promise<void>;
|
|
148
128
|
|
|
149
|
-
addReqRespSubProtocol(
|
|
150
|
-
subProtocol: ReqRespSubProtocol,
|
|
151
|
-
handler: ReqRespSubProtocolHandler,
|
|
152
|
-
validator?: ReqRespSubProtocolValidators[ReqRespSubProtocol],
|
|
153
|
-
): Promise<void>;
|
|
129
|
+
addReqRespSubProtocol(subProtocol: ReqRespSubProtocol, handler: ReqRespSubProtocolHandler): Promise<void>;
|
|
154
130
|
|
|
155
131
|
handleAuthRequestFromPeer(authRequest: AuthRequest, peerId: PeerId): Promise<StatusMessage>;
|
|
156
132
|
|
|
@@ -201,6 +177,9 @@ export interface PeerDiscoveryService extends EventEmitter {
|
|
|
201
177
|
on(event: 'peer:discovered', listener: (enr: ENR) => void): this;
|
|
202
178
|
emit(event: 'peer:discovered', enr: ENR): boolean;
|
|
203
179
|
|
|
180
|
+
on(event: 'ip:changed', listener: (ip: string) => void): this;
|
|
181
|
+
emit(event: 'ip:changed', ip: string): boolean;
|
|
182
|
+
|
|
204
183
|
getStatus(): PeerDiscoveryState;
|
|
205
184
|
|
|
206
185
|
getEnr(): ENR | undefined;
|
|
@@ -1,26 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type ConfigMappingsType,
|
|
3
|
-
booleanConfigHelper,
|
|
4
|
-
enumConfigHelper,
|
|
5
|
-
numberConfigHelper,
|
|
6
|
-
} from '@aztec/foundation/config';
|
|
1
|
+
import { type ConfigMappingsType, numberConfigHelper } from '@aztec/foundation/config';
|
|
7
2
|
import { MAX_RPC_TXS_LEN } from '@aztec/stdlib/interfaces/api-limit';
|
|
8
3
|
|
|
9
|
-
export type MissingTxsCollectorType = 'new' | 'old';
|
|
10
|
-
|
|
11
4
|
export type TxCollectionConfig = {
|
|
12
5
|
/** How long to wait before starting reqresp for fast collection */
|
|
13
6
|
txCollectionFastNodesTimeoutBeforeReqRespMs: number;
|
|
14
|
-
/** How often to collect from configured nodes */
|
|
15
|
-
txCollectionSlowNodesIntervalMs: number;
|
|
16
|
-
/** How ofter to collect from peers */
|
|
17
|
-
txCollectionSlowReqRespIntervalMs: number;
|
|
18
|
-
/** How long to wait for a reqresp response during slow collection */
|
|
19
|
-
txCollectionSlowReqRespTimeoutMs: number;
|
|
20
|
-
/** How often to reconcile found txs with the tx pool */
|
|
21
|
-
txCollectionReconcileIntervalMs: number;
|
|
22
|
-
/** Whether to disable the slow collection loop if we are dealing with any immediate requests */
|
|
23
|
-
txCollectionDisableSlowDuringFastRequests: boolean;
|
|
24
7
|
/** How many ms to wait between retried request to a node via RPC during fast collection */
|
|
25
8
|
txCollectionFastNodeIntervalMs: number;
|
|
26
9
|
/** A comma-separated list of Aztec node RPC URLs to use for tx collection */
|
|
@@ -29,26 +12,16 @@ export type TxCollectionConfig = {
|
|
|
29
12
|
txCollectionFastMaxParallelRequestsPerNode: number;
|
|
30
13
|
/** Maximum number of transactions to request from a node in a single batch */
|
|
31
14
|
txCollectionNodeRpcMaxBatchSize: number;
|
|
32
|
-
/** Which collector implementation to use for missing txs collection */
|
|
33
|
-
txCollectionMissingTxsCollectorType: MissingTxsCollectorType;
|
|
34
15
|
/** A comma-separated list of file store URLs (s3://, gs://, file://, http://) for tx collection */
|
|
35
16
|
txCollectionFileStoreUrls: string[];
|
|
36
|
-
/** Delay in ms before file store collection
|
|
37
|
-
txCollectionFileStoreSlowDelayMs: number;
|
|
38
|
-
/** Delay in ms before file store collection starts after fast collection is triggered */
|
|
17
|
+
/** Delay in ms from reqresp start before file store collection begins */
|
|
39
18
|
txCollectionFileStoreFastDelayMs: number;
|
|
40
19
|
/** Number of concurrent workers for fast file store collection */
|
|
41
20
|
txCollectionFileStoreFastWorkerCount: number;
|
|
42
|
-
/** Number of concurrent workers for slow file store collection */
|
|
43
|
-
txCollectionFileStoreSlowWorkerCount: number;
|
|
44
21
|
/** Base backoff time in ms for fast file store collection retries */
|
|
45
22
|
txCollectionFileStoreFastBackoffBaseMs: number;
|
|
46
|
-
/** Base backoff time in ms for slow file store collection retries */
|
|
47
|
-
txCollectionFileStoreSlowBackoffBaseMs: number;
|
|
48
23
|
/** Max backoff time in ms for fast file store collection retries */
|
|
49
24
|
txCollectionFileStoreFastBackoffMaxMs: number;
|
|
50
|
-
/** Max backoff time in ms for slow file store collection retries */
|
|
51
|
-
txCollectionFileStoreSlowBackoffMaxMs: number;
|
|
52
25
|
};
|
|
53
26
|
|
|
54
27
|
export const txCollectionConfigMappings: ConfigMappingsType<TxCollectionConfig> = {
|
|
@@ -57,31 +30,6 @@ export const txCollectionConfigMappings: ConfigMappingsType<TxCollectionConfig>
|
|
|
57
30
|
description: 'How long to wait before starting reqresp for fast collection',
|
|
58
31
|
...numberConfigHelper(200),
|
|
59
32
|
},
|
|
60
|
-
txCollectionSlowNodesIntervalMs: {
|
|
61
|
-
env: 'TX_COLLECTION_SLOW_NODES_INTERVAL_MS',
|
|
62
|
-
description: 'How often to collect from configured nodes in the slow collection loop',
|
|
63
|
-
...numberConfigHelper(12_000),
|
|
64
|
-
},
|
|
65
|
-
txCollectionSlowReqRespIntervalMs: {
|
|
66
|
-
env: 'TX_COLLECTION_SLOW_REQ_RESP_INTERVAL_MS',
|
|
67
|
-
description: 'How often to collect from peers via reqresp in the slow collection loop',
|
|
68
|
-
...numberConfigHelper(12_000),
|
|
69
|
-
},
|
|
70
|
-
txCollectionSlowReqRespTimeoutMs: {
|
|
71
|
-
env: 'TX_COLLECTION_SLOW_REQ_RESP_TIMEOUT_MS',
|
|
72
|
-
description: 'How long to wait for a reqresp response during slow collection',
|
|
73
|
-
...numberConfigHelper(20_000),
|
|
74
|
-
},
|
|
75
|
-
txCollectionReconcileIntervalMs: {
|
|
76
|
-
env: 'TX_COLLECTION_RECONCILE_INTERVAL_MS',
|
|
77
|
-
description: 'How often to reconcile found txs from the tx pool',
|
|
78
|
-
...numberConfigHelper(60_000),
|
|
79
|
-
},
|
|
80
|
-
txCollectionDisableSlowDuringFastRequests: {
|
|
81
|
-
env: 'TX_COLLECTION_DISABLE_SLOW_DURING_FAST_REQUESTS',
|
|
82
|
-
description: 'Whether to disable the slow collection loop if we are dealing with any immediate requests',
|
|
83
|
-
...booleanConfigHelper(true),
|
|
84
|
-
},
|
|
85
33
|
txCollectionFastNodeIntervalMs: {
|
|
86
34
|
env: 'TX_COLLECTION_FAST_NODE_INTERVAL_MS',
|
|
87
35
|
description: 'How many ms to wait between retried request to a node via RPC during fast collection',
|
|
@@ -108,11 +56,6 @@ export const txCollectionConfigMappings: ConfigMappingsType<TxCollectionConfig>
|
|
|
108
56
|
description: 'Maximum number of transactions to request from a node in a single batch',
|
|
109
57
|
...numberConfigHelper(MAX_RPC_TXS_LEN),
|
|
110
58
|
},
|
|
111
|
-
txCollectionMissingTxsCollectorType: {
|
|
112
|
-
env: 'TX_COLLECTION_MISSING_TXS_COLLECTOR_TYPE',
|
|
113
|
-
description: 'Which collector implementation to use for missing txs collection (new or old)',
|
|
114
|
-
...enumConfigHelper(['new', 'old'] as const, 'new'),
|
|
115
|
-
},
|
|
116
59
|
txCollectionFileStoreUrls: {
|
|
117
60
|
env: 'TX_COLLECTION_FILE_STORE_URLS',
|
|
118
61
|
description: 'A comma-separated list of file store URLs (s3://, gs://, file://, http://) for tx collection',
|
|
@@ -123,14 +66,9 @@ export const txCollectionConfigMappings: ConfigMappingsType<TxCollectionConfig>
|
|
|
123
66
|
.filter(url => url.length > 0),
|
|
124
67
|
defaultValue: [],
|
|
125
68
|
},
|
|
126
|
-
txCollectionFileStoreSlowDelayMs: {
|
|
127
|
-
env: 'TX_COLLECTION_FILE_STORE_SLOW_DELAY_MS',
|
|
128
|
-
description: 'Delay before file store collection starts after slow collection',
|
|
129
|
-
...numberConfigHelper(24_000),
|
|
130
|
-
},
|
|
131
69
|
txCollectionFileStoreFastDelayMs: {
|
|
132
70
|
env: 'TX_COLLECTION_FILE_STORE_FAST_DELAY_MS',
|
|
133
|
-
description: 'Delay before file store collection
|
|
71
|
+
description: 'Delay in ms from reqresp start before file store collection begins',
|
|
134
72
|
...numberConfigHelper(2_000),
|
|
135
73
|
},
|
|
136
74
|
txCollectionFileStoreFastWorkerCount: {
|
|
@@ -138,29 +76,14 @@ export const txCollectionConfigMappings: ConfigMappingsType<TxCollectionConfig>
|
|
|
138
76
|
description: 'Number of concurrent workers for fast file store collection',
|
|
139
77
|
...numberConfigHelper(5),
|
|
140
78
|
},
|
|
141
|
-
txCollectionFileStoreSlowWorkerCount: {
|
|
142
|
-
env: 'TX_COLLECTION_FILE_STORE_SLOW_WORKER_COUNT',
|
|
143
|
-
description: 'Number of concurrent workers for slow file store collection',
|
|
144
|
-
...numberConfigHelper(2),
|
|
145
|
-
},
|
|
146
79
|
txCollectionFileStoreFastBackoffBaseMs: {
|
|
147
80
|
env: 'TX_COLLECTION_FILE_STORE_FAST_BACKOFF_BASE_MS',
|
|
148
81
|
description: 'Base backoff time in ms for fast file store collection retries',
|
|
149
82
|
...numberConfigHelper(1_000),
|
|
150
83
|
},
|
|
151
|
-
txCollectionFileStoreSlowBackoffBaseMs: {
|
|
152
|
-
env: 'TX_COLLECTION_FILE_STORE_SLOW_BACKOFF_BASE_MS',
|
|
153
|
-
description: 'Base backoff time in ms for slow file store collection retries',
|
|
154
|
-
...numberConfigHelper(5_000),
|
|
155
|
-
},
|
|
156
84
|
txCollectionFileStoreFastBackoffMaxMs: {
|
|
157
85
|
env: 'TX_COLLECTION_FILE_STORE_FAST_BACKOFF_MAX_MS',
|
|
158
86
|
description: 'Max backoff time in ms for fast file store collection retries',
|
|
159
87
|
...numberConfigHelper(5_000),
|
|
160
88
|
},
|
|
161
|
-
txCollectionFileStoreSlowBackoffMaxMs: {
|
|
162
|
-
env: 'TX_COLLECTION_FILE_STORE_SLOW_BACKOFF_MAX_MS',
|
|
163
|
-
description: 'Max backoff time in ms for slow file store collection retries',
|
|
164
|
-
...numberConfigHelper(30_000),
|
|
165
|
-
},
|
|
166
89
|
};
|