@aztec/p2p 3.0.0-nightly.20251125 → 3.0.0-nightly.20251127
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/config.d.ts +3 -0
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +6 -1
- package/dest/mem_pools/instrumentation.d.ts +2 -0
- package/dest/mem_pools/instrumentation.d.ts.map +1 -1
- package/dest/mem_pools/instrumentation.js +11 -2
- package/dest/services/libp2p/instrumentation.d.ts +2 -0
- package/dest/services/libp2p/instrumentation.d.ts.map +1 -1
- package/dest/services/libp2p/instrumentation.js +9 -2
- package/dest/services/libp2p/libp2p_service.d.ts +0 -1
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +23 -17
- package/dest/services/peer-manager/metrics.d.ts +2 -0
- package/dest/services/peer-manager/metrics.d.ts.map +1 -1
- package/dest/services/peer-manager/metrics.js +11 -0
- package/dest/services/peer-manager/peer_manager.d.ts.map +1 -1
- package/dest/services/peer-manager/peer_manager.js +2 -0
- package/dest/services/peer-manager/peer_scoring.d.ts +6 -1
- package/dest/services/peer-manager/peer_scoring.d.ts.map +1 -1
- package/dest/services/peer-manager/peer_scoring.js +40 -2
- package/package.json +15 -15
- package/src/config.ts +9 -1
- package/src/mem_pools/instrumentation.ts +13 -0
- package/src/services/libp2p/instrumentation.ts +10 -1
- package/src/services/libp2p/libp2p_service.ts +25 -22
- package/src/services/peer-manager/metrics.ts +10 -0
- package/src/services/peer-manager/peer_manager.ts +2 -0
- package/src/services/peer-manager/peer_scoring.ts +46 -3
package/dest/config.d.ts
CHANGED
|
@@ -103,6 +103,8 @@ export interface P2PConfig extends P2PReqRespConfig, ChainConfig, TxCollectionCo
|
|
|
103
103
|
dropTransactionsProbability: number;
|
|
104
104
|
/** Whether to delete transactions from the pool after a reorg instead of moving them back to pending. */
|
|
105
105
|
txPoolDeleteTxsAfterReorg: boolean;
|
|
106
|
+
/** Alters the format of p2p messages to include things like broadcast timestamp FOR TESTING ONLY */
|
|
107
|
+
debugP2PInstrumentMessages: boolean;
|
|
106
108
|
/** Whether to run in fisherman mode: validates all proposals and attestations but does not broadcast attestations or participate in consensus */
|
|
107
109
|
fishermanMode: boolean;
|
|
108
110
|
}
|
|
@@ -186,6 +188,7 @@ export declare const bootnodeConfigMappings: ConfigMappingsType<Pick<{
|
|
|
186
188
|
dropTransactions: unknown;
|
|
187
189
|
dropTransactionsProbability: unknown;
|
|
188
190
|
txPoolDeleteTxsAfterReorg: unknown;
|
|
191
|
+
debugP2PInstrumentMessages: unknown;
|
|
189
192
|
fishermanMode: unknown;
|
|
190
193
|
}, "p2pPort" | "p2pBroadcastPort" | "p2pIp" | "listenAddress" | "peerIdPrivateKey" | "peerIdPrivateKeyPath" | "bootstrapNodes" | "queryForIp" | "l1ChainId" | "dataDirectory" | "dataStoreMapSizeKb">>;
|
|
191
194
|
/**
|
package/dest/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,kBAAkB,EACvB,WAAW,EAQZ,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,KAAK,eAAe,EAAsB,MAAM,wBAAwB,CAAC;AAGlF,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,WAAW,EAAuB,MAAM,sBAAsB,CAAC;AAElG,OAAO,EAAE,KAAK,gBAAgB,EAA4B,MAAM,8BAA8B,CAAC;AAC/F,OAAO,EAAE,KAAK,kBAAkB,EAA8B,MAAM,oCAAoC,CAAC;AAEzG;;GAEG;AACH,MAAM,WAAW,SAAU,SAAQ,gBAAgB,EAAE,WAAW,EAAE,kBAAkB;IAClF,oEAAoE;IACpE,UAAU,EAAE,OAAO,CAAC;IAEpB,yDAAyD;IACzD,oBAAoB,EAAE,MAAM,CAAC;IAE7B,uDAAuD;IACvD,qBAAqB,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CHANGED
|
@@ -242,7 +242,7 @@ export const p2pConfigMappings = {
|
|
|
242
242
|
},
|
|
243
243
|
dropTransactionsProbability: {
|
|
244
244
|
env: 'P2P_DROP_TX_CHANCE',
|
|
245
|
-
description: 'The probability that a transaction is discarded. - For testing purposes only',
|
|
245
|
+
description: 'The probability that a transaction is discarded (0 - 1). - For testing purposes only',
|
|
246
246
|
...floatConfigHelper(0)
|
|
247
247
|
},
|
|
248
248
|
disableTransactions: {
|
|
@@ -255,6 +255,11 @@ export const p2pConfigMappings = {
|
|
|
255
255
|
description: 'Whether to delete transactions from the pool after a reorg instead of moving them back to pending.',
|
|
256
256
|
...booleanConfigHelper(false)
|
|
257
257
|
},
|
|
258
|
+
debugP2PInstrumentMessages: {
|
|
259
|
+
env: 'DEBUG_P2P_INSTRUMENT_MESSAGES',
|
|
260
|
+
description: 'Alters the format of p2p messages to include things like broadcast timestamp FOR TESTING ONLY',
|
|
261
|
+
...booleanConfigHelper(false)
|
|
262
|
+
},
|
|
258
263
|
fishermanMode: {
|
|
259
264
|
env: 'FISHERMAN_MODE',
|
|
260
265
|
description: 'Whether to run in fisherman mode: validates all proposals and attestations but does not broadcast attestations or participate in consensus.',
|
|
@@ -14,6 +14,7 @@ export declare class PoolInstrumentation<PoolObject extends Gossipable> {
|
|
|
14
14
|
private poolStats;
|
|
15
15
|
/** The number of txs in the mempool */
|
|
16
16
|
private objectsInMempool;
|
|
17
|
+
private addObjectCounter;
|
|
17
18
|
/** Tracks tx size */
|
|
18
19
|
private objectSize;
|
|
19
20
|
private dbMetrics;
|
|
@@ -21,6 +22,7 @@ export declare class PoolInstrumentation<PoolObject extends Gossipable> {
|
|
|
21
22
|
private meter;
|
|
22
23
|
constructor(telemetry: TelemetryClient, name: PoolName, poolStats: PoolStatsCallback, dbStats?: LmdbStatsCallback);
|
|
23
24
|
recordSize(poolObject: PoolObject): void;
|
|
25
|
+
incrementAddedObjects(count: number): void;
|
|
24
26
|
private observeStats;
|
|
25
27
|
}
|
|
26
28
|
//# sourceMappingURL=instrumentation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instrumentation.d.ts","sourceRoot":"","sources":["../../src/mem_pools/instrumentation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAKL,KAAK,iBAAiB,EAKtB,KAAK,eAAe,
|
|
1
|
+
{"version":3,"file":"instrumentation.d.ts","sourceRoot":"","sources":["../../src/mem_pools/instrumentation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAKL,KAAK,iBAAiB,EAKtB,KAAK,eAAe,EAErB,MAAM,yBAAyB,CAAC;AAEjC,oBAAY,QAAQ;IAClB,OAAO,WAAW;IAClB,gBAAgB,oBAAoB;CACrC;AA+BD,MAAM,MAAM,iBAAiB,GAAG,MAAM,OAAO,CAAC;IAC5C,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC5C,CAAC,CAAC;AAEH;;GAEG;AACH,qBAAa,mBAAmB,CAAC,UAAU,SAAS,UAAU;IAe1D,OAAO,CAAC,SAAS;IAdnB,uCAAuC;IACvC,OAAO,CAAC,gBAAgB,CAAkB;IAC1C,OAAO,CAAC,gBAAgB,CAAgB;IACxC,qBAAqB;IACrB,OAAO,CAAC,UAAU,CAAY;IAE9B,OAAO,CAAC,SAAS,CAAc;IAE/B,OAAO,CAAC,iBAAiB,CAAC;IAC1B,OAAO,CAAC,KAAK,CAAQ;gBAGnB,SAAS,EAAE,eAAe,EAC1B,IAAI,EAAE,QAAQ,EACN,SAAS,EAAE,iBAAiB,EACpC,OAAO,CAAC,EAAE,iBAAiB;IA+BtB,UAAU,CAAC,UAAU,EAAE,UAAU;IAIjC,qBAAqB,CAAC,KAAK,EAAE,MAAM;IAI1C,OAAO,CAAC,YAAY,CAYlB;CACH"}
|
|
@@ -12,12 +12,14 @@ export var PoolName = /*#__PURE__*/ function(PoolName) {
|
|
|
12
12
|
if (name === "TxPool") {
|
|
13
13
|
return {
|
|
14
14
|
objectInMempool: Metrics.MEMPOOL_TX_COUNT,
|
|
15
|
-
objectSize: Metrics.MEMPOOL_TX_SIZE
|
|
15
|
+
objectSize: Metrics.MEMPOOL_TX_SIZE,
|
|
16
|
+
itemsAdded: Metrics.MEMPOOL_TX_ADDED_COUNT
|
|
16
17
|
};
|
|
17
18
|
} else if (name === "AttestationPool") {
|
|
18
19
|
return {
|
|
19
20
|
objectInMempool: Metrics.MEMPOOL_ATTESTATIONS_COUNT,
|
|
20
|
-
objectSize: Metrics.MEMPOOL_ATTESTATIONS_SIZE
|
|
21
|
+
objectSize: Metrics.MEMPOOL_ATTESTATIONS_SIZE,
|
|
22
|
+
itemsAdded: Metrics.MEMPOOL_ATTESTATIONS_ADDED_COUNT
|
|
21
23
|
};
|
|
22
24
|
}
|
|
23
25
|
throw new Error('Invalid pool type');
|
|
@@ -27,6 +29,7 @@ export var PoolName = /*#__PURE__*/ function(PoolName) {
|
|
|
27
29
|
*/ export class PoolInstrumentation {
|
|
28
30
|
poolStats;
|
|
29
31
|
/** The number of txs in the mempool */ objectsInMempool;
|
|
32
|
+
addObjectCounter;
|
|
30
33
|
/** Tracks tx size */ objectSize;
|
|
31
34
|
dbMetrics;
|
|
32
35
|
defaultAttributes;
|
|
@@ -61,6 +64,9 @@ export var PoolName = /*#__PURE__*/ function(PoolName) {
|
|
|
61
64
|
this.dbMetrics = new LmdbMetrics(this.meter, {
|
|
62
65
|
[Attributes.DB_DATA_TYPE]: 'tx-pool'
|
|
63
66
|
}, dbStats);
|
|
67
|
+
this.addObjectCounter = this.meter.createUpDownCounter(metricsLabels.itemsAdded, {
|
|
68
|
+
description: 'The number of transactions added to the mempool'
|
|
69
|
+
});
|
|
64
70
|
this.meter.addBatchObservableCallback(this.observeStats, [
|
|
65
71
|
this.objectsInMempool
|
|
66
72
|
]);
|
|
@@ -68,5 +74,8 @@ export var PoolName = /*#__PURE__*/ function(PoolName) {
|
|
|
68
74
|
recordSize(poolObject) {
|
|
69
75
|
this.objectSize.record(poolObject.getSize());
|
|
70
76
|
}
|
|
77
|
+
incrementAddedObjects(count) {
|
|
78
|
+
this.addObjectCounter.add(count);
|
|
79
|
+
}
|
|
71
80
|
observeStats;
|
|
72
81
|
}
|
|
@@ -5,12 +5,14 @@ export declare class P2PInstrumentation {
|
|
|
5
5
|
private messageValidationDuration;
|
|
6
6
|
private messagePrevalidationCount;
|
|
7
7
|
private messageLatency;
|
|
8
|
+
private txReceivedCount;
|
|
8
9
|
private aggLatencyHisto;
|
|
9
10
|
private aggValidationHisto;
|
|
10
11
|
private aggLatencyMetrics;
|
|
11
12
|
private aggValidationMetrics;
|
|
12
13
|
constructor(client: TelemetryClient, name: string);
|
|
13
14
|
recordMessageValidation(topicName: TopicType, timerOrMs: Timer | number): void;
|
|
15
|
+
incrementTxReceived(count: number): void;
|
|
14
16
|
incMessagePrevalidationStatus(passed: boolean, topicName: TopicType | undefined): void;
|
|
15
17
|
recordMessageLatency(topicName: TopicType, timerOrMs: Timer | number): void;
|
|
16
18
|
private aggregate;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instrumentation.d.ts","sourceRoot":"","sources":["../../../src/services/libp2p/instrumentation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAML,KAAK,eAAe,EAGrB,MAAM,yBAAyB,CAAC;AAIjC,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,yBAAyB,CAAY;IAC7C,OAAO,CAAC,yBAAyB,CAAgB;IACjD,OAAO,CAAC,cAAc,CAAY;
|
|
1
|
+
{"version":3,"file":"instrumentation.d.ts","sourceRoot":"","sources":["../../../src/services/libp2p/instrumentation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAML,KAAK,eAAe,EAGrB,MAAM,yBAAyB,CAAC;AAIjC,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,yBAAyB,CAAY;IAC7C,OAAO,CAAC,yBAAyB,CAAgB;IACjD,OAAO,CAAC,cAAc,CAAY;IAClC,OAAO,CAAC,eAAe,CAAgB;IAEvC,OAAO,CAAC,eAAe,CAA6C;IACpE,OAAO,CAAC,kBAAkB,CAA6C;IAEvE,OAAO,CAAC,iBAAiB,CAAiE;IAC1F,OAAO,CAAC,oBAAoB,CAAiE;gBAEjF,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM;IAsF1C,uBAAuB,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,GAAG,MAAM;IAavE,mBAAmB,CAAC,KAAK,EAAE,MAAM;IAIjC,6BAA6B,CAAC,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,GAAG,SAAS;IAI/E,oBAAoB,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,GAAG,MAAM;IAa3E,OAAO,CAAC,SAAS,CAkBf;CACH"}
|
|
@@ -5,6 +5,7 @@ export class P2PInstrumentation {
|
|
|
5
5
|
messageValidationDuration;
|
|
6
6
|
messagePrevalidationCount;
|
|
7
7
|
messageLatency;
|
|
8
|
+
txReceivedCount;
|
|
8
9
|
aggLatencyHisto = new Map();
|
|
9
10
|
aggValidationHisto = new Map();
|
|
10
11
|
aggLatencyMetrics;
|
|
@@ -25,6 +26,9 @@ export class P2PInstrumentation {
|
|
|
25
26
|
description: 'P2P message latency',
|
|
26
27
|
valueType: ValueType.INT
|
|
27
28
|
});
|
|
29
|
+
this.txReceivedCount = meter.createUpDownCounter(Metrics.P2P_GOSSIP_TX_RECEIVED_COUNT, {
|
|
30
|
+
description: 'The number of txs received from the p2p network'
|
|
31
|
+
});
|
|
28
32
|
this.aggLatencyMetrics = {
|
|
29
33
|
avg: meter.createObservableGauge(Metrics.P2P_GOSSIP_AGG_MESSAGE_LATENCY_AVG, {
|
|
30
34
|
valueType: ValueType.DOUBLE,
|
|
@@ -99,6 +103,9 @@ export class P2PInstrumentation {
|
|
|
99
103
|
}
|
|
100
104
|
validationHistogram.record(Math.max(ms, 1));
|
|
101
105
|
}
|
|
106
|
+
incrementTxReceived(count) {
|
|
107
|
+
this.txReceivedCount.add(count);
|
|
108
|
+
}
|
|
102
109
|
incMessagePrevalidationStatus(passed, topicName) {
|
|
103
110
|
this.messagePrevalidationCount.add(1, {
|
|
104
111
|
[Attributes.TOPIC_NAME]: topicName,
|
|
@@ -114,8 +121,8 @@ export class P2PInstrumentation {
|
|
|
114
121
|
if (!latencyHistogram) {
|
|
115
122
|
latencyHistogram = createHistogram({
|
|
116
123
|
min: 1,
|
|
117
|
-
max:
|
|
118
|
-
}); //
|
|
124
|
+
max: 60 * 1000
|
|
125
|
+
}); // Max: 1 minute
|
|
119
126
|
this.aggLatencyHisto.set(topicName, latencyHistogram);
|
|
120
127
|
}
|
|
121
128
|
latencyHistogram.record(Math.max(ms, 1));
|
|
@@ -39,7 +39,6 @@ export declare class LibP2PService<T extends P2PClientType = P2PClientType.Full>
|
|
|
39
39
|
private epochCache;
|
|
40
40
|
private proofVerifier;
|
|
41
41
|
private worldStateSynchronizer;
|
|
42
|
-
private jobQueue;
|
|
43
42
|
private discoveryRunningPromise?;
|
|
44
43
|
private msgIdSeenValidators;
|
|
45
44
|
private attestationValidator;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"libp2p_service.d.ts","sourceRoot":"","sources":["../../../src/services/libp2p/libp2p_service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAG9D,OAAO,EAAE,KAAK,MAAM,EAA6C,MAA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B;YA+D1B,oBAAoB;YAwDpB,yBAAyB;IA8CvC;;;OAGG;YAMW,oBAAoB;IAIlC;;;OAGG;IACU,SAAS,CAAC,CAAC,SAAS,UAAU,EAAE,OAAO,EAAE,CAAC;IAQvD;;;;;;OAMG;YAIW,yBAAyB;IA+EvC;;;;;;;;;;;;;OAaG;YAIW,oBAAoB;IAoBlC;;;;;;;;;;OAUG;YAIW,sBAAsB;IAiCpC,OAAO,CAAC,0BAA0B;YAapB,mBAAmB;YAuBnB,oBAAoB;YA4BpB,UAAU;IAWX,QAAQ,CAAC,GAAG,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAmB/C;;;;;;;;;OASG;YACW,uBAAuB;IAwBrC;;;;;OAKG;YACW,cAAc;IA4B5B;;;;;;;;;;OAUG;YACW,wBAAwB;IAuBtC;;;;;OAKG;IAMU,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC;IAUjG;;;;;OAKG;IAIU,qBAAqB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC;IAWnF,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;IAIpC,yBAAyB,CAAC,WAAW,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;YAIpF,WAAW;YAcX,UAAU;CAYzB"}
|
|
@@ -7,7 +7,6 @@ function _ts_decorate(decorators, target, key, desc) {
|
|
|
7
7
|
import { randomInt } from '@aztec/foundation/crypto';
|
|
8
8
|
import { Fr } from '@aztec/foundation/fields';
|
|
9
9
|
import { createLibp2pComponentLogger, createLogger } from '@aztec/foundation/log';
|
|
10
|
-
import { SerialQueue } from '@aztec/foundation/queue';
|
|
11
10
|
import { RunningPromise } from '@aztec/foundation/running-promise';
|
|
12
11
|
import { Timer } from '@aztec/foundation/timer';
|
|
13
12
|
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
@@ -65,7 +64,6 @@ import { P2PInstrumentation } from './instrumentation.js';
|
|
|
65
64
|
epochCache;
|
|
66
65
|
proofVerifier;
|
|
67
66
|
worldStateSynchronizer;
|
|
68
|
-
jobQueue;
|
|
69
67
|
discoveryRunningPromise;
|
|
70
68
|
msgIdSeenValidators;
|
|
71
69
|
// Message validators
|
|
@@ -83,7 +81,7 @@ import { P2PInstrumentation } from './instrumentation.js';
|
|
|
83
81
|
instrumentation;
|
|
84
82
|
logger;
|
|
85
83
|
constructor(clientType, config, node, peerDiscoveryService, reqresp, peerManager, mempools, archiver, epochCache, proofVerifier, worldStateSynchronizer, telemetry, logger = createLogger('p2p:libp2p_service')){
|
|
86
|
-
super(telemetry, 'LibP2PService'), this.clientType = clientType, this.config = config, this.node = node, this.peerDiscoveryService = peerDiscoveryService, this.reqresp = reqresp, this.peerManager = peerManager, this.mempools = mempools, this.archiver = archiver, this.epochCache = epochCache, this.proofVerifier = proofVerifier, this.worldStateSynchronizer = worldStateSynchronizer, this.
|
|
84
|
+
super(telemetry, 'LibP2PService'), this.clientType = clientType, this.config = config, this.node = node, this.peerDiscoveryService = peerDiscoveryService, this.reqresp = reqresp, this.peerManager = peerManager, this.mempools = mempools, this.archiver = archiver, this.epochCache = epochCache, this.proofVerifier = proofVerifier, this.worldStateSynchronizer = worldStateSynchronizer, this.msgIdSeenValidators = {}, this.protocolVersion = '', this.topicStrings = {};
|
|
87
85
|
// Create child logger with fisherman prefix if in fisherman mode
|
|
88
86
|
this.logger = config.fishermanMode ? logger.createChild('[FISHERMAN]') : logger;
|
|
89
87
|
this.instrumentation = new P2PInstrumentation(telemetry, 'LibP2PService');
|
|
@@ -282,7 +280,7 @@ import { P2PInstrumentation } from './instrumentation.js';
|
|
|
282
280
|
},
|
|
283
281
|
logger: createLibp2pComponentLogger(logger.module)
|
|
284
282
|
});
|
|
285
|
-
const peerScoring = new PeerScoring(config);
|
|
283
|
+
const peerScoring = new PeerScoring(config, telemetry);
|
|
286
284
|
const reqresp = new ReqResp(config, node, peerScoring, createLogger(`${logger.module}:reqresp`));
|
|
287
285
|
const peerManager = new PeerManager(node, peerDiscoveryService, config, telemetry, createLogger(`${logger.module}:peer_manager`), peerScoring, reqresp, worldStateSynchronizer, protocolVersion, epochCache);
|
|
288
286
|
// Update gossipsub score params
|
|
@@ -304,8 +302,6 @@ import { P2PInstrumentation } from './instrumentation.js';
|
|
|
304
302
|
throw new Error('Announce address not provided.');
|
|
305
303
|
}
|
|
306
304
|
const announceTcpMultiaddr = convertToMultiaddr(p2pIp, p2pPort, 'tcp');
|
|
307
|
-
// Start job queue, peer discovery service and libp2p node
|
|
308
|
-
this.jobQueue.start();
|
|
309
305
|
await this.peerManager.initializePeers();
|
|
310
306
|
if (!this.config.p2pDiscoveryDisabled) {
|
|
311
307
|
await this.peerDiscoveryService.start();
|
|
@@ -336,8 +332,10 @@ import { P2PInstrumentation } from './instrumentation.js';
|
|
|
336
332
|
}
|
|
337
333
|
// add GossipSub listener
|
|
338
334
|
this.node.services.pubsub.addEventListener(GossipSubEvent.MESSAGE, this.gossipSubEventHandler);
|
|
339
|
-
// Start running promise for peer discovery
|
|
340
|
-
this.discoveryRunningPromise = new RunningPromise(()=>
|
|
335
|
+
// Start running promise for peer discovery and metrics collection
|
|
336
|
+
this.discoveryRunningPromise = new RunningPromise(async ()=>{
|
|
337
|
+
await this.peerManager.heartbeat();
|
|
338
|
+
}, this.logger, this.config.peerCheckIntervalMS);
|
|
341
339
|
this.discoveryRunningPromise.start();
|
|
342
340
|
// Define the sub protocol validators - This is done within this start() method to gain a callback to the existing validateTx function
|
|
343
341
|
const reqrespSubProtocolValidators = {
|
|
@@ -363,8 +361,6 @@ import { P2PInstrumentation } from './instrumentation.js';
|
|
|
363
361
|
// Stop peer manager
|
|
364
362
|
this.logger.debug('Stopping peer manager...');
|
|
365
363
|
await this.peerManager.stop();
|
|
366
|
-
this.logger.debug('Stopping job queue...');
|
|
367
|
-
await this.jobQueue.end();
|
|
368
364
|
this.logger.debug('Stopping running promise...');
|
|
369
365
|
await this.discoveryRunningPromise?.stop();
|
|
370
366
|
this.logger.debug('Stopping peer discovery service...');
|
|
@@ -430,7 +426,7 @@ import { P2PInstrumentation } from './instrumentation.js';
|
|
|
430
426
|
if (!this.node.services.pubsub) {
|
|
431
427
|
throw new Error('Pubsub service not available.');
|
|
432
428
|
}
|
|
433
|
-
const p2pMessage = P2PMessage.fromGossipable(message);
|
|
429
|
+
const p2pMessage = P2PMessage.fromGossipable(message, this.config.debugP2PInstrumentMessages);
|
|
434
430
|
const result = await this.node.services.pubsub.publish(topic, p2pMessage.toMessageData());
|
|
435
431
|
return result.recipients.length;
|
|
436
432
|
}
|
|
@@ -477,7 +473,7 @@ import { P2PInstrumentation } from './instrumentation.js';
|
|
|
477
473
|
* @returns The deserialized P2PMessage or undefined if deserialization fails.
|
|
478
474
|
*/ safelyDeserializeP2PMessage(msgId, source, data) {
|
|
479
475
|
try {
|
|
480
|
-
return P2PMessage.fromMessageData(Buffer.from(data));
|
|
476
|
+
return P2PMessage.fromMessageData(Buffer.from(data), this.config.debugP2PInstrumentMessages);
|
|
481
477
|
} catch (err) {
|
|
482
478
|
this.logger.error(`Error deserializing P2PMessage`, err, {
|
|
483
479
|
msgId,
|
|
@@ -493,6 +489,8 @@ import { P2PInstrumentation } from './instrumentation.js';
|
|
|
493
489
|
* @param topic - The message's topic.
|
|
494
490
|
* @param data - The message data
|
|
495
491
|
*/ async handleNewGossipMessage(msg, msgId, source) {
|
|
492
|
+
const msgReceivedTime = Date.now();
|
|
493
|
+
let topicType;
|
|
496
494
|
const p2pMessage = this.safelyDeserializeP2PMessage(msgId, source, msg.data);
|
|
497
495
|
if (!p2pMessage) {
|
|
498
496
|
return;
|
|
@@ -502,14 +500,23 @@ import { P2PInstrumentation } from './instrumentation.js';
|
|
|
502
500
|
return;
|
|
503
501
|
}
|
|
504
502
|
if (msg.topic === this.topicStrings[TopicType.tx]) {
|
|
503
|
+
topicType = TopicType.tx;
|
|
505
504
|
await this.handleGossipedTx(p2pMessage.payload, msgId, source);
|
|
506
505
|
}
|
|
507
|
-
if (msg.topic === this.topicStrings[TopicType.block_attestation]
|
|
508
|
-
|
|
506
|
+
if (msg.topic === this.topicStrings[TopicType.block_attestation]) {
|
|
507
|
+
topicType = TopicType.block_attestation;
|
|
508
|
+
if (this.clientType === P2PClientType.Full) {
|
|
509
|
+
await this.processAttestationFromPeer(p2pMessage.payload, msgId, source);
|
|
510
|
+
}
|
|
509
511
|
}
|
|
510
512
|
if (msg.topic === this.topicStrings[TopicType.block_proposal]) {
|
|
513
|
+
topicType = TopicType.block_proposal;
|
|
511
514
|
await this.processBlockFromPeer(p2pMessage.payload, msgId, source);
|
|
512
515
|
}
|
|
516
|
+
if (p2pMessage.timestamp !== undefined && topicType !== undefined) {
|
|
517
|
+
const latency = msgReceivedTime - p2pMessage.timestamp.getTime();
|
|
518
|
+
this.instrumentation.recordMessageLatency(topicType, latency);
|
|
519
|
+
}
|
|
513
520
|
return;
|
|
514
521
|
}
|
|
515
522
|
async validateReceivedMessage(validationFunc, msgId, source, topicType) {
|
|
@@ -573,6 +580,7 @@ import { P2PInstrumentation } from './instrumentation.js';
|
|
|
573
580
|
this.logger.warn(`Intentionally dropping tx ${txHashString} (probability rule)`);
|
|
574
581
|
return;
|
|
575
582
|
}
|
|
583
|
+
this.instrumentation.incrementTxReceived(1);
|
|
576
584
|
await this.mempools.txPool.addTxs([
|
|
577
585
|
tx
|
|
578
586
|
]);
|
|
@@ -748,9 +756,7 @@ import { P2PInstrumentation } from './instrumentation.js';
|
|
|
748
756
|
this.logger.trace(`Message ${p2pMessageIdentifier} queued`, {
|
|
749
757
|
p2pMessageIdentifier
|
|
750
758
|
});
|
|
751
|
-
void this.
|
|
752
|
-
await this.sendToPeers(message);
|
|
753
|
-
}).catch((error)=>{
|
|
759
|
+
void this.sendToPeers(message).catch((error)=>{
|
|
754
760
|
this.logger.error(`Error propagating message ${p2pMessageIdentifier}`, {
|
|
755
761
|
error
|
|
756
762
|
});
|
|
@@ -5,10 +5,12 @@ export declare class PeerManagerMetrics {
|
|
|
5
5
|
private sentGoodbyes;
|
|
6
6
|
private receivedGoodbyes;
|
|
7
7
|
private peerCount;
|
|
8
|
+
private lowScoreDisconnects;
|
|
8
9
|
readonly tracer: Tracer;
|
|
9
10
|
constructor(telemetryClient?: TelemetryClient, name?: string);
|
|
10
11
|
recordGoodbyeSent(reason: GoodByeReason): void;
|
|
11
12
|
recordGoodbyeReceived(reason: GoodByeReason): void;
|
|
12
13
|
recordPeerCount(count: number): void;
|
|
14
|
+
recordLowScoreDisconnect(scoreState: 'Banned' | 'Disconnect'): void;
|
|
13
15
|
}
|
|
14
16
|
//# sourceMappingURL=metrics.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metrics.d.ts","sourceRoot":"","sources":["../../../src/services/peer-manager/metrics.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,eAAe,EACpB,KAAK,MAAM,EAIZ,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,KAAK,aAAa,EAAuB,MAAM,+BAA+B,CAAC;AAExF,qBAAa,kBAAkB;
|
|
1
|
+
{"version":3,"file":"metrics.d.ts","sourceRoot":"","sources":["../../../src/services/peer-manager/metrics.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,eAAe,EACpB,KAAK,MAAM,EAIZ,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,KAAK,aAAa,EAAuB,MAAM,+BAA+B,CAAC;AAExF,qBAAa,kBAAkB;aASX,eAAe,EAAE,eAAe;IARlD,OAAO,CAAC,YAAY,CAAgB;IACpC,OAAO,CAAC,gBAAgB,CAAgB;IACxC,OAAO,CAAC,SAAS,CAAQ;IACzB,OAAO,CAAC,mBAAmB,CAAgB;IAE3C,SAAgB,MAAM,EAAE,MAAM,CAAC;gBAGb,eAAe,GAAE,eAAsC,EACvE,IAAI,SAAgB;IA2Bf,iBAAiB,CAAC,MAAM,EAAE,aAAa;IAIvC,qBAAqB,CAAC,MAAM,EAAE,aAAa;IAI3C,eAAe,CAAC,KAAK,EAAE,MAAM;IAI7B,wBAAwB,CAAC,UAAU,EAAE,QAAQ,GAAG,YAAY;CAGpE"}
|
|
@@ -5,6 +5,7 @@ export class PeerManagerMetrics {
|
|
|
5
5
|
sentGoodbyes;
|
|
6
6
|
receivedGoodbyes;
|
|
7
7
|
peerCount;
|
|
8
|
+
lowScoreDisconnects;
|
|
8
9
|
tracer;
|
|
9
10
|
constructor(telemetryClient = getTelemetryClient(), name = 'PeerManager'){
|
|
10
11
|
this.telemetryClient = telemetryClient;
|
|
@@ -25,6 +26,11 @@ export class PeerManagerMetrics {
|
|
|
25
26
|
unit: 'peers',
|
|
26
27
|
valueType: ValueType.INT
|
|
27
28
|
});
|
|
29
|
+
this.lowScoreDisconnects = meter.createUpDownCounter(Metrics.PEER_MANAGER_LOW_SCORE_DISCONNECTS, {
|
|
30
|
+
description: 'Number of peers disconnected due to low score',
|
|
31
|
+
unit: 'peers',
|
|
32
|
+
valueType: ValueType.INT
|
|
33
|
+
});
|
|
28
34
|
}
|
|
29
35
|
recordGoodbyeSent(reason) {
|
|
30
36
|
this.sentGoodbyes.add(1, {
|
|
@@ -39,4 +45,9 @@ export class PeerManagerMetrics {
|
|
|
39
45
|
recordPeerCount(count) {
|
|
40
46
|
this.peerCount.record(count);
|
|
41
47
|
}
|
|
48
|
+
recordLowScoreDisconnect(scoreState) {
|
|
49
|
+
this.lowScoreDisconnects.add(1, {
|
|
50
|
+
[Attributes.P2P_PEER_SCORE_STATE]: scoreState
|
|
51
|
+
});
|
|
52
|
+
}
|
|
42
53
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"peer_manager.d.ts","sourceRoot":"","sources":["../../../src/services/peer-manager/peer_manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,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AAE,aAAa;IAQrD,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB;IAIvD,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;IAIpC,sBAAsB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;IAK/C,QAAQ,CAAC,cAAc,UAAQ,GAAG,QAAQ,EAAE;IAiC5C,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;IAiB5C,sBAAsB,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO;IAe3D;;OAEG;IACH,OAAO,CAAC,QAAQ;IAkEhB,OAAO,CAAC,oBAAoB;IAI5B,OAAO,CAAC,qBAAqB;IAI7B,OAAO,CAAC,mBAAmB;IAsB3B;;;;;OAKG;IACH,OAAO,CAAC,eAAe;YAyBT,wBAAwB;IAgCtC,OAAO,CAAC,qBAAqB;IAM7B;;;;;OAKG;YACW,cAAc;IAc5B;;;OAGG;YACW,oBAAoB;YAoEpB,QAAQ;IA2BtB,OAAO,CAAC,cAAc;IAWtB,OAAO,CAAC,gBAAgB;YAsBV,mBAAmB;IAKjC;;;;;;;;;SASK;YACS,uBAAuB;IAsCrC;;;;SAIK;YACS,qBAAqB;IAyFnC,OAAO,CAAC,uBAAuB;IA0B/B,OAAO,CAAC,wBAAwB;IAUhC;;;OAGG;IACU,IAAI;IAajB,OAAO,CAAC,uBAAuB;IAI/B;;;;;;;;;SASK;IACQ,yBAAyB,CAAC,YAAY,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;YAS3F,wBAAwB;CAwBvC"}
|
|
@@ -454,9 +454,11 @@ export class PeerManager {
|
|
|
454
454
|
const score = this.peerScoring.getScoreState(peer.remotePeer.toString());
|
|
455
455
|
switch(score){
|
|
456
456
|
case PeerScoreState.Banned:
|
|
457
|
+
this.metrics.recordLowScoreDisconnect('Banned');
|
|
457
458
|
void this.goodbyeAndDisconnectPeer(peer.remotePeer, GoodByeReason.BANNED);
|
|
458
459
|
break;
|
|
459
460
|
case PeerScoreState.Disconnect:
|
|
461
|
+
this.metrics.recordLowScoreDisconnect('Disconnect');
|
|
460
462
|
void this.goodbyeAndDisconnectPeer(peer.remotePeer, GoodByeReason.LOW_SCORE);
|
|
461
463
|
break;
|
|
462
464
|
case PeerScoreState.Healthy:
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { PeerErrorSeverity } from '@aztec/stdlib/p2p';
|
|
2
|
+
import { type TelemetryClient } from '@aztec/telemetry-client';
|
|
2
3
|
import type { PeerId } from '@libp2p/interface';
|
|
3
4
|
import type { P2PConfig } from '../../config.js';
|
|
4
5
|
export declare enum PeerScoreState {
|
|
@@ -15,7 +16,8 @@ export declare class PeerScoring {
|
|
|
15
16
|
peerPenalties: {
|
|
16
17
|
[key in PeerErrorSeverity]: number;
|
|
17
18
|
};
|
|
18
|
-
|
|
19
|
+
private peerStateCounter;
|
|
20
|
+
constructor(config: P2PConfig, telemetry?: TelemetryClient);
|
|
19
21
|
penalizePeer(peerId: PeerId, penalty: PeerErrorSeverity): number;
|
|
20
22
|
updateScore(peerId: string, scoreDelta: number): number;
|
|
21
23
|
decayAllScores(): void;
|
|
@@ -23,6 +25,9 @@ export declare class PeerScoring {
|
|
|
23
25
|
getScoreState(peerId: string): PeerScoreState;
|
|
24
26
|
getStats(): {
|
|
25
27
|
medianScore: number;
|
|
28
|
+
healthyCount: number;
|
|
29
|
+
disconnectCount: number;
|
|
30
|
+
bannedCount: number;
|
|
26
31
|
};
|
|
27
32
|
}
|
|
28
33
|
//# sourceMappingURL=peer_scoring.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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;AAQjD,oBAAY,cAAc;IACxB,MAAM,IAAA;IACN,UAAU,IAAA;IACV,OAAO,IAAA;CACR;AAMD,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;gBAE5B,MAAM,EAAE,SAAS,EAAE,SAAS,GAAE,eAAsC;IAmBzE,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB;IAQ9D,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM;IAmBvD,cAAc,IAAI,IAAI;IActB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;IAIzB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,cAAc;IAYpD,QAAQ,IAAI;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAC;QAAC,eAAe,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE;CA6BxG"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { median } from '@aztec/foundation/collection';
|
|
2
2
|
import { createLogger } from '@aztec/foundation/log';
|
|
3
3
|
import { PeerErrorSeverity } from '@aztec/stdlib/p2p';
|
|
4
|
+
import { Attributes, Metrics, ValueType, getTelemetryClient } from '@aztec/telemetry-client';
|
|
4
5
|
const DefaultPeerPenalties = {
|
|
5
6
|
[PeerErrorSeverity.LowToleranceError]: 50,
|
|
6
7
|
[PeerErrorSeverity.MidToleranceError]: 10,
|
|
@@ -22,13 +23,19 @@ export class PeerScoring {
|
|
|
22
23
|
decayInterval = 1000 * 60;
|
|
23
24
|
decayFactor = 0.9;
|
|
24
25
|
peerPenalties;
|
|
25
|
-
|
|
26
|
+
peerStateCounter;
|
|
27
|
+
constructor(config, telemetry = getTelemetryClient()){
|
|
26
28
|
const orderedValues = config.peerPenaltyValues?.sort((a, b)=>a - b);
|
|
27
29
|
this.peerPenalties = {
|
|
28
30
|
[PeerErrorSeverity.HighToleranceError]: orderedValues?.[0] ?? DefaultPeerPenalties[PeerErrorSeverity.HighToleranceError],
|
|
29
31
|
[PeerErrorSeverity.MidToleranceError]: orderedValues?.[1] ?? DefaultPeerPenalties[PeerErrorSeverity.MidToleranceError],
|
|
30
32
|
[PeerErrorSeverity.LowToleranceError]: orderedValues?.[2] ?? DefaultPeerPenalties[PeerErrorSeverity.LowToleranceError]
|
|
31
33
|
};
|
|
34
|
+
const meter = telemetry.getMeter('PeerScoring');
|
|
35
|
+
this.peerStateCounter = meter.createUpDownCounter(Metrics.P2P_PEER_STATE_COUNT, {
|
|
36
|
+
description: 'Count of peers by state (Healthy, Disconnect, Banned)',
|
|
37
|
+
valueType: ValueType.INT
|
|
38
|
+
});
|
|
32
39
|
}
|
|
33
40
|
penalizePeer(peerId, penalty) {
|
|
34
41
|
const id = peerId.toString();
|
|
@@ -79,8 +86,39 @@ export class PeerScoring {
|
|
|
79
86
|
return 2;
|
|
80
87
|
}
|
|
81
88
|
getStats() {
|
|
89
|
+
const stateCounts = {
|
|
90
|
+
healthy: 0,
|
|
91
|
+
disconnect: 0,
|
|
92
|
+
banned: 0
|
|
93
|
+
};
|
|
94
|
+
for (const peerId of this.scores.keys()){
|
|
95
|
+
const state = this.getScoreState(peerId);
|
|
96
|
+
switch(state){
|
|
97
|
+
case 2:
|
|
98
|
+
stateCounts.healthy++;
|
|
99
|
+
break;
|
|
100
|
+
case 1:
|
|
101
|
+
stateCounts.disconnect++;
|
|
102
|
+
break;
|
|
103
|
+
case 0:
|
|
104
|
+
stateCounts.banned++;
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
this.peerStateCounter.add(stateCounts.healthy, {
|
|
109
|
+
[Attributes.P2P_PEER_SCORE_STATE]: 'Healthy'
|
|
110
|
+
});
|
|
111
|
+
this.peerStateCounter.add(stateCounts.disconnect, {
|
|
112
|
+
[Attributes.P2P_PEER_SCORE_STATE]: 'Disconnect'
|
|
113
|
+
});
|
|
114
|
+
this.peerStateCounter.add(stateCounts.banned, {
|
|
115
|
+
[Attributes.P2P_PEER_SCORE_STATE]: 'Banned'
|
|
116
|
+
});
|
|
82
117
|
return {
|
|
83
|
-
medianScore: median(Array.from(this.scores.values())) ?? 0
|
|
118
|
+
medianScore: median(Array.from(this.scores.values())) ?? 0,
|
|
119
|
+
healthyCount: stateCounts.healthy,
|
|
120
|
+
disconnectCount: stateCounts.disconnect,
|
|
121
|
+
bannedCount: stateCounts.banned
|
|
84
122
|
};
|
|
85
123
|
}
|
|
86
124
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/p2p",
|
|
3
|
-
"version": "3.0.0-nightly.
|
|
3
|
+
"version": "3.0.0-nightly.20251127",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
@@ -67,17 +67,17 @@
|
|
|
67
67
|
]
|
|
68
68
|
},
|
|
69
69
|
"dependencies": {
|
|
70
|
-
"@aztec/constants": "3.0.0-nightly.
|
|
71
|
-
"@aztec/epoch-cache": "3.0.0-nightly.
|
|
72
|
-
"@aztec/ethereum": "3.0.0-nightly.
|
|
73
|
-
"@aztec/foundation": "3.0.0-nightly.
|
|
74
|
-
"@aztec/kv-store": "3.0.0-nightly.
|
|
75
|
-
"@aztec/noir-contracts.js": "3.0.0-nightly.
|
|
76
|
-
"@aztec/noir-protocol-circuits-types": "3.0.0-nightly.
|
|
77
|
-
"@aztec/protocol-contracts": "3.0.0-nightly.
|
|
78
|
-
"@aztec/simulator": "3.0.0-nightly.
|
|
79
|
-
"@aztec/stdlib": "3.0.0-nightly.
|
|
80
|
-
"@aztec/telemetry-client": "3.0.0-nightly.
|
|
70
|
+
"@aztec/constants": "3.0.0-nightly.20251127",
|
|
71
|
+
"@aztec/epoch-cache": "3.0.0-nightly.20251127",
|
|
72
|
+
"@aztec/ethereum": "3.0.0-nightly.20251127",
|
|
73
|
+
"@aztec/foundation": "3.0.0-nightly.20251127",
|
|
74
|
+
"@aztec/kv-store": "3.0.0-nightly.20251127",
|
|
75
|
+
"@aztec/noir-contracts.js": "3.0.0-nightly.20251127",
|
|
76
|
+
"@aztec/noir-protocol-circuits-types": "3.0.0-nightly.20251127",
|
|
77
|
+
"@aztec/protocol-contracts": "3.0.0-nightly.20251127",
|
|
78
|
+
"@aztec/simulator": "3.0.0-nightly.20251127",
|
|
79
|
+
"@aztec/stdlib": "3.0.0-nightly.20251127",
|
|
80
|
+
"@aztec/telemetry-client": "3.0.0-nightly.20251127",
|
|
81
81
|
"@chainsafe/libp2p-gossipsub": "13.0.0",
|
|
82
82
|
"@chainsafe/libp2p-noise": "^15.0.0",
|
|
83
83
|
"@chainsafe/libp2p-yamux": "^6.0.2",
|
|
@@ -104,8 +104,8 @@
|
|
|
104
104
|
"xxhash-wasm": "^1.1.0"
|
|
105
105
|
},
|
|
106
106
|
"devDependencies": {
|
|
107
|
-
"@aztec/archiver": "3.0.0-nightly.
|
|
108
|
-
"@aztec/world-state": "3.0.0-nightly.
|
|
107
|
+
"@aztec/archiver": "3.0.0-nightly.20251127",
|
|
108
|
+
"@aztec/world-state": "3.0.0-nightly.20251127",
|
|
109
109
|
"@jest/globals": "^30.0.0",
|
|
110
110
|
"@types/jest": "^30.0.0",
|
|
111
111
|
"@types/node": "^22.15.17",
|
|
@@ -117,7 +117,7 @@
|
|
|
117
117
|
"ts-node": "^10.9.1",
|
|
118
118
|
"typescript": "^5.3.3",
|
|
119
119
|
"uint8arrays": "^5.0.3",
|
|
120
|
-
"viem": "npm:@
|
|
120
|
+
"viem": "npm:@aztec/viem@2.38.2"
|
|
121
121
|
},
|
|
122
122
|
"files": [
|
|
123
123
|
"dest",
|
package/src/config.ts
CHANGED
|
@@ -165,6 +165,9 @@ export interface P2PConfig extends P2PReqRespConfig, ChainConfig, TxCollectionCo
|
|
|
165
165
|
/** Whether to delete transactions from the pool after a reorg instead of moving them back to pending. */
|
|
166
166
|
txPoolDeleteTxsAfterReorg: boolean;
|
|
167
167
|
|
|
168
|
+
/** Alters the format of p2p messages to include things like broadcast timestamp FOR TESTING ONLY */
|
|
169
|
+
debugP2PInstrumentMessages: boolean;
|
|
170
|
+
|
|
168
171
|
/** Whether to run in fisherman mode: validates all proposals and attestations but does not broadcast attestations or participate in consensus */
|
|
169
172
|
fishermanMode: boolean;
|
|
170
173
|
}
|
|
@@ -409,7 +412,7 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
|
|
|
409
412
|
},
|
|
410
413
|
dropTransactionsProbability: {
|
|
411
414
|
env: 'P2P_DROP_TX_CHANCE',
|
|
412
|
-
description: 'The probability that a transaction is discarded. - For testing purposes only',
|
|
415
|
+
description: 'The probability that a transaction is discarded (0 - 1). - For testing purposes only',
|
|
413
416
|
...floatConfigHelper(0),
|
|
414
417
|
},
|
|
415
418
|
disableTransactions: {
|
|
@@ -423,6 +426,11 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
|
|
|
423
426
|
description: 'Whether to delete transactions from the pool after a reorg instead of moving them back to pending.',
|
|
424
427
|
...booleanConfigHelper(false),
|
|
425
428
|
},
|
|
429
|
+
debugP2PInstrumentMessages: {
|
|
430
|
+
env: 'DEBUG_P2P_INSTRUMENT_MESSAGES',
|
|
431
|
+
description: 'Alters the format of p2p messages to include things like broadcast timestamp FOR TESTING ONLY',
|
|
432
|
+
...booleanConfigHelper(false),
|
|
433
|
+
},
|
|
426
434
|
fishermanMode: {
|
|
427
435
|
env: 'FISHERMAN_MODE',
|
|
428
436
|
description:
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
type MetricsType,
|
|
11
11
|
type ObservableGauge,
|
|
12
12
|
type TelemetryClient,
|
|
13
|
+
type UpDownCounter,
|
|
13
14
|
} from '@aztec/telemetry-client';
|
|
14
15
|
|
|
15
16
|
export enum PoolName {
|
|
@@ -20,6 +21,7 @@ export enum PoolName {
|
|
|
20
21
|
type MetricsLabels = {
|
|
21
22
|
objectInMempool: MetricsType;
|
|
22
23
|
objectSize: MetricsType;
|
|
24
|
+
itemsAdded: MetricsType;
|
|
23
25
|
};
|
|
24
26
|
|
|
25
27
|
/**
|
|
@@ -32,11 +34,13 @@ function getMetricsLabels(name: PoolName): MetricsLabels {
|
|
|
32
34
|
return {
|
|
33
35
|
objectInMempool: Metrics.MEMPOOL_TX_COUNT,
|
|
34
36
|
objectSize: Metrics.MEMPOOL_TX_SIZE,
|
|
37
|
+
itemsAdded: Metrics.MEMPOOL_TX_ADDED_COUNT,
|
|
35
38
|
};
|
|
36
39
|
} else if (name === PoolName.ATTESTATION_POOL) {
|
|
37
40
|
return {
|
|
38
41
|
objectInMempool: Metrics.MEMPOOL_ATTESTATIONS_COUNT,
|
|
39
42
|
objectSize: Metrics.MEMPOOL_ATTESTATIONS_SIZE,
|
|
43
|
+
itemsAdded: Metrics.MEMPOOL_ATTESTATIONS_ADDED_COUNT,
|
|
40
44
|
};
|
|
41
45
|
}
|
|
42
46
|
|
|
@@ -53,6 +57,7 @@ export type PoolStatsCallback = () => Promise<{
|
|
|
53
57
|
export class PoolInstrumentation<PoolObject extends Gossipable> {
|
|
54
58
|
/** The number of txs in the mempool */
|
|
55
59
|
private objectsInMempool: ObservableGauge;
|
|
60
|
+
private addObjectCounter: UpDownCounter;
|
|
56
61
|
/** Tracks tx size */
|
|
57
62
|
private objectSize: Histogram;
|
|
58
63
|
|
|
@@ -89,6 +94,10 @@ export class PoolInstrumentation<PoolObject extends Gossipable> {
|
|
|
89
94
|
dbStats,
|
|
90
95
|
);
|
|
91
96
|
|
|
97
|
+
this.addObjectCounter = this.meter.createUpDownCounter(metricsLabels.itemsAdded, {
|
|
98
|
+
description: 'The number of transactions added to the mempool',
|
|
99
|
+
});
|
|
100
|
+
|
|
92
101
|
this.meter.addBatchObservableCallback(this.observeStats, [this.objectsInMempool]);
|
|
93
102
|
}
|
|
94
103
|
|
|
@@ -96,6 +105,10 @@ export class PoolInstrumentation<PoolObject extends Gossipable> {
|
|
|
96
105
|
this.objectSize.record(poolObject.getSize());
|
|
97
106
|
}
|
|
98
107
|
|
|
108
|
+
public incrementAddedObjects(count: number) {
|
|
109
|
+
this.addObjectCounter.add(count);
|
|
110
|
+
}
|
|
111
|
+
|
|
99
112
|
private observeStats = async (observer: BatchObservableResult) => {
|
|
100
113
|
const { itemCount } = await this.poolStats();
|
|
101
114
|
if (typeof itemCount === 'number') {
|
|
@@ -17,6 +17,7 @@ export class P2PInstrumentation {
|
|
|
17
17
|
private messageValidationDuration: Histogram;
|
|
18
18
|
private messagePrevalidationCount: UpDownCounter;
|
|
19
19
|
private messageLatency: Histogram;
|
|
20
|
+
private txReceivedCount: UpDownCounter;
|
|
20
21
|
|
|
21
22
|
private aggLatencyHisto = new Map<TopicType, RecordableHistogram>();
|
|
22
23
|
private aggValidationHisto = new Map<TopicType, RecordableHistogram>();
|
|
@@ -44,6 +45,10 @@ export class P2PInstrumentation {
|
|
|
44
45
|
valueType: ValueType.INT,
|
|
45
46
|
});
|
|
46
47
|
|
|
48
|
+
this.txReceivedCount = meter.createUpDownCounter(Metrics.P2P_GOSSIP_TX_RECEIVED_COUNT, {
|
|
49
|
+
description: 'The number of txs received from the p2p network',
|
|
50
|
+
});
|
|
51
|
+
|
|
47
52
|
this.aggLatencyMetrics = {
|
|
48
53
|
avg: meter.createObservableGauge(Metrics.P2P_GOSSIP_AGG_MESSAGE_LATENCY_AVG, {
|
|
49
54
|
valueType: ValueType.DOUBLE,
|
|
@@ -119,6 +124,10 @@ export class P2PInstrumentation {
|
|
|
119
124
|
validationHistogram.record(Math.max(ms, 1));
|
|
120
125
|
}
|
|
121
126
|
|
|
127
|
+
public incrementTxReceived(count: number) {
|
|
128
|
+
this.txReceivedCount.add(count);
|
|
129
|
+
}
|
|
130
|
+
|
|
122
131
|
public incMessagePrevalidationStatus(passed: boolean, topicName: TopicType | undefined) {
|
|
123
132
|
this.messagePrevalidationCount.add(1, { [Attributes.TOPIC_NAME]: topicName, [Attributes.OK]: passed });
|
|
124
133
|
}
|
|
@@ -129,7 +138,7 @@ export class P2PInstrumentation {
|
|
|
129
138
|
|
|
130
139
|
let latencyHistogram = this.aggLatencyHisto.get(topicName);
|
|
131
140
|
if (!latencyHistogram) {
|
|
132
|
-
latencyHistogram = createHistogram({ min: 1, max:
|
|
141
|
+
latencyHistogram = createHistogram({ min: 1, max: 60 * 1000 }); // Max: 1 minute
|
|
133
142
|
this.aggLatencyHisto.set(topicName, latencyHistogram);
|
|
134
143
|
}
|
|
135
144
|
|
|
@@ -2,7 +2,6 @@ import type { EpochCacheInterface } from '@aztec/epoch-cache';
|
|
|
2
2
|
import { randomInt } from '@aztec/foundation/crypto';
|
|
3
3
|
import { Fr } from '@aztec/foundation/fields';
|
|
4
4
|
import { type Logger, createLibp2pComponentLogger, createLogger } from '@aztec/foundation/log';
|
|
5
|
-
import { SerialQueue } from '@aztec/foundation/queue';
|
|
6
5
|
import { RunningPromise } from '@aztec/foundation/running-promise';
|
|
7
6
|
import { Timer } from '@aztec/foundation/timer';
|
|
8
7
|
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
@@ -121,7 +120,6 @@ type ReceivedMessageValidationResult<T> =
|
|
|
121
120
|
* Lib P2P implementation of the P2PService interface.
|
|
122
121
|
*/
|
|
123
122
|
export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends WithTracer implements P2PService {
|
|
124
|
-
private jobQueue: SerialQueue = new SerialQueue();
|
|
125
123
|
private discoveryRunningPromise?: RunningPromise;
|
|
126
124
|
private msgIdSeenValidators: Record<TopicType, MessageSeenValidator> = {} as Record<TopicType, MessageSeenValidator>;
|
|
127
125
|
|
|
@@ -408,7 +406,7 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
408
406
|
logger: createLibp2pComponentLogger(logger.module),
|
|
409
407
|
});
|
|
410
408
|
|
|
411
|
-
const peerScoring = new PeerScoring(config);
|
|
409
|
+
const peerScoring = new PeerScoring(config, telemetry);
|
|
412
410
|
const reqresp = new ReqResp(config, node, peerScoring, createLogger(`${logger.module}:reqresp`));
|
|
413
411
|
|
|
414
412
|
const peerManager = new PeerManager(
|
|
@@ -463,9 +461,6 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
463
461
|
}
|
|
464
462
|
const announceTcpMultiaddr = convertToMultiaddr(p2pIp, p2pPort, 'tcp');
|
|
465
463
|
|
|
466
|
-
// Start job queue, peer discovery service and libp2p node
|
|
467
|
-
this.jobQueue.start();
|
|
468
|
-
|
|
469
464
|
await this.peerManager.initializePeers();
|
|
470
465
|
if (!this.config.p2pDiscoveryDisabled) {
|
|
471
466
|
await this.peerDiscoveryService.start();
|
|
@@ -503,9 +498,11 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
503
498
|
// add GossipSub listener
|
|
504
499
|
this.node.services.pubsub.addEventListener(GossipSubEvent.MESSAGE, this.gossipSubEventHandler);
|
|
505
500
|
|
|
506
|
-
// Start running promise for peer discovery
|
|
501
|
+
// Start running promise for peer discovery and metrics collection
|
|
507
502
|
this.discoveryRunningPromise = new RunningPromise(
|
|
508
|
-
() =>
|
|
503
|
+
async () => {
|
|
504
|
+
await this.peerManager.heartbeat();
|
|
505
|
+
},
|
|
509
506
|
this.logger,
|
|
510
507
|
this.config.peerCheckIntervalMS,
|
|
511
508
|
);
|
|
@@ -538,9 +535,6 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
538
535
|
// Stop peer manager
|
|
539
536
|
this.logger.debug('Stopping peer manager...');
|
|
540
537
|
await this.peerManager.stop();
|
|
541
|
-
|
|
542
|
-
this.logger.debug('Stopping job queue...');
|
|
543
|
-
await this.jobQueue.end();
|
|
544
538
|
this.logger.debug('Stopping running promise...');
|
|
545
539
|
await this.discoveryRunningPromise?.stop();
|
|
546
540
|
this.logger.debug('Stopping peer discovery service...');
|
|
@@ -628,7 +622,7 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
628
622
|
if (!this.node.services.pubsub) {
|
|
629
623
|
throw new Error('Pubsub service not available.');
|
|
630
624
|
}
|
|
631
|
-
const p2pMessage = P2PMessage.fromGossipable(message);
|
|
625
|
+
const p2pMessage = P2PMessage.fromGossipable(message, this.config.debugP2PInstrumentMessages);
|
|
632
626
|
const result = await this.node.services.pubsub.publish(topic, p2pMessage.toMessageData());
|
|
633
627
|
return result.recipients.length;
|
|
634
628
|
}
|
|
@@ -682,7 +676,7 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
682
676
|
*/
|
|
683
677
|
private safelyDeserializeP2PMessage(msgId: string, source: PeerId, data: Uint8Array): P2PMessage | undefined {
|
|
684
678
|
try {
|
|
685
|
-
return P2PMessage.fromMessageData(Buffer.from(data));
|
|
679
|
+
return P2PMessage.fromMessageData(Buffer.from(data), this.config.debugP2PInstrumentMessages);
|
|
686
680
|
} catch (err) {
|
|
687
681
|
this.logger.error(`Error deserializing P2PMessage`, err, {
|
|
688
682
|
msgId,
|
|
@@ -700,6 +694,8 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
700
694
|
* @param data - The message data
|
|
701
695
|
*/
|
|
702
696
|
protected async handleNewGossipMessage(msg: Message, msgId: string, source: PeerId) {
|
|
697
|
+
const msgReceivedTime = Date.now();
|
|
698
|
+
let topicType: TopicType | undefined;
|
|
703
699
|
const p2pMessage = this.safelyDeserializeP2PMessage(msgId, source, msg.data);
|
|
704
700
|
if (!p2pMessage) {
|
|
705
701
|
return;
|
|
@@ -712,15 +708,25 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
712
708
|
}
|
|
713
709
|
|
|
714
710
|
if (msg.topic === this.topicStrings[TopicType.tx]) {
|
|
711
|
+
topicType = TopicType.tx;
|
|
715
712
|
await this.handleGossipedTx(p2pMessage.payload, msgId, source);
|
|
716
713
|
}
|
|
717
|
-
if (msg.topic === this.topicStrings[TopicType.block_attestation]
|
|
718
|
-
|
|
714
|
+
if (msg.topic === this.topicStrings[TopicType.block_attestation]) {
|
|
715
|
+
topicType = TopicType.block_attestation;
|
|
716
|
+
if (this.clientType === P2PClientType.Full) {
|
|
717
|
+
await this.processAttestationFromPeer(p2pMessage.payload, msgId, source);
|
|
718
|
+
}
|
|
719
719
|
}
|
|
720
720
|
if (msg.topic === this.topicStrings[TopicType.block_proposal]) {
|
|
721
|
+
topicType = TopicType.block_proposal;
|
|
721
722
|
await this.processBlockFromPeer(p2pMessage.payload, msgId, source);
|
|
722
723
|
}
|
|
723
724
|
|
|
725
|
+
if (p2pMessage.timestamp !== undefined && topicType !== undefined) {
|
|
726
|
+
const latency = msgReceivedTime - p2pMessage.timestamp.getTime();
|
|
727
|
+
this.instrumentation.recordMessageLatency(topicType, latency);
|
|
728
|
+
}
|
|
729
|
+
|
|
724
730
|
return;
|
|
725
731
|
}
|
|
726
732
|
|
|
@@ -789,6 +795,7 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
789
795
|
return;
|
|
790
796
|
}
|
|
791
797
|
|
|
798
|
+
this.instrumentation.incrementTxReceived(1);
|
|
792
799
|
await this.mempools.txPool.addTxs([tx]);
|
|
793
800
|
}
|
|
794
801
|
|
|
@@ -983,13 +990,9 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
983
990
|
public async propagate<T extends Gossipable>(message: T) {
|
|
984
991
|
const p2pMessageIdentifier = await message.p2pMessageLoggingIdentifier();
|
|
985
992
|
this.logger.trace(`Message ${p2pMessageIdentifier} queued`, { p2pMessageIdentifier });
|
|
986
|
-
void this.
|
|
987
|
-
.
|
|
988
|
-
|
|
989
|
-
})
|
|
990
|
-
.catch(error => {
|
|
991
|
-
this.logger.error(`Error propagating message ${p2pMessageIdentifier}`, { error });
|
|
992
|
-
});
|
|
993
|
+
void this.sendToPeers(message).catch(error => {
|
|
994
|
+
this.logger.error(`Error propagating message ${p2pMessageIdentifier}`, { error });
|
|
995
|
+
});
|
|
993
996
|
}
|
|
994
997
|
|
|
995
998
|
/**
|
|
@@ -15,6 +15,7 @@ export class PeerManagerMetrics {
|
|
|
15
15
|
private sentGoodbyes: UpDownCounter;
|
|
16
16
|
private receivedGoodbyes: UpDownCounter;
|
|
17
17
|
private peerCount: Gauge;
|
|
18
|
+
private lowScoreDisconnects: UpDownCounter;
|
|
18
19
|
|
|
19
20
|
public readonly tracer: Tracer;
|
|
20
21
|
|
|
@@ -40,6 +41,11 @@ export class PeerManagerMetrics {
|
|
|
40
41
|
unit: 'peers',
|
|
41
42
|
valueType: ValueType.INT,
|
|
42
43
|
});
|
|
44
|
+
this.lowScoreDisconnects = meter.createUpDownCounter(Metrics.PEER_MANAGER_LOW_SCORE_DISCONNECTS, {
|
|
45
|
+
description: 'Number of peers disconnected due to low score',
|
|
46
|
+
unit: 'peers',
|
|
47
|
+
valueType: ValueType.INT,
|
|
48
|
+
});
|
|
43
49
|
}
|
|
44
50
|
|
|
45
51
|
public recordGoodbyeSent(reason: GoodByeReason) {
|
|
@@ -53,4 +59,8 @@ export class PeerManagerMetrics {
|
|
|
53
59
|
public recordPeerCount(count: number) {
|
|
54
60
|
this.peerCount.record(count);
|
|
55
61
|
}
|
|
62
|
+
|
|
63
|
+
public recordLowScoreDisconnect(scoreState: 'Banned' | 'Disconnect') {
|
|
64
|
+
this.lowScoreDisconnects.add(1, { [Attributes.P2P_PEER_SCORE_STATE]: scoreState });
|
|
65
|
+
}
|
|
56
66
|
}
|
|
@@ -577,9 +577,11 @@ export class PeerManager implements PeerManagerInterface {
|
|
|
577
577
|
const score = this.peerScoring.getScoreState(peer.remotePeer.toString());
|
|
578
578
|
switch (score) {
|
|
579
579
|
case PeerScoreState.Banned:
|
|
580
|
+
this.metrics.recordLowScoreDisconnect('Banned');
|
|
580
581
|
void this.goodbyeAndDisconnectPeer(peer.remotePeer, GoodByeReason.BANNED);
|
|
581
582
|
break;
|
|
582
583
|
case PeerScoreState.Disconnect:
|
|
584
|
+
this.metrics.recordLowScoreDisconnect('Disconnect');
|
|
583
585
|
void this.goodbyeAndDisconnectPeer(peer.remotePeer, GoodByeReason.LOW_SCORE);
|
|
584
586
|
break;
|
|
585
587
|
case PeerScoreState.Healthy:
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { median } from '@aztec/foundation/collection';
|
|
2
2
|
import { createLogger } from '@aztec/foundation/log';
|
|
3
3
|
import { PeerErrorSeverity } from '@aztec/stdlib/p2p';
|
|
4
|
+
import {
|
|
5
|
+
Attributes,
|
|
6
|
+
Metrics,
|
|
7
|
+
type TelemetryClient,
|
|
8
|
+
type UpDownCounter,
|
|
9
|
+
ValueType,
|
|
10
|
+
getTelemetryClient,
|
|
11
|
+
} from '@aztec/telemetry-client';
|
|
4
12
|
|
|
5
13
|
import type { PeerId } from '@libp2p/interface';
|
|
6
14
|
|
|
@@ -30,7 +38,9 @@ export class PeerScoring {
|
|
|
30
38
|
private decayFactor = 0.9;
|
|
31
39
|
peerPenalties: { [key in PeerErrorSeverity]: number };
|
|
32
40
|
|
|
33
|
-
|
|
41
|
+
private peerStateCounter: UpDownCounter;
|
|
42
|
+
|
|
43
|
+
constructor(config: P2PConfig, telemetry: TelemetryClient = getTelemetryClient()) {
|
|
34
44
|
const orderedValues = config.peerPenaltyValues?.sort((a, b) => a - b);
|
|
35
45
|
this.peerPenalties = {
|
|
36
46
|
[PeerErrorSeverity.HighToleranceError]:
|
|
@@ -40,6 +50,13 @@ export class PeerScoring {
|
|
|
40
50
|
[PeerErrorSeverity.LowToleranceError]:
|
|
41
51
|
orderedValues?.[2] ?? DefaultPeerPenalties[PeerErrorSeverity.LowToleranceError],
|
|
42
52
|
};
|
|
53
|
+
|
|
54
|
+
const meter = telemetry.getMeter('PeerScoring');
|
|
55
|
+
|
|
56
|
+
this.peerStateCounter = meter.createUpDownCounter(Metrics.P2P_PEER_STATE_COUNT, {
|
|
57
|
+
description: 'Count of peers by state (Healthy, Disconnect, Banned)',
|
|
58
|
+
valueType: ValueType.INT,
|
|
59
|
+
});
|
|
43
60
|
}
|
|
44
61
|
|
|
45
62
|
public penalizePeer(peerId: PeerId, penalty: PeerErrorSeverity) {
|
|
@@ -99,7 +116,33 @@ export class PeerScoring {
|
|
|
99
116
|
return PeerScoreState.Healthy;
|
|
100
117
|
}
|
|
101
118
|
|
|
102
|
-
getStats(): { medianScore: number } {
|
|
103
|
-
|
|
119
|
+
getStats(): { medianScore: number; healthyCount: number; disconnectCount: number; bannedCount: number } {
|
|
120
|
+
const stateCounts = { healthy: 0, disconnect: 0, banned: 0 };
|
|
121
|
+
|
|
122
|
+
for (const peerId of this.scores.keys()) {
|
|
123
|
+
const state = this.getScoreState(peerId);
|
|
124
|
+
switch (state) {
|
|
125
|
+
case PeerScoreState.Healthy:
|
|
126
|
+
stateCounts.healthy++;
|
|
127
|
+
break;
|
|
128
|
+
case PeerScoreState.Disconnect:
|
|
129
|
+
stateCounts.disconnect++;
|
|
130
|
+
break;
|
|
131
|
+
case PeerScoreState.Banned:
|
|
132
|
+
stateCounts.banned++;
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
this.peerStateCounter.add(stateCounts.healthy, { [Attributes.P2P_PEER_SCORE_STATE]: 'Healthy' });
|
|
138
|
+
this.peerStateCounter.add(stateCounts.disconnect, { [Attributes.P2P_PEER_SCORE_STATE]: 'Disconnect' });
|
|
139
|
+
this.peerStateCounter.add(stateCounts.banned, { [Attributes.P2P_PEER_SCORE_STATE]: 'Banned' });
|
|
140
|
+
|
|
141
|
+
return {
|
|
142
|
+
medianScore: median(Array.from(this.scores.values())) ?? 0,
|
|
143
|
+
healthyCount: stateCounts.healthy,
|
|
144
|
+
disconnectCount: stateCounts.disconnect,
|
|
145
|
+
bannedCount: stateCounts.banned,
|
|
146
|
+
};
|
|
104
147
|
}
|
|
105
148
|
}
|