Skip to content

Commit 5793120

Browse files
Remove peerlist push gossip (#2791)
1 parent 66ae8ef commit 5793120

File tree

9 files changed

+20
-126
lines changed

9 files changed

+20
-126
lines changed

config/config.go

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ const (
5555

5656
keystoreDeprecationMsg = "keystore API is deprecated"
5757
acceptedFrontierGossipDeprecationMsg = "push-based accepted frontier gossip is deprecated"
58-
peerListPushGossipDeprecationMsg = "push-based peer list gossip is deprecated"
5958
)
6059

6160
var (
@@ -72,11 +71,6 @@ var (
7271
ConsensusGossipOnAcceptNonValidatorSizeKey: acceptedFrontierGossipDeprecationMsg,
7372
ConsensusGossipOnAcceptPeerSizeKey: acceptedFrontierGossipDeprecationMsg,
7473

75-
NetworkPeerListValidatorGossipSizeKey: peerListPushGossipDeprecationMsg,
76-
NetworkPeerListNonValidatorGossipSizeKey: peerListPushGossipDeprecationMsg,
77-
NetworkPeerListPeersGossipSizeKey: peerListPushGossipDeprecationMsg,
78-
NetworkPeerListGossipFreqKey: peerListPushGossipDeprecationMsg,
79-
8074
SnowRogueCommitThresholdKey: commitThresholdDeprecationMsg,
8175
SnowVirtuousCommitThresholdKey: commitThresholdDeprecationMsg,
8276
}
@@ -386,13 +380,9 @@ func getNetworkConfig(
386380
},
387381

388382
PeerListGossipConfig: network.PeerListGossipConfig{
389-
PeerListNumValidatorIPs: v.GetUint32(NetworkPeerListNumValidatorIPsKey),
390-
PeerListValidatorGossipSize: v.GetUint32(NetworkPeerListValidatorGossipSizeKey),
391-
PeerListNonValidatorGossipSize: v.GetUint32(NetworkPeerListNonValidatorGossipSizeKey),
392-
PeerListPeersGossipSize: v.GetUint32(NetworkPeerListPeersGossipSizeKey),
393-
PeerListGossipFreq: v.GetDuration(NetworkPeerListGossipFreqKey),
394-
PeerListPullGossipFreq: v.GetDuration(NetworkPeerListPullGossipFreqKey),
395-
PeerListBloomResetFreq: v.GetDuration(NetworkPeerListBloomResetFreqKey),
383+
PeerListNumValidatorIPs: v.GetUint32(NetworkPeerListNumValidatorIPsKey),
384+
PeerListPullGossipFreq: v.GetDuration(NetworkPeerListPullGossipFreqKey),
385+
PeerListBloomResetFreq: v.GetDuration(NetworkPeerListBloomResetFreqKey),
396386
},
397387

398388
DelayConfig: network.DelayConfig{
@@ -426,8 +416,6 @@ func getNetworkConfig(
426416
return network.Config{}, fmt.Errorf("%s must be in [0,1]", NetworkHealthMaxPortionSendQueueFillKey)
427417
case config.DialerConfig.ConnectionTimeout < 0:
428418
return network.Config{}, fmt.Errorf("%q must be >= 0", NetworkOutboundConnectionTimeoutKey)
429-
case config.PeerListGossipFreq < 0:
430-
return network.Config{}, fmt.Errorf("%s must be >= 0", NetworkPeerListGossipFreqKey)
431419
case config.PeerListPullGossipFreq < 0:
432420
return network.Config{}, fmt.Errorf("%s must be >= 0", NetworkPeerListPullGossipFreqKey)
433421
case config.PeerListBloomResetFreq < 0:

config/flags.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,6 @@ func addNodeFlags(fs *pflag.FlagSet) {
128128

129129
// Peer List Gossip
130130
fs.Uint(NetworkPeerListNumValidatorIPsKey, constants.DefaultNetworkPeerListNumValidatorIPs, "Number of validator IPs to gossip to other nodes")
131-
fs.Uint(NetworkPeerListValidatorGossipSizeKey, constants.DefaultNetworkPeerListValidatorGossipSize, "Number of validators that the node will gossip peer list to")
132-
fs.Uint(NetworkPeerListNonValidatorGossipSizeKey, constants.DefaultNetworkPeerListNonValidatorGossipSize, "Number of non-validators that the node will gossip peer list to")
133-
fs.Uint(NetworkPeerListPeersGossipSizeKey, constants.DefaultNetworkPeerListPeersGossipSize, "Number of total peers (including non-validators and validators) that the node will gossip peer list to")
134-
fs.Duration(NetworkPeerListGossipFreqKey, constants.DefaultNetworkPeerListGossipFreq, "Frequency to gossip peers to other nodes")
135131
fs.Duration(NetworkPeerListPullGossipFreqKey, constants.DefaultNetworkPeerListPullGossipFreq, "Frequency to request peers from other nodes")
136132
fs.Duration(NetworkPeerListBloomResetFreqKey, constants.DefaultNetworkPeerListBloomResetFreq, "Frequency to recalculate the bloom filter used to request new peers from other nodes")
137133

config/keys.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,6 @@ const (
8787
NetworkHealthMaxSendFailRateKey = "network-health-max-send-fail-rate"
8888
NetworkHealthMaxOutstandingDurationKey = "network-health-max-outstanding-request-duration"
8989
NetworkPeerListNumValidatorIPsKey = "network-peer-list-num-validator-ips"
90-
NetworkPeerListValidatorGossipSizeKey = "network-peer-list-validator-gossip-size"
91-
NetworkPeerListNonValidatorGossipSizeKey = "network-peer-list-non-validator-gossip-size"
92-
NetworkPeerListPeersGossipSizeKey = "network-peer-list-peers-gossip-size"
93-
NetworkPeerListGossipFreqKey = "network-peer-list-gossip-frequency"
9490
NetworkPeerListPullGossipFreqKey = "network-peer-list-pull-gossip-frequency"
9591
NetworkPeerListBloomResetFreqKey = "network-peer-list-bloom-reset-frequency"
9692
NetworkInitialReconnectDelayKey = "network-initial-reconnect-delay"

network/config.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -58,22 +58,6 @@ type PeerListGossipConfig struct {
5858
// gossip event.
5959
PeerListNumValidatorIPs uint32 `json:"peerListNumValidatorIPs"`
6060

61-
// PeerListValidatorGossipSize is the number of validators to gossip the IPs
62-
// to in every IP gossip event.
63-
PeerListValidatorGossipSize uint32 `json:"peerListValidatorGossipSize"`
64-
65-
// PeerListNonValidatorGossipSize is the number of non-validators to gossip
66-
// the IPs to in every IP gossip event.
67-
PeerListNonValidatorGossipSize uint32 `json:"peerListNonValidatorGossipSize"`
68-
69-
// PeerListPeersGossipSize is the number of peers to gossip
70-
// the IPs to in every IP gossip event.
71-
PeerListPeersGossipSize uint32 `json:"peerListPeersGossipSize"`
72-
73-
// PeerListGossipFreq is the frequency that this node will attempt to gossip
74-
// signed IPs to its peers.
75-
PeerListGossipFreq time.Duration `json:"peerListGossipFreq"`
76-
7761
// PeerListPullGossipFreq is the frequency that this node will attempt to
7862
// request signed IPs from its peers.
7963
PeerListPullGossipFreq time.Duration `json:"peerListPullGossipFreq"`

network/network.go

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,12 +1157,10 @@ func (n *network) NodeUptime(subnetID ids.ID) (UptimeResult, error) {
11571157
}
11581158

11591159
func (n *network) runTimers() {
1160-
pushGossipPeerlists := time.NewTicker(n.config.PeerListGossipFreq)
11611160
pullGossipPeerlists := time.NewTicker(n.config.PeerListPullGossipFreq)
11621161
resetPeerListBloom := time.NewTicker(n.config.PeerListBloomResetFreq)
11631162
updateUptimes := time.NewTicker(n.config.UptimeMetricFreq)
11641163
defer func() {
1165-
pushGossipPeerlists.Stop()
11661164
resetPeerListBloom.Stop()
11671165
updateUptimes.Stop()
11681166
}()
@@ -1171,8 +1169,6 @@ func (n *network) runTimers() {
11711169
select {
11721170
case <-n.onCloseCtx.Done():
11731171
return
1174-
case <-pushGossipPeerlists.C:
1175-
n.pushGossipPeerLists()
11761172
case <-pullGossipPeerlists.C:
11771173
n.pullGossipPeerLists()
11781174
case <-resetPeerListBloom.C:
@@ -1209,21 +1205,6 @@ func (n *network) runTimers() {
12091205
}
12101206
}
12111207

1212-
// pushGossipPeerLists gossips validators to peers in the network
1213-
func (n *network) pushGossipPeerLists() {
1214-
peers := n.samplePeers(
1215-
constants.PrimaryNetworkID,
1216-
int(n.config.PeerListValidatorGossipSize),
1217-
int(n.config.PeerListNonValidatorGossipSize),
1218-
int(n.config.PeerListPeersGossipSize),
1219-
subnets.NoOpAllower,
1220-
)
1221-
1222-
for _, p := range peers {
1223-
p.StartSendPeerList()
1224-
}
1225-
}
1226-
12271208
// pullGossipPeerLists requests validators from peers in the network
12281209
func (n *network) pullGossipPeerLists() {
12291210
peers := n.samplePeers(

network/network_test.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,9 @@ var (
4949
SendFailRateHalflife: time.Second,
5050
}
5151
defaultPeerListGossipConfig = PeerListGossipConfig{
52-
PeerListNumValidatorIPs: 100,
53-
PeerListValidatorGossipSize: 100,
54-
PeerListNonValidatorGossipSize: 100,
55-
PeerListPeersGossipSize: 100,
56-
PeerListGossipFreq: time.Second,
57-
PeerListPullGossipFreq: time.Second,
58-
PeerListBloomResetFreq: constants.DefaultNetworkPeerListBloomResetFreq,
52+
PeerListNumValidatorIPs: 100,
53+
PeerListPullGossipFreq: time.Second,
54+
PeerListBloomResetFreq: constants.DefaultNetworkPeerListBloomResetFreq,
5955
}
6056
defaultTimeoutConfig = TimeoutConfig{
6157
PingPongTimeout: 30 * time.Second,

network/peer/peer.go

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,6 @@ type Peer interface {
9292
// guaranteed not to be delivered to the peer.
9393
Send(ctx context.Context, msg message.OutboundMessage) bool
9494

95-
// StartSendPeerList attempts to send a PeerList message to this peer on
96-
// this peer's gossip routine. It is not guaranteed that a PeerList will be
97-
// sent.
98-
StartSendPeerList()
99-
10095
// StartSendGetPeerList attempts to send a GetPeerList message to this peer
10196
// on this peer's gossip routine. It is not guaranteed that a GetPeerList
10297
// will be sent.
@@ -186,10 +181,6 @@ type peer struct {
186181
// Must only be accessed atomically
187182
lastSent, lastReceived int64
188183

189-
// peerListChan signals that we should attempt to send a PeerList to this
190-
// peer
191-
peerListChan chan struct{}
192-
193184
// getPeerListChan signals that we should attempt to send a GetPeerList to
194185
// this peer
195186
getPeerListChan chan struct{}
@@ -219,7 +210,6 @@ func Start(
219210
onClosingCtxCancel: onClosingCtxCancel,
220211
onClosed: make(chan struct{}),
221212
observedUptimes: make(map[ids.ID]uint32),
222-
peerListChan: make(chan struct{}, 1),
223213
getPeerListChan: make(chan struct{}, 1),
224214
}
225215

@@ -327,13 +317,6 @@ func (p *peer) Send(ctx context.Context, msg message.OutboundMessage) bool {
327317
return p.messageQueue.Push(ctx, msg)
328318
}
329319

330-
func (p *peer) StartSendPeerList() {
331-
select {
332-
case p.peerListChan <- struct{}{}:
333-
default:
334-
}
335-
}
336-
337320
func (p *peer) StartSendGetPeerList() {
338321
select {
339322
case p.getPeerListChan <- struct{}{}:
@@ -656,32 +639,6 @@ func (p *peer) sendNetworkMessages() {
656639

657640
for {
658641
select {
659-
case <-p.peerListChan:
660-
peerIPs := p.Config.Network.Peers(p.id, bloom.EmptyFilter, nil)
661-
if len(peerIPs) == 0 {
662-
p.Log.Verbo(
663-
"skipping peer gossip as there are no unknown peers",
664-
zap.Stringer("nodeID", p.id),
665-
)
666-
continue
667-
}
668-
669-
// Bypass throttling is disabled here to follow the non-handshake
670-
// message sending pattern.
671-
msg, err := p.Config.MessageCreator.PeerList(peerIPs, false /*=bypassThrottling*/)
672-
if err != nil {
673-
p.Log.Error("failed to create peer list message",
674-
zap.Stringer("nodeID", p.id),
675-
zap.Error(err),
676-
)
677-
continue
678-
}
679-
680-
if !p.Send(p.onClosingCtx, msg) {
681-
p.Log.Debug("failed to send peer list",
682-
zap.Stringer("nodeID", p.id),
683-
)
684-
}
685642
case <-p.getPeerListChan:
686643
knownPeersFilter, knownPeersSalt := p.Config.Network.KnownPeers()
687644
msg, err := p.Config.MessageCreator.GetPeerList(knownPeersFilter, knownPeersSalt)

network/test_network.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -152,13 +152,9 @@ func NewTestNetwork(
152152
},
153153

154154
PeerListGossipConfig: PeerListGossipConfig{
155-
PeerListNumValidatorIPs: constants.DefaultNetworkPeerListNumValidatorIPs,
156-
PeerListValidatorGossipSize: constants.DefaultNetworkPeerListValidatorGossipSize,
157-
PeerListNonValidatorGossipSize: constants.DefaultNetworkPeerListNonValidatorGossipSize,
158-
PeerListPeersGossipSize: constants.DefaultNetworkPeerListPeersGossipSize,
159-
PeerListGossipFreq: constants.DefaultNetworkPeerListGossipFreq,
160-
PeerListPullGossipFreq: constants.DefaultNetworkPeerListPullGossipFreq,
161-
PeerListBloomResetFreq: constants.DefaultNetworkPeerListBloomResetFreq,
155+
PeerListNumValidatorIPs: constants.DefaultNetworkPeerListNumValidatorIPs,
156+
PeerListPullGossipFreq: constants.DefaultNetworkPeerListPullGossipFreq,
157+
PeerListBloomResetFreq: constants.DefaultNetworkPeerListBloomResetFreq,
162158
},
163159

164160
DelayConfig: DelayConfig{

tests/fixture/tmpnet/defaults.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,17 @@ const (
3838
func DefaultFlags() FlagsMap {
3939
// Supply only non-default configuration to ensure that default values will be used.
4040
return FlagsMap{
41-
config.NetworkPeerListGossipFreqKey: "250ms",
42-
config.NetworkMaxReconnectDelayKey: "1s",
43-
config.PublicIPKey: "127.0.0.1",
44-
config.HTTPHostKey: "127.0.0.1",
45-
config.StakingHostKey: "127.0.0.1",
46-
config.HealthCheckFreqKey: "2s",
47-
config.AdminAPIEnabledKey: true,
48-
config.IndexEnabledKey: true,
49-
config.LogDisplayLevelKey: "INFO",
50-
config.LogLevelKey: "DEBUG",
51-
config.MinStakeDurationKey: DefaultMinStakeDuration.String(),
41+
config.NetworkPeerListPullGossipFreqKey: "250ms",
42+
config.NetworkMaxReconnectDelayKey: "1s",
43+
config.PublicIPKey: "127.0.0.1",
44+
config.HTTPHostKey: "127.0.0.1",
45+
config.StakingHostKey: "127.0.0.1",
46+
config.HealthCheckFreqKey: "2s",
47+
config.AdminAPIEnabledKey: true,
48+
config.IndexEnabledKey: true,
49+
config.LogDisplayLevelKey: "INFO",
50+
config.LogLevelKey: "DEBUG",
51+
config.MinStakeDurationKey: DefaultMinStakeDuration.String(),
5252
}
5353
}
5454

0 commit comments

Comments
 (0)