Skip to content
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

Khalil/6819 simplify rpc inspector validation #4642

Merged
merged 43 commits into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
b376519
simplify RPC control message inspection
kc1116 Aug 18, 2023
74755b2
remove old config values
kc1116 Aug 18, 2023
977cde4
Merge branch 'khalil/6472-iwant-flooding-detection' of github.com:onf…
kc1116 Aug 24, 2023
a59b37e
add max message id sample size
kc1116 Aug 25, 2023
6452581
update rpc inspection
kc1116 Aug 28, 2023
9ec19eb
provide a brief description of config values
kc1116 Aug 28, 2023
97bab3e
rename stopTestComponents -> stopComponents
kc1116 Aug 28, 2023
5fc10c3
add returns godoc
kc1116 Aug 28, 2023
0fb6faf
add godoc for last highest size
kc1116 Aug 28, 2023
797dc16
add godoc for RPCControlTracking interface
kc1116 Aug 28, 2023
3c20855
rename ControlMessageMaxSampleSize -> GraftPruneMessageMaxSampleSize
kc1116 Aug 28, 2023
b11999f
short circuit inspection when err encountered
kc1116 Aug 28, 2023
2b2080f
ensure notifications are not disseminated for unexpected errors
kc1116 Aug 28, 2023
e91f308
lint fixes
kc1116 Aug 28, 2023
08adf5e
update mocks
kc1116 Aug 28, 2023
ca55765
Merge branch 'master' of github.com:onflow/flow-go into khalil/6819-s…
kc1116 Aug 29, 2023
d25656d
Merge branch 'master' into khalil/6819-simplify-rpc-inspector-validation
kc1116 Aug 31, 2023
666c1f9
Merge branch 'master' into khalil/6819-simplify-rpc-inspector-validation
kc1116 Sep 1, 2023
984b740
update godoc
kc1116 Sep 11, 2023
83bc1d7
Update network/p2p/inspector/validation/control_message_validation_in…
kc1116 Sep 11, 2023
43cb7fb
Update config/default-config.yml
kc1116 Sep 11, 2023
c8b7c4e
Update network/p2p/pubsub.go
kc1116 Sep 11, 2023
8055eb1
Update network/p2p/pubsub.go
kc1116 Sep 11, 2023
479aa47
Update control_message_validation_inspector.go
kc1116 Sep 11, 2023
fef5143
Merge branch 'khalil/6819-simplify-rpc-inspector-validation' of githu…
kc1116 Sep 11, 2023
64ece62
rename RPCControlTracking -> RpcControlTracking
kc1116 Sep 11, 2023
d5552d8
Update network/p2p/p2pconf/gossipsub_rpc_inspectors.go
kc1116 Sep 11, 2023
feb7780
Update network/p2p/p2pconf/gossipsub_rpc_inspectors.go
kc1116 Sep 11, 2023
6009189
Update network/p2p/p2pconf/gossipsub_rpc_inspectors.go
kc1116 Sep 11, 2023
7dc3c4e
Update network/p2p/inspector/validation/control_message_validation_in…
kc1116 Sep 11, 2023
82c2eb2
remove Fatal level logs
kc1116 Sep 11, 2023
ff46672
log warning for unstaked peer
kc1116 Sep 11, 2023
596981d
Update network/p2p/consumers.go
kc1116 Sep 11, 2023
3b137f3
Update network/p2p/consumers.go
kc1116 Sep 11, 2023
9bf850c
Update network/p2p/consumers.go
kc1116 Sep 11, 2023
39a7069
update scoring test
kc1116 Sep 11, 2023
fca6fb6
Merge branch 'khalil/6819-simplify-rpc-inspector-validation' of githu…
kc1116 Sep 11, 2023
4b90950
Merge branch 'master' of github.com:onflow/flow-go into khalil/6819-s…
kc1116 Sep 11, 2023
7e885c0
Update gossip_sub_rpc_inspector_suite_factory_func.go
kc1116 Sep 11, 2023
26724d1
fix spamIHaveBrokenPromise
kc1116 Sep 12, 2023
cc0d585
Merge branch 'master' of github.com:onflow/flow-go into khalil/6819-s…
kc1116 Sep 12, 2023
9e416a6
fix test
kc1116 Sep 13, 2023
2bdb75b
Update control_message_validation_inspector.go
kc1116 Sep 13, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 22 additions & 25 deletions config/default-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,34 @@ network-config:
gossipsub-rpc-sent-tracker-workers: 5
# Peer scoring is the default value for enabling peer scoring
gossipsub-peer-scoring-enabled: true

# Gossipsub rpc inspectors configs
# The size of the queue for notifications about invalid RPC messages
gossipsub-rpc-inspector-notification-cache-size: 10000
# RPC control message validation inspector configs
# Rpc validation inspector number of pool workers
gossipsub-rpc-validation-inspector-workers: 5
# Max number of ihave messages in a sample to be inspected. If the number of ihave messages exceeds this configured value
# the control message ihaves will be truncated to the max sample size. This sample is randomly selected.
gossipsub-rpc-ihave-max-sample-size: 5000
# Max number of ihave message ids in a sample to be inspected per ihave. Each ihave message includes a list of message ids
# each, if the size of this list exceeds the configured max message id sample size the list of message ids will be truncated.
gossipsub-rpc-ihave-max-message-id-sample-size: 3000
# Max number of control messages in a sample to be inspected when inspecting GRAFT and PRUNE message types. If the total number of control messages (GRAFT or PRUNE)
# exceeds this max sample size then the respective message will be truncated before being processed.
gossipsub-rpc-graft-and-prune-message-max-sample-size: 1000
# Max number of iwant messages in a sample to be inspected. If the total number of iWant control messages
# exceeds this max sample size then the respective message will be truncated before being processed.
gossipsub-rpc-iwant-max-sample-size: 1_000_000
# Max number of iwant message ids in a sample to be inspected per iwant. Each iwant message includes a list of message ids
# each, if the size of this list exceeds the configured max message id sample size the list of message ids will be truncated.
gossipsub-rpc-iwant-max-message-id-sample-size: 3000
# The allowed threshold of iWant messages received without a corresponding tracked iHave message that was sent. If the cache miss threshold is exceeded an
# invalid control message notification is disseminated and the sender will be penalized.
gossipsub-rpc-iwant-cache-miss-threshold: .5
# The max allowed duplicate message IDs in a single iWant control message. If the duplicate message threshold is exceeded an invalid control message
# notification is disseminated and the sender will be penalized.
gossipsub-rpc-iwant-duplicate-message-id-threshold: .15
kc1116 marked this conversation as resolved.
Show resolved Hide resolved
# The size of the queue used by worker pool for the control message validation inspector
gossipsub-rpc-validation-inspector-queue-cache-size: 100
# Cluster prefixed control message validation configs
Expand All @@ -87,32 +109,7 @@ network-config:
gossipsub-cluster-prefix-tracker-cache-decay: 0.99
# The upper bound on the amount of cluster prefixed control messages that will be processed
gossipsub-rpc-cluster-prefixed-hard-threshold: 100
# GRAFT libp2p control message validation limits
gossipsub-rpc-graft-hard-threshold: 30
gossipsub-rpc-graft-safety-threshold: 15
gossipsub-rpc-graft-rate-limit: 30
# PRUNE libp2p control message validation limits
gossipsub-rpc-prune-hard-threshold: 30
gossipsub-rpc-prune-safety-threshold: 15
gossipsub-rpc-prune-rate-limit: 30
# IHAVE libp2p control message validation limits
gossipsub-rpc-ihave-hard-threshold: 100
gossipsub-rpc-ihave-safety-threshold: 50
# Rate limiting is disabled for ihave control messages
gossipsub-rpc-ihave-rate-limit: 0
# Percentage of ihaves to use as the sample size for synchronous inspection 25%
ihave-sync-inspection-sample-size-percentage: .25
# Percentage of ihaves to use as the sample size for asynchronous inspection 10%
ihave-async-inspection-sample-size-percentage: .10
# Max number of ihave messages in a sample to be inspected
ihave-max-sample-size: 100

# Max number of iwant messages in a sample to be inspected
gossipsub-rpc-iwant-max-sample-size: 1_000_000
# The allowed threshold of iWant messages received without a corresponding tracked iHave message that was sent
gossipsub-rpc-iwant-cache-miss-threshold: .5
# The max allowed duplicate message IDs in a single iWant control message
gossipsub-rpc-iwant-duplicate-message-id-threshold: .15
# RPC metrics observer inspector configs
# The number of metrics inspector pool workers
gossipsub-rpc-metrics-inspector-workers: 1
Expand Down
4 changes: 2 additions & 2 deletions insecure/corruptlibp2p/fixtures.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ func GossipSubCtrlFixture(opts ...GossipSubCtrlOption) *pubsubpb.ControlMessage
}

// WithIHave adds iHave control messages of the given size and number to the control message.
func WithIHave(msgCount, msgSize int, topicId string) GossipSubCtrlOption {
func WithIHave(msgCount, msgIDCount int, topicId string) GossipSubCtrlOption {
return func(msg *pubsubpb.ControlMessage) {
iHaves := make([]*pubsubpb.ControlIHave, msgCount)
for i := 0; i < msgCount; i++ {
iHaves[i] = &pubsubpb.ControlIHave{
TopicID: &topicId,
MessageIDs: GossipSubMessageIdsFixture(msgSize),
MessageIDs: GossipSubMessageIdsFixture(msgIDCount),
}
}
msg.Ihave = iHaves
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func TestMetricsInspector_ObserveRPC(t *testing.T) {
nodes := []p2p.LibP2PNode{victimNode, spammer.SpammerNode}
startNodesAndEnsureConnected(t, signalerCtx, nodes, sporkID)
spammer.Start(t)
defer stopTestComponents(t, cancel, nodes, metricsInspector)
defer stopComponents(t, cancel, nodes, metricsInspector)
// prepare to spam - generate control messages
ctlMsgs := spammer.GenerateCtlMessages(controlMessageCount,
corruptlibp2p.WithGraft(messageCount, channels.PushBlocks.String()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func startNodesAndEnsureConnected(t *testing.T, ctx irrecoverable.SignalerContex
})
}

func stopTestComponents(t *testing.T, cancel context.CancelFunc, nodes []p2p.LibP2PNode, components ...module.ReadyDoneAware) {
func stopComponents(t *testing.T, cancel context.CancelFunc, nodes []p2p.LibP2PNode, components ...module.ReadyDoneAware) {
p2ptest.StopNodes(t, nodes, cancel)
unittest.RequireComponentsDoneBefore(t, time.Second, components...)
}
Expand Down
Loading
Loading