-
Notifications
You must be signed in to change notification settings - Fork 180
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
[ALSP] Synchronization Engine spam detection flag support, config/README.md
updates
#4842
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #4842 +/- ##
==========================================
- Coverage 55.91% 53.84% -2.07%
==========================================
Files 945 676 -269
Lines 87965 67837 -20128
==========================================
- Hits 49184 36527 -12657
+ Misses 35089 28618 -6471
+ Partials 3692 2692 -1000
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
@@ -68,10 +73,16 @@ type SpamDetectionConfig struct { | |||
} | |||
|
|||
func NewSpamDetectionConfig() *SpamDetectionConfig { |
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.
Better to return an error and let the parent context throw it so that the node shuts down properly
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/netconf/config.go
Outdated
SyncEngineBatchRequestBaseProb float32 `mapstructure:"alsp-sync-engine-batch-request-base-prob"` | ||
|
||
// SyncEngineRangeRequestBaseProb is the base probability in [0,1] that's used in creating the final probability of creating a | ||
// misbehavior report for a RangeRequest message. This is why the word "base" is used in the name of this field, | ||
// since it's not the final probability and there are other factors that determine the final probability. | ||
// The reason for this is that we want to increase the probability of creating a misbehavior report for a large range. | ||
SyncEngineRangeRequestBaseProb float32 `mapstructure:"alsp-sync-engine-range-request-base-prob"` | ||
|
||
// SyncEngineSyncRequestProb is the probability in [0,1] of creating a misbehavior report for a SyncRequest message. | ||
SyncEngineSyncRequestProb float32 `mapstructure:"alsp-sync-engine-sync-request-prob"` |
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.
I suggest adding validation tags to make sure these are greater than 0
SyncEngineBatchRequestBaseProb float32 `mapstructure:"alsp-sync-engine-batch-request-base-prob"` | |
// SyncEngineRangeRequestBaseProb is the base probability in [0,1] that's used in creating the final probability of creating a | |
// misbehavior report for a RangeRequest message. This is why the word "base" is used in the name of this field, | |
// since it's not the final probability and there are other factors that determine the final probability. | |
// The reason for this is that we want to increase the probability of creating a misbehavior report for a large range. | |
SyncEngineRangeRequestBaseProb float32 `mapstructure:"alsp-sync-engine-range-request-base-prob"` | |
// SyncEngineSyncRequestProb is the probability in [0,1] of creating a misbehavior report for a SyncRequest message. | |
SyncEngineSyncRequestProb float32 `mapstructure:"alsp-sync-engine-sync-request-prob"` | |
SyncEngineBatchRequestBaseProb float32 `validate:"gt=0" mapstructure:"alsp-sync-engine-batch-request-base-prob"` | |
// SyncEngineRangeRequestBaseProb is the base probability in [0,1] that's used in creating the final probability of creating a | |
// misbehavior report for a RangeRequest message. This is why the word "base" is used in the name of this field, | |
// since it's not the final probability and there are other factors that determine the final probability. | |
// The reason for this is that we want to increase the probability of creating a misbehavior report for a large range. | |
SyncEngineRangeRequestBaseProb float32 `validate:"gt=0" mapstructure:"alsp-sync-engine-range-request-base-prob"` | |
// SyncEngineSyncRequestProb is the probability in [0,1] of creating a misbehavior report for a SyncRequest message. | |
SyncEngineSyncRequestProb float32 `validate:"gt=0" mapstructure:"alsp-sync-engine-sync-request-prob"` |
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.
Great idea. I made the validation enforce a range of values between 0 and 1.
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.
Also, please consider encapsulating them into a sync engine-specific config type:
// AlspConfig is the config for the Application Layer Spam Prevention (ALSP) protocol.
type AlspConfig struct {
//... Other Configs
SyncEngine SyncEngineAlspConfig
}
type SyncEngineAlspConfig struct {
// SyncEngineBatchRequestBaseProb is the base probability in [0,1] that's used in creating the final probability of creating a
// misbehavior report for a BatchRequest message. This is why the word "base" is used in the name of this field,
// since it's not the final probability and there are other factors that determine the final probability.
// The reason for this is that we want to increase the probability of creating a misbehavior report for a large batch.
BatchRequestBaseProb float32 `validate:"range=0,1" mapstructure:"alsp-sync-engine-batch-request-base-prob"`
// SyncEngineRangeRequestBaseProb is the base probability in [0,1] that's used in creating the final probability of creating a
// misbehavior report for a RangeRequest message. This is why the word "base" is used in the name of this field,
// since it's not the final probability and there are other factors that determine the final probability.
// The reason for this is that we want to increase the probability of creating a misbehavior report for a large range.
RangeRequestBaseProb float32 `validate:"range=0,1" mapstructure:"alsp-sync-engine-range-request-base-prob"`
// SyncEngineSyncRequestProb is the probability in [0,1] of creating a misbehavior report for a SyncRequest message.
SyncRequestProb float32 `validate:"range=0,1" mapstructure:"alsp-sync-engine-sync-request-prob"`
}
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.
Great idea. Now the SyncEngine ALSP config is referenced list this:
batchRequestBaseProb: flowConfig.NetworkConfig.SyncEngine.SyncEngineBatchRequestBaseProb,
syncRequestProb: flowConfig.NetworkConfig.SyncEngine.SyncEngineSyncRequestProb,
rangeRequestBaseProb: flowConfig.NetworkConfig.SyncEngine.SyncEngineRangeRequestBaseProb,
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.
Shortened field names to this:
batchRequestBaseProb: flowConfig.NetworkConfig.SyncEngine.BatchRequestBaseProb,
syncRequestProb: flowConfig.NetworkConfig.SyncEngine.SyncRequestProb,
rangeRequestBaseProb: flowConfig.NetworkConfig.SyncEngine.RangeRequestBaseProb,
config/README.md
updates
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.
Except for one encapsulation comment, the rest looks good.
network/netconf/config.go
Outdated
SyncEngineBatchRequestBaseProb float32 `mapstructure:"alsp-sync-engine-batch-request-base-prob"` | ||
|
||
// SyncEngineRangeRequestBaseProb is the base probability in [0,1] that's used in creating the final probability of creating a | ||
// misbehavior report for a RangeRequest message. This is why the word "base" is used in the name of this field, | ||
// since it's not the final probability and there are other factors that determine the final probability. | ||
// The reason for this is that we want to increase the probability of creating a misbehavior report for a large range. | ||
SyncEngineRangeRequestBaseProb float32 `mapstructure:"alsp-sync-engine-range-request-base-prob"` | ||
|
||
// SyncEngineSyncRequestProb is the probability in [0,1] of creating a misbehavior report for a SyncRequest message. | ||
SyncEngineSyncRequestProb float32 `mapstructure:"alsp-sync-engine-sync-request-prob"` |
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.
Also, please consider encapsulating them into a sync engine-specific config type:
// AlspConfig is the config for the Application Layer Spam Prevention (ALSP) protocol.
type AlspConfig struct {
//... Other Configs
SyncEngine SyncEngineAlspConfig
}
type SyncEngineAlspConfig struct {
// SyncEngineBatchRequestBaseProb is the base probability in [0,1] that's used in creating the final probability of creating a
// misbehavior report for a BatchRequest message. This is why the word "base" is used in the name of this field,
// since it's not the final probability and there are other factors that determine the final probability.
// The reason for this is that we want to increase the probability of creating a misbehavior report for a large batch.
BatchRequestBaseProb float32 `validate:"range=0,1" mapstructure:"alsp-sync-engine-batch-request-base-prob"`
// SyncEngineRangeRequestBaseProb is the base probability in [0,1] that's used in creating the final probability of creating a
// misbehavior report for a RangeRequest message. This is why the word "base" is used in the name of this field,
// since it's not the final probability and there are other factors that determine the final probability.
// The reason for this is that we want to increase the probability of creating a misbehavior report for a large range.
RangeRequestBaseProb float32 `validate:"range=0,1" mapstructure:"alsp-sync-engine-range-request-base-prob"`
// SyncEngineSyncRequestProb is the probability in [0,1] of creating a misbehavior report for a SyncRequest message.
SyncRequestProb float32 `validate:"range=0,1" mapstructure:"alsp-sync-engine-sync-request-prob"`
}
Context
This PR:
alsp-sync-engine-batch-request-base-prob
alsp-sync-engine-range-request-base-prob
alsp-sync-engine-sync-request-prob
config/README.md
with more examples, clarifications and broken link fixesThis PR adds flag support to the 3 PRs that added support for spam detection to the Sync Engine:
SyncRequest
spam detection (Permissionless-related engine level spam detection) #4590RangeRequest
spam detection (Permissionless-related engine level spam detection) #4665BatchRequest
spam detection (Permissionless-related engine level spam detection) #4704ref: https://github.com/dapperlabs/flow-go/issues/6812