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

go/worker/common/p2p: Add support for persistent and blocked peers #4713

Merged
merged 1 commit into from
May 18, 2022

Conversation

abukosek
Copy link
Contributor

@abukosek abukosek commented Apr 28, 2022

This PR adds support for blocking p2p peers and for keeping persistent connections to peers.

The persistent peer functionality currently doesn't automatically connect to the given peers on startup, but will only keep the connection once it's already established.

@abukosek abukosek force-pushed the andrej/feature/p2p-blacklist branch 2 times, most recently from 31c6a67 to ca9a83f Compare April 28, 2022 09:07
@codecov
Copy link

codecov bot commented Apr 28, 2022

Codecov Report

Merging #4713 (9df6aa8) into master (513420e) will decrease coverage by 0.05%.
The diff coverage is 46.42%.

@@            Coverage Diff             @@
##           master    #4713      +/-   ##
==========================================
- Coverage   66.77%   66.71%   -0.06%     
==========================================
  Files         441      441              
  Lines       49348    49407      +59     
==========================================
+ Hits        32952    32963      +11     
- Misses      12317    12375      +58     
+ Partials     4079     4069      -10     
Impacted Files Coverage Δ
go/worker/common/p2p/p2p.go 57.57% <18.00%> (-9.25%) ⬇️
go/common/node/address.go 58.53% <84.61%> (+2.98%) ⬆️
go/worker/common/p2p/peermgmt.go 79.05% <86.66%> (-0.47%) ⬇️
go/registry/tests/tester.go 92.49% <100.00%> (-0.03%) ⬇️
go/worker/common/p2p/init.go 100.00% <100.00%> (ø)
go/oasis-node/cmd/common/metrics/disk.go 65.51% <0.00%> (-20.69%) ⬇️
go/oasis-node/cmd/common/metrics/resource.go 84.00% <0.00%> (-8.00%) ⬇️
go/worker/compute/executor/committee/node.go 68.01% <0.00%> (-3.29%) ⬇️
go/sentry/api/grpc.go 40.62% <0.00%> (-3.13%) ⬇️
...consensus/tendermint/apps/roothash/transactions.go 66.66% <0.00%> (-3.12%) ⬇️
... and 25 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6ef8411...9df6aa8. Read the comment docs.

@abukosek abukosek force-pushed the andrej/feature/p2p-blacklist branch 2 times, most recently from 8715c86 to 51dadc3 Compare May 2, 2022 07:59
@abukosek abukosek force-pushed the andrej/feature/p2p-blacklist branch from 51dadc3 to e8a00b6 Compare May 16, 2022 07:39
@abukosek abukosek marked this pull request as ready for review May 16, 2022 08:34
Copy link
Member

@kostko kostko left a comment

Choose a reason for hiding this comment

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

You could probably use pubsub.WithDirectPeers to make the pubsub router maintain those connections. That option also supports specifying IP addresses, see here for how this is implemented.

go/worker/common/p2p/p2p.go Show resolved Hide resolved
go/worker/common/p2p/peermgmt.go Outdated Show resolved Hide resolved
@abukosek abukosek force-pushed the andrej/feature/p2p-blacklist branch 3 times, most recently from a0524ad to db8fd41 Compare May 18, 2022 11:38
return nil, fmt.Errorf("worker/common/p2p: invalid persistent peer public key (%s): %w", pubkey, grr)
}

ipport := strings.Split(addr, ":")
Copy link
Member

Choose a reason for hiding this comment

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

Should probably use net.SplitHostPort.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice, thanks!

@abukosek abukosek force-pushed the andrej/feature/p2p-blacklist branch from db8fd41 to 9df6aa8 Compare May 18, 2022 14:54
@abukosek abukosek merged commit aef4f28 into master May 18, 2022
@abukosek abukosek deleted the andrej/feature/p2p-blacklist branch May 18, 2022 15:22
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.

None yet

2 participants