addrman: don't stall feelers when a tried collision is unreachable

bitcoin/bitcoin: PR #36932

1 minor finding · 3 suggestions

Findings

Link

[minor] · Fallback feelers can restart the collision timeout

When every pending incumbent is unreachable and stale, successful fallback feelers to a challenger can restart its 40-minute collision timeout and delay promotion to tried; no production occurrence was identified.

Location: src/net.cpp:2919 (head).

Details and suggested fix

If an unreachable incumbent's last success and last attempt are both older than ADDRMAN_REPLACEMENT (4 hours), resolution depends on the challenger's age. The new empty result reaches Select(true, reachable_nets), which can select that challenger because it remains in new. A successful feeler calls Good(), refreshing m_last_success while retaining the collision. ResolveCollisions_() measures ADDRMAN_TEST_WINDOW from that refreshed timestamp. Repeated successes within each window can therefore keep the incumbent and a collision-set slot occupied, especially with a small reachable new table. At base, a sole unreachable collision prevented this feeler refresh path; refreshes from non-feeler connections were already possible. Connectivity otherwise remains unaffected.

Track pending-collision age separately from the challenger's latest success, and add a mock-clock regression that refreshes the challenger before the original deadline.


Optional improvements

Link

[suggestion] · Collision tests do not distinguish challenger and incumbent networks

All new assertions would still pass if the filter checked newInfo.GetNetwork() instead of info_old.GetNetwork(), because each challenger shares its incumbent's network.

Location: src/test/addrman_tests.cpp:1048 (head).

Details and suggested fix

addrman_select_tried_collision_networks creates only IPv4/IPv4 and IPv6/IPv6 collisions, so filtering either side produces the same decisions. The motivating case instead has a reachable challenger colliding with an incumbent on an unreachable network. Add a deterministic cross-network pair and assert that filtering on only the challenger's network returns nothing, while filtering on the incumbent's network returns the incumbent. Checking the latter after the rejected selection also verifies that filtering kept the collision pending.


Link

[suggestion] · New tests do not protect the feeler call-site change

Reverting the feeler call to SelectTriedCollision() would compile and leave the new unit assertions unchanged, despite restoring the unreachable-collision stall.

Location: src/net.cpp:2919 (head).

Details and suggested fix

The default networks = {} preserves the old call, while addrman_select_tried_collision_networks exercises only the library API. Existing explicit-feeler handshake tests do not exercise this automatic-selection branch. Add a regression with an unreachable pending incumbent and an eligible reachable new entry, then assert that automatic selection still makes a feeler before collision timeout. A possible functional fixture would enable autoconnect with -onlynet, -test=addrman, and mocktime; constructing the collision through RPC has not been verified. If that fixture is impractical, document that the call-site change relies on reasoning and the reported manual reproduction rather than automated regression coverage.


Link

[suggestion] · Fuzzing never supplies a collision network filter

The addrman fuzz target calls only SelectTriedCollision() with the default empty filter, leaving filter rejection and the returned incumbent's network-membership contract unchecked.

Location: src/addrman.cpp:998 (head).

Details and suggested fix

networks.empty() short-circuits the new predicate for every collision-selection fuzz call. The unfiltered call still exercises the shared scan, but cannot exercise wrapping after filter rejection or rejection mixed with stale-ID cleanup. Keep that call and add one with a fuzzed subset of ALL_NETWORKS, following the existing Select() pattern. Assert nets.empty() || !result.IsValid() || nets.contains(result.GetNetwork()). Whether the corpus reaches several mixed-network collisions is unknown.


Coverage details