mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-26 07:26:15 +01:00
1b1088d52ftest: add combined I2P/onion/localhost eviction protection tests (Jon Atack)7c2284eda2test: add tests for inbound eviction protection of I2P peers (Jon Atack)ce02dd1ef1p2p: extend inbound eviction protection by network to I2P peers (Jon Atack)70bbc62711test: add combined onion/localhost eviction protection coverage (Jon Atack)045cb40192p2p: remove unused m_is_onion member from NodeEvictionCandidate struct (Jon Atack)310fab4928p2p: remove unused CompareLocalHostTimeConnected() (Jon Atack)9e889e8a5cp2p: remove unused CompareOnionTimeConnected() (Jon Atack)787d46bb2ap2p: update ProtectEvictionCandidatesByRatio() doxygen docs (Jon Atack)1e15acf478p2p: make ProtectEvictionCandidatesByRatio() fully ratio-based (Jon Atack)3f8105c4d2test: remove combined onion/localhost eviction protection tests (Jon Atack)38a81a8e20p2p: add CompareNodeNetworkTime() comparator struct (Jon Atack)4ee7aec47ep2p: add m_network to NodeEvictionCandidate struct (Jon Atack)7321e6f2fep2p, refactor: rename vEvictionCandidates to eviction_candidates (Jon Atack)ec590f1d91p2p, refactor: improve constness in ProtectEvictionCandidatesByRatio() (Jon Atack)4a19f501abtest: add ALL_NETWORKS to test utilities (Jon Atack)519e76bb64test: speed up and simplify peer_eviction_test (Jon Atack)1cde800523p2p, refactor: rm redundant erase_size calculation in SelectNodeToEvict() (Jon Atack) Pull request description: Continuing the work in #20197 and #20685, this pull updates and abstracts our inbound eviction protection to make it fully ratio-based and easily extensible to peers connected via high-latency privacy networks that we newly support, like I2P and perhaps others soon, as these peers are disadvantaged by the latency criteria of our eviction logic. It then adds eviction protection for peers connected over I2P. As described in https://github.com/bitcoin/bitcoin/pull/20685#issuecomment-767486499, we've observed over the past few months that I2P peers have a min ping latency similar to or greater than that of onion peers. The algorithm is a basically a multi-pass knapsack: - Count the number of eviction candidates in each of the disadvantaged privacy networks. - Sort the networks from lower to higher candidate counts, so that a network with fewer candidates will have the first opportunity for any unused slots remaining from the previous iteration. In the case of a tie in candidate counts, priority is given by array member order from first to last, guesstimated to favor more unusual networks. - Iterate through the networks in this order. On each iteration, allocate each network an equal number of protected slots targeting a total number of candidates to protect, provided any slots remain in the knapsack. - Protect the candidates in that network having the longest uptime, if any in that network are present. - Continue iterating as long as we have non-allocated slots remaining and candidates available to protect. The goal of this logic is to favorise the diversity of our peer connections. The individual commit messages describe each change in more detail. Special thank you to Vasil Dimov for the excellent review feedback and the algorithm improvement that made this change much better than it would have been otherwise. Thanks also to Antoine Riard, whose review feedback nudged this change to protect disadvantaged networks having fewer, rather than more, eviction candidates. ACKs for top commit: laanwj: Code review re-ACK1b1088d52fvasild: ACK1b1088d52fTree-SHA512: 722f790ff11f2969c79e45a5e0e938d94df78df8687e77002f32e3ef5c72a9ac10ebf8c7a9eb7f71882c97ab0e67b2778191effdb747d9ca54d7c23c2ed19a90
Test library
This contains files for the test library, which is used by the test binaries (unit tests, benchmarks, fuzzers, gui tests).
Generally, the files in this folder should be well-separated modules. New code should be added to existing modules or (when in doubt) a new module should be created.
The utilities in here are compiled into a library, which does not hold any state. However, the main file setup_common
defines the common test setup for all test binaries. The test binaries will handle the global state when they
instantiate the BasicTestingSetup (or one of its derived classes).