@aztec/p2p 0.0.1-commit.d431d1c → 0.0.1-commit.e310a4c8
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 +4 -3
- package/dest/bootstrap/bootstrap.d.ts.map +1 -1
- package/dest/bootstrap/bootstrap.js +4 -4
- package/dest/client/factory.d.ts +1 -1
- package/dest/client/factory.d.ts.map +1 -1
- package/dest/client/factory.js +6 -5
- 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 +9 -2
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.d.ts +2 -0
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.d.ts.map +1 -0
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +305 -0
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.d.ts +73 -0
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.d.ts.map +1 -0
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.js +8 -0
- package/dest/config.d.ts +8 -2
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +2 -0
- 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 +2 -2
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts +3 -3
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/eviction/eviction_manager.d.ts +3 -2
- package/dest/mem_pools/tx_pool/eviction/eviction_manager.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/eviction/eviction_strategy.d.ts +3 -2
- package/dest/mem_pools/tx_pool/eviction/eviction_strategy.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.d.ts +3 -3
- package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.js +8 -1
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.d.ts +3 -3
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.js +2 -0
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts +3 -3
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts.map +1 -1
- package/dest/msg_validators/attestation_validator/attestation_validator.js +40 -9
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts +3 -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 +18 -6
- package/dest/msg_validators/clock_tolerance.d.ts +21 -0
- package/dest/msg_validators/clock_tolerance.d.ts.map +1 -0
- package/dest/msg_validators/clock_tolerance.js +37 -0
- package/dest/msg_validators/proposal_validator/proposal_validator.d.ts +3 -3
- package/dest/msg_validators/proposal_validator/proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/proposal_validator.js +46 -15
- package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.d.ts +3 -3
- package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.js +66 -11
- package/dest/msg_validators/tx_validator/archive_cache.d.ts +3 -3
- package/dest/msg_validators/tx_validator/archive_cache.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/archive_cache.js +1 -1
- package/dest/msg_validators/tx_validator/block_header_validator.d.ts +5 -4
- package/dest/msg_validators/tx_validator/block_header_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/block_header_validator.js +3 -2
- package/dest/msg_validators/tx_validator/data_validator.d.ts +3 -1
- package/dest/msg_validators/tx_validator/data_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/data_validator.js +4 -1
- package/dest/msg_validators/tx_validator/double_spend_validator.d.ts +3 -2
- package/dest/msg_validators/tx_validator/double_spend_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/double_spend_validator.js +3 -2
- package/dest/msg_validators/tx_validator/factory.d.ts +8 -3
- package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/factory.js +21 -11
- package/dest/msg_validators/tx_validator/gas_validator.d.ts +3 -2
- package/dest/msg_validators/tx_validator/gas_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/gas_validator.js +3 -2
- package/dest/msg_validators/tx_validator/metadata_validator.d.ts +3 -2
- package/dest/msg_validators/tx_validator/metadata_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/metadata_validator.js +2 -2
- package/dest/msg_validators/tx_validator/phases_validator.d.ts +3 -2
- package/dest/msg_validators/tx_validator/phases_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/phases_validator.js +3 -3
- package/dest/msg_validators/tx_validator/size_validator.d.ts +3 -1
- package/dest/msg_validators/tx_validator/size_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/size_validator.js +4 -1
- package/dest/msg_validators/tx_validator/timestamp_validator.d.ts +3 -2
- package/dest/msg_validators/tx_validator/timestamp_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/timestamp_validator.js +2 -2
- package/dest/msg_validators/tx_validator/tx_permitted_validator.d.ts +3 -2
- package/dest/msg_validators/tx_validator/tx_permitted_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/tx_permitted_validator.js +2 -2
- package/dest/msg_validators/tx_validator/tx_proof_validator.d.ts +3 -2
- 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 -2
- package/dest/services/data_store.d.ts +1 -1
- package/dest/services/data_store.d.ts.map +1 -1
- package/dest/services/data_store.js +10 -6
- package/dest/services/discv5/discV5_service.js +1 -1
- package/dest/services/dummy_service.d.ts +13 -1
- package/dest/services/dummy_service.d.ts.map +1 -1
- package/dest/services/dummy_service.js +39 -0
- package/dest/services/libp2p/instrumentation.d.ts +1 -1
- package/dest/services/libp2p/instrumentation.d.ts.map +1 -1
- package/dest/services/libp2p/instrumentation.js +14 -3
- package/dest/services/libp2p/libp2p_service.d.ts +13 -7
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +61 -52
- package/dest/services/peer-manager/metrics.d.ts +2 -2
- package/dest/services/peer-manager/metrics.d.ts.map +1 -1
- package/dest/services/peer-manager/metrics.js +20 -5
- package/dest/services/peer-manager/peer_scoring.d.ts +1 -1
- package/dest/services/peer-manager/peer_scoring.d.ts.map +1 -1
- package/dest/services/peer-manager/peer_scoring.js +8 -2
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts +47 -0
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts.map +1 -0
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.js +566 -0
- package/dest/services/reqresp/batch-tx-requester/config.d.ts +17 -0
- package/dest/services/reqresp/batch-tx-requester/config.d.ts.map +1 -0
- package/dest/services/reqresp/batch-tx-requester/config.js +27 -0
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts +50 -0
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts.map +1 -0
- package/dest/services/reqresp/batch-tx-requester/interface.js +1 -0
- package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts +37 -0
- package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts.map +1 -0
- package/dest/services/reqresp/batch-tx-requester/missing_txs.js +151 -0
- package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts +54 -0
- package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts.map +1 -0
- package/dest/services/reqresp/batch-tx-requester/peer_collection.js +139 -0
- package/dest/services/reqresp/batch-tx-requester/tx_validator.d.ts +20 -0
- package/dest/services/reqresp/batch-tx-requester/tx_validator.d.ts.map +1 -0
- package/dest/services/reqresp/batch-tx-requester/tx_validator.js +21 -0
- package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts +22 -3
- package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts.map +1 -1
- package/dest/services/reqresp/connection-sampler/batch_connection_sampler.js +63 -4
- package/dest/services/reqresp/connection-sampler/connection_sampler.d.ts +2 -1
- package/dest/services/reqresp/connection-sampler/connection_sampler.d.ts.map +1 -1
- package/dest/services/reqresp/connection-sampler/connection_sampler.js +12 -0
- package/dest/services/reqresp/interface.d.ts +5 -3
- package/dest/services/reqresp/interface.d.ts.map +1 -1
- package/dest/services/reqresp/interface.js +2 -2
- package/dest/services/reqresp/metrics.d.ts +6 -5
- package/dest/services/reqresp/metrics.d.ts.map +1 -1
- package/dest/services/reqresp/metrics.js +17 -5
- package/dest/services/reqresp/protocols/block_txs/bitvector.d.ts +5 -1
- package/dest/services/reqresp/protocols/block_txs/bitvector.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/block_txs/bitvector.js +5 -0
- 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 +16 -3
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts +18 -6
- 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 +43 -13
- package/dest/services/reqresp/reqresp.d.ts +6 -1
- package/dest/services/reqresp/reqresp.d.ts.map +1 -1
- package/dest/services/reqresp/reqresp.js +58 -22
- package/dest/services/service.d.ts +4 -1
- package/dest/services/service.d.ts.map +1 -1
- package/dest/services/tx_collection/config.d.ts +4 -1
- package/dest/services/tx_collection/config.d.ts.map +1 -1
- package/dest/services/tx_collection/config.js +9 -1
- package/dest/services/tx_collection/fast_tx_collection.d.ts +6 -4
- package/dest/services/tx_collection/fast_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/fast_tx_collection.js +16 -5
- package/dest/services/tx_collection/index.d.ts +2 -1
- package/dest/services/tx_collection/index.d.ts.map +1 -1
- package/dest/services/tx_collection/index.js +1 -0
- 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 +9 -2
- package/dest/services/tx_collection/proposal_tx_collector.d.ts +48 -0
- package/dest/services/tx_collection/proposal_tx_collector.d.ts.map +1 -0
- package/dest/services/tx_collection/proposal_tx_collector.js +50 -0
- package/dest/services/tx_collection/slow_tx_collection.d.ts +3 -3
- package/dest/services/tx_collection/slow_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_collection.d.ts +8 -8
- package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_collection.js +5 -5
- package/dest/services/tx_provider.d.ts +3 -3
- package/dest/services/tx_provider.d.ts.map +1 -1
- package/dest/services/tx_provider_instrumentation.d.ts +1 -1
- package/dest/services/tx_provider_instrumentation.d.ts.map +1 -1
- package/dest/services/tx_provider_instrumentation.js +5 -5
- package/dest/test-helpers/index.d.ts +3 -1
- package/dest/test-helpers/index.d.ts.map +1 -1
- package/dest/test-helpers/index.js +2 -0
- package/dest/test-helpers/test_tx_provider.d.ts +40 -0
- package/dest/test-helpers/test_tx_provider.d.ts.map +1 -0
- package/dest/test-helpers/test_tx_provider.js +41 -0
- package/dest/test-helpers/testbench-utils.d.ts +158 -0
- package/dest/test-helpers/testbench-utils.d.ts.map +1 -0
- package/dest/test-helpers/testbench-utils.js +297 -0
- package/dest/testbench/p2p_client_testbench_worker.d.ts +28 -2
- package/dest/testbench/p2p_client_testbench_worker.d.ts.map +1 -1
- package/dest/testbench/p2p_client_testbench_worker.js +212 -130
- package/dest/testbench/worker_client_manager.d.ts +51 -6
- package/dest/testbench/worker_client_manager.d.ts.map +1 -1
- package/dest/testbench/worker_client_manager.js +226 -44
- package/package.json +14 -14
- package/src/bootstrap/bootstrap.ts +7 -4
- package/src/client/factory.ts +6 -10
- package/src/client/p2p_client.ts +14 -7
- package/src/client/test/tx_proposal_collector/README.md +227 -0
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +336 -0
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.ts +43 -0
- package/src/config.ts +6 -1
- package/src/mem_pools/instrumentation.ts +2 -1
- package/src/mem_pools/tx_pool/aztec_kv_tx_pool.ts +2 -2
- package/src/mem_pools/tx_pool/eviction/eviction_manager.ts +2 -1
- package/src/mem_pools/tx_pool/eviction/eviction_strategy.ts +2 -1
- package/src/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.ts +10 -7
- package/src/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.ts +4 -2
- package/src/msg_validators/attestation_validator/attestation_validator.ts +25 -13
- package/src/msg_validators/attestation_validator/fisherman_attestation_validator.ts +14 -8
- package/src/msg_validators/clock_tolerance.ts +51 -0
- package/src/msg_validators/proposal_validator/proposal_validator.ts +21 -14
- package/src/msg_validators/proposal_validator/proposal_validator_test_suite.ts +53 -14
- package/src/msg_validators/tx_validator/archive_cache.ts +3 -3
- package/src/msg_validators/tx_validator/block_header_validator.ts +6 -5
- package/src/msg_validators/tx_validator/data_validator.ts +6 -2
- package/src/msg_validators/tx_validator/double_spend_validator.ts +4 -3
- package/src/msg_validators/tx_validator/factory.ts +64 -23
- package/src/msg_validators/tx_validator/gas_validator.ts +9 -3
- package/src/msg_validators/tx_validator/metadata_validator.ts +6 -3
- package/src/msg_validators/tx_validator/phases_validator.ts +5 -3
- package/src/msg_validators/tx_validator/size_validator.ts +6 -2
- package/src/msg_validators/tx_validator/timestamp_validator.ts +6 -3
- package/src/msg_validators/tx_validator/tx_permitted_validator.ts +8 -3
- package/src/msg_validators/tx_validator/tx_proof_validator.ts +8 -3
- package/src/services/data_store.ts +10 -7
- package/src/services/discv5/discV5_service.ts +1 -1
- package/src/services/dummy_service.ts +45 -0
- package/src/services/libp2p/instrumentation.ts +15 -2
- package/src/services/libp2p/libp2p_service.ts +99 -75
- package/src/services/peer-manager/metrics.ts +21 -4
- package/src/services/peer-manager/peer_scoring.ts +4 -1
- package/src/services/reqresp/batch-tx-requester/README.md +305 -0
- package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +706 -0
- package/src/services/reqresp/batch-tx-requester/config.ts +40 -0
- package/src/services/reqresp/batch-tx-requester/interface.ts +57 -0
- package/src/services/reqresp/batch-tx-requester/missing_txs.ts +209 -0
- package/src/services/reqresp/batch-tx-requester/peer_collection.ts +205 -0
- package/src/services/reqresp/batch-tx-requester/tx_validator.ts +37 -0
- package/src/services/reqresp/connection-sampler/batch_connection_sampler.ts +65 -4
- package/src/services/reqresp/connection-sampler/connection_sampler.ts +16 -0
- package/src/services/reqresp/interface.ts +5 -2
- package/src/services/reqresp/metrics.ts +34 -9
- package/src/services/reqresp/protocols/block_txs/bitvector.ts +7 -0
- package/src/services/reqresp/protocols/block_txs/block_txs_handler.ts +18 -4
- package/src/services/reqresp/protocols/block_txs/block_txs_reqresp.ts +51 -9
- package/src/services/reqresp/reqresp.ts +66 -19
- package/src/services/service.ts +4 -0
- package/src/services/tx_collection/config.ts +15 -1
- package/src/services/tx_collection/fast_tx_collection.ts +36 -13
- package/src/services/tx_collection/index.ts +5 -0
- package/src/services/tx_collection/instrumentation.ts +11 -2
- package/src/services/tx_collection/proposal_tx_collector.ts +114 -0
- package/src/services/tx_collection/slow_tx_collection.ts +2 -2
- package/src/services/tx_collection/tx_collection.ts +8 -8
- package/src/services/tx_provider.ts +2 -2
- package/src/services/tx_provider_instrumentation.ts +11 -5
- package/src/test-helpers/index.ts +2 -0
- package/src/test-helpers/test_tx_provider.ts +64 -0
- package/src/test-helpers/testbench-utils.ts +374 -0
- package/src/testbench/p2p_client_testbench_worker.ts +321 -122
- package/src/testbench/worker_client_manager.ts +304 -47
|
@@ -6,9 +6,8 @@ import { type Logger, createLibp2pComponentLogger, createLogger } from '@aztec/f
|
|
|
6
6
|
import { RunningPromise } from '@aztec/foundation/running-promise';
|
|
7
7
|
import { Timer } from '@aztec/foundation/timer';
|
|
8
8
|
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
9
|
-
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
10
9
|
import { protocolContractsHash } from '@aztec/protocol-contracts';
|
|
11
|
-
import type { EthAddress,
|
|
10
|
+
import type { EthAddress, L2Block, L2BlockSource } from '@aztec/stdlib/block';
|
|
12
11
|
import type { ContractDataSource } from '@aztec/stdlib/contract';
|
|
13
12
|
import { GasFees } from '@aztec/stdlib/gas';
|
|
14
13
|
import type { ClientProtocolCircuitVerifier, PeerInfo, WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
|
|
@@ -20,6 +19,7 @@ import {
|
|
|
20
19
|
type Gossipable,
|
|
21
20
|
P2PClientType,
|
|
22
21
|
P2PMessage,
|
|
22
|
+
type ValidationResult as P2PValidationResult,
|
|
23
23
|
PeerErrorSeverity,
|
|
24
24
|
TopicType,
|
|
25
25
|
createTopicString,
|
|
@@ -66,18 +66,15 @@ import {
|
|
|
66
66
|
CheckpointAttestationValidator,
|
|
67
67
|
CheckpointProposalValidator,
|
|
68
68
|
FishermanAttestationValidator,
|
|
69
|
-
SizeTxValidator,
|
|
70
69
|
} from '../../msg_validators/index.js';
|
|
71
70
|
import { MessageSeenValidator } from '../../msg_validators/msg_seen_validator/msg_seen_validator.js';
|
|
72
71
|
import { getDefaultAllowedSetupFunctions } from '../../msg_validators/tx_validator/allowed_public_setup.js';
|
|
73
|
-
import { type MessageValidator, createTxMessageValidators } from '../../msg_validators/tx_validator/factory.js';
|
|
74
72
|
import {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
} from '../../msg_validators/tx_validator/index.js';
|
|
73
|
+
type MessageValidator,
|
|
74
|
+
createTxMessageValidators,
|
|
75
|
+
createTxReqRespValidator,
|
|
76
|
+
} from '../../msg_validators/tx_validator/factory.js';
|
|
77
|
+
import { DoubleSpendTxValidator } from '../../msg_validators/tx_validator/index.js';
|
|
81
78
|
import { GossipSubEvent } from '../../types/index.js';
|
|
82
79
|
import { type PubSubLibp2p, convertToMultiaddr } from '../../util.js';
|
|
83
80
|
import { getVersions } from '../../versioning.js';
|
|
@@ -88,10 +85,12 @@ import { gossipScoreThresholds } from '../gossipsub/scoring.js';
|
|
|
88
85
|
import type { PeerManagerInterface } from '../peer-manager/interface.js';
|
|
89
86
|
import { PeerManager } from '../peer-manager/peer_manager.js';
|
|
90
87
|
import { PeerScoring } from '../peer-manager/peer_scoring.js';
|
|
88
|
+
import type { BatchTxRequesterLibP2PService } from '../reqresp/batch-tx-requester/interface.js';
|
|
91
89
|
import type { P2PReqRespConfig } from '../reqresp/config.js';
|
|
92
90
|
import {
|
|
93
91
|
DEFAULT_SUB_PROTOCOL_VALIDATORS,
|
|
94
92
|
type ReqRespInterface,
|
|
93
|
+
type ReqRespResponse,
|
|
95
94
|
ReqRespSubProtocol,
|
|
96
95
|
type ReqRespSubProtocolHandler,
|
|
97
96
|
type ReqRespSubProtocolHandlers,
|
|
@@ -285,14 +284,14 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
285
284
|
|
|
286
285
|
const datastore = new AztecDatastore(peerStore);
|
|
287
286
|
|
|
288
|
-
const otelMetricsAdapter = new OtelMetricsAdapter(telemetry);
|
|
287
|
+
const otelMetricsAdapter = new OtelMetricsAdapter(telemetry, logger.getBindings());
|
|
289
288
|
|
|
290
289
|
const peerDiscoveryService = new DiscV5Service(
|
|
291
290
|
peerId,
|
|
292
291
|
config,
|
|
293
292
|
packageVersion,
|
|
294
293
|
telemetry,
|
|
295
|
-
createLogger(`${logger.module}:discv5_service
|
|
294
|
+
createLogger(`${logger.module}:discv5_service`, logger.getBindings()),
|
|
296
295
|
);
|
|
297
296
|
|
|
298
297
|
// Seed libp2p's bootstrap discovery with private and trusted peers
|
|
@@ -453,7 +452,7 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
453
452
|
connectionManager: components.connectionManager,
|
|
454
453
|
}),
|
|
455
454
|
},
|
|
456
|
-
logger: createLibp2pComponentLogger(logger.module),
|
|
455
|
+
logger: createLibp2pComponentLogger(logger.module, logger.getBindings()),
|
|
457
456
|
});
|
|
458
457
|
|
|
459
458
|
const peerScoring = new PeerScoring(config, telemetry);
|
|
@@ -641,6 +640,15 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
641
640
|
return this.reqresp.sendBatchRequest(protocol, requests, pinnedPeerId);
|
|
642
641
|
}
|
|
643
642
|
|
|
643
|
+
public sendRequestToPeer(
|
|
644
|
+
peerId: PeerId,
|
|
645
|
+
subProtocol: ReqRespSubProtocol,
|
|
646
|
+
payload: Buffer,
|
|
647
|
+
dialTimeout?: number,
|
|
648
|
+
): Promise<ReqRespResponse> {
|
|
649
|
+
return this.reqresp.sendRequestToPeer(peerId, subProtocol, payload, dialTimeout);
|
|
650
|
+
}
|
|
651
|
+
|
|
644
652
|
/**
|
|
645
653
|
* Get the ENR of the node
|
|
646
654
|
* @returns The ENR of the node
|
|
@@ -924,7 +932,8 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
924
932
|
const validationFunc: () => Promise<ReceivedMessageValidationResult<CheckpointAttestation>> = async () => {
|
|
925
933
|
const attestation = CheckpointAttestation.fromBuffer(payloadData);
|
|
926
934
|
const pool = this.mempools.attestationPool;
|
|
927
|
-
const
|
|
935
|
+
const validationResult = await this.validateCheckpointAttestation(source, attestation);
|
|
936
|
+
const isValid = validationResult.result === 'accept';
|
|
928
937
|
const exists = isValid && (await pool.hasCheckpointAttestation(attestation));
|
|
929
938
|
|
|
930
939
|
let canAdd = true;
|
|
@@ -943,9 +952,9 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
943
952
|
[Attributes.P2P_ID]: source.toString(),
|
|
944
953
|
});
|
|
945
954
|
|
|
946
|
-
if (
|
|
955
|
+
if (validationResult.result === 'reject') {
|
|
947
956
|
return { result: TopicValidatorResult.Reject };
|
|
948
|
-
} else if (exists) {
|
|
957
|
+
} else if (validationResult.result === 'ignore' || exists) {
|
|
949
958
|
return { result: TopicValidatorResult.Ignore, obj: attestation };
|
|
950
959
|
} else if (!canAdd) {
|
|
951
960
|
this.logger.warn(`Dropping checkpoint attestation due to per-(slot, proposalId) attestation cap`, {
|
|
@@ -986,7 +995,8 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
986
995
|
private async processBlockFromPeer(payloadData: Buffer, msgId: string, source: PeerId): Promise<void> {
|
|
987
996
|
const validationFunc: () => Promise<ReceivedMessageValidationResult<BlockProposal>> = async () => {
|
|
988
997
|
const block = BlockProposal.fromBuffer(payloadData);
|
|
989
|
-
const
|
|
998
|
+
const validationResult = await this.validateBlockProposal(source, block);
|
|
999
|
+
const isValid = validationResult.result === 'accept';
|
|
990
1000
|
const pool = this.mempools.attestationPool;
|
|
991
1001
|
|
|
992
1002
|
const exists = isValid && (await pool.hasBlockProposal(block));
|
|
@@ -1000,9 +1010,9 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
1000
1010
|
[Attributes.P2P_ID]: source.toString(),
|
|
1001
1011
|
});
|
|
1002
1012
|
|
|
1003
|
-
if (
|
|
1013
|
+
if (validationResult.result === 'reject') {
|
|
1004
1014
|
return { result: TopicValidatorResult.Reject };
|
|
1005
|
-
} else if (exists) {
|
|
1015
|
+
} else if (validationResult.result === 'ignore' || exists) {
|
|
1006
1016
|
return { result: TopicValidatorResult.Ignore, obj: block };
|
|
1007
1017
|
} else if (!canAdd) {
|
|
1008
1018
|
this.peerManager.penalizePeer(source, PeerErrorSeverity.MidToleranceError);
|
|
@@ -1082,7 +1092,8 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
1082
1092
|
// TODO(palla/mbps): This pattern is repeated across multiple message handlers, consider abstracting it.
|
|
1083
1093
|
const validationFunc: () => Promise<ReceivedMessageValidationResult<CheckpointProposal>> = async () => {
|
|
1084
1094
|
const checkpoint = CheckpointProposal.fromBuffer(payloadData);
|
|
1085
|
-
const
|
|
1095
|
+
const validationResult = await this.validateCheckpointProposal(source, checkpoint);
|
|
1096
|
+
const isValid = validationResult.result === 'accept';
|
|
1086
1097
|
const pool = this.mempools.attestationPool;
|
|
1087
1098
|
|
|
1088
1099
|
const exists = isValid && (await pool.hasCheckpointProposal(checkpoint));
|
|
@@ -1096,9 +1107,9 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
1096
1107
|
[Attributes.P2P_ID]: source.toString(),
|
|
1097
1108
|
});
|
|
1098
1109
|
|
|
1099
|
-
if (
|
|
1110
|
+
if (validationResult.result === 'reject') {
|
|
1100
1111
|
return { result: TopicValidatorResult.Reject };
|
|
1101
|
-
} else if (exists) {
|
|
1112
|
+
} else if (validationResult.result === 'ignore' || exists) {
|
|
1102
1113
|
return { result: TopicValidatorResult.Ignore, obj: checkpoint };
|
|
1103
1114
|
} else if (!canAdd) {
|
|
1104
1115
|
this.peerManager.penalizePeer(source, PeerErrorSeverity.MidToleranceError);
|
|
@@ -1203,7 +1214,7 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
1203
1214
|
* @returns True if the requested block transactions are valid, false otherwise.
|
|
1204
1215
|
*/
|
|
1205
1216
|
@trackSpan('Libp2pService.validateRequestedBlockTxs', request => ({
|
|
1206
|
-
[Attributes.
|
|
1217
|
+
[Attributes.BLOCK_ARCHIVE]: request.archiveRoot.toString(),
|
|
1207
1218
|
}))
|
|
1208
1219
|
private async validateRequestedBlockTxs(
|
|
1209
1220
|
request: BlockTxsRequest,
|
|
@@ -1213,10 +1224,10 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
1213
1224
|
const requestedTxValidator = this.createRequestedTxValidator();
|
|
1214
1225
|
|
|
1215
1226
|
try {
|
|
1216
|
-
if (!response.
|
|
1227
|
+
if (!response.archiveRoot.equals(request.archiveRoot)) {
|
|
1217
1228
|
this.peerManager.penalizePeer(peerId, PeerErrorSeverity.MidToleranceError);
|
|
1218
1229
|
throw new ValidationError(
|
|
1219
|
-
`Received block txs for unexpected
|
|
1230
|
+
`Received block txs for unexpected archive root: expected ${request.archiveRoot.toString()}, got ${response.archiveRoot.toString()}`,
|
|
1220
1231
|
);
|
|
1221
1232
|
}
|
|
1222
1233
|
|
|
@@ -1246,7 +1257,7 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
1246
1257
|
}
|
|
1247
1258
|
|
|
1248
1259
|
// Given proposal (should have locally), ensure returned txs are valid subset and match request indices
|
|
1249
|
-
const proposal = await this.mempools.attestationPool.getBlockProposal(request.
|
|
1260
|
+
const proposal = await this.mempools.attestationPool.getBlockProposal(request.archiveRoot.toString());
|
|
1250
1261
|
if (proposal) {
|
|
1251
1262
|
// Build intersected indices
|
|
1252
1263
|
const intersectIdx = request.txIndices.getTrueIndices().filter(i => response.txIndices.isSet(i));
|
|
@@ -1266,7 +1277,7 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
1266
1277
|
} else {
|
|
1267
1278
|
// No local proposal, cannot check the membership/order of the returned txs
|
|
1268
1279
|
this.logger.warn(
|
|
1269
|
-
`Block proposal not found for
|
|
1280
|
+
`Block proposal not found for archive root ${request.archiveRoot.toString()}; cannot validate membership/order of returned txs`,
|
|
1270
1281
|
);
|
|
1271
1282
|
return false;
|
|
1272
1283
|
}
|
|
@@ -1305,7 +1316,7 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
1305
1316
|
const requested = new Set(requestedTxHash.map(h => h.toString()));
|
|
1306
1317
|
const requestedTxValidator = this.createRequestedTxValidator();
|
|
1307
1318
|
|
|
1308
|
-
//TODO: (mralj) - this is somewhat naive implementation, if single tx is
|
|
1319
|
+
//TODO: (mralj) - this is somewhat naive implementation, if single tx is invalid we consider the whole response invalid.
|
|
1309
1320
|
// I think we should still extract the valid txs and return them, so that we can still use the response.
|
|
1310
1321
|
try {
|
|
1311
1322
|
await Promise.all(responseTx.map(tx => this.validateRequestedTx(tx, peerId, requestedTxValidator, requested)));
|
|
@@ -1337,7 +1348,7 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
1337
1348
|
}))
|
|
1338
1349
|
private async validateRequestedBlock(
|
|
1339
1350
|
requestedBlockNumber: Fr,
|
|
1340
|
-
responseBlock:
|
|
1351
|
+
responseBlock: L2Block,
|
|
1341
1352
|
peerId: PeerId,
|
|
1342
1353
|
): Promise<boolean> {
|
|
1343
1354
|
try {
|
|
@@ -1368,28 +1379,8 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
1368
1379
|
}
|
|
1369
1380
|
}
|
|
1370
1381
|
|
|
1371
|
-
private createRequestedTxValidator(): TxValidator {
|
|
1372
|
-
return new AggregateTxValidator(
|
|
1373
|
-
new DataTxValidator(),
|
|
1374
|
-
new SizeTxValidator(),
|
|
1375
|
-
new MetadataTxValidator({
|
|
1376
|
-
l1ChainId: new Fr(this.config.l1ChainId),
|
|
1377
|
-
rollupVersion: new Fr(this.config.rollupVersion),
|
|
1378
|
-
protocolContractsHash,
|
|
1379
|
-
vkTreeRoot: getVKTreeRoot(),
|
|
1380
|
-
}),
|
|
1381
|
-
new TxProofValidator(this.proofVerifier),
|
|
1382
|
-
);
|
|
1383
|
-
}
|
|
1384
|
-
|
|
1385
1382
|
private async validateRequestedTx(tx: Tx, peerId: PeerId, txValidator: TxValidator, requested?: Set<`0x${string}`>) {
|
|
1386
1383
|
const penalize = (severity: PeerErrorSeverity) => this.peerManager.penalizePeer(peerId, severity);
|
|
1387
|
-
|
|
1388
|
-
if (!(await tx.validateTxHash())) {
|
|
1389
|
-
penalize(PeerErrorSeverity.MidToleranceError);
|
|
1390
|
-
throw new ValidationError(`Received tx with invalid hash ${tx.getTxHash().toString()}.`);
|
|
1391
|
-
}
|
|
1392
|
-
|
|
1393
1384
|
if (requested && !requested.has(tx.getTxHash().toString())) {
|
|
1394
1385
|
penalize(PeerErrorSeverity.MidToleranceError);
|
|
1395
1386
|
throw new ValidationError(`Received tx with hash ${tx.getTxHash().toString()} that was not requested.`);
|
|
@@ -1402,6 +1393,13 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
1402
1393
|
}
|
|
1403
1394
|
}
|
|
1404
1395
|
|
|
1396
|
+
private createRequestedTxValidator(): TxValidator {
|
|
1397
|
+
return createTxReqRespValidator(this.proofVerifier, {
|
|
1398
|
+
l1ChainId: this.config.l1ChainId,
|
|
1399
|
+
rollupVersion: this.config.rollupVersion,
|
|
1400
|
+
});
|
|
1401
|
+
}
|
|
1402
|
+
|
|
1405
1403
|
@trackSpan('Libp2pService.validatePropagatedTx', tx => ({
|
|
1406
1404
|
[Attributes.TX_HASH]: tx.getTxHash().toString(),
|
|
1407
1405
|
}))
|
|
@@ -1444,6 +1442,22 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
1444
1442
|
return gasFees;
|
|
1445
1443
|
}
|
|
1446
1444
|
|
|
1445
|
+
/**
|
|
1446
|
+
* Get the BatchTxRequesterLibP2PService dependencies for creating BatchTxRequester instances
|
|
1447
|
+
*/
|
|
1448
|
+
public getBatchTxRequesterService(): BatchTxRequesterLibP2PService {
|
|
1449
|
+
return {
|
|
1450
|
+
reqResp: this.reqresp,
|
|
1451
|
+
connectionSampler: this.reqresp.getConnectionSampler(),
|
|
1452
|
+
txValidatorConfig: {
|
|
1453
|
+
l1ChainId: this.config.l1ChainId,
|
|
1454
|
+
rollupVersion: this.config.rollupVersion,
|
|
1455
|
+
proofVerifier: this.proofVerifier,
|
|
1456
|
+
},
|
|
1457
|
+
peerScoring: this.peerManager,
|
|
1458
|
+
};
|
|
1459
|
+
}
|
|
1460
|
+
|
|
1447
1461
|
public async validate(txs: Tx[]): Promise<void> {
|
|
1448
1462
|
const currentBlockNumber = await this.archiver.getBlockNumber();
|
|
1449
1463
|
|
|
@@ -1494,6 +1508,7 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
1494
1508
|
this.proofVerifier,
|
|
1495
1509
|
!this.config.disableTransactions,
|
|
1496
1510
|
allowedInSetup,
|
|
1511
|
+
this.logger.getBindings(),
|
|
1497
1512
|
);
|
|
1498
1513
|
}
|
|
1499
1514
|
|
|
@@ -1547,15 +1562,18 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
1547
1562
|
return PeerErrorSeverity.HighToleranceError;
|
|
1548
1563
|
}
|
|
1549
1564
|
|
|
1550
|
-
const snapshotValidator = new DoubleSpendTxValidator(
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1565
|
+
const snapshotValidator = new DoubleSpendTxValidator(
|
|
1566
|
+
{
|
|
1567
|
+
nullifiersExist: async (nullifiers: Buffer[]) => {
|
|
1568
|
+
const merkleTree = this.worldStateSynchronizer.getSnapshot(
|
|
1569
|
+
BlockNumber(blockNumber - this.config.doubleSpendSeverePeerPenaltyWindow),
|
|
1570
|
+
);
|
|
1571
|
+
const indices = await merkleTree.findLeafIndices(MerkleTreeId.NULLIFIER_TREE, nullifiers);
|
|
1572
|
+
return indices.map(index => index !== undefined);
|
|
1573
|
+
},
|
|
1557
1574
|
},
|
|
1558
|
-
|
|
1575
|
+
this.logger.getBindings(),
|
|
1576
|
+
);
|
|
1559
1577
|
|
|
1560
1578
|
const validSnapshot = await snapshotValidator.validateTx(tx);
|
|
1561
1579
|
if (validSnapshot.result !== 'valid') {
|
|
@@ -1576,15 +1594,18 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
1576
1594
|
[Attributes.BLOCK_ARCHIVE]: attestation.archive.toString(),
|
|
1577
1595
|
[Attributes.P2P_ID]: await attestation.p2pMessageLoggingIdentifier().then(i => i.toString()),
|
|
1578
1596
|
}))
|
|
1579
|
-
public async validateCheckpointAttestation(
|
|
1580
|
-
|
|
1581
|
-
|
|
1597
|
+
public async validateCheckpointAttestation(
|
|
1598
|
+
peerId: PeerId,
|
|
1599
|
+
attestation: CheckpointAttestation,
|
|
1600
|
+
): Promise<P2PValidationResult> {
|
|
1601
|
+
const result = await this.checkpointAttestationValidator.validate(attestation);
|
|
1602
|
+
|
|
1603
|
+
if (result.result === 'reject') {
|
|
1582
1604
|
this.logger.debug(`Penalizing peer ${peerId} for checkpoint attestation validation failure`);
|
|
1583
|
-
this.peerManager.penalizePeer(peerId, severity);
|
|
1584
|
-
return false;
|
|
1605
|
+
this.peerManager.penalizePeer(peerId, result.severity);
|
|
1585
1606
|
}
|
|
1586
1607
|
|
|
1587
|
-
return
|
|
1608
|
+
return result;
|
|
1588
1609
|
}
|
|
1589
1610
|
|
|
1590
1611
|
/**
|
|
@@ -1596,15 +1617,15 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
1596
1617
|
@trackSpan('Libp2pService.validateBlockProposal', (_peerId, block) => ({
|
|
1597
1618
|
[Attributes.SLOT_NUMBER]: block.slotNumber.toString(),
|
|
1598
1619
|
}))
|
|
1599
|
-
public async validateBlockProposal(peerId: PeerId, block: BlockProposal): Promise<
|
|
1600
|
-
const
|
|
1601
|
-
|
|
1620
|
+
public async validateBlockProposal(peerId: PeerId, block: BlockProposal): Promise<P2PValidationResult> {
|
|
1621
|
+
const result = await this.blockProposalValidator.validate(block);
|
|
1622
|
+
|
|
1623
|
+
if (result.result === 'reject') {
|
|
1602
1624
|
this.logger.debug(`Penalizing peer ${peerId} for block proposal validation failure`);
|
|
1603
|
-
this.peerManager.penalizePeer(peerId, severity);
|
|
1604
|
-
return false;
|
|
1625
|
+
this.peerManager.penalizePeer(peerId, result.severity);
|
|
1605
1626
|
}
|
|
1606
1627
|
|
|
1607
|
-
return
|
|
1628
|
+
return result;
|
|
1608
1629
|
}
|
|
1609
1630
|
|
|
1610
1631
|
/**
|
|
@@ -1616,15 +1637,18 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
1616
1637
|
@trackSpan('Libp2pService.validateCheckpointProposal', (_peerId, checkpoint) => ({
|
|
1617
1638
|
[Attributes.SLOT_NUMBER]: checkpoint.slotNumber.toString(),
|
|
1618
1639
|
}))
|
|
1619
|
-
public async validateCheckpointProposal(
|
|
1620
|
-
|
|
1621
|
-
|
|
1640
|
+
public async validateCheckpointProposal(
|
|
1641
|
+
peerId: PeerId,
|
|
1642
|
+
checkpoint: CheckpointProposal,
|
|
1643
|
+
): Promise<P2PValidationResult> {
|
|
1644
|
+
const result = await this.checkpointProposalValidator.validate(checkpoint);
|
|
1645
|
+
|
|
1646
|
+
if (result.result === 'reject') {
|
|
1622
1647
|
this.logger.debug(`Penalizing peer ${peerId} for checkpoint proposal validation failure`);
|
|
1623
|
-
this.peerManager.penalizePeer(peerId, severity);
|
|
1624
|
-
return false;
|
|
1648
|
+
this.peerManager.penalizePeer(peerId, result.severity);
|
|
1625
1649
|
}
|
|
1626
1650
|
|
|
1627
|
-
return
|
|
1651
|
+
return result;
|
|
1628
1652
|
}
|
|
1629
1653
|
|
|
1630
1654
|
public getPeerScore(peerId: PeerId): number {
|
|
@@ -6,12 +6,13 @@ import {
|
|
|
6
6
|
type TelemetryClient,
|
|
7
7
|
type Tracer,
|
|
8
8
|
type UpDownCounter,
|
|
9
|
+
createUpDownCounterWithDefault,
|
|
9
10
|
getTelemetryClient,
|
|
10
11
|
} from '@aztec/telemetry-client';
|
|
11
12
|
|
|
12
13
|
import type { PeerId } from '@libp2p/interface';
|
|
13
14
|
|
|
14
|
-
import {
|
|
15
|
+
import { GoodByeReason, prettyGoodbyeReason } from '../reqresp/protocols/index.js';
|
|
15
16
|
|
|
16
17
|
export class PeerManagerMetrics {
|
|
17
18
|
private sentGoodbyes: UpDownCounter;
|
|
@@ -31,10 +32,26 @@ export class PeerManagerMetrics {
|
|
|
31
32
|
this.tracer = telemetryClient.getTracer(name);
|
|
32
33
|
|
|
33
34
|
const meter = telemetryClient.getMeter(name);
|
|
34
|
-
|
|
35
|
-
|
|
35
|
+
const goodbyeReasonAttrs = {
|
|
36
|
+
[Attributes.P2P_GOODBYE_REASON]: [
|
|
37
|
+
prettyGoodbyeReason(GoodByeReason.SHUTDOWN),
|
|
38
|
+
prettyGoodbyeReason(GoodByeReason.MAX_PEERS),
|
|
39
|
+
prettyGoodbyeReason(GoodByeReason.LOW_SCORE),
|
|
40
|
+
prettyGoodbyeReason(GoodByeReason.BANNED),
|
|
41
|
+
prettyGoodbyeReason(GoodByeReason.WRONG_NETWORK),
|
|
42
|
+
prettyGoodbyeReason(GoodByeReason.UNKNOWN),
|
|
43
|
+
],
|
|
44
|
+
};
|
|
45
|
+
this.sentGoodbyes = createUpDownCounterWithDefault(meter, Metrics.PEER_MANAGER_GOODBYES_SENT, goodbyeReasonAttrs);
|
|
46
|
+
this.receivedGoodbyes = createUpDownCounterWithDefault(
|
|
47
|
+
meter,
|
|
48
|
+
Metrics.PEER_MANAGER_GOODBYES_RECEIVED,
|
|
49
|
+
goodbyeReasonAttrs,
|
|
50
|
+
);
|
|
36
51
|
this.peerCount = meter.createGauge(Metrics.PEER_MANAGER_PEER_COUNT);
|
|
37
|
-
this.lowScoreDisconnects = meter
|
|
52
|
+
this.lowScoreDisconnects = createUpDownCounterWithDefault(meter, Metrics.PEER_MANAGER_LOW_SCORE_DISCONNECTS, {
|
|
53
|
+
[Attributes.P2P_PEER_SCORE_STATE]: ['Banned', 'Disconnect'],
|
|
54
|
+
});
|
|
38
55
|
this.peerConnectionDuration = meter.createHistogram(Metrics.PEER_MANAGER_PEER_CONNECTION_DURATION);
|
|
39
56
|
}
|
|
40
57
|
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
Metrics,
|
|
7
7
|
type TelemetryClient,
|
|
8
8
|
type UpDownCounter,
|
|
9
|
+
createUpDownCounterWithDefault,
|
|
9
10
|
getTelemetryClient,
|
|
10
11
|
} from '@aztec/telemetry-client';
|
|
11
12
|
|
|
@@ -52,7 +53,9 @@ export class PeerScoring {
|
|
|
52
53
|
|
|
53
54
|
const meter = telemetry.getMeter('PeerScoring');
|
|
54
55
|
|
|
55
|
-
this.peerStateCounter = meter
|
|
56
|
+
this.peerStateCounter = createUpDownCounterWithDefault(meter, Metrics.P2P_PEER_STATE_COUNT, {
|
|
57
|
+
[Attributes.P2P_PEER_SCORE_STATE]: ['Healthy', 'Disconnect', 'Banned'],
|
|
58
|
+
});
|
|
56
59
|
}
|
|
57
60
|
|
|
58
61
|
public penalizePeer(peerId: PeerId, penalty: PeerErrorSeverity) {
|