Due to AttemptToEvictConnection not being tested the following net.cpp functions – which are only called directly or indirectly via AttemptToEvictConnection – are currently untested:
0staticbool ReverseCompareNodeMinPingTime(const NodeEvictionCandidate& a, const NodeEvictionCandidate& b)
1staticbool ReverseCompareNodeTimeConnected(const NodeEvictionCandidate& a, const NodeEvictionCandidate& b)
2staticbool CompareNetGroupKeyed(const NodeEvictionCandidate& a, const NodeEvictionCandidate& b)
3staticbool CompareNodeBlockTime(const NodeEvictionCandidate& a, const NodeEvictionCandidate& b)
4staticbool CompareNodeTXTime(const NodeEvictionCandidate& a, const NodeEvictionCandidate& b)
5static void EraseLastKElements(std::vector<T>& elements, Comparator comparator, size_t k)
fanquake added the label
Tests
on Aug 20, 2019
fanquake added the label
P2P
on Aug 20, 2019
MarcoFalke
commented at 2:54 pm on August 21, 2019:
member
Do you know if we have any tests for the eviction logic? Perhaps my measurements are incorrect.
AFAICT the eviction logic is by far the most critical code path not covered at all by any test. I mean “at all” in the most literal sense: the code path it isn’t even entered (if my measurements are correct) when running the full test suite :-)
I’m not super convinced that this very specific observation/issue is a duplicate of the general observation/issue “we could do better network testing in general” (#14210). Fixing the former can be done quickly - fixing the latter will take quite some time. Don’t you think? :-)
MarcoFalke
commented at 4:00 pm on August 21, 2019:
member
Fixing #14210 is a requirement for fixing this issue. This issue is also mentioned as motivating example in #14210.
practicalswift
commented at 4:15 pm on August 21, 2019:
contributor
I can see the dependency on #14210 for functional testing, but unit tests could easily be written to cover these functions AFAICT:
0staticbool ReverseCompareNodeMinPingTime(const NodeEvictionCandidate& a, const NodeEvictionCandidate& b)
1staticbool ReverseCompareNodeTimeConnected(const NodeEvictionCandidate& a, const NodeEvictionCandidate& b)
2staticbool CompareNetGroupKeyed(const NodeEvictionCandidate& a, const NodeEvictionCandidate& b)
3staticbool CompareNodeBlockTime(const NodeEvictionCandidate& a, const NodeEvictionCandidate& b)
4staticbool CompareNodeTXTime(const NodeEvictionCandidate& a, const NodeEvictionCandidate& b)
5static void EraseLastKElements(std::vector<T>& elements, Comparator comparator, size_t k)
That would be good even if #14210 takes time to resolve :-)
mzumsande
commented at 1:06 am on August 23, 2019:
member
I think that parts of the eviction logic could be tested in a functional test also prior to #14210 being solved.
The eviction logic applies to inbound peers and ignores outbound peers - we can simulate inbound connections with P2PInterface, and don’t need outbound peers to actually exist.
I don’t see how the logic based on address/netgroup could be tested, but other parts can.
There is a draft version of a functional test that partially covers the logic of CConnman::AttemptToEvictConnection in mzumsande@56d38d05c922ec37cae7ca957ad230a1dfbc4e96
I intend to open a PR based on this in the next days, but for that PR I will also add a commit with unit tests (unless @practicalswift you are working on that?).
practicalswift
commented at 4:36 am on August 23, 2019:
contributor
@mzumsande Oh, that’s excellent news! Very glad to hear that you’re working on this! Thanks!
No, I’m just sharing my observation: I was quite surprised to see that the code eviction code path wasn’t exercised at all when running the full test suite given how important it is that we get this logic correct. An error in this code could lead to attacker triggered network partitioning.
@MarcoFalke Would you mind re-opening this ticket?
MarcoFalke reopened this
on Aug 26, 2019
practicalswift closed this
on May 19, 2020
practicalswift
commented at 11:28 am on May 19, 2020:
contributor
Closing due to lack of progress/interest :)
jnewbery
commented at 8:17 pm on May 31, 2020:
member
This is a metadata mirror of the GitHub repository
bitcoin/bitcoin.
This site is not affiliated with GitHub.
Content is generated from a GitHub metadata backup.
generated: 2024-12-19 00:12 UTC
This site is hosted by @0xB10C More mirrored repositories can be found on mirror.b10c.me