@libp2p/gossipsub 17.1.1-5cb617ae2 → 17.1.1-fb139d1c8
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/README.md +56 -52
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +3 -3
- package/dist/src/constants.d.ts +3 -3
- package/dist/src/constants.js +3 -3
- package/dist/src/gossipsub.js +8 -8
- package/dist/src/gossipsub.js.map +1 -1
- package/dist/src/index.d.ts +36 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +36 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/metrics.d.ts +1 -1
- package/dist/src/metrics.d.ts.map +1 -1
- package/dist/src/metrics.js +1 -1
- package/dist/src/metrics.js.map +1 -1
- package/dist/src/score/peer-score-params.d.ts +1 -1
- package/dist/src/score/peer-score-params.js +1 -1
- package/dist/src/score/peer-score-params.js.map +1 -1
- package/dist/src/score/peer-score-thresholds.d.ts +2 -2
- package/dist/src/score/peer-score.d.ts +2 -2
- package/dist/src/score/peer-score.d.ts.map +1 -1
- package/dist/src/tracer.js +1 -1
- package/dist/src/utils/buildRawMessage.js +2 -2
- package/dist/src/utils/buildRawMessage.js.map +1 -1
- package/package.json +18 -13
- package/src/constants.ts +3 -3
- package/src/gossipsub.ts +8 -8
- package/src/index.ts +37 -0
- package/src/message/rpc.proto +1 -1
- package/src/metrics.ts +1 -1
- package/src/score/peer-score-params.ts +2 -2
- package/src/score/peer-score-thresholds.ts +2 -2
- package/src/score/peer-score.ts +2 -2
- package/src/tracer.ts +1 -1
- package/src/utils/buildRawMessage.ts +2 -2
package/src/message/rpc.proto
CHANGED
package/src/metrics.ts
CHANGED
|
@@ -29,7 +29,7 @@ export interface PeerScoreParams {
|
|
|
29
29
|
* is the square of the difference, ie (PeersInSameIP - IPColocationThreshold)^2.
|
|
30
30
|
* If the number of peers in the same IP is less than the threshold, then the value is 0.
|
|
31
31
|
* The weight of the parameter MUST be negative, unless you want to disable for testing.
|
|
32
|
-
* Note: In order to simulate many IPs in a
|
|
32
|
+
* Note: In order to simulate many IPs in a manageable manner when testing, you can set the weight to 0
|
|
33
33
|
* thus disabling the IP colocation penalty.
|
|
34
34
|
*/
|
|
35
35
|
IPColocationFactorWeight: number
|
|
@@ -266,7 +266,7 @@ export function validateTopicScoreParams (p: TopicScoreParams): void {
|
|
|
266
266
|
|
|
267
267
|
// check P2
|
|
268
268
|
if (p.firstMessageDeliveriesWeight < 0) {
|
|
269
|
-
throw new InvalidPeerScoreParamsError('
|
|
269
|
+
throw new InvalidPeerScoreParamsError('invalid FirstMessageDeliveriesWeight; must be positive (or 0 to disable)')
|
|
270
270
|
}
|
|
271
271
|
if (
|
|
272
272
|
p.firstMessageDeliveriesWeight !== 0 &&
|
|
@@ -6,7 +6,7 @@ import { InvalidPeerScoreThresholdsError } from '../errors.ts'
|
|
|
6
6
|
|
|
7
7
|
export interface PeerScoreThresholds {
|
|
8
8
|
/**
|
|
9
|
-
* gossipThreshold is the score threshold below which gossip propagation is
|
|
9
|
+
* gossipThreshold is the score threshold below which gossip propagation is suppressed;
|
|
10
10
|
* should be negative.
|
|
11
11
|
*/
|
|
12
12
|
gossipThreshold: number
|
|
@@ -18,7 +18,7 @@ export interface PeerScoreThresholds {
|
|
|
18
18
|
publishThreshold: number
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
|
-
* graylistThreshold is the score threshold below which message processing is
|
|
21
|
+
* graylistThreshold is the score threshold below which message processing is suppressed altogether,
|
|
22
22
|
* implementing an effective graylist according to peer score; should be negative and <= PublisThreshold.
|
|
23
23
|
*/
|
|
24
24
|
graylistThreshold: number
|
package/src/score/peer-score.ts
CHANGED
|
@@ -11,7 +11,7 @@ import type { ComponentLogger, Logger } from '@libp2p/interface'
|
|
|
11
11
|
|
|
12
12
|
interface PeerScoreOpts {
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
14
|
+
* Milliseconds to cache computed score per peer
|
|
15
15
|
*/
|
|
16
16
|
scoreCacheValidityMs: number
|
|
17
17
|
|
|
@@ -21,7 +21,7 @@ interface PeerScoreOpts {
|
|
|
21
21
|
interface ScoreCacheEntry {
|
|
22
22
|
/** The cached score */
|
|
23
23
|
score: number
|
|
24
|
-
/** Unix timestamp in
|
|
24
|
+
/** Unix timestamp in milliseconds, the time after which the cached score for a peer is no longer valid */
|
|
25
25
|
cacheUntil: number
|
|
26
26
|
}
|
|
27
27
|
|
package/src/tracer.ts
CHANGED
|
@@ -131,7 +131,7 @@ export class IWantTracer {
|
|
|
131
131
|
this.trackMessage(msgIdStr)
|
|
132
132
|
|
|
133
133
|
// A message got rejected, so we can stop tracking promises and let the score penalty apply.
|
|
134
|
-
// With the
|
|
134
|
+
// With the exception of obvious invalid messages
|
|
135
135
|
switch (reason) {
|
|
136
136
|
case RejectReason.Error:
|
|
137
137
|
return
|
|
@@ -101,13 +101,13 @@ export async function validateToRawMessage (
|
|
|
101
101
|
msg: RPC.Message
|
|
102
102
|
): Promise<ValidationResult> {
|
|
103
103
|
// If strict-sign, verify all
|
|
104
|
-
// If anonymous (no-sign), ensure no
|
|
104
|
+
// If anonymous (no-sign), ensure no signature, key, from or seqno is present
|
|
105
105
|
|
|
106
106
|
switch (signaturePolicy) {
|
|
107
107
|
case StrictNoSign:
|
|
108
108
|
if (msg.signature != null) { return { valid: false, error: ValidateError.SignaturePresent } }
|
|
109
109
|
if (msg.seqno != null) { return { valid: false, error: ValidateError.SeqnoPresent } }
|
|
110
|
-
if (msg.key != null) { return { valid: false, error: ValidateError.FromPresent } }
|
|
110
|
+
if (msg.from != null || msg.key != null) { return { valid: false, error: ValidateError.FromPresent } }
|
|
111
111
|
|
|
112
112
|
return { valid: true, message: { type: 'unsigned', topic: msg.topic, data: msg.data ?? new Uint8Array(0) } }
|
|
113
113
|
|