Skip to content

Commit

Permalink
Remove peerlist push gossip (#2791)
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenButtolph authored Mar 6, 2024
1 parent 66ae8ef commit 5793120
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 126 deletions.
18 changes: 3 additions & 15 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ const (

keystoreDeprecationMsg = "keystore API is deprecated"
acceptedFrontierGossipDeprecationMsg = "push-based accepted frontier gossip is deprecated"
peerListPushGossipDeprecationMsg = "push-based peer list gossip is deprecated"
)

var (
Expand All @@ -72,11 +71,6 @@ var (
ConsensusGossipOnAcceptNonValidatorSizeKey: acceptedFrontierGossipDeprecationMsg,
ConsensusGossipOnAcceptPeerSizeKey: acceptedFrontierGossipDeprecationMsg,

NetworkPeerListValidatorGossipSizeKey: peerListPushGossipDeprecationMsg,
NetworkPeerListNonValidatorGossipSizeKey: peerListPushGossipDeprecationMsg,
NetworkPeerListPeersGossipSizeKey: peerListPushGossipDeprecationMsg,
NetworkPeerListGossipFreqKey: peerListPushGossipDeprecationMsg,

SnowRogueCommitThresholdKey: commitThresholdDeprecationMsg,
SnowVirtuousCommitThresholdKey: commitThresholdDeprecationMsg,
}
Expand Down Expand Up @@ -386,13 +380,9 @@ func getNetworkConfig(
},

PeerListGossipConfig: network.PeerListGossipConfig{
PeerListNumValidatorIPs: v.GetUint32(NetworkPeerListNumValidatorIPsKey),
PeerListValidatorGossipSize: v.GetUint32(NetworkPeerListValidatorGossipSizeKey),
PeerListNonValidatorGossipSize: v.GetUint32(NetworkPeerListNonValidatorGossipSizeKey),
PeerListPeersGossipSize: v.GetUint32(NetworkPeerListPeersGossipSizeKey),
PeerListGossipFreq: v.GetDuration(NetworkPeerListGossipFreqKey),
PeerListPullGossipFreq: v.GetDuration(NetworkPeerListPullGossipFreqKey),
PeerListBloomResetFreq: v.GetDuration(NetworkPeerListBloomResetFreqKey),
PeerListNumValidatorIPs: v.GetUint32(NetworkPeerListNumValidatorIPsKey),
PeerListPullGossipFreq: v.GetDuration(NetworkPeerListPullGossipFreqKey),
PeerListBloomResetFreq: v.GetDuration(NetworkPeerListBloomResetFreqKey),
},

DelayConfig: network.DelayConfig{
Expand Down Expand Up @@ -426,8 +416,6 @@ 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.PeerListGossipFreq < 0:
return network.Config{}, fmt.Errorf("%s must be >= 0", NetworkPeerListGossipFreqKey)
case config.PeerListPullGossipFreq < 0:
return network.Config{}, fmt.Errorf("%s must be >= 0", NetworkPeerListPullGossipFreqKey)
case config.PeerListBloomResetFreq < 0:
Expand Down
4 changes: 0 additions & 4 deletions config/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,6 @@ func addNodeFlags(fs *pflag.FlagSet) {

// Peer List Gossip
fs.Uint(NetworkPeerListNumValidatorIPsKey, constants.DefaultNetworkPeerListNumValidatorIPs, "Number of validator IPs to gossip to other nodes")
fs.Uint(NetworkPeerListValidatorGossipSizeKey, constants.DefaultNetworkPeerListValidatorGossipSize, "Number of validators that the node will gossip peer list to")
fs.Uint(NetworkPeerListNonValidatorGossipSizeKey, constants.DefaultNetworkPeerListNonValidatorGossipSize, "Number of non-validators that the node will gossip peer list to")
fs.Uint(NetworkPeerListPeersGossipSizeKey, constants.DefaultNetworkPeerListPeersGossipSize, "Number of total peers (including non-validators and validators) that the node will gossip peer list to")
fs.Duration(NetworkPeerListGossipFreqKey, constants.DefaultNetworkPeerListGossipFreq, "Frequency to gossip peers 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")

Expand Down
4 changes: 0 additions & 4 deletions config/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,6 @@ const (
NetworkHealthMaxSendFailRateKey = "network-health-max-send-fail-rate"
NetworkHealthMaxOutstandingDurationKey = "network-health-max-outstanding-request-duration"
NetworkPeerListNumValidatorIPsKey = "network-peer-list-num-validator-ips"
NetworkPeerListValidatorGossipSizeKey = "network-peer-list-validator-gossip-size"
NetworkPeerListNonValidatorGossipSizeKey = "network-peer-list-non-validator-gossip-size"
NetworkPeerListPeersGossipSizeKey = "network-peer-list-peers-gossip-size"
NetworkPeerListGossipFreqKey = "network-peer-list-gossip-frequency"
NetworkPeerListPullGossipFreqKey = "network-peer-list-pull-gossip-frequency"
NetworkPeerListBloomResetFreqKey = "network-peer-list-bloom-reset-frequency"
NetworkInitialReconnectDelayKey = "network-initial-reconnect-delay"
Expand Down
16 changes: 0 additions & 16 deletions network/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,22 +58,6 @@ type PeerListGossipConfig struct {
// gossip event.
PeerListNumValidatorIPs uint32 `json:"peerListNumValidatorIPs"`

// PeerListValidatorGossipSize is the number of validators to gossip the IPs
// to in every IP gossip event.
PeerListValidatorGossipSize uint32 `json:"peerListValidatorGossipSize"`

// PeerListNonValidatorGossipSize is the number of non-validators to gossip
// the IPs to in every IP gossip event.
PeerListNonValidatorGossipSize uint32 `json:"peerListNonValidatorGossipSize"`

// PeerListPeersGossipSize is the number of peers to gossip
// the IPs to in every IP gossip event.
PeerListPeersGossipSize uint32 `json:"peerListPeersGossipSize"`

// PeerListGossipFreq is the frequency that this node will attempt to gossip
// signed IPs to its peers.
PeerListGossipFreq time.Duration `json:"peerListGossipFreq"`

// PeerListPullGossipFreq is the frequency that this node will attempt to
// request signed IPs from its peers.
PeerListPullGossipFreq time.Duration `json:"peerListPullGossipFreq"`
Expand Down
19 changes: 0 additions & 19 deletions network/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -1157,12 +1157,10 @@ func (n *network) NodeUptime(subnetID ids.ID) (UptimeResult, error) {
}

func (n *network) runTimers() {
pushGossipPeerlists := time.NewTicker(n.config.PeerListGossipFreq)
pullGossipPeerlists := time.NewTicker(n.config.PeerListPullGossipFreq)
resetPeerListBloom := time.NewTicker(n.config.PeerListBloomResetFreq)
updateUptimes := time.NewTicker(n.config.UptimeMetricFreq)
defer func() {
pushGossipPeerlists.Stop()
resetPeerListBloom.Stop()
updateUptimes.Stop()
}()
Expand All @@ -1171,8 +1169,6 @@ func (n *network) runTimers() {
select {
case <-n.onCloseCtx.Done():
return
case <-pushGossipPeerlists.C:
n.pushGossipPeerLists()
case <-pullGossipPeerlists.C:
n.pullGossipPeerLists()
case <-resetPeerListBloom.C:
Expand Down Expand Up @@ -1209,21 +1205,6 @@ func (n *network) runTimers() {
}
}

// pushGossipPeerLists gossips validators to peers in the network
func (n *network) pushGossipPeerLists() {
peers := n.samplePeers(
constants.PrimaryNetworkID,
int(n.config.PeerListValidatorGossipSize),
int(n.config.PeerListNonValidatorGossipSize),
int(n.config.PeerListPeersGossipSize),
subnets.NoOpAllower,
)

for _, p := range peers {
p.StartSendPeerList()
}
}

// pullGossipPeerLists requests validators from peers in the network
func (n *network) pullGossipPeerLists() {
peers := n.samplePeers(
Expand Down
10 changes: 3 additions & 7 deletions network/network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,9 @@ var (
SendFailRateHalflife: time.Second,
}
defaultPeerListGossipConfig = PeerListGossipConfig{
PeerListNumValidatorIPs: 100,
PeerListValidatorGossipSize: 100,
PeerListNonValidatorGossipSize: 100,
PeerListPeersGossipSize: 100,
PeerListGossipFreq: time.Second,
PeerListPullGossipFreq: time.Second,
PeerListBloomResetFreq: constants.DefaultNetworkPeerListBloomResetFreq,
PeerListNumValidatorIPs: 100,
PeerListPullGossipFreq: time.Second,
PeerListBloomResetFreq: constants.DefaultNetworkPeerListBloomResetFreq,
}
defaultTimeoutConfig = TimeoutConfig{
PingPongTimeout: 30 * time.Second,
Expand Down
43 changes: 0 additions & 43 deletions network/peer/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,6 @@ type Peer interface {
// guaranteed not to be delivered to the peer.
Send(ctx context.Context, msg message.OutboundMessage) bool

// StartSendPeerList attempts to send a PeerList message to this peer on
// this peer's gossip routine. It is not guaranteed that a PeerList will be
// sent.
StartSendPeerList()

// StartSendGetPeerList attempts to send a GetPeerList message to this peer
// on this peer's gossip routine. It is not guaranteed that a GetPeerList
// will be sent.
Expand Down Expand Up @@ -186,10 +181,6 @@ type peer struct {
// Must only be accessed atomically
lastSent, lastReceived int64

// peerListChan signals that we should attempt to send a PeerList to this
// peer
peerListChan chan struct{}

// getPeerListChan signals that we should attempt to send a GetPeerList to
// this peer
getPeerListChan chan struct{}
Expand Down Expand Up @@ -219,7 +210,6 @@ func Start(
onClosingCtxCancel: onClosingCtxCancel,
onClosed: make(chan struct{}),
observedUptimes: make(map[ids.ID]uint32),
peerListChan: make(chan struct{}, 1),
getPeerListChan: make(chan struct{}, 1),
}

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

func (p *peer) StartSendPeerList() {
select {
case p.peerListChan <- struct{}{}:
default:
}
}

func (p *peer) StartSendGetPeerList() {
select {
case p.getPeerListChan <- struct{}{}:
Expand Down Expand Up @@ -656,32 +639,6 @@ func (p *peer) sendNetworkMessages() {

for {
select {
case <-p.peerListChan:
peerIPs := p.Config.Network.Peers(p.id, bloom.EmptyFilter, nil)
if len(peerIPs) == 0 {
p.Log.Verbo(
"skipping peer gossip as there are no unknown peers",
zap.Stringer("nodeID", p.id),
)
continue
}

// Bypass throttling is disabled here to follow the non-handshake
// message sending pattern.
msg, err := p.Config.MessageCreator.PeerList(peerIPs, false /*=bypassThrottling*/)
if err != nil {
p.Log.Error("failed to create peer list message",
zap.Stringer("nodeID", p.id),
zap.Error(err),
)
continue
}

if !p.Send(p.onClosingCtx, msg) {
p.Log.Debug("failed to send peer list",
zap.Stringer("nodeID", p.id),
)
}
case <-p.getPeerListChan:
knownPeersFilter, knownPeersSalt := p.Config.Network.KnownPeers()
msg, err := p.Config.MessageCreator.GetPeerList(knownPeersFilter, knownPeersSalt)
Expand Down
10 changes: 3 additions & 7 deletions network/test_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,9 @@ func NewTestNetwork(
},

PeerListGossipConfig: PeerListGossipConfig{
PeerListNumValidatorIPs: constants.DefaultNetworkPeerListNumValidatorIPs,
PeerListValidatorGossipSize: constants.DefaultNetworkPeerListValidatorGossipSize,
PeerListNonValidatorGossipSize: constants.DefaultNetworkPeerListNonValidatorGossipSize,
PeerListPeersGossipSize: constants.DefaultNetworkPeerListPeersGossipSize,
PeerListGossipFreq: constants.DefaultNetworkPeerListGossipFreq,
PeerListPullGossipFreq: constants.DefaultNetworkPeerListPullGossipFreq,
PeerListBloomResetFreq: constants.DefaultNetworkPeerListBloomResetFreq,
PeerListNumValidatorIPs: constants.DefaultNetworkPeerListNumValidatorIPs,
PeerListPullGossipFreq: constants.DefaultNetworkPeerListPullGossipFreq,
PeerListBloomResetFreq: constants.DefaultNetworkPeerListBloomResetFreq,
},

DelayConfig: DelayConfig{
Expand Down
22 changes: 11 additions & 11 deletions tests/fixture/tmpnet/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,17 @@ const (
func DefaultFlags() FlagsMap {
// Supply only non-default configuration to ensure that default values will be used.
return FlagsMap{
config.NetworkPeerListGossipFreqKey: "250ms",
config.NetworkMaxReconnectDelayKey: "1s",
config.PublicIPKey: "127.0.0.1",
config.HTTPHostKey: "127.0.0.1",
config.StakingHostKey: "127.0.0.1",
config.HealthCheckFreqKey: "2s",
config.AdminAPIEnabledKey: true,
config.IndexEnabledKey: true,
config.LogDisplayLevelKey: "INFO",
config.LogLevelKey: "DEBUG",
config.MinStakeDurationKey: DefaultMinStakeDuration.String(),
config.NetworkPeerListPullGossipFreqKey: "250ms",
config.NetworkMaxReconnectDelayKey: "1s",
config.PublicIPKey: "127.0.0.1",
config.HTTPHostKey: "127.0.0.1",
config.StakingHostKey: "127.0.0.1",
config.HealthCheckFreqKey: "2s",
config.AdminAPIEnabledKey: true,
config.IndexEnabledKey: true,
config.LogDisplayLevelKey: "INFO",
config.LogLevelKey: "DEBUG",
config.MinStakeDurationKey: DefaultMinStakeDuration.String(),
}
}

Expand Down

0 comments on commit 5793120

Please sign in to comment.