#36470 test: make p2p_eviction actually exercise block-time protection
| Reviewability | Reviews | Agreement | Size | ||||
|---|---|---|---|---|---|---|---|
| #36470 test: make p2p_eviction actually exercise block-time protection | Ready | 1 (+1) | Strong | 0 + 57 tests | |||
|
|
|
|
| |||
Reviewability: ReadyStalePaused Agreement: StrongPositivePositive w/ caveatsNeutralMildDisputedBlockedCrickets Reviews: current code-review ACKs, then (+stale ACKs) and -NACKs; greener = more ACKs. Size: lines added or modified outside tests, then in tests; greener = smaller. | |||||||
Goal
Restructures peer connection order and ping timings in the `p2p_eviction.py` functional test so that peer eviction protection for block-relaying peers is actually exercised. Eviction candidates are connected first and assigned lower ping times than block and transaction relayers using mocktime-controlled pong responses.
Problem: `p2p_eviction.py` passes even if block-time eviction protection is broken or completely disabled. Because block-sending peers were connected first, fallback logic in `CompareNodeBlockTime` protected them as the oldest inbound connections regardless of whether they sent blocks.
Evidence of importance:
- PR description: "This can be shown by deleting the line where the peers send their block (L71 on master): block_peer.send_blocks_and_test([block], node, success=True)" and the test continues to pass.
Risk of a mistake: low (tests). A mistake can only cause functional test failures or CI flakiness.
Changed since the previous assessment: No structural changes; the implementation maintains the approach of connecting eviction candidates first with mocktime-based ping delays.
Reviewability
Ready
Nothing known that would invalidate a review now.
Waiting on (from the thread read):
- nothing: all objections and suggestions addressed; PR has ACKs and no pending requests
Agreement
Strong
substantive support, no open objection (trakshan-mishra, maflcko)
Thread notes: Author responded to maflcko's suggestion about peer connection ordering and mutation testing, opting to keep the current implementation as-is unless other reviewers ask for it.
Objections, suggestions, and questions:
| Reviewer | Type | Harm, request, or question | Status | Must be | Author replied | Quote |
|---|---|---|---|---|---|---|
| instagibbs (member) | objection, correctness | the regression test does not catch mutants under libc++ or MSVC due to sort implementation details when peers share a netgroup | fixed · fix pushed · author force-pushed addressing the issue for libc++/MSVC | changed | yes | 2026-10-13: 'regression test doesn't fail under mutants for libc++/MSVC due to sort implementation details with all peers falling under the same netgroup' Status from: 2026-10-14: brunoerg: 'Force-pushed addressing https://github.com/bitcoin/bitcoin/pull/36470#discussion_r4263718474 to cover the libc++/MSVC ca' |
| maflcko (member) | objection, correctness | manual sleeps may cause test unreliability and failures in slow or racy test environments such as QEMU VMs or Bedrock | accepted · fix pushed · maflcko confirmed the mocktime fix makes the test deterministic and twice as fast | answered | yes | 2026-10-16: 'not sure this is reliable. the tests run also in qemu in vms, which may be slow or racy. Also, if someone runs them in bedrock or similar, this may not hold, so the test may fail?' Status from: 2026-10-20: maflcko: 'The test should now be deterministic and twice as fast with mocktime.' |
| maflcko (member) | suggestion, approach | connect candidate peers first, then shuffle protected peer types to satisfy mutation testing | answered · author declined to change connection order for now unless other reviewers request it | answered | yes | 2026-10-20: 'Ralph complains, but to make it happy, one would have to first connect candidates peers, then connect shuffle(tx, block, fast-ping)? Not sure if this is worth it or if it makes Ralph happy. Up to you.' Status from: 2026-10-26: brunoerg: 'I'm not sure is worth, will leave as-is for now unless other reviewers prefer that.' |
Support:
- trakshan-mishra (none) (Tested ACK, 2026-10-09) [tested]: verified through mutation testing that the test fails under this PR when block-time protection logic is removed or bypassed, unlike on master where it passes unconditionally
- maflcko (member) (ACK, 2026-10-12): review ACK c75cdce1f9430cab029a329fd86c7e6bef7bf444 [not substantive]
- maflcko (member) (ACK, 2026-10-20) [read]: the test should now be deterministic and twice as fast with mocktime
Participants:
- trakshan-mishra (none, support, 1 statements 2026-10-09 to 2026-10-09): Tested ACK verifying that the test catches disabled block-time protection via mutation testing
- maflcko (member, support, 8 statements 2026-10-12 to 2026-10-20): review ACKed after mocktime resolved flakiness concerns; noted optional connection ordering suggestion for mutation testing
- instagibbs (member, objection, 1 statements 2026-10-13 to 2026-10-13): reported that the test does not catch mutants on libc++/MSVC due to sort implementation details
- Crypt-iQ (member, neutral, 1 statements 2026-10-16 to 2026-10-16): noted that a change fixes a scheduling flake in Bedrock
Files
100 lines under test/bench/ci.
- test/functional/p2p_eviction.py +57/-43
Card
The short text the ranking pass compares across PRs.
Fixes a test flaw in p2p_eviction.py where the test passed even when block-time eviction protection was disabled or bypassed. Because block-relaying peers were connected first, fallback logic in CompareNodeBlockTime protected them as the oldest connections anyway. The test now connects eviction candidate peers first with lower mocktime ping responses so block and transaction protection steps are genuinely required. Test-only change.
Data
thread read through 2026-10-26 (20 statements), head 2fd9be21e2
labels: Tests
Categories
P2P
P3 · test coverage
Fixes a test gap where inbound peer eviction logic for block relayers was completely bypassed due to connection order fallback. As verified by mutation testing, master passed even when block-time protection was removed, which this PR corrects without altering production p2p code.
Membership: Modifies test/functional/p2p_eviction.py to properly test connection management and inbound peer eviction protection.
Factors: security/stability 1, bug 1, performance 0, user value 0, leverage 0