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

Conversation

kc1116
Copy link
Contributor

@kc1116 kc1116 commented Aug 18, 2023

This PR simplifies RPC control message validation.

  1. Instead of using a Safety and Hard threshold, we will now shrink the RPC using a configured MaxSampleSize. Each subsequent control message that is not included in the sample will be resent in a subsequent RPC.
  2. A single inspector worker will validate an entire RPC rather than a single control message type.
  3. RPC validation will fail on the first encountered validation error enforcing a 1 notification per RPC rule.

Tests removed:

  • TestErrHardThresholdRoundTrip and TestErrRateLimitedControlMsgRoundTrip were removed because the associated errors no longer exist.
  • TestValidationInspector_SafetyThreshold, TestValidationInspector_HardThresholdIHave_Detection, and TestValidationInspector_RateLimitedPeer_Detection were also removed due to the simplification, which eliminated safety and hard thresholds as well as rate limiting.

- remove blocking pre-processing
- queue up a single RPC per request not control message per request
- update metrics
- capture all errors encountered for each control message, pass the actual error count to the notification distributor
- update CLI flags
return nil
}

// Name returns the name of the rpc inspector.
func (c *ControlMsgValidationInspector) Name() string {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While the ControlMsgValidationInspector is covered by integration tests in the insecure package, its critical role in our codebase warrants dedicated unit tests. These tests should focus on both successful and unsuccessful RPC processing:

  1. Verify that legitimate RPCs (iHave, iWant, Graft, Prune) do not trigger misbehavior notifications.
  2. Test for iHave misbehaviors, ensuring each case triggers a misbehavior notification.
  3. Similarly, validate that iWant misbehaviors trigger misbehavior notifications.
  4. Confirm that GRAFT and PRUNE misbehaviors also lead to misbehavior notifications.

Please include these tests in this PR or create an issue for them to be implemented in a subsequent PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

- update error handling
- add ihave duplicate message ID tests
@kc1116 kc1116 marked this pull request as ready for review August 28, 2023 04:18
@kc1116 kc1116 closed this Aug 28, 2023
@kc1116 kc1116 reopened this Aug 28, 2023
@codecov-commenter
Copy link

codecov-commenter commented Aug 28, 2023

Codecov Report

Patch coverage: 1.40% and project coverage change: -4.58% ⚠️

Comparison is base (0648496) 56.74% compared to head (2bdb75b) 52.16%.
Report is 26 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4642      +/-   ##
==========================================
- Coverage   56.74%   52.16%   -4.58%     
==========================================
  Files         876      734     -142     
  Lines       80357    65958   -14399     
==========================================
- Hits        45597    34406   -11191     
+ Misses      31208    28922    -2286     
+ Partials     3552     2630     -922     
Flag Coverage Δ
unittests 52.16% <1.40%> (-4.58%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
...dule/metrics/gossipsub_rpc_validation_inspector.go 0.00% <0.00%> (ø)
module/metrics/noop.go 0.00% <0.00%> (ø)
...validation/control_message_validation_inspector.go 0.00% <0.00%> (ø)
network/p2p/inspector/validation/errors.go 80.00% <ø> (-5.72%) ⬇️
...2p/inspector/validation/inspect_message_request.go 0.00% <0.00%> (ø)
network/p2p/p2pbuilder/libp2pNodeBuilder.go 0.00% <0.00%> (ø)
network/p2p/tracer/internal/rpc_sent_tracker.go 88.88% <ø> (ø)
network/netconf/flags.go 30.12% <33.33%> (+4.61%) ⬆️
network/p2p/test/fixtures.go 32.96% <33.33%> (ø)
network/p2p/scoring/registry.go 89.93% <100.00%> (+0.06%) ⬆️

... and 229 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@kc1116 kc1116 closed this Aug 29, 2023
@kc1116 kc1116 reopened this Aug 29, 2023
kc1116 and others added 20 commits September 11, 2023 12:53
…spector.go

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>
…b.com:onflow/flow-go into khalil/6819-simplify-rpc-inspector-validation
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>
…spector.go

Co-authored-by: Yahya Hassanzadeh, Ph.D. <yhassanzadeh@ieee.org>
- throw error on signaler context
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>
…b.com:onflow/flow-go into khalil/6819-simplify-rpc-inspector-validation
@kc1116 kc1116 added this pull request to the merge queue Sep 13, 2023
Merged via the queue into master with commit a85341d Sep 13, 2023
36 checks passed
@kc1116 kc1116 deleted the khalil/6819-simplify-rpc-inspector-validation branch September 13, 2023 01:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants