@aztec/p2p 0.0.1-commit.9ef841308 → 0.0.1-commit.a89ec08
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 +2 -2
- package/dest/client/factory.d.ts.map +1 -1
- package/dest/client/factory.js +1 -2
- package/dest/client/p2p_client.d.ts +1 -1
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +4 -6
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +6 -17
- package/dest/config.d.ts +6 -6
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +6 -6
- package/dest/index.d.ts +2 -1
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -0
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +4 -4
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool.js +4 -8
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.js +6 -6
- package/dest/mem_pools/index.d.ts +2 -1
- package/dest/mem_pools/index.d.ts.map +1 -1
- package/dest/mem_pools/instrumentation.d.ts +2 -4
- package/dest/mem_pools/instrumentation.d.ts.map +1 -1
- package/dest/mem_pools/instrumentation.js +14 -16
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts +125 -0
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.js +596 -0
- package/dest/mem_pools/tx_pool/eviction/eviction_manager.d.ts +32 -0
- package/dest/mem_pools/tx_pool/eviction/eviction_manager.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool/eviction/eviction_manager.js +112 -0
- package/dest/mem_pools/tx_pool/eviction/eviction_strategy.d.ts +157 -0
- package/dest/mem_pools/tx_pool/eviction/eviction_strategy.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool/eviction/eviction_strategy.js +52 -0
- package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.d.ts +16 -0
- package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.js +123 -0
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.d.ts +17 -0
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.js +84 -0
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.d.ts +19 -0
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.js +78 -0
- package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.d.ts +26 -0
- package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.js +84 -0
- package/dest/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.d.ts +25 -0
- package/dest/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.js +57 -0
- package/dest/mem_pools/tx_pool/index.d.ts +3 -0
- package/dest/mem_pools/tx_pool/index.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool/index.js +2 -0
- package/dest/mem_pools/tx_pool/priority.d.ts +12 -0
- package/dest/mem_pools/tx_pool/priority.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool/priority.js +15 -0
- package/dest/mem_pools/tx_pool/tx_pool.d.ts +127 -0
- package/dest/mem_pools/tx_pool/tx_pool.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool/tx_pool.js +3 -0
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts +7 -0
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.js +402 -0
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts +5 -7
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/interfaces.js +0 -1
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +6 -5
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_metadata.js +1 -5
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts +1 -1
- 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 +43 -26
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts +1 -1
- 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 +0 -3
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +1 -2
- 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 +1 -18
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts +1 -1
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts.map +1 -1
- package/dest/msg_validators/attestation_validator/attestation_validator.js +4 -5
- 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 +3 -4
- package/dest/msg_validators/proposal_validator/proposal_validator.d.ts +1 -1
- package/dest/msg_validators/proposal_validator/proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/proposal_validator.js +5 -5
- package/dest/msg_validators/tx_validator/metadata_validator.d.ts +1 -1
- package/dest/msg_validators/tx_validator/metadata_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/metadata_validator.js +4 -4
- package/dest/services/discv5/discV5_service.d.ts +1 -1
- package/dest/services/discv5/discV5_service.d.ts.map +1 -1
- package/dest/services/discv5/discV5_service.js +2 -4
- package/dest/services/libp2p/libp2p_service.d.ts +9 -7
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +59 -137
- package/dest/services/peer-manager/metrics.d.ts +1 -3
- package/dest/services/peer-manager/metrics.d.ts.map +1 -1
- package/dest/services/peer-manager/metrics.js +0 -6
- package/dest/services/peer-manager/peer_manager.d.ts +2 -6
- package/dest/services/peer-manager/peer_manager.d.ts.map +1 -1
- package/dest/services/peer-manager/peer_manager.js +9 -24
- package/dest/services/peer-manager/peer_scoring.d.ts +2 -5
- package/dest/services/peer-manager/peer_scoring.d.ts.map +1 -1
- package/dest/services/peer-manager/peer_scoring.js +10 -28
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts +8 -11
- 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 +101 -82
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts +2 -3
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts +4 -5
- package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/missing_txs.js +7 -13
- package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts +11 -19
- package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/peer_collection.js +15 -52
- 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 +3 -4
- package/dest/services/service.d.ts +1 -7
- package/dest/services/service.d.ts.map +1 -1
- package/dest/services/tx_collection/fast_tx_collection.d.ts +4 -1
- package/dest/services/tx_collection/fast_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/fast_tx_collection.js +73 -57
- 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 +4 -4
- package/dest/services/tx_collection/slow_tx_collection.js +1 -1
- package/dest/services/tx_collection/tx_collection.d.ts +6 -3
- package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
- 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/mock-pubsub.d.ts +1 -6
- package/dest/test-helpers/mock-pubsub.d.ts.map +1 -1
- package/dest/test-helpers/mock-pubsub.js +1 -9
- package/dest/test-helpers/reqresp-nodes.d.ts +1 -1
- package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
- package/dest/test-helpers/testbench-utils.d.ts +1 -1
- package/dest/test-helpers/testbench-utils.d.ts.map +1 -1
- package/dest/test-helpers/testbench-utils.js +2 -20
- package/dest/testbench/p2p_client_testbench_worker.js +15 -44
- package/dest/testbench/worker_client_manager.d.ts +1 -1
- package/dest/testbench/worker_client_manager.d.ts.map +1 -1
- package/dest/testbench/worker_client_manager.js +2 -2
- package/dest/util.d.ts +4 -9
- package/dest/util.d.ts.map +1 -1
- package/dest/util.js +9 -2
- package/package.json +14 -14
- package/src/client/factory.ts +2 -3
- package/src/client/p2p_client.ts +4 -6
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +9 -19
- package/src/config.ts +10 -10
- package/src/index.ts +1 -0
- package/src/mem_pools/attestation_pool/attestation_pool.ts +7 -8
- package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +6 -6
- package/src/mem_pools/index.ts +3 -0
- package/src/mem_pools/instrumentation.ts +13 -17
- package/src/mem_pools/tx_pool/README.md +270 -0
- package/src/mem_pools/tx_pool/aztec_kv_tx_pool.ts +746 -0
- package/src/mem_pools/tx_pool/eviction/eviction_manager.ts +132 -0
- package/src/mem_pools/tx_pool/eviction/eviction_strategy.ts +208 -0
- package/src/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.ts +163 -0
- package/src/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.ts +104 -0
- package/src/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.ts +93 -0
- package/src/mem_pools/tx_pool/eviction/low_priority_eviction_rule.ts +106 -0
- package/src/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.ts +75 -0
- package/src/mem_pools/tx_pool/index.ts +2 -0
- package/src/mem_pools/tx_pool/priority.ts +20 -0
- package/src/mem_pools/tx_pool/tx_pool.ts +141 -0
- package/src/mem_pools/tx_pool/tx_pool_test_suite.ts +321 -0
- package/src/mem_pools/tx_pool_v2/interfaces.ts +4 -7
- package/src/mem_pools/tx_pool_v2/tx_metadata.ts +5 -11
- package/src/mem_pools/tx_pool_v2/tx_pool_indices.ts +43 -29
- package/src/mem_pools/tx_pool_v2/tx_pool_v2.ts +0 -3
- package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +1 -19
- package/src/msg_validators/attestation_validator/README.md +1 -1
- package/src/msg_validators/attestation_validator/attestation_validator.ts +4 -5
- package/src/msg_validators/clock_tolerance.ts +3 -4
- package/src/msg_validators/proposal_validator/README.md +4 -4
- package/src/msg_validators/proposal_validator/proposal_validator.ts +5 -6
- package/src/msg_validators/tx_validator/metadata_validator.ts +4 -12
- package/src/services/discv5/discV5_service.ts +2 -4
- package/src/services/libp2p/libp2p_service.ts +71 -135
- package/src/services/peer-manager/metrics.ts +0 -7
- package/src/services/peer-manager/peer_manager.ts +9 -28
- package/src/services/peer-manager/peer_scoring.ts +5 -21
- package/src/services/reqresp/batch-tx-requester/README.md +7 -46
- package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +111 -78
- package/src/services/reqresp/batch-tx-requester/interface.ts +1 -2
- package/src/services/reqresp/batch-tx-requester/missing_txs.ts +6 -13
- package/src/services/reqresp/batch-tx-requester/peer_collection.ts +24 -68
- package/src/services/reqresp/reqresp.ts +3 -5
- package/src/services/service.ts +0 -7
- package/src/services/tx_collection/fast_tx_collection.ts +83 -57
- package/src/services/tx_collection/missing_txs_tracker.ts +52 -0
- package/src/services/tx_collection/proposal_tx_collector.ts +13 -8
- package/src/services/tx_collection/slow_tx_collection.ts +1 -1
- package/src/services/tx_collection/tx_collection.ts +5 -3
- package/src/test-helpers/make-test-p2p-clients.ts +1 -1
- package/src/test-helpers/mock-pubsub.ts +0 -9
- package/src/test-helpers/reqresp-nodes.ts +1 -1
- package/src/test-helpers/testbench-utils.ts +3 -28
- package/src/testbench/p2p_client_testbench_worker.ts +15 -44
- package/src/testbench/worker_client_manager.ts +2 -2
- package/src/util.ts +13 -9
- package/dest/services/tx_collection/request_tracker.d.ts +0 -53
- package/dest/services/tx_collection/request_tracker.d.ts.map +0 -1
- package/dest/services/tx_collection/request_tracker.js +0 -84
- package/src/services/tx_collection/request_tracker.ts +0 -127
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { DateProvider } from '@aztec/foundation/timer';
|
|
2
1
|
import { PeerErrorSeverity } from '@aztec/stdlib/p2p';
|
|
3
2
|
import { type TelemetryClient } from '@aztec/telemetry-client';
|
|
4
3
|
import type { PeerId } from '@libp2p/interface';
|
|
@@ -9,7 +8,6 @@ export declare enum PeerScoreState {
|
|
|
9
8
|
Healthy = 2
|
|
10
9
|
}
|
|
11
10
|
export declare class PeerScoring {
|
|
12
|
-
private readonly dateProvider;
|
|
13
11
|
private logger;
|
|
14
12
|
private scores;
|
|
15
13
|
private lastUpdateTime;
|
|
@@ -19,11 +17,10 @@ export declare class PeerScoring {
|
|
|
19
17
|
[key in PeerErrorSeverity]: number;
|
|
20
18
|
};
|
|
21
19
|
private peerStateCounter;
|
|
22
|
-
constructor(config: P2PConfig, telemetry?: TelemetryClient
|
|
20
|
+
constructor(config: P2PConfig, telemetry?: TelemetryClient);
|
|
23
21
|
penalizePeer(peerId: PeerId, penalty: PeerErrorSeverity): number;
|
|
24
22
|
updateScore(peerId: string, scoreDelta: number): number;
|
|
25
23
|
decayAllScores(): void;
|
|
26
|
-
removePeer(peerId: string): void;
|
|
27
24
|
getScore(peerId: string): number;
|
|
28
25
|
getScoreState(peerId: string): PeerScoreState;
|
|
29
26
|
getStats(): {
|
|
@@ -33,4 +30,4 @@ export declare class PeerScoring {
|
|
|
33
30
|
bannedCount: number;
|
|
34
31
|
};
|
|
35
32
|
}
|
|
36
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
33
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicGVlcl9zY29yaW5nLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvc2VydmljZXMvcGVlci1tYW5hZ2VyL3BlZXJfc2NvcmluZy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFFQSxPQUFPLEVBQUUsaUJBQWlCLEVBQUUsTUFBTSxtQkFBbUIsQ0FBQztBQUN0RCxPQUFPLEVBR0wsS0FBSyxlQUFlLEVBSXJCLE1BQU0seUJBQXlCLENBQUM7QUFFakMsT0FBTyxLQUFLLEVBQUUsTUFBTSxFQUFFLE1BQU0sbUJBQW1CLENBQUM7QUFFaEQsT0FBTyxLQUFLLEVBQUUsU0FBUyxFQUFFLE1BQU0saUJBQWlCLENBQUM7QUF1QmpELG9CQUFZLGNBQWM7SUFDeEIsTUFBTSxJQUFBO0lBQ04sVUFBVSxJQUFBO0lBQ1YsT0FBTyxJQUFBO0NBQ1I7QUFnQkQscUJBQWEsV0FBVztJQUN0QixPQUFPLENBQUMsTUFBTSxDQUFvQztJQUNsRCxPQUFPLENBQUMsTUFBTSxDQUFrQztJQUNoRCxPQUFPLENBQUMsY0FBYyxDQUFrQztJQUN4RCxPQUFPLENBQUMsYUFBYSxDQUFhO0lBQ2xDLE9BQU8sQ0FBQyxXQUFXLENBQU87SUFDMUIsYUFBYSxFQUFFO1NBQUcsR0FBRyxJQUFJLGlCQUFpQixHQUFHLE1BQU07S0FBRSxDQUFDO0lBRXRELE9BQU8sQ0FBQyxnQkFBZ0IsQ0FBZ0I7SUFFeEMsWUFBWSxNQUFNLEVBQUUsU0FBUyxFQUFFLFNBQVMsR0FBRSxlQUFzQyxFQWdCL0U7SUFFTSxZQUFZLENBQUMsTUFBTSxFQUFFLE1BQU0sRUFBRSxPQUFPLEVBQUUsaUJBQWlCLFVBTTdEO0lBRUQsV0FBVyxDQUFDLE1BQU0sRUFBRSxNQUFNLEVBQUUsVUFBVSxFQUFFLE1BQU0sR0FBRyxNQUFNLENBaUJ0RDtJQUVELGNBQWMsSUFBSSxJQUFJLENBWXJCO0lBRUQsUUFBUSxDQUFDLE1BQU0sRUFBRSxNQUFNLEdBQUcsTUFBTSxDQUUvQjtJQUVNLGFBQWEsQ0FBQyxNQUFNLEVBQUUsTUFBTSxHQUFHLGNBQWMsQ0FVbkQ7SUFFRCxRQUFRLElBQUk7UUFBRSxXQUFXLEVBQUUsTUFBTSxDQUFDO1FBQUMsWUFBWSxFQUFFLE1BQU0sQ0FBQztRQUFDLGVBQWUsRUFBRSxNQUFNLENBQUM7UUFBQyxXQUFXLEVBQUUsTUFBTSxDQUFBO0tBQUUsQ0E0QnRHO0NBQ0YifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"peer_scoring.d.ts","sourceRoot":"","sources":["../../../src/services/peer-manager/peer_scoring.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"peer_scoring.d.ts","sourceRoot":"","sources":["../../../src/services/peer-manager/peer_scoring.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAGL,KAAK,eAAe,EAIrB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAuBjD,oBAAY,cAAc;IACxB,MAAM,IAAA;IACN,UAAU,IAAA;IACV,OAAO,IAAA;CACR;AAgBD,qBAAa,WAAW;IACtB,OAAO,CAAC,MAAM,CAAoC;IAClD,OAAO,CAAC,MAAM,CAAkC;IAChD,OAAO,CAAC,cAAc,CAAkC;IACxD,OAAO,CAAC,aAAa,CAAa;IAClC,OAAO,CAAC,WAAW,CAAO;IAC1B,aAAa,EAAE;SAAG,GAAG,IAAI,iBAAiB,GAAG,MAAM;KAAE,CAAC;IAEtD,OAAO,CAAC,gBAAgB,CAAgB;IAExC,YAAY,MAAM,EAAE,SAAS,EAAE,SAAS,GAAE,eAAsC,EAgB/E;IAEM,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,UAM7D;IAED,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAiBtD;IAED,cAAc,IAAI,IAAI,CAYrB;IAED,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAE/B;IAEM,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,cAAc,CAUnD;IAED,QAAQ,IAAI;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAC;QAAC,eAAe,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CA4BtG;CACF"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { median } from '@aztec/foundation/collection';
|
|
2
2
|
import { createLogger } from '@aztec/foundation/log';
|
|
3
|
-
import { DateProvider } from '@aztec/foundation/timer';
|
|
4
3
|
import { PeerErrorSeverity } from '@aztec/stdlib/p2p';
|
|
5
4
|
import { Attributes, Metrics, createUpDownCounterWithDefault, getTelemetryClient } from '@aztec/telemetry-client';
|
|
6
5
|
/**
|
|
@@ -40,23 +39,15 @@ export var PeerScoreState = /*#__PURE__*/ function(PeerScoreState) {
|
|
|
40
39
|
*/ // TODO: move into config / constants
|
|
41
40
|
const MIN_SCORE_BEFORE_BAN = -100;
|
|
42
41
|
const MIN_SCORE_BEFORE_DISCONNECT = -50;
|
|
43
|
-
const SCORE_CLEANUP_THRESHOLD = 0.1;
|
|
44
42
|
export class PeerScoring {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
decayFactor;
|
|
43
|
+
logger = createLogger('p2p:peer-scoring');
|
|
44
|
+
scores = new Map();
|
|
45
|
+
lastUpdateTime = new Map();
|
|
46
|
+
decayInterval = 1000 * 60;
|
|
47
|
+
decayFactor = 0.9;
|
|
51
48
|
peerPenalties;
|
|
52
49
|
peerStateCounter;
|
|
53
|
-
constructor(config, telemetry = getTelemetryClient()
|
|
54
|
-
this.dateProvider = dateProvider;
|
|
55
|
-
this.logger = createLogger('p2p:peer-scoring');
|
|
56
|
-
this.scores = new Map();
|
|
57
|
-
this.lastUpdateTime = new Map();
|
|
58
|
-
this.decayInterval = 1000 * 60;
|
|
59
|
-
this.decayFactor = 0.9;
|
|
50
|
+
constructor(config, telemetry = getTelemetryClient()){
|
|
60
51
|
const orderedValues = config.peerPenaltyValues?.sort((a, b)=>a - b);
|
|
61
52
|
this.peerPenalties = {
|
|
62
53
|
[PeerErrorSeverity.HighToleranceError]: orderedValues?.[0] ?? DefaultPeerPenalties[PeerErrorSeverity.HighToleranceError],
|
|
@@ -80,7 +71,7 @@ export class PeerScoring {
|
|
|
80
71
|
return newScore;
|
|
81
72
|
}
|
|
82
73
|
updateScore(peerId, scoreDelta) {
|
|
83
|
-
const currentTime =
|
|
74
|
+
const currentTime = Date.now();
|
|
84
75
|
const lastUpdate = this.lastUpdateTime.get(peerId) || currentTime;
|
|
85
76
|
const timePassed = currentTime - lastUpdate;
|
|
86
77
|
const decayPeriods = Math.floor(timePassed / this.decayInterval);
|
|
@@ -94,27 +85,18 @@ export class PeerScoring {
|
|
|
94
85
|
return currentScore;
|
|
95
86
|
}
|
|
96
87
|
decayAllScores() {
|
|
97
|
-
const currentTime =
|
|
88
|
+
const currentTime = Date.now();
|
|
98
89
|
for (const [peerId, lastUpdate] of this.lastUpdateTime.entries()){
|
|
99
90
|
const timePassed = currentTime - lastUpdate;
|
|
100
91
|
const decayPeriods = Math.floor(timePassed / this.decayInterval);
|
|
101
92
|
if (decayPeriods > 0) {
|
|
102
93
|
let score = this.scores.get(peerId) || 0;
|
|
103
94
|
score *= Math.pow(this.decayFactor, decayPeriods);
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
this.lastUpdateTime.delete(peerId);
|
|
107
|
-
} else {
|
|
108
|
-
this.scores.set(peerId, score);
|
|
109
|
-
this.lastUpdateTime.set(peerId, currentTime);
|
|
110
|
-
}
|
|
95
|
+
this.scores.set(peerId, score);
|
|
96
|
+
this.lastUpdateTime.set(peerId, currentTime);
|
|
111
97
|
}
|
|
112
98
|
}
|
|
113
99
|
}
|
|
114
|
-
removePeer(peerId) {
|
|
115
|
-
this.scores.delete(peerId);
|
|
116
|
-
this.lastUpdateTime.delete(peerId);
|
|
117
|
-
}
|
|
118
100
|
getScore(peerId) {
|
|
119
101
|
return this.scores.get(peerId) || 0;
|
|
120
102
|
}
|
|
@@ -2,25 +2,27 @@ import { type Logger } from '@aztec/foundation/log';
|
|
|
2
2
|
import { DateProvider } from '@aztec/foundation/timer';
|
|
3
3
|
import { Tx } from '@aztec/stdlib/tx';
|
|
4
4
|
import type { PeerId } from '@libp2p/interface';
|
|
5
|
-
import type {
|
|
5
|
+
import type { IMissingTxsTracker } from '../../tx_collection/missing_txs_tracker.js';
|
|
6
6
|
import { type BlockTxsSource } from '.././protocols/index.js';
|
|
7
7
|
import type { BatchTxRequesterLibP2PService, BatchTxRequesterOptions } from './interface.js';
|
|
8
8
|
export declare class BatchTxRequester {
|
|
9
|
-
private readonly requestTracker;
|
|
10
9
|
private readonly blockTxsSource;
|
|
11
10
|
private readonly pinnedPeer;
|
|
11
|
+
private readonly timeoutMs;
|
|
12
12
|
private readonly p2pService;
|
|
13
13
|
private readonly logger;
|
|
14
|
+
private readonly dateProvider;
|
|
14
15
|
private readonly opts;
|
|
15
16
|
private readonly peers;
|
|
16
17
|
private readonly txsMetadata;
|
|
18
|
+
private readonly deadline;
|
|
17
19
|
private readonly smartRequesterSemaphore;
|
|
18
20
|
private readonly txQueue;
|
|
19
21
|
private readonly txValidator;
|
|
20
22
|
private readonly smartParallelWorkerCount;
|
|
21
23
|
private readonly dumbParallelWorkerCount;
|
|
22
24
|
private readonly txBatchSize;
|
|
23
|
-
constructor(
|
|
25
|
+
constructor(missingTxsTracker: IMissingTxsTracker, blockTxsSource: BlockTxsSource, pinnedPeer: PeerId | undefined, timeoutMs: number, p2pService: BatchTxRequesterLibP2PService, logger?: Logger, dateProvider?: DateProvider, opts?: BatchTxRequesterOptions);
|
|
24
26
|
run(): AsyncGenerator<Tx, Tx | undefined, unknown>;
|
|
25
27
|
static collectAllTxs(generator: AsyncGenerator<Tx, Tx | undefined, unknown>): Promise<Tx[]>;
|
|
26
28
|
private pinnedPeerRequester;
|
|
@@ -33,19 +35,14 @@ export declare class BatchTxRequester {
|
|
|
33
35
|
private handleSuccessResponseFromPeer;
|
|
34
36
|
private handleReceivedTxs;
|
|
35
37
|
private decideIfPeerIsSmart;
|
|
36
|
-
|
|
37
|
-
* Handles an archive root mismatch between local state and peer response.
|
|
38
|
-
*
|
|
39
|
-
* - Response archive is Fr.ZERO (peer pruned proposal, legitimate): marks peer dumb.
|
|
40
|
-
* - Non-zero archive mismatch (malicious response): penalises + marks dumb.
|
|
41
|
-
*/
|
|
42
|
-
private handleArchiveRootMismatch;
|
|
38
|
+
private isBlockResponseValid;
|
|
43
39
|
private peerHasSomeTxsWeAreMissing;
|
|
44
40
|
private markTxsPeerHas;
|
|
45
41
|
private extractHashesPeerHasFromResponse;
|
|
46
42
|
private makeRoundRobinIndexer;
|
|
43
|
+
private fetchedAllTxs;
|
|
47
44
|
private shouldStop;
|
|
48
45
|
private unlockSmartRequesterSemaphores;
|
|
49
46
|
private sleepClampedToDeadline;
|
|
50
47
|
}
|
|
51
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
48
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmF0Y2hfdHhfcmVxdWVzdGVyLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvc2VydmljZXMvcmVxcmVzcC9iYXRjaC10eC1yZXF1ZXN0ZXIvYmF0Y2hfdHhfcmVxdWVzdGVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUVBLE9BQU8sRUFBRSxLQUFLLE1BQU0sRUFBZ0IsTUFBTSx1QkFBdUIsQ0FBQztBQUdsRSxPQUFPLEVBQUUsWUFBWSxFQUFrQixNQUFNLHlCQUF5QixDQUFDO0FBRXZFLE9BQU8sRUFBRSxFQUFFLEVBQW1CLE1BQU0sa0JBQWtCLENBQUM7QUFFdkQsT0FBTyxLQUFLLEVBQUUsTUFBTSxFQUFFLE1BQU0sbUJBQW1CLENBQUM7QUFHaEQsT0FBTyxLQUFLLEVBQUUsa0JBQWtCLEVBQUUsTUFBTSw0Q0FBNEMsQ0FBQztBQUVyRixPQUFPLEVBQXFDLEtBQUssY0FBYyxFQUFFLE1BQU0seUJBQXlCLENBQUM7QUFRakcsT0FBTyxLQUFLLEVBQUUsNkJBQTZCLEVBQUUsdUJBQXVCLEVBQXlCLE1BQU0sZ0JBQWdCLENBQUM7QUFzQnBILHFCQUFhLGdCQUFn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ElBQUksQ0FBQyxFQUFFLHVCQUF1QixFQWtDL0I7SUFLYSxHQUFHLElBQUksY0FBYyxDQUFDLEVBQUUsRUFBRSxFQUFFLEdBQUcsU0FBUyxFQUFFLE9BQU8sQ0FBQyxDQTZDL0Q7SUFLRCxPQUFvQixhQUFhLENBQUMsU0FBUyxFQUFFLGNBQWMsQ0FBQyxFQUFFLEVBQUUsRUFBRSxHQUFHLFNBQVMsRUFBRSxPQUFPLENBQUMsR0FBRyxPQUFPLENBQUMsRUFBRSxFQUFFLENBQUMsQ0FTdkc7WUFVYSxtQkFBbUI7WUFrRG5CLGFBQWE7WUF5RGIsY0FBYztZQWdEZCxjQUFjO1lBd0NkLGVBQWU7WUFrRmYsY0FBYztJQW1DNUIsT0FBTyxDQUFDLDBCQUEwQjtZQWlCcEIsNkJBQTZCO1lBWTdCLGlCQUFpQjtJQXFEL0IsT0FBTyxDQUFDLG1CQUFtQjtJQWtDM0IsT0FBTyxDQUFDLG9CQUFvQjtJQU01QixPQUFPLENBQUMsMEJBQTBCO0lBS2xDLE9BQU8sQ0FBQyxjQUFjO0lBTXRCLE9BQU8sQ0FBQyxnQ0FBZ0M7SUFnQnhDLE9BQU8sQ0FBQyxxQkFBcUI7SUF1QjdCLE9BQU8sQ0FBQyxhQUFhO0lBYXJCLE9BQU8sQ0FBQyxVQUFVO0lBYWxCLE9BQU8sQ0FBQyw4QkFBOEI7WUFVeEIsc0JBQXNCO0NBT3JDIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"batch_tx_requester.d.ts","sourceRoot":"","sources":["../../../../src/services/reqresp/batch-tx-requester/batch_tx_requester.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"batch_tx_requester.d.ts","sourceRoot":"","sources":["../../../../src/services/reqresp/batch-tx-requester/batch_tx_requester.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAGlE,OAAO,EAAE,YAAY,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CAAC,EAAE,MAAM,EACf,YAAY,CAAC,EAAE,YAAY,EAC3B,IAAI,CAAC,EAAE,uBAAuB,EAkC/B;IAKa,GAAG,IAAI,cAAc,CAAC,EAAE,EAAE,EAAE,GAAG,SAAS,EAAE,OAAO,CAAC,CA6C/D;IAKD,OAAoB,aAAa,CAAC,SAAS,EAAE,cAAc,CAAC,EAAE,EAAE,EAAE,GAAG,SAAS,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,EAAE,EAAE,CAAC,CASvG;YAUa,mBAAmB;YAkDnB,aAAa;YAyDb,cAAc;YAgDd,cAAc;YAwCd,eAAe;YAkFf,cAAc;IAmC5B,OAAO,CAAC,0BAA0B;YAiBpB,6BAA6B;YAY7B,iBAAiB;IAqD/B,OAAO,CAAC,mBAAmB;IAkC3B,OAAO,CAAC,oBAAoB;IAM5B,OAAO,CAAC,0BAA0B;IAKlC,OAAO,CAAC,cAAc;IAMtB,OAAO,CAAC,gCAAgC;IAgBxC,OAAO,CAAC,qBAAqB;IAuB7B,OAAO,CAAC,aAAa;IAarB,OAAO,CAAC,UAAU;IAalB,OAAO,CAAC,8BAA8B;YAUxB,sBAAsB;CAOrC"}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { chunkWrapAround } from '@aztec/foundation/collection';
|
|
2
|
+
import { TimeoutError } from '@aztec/foundation/error';
|
|
2
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
3
4
|
import { FifoMemoryQueue, Semaphore } from '@aztec/foundation/queue';
|
|
4
5
|
import { sleep } from '@aztec/foundation/sleep';
|
|
5
|
-
import { DateProvider } from '@aztec/foundation/timer';
|
|
6
|
+
import { DateProvider, executeTimeout } from '@aztec/foundation/timer';
|
|
6
7
|
import { PeerErrorSeverity } from '@aztec/stdlib/p2p';
|
|
7
8
|
import { TxHash } from '@aztec/stdlib/tx';
|
|
9
|
+
import { peerIdFromString } from '@libp2p/peer-id';
|
|
8
10
|
import { ReqRespSubProtocol } from '.././interface.js';
|
|
9
11
|
import { BlockTxsRequest, BlockTxsResponse } from '.././protocols/index.js';
|
|
10
12
|
import { ReqRespStatus } from '.././status.js';
|
|
@@ -29,64 +31,79 @@ import { BatchRequestTxValidator } from './tx_validator.js';
|
|
|
29
31
|
* - Bad peer:
|
|
30
32
|
* - Is the peer which was unable to send us successful response N times in a row
|
|
31
33
|
* */ export class BatchTxRequester {
|
|
32
|
-
requestTracker;
|
|
33
34
|
blockTxsSource;
|
|
34
35
|
pinnedPeer;
|
|
36
|
+
timeoutMs;
|
|
35
37
|
p2pService;
|
|
36
38
|
logger;
|
|
39
|
+
dateProvider;
|
|
37
40
|
opts;
|
|
38
41
|
peers;
|
|
39
42
|
txsMetadata;
|
|
43
|
+
deadline;
|
|
40
44
|
smartRequesterSemaphore;
|
|
41
45
|
txQueue;
|
|
42
46
|
txValidator;
|
|
43
47
|
smartParallelWorkerCount;
|
|
44
48
|
dumbParallelWorkerCount;
|
|
45
49
|
txBatchSize;
|
|
46
|
-
constructor(
|
|
47
|
-
this.requestTracker = requestTracker;
|
|
50
|
+
constructor(missingTxsTracker, blockTxsSource, pinnedPeer, timeoutMs, p2pService, logger, dateProvider, opts){
|
|
48
51
|
this.blockTxsSource = blockTxsSource;
|
|
49
52
|
this.pinnedPeer = pinnedPeer;
|
|
53
|
+
this.timeoutMs = timeoutMs;
|
|
50
54
|
this.p2pService = p2pService;
|
|
51
55
|
this.logger = logger ?? createLogger('p2p:reqresp_batch');
|
|
56
|
+
this.dateProvider = dateProvider ?? new DateProvider();
|
|
52
57
|
this.opts = opts ?? {};
|
|
53
58
|
this.smartParallelWorkerCount = this.opts.smartParallelWorkerCount ?? DEFAULT_BATCH_TX_REQUESTER_SMART_PARALLEL_WORKER_COUNT;
|
|
54
59
|
this.dumbParallelWorkerCount = this.opts.dumbParallelWorkerCount ?? DEFAULT_BATCH_TX_REQUESTER_DUMB_PARALLEL_WORKER_COUNT;
|
|
55
60
|
this.txBatchSize = this.opts.txBatchSize ?? DEFAULT_BATCH_TX_REQUESTER_TX_BATCH_SIZE;
|
|
61
|
+
this.deadline = this.dateProvider.now() + this.timeoutMs;
|
|
56
62
|
this.txQueue = new FifoMemoryQueue(this.logger);
|
|
57
63
|
this.txValidator = this.opts.txValidator ?? new BatchRequestTxValidator(this.p2pService.txValidatorConfig);
|
|
58
64
|
if (this.opts.peerCollection) {
|
|
59
65
|
this.peers = this.opts.peerCollection;
|
|
60
66
|
} else {
|
|
67
|
+
const initialPeers = this.p2pService.connectionSampler.getPeerListSortedByConnectionCountAsc();
|
|
61
68
|
const badPeerThreshold = this.opts.badPeerThreshold ?? DEFAULT_BATCH_TX_REQUESTER_BAD_PEER_THRESHOLD;
|
|
62
|
-
this.peers = new PeerCollection(
|
|
69
|
+
this.peers = new PeerCollection(initialPeers, this.pinnedPeer, this.dateProvider, badPeerThreshold, this.p2pService.peerScoring);
|
|
63
70
|
}
|
|
64
|
-
this.txsMetadata = new MissingTxMetadataCollection(
|
|
71
|
+
this.txsMetadata = new MissingTxMetadataCollection(missingTxsTracker, this.txBatchSize);
|
|
65
72
|
this.smartRequesterSemaphore = this.opts.semaphore ?? new Semaphore(0);
|
|
66
73
|
}
|
|
67
74
|
/*
|
|
68
75
|
* Fetches all missing transactions and yields them one by one
|
|
69
76
|
* */ async *run() {
|
|
77
|
+
// Our timeout is represented in milliseconds but queue expects seconds
|
|
78
|
+
// We also want to make sure we wait at least 1 second in case of very low timeouts
|
|
79
|
+
const timeoutQueueAfter = Math.max(Math.ceil(this.timeoutMs / 1_000), 1);
|
|
70
80
|
try {
|
|
71
81
|
if (this.txsMetadata.getMissingTxHashes().size === 0) {
|
|
72
82
|
return undefined;
|
|
73
83
|
}
|
|
74
|
-
// Start workers in background
|
|
75
|
-
const workersPromise = Promise.allSettled([
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
84
|
+
// Start workers in background
|
|
85
|
+
const workersPromise = executeTimeout(()=>Promise.allSettled([
|
|
86
|
+
this.smartRequester(),
|
|
87
|
+
this.dumbRequester(),
|
|
88
|
+
this.pinnedPeerRequester()
|
|
89
|
+
]), this.timeoutMs).finally(()=>{
|
|
80
90
|
this.txQueue.end();
|
|
81
91
|
});
|
|
82
|
-
// Yield txs as workers put them on the queue. The queue's end() drains remaining items
|
|
83
|
-
// before returning null, so we don't lose any txs.
|
|
84
92
|
while(true){
|
|
85
|
-
const tx = await this.txQueue.get();
|
|
93
|
+
const tx = await this.txQueue.get(timeoutQueueAfter);
|
|
94
|
+
// null indicates that the queue has ended
|
|
86
95
|
if (tx === null) {
|
|
87
96
|
break;
|
|
88
97
|
}
|
|
89
98
|
yield tx;
|
|
99
|
+
if (this.shouldStop()) {
|
|
100
|
+
// Drain queue before ending
|
|
101
|
+
let remaining;
|
|
102
|
+
while((remaining = this.txQueue.getImmediate()) !== undefined){
|
|
103
|
+
yield remaining;
|
|
104
|
+
}
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
90
107
|
}
|
|
91
108
|
this.unlockSmartRequesterSemaphores();
|
|
92
109
|
await workersPromise;
|
|
@@ -160,6 +177,7 @@ import { BatchRequestTxValidator } from './tx_validator.js';
|
|
|
160
177
|
/*
|
|
161
178
|
* Starts dumb worker loops
|
|
162
179
|
* */ async dumbRequester() {
|
|
180
|
+
const nextPeerIndex = this.makeRoundRobinIndexer();
|
|
163
181
|
const nextBatchIndex = this.makeRoundRobinIndexer();
|
|
164
182
|
// Chunk missing tx hashes into batches of txBatchSize, wrapping around to ensure no peer gets less than txBatchSize
|
|
165
183
|
const txChunks = ()=>{
|
|
@@ -187,10 +205,15 @@ import { BatchRequestTxValidator } from './tx_validator.js';
|
|
|
187
205
|
txs
|
|
188
206
|
};
|
|
189
207
|
};
|
|
190
|
-
const
|
|
208
|
+
const nextPeer = ()=>{
|
|
209
|
+
const peers = this.peers.getDumbPeersToQuery();
|
|
210
|
+
const idx = nextPeerIndex(()=>peers.length);
|
|
211
|
+
return idx === undefined ? undefined : peerIdFromString(peers[idx]);
|
|
212
|
+
};
|
|
213
|
+
const workerCount = Math.min(this.dumbParallelWorkerCount, this.peers.getAllPeers().size);
|
|
191
214
|
const workers = Array.from({
|
|
192
215
|
length: workerCount
|
|
193
|
-
}, (_, index)=>this.dumbWorkerLoop(
|
|
216
|
+
}, (_, index)=>this.dumbWorkerLoop(nextPeer, makeRequest, index + 1));
|
|
194
217
|
await Promise.allSettled(workers);
|
|
195
218
|
}
|
|
196
219
|
/*
|
|
@@ -234,6 +257,12 @@ import { BatchRequestTxValidator } from './tx_validator.js';
|
|
|
234
257
|
/*
|
|
235
258
|
* Starts smart worker loops
|
|
236
259
|
* */ async smartRequester() {
|
|
260
|
+
const nextPeerIndex = this.makeRoundRobinIndexer();
|
|
261
|
+
const nextPeer = ()=>{
|
|
262
|
+
const peers = this.peers.getSmartPeersToQuery();
|
|
263
|
+
const idx = nextPeerIndex(()=>peers.length);
|
|
264
|
+
return idx === undefined ? undefined : peerIdFromString(peers[idx]);
|
|
265
|
+
};
|
|
237
266
|
const makeRequest = (pid)=>{
|
|
238
267
|
const txs = this.txsMetadata.getTxsToRequestFromThePeer(pid);
|
|
239
268
|
const blockRequest = BlockTxsRequest.fromTxsSourceAndMissingTxs(this.blockTxsSource, txs);
|
|
@@ -246,8 +275,8 @@ import { BatchRequestTxValidator } from './tx_validator.js';
|
|
|
246
275
|
};
|
|
247
276
|
};
|
|
248
277
|
const workers = Array.from({
|
|
249
|
-
length: this.smartParallelWorkerCount
|
|
250
|
-
}, (_, index)=>this.smartWorkerLoop(
|
|
278
|
+
length: Math.min(this.smartParallelWorkerCount, this.peers.getAllPeers().size)
|
|
279
|
+
}, (_, index)=>this.smartWorkerLoop(nextPeer, makeRequest, index + 1));
|
|
251
280
|
await Promise.allSettled(workers);
|
|
252
281
|
}
|
|
253
282
|
/*
|
|
@@ -265,40 +294,35 @@ import { BatchRequestTxValidator } from './tx_validator.js';
|
|
|
265
294
|
* */ async smartWorkerLoop(pickNextPeer, request, workerIndex) {
|
|
266
295
|
try {
|
|
267
296
|
this.logger.trace(`Smart worker ${workerIndex} started`);
|
|
268
|
-
await
|
|
269
|
-
this.smartRequesterSemaphore.acquire(),
|
|
270
|
-
this.requestTracker.cancellationToken
|
|
271
|
-
]);
|
|
272
|
-
if (this.requestTracker.checkCancelled()) {
|
|
273
|
-
return;
|
|
274
|
-
}
|
|
297
|
+
await executeTimeout((_)=>this.smartRequesterSemaphore.acquire(), this.timeoutMs);
|
|
275
298
|
this.logger.trace(`Smart worker ${workerIndex} acquired semaphore`);
|
|
276
299
|
while(!this.shouldStop()){
|
|
277
300
|
const peerId = pickNextPeer();
|
|
278
301
|
const weRanOutOfPeersToQuery = peerId === undefined;
|
|
279
302
|
if (weRanOutOfPeersToQuery) {
|
|
280
303
|
this.logger.debug(`Worker loop smart: No more peers to query`);
|
|
281
|
-
// If
|
|
282
|
-
|
|
283
|
-
const
|
|
284
|
-
if (
|
|
285
|
-
|
|
286
|
-
|
|
304
|
+
// If there are no more dumb peers to query then none of our peers can become smart,
|
|
305
|
+
// thus we can simply exit this worker
|
|
306
|
+
const noMoreDumbPeersToQuery = this.peers.getDumbPeersToQuery().length === 0;
|
|
307
|
+
if (noMoreDumbPeersToQuery) {
|
|
308
|
+
// These might be either smart peers that will get unblocked after _some time_
|
|
309
|
+
const nextSmartPeerDelay = this.peers.getNextSmartPeerAvailabilityDelayMs();
|
|
310
|
+
const thereAreSomeRateLimitedSmartPeers = nextSmartPeerDelay !== undefined;
|
|
311
|
+
if (thereAreSomeRateLimitedSmartPeers) {
|
|
312
|
+
await this.sleepClampedToDeadline(nextSmartPeerDelay);
|
|
313
|
+
continue;
|
|
314
|
+
}
|
|
315
|
+
this.logger.debug(`Worker loop smart: No more smart peers to query killing ${workerIndex}`);
|
|
316
|
+
break;
|
|
287
317
|
}
|
|
318
|
+
// Otherwise there are still some dumb peers that could become smart.
|
|
288
319
|
// We end up here when all known smart peers became temporarily unavailable via combination of
|
|
289
320
|
// (bad, in-flight, or rate-limited) or in some weird scenario all current smart peers turn bad which is permanent
|
|
290
|
-
// but
|
|
291
|
-
// or new peer can join as dumb and be promoted later
|
|
321
|
+
// but dumb peers still exist that could become smart.
|
|
292
322
|
//
|
|
293
323
|
// When a dumb peer responds with valid txIndices, it gets
|
|
294
324
|
// promoted to smart and releases the semaphore, waking this worker.
|
|
295
|
-
await
|
|
296
|
-
this.smartRequesterSemaphore.acquire(),
|
|
297
|
-
this.requestTracker.cancellationToken
|
|
298
|
-
]);
|
|
299
|
-
if (this.requestTracker.checkCancelled()) {
|
|
300
|
-
break;
|
|
301
|
-
}
|
|
325
|
+
await executeTimeout((_)=>this.smartRequesterSemaphore.acquire(), this.timeoutMs);
|
|
302
326
|
this.logger.debug(`Worker loop smart: acquired next smart peer`);
|
|
303
327
|
continue;
|
|
304
328
|
}
|
|
@@ -321,7 +345,11 @@ import { BatchRequestTxValidator } from './tx_validator.js';
|
|
|
321
345
|
});
|
|
322
346
|
}
|
|
323
347
|
} catch (err) {
|
|
324
|
-
|
|
348
|
+
if (err instanceof TimeoutError) {
|
|
349
|
+
this.logger.debug(`Smart worker ${workerIndex} timed out waiting for semaphore`);
|
|
350
|
+
} else {
|
|
351
|
+
this.logger.error(`Smart worker ${workerIndex} encountered an error: ${err}`);
|
|
352
|
+
}
|
|
325
353
|
} finally{
|
|
326
354
|
this.logger.debug(`Smart worker ${workerIndex} finished`);
|
|
327
355
|
}
|
|
@@ -359,17 +387,9 @@ import { BatchRequestTxValidator } from './tx_validator.js';
|
|
|
359
387
|
* - FAILURE and UNKNOWN: We penalise this, if peer has been penalised this way N times they are not queried again
|
|
360
388
|
* this implies we will query these peers couple of more times and give them a chance to "redeem" themselves before completely ignoring them
|
|
361
389
|
*/ handleFailResponseFromPeer(peerId, responseStatus) {
|
|
390
|
+
//TODO: Should we ban these peers?
|
|
362
391
|
if (responseStatus === ReqRespStatus.FAILURE || responseStatus === ReqRespStatus.UNKNOWN) {
|
|
363
392
|
this.peers.penalisePeer(peerId, PeerErrorSeverity.HighToleranceError);
|
|
364
|
-
this.peers.markPeerDumb(peerId);
|
|
365
|
-
this.txsMetadata.clearPeerData(peerId);
|
|
366
|
-
return;
|
|
367
|
-
}
|
|
368
|
-
// NOT_FOUND means the peer pruned its block proposal — it can no longer serve
|
|
369
|
-
// index-based requests, but this is a legitimate state so we don't penalize.
|
|
370
|
-
if (responseStatus === ReqRespStatus.NOT_FOUND) {
|
|
371
|
-
this.peers.markPeerDumb(peerId);
|
|
372
|
-
this.txsMetadata.clearPeerData(peerId);
|
|
373
393
|
return;
|
|
374
394
|
}
|
|
375
395
|
if (responseStatus === ReqRespStatus.RATE_LIMIT_EXCEEDED) {
|
|
@@ -411,9 +431,6 @@ import { BatchRequestTxValidator } from './tx_validator.js';
|
|
|
411
431
|
}
|
|
412
432
|
});
|
|
413
433
|
if (hasInvalidTx) {
|
|
414
|
-
this.logger.warn(`Penalizing peer ${peerId.toString()} for sending invalid transactions in batch response`, {
|
|
415
|
-
peerId
|
|
416
|
-
});
|
|
417
434
|
this.peers.penalisePeer(peerId, PeerErrorSeverity.LowToleranceError);
|
|
418
435
|
} else {
|
|
419
436
|
// If we have received successful response from the peer, they have "redeemed" themselves and not considered bad anymore
|
|
@@ -441,9 +458,10 @@ import { BatchRequestTxValidator } from './tx_validator.js';
|
|
|
441
458
|
if (smartPeersAreDisabled) {
|
|
442
459
|
return;
|
|
443
460
|
}
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
461
|
+
// If block response is invalid we still want to query this peer in the future
|
|
462
|
+
// Because they sent successful response, so they might become smart peer in the future
|
|
463
|
+
// Or send us needed txs
|
|
464
|
+
if (!this.isBlockResponseValid(response)) {
|
|
447
465
|
return;
|
|
448
466
|
}
|
|
449
467
|
// We mark peer as "smart" only if they have some txs we are missing
|
|
@@ -455,24 +473,16 @@ import { BatchRequestTxValidator } from './tx_validator.js';
|
|
|
455
473
|
this.peers.markPeerSmart(peerId);
|
|
456
474
|
this.markTxsPeerHas(peerId, response);
|
|
457
475
|
// Unblock smart workers
|
|
458
|
-
this.
|
|
459
|
-
|
|
460
|
-
/**
|
|
461
|
-
* Handles an archive root mismatch between local state and peer response.
|
|
462
|
-
*
|
|
463
|
-
* - Response archive is Fr.ZERO (peer pruned proposal, legitimate): marks peer dumb.
|
|
464
|
-
* - Non-zero archive mismatch (malicious response): penalises + marks dumb.
|
|
465
|
-
*/ handleArchiveRootMismatch(peerId, response) {
|
|
466
|
-
if (!response.archiveRoot.isZero()) {
|
|
467
|
-
this.peers.penalisePeer(peerId, PeerErrorSeverity.LowToleranceError);
|
|
476
|
+
if (this.peers.getSmartPeersToQuery().length <= this.smartParallelWorkerCount) {
|
|
477
|
+
this.smartRequesterSemaphore.release();
|
|
468
478
|
}
|
|
469
|
-
|
|
470
|
-
|
|
479
|
+
}
|
|
480
|
+
isBlockResponseValid(response) {
|
|
481
|
+
const archiveRootsMatch = this.blockTxsSource.archive.toString() === response.archiveRoot.toString();
|
|
482
|
+
const peerHasSomeTxsFromProposal = !response.txIndices.isEmpty();
|
|
483
|
+
return archiveRootsMatch && peerHasSomeTxsFromProposal;
|
|
471
484
|
}
|
|
472
485
|
peerHasSomeTxsWeAreMissing(_peerId, response) {
|
|
473
|
-
if (response.txIndices.isEmpty()) {
|
|
474
|
-
return false;
|
|
475
|
-
}
|
|
476
486
|
const txsPeerHas = new Set(this.extractHashesPeerHasFromResponse(response).map((h)=>h.toString()));
|
|
477
487
|
return this.txsMetadata.getMissingTxHashes().intersection(txsPeerHas).size > 0;
|
|
478
488
|
}
|
|
@@ -513,12 +523,23 @@ import { BatchRequestTxValidator } from './tx_validator.js';
|
|
|
513
523
|
};
|
|
514
524
|
}
|
|
515
525
|
/*
|
|
516
|
-
*
|
|
517
|
-
|
|
518
|
-
|
|
526
|
+
* @returns true if all missing txs have been fetched */ fetchedAllTxs() {
|
|
527
|
+
return this.txsMetadata.getMissingTxHashes().size == 0;
|
|
528
|
+
}
|
|
529
|
+
/*
|
|
530
|
+
* Checks if the BatchTxRequester should stop fetching missing txs
|
|
531
|
+
* Conditions for stopping are:
|
|
532
|
+
* - There have been no missing transactions to start with
|
|
533
|
+
* - All transactions have been fetched
|
|
534
|
+
* - The deadline has been hit (no more time to fetch)
|
|
535
|
+
* - This process has been cancelled via abortSignal
|
|
536
|
+
*
|
|
537
|
+
* @returns true if BatchTxRequester should stop, otherwise false*/ shouldStop() {
|
|
538
|
+
const aborted = this.opts.abortSignal?.aborted ?? false;
|
|
539
|
+
if (aborted) {
|
|
519
540
|
this.unlockSmartRequesterSemaphores();
|
|
520
541
|
}
|
|
521
|
-
return this.
|
|
542
|
+
return aborted || this.fetchedAllTxs() || this.dateProvider.now() > this.deadline;
|
|
522
543
|
}
|
|
523
544
|
/*
|
|
524
545
|
* Helper function which unlocks all smart requester semaphores
|
|
@@ -532,12 +553,10 @@ import { BatchRequestTxValidator } from './tx_validator.js';
|
|
|
532
553
|
* Sleeps for the given duration, but clamped to the deadline.
|
|
533
554
|
* This ensures we don't sleep past the deadline.
|
|
534
555
|
* */ async sleepClampedToDeadline(durationMs) {
|
|
535
|
-
|
|
536
|
-
|
|
556
|
+
const remaining = this.deadline - this.dateProvider.now();
|
|
557
|
+
const thereIsTimeRemaining = remaining > 0;
|
|
558
|
+
if (thereIsTimeRemaining) {
|
|
559
|
+
await sleep(Math.min(durationMs, remaining));
|
|
537
560
|
}
|
|
538
|
-
await Promise.race([
|
|
539
|
-
sleep(durationMs),
|
|
540
|
-
this.requestTracker.cancellationToken
|
|
541
|
-
]);
|
|
542
561
|
}
|
|
543
562
|
}
|
|
@@ -18,8 +18,6 @@ export interface ITxMetadataCollection {
|
|
|
18
18
|
markNotInFlightBySmartPeer(txHash: TxHash): void;
|
|
19
19
|
alreadyFetched(txHash: TxHash): boolean;
|
|
20
20
|
markPeerHas(peerId: PeerId, txHashes: TxHash[]): void;
|
|
21
|
-
/** Remove all tx metadata associations for a peer (e.g. on demotion from smart to dumb). */
|
|
22
|
-
clearPeerData(peerId: PeerId): void;
|
|
23
21
|
}
|
|
24
22
|
/**
|
|
25
23
|
* Interface for BatchTxRequester dependencies that can be injected from upstream
|
|
@@ -41,7 +39,8 @@ export interface BatchTxRequesterOptions {
|
|
|
41
39
|
badPeerThreshold?: number;
|
|
42
40
|
semaphore?: ISemaphore;
|
|
43
41
|
peerCollection?: IPeerCollection;
|
|
42
|
+
abortSignal?: AbortSignal;
|
|
44
43
|
/** Optional tx validator for testing - if not provided, one is created from p2pService.txValidatorConfig */
|
|
45
44
|
txValidator?: IBatchRequestTxValidator;
|
|
46
45
|
}
|
|
47
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
46
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW50ZXJmYWNlLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvc2VydmljZXMvcmVxcmVzcC9iYXRjaC10eC1yZXF1ZXN0ZXIvaW50ZXJmYWNlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLFVBQVUsRUFBRSxNQUFNLHlCQUF5QixDQUFDO0FBQzFELE9BQU8sS0FBSyxFQUFFLGlCQUFpQixFQUFFLE1BQU0sbUJBQW1CLENBQUM7QUFDM0QsT0FBTyxLQUFLLEVBQUUsRUFBRSxFQUFFLE1BQU0sRUFBRSxNQUFNLGtCQUFrQixDQUFDO0FBRW5ELE9BQU8sS0FBSyxFQUFFLE1BQU0sRUFBRSxNQUFNLG1CQUFtQixDQUFDO0FBRWhELE9BQU8sS0FBSyxFQUFFLGlCQUFpQixFQUFFLE1BQU0sNkNBQTZDLENBQUM7QUFDckYsT0FBTyxLQUFLLEVBQUUsZ0JBQWdCLEVBQUUsTUFBTSxpQkFBaUIsQ0FBQztBQUN4RCxPQUFPLEtBQUssRUFBRSxlQUFlLEVBQUUsTUFBTSxzQkFBc0IsQ0FBQztBQUM1RCxPQUFPLEtBQUssRUFBRSw2QkFBNkIsRUFB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A4G;IAC5G,WAAW,CAAC,EAAE,wBAAwB,CAAC;CACxC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Tx, TxHash } from '@aztec/stdlib/tx';
|
|
2
2
|
import type { PeerId } from '@libp2p/interface';
|
|
3
|
-
import type {
|
|
3
|
+
import type { IMissingTxsTracker } from '../../tx_collection/missing_txs_tracker.js';
|
|
4
4
|
import type { ITxMetadataCollection } from './interface.js';
|
|
5
5
|
declare class MissingTxMetadata {
|
|
6
6
|
readonly txHash: string;
|
|
@@ -15,10 +15,10 @@ declare class MissingTxMetadata {
|
|
|
15
15
|
isInFlight(): boolean;
|
|
16
16
|
}
|
|
17
17
|
export declare class MissingTxMetadataCollection implements ITxMetadataCollection {
|
|
18
|
-
private
|
|
18
|
+
private missingTxsTracker;
|
|
19
19
|
private readonly txBatchSize;
|
|
20
20
|
private txMetadata;
|
|
21
|
-
constructor(
|
|
21
|
+
constructor(missingTxsTracker: IMissingTxsTracker, txBatchSize?: number);
|
|
22
22
|
getPrioritizingNotInFlightAndLowerRequestCount(txs: string[]): MissingTxMetadata[];
|
|
23
23
|
getMissingTxHashes(): Set<string>;
|
|
24
24
|
getTxsPeerHas(peer: PeerId): Set<string>;
|
|
@@ -29,7 +29,6 @@ export declare class MissingTxMetadataCollection implements ITxMetadataCollectio
|
|
|
29
29
|
alreadyFetched(txHash: TxHash): boolean;
|
|
30
30
|
markFetched(peerId: PeerId, tx: Tx): boolean;
|
|
31
31
|
markPeerHas(peerId: PeerId, txHash: TxHash[]): void;
|
|
32
|
-
clearPeerData(peerId: PeerId): void;
|
|
33
32
|
}
|
|
34
33
|
export {};
|
|
35
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
34
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWlzc2luZ190eHMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy9zZXJ2aWNlc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lCLEVBQUUsQ0FleEY7SUFFTSxrQkFBa0IsSUFBSSxHQUFHLENBQUMsTUFBTSxDQUFDLENBRXZDO0lBRU0sYUFBYSxDQUFDLElBQUksRUFBRSxNQUFNLEdBQUcsR0FBRyxDQUFDLE1BQU0sQ0FBQyxDQVc5QztJQUVNLDBCQUEwQixDQUFDLElBQUksRUFBRSxNQUFNLEdBQUcsTUFBTSxFQUFFLENBdUJ4RDtJQUVNLGFBQWEsQ0FBQyxNQUFNLEVBQUUsTUFBTSxRQUVsQztJQU9NLHVCQUF1QixDQUFDLE1BQU0sRUFBRSxNQUFNLFFBRTVDO0lBTU0sMEJBQTBCLENBQUMsTUFBTSxFQUFFLE1BQU0sUUFFL0M7SUFFTSxjQUFjLENBQUMsTUFBTSxFQUFFLE1BQU0sR0FBRyxPQUFPLENBRTdDO0lBRU0sV0FBVyxDQUFDLE1BQU0sRUFBRSxNQUFNLEVBQUUsRUFBRSxFQUFFLEVBQUUsR0FBRyxPQUFPLENBY2xEO0lBRU0sV0FBVyxDQUFDLE1BQU0sRUFBRSxNQUFNLEVBQUUsTUFBTSxFQUFFLE1BQU0sRUFBRSxRQVVsRDtDQUNGIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"missing_txs.d.ts","sourceRoot":"","sources":["../../../../src/services/reqresp/batch-tx-requester/missing_txs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"missing_txs.d.ts","sourceRoot":"","sources":["../../../../src/services/reqresp/batch-tx-requester/missing_txs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAm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