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

p2p: peer store and dialing changes #8737

Merged
merged 70 commits into from
Jun 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
9dbb135
p2p: peer store and dialing changes
tychoish Jun 10, 2022
b213a27
reduce persistent peer max
tychoish Jun 10, 2022
cc28ce2
don't gossip inactive peers
tychoish Jun 10, 2022
56a9164
fix small case
tychoish Jun 10, 2022
86db59f
fix error message
tychoish Jun 10, 2022
000aa05
remove seed flag
tychoish Jun 10, 2022
4e2bc8f
reduce logging level
tychoish Jun 10, 2022
e3068b5
make const
tychoish Jun 10, 2022
31bd396
update comment
tychoish Jun 10, 2022
eddb23b
cleanup
tychoish Jun 10, 2022
a12fa36
Merge remote-tracking branch 'origin/master' into p2p-dialer-store-ch…
tychoish Jun 10, 2022
d6e3cab
fix tests
tychoish Jun 10, 2022
4c86510
overflows
tychoish Jun 10, 2022
f23f6e1
Update internal/p2p/peermanager.go
tychoish Jun 10, 2022
1c02758
Update internal/p2p/peermanager.go
tychoish Jun 10, 2022
9f604fd
comment
tychoish Jun 10, 2022
930fd7f
test: new scoring
tychoish Jun 10, 2022
5150c3f
Merge branch 'master' into p2p-dialer-store-change
tychoish Jun 13, 2022
9abc55f
fix scoring test
tychoish Jun 13, 2022
904390a
cleanup peer manager
tychoish Jun 13, 2022
7d93b2e
Merge remote-tracking branch 'origin/master' into p2p-dialer-store-ch…
tychoish Jun 13, 2022
420ae37
fix panic
tychoish Jun 13, 2022
9a0d440
add metrics
tychoish Jun 14, 2022
c5b1816
Merge remote-tracking branch 'origin/master' into p2p-dialer-store-ch…
tychoish Jun 14, 2022
35dc9ea
Merge remote-tracking branch 'origin/master' into p2p-dialer-store-ch…
tychoish Jun 14, 2022
2e9ca4e
fix compile
tychoish Jun 14, 2022
5a71966
fix test
tychoish Jun 14, 2022
b01fec9
default metrics to noop
tychoish Jun 14, 2022
720600e
update metrics
tychoish Jun 14, 2022
c11c88d
fix merge
tychoish Jun 14, 2022
d83dc89
rename metrics
tychoish Jun 14, 2022
afae39c
actually shuffle peers more
tychoish Jun 14, 2022
8195c97
fix up advertise
tychoish Jun 14, 2022
246e6d9
Merge remote-tracking branch 'origin/master' into p2p-dialer-store-ch…
tychoish Jun 14, 2022
487579f
Merge remote-tracking branch 'origin/master' into p2p-dialer-store-ch…
tychoish Jun 15, 2022
a8b93d2
chagelog
tychoish Jun 15, 2022
68840b3
Merge remote-tracking branch 'origin/master' into p2p-dialer-store-ch…
tychoish Jun 15, 2022
0b7cfa7
add max dialing attempts
tychoish Jun 15, 2022
95bc039
connection tracking
tychoish Jun 15, 2022
053ecd9
comments mostly
tychoish Jun 15, 2022
796688e
Apply suggestions from code review
tychoish Jun 15, 2022
40fb981
comments
tychoish Jun 15, 2022
a95efeb
fix lint
tychoish Jun 15, 2022
c411a83
Update CHANGELOG_PENDING.md
tychoish Jun 16, 2022
db39cfb
cr feedback
tychoish Jun 16, 2022
b1ef61a
make metrics match across versions
tychoish Jun 16, 2022
8c854cc
Merge remote-tracking branch 'origin/master' into p2p-dialer-store-ch…
tychoish Jun 16, 2022
dc1157d
fix lint
tychoish Jun 16, 2022
4f3f4da
make wb happy
tychoish Jun 16, 2022
9f491ef
more comments
tychoish Jun 16, 2022
1386556
Merge remote-tracking branch 'origin/master' into p2p-dialer-store-ch…
tychoish Jun 16, 2022
ebf2c30
add skip
tychoish Jun 16, 2022
f940ec1
iota fix
tychoish Jun 16, 2022
29d592f
cleanup
tychoish Jun 16, 2022
6044ecb
remove comment
tychoish Jun 16, 2022
ddbeb36
Merge remote-tracking branch 'origin/master' into p2p-dialer-store-ch…
tychoish Jun 16, 2022
acd12b9
fix rand
tychoish Jun 16, 2022
3f5b12d
fix rand
tychoish Jun 16, 2022
88b2536
use numaddresses correctly
tychoish Jun 16, 2022
6d3c623
readd
tychoish Jun 16, 2022
3b08f1a
Update internal/p2p/peermanager.go
tychoish Jun 16, 2022
bfdcb9a
remove some things
tychoish Jun 16, 2022
690a929
cleanup comment
tychoish Jun 16, 2022
1b24241
more fixes
tychoish Jun 16, 2022
b24fcf8
toml
tychoish Jun 16, 2022
e63dad0
fix port
tychoish Jun 16, 2022
5bd378b
fix comment
tychoish Jun 16, 2022
2e46fe0
dec limit
tychoish Jun 16, 2022
0ea605a
fixes
tychoish Jun 16, 2022
50afbc2
up the attmept max
tychoish Jun 16, 2022
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
4 changes: 4 additions & 0 deletions CHANGELOG_PENDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ Special thanks to external contributors on this release:
- [p2p] \#7035 Remove legacy P2P routing implementation and associated configuration options. (@tychoish)
- [p2p] \#7265 Peer manager reduces peer score for each failed dial attempts for peers that have not successfully dialed. (@tychoish)
- [p2p] [\#7594](https://github.com/tendermint/tendermint/pull/7594) always advertise self, to enable mutual address discovery. (@altergui)
- [p2p] \#8737 Introduce "inactive" peer label to avoid re-dialing incompatible peers. (@tychoish)
- [p2p] \#8737 Increase frequency of dialing attempts to reduce latency for peer acquisition. (@tychoish)
- [p2p] \#8737 Improvements to peer scoring and sorting to gossip a greater variety of peers during PEX. (@tychoish)
- [p2p] \#8737 Track incoming and outgoing peers separately to ensure more peer slots open for incoming connections. (@tychoish)

- Go API

Expand Down
8 changes: 8 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,10 @@ type P2PConfig struct { //nolint: maligned
// outbound).
MaxConnections uint16 `mapstructure:"max-connections"`

// MaxOutgoingConnections defines the maximum number of connected peers (inbound and
// outbound).
MaxOutgoingConnections uint16 `mapstructure:"max-outgoing-connections"`

tychoish marked this conversation as resolved.
Show resolved Hide resolved
// MaxIncomingConnectionAttempts rate limits the number of incoming connection
// attempts per IP address.
MaxIncomingConnectionAttempts uint `mapstructure:"max-incoming-connection-attempts"`
Expand Down Expand Up @@ -667,6 +671,7 @@ func DefaultP2PConfig() *P2PConfig {
ExternalAddress: "",
UPNP: false,
MaxConnections: 64,
MaxOutgoingConnections: 32,
MaxIncomingConnectionAttempts: 100,
FlushThrottleTimeout: 100 * time.Millisecond,
// The MTU (Maximum Transmission Unit) for Ethernet is 1500 bytes.
Expand Down Expand Up @@ -699,6 +704,9 @@ func (cfg *P2PConfig) ValidateBasic() error {
if cfg.RecvRate < 0 {
return errors.New("recv-rate can't be negative")
}
if cfg.MaxOutgoingConnections > cfg.MaxConnections {
return errors.New("max-outgoing-connections cannot be larger than max-connections")
}
return nil
}

Expand Down
4 changes: 4 additions & 0 deletions config/toml.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,10 @@ upnp = {{ .P2P.UPNP }}
# Maximum number of connections (inbound and outbound).
max-connections = {{ .P2P.MaxConnections }}

# Maximum number of connections reserved for outgoing
# connections. Must be less than max-connections
max-outgoing-connections = {{ .P2P.MaxOutgoingConnections }}

# Rate limits the number of incoming connection attempts per IP address.
max-incoming-connection-attempts = {{ .P2P.MaxIncomingConnectionAttempts }}

Expand Down
50 changes: 46 additions & 4 deletions internal/p2p/metrics.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 18 additions & 2 deletions internal/p2p/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,31 @@ var (

// Metrics contains metrics exposed by this package.
type Metrics struct {
// Number of peers.
Peers metrics.Gauge
// Number of peers connected.
PeersConnected metrics.Gauge
// Nomber of peers in the peer store database.
PeersStored metrics.Gauge
// Number of inactive peers stored.
PeersInactivated metrics.Gauge
// Number of bytes per channel received from a given peer.
PeerReceiveBytesTotal metrics.Counter `metrics_labels:"peer_id, chID, message_type"`
// Number of bytes per channel sent to a given peer.
PeerSendBytesTotal metrics.Counter `metrics_labels:"peer_id, chID, message_type"`
// Number of bytes pending being sent to a given peer.
PeerPendingSendBytes metrics.Gauge `metrics_labels:"peer_id"`

// Number of successful connection attempts
PeersConnectedSuccess metrics.Counter
// Number of failed connection attempts
PeersConnectedFailure metrics.Counter

// Number of peers connected as a result of dialing the
// peer.
PeersConnectedIncoming metrics.Gauge
// Number of peers connected as a result of the peer dialing
// this node.
PeersConnectedOutgoing metrics.Gauge
tychoish marked this conversation as resolved.
Show resolved Hide resolved

// RouterPeerQueueRecv defines the time taken to read off of a peer's queue
// before sending on the connection.
//metrics:The time taken to read off of a peer's queue before sending on the connection.
Expand Down
1 change: 1 addition & 0 deletions internal/p2p/p2ptest/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ func (n *Network) MakeNode(ctx context.Context, t *testing.T, opts NodeOptions)
RetryTimeJitter: time.Millisecond,
MaxPeers: opts.MaxPeers,
MaxConnected: opts.MaxConnected,
Metrics: p2p.NopMetrics(),
})
require.NoError(t, err)

Expand Down
Loading