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

Rename GetPeerList and PeerList messages #3182

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
16 changes: 8 additions & 8 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,10 +353,10 @@ func getNetworkConfig(
ReadHandshakeTimeout: v.GetDuration(NetworkReadHandshakeTimeoutKey),
},

PeerListGossipConfig: network.PeerListGossipConfig{
PeerListNumValidatorIPs: v.GetUint32(NetworkPeerListNumValidatorIPsKey),
PeerListPullGossipFreq: v.GetDuration(NetworkPeerListPullGossipFreqKey),
PeerListBloomResetFreq: v.GetDuration(NetworkPeerListBloomResetFreqKey),
PeersGossipConfig: network.PeersGossipConfig{
Copy link
Contributor

Choose a reason for hiding this comment

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

Applicable to the similar spots in this PR but we should name this PeerGossipConfig since PeersGossipConfig reads awkwardly.

Copy link
Author

Choose a reason for hiding this comment

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

Thank you for reviewing.
I am not a native English speaker, so I'm not very familiar with it.
I have made the changes.

PeersNumValidatorIPs: v.GetUint32(NetworkPeersNumValidatorIPsKey),
PeersPullGossipFreq: v.GetDuration(NetworkPeersPullGossipFreqKey),
PeersBloomResetFreq: v.GetDuration(NetworkPeersBloomResetFreqKey),
},

DelayConfig: network.DelayConfig{
Expand Down Expand Up @@ -390,10 +390,10 @@ func getNetworkConfig(
return network.Config{}, fmt.Errorf("%s must be in [0,1]", NetworkHealthMaxPortionSendQueueFillKey)
case config.DialerConfig.ConnectionTimeout < 0:
return network.Config{}, fmt.Errorf("%q must be >= 0", NetworkOutboundConnectionTimeoutKey)
case config.PeerListPullGossipFreq < 0:
return network.Config{}, fmt.Errorf("%s must be >= 0", NetworkPeerListPullGossipFreqKey)
case config.PeerListBloomResetFreq < 0:
return network.Config{}, fmt.Errorf("%s must be >= 0", NetworkPeerListBloomResetFreqKey)
case config.PeersPullGossipFreq < 0:
return network.Config{}, fmt.Errorf("%s must be >= 0", NetworkPeersPullGossipFreqKey)
case config.PeersBloomResetFreq < 0:
return network.Config{}, fmt.Errorf("%s must be >= 0", NetworkPeersBloomResetFreqKey)
case config.ThrottlerConfig.InboundMsgThrottlerConfig.CPUThrottlerConfig.MaxRecheckDelay < constants.MinInboundThrottlerMaxRecheckDelay:
return network.Config{}, fmt.Errorf("%s must be >= %d", InboundThrottlerCPUMaxRecheckDelayKey, constants.MinInboundThrottlerMaxRecheckDelay)
case config.ThrottlerConfig.InboundMsgThrottlerConfig.DiskThrottlerConfig.MaxRecheckDelay < constants.MinInboundThrottlerMaxRecheckDelay:
Expand Down
8 changes: 4 additions & 4 deletions config/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,10 @@ func addNodeFlags(fs *pflag.FlagSet) {
fs.Bool(LogRotaterCompressEnabledKey, false, "Enables the compression of rotated log files through gzip.")
fs.Bool(LogDisableDisplayPluginLogsKey, false, "Disables displaying plugin logs in stdout.")

// Peer List Gossip
fs.Uint(NetworkPeerListNumValidatorIPsKey, constants.DefaultNetworkPeerListNumValidatorIPs, "Number of validator IPs to gossip to other nodes")
fs.Duration(NetworkPeerListPullGossipFreqKey, constants.DefaultNetworkPeerListPullGossipFreq, "Frequency to request peers from other nodes")
fs.Duration(NetworkPeerListBloomResetFreqKey, constants.DefaultNetworkPeerListBloomResetFreq, "Frequency to recalculate the bloom filter used to request new peers from other nodes")
// Peers Gossip
fs.Uint(NetworkPeersNumValidatorIPsKey, constants.DefaultNetworkPeersNumValidatorIPs, "Number of validator IPs to gossip to other nodes")
fs.Duration(NetworkPeersPullGossipFreqKey, constants.DefaultNetworkPeersPullGossipFreq, "Frequency to request peers from other nodes")
fs.Duration(NetworkPeersBloomResetFreqKey, constants.DefaultNetworkPeersBloomResetFreq, "Frequency to recalculate the bloom filter used to request new peers from other nodes")

// Public IP Resolution
fs.String(PublicIPKey, "", "Public IP of this node for P2P communication")
Expand Down
6 changes: 3 additions & 3 deletions config/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ const (
NetworkHealthMaxPortionSendQueueFillKey = "network-health-max-portion-send-queue-full"
NetworkHealthMaxSendFailRateKey = "network-health-max-send-fail-rate"
NetworkHealthMaxOutstandingDurationKey = "network-health-max-outstanding-request-duration"
NetworkPeerListNumValidatorIPsKey = "network-peer-list-num-validator-ips"
NetworkPeerListPullGossipFreqKey = "network-peer-list-pull-gossip-frequency"
NetworkPeerListBloomResetFreqKey = "network-peer-list-bloom-reset-frequency"
NetworkPeersNumValidatorIPsKey = "network-peers-num-validator-ips"
NetworkPeersPullGossipFreqKey = "network-peers-pull-gossip-frequency"
NetworkPeersBloomResetFreqKey = "network-peers-bloom-reset-frequency"
NetworkInitialReconnectDelayKey = "network-initial-reconnect-delay"
NetworkReadHandshakeTimeoutKey = "network-read-handshake-timeout"
NetworkPingTimeoutKey = "network-ping-timeout"
Expand Down
24 changes: 12 additions & 12 deletions message/messages_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,10 @@ func TestMessage(t *testing.T) {
},
{
desc: "get_peer_list message with no compression",
op: GetPeerListOp,
op: GetPeersOp,
msg: &p2p.Message{
Message: &p2p.Message_GetPeerList{
GetPeerList: &p2p.GetPeerList{
Message: &p2p.Message_GetPeers{
GetPeers: &p2p.GetPeers{
KnownPeers: &p2p.BloomFilter{
Filter: make([]byte, 2048),
Salt: make([]byte, 32),
Expand All @@ -136,10 +136,10 @@ func TestMessage(t *testing.T) {
},
{
desc: "get_peer_list message with zstd compression",
op: GetPeerListOp,
op: GetPeersOp,
msg: &p2p.Message{
Message: &p2p.Message_GetPeerList{
GetPeerList: &p2p.GetPeerList{
Message: &p2p.Message_GetPeers{
GetPeers: &p2p.GetPeers{
KnownPeers: &p2p.BloomFilter{
Filter: make([]byte, 2048),
Salt: make([]byte, 32),
Expand All @@ -153,10 +153,10 @@ func TestMessage(t *testing.T) {
},
{
desc: "peer_list message with no compression",
op: PeerListOp,
op: PeersOp,
msg: &p2p.Message{
Message: &p2p.Message_PeerList_{
PeerList_: &p2p.PeerList{
Message: &p2p.Message_Peers_{
Peers_: &p2p.Peers{
ClaimedIpPorts: []*p2p.ClaimedIpPort{
{
X509Certificate: testTLSCert.Certificate[0],
Expand All @@ -175,10 +175,10 @@ func TestMessage(t *testing.T) {
},
{
desc: "peer_list message with zstd compression",
op: PeerListOp,
op: PeersOp,
msg: &p2p.Message{
Message: &p2p.Message_PeerList_{
PeerList_: &p2p.PeerList{
Message: &p2p.Message_Peers_{
Peers_: &p2p.Peers{
ClaimedIpPorts: []*p2p.ClaimedIpPort{
{
X509Certificate: testTLSCert.Certificate[0],
Expand Down
24 changes: 12 additions & 12 deletions message/mock_outbound_message_builder.go

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

32 changes: 16 additions & 16 deletions message/ops.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ const (
PingOp Op = iota
PongOp
HandshakeOp
GetPeerListOp
PeerListOp
GetPeersOp
PeersOp
// State sync:
GetStateSummaryFrontierOp
GetStateSummaryFrontierFailedOp
Expand Down Expand Up @@ -72,8 +72,8 @@ var (
PingOp,
PongOp,
HandshakeOp,
GetPeerListOp,
PeerListOp,
GetPeersOp,
PeersOp,
}

// List of all consensus request message types
Expand Down Expand Up @@ -211,10 +211,10 @@ func (op Op) String() string {
return "pong"
case HandshakeOp:
return "handshake"
case GetPeerListOp:
return "get_peerlist"
case PeerListOp:
return "peerlist"
case GetPeersOp:
return "get_peers"
case PeersOp:
return "peers"
// State sync
case GetStateSummaryFrontierOp:
return "get_state_summary_frontier"
Expand Down Expand Up @@ -305,10 +305,10 @@ func Unwrap(m *p2p.Message) (fmt.Stringer, error) {
return msg.Pong, nil
case *p2p.Message_Handshake:
return msg.Handshake, nil
case *p2p.Message_GetPeerList:
return msg.GetPeerList, nil
case *p2p.Message_PeerList_:
return msg.PeerList_, nil
case *p2p.Message_GetPeers:
return msg.GetPeers, nil
case *p2p.Message_Peers_:
return msg.Peers_, nil
// State sync:
case *p2p.Message_GetStateSummaryFrontier:
return msg.GetStateSummaryFrontier, nil
Expand Down Expand Up @@ -364,10 +364,10 @@ func ToOp(m *p2p.Message) (Op, error) {
return PongOp, nil
case *p2p.Message_Handshake:
return HandshakeOp, nil
case *p2p.Message_GetPeerList:
return GetPeerListOp, nil
case *p2p.Message_PeerList_:
return PeerListOp, nil
case *p2p.Message_GetPeers:
return GetPeersOp, nil
case *p2p.Message_Peers_:
return PeersOp, nil
case *p2p.Message_GetStateSummaryFrontier:
return GetStateSummaryFrontierOp, nil
case *p2p.Message_StateSummaryFrontier_:
Expand Down
16 changes: 8 additions & 8 deletions message/outbound_msg_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ type OutboundMsgBuilder interface {
knownPeersSalt []byte,
) (OutboundMessage, error)

GetPeerList(
GetPeers(
knownPeersFilter []byte,
knownPeersSalt []byte,
) (OutboundMessage, error)

PeerList(
Peers(
peers []*ips.ClaimedIPPort,
bypassThrottling bool,
) (OutboundMessage, error)
Expand Down Expand Up @@ -279,14 +279,14 @@ func (b *outMsgBuilder) Handshake(
)
}

func (b *outMsgBuilder) GetPeerList(
func (b *outMsgBuilder) GetPeers(
knownPeersFilter []byte,
knownPeersSalt []byte,
) (OutboundMessage, error) {
return b.builder.createOutbound(
&p2p.Message{
Message: &p2p.Message_GetPeerList{
GetPeerList: &p2p.GetPeerList{
Message: &p2p.Message_GetPeers{
GetPeers: &p2p.GetPeers{
KnownPeers: &p2p.BloomFilter{
Filter: knownPeersFilter,
Salt: knownPeersSalt,
Expand All @@ -299,7 +299,7 @@ func (b *outMsgBuilder) GetPeerList(
)
}

func (b *outMsgBuilder) PeerList(peers []*ips.ClaimedIPPort, bypassThrottling bool) (OutboundMessage, error) {
func (b *outMsgBuilder) Peers(peers []*ips.ClaimedIPPort, bypassThrottling bool) (OutboundMessage, error) {
claimIPPorts := make([]*p2p.ClaimedIpPort, len(peers))
for i, p := range peers {
// TODO: Use .AsSlice() after v1.12.x activates.
Expand All @@ -315,8 +315,8 @@ func (b *outMsgBuilder) PeerList(peers []*ips.ClaimedIPPort, bypassThrottling bo
}
return b.builder.createOutbound(
&p2p.Message{
Message: &p2p.Message_PeerList_{
PeerList_: &p2p.PeerList{
Message: &p2p.Message_Peers_{
Peers_: &p2p.Peers{
ClaimedIpPorts: claimIPPorts,
},
},
Expand Down
24 changes: 12 additions & 12 deletions network/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,18 @@ type HealthConfig struct {
SendFailRateHalflife time.Duration `json:"sendFailRateHalflife"`
}

type PeerListGossipConfig struct {
// PeerListNumValidatorIPs is the number of validator IPs to gossip in every
type PeersGossipConfig struct {
// PeersNumValidatorIPs is the number of validator IPs to gossip in every
// gossip event.
PeerListNumValidatorIPs uint32 `json:"peerListNumValidatorIPs"`
PeersNumValidatorIPs uint32 `json:"peersNumValidatorIPs"`

// PeerListPullGossipFreq is the frequency that this node will attempt to
// PeersPullGossipFreq is the frequency that this node will attempt to
// request signed IPs from its peers.
PeerListPullGossipFreq time.Duration `json:"peerListPullGossipFreq"`
PeersPullGossipFreq time.Duration `json:"peersPullGossipFreq"`

// PeerListBloomResetFreq is how frequently this node will recalculate the
// PeersBloomResetFreq is how frequently this node will recalculate the
// IP tracker's bloom filter.
PeerListBloomResetFreq time.Duration `json:"peerListBloomResetFreq"`
PeersBloomResetFreq time.Duration `json:"peersBloomResetFreq"`
}

type TimeoutConfig struct {
Expand Down Expand Up @@ -97,11 +97,11 @@ type ThrottlerConfig struct {
}

type Config struct {
HealthConfig `json:"healthConfig"`
PeerListGossipConfig `json:"peerListGossipConfig"`
TimeoutConfig `json:"timeoutConfigs"`
DelayConfig `json:"delayConfig"`
ThrottlerConfig ThrottlerConfig `json:"throttlerConfig"`
HealthConfig `json:"healthConfig"`
PeersGossipConfig `json:"peersGossipConfig"`
TimeoutConfig `json:"timeoutConfigs"`
DelayConfig `json:"delayConfig"`
ThrottlerConfig ThrottlerConfig `json:"throttlerConfig"`

ProxyEnabled bool `json:"proxyEnabled"`
ProxyReadHeaderTimeout time.Duration `json:"proxyReadHeaderTimeout"`
Expand Down
10 changes: 5 additions & 5 deletions network/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type metrics struct {
inboundConnRateLimited prometheus.Counter
inboundConnAllowed prometheus.Counter
tlsConnRejected prometheus.Counter
numUselessPeerListBytes prometheus.Counter
numUselessPeersBytes prometheus.Counter
nodeUptimeWeightedAverage prometheus.Gauge
nodeUptimeRewardingStake prometheus.Gauge
nodeSubnetUptimeWeightedAverage *prometheus.GaugeVec
Expand Down Expand Up @@ -96,9 +96,9 @@ func newMetrics(
Name: "tls_conn_rejected",
Help: "Times this node rejected a connection due to an unsupported TLS certificate",
}),
numUselessPeerListBytes: prometheus.NewCounter(prometheus.CounterOpts{
Name: "num_useless_peerlist_bytes",
Help: "Amount of useless bytes (i.e. information about nodes we already knew/don't want to connect to) received in PeerList messages",
numUselessPeersBytes: prometheus.NewCounter(prometheus.CounterOpts{
Name: "num_useless_peers_bytes",
Help: "Amount of useless bytes (i.e. information about nodes we already knew/don't want to connect to) received in Peers messages",
}),
inboundConnRateLimited: prometheus.NewCounter(prometheus.CounterOpts{
Name: "inbound_conn_throttler_rate_limited",
Expand Down Expand Up @@ -147,7 +147,7 @@ func newMetrics(
registerer.Register(m.acceptFailed),
registerer.Register(m.inboundConnAllowed),
registerer.Register(m.tlsConnRejected),
registerer.Register(m.numUselessPeerListBytes),
registerer.Register(m.numUselessPeersBytes),
registerer.Register(m.inboundConnRateLimited),
registerer.Register(m.nodeUptimeWeightedAverage),
registerer.Register(m.nodeUptimeRewardingStake),
Expand Down
Loading