Skip to content

feat: add ConnectionGater - #610

Merged
tzdybal merged 9 commits into
evstack:mainfrom
randomshinichi:feature/connectiongater
Jan 17, 2023
Merged

feat: add ConnectionGater#610
tzdybal merged 9 commits into
evstack:mainfrom
randomshinichi:feature/connectiongater

Conversation

@randomshinichi

@randomshinichirandomshinichi commented Nov 17, 2022

Copy link
Copy Markdown
Contributor

Overview

Resolves#386
Blacklists/whitelists are only applied while starting the Client, and do not update while the Client is running.

Checklist

  • New and updated code has appropriate documentation
  • New and updated code has new and/or updated testing
  • Required CI checks are passing
  • Visual proof for any user facing features like CLI or documentation updates
  • Linked issues closed with keywords

@tzdybal
tzdybal marked this pull request as draft November 17, 2022 14:04
@tzdybaltzdybal changed the title DRAFT: feature/connectiongaterfeature/connectiongaterNov 17, 2022

@tzdybaltzdybal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the submission!
I left some comments.

Comment threadp2p/client_test.go Outdated
Comment threadp2p/client.go
Comment threadp2p/client.go Outdated
Comment threadp2p/client.go Outdated
Comment threadp2p/client.go
@tzdybaltzdybal mentioned this pull request Nov 21, 2022
2 tasks
@randomshinichi
randomshinichi marked this pull request as ready for review November 28, 2022 15:29
@codecov-commenter

codecov-commenter commented Nov 28, 2022

Copy link
Copy Markdown

Codecov Report

Merging #610 (ff454bb) into main (90ff206) will decrease coverage by 0.03%.
The diff coverage is 52.27%.

@@ Coverage Diff @@## main #610 +/- ##
==========================================
- Coverage 55.06% 55.02% -0.04% 
==========================================
Files 48 48 Lines 10206 10224 +18 ==========================================
+ Hits 5620 5626 +6 - Misses 3724 3732 +8 - Partials 862 866 +4 
Impacted FilesCoverage Δ
node/node.go60.60% <40.00%> (+0.17%)⬆️
p2p/client.go60.72% <53.84%> (-2.32%)⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@tzdybal
tzdybal requested review from a team, Manav-Aggarwal and gupadhyaya and removed request for a teamNovember 29, 2022 06:34

@tzdybaltzdybal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the submission! I left some comments.

Comment threadp2p/client.go Outdated
Comment threadp2p/client.go Outdated
Comment threadp2p/client.go Outdated
Comment threadp2p/client.go Outdated
Comment threadp2p/client.go Outdated
Comment threadp2p/client.go Outdated
Comment threadp2p/client.go Outdated
@randomshinichi
randomshinichiforce-pushed the feature/connectiongater branch 2 times, most recently from 768aa05 to 3687d3eCompareDecember 11, 2022 11:16
tzdybal
tzdybal previously approved these changes Dec 19, 2022
@tzdybal
tzdybalforce-pushed the feature/connectiongater branch from 3687d3e to dad8975CompareDecember 19, 2022 20:17
@tzdybal
tzdybal enabled auto-merge (squash) December 19, 2022 20:19

@Manav-AggarwalManav-Aggarwal left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the submission! Left some comments. Had one question, when are whitelists useful as opposed to just having a blocklist? Or is the point to have overlap in whitelists and blocklists when unblocking a peer? Also, what happens when there are duplicate peer IDs in these blocklists/whitelists?

Comment threadp2p/client.go Outdated
Comment threadp2p/client.go Outdated
Comment threadp2p/client.go Outdated
Comment threadp2p/client_test.go Outdated
@tzdybal

Copy link
Copy Markdown
Contributor

When we get to the point where peers are blocked automatically (because of for example spamming, sending invalid FPs, etc), we might want to manually unblock specific peer.

@Manav-Aggarwal

Copy link
Copy Markdown
Member

When we get to the point where peers are blocked automatically (because of for example spamming, sending invalid FPs, etc), we might want to manually unblock specific peer.

That makes sense but instead of having that peer in both the whitelist and blacklist, is it possible to just remove the peer from the blacklist instead since this is done during client initialization?

TestClientStartup() ensures that using blacklists/whitelists don't result in an error
log which peers exactly were white/blacklisted
don't reuse gater between subtests
blacklist/whitelist should be setup before gossiping/DHT/peer discovery
do not create ConnectionGater yourself if gater was nil
style revisions
@tzdybal
tzdybalforce-pushed the feature/connectiongater branch from dad8975 to 1f7aa04CompareJanuary 12, 2023 13:15
@tzdybaltzdybal self-assigned this Jan 12, 2023
tzdybal
tzdybal previously approved these changes Jan 13, 2023

@tzdybaltzdybal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@randomshinichi thanks again for your submission!

@tzdybaltzdybal changed the title feature/connectiongaterfeat: add ConnectionGaterJan 13, 2023
Comment threadp2p/client_test.go Outdated
Comment threadp2p/client.go Outdated
Comment threadp2p/client.go Outdated
Comment threadp2p/client.go Outdated
nashqueue
nashqueue previously approved these changes Jan 13, 2023

@nashqueuenashqueue left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No additional comments to the ones that were mentioned above. LGTM if they are resolved

@tzdybal
tzdybal dismissed stale reviews from nashqueue and themself via 3d9e055January 16, 2023 14:03
@tzdybal

Copy link
Copy Markdown
Contributor

I changed the logic a bit - connection gater is created in NewNode to make sure that it's always present - this simplifies the code.

Also addressed all the comments.

@tzdybal
tzdybal dismissed Manav-Aggarwal’s stale reviewJanuary 16, 2023 14:11

To simplify our code, lets just depend on gater ability to block/unblock right peers.

gupadhyaya
gupadhyaya previously approved these changes Jan 16, 2023

@gupadhyayagupadhyaya left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM.

nashqueue
nashqueue previously approved these changes Jan 16, 2023

@nashqueuenashqueue left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@tzdybal
tzdybalforce-pushed the feature/connectiongater branch from 107539b to 7ac66dcCompareJanuary 16, 2023 14:31

@gupadhyayagupadhyaya left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM again :P

@tzdybal
tzdybal merged commit e5ec6a8 into evstack:mainJan 17, 2023
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Maintain a blacklist of malicious peers

6 participants

@randomshinichi@codecov-commenter@tzdybal@Manav-Aggarwal@gupadhyaya@nashqueue