-
Notifications
You must be signed in to change notification settings - Fork 176
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Networking] GossipSub Spam Mitigation- Dynamic Decay Speed #4891
Conversation
- remove static decay of .99 instead initialize to random decay that is updated based on gossip score - update tests ensure initial decay is between constant lower and upper bounds
- add new GossipSubScoringRegistryConfig struct to hold configs needed for registry that were previously hard coded - update builders
@@ -136,7 +136,7 @@ func TestInvalidCtrlMsgScoringIntegration(t *testing.T) { | |||
}) | |||
|
|||
// now simulates node2 spamming node1 with invalid gossipsub control messages. | |||
for i := 0; i < 30; i++ { | |||
for i := 0; i < 750; i++ { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that decay will start lower than .99 and only be incremented by default .01 we need to spam more messages in this test so that the node gets disallow listed.
config/config_test.go
Outdated
err := c.Validate() | ||
require.Error(t, err) | ||
errs, ok := errors.Unwrap(err).(validator.ValidationErrors) | ||
require.True(t, ok) | ||
require.Len(t, errs, 2) | ||
require.Len(t, errs, 3) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This only checks that there were 3 errors returned but it doesn't check what those errors were. Would be better to check the actual errors returned.
config/default-config.yml
Outdated
# The lower bound on the decay value for a spam record when initialized. | ||
# A random value in a range of InitDecayLowerBound and InitDecayUpperBound is used when initializing the decay | ||
# of a spam record. | ||
gossipsub-scoring-registry-init-decay-lowerbound: .5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gossipsub-scoring-registry-init-decay-lowerbound: .5 | |
gossipsub-scoring-registry-init-decay-lower-bound: .5 |
config/default-config.yml
Outdated
# of a spam record. | ||
gossipsub-scoring-registry-init-decay-lowerbound: .5 | ||
# The upper bound on the decay value for a spam record when initialized. | ||
gossipsub-scoring-registry-init-decay-upperbound: .7 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gossipsub-scoring-registry-init-decay-upperbound: .7 | |
gossipsub-scoring-registry-init-decay-upper-bound: .7 |
network/p2p/p2pconf/gossipsub.go
Outdated
// InitDecayLowerBound is the lower bound on the decay value for a spam record when initialized. | ||
// A random value in a range of InitDecayLowerBound and InitDecayUpperBound is used when initializing the decay | ||
// of a spam record. | ||
InitDecayLowerBound float64 `validate:"gt=0,lt=1" mapstructure:"gossipsub-scoring-registry-init-decay-lowerbound"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
InitDecayLowerBound float64 `validate:"gt=0,lt=1" mapstructure:"gossipsub-scoring-registry-init-decay-lowerbound"` | |
InitDecayLowerBound float64 `validate:"gt=0,lt=1,ltfield=InitDecayUpperBound" mapstructure:"gossipsub-scoring-registry-init-decay-lowerbound"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
network/p2p/scoring/registry.go
Outdated
// - decayLowerbound: the lower bound of the range for the initial random decay value | ||
// - decayUpperbound: the upper bound of the range for the initial random decay value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// - decayLowerbound: the lower bound of the range for the initial random decay value | |
// - decayUpperbound: the upper bound of the range for the initial random decay value | |
// - decayLowerBound: the lower bound of the range for the initial random decay value | |
// - decayUpperBound: the upper bound of the range for the initial random decay value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
network/p2p/scoring/registry.go
Outdated
func InitAppScoreRecordStateFunc(decayLowerbound, decayUpperbound float64) func() p2p.GossipSubSpamRecord { | ||
return func() p2p.GossipSubSpamRecord { | ||
return p2p.GossipSubSpamRecord{ | ||
Decay: rand.Float64()*(decayUpperbound-decayLowerbound) + decayLowerbound, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
func InitAppScoreRecordStateFunc(decayLowerbound, decayUpperbound float64) func() p2p.GossipSubSpamRecord { | |
return func() p2p.GossipSubSpamRecord { | |
return p2p.GossipSubSpamRecord{ | |
Decay: rand.Float64()*(decayUpperbound-decayLowerbound) + decayLowerbound, | |
func InitAppScoreRecordStateFunc(decayLowerBound, decayUpperBound float64) func() p2p.GossipSubSpamRecord { | |
return func() p2p.GossipSubSpamRecord { | |
return p2p.GossipSubSpamRecord{ | |
Decay: rand.Float64()*(decayUpperBound-decayLowerBound) + decayLowerBound, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. A bunch of nits and 1 testing issue that should be addressed before merging.
Co-authored-by: Misha <15269764+gomisha@users.noreply.github.com>
Co-authored-by: Misha <15269764+gomisha@users.noreply.github.com>
Co-authored-by: Misha <15269764+gomisha@users.noreply.github.com>
Co-authored-by: Misha <15269764+gomisha@users.noreply.github.com>
Co-authored-by: Misha <15269764+gomisha@users.noreply.github.com>
Co-authored-by: Misha <15269764+gomisha@users.noreply.github.com>
Co-authored-by: Misha <15269764+gomisha@users.noreply.github.com>
Co-authored-by: Yahya Hassanzadeh, Ph.D. <yhassanzadeh@ieee.org>
Co-authored-by: Yahya Hassanzadeh, Ph.D. <yhassanzadeh@ieee.org>
Co-authored-by: Yahya Hassanzadeh, Ph.D. <yhassanzadeh@ieee.org>
Co-authored-by: Yahya Hassanzadeh, Ph.D. <yhassanzadeh@ieee.org>
Co-authored-by: Yahya Hassanzadeh, Ph.D. <yhassanzadeh@ieee.org>
…& MaximumSpamPenaltyDecaySpeed -> MaximumSpamPenaltyDecayFactor
…w/flow-go into khalil/6662-peer-id-specific-decay
…eer-id-specific-decay
This PR addresses the issue of spam record decay in the GossipSub scoring registry, which currently decays at a constant rate of 0.99, a hard-coded package-level value. This constant decay rate affects both honest and malicious nodes equally, potentially causing network degradation, especially when honest nodes take longer to recover their gossip scores.
To mitigate this issue, this PR introduces a mechanism for dynamic spam record decay. With this enhancement, each spam record is now initialized with a random decay value, denoted as 'n,' falling within the range specified by
...scoringRegistryConfig.InitDecayLowerBound
and...scoringRegistryConfig.InitDecayUpperBound
.Furthermore, when a record's penalty reaches the threshold defined by
...scoringRegistryConfig.IncreaseDecayThreshold
, the record's decay rate is increased by...scoringRegistryConfig.DecayThresholdIncrementer
. This change ensures that nodes engaging in sustained malicious behavior will have spam records with the highest decay rate, resulting in a slower recovery process.By introducing dynamic decay rates for spam records, this PR enhances the fairness and resilience of the GossipSub scoring mechanism, creating a more robust foundation for the network's health and performance.
ref: https://github.com/dapperlabs/flow-go/issues/6662