New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test: p2p: check disconnect due to lack of desirable service flags #29279
test: p2p: check disconnect due to lack of desirable service flags #29279
Conversation
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code CoverageFor detailed information about the code coverage, see the test coverage report. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. ConflictsNo conflicts as of last run. |
0f7b25f
to
358561e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review ACK 358561e
Adds a new test, increases code coverage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #28170. Obvious concept ACK.
We do have a post-IBD bug on this process.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concept ACK 358561e
Increasing code coverage
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concept ACK! i think flaky tests are possible because disconnection could happen before p2p_conn.wait_for_connect()
in add_outbound_connection()
?
True, good catch. The flaky case can be reproduced by adding an artificial delay before the diff --git a/test/functional/test_framework/test_node.py b/test/functional/test_framework/test_node.py
index 77f6e69e98..4aa54fa64a 100755
--- a/test/functional/test_framework/test_node.py
+++ b/test/functional/test_framework/test_node.py
@@ -725,6 +725,7 @@ class TestNode():
p2p_conn.wait_until(lambda: p2p_conn.message_count["version"] == 1, check_connected=False)
p2p_conn.wait_until(lambda: not p2p_conn.is_connected, check_connected=False)
else:
+ time.sleep(1)
p2p_conn.wait_for_connect()
self.p2ps.append(p2p_conn) I guess one solution could be to add a |
358561e
to
ff5f994
Compare
Solved the flaky test issue by introducing a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tested ACK ff5f994.
ff5f994
to
d82eafb
Compare
Rebased on master (after the merge of #24748 🎉 ), and tackled #29279 (comment). Note that I tried enabling v2 transport for this test, but it seems that it is non-trivial and needs some deeper changes in the test framework regarding the order of version messages sent (see slightly related comment https://mirror.b10c.me/bitcoin-bitcoin/24748/#discussion_r1465420112). Will tackle that in a follow-up. |
ACK d82eafb. |
Adds a new boolean parameter `wait_for_disconnect` to the `add_outbound_p2p_connection` method. If set, the node under test is checked to disconnect immediately after receiving the version message (same logic as for feeler connections).
…depth) This adds coverage for the logic introduced in PR bitcoin#28170 ("p2p: adaptive connections services flags").
49fbd57
to
2f23987
Compare
Force-pushed with rebase on master and tackled comment #29279 (comment). I reworked the |
reACK 2f23987 Looks good, retested by modifying |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
re-utACK 2f23987
(CI failure can be ignored)
self.test_desirable_service_flags(node, [NODE_NETWORK_LIMITED | NODE_WITNESS], | ||
DESIRABLE_SERVICE_FLAGS_FULL, expect_disconnect=True) | ||
node.setmocktime(int(time.time()) + 23 * 3600) # tip inside the 24h window, should succeed | ||
self.test_desirable_service_flags(node, [NODE_NETWORK_LIMITED | NODE_WITNESS], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: The DESIRABLE_SERVICE_FLAGS_*
above are the same as the combinations passed as service_flag_tests
so that variable could have been used in both places IMO (with a slight rename maybe). But this isn't critical.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
re ACK 2f23987
Built & re-ran test/functional/test_runner.py --cachedir=/mnt/tmp/cache --tmpdir=/mnt/tmp
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tested ACK 2f23987. 🚀
tested ACK 2f23987
Notes:
|
This PR adds missing test coverage for disconnecting peers which don't offer the desirable service flags in their VERSION message:
bitcoin/src/net_processing.cpp
Lines 3384 to 3389 in 5f3a057
This check is relevant for the connection types "outbound-full-relay", "block-relay-only" and "addr-fetch" (see
CNode::ExpectServicesFromConn(...)
). Feeler connections always disconnect, which is also tested here.In lack of finding a proper file where this test would fit in, I created a new one. Happy to take suggestions there.