Skip to content

Commit c1bdcdb

Browse files
authored
Merge branch 'master' into powerslider/4416-migrate-message-coreth
2 parents 479821c + edf6750 commit c1bdcdb

File tree

7 files changed

+1139
-145
lines changed

7 files changed

+1139
-145
lines changed

network/config.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,4 +181,8 @@ type Config struct {
181181
// Specifies how much disk usage each peer can cause before
182182
// we rate-limit them.
183183
DiskTargeter tracker.Targeter `json:"-"`
184+
185+
// If true, connects to all validators regardless of primary network validator
186+
// status or of configured tracked subnets.
187+
ConnectToAllValidators bool `json:"connectToAllValidators"`
184188
}

network/ip_tracker.go

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ func newIPTracker(
4444
trackedSubnets set.Set[ids.ID],
4545
log logging.Logger,
4646
registerer prometheus.Registerer,
47+
connectToAllValidators bool,
4748
) (*ipTracker, error) {
4849
bloomMetrics, err := bloom.NewMetrics("ip_bloom", registerer)
4950
if err != nil {
@@ -64,11 +65,12 @@ func newIPTracker(
6465
Name: "tracked_subnets",
6566
Help: "number of subnets this node is monitoring",
6667
}),
67-
bloomMetrics: bloomMetrics,
68-
tracked: make(map[ids.NodeID]*trackedNode),
69-
bloomAdditions: make(map[ids.NodeID]int),
70-
connected: make(map[ids.NodeID]*connectedNode),
71-
subnet: make(map[ids.ID]*gossipableSubnet),
68+
connectToAllValidators: connectToAllValidators,
69+
bloomMetrics: bloomMetrics,
70+
tracked: make(map[ids.NodeID]*trackedNode),
71+
bloomAdditions: make(map[ids.NodeID]int),
72+
connected: make(map[ids.NodeID]*connectedNode),
73+
subnet: make(map[ids.ID]*gossipableSubnet),
7274
}
7375
err = errors.Join(
7476
registerer.Register(tracker.numTrackedPeers),
@@ -230,6 +232,8 @@ type ipTracker struct {
230232
connected map[ids.NodeID]*connectedNode
231233
// subnet tracks all the subnets that have at least one gossipable ID.
232234
subnet map[ids.ID]*gossipableSubnet
235+
236+
connectToAllValidators bool
233237
}
234238

235239
// ManuallyTrack marks the provided nodeID as being desirable to connect to.
@@ -267,6 +271,7 @@ func (i *ipTracker) ManuallyGossip(subnetID ids.ID, nodeID ids.NodeID) {
267271
// 1. The node has been manually tracked.
268272
// 2. The node has been manually gossiped on a tracked subnet.
269273
// 3. The node is currently a validator on a tracked subnet.
274+
// 4. The node is currently a validator on any subnet and connectToAllValidators is true.
270275
func (i *ipTracker) WantsConnection(nodeID ids.NodeID) bool {
271276
i.lock.RLock()
272277
defer i.lock.RUnlock()
@@ -305,6 +310,7 @@ func (i *ipTracker) ShouldVerifyIP(
305310
// 1. The provided IP is from a node whose connection is desired on a tracked
306311
// subnet.
307312
// 2. This IP is newer than the most recent IP we know of for the node.
313+
// 3. The node is a validator and connectToAllValidators is true.
308314
//
309315
// If this IP is replacing a gossipable IP, this IP will also be marked as
310316
// gossipable.
@@ -428,7 +434,7 @@ func (i *ipTracker) addTrackableID(nodeID ids.NodeID, subnetID *ids.ID) {
428434
nodeTracker.manuallyTracked = true
429435
} else {
430436
nodeTracker.validatedSubnets.Add(*subnetID)
431-
if *subnetID == constants.PrimaryNetworkID || i.trackedSubnets.Contains(*subnetID) {
437+
if *subnetID == constants.PrimaryNetworkID || i.trackedSubnets.Contains(*subnetID) || i.connectToAllValidators {
432438
nodeTracker.trackedSubnets.Add(*subnetID)
433439
}
434440
}

0 commit comments

Comments
 (0)