From 69a7baefd8986a2d651cedf1ca9a74f94a5f690b Mon Sep 17 00:00:00 2001 From: Csaba Kiraly Date: Mon, 13 Apr 2026 19:13:12 +0200 Subject: [PATCH] eth: drop skipped_protected metric and simplify dropper skip path The skipped_protected metric (added earlier on this branch) counted the subset of drop skips where inclusion protection was the cause. The signal can be inferred from rising dropSkipped rate plus the existing "Protecting high-value peers" debug log, which wasn't worth the second metric, the causality-check loop over the protected set, and the baseNotDrop closure extracted solely to share the predicate. Collapse baseNotDrop back into selectDoNotDrop and remove the metric. dropSkipped still fires on every skip (fast-path headroom + all-filtered). --- eth/dropper.go | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/eth/dropper.go b/eth/dropper.go index 741ca5cbd2..d3eb718e6a 100644 --- a/eth/dropper.go +++ b/eth/dropper.go @@ -56,10 +56,6 @@ var ( // for any reason (pool has headroom, all candidates trusted/static/young, // or protected by inclusion stats). dropSkipped = metrics.NewRegisteredMeter("eth/dropper/skipped", nil) - // dropSkippedProtected counts the subset of skips caused specifically by - // inclusion-based peer protection: at least one otherwise-droppable peer - // was kept only because it was in the protected set. - dropSkippedProtected = metrics.NewRegisteredMeter("eth/dropper/skipped_protected", nil) ) // PeerInclusionStats holds the per-peer inclusion data needed by the dropper @@ -181,27 +177,17 @@ func (cm *dropper) dropRandomPeer() bool { // Compute the set of inclusion-protected peers before filtering. protected := cm.protectedPeers(peers) - baseNotDrop := func(p *p2p.Peer) bool { + selectDoNotDrop := func(p *p2p.Peer) bool { return p.Trusted() || p.StaticDialed() || p.Lifetime() < mclock.AbsTime(doNotDropBefore) || (p.DynDialed() && cm.maxDialPeers-numDialed > peerDropThreshold) || - (p.Inbound() && cm.maxInboundPeers-numInbound > peerDropThreshold) - } - selectDoNotDrop := func(p *p2p.Peer) bool { - return baseNotDrop(p) || protected[p] + (p.Inbound() && cm.maxInboundPeers-numInbound > peerDropThreshold) || + protected[p] } droppable := slices.DeleteFunc(peers, selectDoNotDrop) if len(droppable) == 0 { dropSkipped.Mark(1) - // If any protected peer would otherwise have been droppable, - // protection was the cause of the skip. - for p := range protected { - if !baseNotDrop(p) { - dropSkippedProtected.Mark(1) - break - } - } return false } p := droppable[mrand.Intn(len(droppable))]