@aztec/p2p 0.0.1-commit.d6f2b3f94 → 0.0.1-commit.dbf9cec
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/factory.d.ts +6 -6
- package/dest/client/factory.d.ts.map +1 -1
- package/dest/client/factory.js +23 -30
- package/dest/client/interface.d.ts +14 -19
- package/dest/client/interface.d.ts.map +1 -1
- package/dest/client/p2p_client.d.ts +9 -18
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +52 -72
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +6 -7
- package/dest/config.d.ts +13 -6
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +5 -5
- package/dest/errors/tx-pool.error.d.ts +8 -0
- package/dest/errors/tx-pool.error.d.ts.map +1 -0
- package/dest/errors/tx-pool.error.js +9 -0
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +4 -2
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool.js +5 -0
- package/dest/mem_pools/attestation_pool/mocks.d.ts +2 -2
- package/dest/mem_pools/attestation_pool/mocks.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/mocks.js +2 -2
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.js +3 -3
- package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts +30 -13
- package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/deleted_pool.js +91 -20
- package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts +3 -3
- package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.js +18 -9
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.js +5 -2
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts +3 -3
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.js +12 -4
- package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts +2 -2
- package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/index.js +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts +48 -5
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.js +8 -0
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.js +7 -5
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.js +7 -5
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts +2 -2
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.js +14 -6
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts +4 -4
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.js +14 -4
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts +3 -3
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.js +2 -2
- package/dest/mem_pools/tx_pool_v2/index.d.ts +2 -2
- package/dest/mem_pools/tx_pool_v2/index.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/index.js +1 -1
- package/dest/mem_pools/tx_pool_v2/instrumentation.d.ts +15 -0
- package/dest/mem_pools/tx_pool_v2/instrumentation.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/instrumentation.js +43 -0
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts +20 -6
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/interfaces.js +4 -1
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +34 -8
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_metadata.js +76 -10
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts +12 -3
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.js +36 -14
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts +9 -4
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.js +11 -6
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +13 -5
- 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 +297 -143
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts +2 -2
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.js +3 -3
- package/dest/msg_validators/tx_validator/factory.d.ts +114 -6
- package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/factory.js +219 -58
- package/dest/msg_validators/tx_validator/gas_validator.d.ts +58 -3
- package/dest/msg_validators/tx_validator/gas_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/gas_validator.js +73 -36
- package/dest/msg_validators/tx_validator/index.d.ts +2 -1
- package/dest/msg_validators/tx_validator/index.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/index.js +1 -0
- package/dest/msg_validators/tx_validator/nullifier_cache.d.ts +14 -0
- package/dest/msg_validators/tx_validator/nullifier_cache.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/nullifier_cache.js +24 -0
- package/dest/msg_validators/tx_validator/timestamp_validator.d.ts +2 -2
- package/dest/msg_validators/tx_validator/timestamp_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/timestamp_validator.js +6 -6
- package/dest/services/dummy_service.d.ts +4 -4
- package/dest/services/dummy_service.d.ts.map +1 -1
- package/dest/services/dummy_service.js +4 -4
- package/dest/services/encoding.d.ts +2 -2
- package/dest/services/encoding.d.ts.map +1 -1
- package/dest/services/encoding.js +9 -8
- package/dest/services/gossipsub/topic_score_params.d.ts +18 -6
- package/dest/services/gossipsub/topic_score_params.d.ts.map +1 -1
- package/dest/services/gossipsub/topic_score_params.js +32 -10
- package/dest/services/libp2p/libp2p_service.d.ts +16 -13
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +69 -81
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts +4 -3
- 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 +19 -46
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts +2 -6
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts +10 -13
- package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/missing_txs.js +25 -46
- package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts +17 -11
- package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/peer_collection.js +49 -15
- package/dest/services/reqresp/batch-tx-requester/tx_validator.js +2 -2
- package/dest/services/reqresp/reqresp.d.ts +1 -1
- package/dest/services/reqresp/reqresp.d.ts.map +1 -1
- package/dest/services/reqresp/reqresp.js +2 -1
- package/dest/services/service.d.ts +5 -3
- package/dest/services/service.d.ts.map +1 -1
- package/dest/services/tx_collection/config.d.ts +13 -1
- package/dest/services/tx_collection/config.d.ts.map +1 -1
- package/dest/services/tx_collection/config.js +30 -0
- package/dest/services/tx_collection/fast_tx_collection.d.ts +1 -1
- package/dest/services/tx_collection/fast_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/fast_tx_collection.js +39 -33
- package/dest/services/tx_collection/file_store_tx_collection.d.ts +38 -29
- package/dest/services/tx_collection/file_store_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/file_store_tx_collection.js +126 -77
- package/dest/services/tx_collection/file_store_tx_source.d.ts +16 -6
- package/dest/services/tx_collection/file_store_tx_source.d.ts.map +1 -1
- package/dest/services/tx_collection/file_store_tx_source.js +49 -16
- 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 +2 -1
- package/dest/services/tx_collection/missing_txs_tracker.d.ts +32 -0
- package/dest/services/tx_collection/missing_txs_tracker.d.ts.map +1 -0
- package/dest/services/tx_collection/missing_txs_tracker.js +27 -0
- package/dest/services/tx_collection/proposal_tx_collector.d.ts +7 -6
- package/dest/services/tx_collection/proposal_tx_collector.d.ts.map +1 -1
- package/dest/services/tx_collection/proposal_tx_collector.js +5 -4
- package/dest/services/tx_collection/slow_tx_collection.d.ts +5 -3
- package/dest/services/tx_collection/slow_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/slow_tx_collection.js +17 -12
- package/dest/services/tx_collection/tx_collection.d.ts +9 -6
- package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_collection.js +26 -10
- package/dest/services/tx_collection/tx_collection_sink.d.ts +6 -5
- package/dest/services/tx_collection/tx_collection_sink.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_collection_sink.js +13 -22
- package/dest/services/tx_collection/tx_source.d.ts +8 -3
- package/dest/services/tx_collection/tx_source.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_source.js +19 -2
- package/dest/services/tx_file_store/tx_file_store.d.ts +3 -2
- package/dest/services/tx_file_store/tx_file_store.d.ts.map +1 -1
- package/dest/services/tx_file_store/tx_file_store.js +9 -6
- package/dest/services/tx_provider.d.ts +3 -3
- package/dest/services/tx_provider.d.ts.map +1 -1
- package/dest/services/tx_provider.js +4 -4
- package/dest/test-helpers/make-test-p2p-clients.d.ts +5 -6
- package/dest/test-helpers/make-test-p2p-clients.d.ts.map +1 -1
- package/dest/test-helpers/make-test-p2p-clients.js +1 -2
- package/dest/test-helpers/mock-pubsub.d.ts +4 -4
- package/dest/test-helpers/mock-pubsub.d.ts.map +1 -1
- package/dest/test-helpers/mock-pubsub.js +8 -2
- package/dest/test-helpers/reqresp-nodes.d.ts +2 -3
- package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
- package/dest/test-helpers/reqresp-nodes.js +2 -2
- package/dest/test-helpers/testbench-utils.d.ts +8 -3
- package/dest/test-helpers/testbench-utils.d.ts.map +1 -1
- package/dest/test-helpers/testbench-utils.js +7 -1
- package/dest/testbench/p2p_client_testbench_worker.d.ts +2 -2
- package/dest/testbench/p2p_client_testbench_worker.d.ts.map +1 -1
- package/dest/testbench/p2p_client_testbench_worker.js +13 -13
- package/dest/util.d.ts +2 -2
- package/dest/util.d.ts.map +1 -1
- package/package.json +14 -14
- package/src/client/factory.ts +39 -48
- package/src/client/interface.ts +17 -20
- package/src/client/p2p_client.ts +60 -104
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +19 -10
- package/src/config.ts +10 -10
- package/src/errors/tx-pool.error.ts +12 -0
- package/src/mem_pools/attestation_pool/attestation_pool.ts +8 -0
- package/src/mem_pools/attestation_pool/mocks.ts +2 -1
- package/src/mem_pools/tx_pool/README.md +1 -1
- package/src/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.ts +3 -3
- package/src/mem_pools/tx_pool_v2/README.md +43 -27
- package/src/mem_pools/tx_pool_v2/deleted_pool.ts +109 -22
- package/src/mem_pools/tx_pool_v2/eviction/eviction_manager.ts +21 -8
- package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.ts +5 -2
- package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.ts +18 -4
- package/src/mem_pools/tx_pool_v2/eviction/index.ts +4 -0
- package/src/mem_pools/tx_pool_v2/eviction/interfaces.ts +49 -4
- package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.ts +5 -5
- package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.ts +5 -5
- package/src/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.ts +14 -9
- package/src/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.ts +24 -6
- package/src/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.ts +3 -3
- package/src/mem_pools/tx_pool_v2/index.ts +1 -1
- package/src/mem_pools/tx_pool_v2/instrumentation.ts +69 -0
- package/src/mem_pools/tx_pool_v2/interfaces.ts +21 -6
- package/src/mem_pools/tx_pool_v2/tx_metadata.ts +107 -17
- package/src/mem_pools/tx_pool_v2/tx_pool_indices.ts +43 -16
- package/src/mem_pools/tx_pool_v2/tx_pool_v2.ts +18 -7
- package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +326 -138
- package/src/msg_validators/tx_validator/README.md +115 -0
- package/src/msg_validators/tx_validator/aggregate_tx_validator.ts +3 -3
- package/src/msg_validators/tx_validator/factory.ts +353 -77
- package/src/msg_validators/tx_validator/gas_validator.ts +90 -27
- package/src/msg_validators/tx_validator/index.ts +1 -0
- package/src/msg_validators/tx_validator/nullifier_cache.ts +30 -0
- package/src/msg_validators/tx_validator/timestamp_validator.ts +7 -7
- package/src/services/dummy_service.ts +6 -6
- package/src/services/encoding.ts +7 -7
- package/src/services/gossipsub/README.md +29 -14
- package/src/services/gossipsub/topic_score_params.ts +49 -13
- package/src/services/libp2p/libp2p_service.ts +80 -90
- package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +20 -48
- package/src/services/reqresp/batch-tx-requester/interface.ts +1 -5
- package/src/services/reqresp/batch-tx-requester/missing_txs.ts +23 -71
- package/src/services/reqresp/batch-tx-requester/peer_collection.ts +63 -24
- package/src/services/reqresp/batch-tx-requester/tx_validator.ts +2 -2
- package/src/services/reqresp/reqresp.ts +3 -1
- package/src/services/service.ts +11 -2
- package/src/services/tx_collection/config.ts +42 -0
- package/src/services/tx_collection/fast_tx_collection.ts +51 -30
- package/src/services/tx_collection/file_store_tx_collection.ts +143 -93
- package/src/services/tx_collection/file_store_tx_source.ts +64 -17
- package/src/services/tx_collection/instrumentation.ts +7 -1
- package/src/services/tx_collection/missing_txs_tracker.ts +52 -0
- package/src/services/tx_collection/proposal_tx_collector.ts +8 -7
- package/src/services/tx_collection/slow_tx_collection.ts +17 -13
- package/src/services/tx_collection/tx_collection.ts +45 -14
- package/src/services/tx_collection/tx_collection_sink.ts +15 -29
- package/src/services/tx_collection/tx_source.ts +22 -3
- package/src/services/tx_file_store/tx_file_store.ts +6 -4
- package/src/services/tx_provider.ts +2 -2
- package/src/test-helpers/make-test-p2p-clients.ts +0 -2
- package/src/test-helpers/mock-pubsub.ts +13 -6
- package/src/test-helpers/reqresp-nodes.ts +2 -5
- package/src/test-helpers/testbench-utils.ts +11 -3
- package/src/testbench/p2p_client_testbench_worker.ts +22 -19
- package/src/util.ts +7 -1
|
@@ -16,13 +16,12 @@ import {
|
|
|
16
16
|
CheckpointProposal,
|
|
17
17
|
type CheckpointProposalCore,
|
|
18
18
|
type Gossipable,
|
|
19
|
-
P2PClientType,
|
|
20
19
|
P2PMessage,
|
|
21
20
|
type ValidationResult as P2PValidationResult,
|
|
22
21
|
PeerErrorSeverity,
|
|
23
22
|
TopicType,
|
|
24
23
|
createTopicString,
|
|
25
|
-
|
|
24
|
+
getTopicsForConfig,
|
|
26
25
|
metricsTopicStrToLabels,
|
|
27
26
|
} from '@aztec/stdlib/p2p';
|
|
28
27
|
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
@@ -69,9 +68,11 @@ import {
|
|
|
69
68
|
} from '../../msg_validators/index.js';
|
|
70
69
|
import { MessageSeenValidator } from '../../msg_validators/msg_seen_validator/msg_seen_validator.js';
|
|
71
70
|
import {
|
|
72
|
-
type
|
|
73
|
-
|
|
74
|
-
|
|
71
|
+
type TransactionValidator,
|
|
72
|
+
createFirstStageTxValidationsForGossipedTransactions,
|
|
73
|
+
createSecondStageTxValidationsForGossipedTransactions,
|
|
74
|
+
createTxValidatorForBlockProposalReceivedTxs,
|
|
75
|
+
createTxValidatorForReqResponseReceivedTxs,
|
|
75
76
|
} from '../../msg_validators/tx_validator/factory.js';
|
|
76
77
|
import { GossipSubEvent } from '../../types/index.js';
|
|
77
78
|
import { type PubSubLibp2p, convertToMultiaddr } from '../../util.js';
|
|
@@ -87,6 +88,9 @@ import { PeerScoring } from '../peer-manager/peer_scoring.js';
|
|
|
87
88
|
import type { BatchTxRequesterLibP2PService } from '../reqresp/batch-tx-requester/interface.js';
|
|
88
89
|
import type { P2PReqRespConfig } from '../reqresp/config.js';
|
|
89
90
|
import {
|
|
91
|
+
AuthRequest,
|
|
92
|
+
BlockTxsRequest,
|
|
93
|
+
BlockTxsResponse,
|
|
90
94
|
DEFAULT_SUB_PROTOCOL_VALIDATORS,
|
|
91
95
|
type ReqRespInterface,
|
|
92
96
|
type ReqRespResponse,
|
|
@@ -94,14 +98,9 @@ import {
|
|
|
94
98
|
type ReqRespSubProtocolHandler,
|
|
95
99
|
type ReqRespSubProtocolHandlers,
|
|
96
100
|
type ReqRespSubProtocolValidators,
|
|
101
|
+
StatusMessage,
|
|
97
102
|
type SubProtocolMap,
|
|
98
103
|
ValidationError,
|
|
99
|
-
} from '../reqresp/index.js';
|
|
100
|
-
import {
|
|
101
|
-
AuthRequest,
|
|
102
|
-
BlockTxsRequest,
|
|
103
|
-
BlockTxsResponse,
|
|
104
|
-
StatusMessage,
|
|
105
104
|
pingHandler,
|
|
106
105
|
reqGoodbyeHandler,
|
|
107
106
|
reqRespBlockHandler,
|
|
@@ -135,7 +134,7 @@ type ReceivedMessageValidationResult<T, M = undefined> =
|
|
|
135
134
|
/**
|
|
136
135
|
* Lib P2P implementation of the P2PService interface.
|
|
137
136
|
*/
|
|
138
|
-
export class LibP2PService
|
|
137
|
+
export class LibP2PService extends WithTracer implements P2PService {
|
|
139
138
|
private discoveryRunningPromise?: RunningPromise;
|
|
140
139
|
private msgIdSeenValidators: Record<TopicType, MessageSeenValidator> = {} as Record<TopicType, MessageSeenValidator>;
|
|
141
140
|
|
|
@@ -182,7 +181,6 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
182
181
|
protected logger: Logger;
|
|
183
182
|
|
|
184
183
|
constructor(
|
|
185
|
-
private clientType: T,
|
|
186
184
|
private config: P2PConfig,
|
|
187
185
|
protected node: PubSubLibp2p,
|
|
188
186
|
private peerDiscoveryService: PeerDiscoveryService,
|
|
@@ -262,8 +260,7 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
262
260
|
* @param txPool - The transaction pool to be accessed by the service.
|
|
263
261
|
* @returns The new service.
|
|
264
262
|
*/
|
|
265
|
-
public static async new
|
|
266
|
-
clientType: T,
|
|
263
|
+
public static async new(
|
|
267
264
|
config: P2PConfig,
|
|
268
265
|
peerId: PeerId,
|
|
269
266
|
deps: {
|
|
@@ -341,6 +338,7 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
341
338
|
heartbeatIntervalMs: config.gossipsubInterval,
|
|
342
339
|
targetCommitteeSize: l1Constants.targetCommitteeSize,
|
|
343
340
|
blockDurationMs: config.blockDurationMs,
|
|
341
|
+
expectedBlockProposalsPerSlot: config.expectedBlockProposalsPerSlot,
|
|
344
342
|
});
|
|
345
343
|
|
|
346
344
|
const node = await createLibp2p({
|
|
@@ -474,7 +472,6 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
474
472
|
peerManager.shouldDisableP2PGossip(peerId) ? -Infinity : peerManager.getPeerScore(peerId);
|
|
475
473
|
|
|
476
474
|
return new LibP2PService(
|
|
477
|
-
clientType,
|
|
478
475
|
config,
|
|
479
476
|
node,
|
|
480
477
|
peerDiscoveryService,
|
|
@@ -548,7 +545,7 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
548
545
|
await this.node.start();
|
|
549
546
|
|
|
550
547
|
// Subscribe to standard GossipSub topics by default
|
|
551
|
-
for (const topic of
|
|
548
|
+
for (const topic of getTopicsForConfig(this.config.disableTransactions)) {
|
|
552
549
|
this.subscribeToTopic(this.topicStrings[topic]);
|
|
553
550
|
}
|
|
554
551
|
|
|
@@ -614,6 +611,10 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
614
611
|
return this.peerManager.getPeers(includePending);
|
|
615
612
|
}
|
|
616
613
|
|
|
614
|
+
public getGossipMeshPeerCount(topicType: TopicType): number {
|
|
615
|
+
return this.node.services.pubsub.getMeshPeers(this.topicStrings[topicType]).length;
|
|
616
|
+
}
|
|
617
|
+
|
|
617
618
|
private handleGossipSubEvent(e: CustomEvent<GossipsubMessage>) {
|
|
618
619
|
this.logger.trace(`Received PUBSUB message.`);
|
|
619
620
|
|
|
@@ -813,9 +814,7 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
813
814
|
if (msg.topic === this.topicStrings[TopicType.tx]) {
|
|
814
815
|
await this.handleGossipedTx(p2pMessage.payload, msgId, source);
|
|
815
816
|
} else if (msg.topic === this.topicStrings[TopicType.checkpoint_attestation]) {
|
|
816
|
-
|
|
817
|
-
await this.processCheckpointAttestationFromPeer(p2pMessage.payload, msgId, source);
|
|
818
|
-
}
|
|
817
|
+
await this.processCheckpointAttestationFromPeer(p2pMessage.payload, msgId, source);
|
|
819
818
|
} else if (msg.topic === this.topicStrings[TopicType.block_proposal]) {
|
|
820
819
|
await this.processBlockFromPeer(p2pMessage.payload, msgId, source);
|
|
821
820
|
} else if (msg.topic === this.topicStrings[TopicType.checkpoint_proposal]) {
|
|
@@ -901,15 +900,45 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
901
900
|
protected async handleGossipedTx(payloadData: Buffer, msgId: string, source: PeerId) {
|
|
902
901
|
const validationFunc: () => Promise<ReceivedMessageValidationResult<Tx>> = async () => {
|
|
903
902
|
const tx = Tx.fromBuffer(payloadData);
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
903
|
+
|
|
904
|
+
const currentBlockNumber = await this.archiver.getBlockNumber();
|
|
905
|
+
const { ts: nextSlotTimestamp } = this.epochCache.getEpochAndSlotInNextL1Slot();
|
|
906
|
+
|
|
907
|
+
// Stage 1: fast validators (metadata, data, timestamps, double-spend, gas, phases, block header)
|
|
908
|
+
const firstStageValidators = await this.createFirstStageMessageValidators(currentBlockNumber, nextSlotTimestamp);
|
|
909
|
+
const firstStageOutcome = await this.runValidations(tx, firstStageValidators);
|
|
910
|
+
if (!firstStageOutcome.allPassed) {
|
|
911
|
+
const { name } = firstStageOutcome.failure;
|
|
912
|
+
let { severity } = firstStageOutcome.failure;
|
|
913
|
+
|
|
914
|
+
// Double spend validator has a special case handler. We perform more detailed examination
|
|
915
|
+
// as to how recently the nullifier was entered into the tree and if the transaction should
|
|
916
|
+
// have 'known' the nullifier existed. This determines the severity of the penalty applied to the peer.
|
|
917
|
+
if (name === 'doubleSpendValidator') {
|
|
918
|
+
const txBlockNumber = BlockNumber(currentBlockNumber + 1);
|
|
919
|
+
severity = await this.handleDoubleSpendFailure(tx, txBlockNumber);
|
|
920
|
+
}
|
|
921
|
+
|
|
922
|
+
this.peerManager.penalizePeer(source, severity);
|
|
923
|
+
return { result: TopicValidatorResult.Reject };
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
// Pool pre-check: see if the pool would accept this tx before doing expensive proof verification
|
|
927
|
+
const canAdd = await this.mempools.txPool.canAddPendingTx(tx);
|
|
928
|
+
if (canAdd === 'ignored') {
|
|
929
|
+
return { result: TopicValidatorResult.Ignore, obj: tx };
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
// Stage 2: expensive proof verification
|
|
933
|
+
const secondStageValidators = this.createSecondStageMessageValidators();
|
|
934
|
+
const secondStageOutcome = await this.runValidations(tx, secondStageValidators);
|
|
935
|
+
if (!secondStageOutcome.allPassed) {
|
|
936
|
+
const { severity } = secondStageOutcome.failure;
|
|
937
|
+
this.peerManager.penalizePeer(source, severity);
|
|
909
938
|
return { result: TopicValidatorResult.Reject };
|
|
910
939
|
}
|
|
911
940
|
|
|
912
|
-
//
|
|
941
|
+
// Pool add: persist the tx
|
|
913
942
|
const txHash = tx.getTxHash();
|
|
914
943
|
const addResult = await this.mempools.txPool.addPendingTxs([tx], { source: 'gossip' });
|
|
915
944
|
|
|
@@ -917,7 +946,6 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
917
946
|
const wasIgnored = addResult.ignored.some(h => h.equals(txHash));
|
|
918
947
|
|
|
919
948
|
this.logger.trace(`Validate propagated tx`, {
|
|
920
|
-
isValid,
|
|
921
949
|
wasAccepted,
|
|
922
950
|
wasIgnored,
|
|
923
951
|
[Attributes.P2P_ID]: source.toString(),
|
|
@@ -1532,43 +1560,12 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
1532
1560
|
}
|
|
1533
1561
|
|
|
1534
1562
|
protected createRequestedTxValidator(): TxValidator {
|
|
1535
|
-
return
|
|
1563
|
+
return createTxValidatorForReqResponseReceivedTxs(this.proofVerifier, {
|
|
1536
1564
|
l1ChainId: this.config.l1ChainId,
|
|
1537
1565
|
rollupVersion: this.config.rollupVersion,
|
|
1538
1566
|
});
|
|
1539
1567
|
}
|
|
1540
1568
|
|
|
1541
|
-
@trackSpan('Libp2pService.validatePropagatedTx', tx => ({
|
|
1542
|
-
[Attributes.TX_HASH]: tx.getTxHash().toString(),
|
|
1543
|
-
}))
|
|
1544
|
-
protected async validatePropagatedTx(tx: Tx, peerId: PeerId): Promise<boolean> {
|
|
1545
|
-
const currentBlockNumber = await this.archiver.getBlockNumber();
|
|
1546
|
-
|
|
1547
|
-
// We accept transactions if they are not expired by the next slot (checked based on the IncludeByTimestamp field)
|
|
1548
|
-
const { ts: nextSlotTimestamp } = this.epochCache.getEpochAndSlotInNextL1Slot();
|
|
1549
|
-
const messageValidators = await this.createMessageValidators(currentBlockNumber, nextSlotTimestamp);
|
|
1550
|
-
|
|
1551
|
-
for (const validator of messageValidators) {
|
|
1552
|
-
const outcome = await this.runValidations(tx, validator);
|
|
1553
|
-
|
|
1554
|
-
if (outcome.allPassed) {
|
|
1555
|
-
continue;
|
|
1556
|
-
}
|
|
1557
|
-
const { name } = outcome.failure;
|
|
1558
|
-
let { severity } = outcome.failure;
|
|
1559
|
-
|
|
1560
|
-
// Double spend validator has a special case handler
|
|
1561
|
-
if (name === 'doubleSpendValidator') {
|
|
1562
|
-
const txBlockNumber = BlockNumber(currentBlockNumber + 1); // tx is expected to be in the next block
|
|
1563
|
-
severity = await this.handleDoubleSpendFailure(tx, txBlockNumber);
|
|
1564
|
-
}
|
|
1565
|
-
|
|
1566
|
-
this.peerManager.penalizePeer(peerId, severity);
|
|
1567
|
-
return false;
|
|
1568
|
-
}
|
|
1569
|
-
return true;
|
|
1570
|
-
}
|
|
1571
|
-
|
|
1572
1569
|
private async getGasFees(blockNumber: BlockNumber): Promise<GasFees> {
|
|
1573
1570
|
if (blockNumber === this.feesCache?.blockNumber) {
|
|
1574
1571
|
return this.feesCache.gasFees;
|
|
@@ -1596,60 +1593,53 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
1596
1593
|
};
|
|
1597
1594
|
}
|
|
1598
1595
|
|
|
1599
|
-
public async
|
|
1600
|
-
const
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1596
|
+
public async validateTxsReceivedInBlockProposal(txs: Tx[]): Promise<void> {
|
|
1597
|
+
const validator = createTxValidatorForBlockProposalReceivedTxs(
|
|
1598
|
+
this.proofVerifier,
|
|
1599
|
+
{ l1ChainId: this.config.l1ChainId, rollupVersion: this.config.rollupVersion },
|
|
1600
|
+
this.logger.getBindings(),
|
|
1601
|
+
);
|
|
1605
1602
|
|
|
1606
|
-
await Promise.all(
|
|
1603
|
+
const results = await Promise.all(
|
|
1607
1604
|
txs.map(async tx => {
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
if (!outcome.allPassed) {
|
|
1611
|
-
throw new Error('Invalid tx detected', { cause: { outcome } });
|
|
1612
|
-
}
|
|
1613
|
-
}
|
|
1605
|
+
const result = await validator.validateTx(tx);
|
|
1606
|
+
return result.result !== 'invalid';
|
|
1614
1607
|
}),
|
|
1615
1608
|
);
|
|
1609
|
+
if (results.some(value => value === false)) {
|
|
1610
|
+
throw new Error('Invalid tx detected');
|
|
1611
|
+
}
|
|
1616
1612
|
}
|
|
1617
1613
|
|
|
1618
|
-
/**
|
|
1619
|
-
|
|
1620
|
-
*
|
|
1621
|
-
* Each validator is a pair of a validator and a severity.
|
|
1622
|
-
* If a validator fails, the peer is penalized with the severity of the validator.
|
|
1623
|
-
*
|
|
1624
|
-
* @param currentBlockNumber - The current synced block number.
|
|
1625
|
-
* @param nextSlotTimestamp - The timestamp of the next slot (used to validate txs are not expired).
|
|
1626
|
-
* @returns The message validators.
|
|
1627
|
-
*/
|
|
1628
|
-
private async createMessageValidators(
|
|
1614
|
+
/** Creates the first stage (fast) validators for gossiped transactions. */
|
|
1615
|
+
protected async createFirstStageMessageValidators(
|
|
1629
1616
|
currentBlockNumber: BlockNumber,
|
|
1630
1617
|
nextSlotTimestamp: UInt64,
|
|
1631
|
-
): Promise<Record<string,
|
|
1618
|
+
): Promise<Record<string, TransactionValidator>> {
|
|
1632
1619
|
const gasFees = await this.getGasFees(currentBlockNumber);
|
|
1633
1620
|
const allowedInSetup = this.config.txPublicSetupAllowList ?? (await getDefaultAllowedSetupFunctions());
|
|
1621
|
+
const blockNumber = BlockNumber(currentBlockNumber + 1);
|
|
1634
1622
|
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
return createTxMessageValidators(
|
|
1623
|
+
return createFirstStageTxValidationsForGossipedTransactions(
|
|
1638
1624
|
nextSlotTimestamp,
|
|
1639
|
-
|
|
1625
|
+
blockNumber,
|
|
1640
1626
|
this.worldStateSynchronizer,
|
|
1641
1627
|
gasFees,
|
|
1642
1628
|
this.config.l1ChainId,
|
|
1643
1629
|
this.config.rollupVersion,
|
|
1644
1630
|
protocolContractsHash,
|
|
1645
1631
|
this.archiver,
|
|
1646
|
-
this.proofVerifier,
|
|
1647
1632
|
!this.config.disableTransactions,
|
|
1648
1633
|
allowedInSetup,
|
|
1649
1634
|
this.logger.getBindings(),
|
|
1650
1635
|
);
|
|
1651
1636
|
}
|
|
1652
1637
|
|
|
1638
|
+
/** Creates the second stage (expensive proof verification) validators for gossiped transactions. */
|
|
1639
|
+
protected createSecondStageMessageValidators(): Record<string, TransactionValidator> {
|
|
1640
|
+
return createSecondStageTxValidationsForGossipedTransactions(this.proofVerifier, this.logger.getBindings());
|
|
1641
|
+
}
|
|
1642
|
+
|
|
1653
1643
|
/**
|
|
1654
1644
|
* Run validations on a tx.
|
|
1655
1645
|
* @param tx - The tx to validate.
|
|
@@ -1658,7 +1648,7 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
1658
1648
|
*/
|
|
1659
1649
|
private async runValidations(
|
|
1660
1650
|
tx: Tx,
|
|
1661
|
-
messageValidators: Record<string,
|
|
1651
|
+
messageValidators: Record<string, TransactionValidator>,
|
|
1662
1652
|
): Promise<ValidationOutcome> {
|
|
1663
1653
|
const validationPromises = Object.entries(messageValidators).map(async ([name, { validator, severity }]) => {
|
|
1664
1654
|
const { result } = await validator.validateTx(tx);
|
|
@@ -8,8 +8,8 @@ import { PeerErrorSeverity } from '@aztec/stdlib/p2p';
|
|
|
8
8
|
import { Tx, TxArray, TxHash } from '@aztec/stdlib/tx';
|
|
9
9
|
|
|
10
10
|
import type { PeerId } from '@libp2p/interface';
|
|
11
|
-
import { peerIdFromString } from '@libp2p/peer-id';
|
|
12
11
|
|
|
12
|
+
import type { IMissingTxsTracker } from '../../tx_collection/missing_txs_tracker.js';
|
|
13
13
|
import { ReqRespSubProtocol } from '.././interface.js';
|
|
14
14
|
import { BlockTxsRequest, BlockTxsResponse, type BlockTxsSource } from '.././protocols/index.js';
|
|
15
15
|
import { ReqRespStatus } from '.././status.js';
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
DEFAULT_BATCH_TX_REQUESTER_TX_BATCH_SIZE,
|
|
21
21
|
} from './config.js';
|
|
22
22
|
import type { BatchTxRequesterLibP2PService, BatchTxRequesterOptions, ITxMetadataCollection } from './interface.js';
|
|
23
|
-
import {
|
|
23
|
+
import { MissingTxMetadataCollection } from './missing_txs.js';
|
|
24
24
|
import { type IPeerCollection, PeerCollection } from './peer_collection.js';
|
|
25
25
|
import { BatchRequestTxValidator, type IBatchRequestTxValidator } from './tx_validator.js';
|
|
26
26
|
|
|
@@ -60,7 +60,7 @@ export class BatchTxRequester {
|
|
|
60
60
|
private readonly txBatchSize: number;
|
|
61
61
|
|
|
62
62
|
constructor(
|
|
63
|
-
|
|
63
|
+
missingTxsTracker: IMissingTxsTracker,
|
|
64
64
|
blockTxsSource: BlockTxsSource,
|
|
65
65
|
pinnedPeer: PeerId | undefined,
|
|
66
66
|
timeoutMs: number,
|
|
@@ -89,18 +89,16 @@ export class BatchTxRequester {
|
|
|
89
89
|
if (this.opts.peerCollection) {
|
|
90
90
|
this.peers = this.opts.peerCollection;
|
|
91
91
|
} else {
|
|
92
|
-
const initialPeers = this.p2pService.connectionSampler.getPeerListSortedByConnectionCountAsc();
|
|
93
92
|
const badPeerThreshold = this.opts.badPeerThreshold ?? DEFAULT_BATCH_TX_REQUESTER_BAD_PEER_THRESHOLD;
|
|
94
93
|
this.peers = new PeerCollection(
|
|
95
|
-
|
|
94
|
+
this.p2pService.connectionSampler,
|
|
96
95
|
this.pinnedPeer,
|
|
97
96
|
this.dateProvider,
|
|
98
97
|
badPeerThreshold,
|
|
99
98
|
this.p2pService.peerScoring,
|
|
100
99
|
);
|
|
101
100
|
}
|
|
102
|
-
|
|
103
|
-
this.txsMetadata = new MissingTxMetadataCollection(entries, this.txBatchSize);
|
|
101
|
+
this.txsMetadata = new MissingTxMetadataCollection(missingTxsTracker, this.txBatchSize);
|
|
104
102
|
this.smartRequesterSemaphore = this.opts.semaphore ?? new Semaphore(0);
|
|
105
103
|
}
|
|
106
104
|
|
|
@@ -227,7 +225,6 @@ export class BatchTxRequester {
|
|
|
227
225
|
* Starts dumb worker loops
|
|
228
226
|
* */
|
|
229
227
|
private async dumbRequester() {
|
|
230
|
-
const nextPeerIndex = this.makeRoundRobinIndexer();
|
|
231
228
|
const nextBatchIndex = this.makeRoundRobinIndexer();
|
|
232
229
|
|
|
233
230
|
// Chunk missing tx hashes into batches of txBatchSize, wrapping around to ensure no peer gets less than txBatchSize
|
|
@@ -263,15 +260,9 @@ export class BatchTxRequester {
|
|
|
263
260
|
return { blockRequest, txs };
|
|
264
261
|
};
|
|
265
262
|
|
|
266
|
-
const
|
|
267
|
-
const peers = this.peers.getDumbPeersToQuery();
|
|
268
|
-
const idx = nextPeerIndex(() => peers.length);
|
|
269
|
-
return idx === undefined ? undefined : peerIdFromString(peers[idx]);
|
|
270
|
-
};
|
|
271
|
-
|
|
272
|
-
const workerCount = Math.min(this.dumbParallelWorkerCount, this.peers.getAllPeers().size);
|
|
263
|
+
const workerCount = this.dumbParallelWorkerCount;
|
|
273
264
|
const workers = Array.from({ length: workerCount }, (_, index) =>
|
|
274
|
-
this.dumbWorkerLoop(
|
|
265
|
+
this.dumbWorkerLoop(this.peers.nextDumbPeerToQuery.bind(this.peers), makeRequest, index + 1),
|
|
275
266
|
);
|
|
276
267
|
|
|
277
268
|
await Promise.allSettled(workers);
|
|
@@ -332,14 +323,6 @@ export class BatchTxRequester {
|
|
|
332
323
|
* Starts smart worker loops
|
|
333
324
|
* */
|
|
334
325
|
private async smartRequester() {
|
|
335
|
-
const nextPeerIndex = this.makeRoundRobinIndexer();
|
|
336
|
-
|
|
337
|
-
const nextPeer = () => {
|
|
338
|
-
const peers = this.peers.getSmartPeersToQuery();
|
|
339
|
-
const idx = nextPeerIndex(() => peers.length);
|
|
340
|
-
return idx === undefined ? undefined : peerIdFromString(peers[idx]);
|
|
341
|
-
};
|
|
342
|
-
|
|
343
326
|
const makeRequest = (pid: PeerId) => {
|
|
344
327
|
const txs = this.txsMetadata.getTxsToRequestFromThePeer(pid);
|
|
345
328
|
const blockRequest = BlockTxsRequest.fromTxsSourceAndMissingTxs(this.blockTxsSource, txs);
|
|
@@ -350,9 +333,8 @@ export class BatchTxRequester {
|
|
|
350
333
|
return { blockRequest, txs };
|
|
351
334
|
};
|
|
352
335
|
|
|
353
|
-
const workers = Array.from(
|
|
354
|
-
|
|
355
|
-
(_, index) => this.smartWorkerLoop(nextPeer, makeRequest, index + 1),
|
|
336
|
+
const workers = Array.from({ length: this.smartParallelWorkerCount }, (_, index) =>
|
|
337
|
+
this.smartWorkerLoop(this.peers.nextSmartPeerToQuery.bind(this.peers), makeRequest, index + 1),
|
|
356
338
|
);
|
|
357
339
|
|
|
358
340
|
await Promise.allSettled(workers);
|
|
@@ -387,26 +369,18 @@ export class BatchTxRequester {
|
|
|
387
369
|
if (weRanOutOfPeersToQuery) {
|
|
388
370
|
this.logger.debug(`Worker loop smart: No more peers to query`);
|
|
389
371
|
|
|
390
|
-
// If
|
|
391
|
-
|
|
392
|
-
const
|
|
393
|
-
if (
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
const thereAreSomeRateLimitedSmartPeers = nextSmartPeerDelay !== undefined;
|
|
397
|
-
if (thereAreSomeRateLimitedSmartPeers) {
|
|
398
|
-
await this.sleepClampedToDeadline(nextSmartPeerDelay);
|
|
399
|
-
continue;
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
this.logger.debug(`Worker loop smart: No more smart peers to query killing ${workerIndex}`);
|
|
403
|
-
break;
|
|
372
|
+
// If we have rate limited peers wait for them.
|
|
373
|
+
const nextSmartPeerDelay = this.peers.getNextSmartPeerAvailabilityDelayMs();
|
|
374
|
+
const thereAreSomeRateLimitedSmartPeers = nextSmartPeerDelay !== undefined;
|
|
375
|
+
if (thereAreSomeRateLimitedSmartPeers) {
|
|
376
|
+
await this.sleepClampedToDeadline(nextSmartPeerDelay);
|
|
377
|
+
continue;
|
|
404
378
|
}
|
|
405
379
|
|
|
406
|
-
// Otherwise there are still some dumb peers that could become smart.
|
|
407
380
|
// We end up here when all known smart peers became temporarily unavailable via combination of
|
|
408
381
|
// (bad, in-flight, or rate-limited) or in some weird scenario all current smart peers turn bad which is permanent
|
|
409
|
-
// but dumb peers
|
|
382
|
+
// but there are dumb peers that could be promoted
|
|
383
|
+
// or new peer can join as dumb and be promoted later
|
|
410
384
|
//
|
|
411
385
|
// When a dumb peer responds with valid txIndices, it gets
|
|
412
386
|
// promoted to smart and releases the semaphore, waking this worker.
|
|
@@ -599,9 +573,7 @@ export class BatchTxRequester {
|
|
|
599
573
|
this.markTxsPeerHas(peerId, response);
|
|
600
574
|
|
|
601
575
|
// Unblock smart workers
|
|
602
|
-
|
|
603
|
-
this.smartRequesterSemaphore.release();
|
|
604
|
-
}
|
|
576
|
+
this.smartRequesterSemaphore.release();
|
|
605
577
|
}
|
|
606
578
|
|
|
607
579
|
private isBlockResponseValid(response: BlockTxsResponse): boolean {
|
|
@@ -661,7 +633,7 @@ export class BatchTxRequester {
|
|
|
661
633
|
/*
|
|
662
634
|
* @returns true if all missing txs have been fetched */
|
|
663
635
|
private fetchedAllTxs() {
|
|
664
|
-
return
|
|
636
|
+
return this.txsMetadata.getMissingTxHashes().size == 0;
|
|
665
637
|
}
|
|
666
638
|
|
|
667
639
|
/*
|
|
@@ -679,7 +651,7 @@ export class BatchTxRequester {
|
|
|
679
651
|
this.unlockSmartRequesterSemaphores();
|
|
680
652
|
}
|
|
681
653
|
|
|
682
|
-
return aborted || this.
|
|
654
|
+
return aborted || this.fetchedAllTxs() || this.dateProvider.now() > this.deadline;
|
|
683
655
|
}
|
|
684
656
|
|
|
685
657
|
/*
|
|
@@ -6,7 +6,6 @@ import type { PeerId } from '@libp2p/interface';
|
|
|
6
6
|
|
|
7
7
|
import type { ConnectionSampler } from '../connection-sampler/connection_sampler.js';
|
|
8
8
|
import type { ReqRespInterface } from '../interface.js';
|
|
9
|
-
import type { MissingTxMetadata } from './missing_txs.js';
|
|
10
9
|
import type { IPeerCollection } from './peer_collection.js';
|
|
11
10
|
import type { BatchRequestTxValidatorConfig, IBatchRequestTxValidator } from './tx_validator.js';
|
|
12
11
|
|
|
@@ -15,18 +14,15 @@ export interface IPeerPenalizer {
|
|
|
15
14
|
}
|
|
16
15
|
|
|
17
16
|
export interface ITxMetadataCollection {
|
|
18
|
-
size: number;
|
|
19
|
-
values(): IterableIterator<MissingTxMetadata>;
|
|
20
17
|
getMissingTxHashes(): Set<string>;
|
|
18
|
+
markFetched(peerId: PeerId, tx: Tx): boolean;
|
|
21
19
|
getTxsToRequestFromThePeer(peer: PeerId): TxHash[];
|
|
22
20
|
markRequested(txHash: TxHash): void;
|
|
23
21
|
markInFlightBySmartPeer(txHash: TxHash): void;
|
|
24
22
|
markNotInFlightBySmartPeer(txHash: TxHash): void;
|
|
25
23
|
alreadyFetched(txHash: TxHash): boolean;
|
|
26
24
|
// Returns true if tx was marked as fetched, false if it was already marked as fetched
|
|
27
|
-
markFetched(peerId: PeerId, tx: Tx): boolean;
|
|
28
25
|
markPeerHas(peerId: PeerId, txHashes: TxHash[]): void;
|
|
29
|
-
getFetchedTxs(): Tx[];
|
|
30
26
|
}
|
|
31
27
|
|
|
32
28
|
/**
|