test: let connections happen in any order in p2p_private_broadcast.py#34410
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code Coverage & BenchmarksFor details see: https://corecheck.dev/bitcoin/bitcoin/pulls/34410. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please copy-paste ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. LLM Linter (✨ experimental)Possible typos and grammar issues:
Possible places where named args for integral literals may be used (e.g.
2026-02-23 13:00:15 |
|
Looks like this causes the test to timeout in most CIs. I see the same failure locally. |
0175769 to
38c0c89
Compare
|
|
38c0c89 to
25ee8bd
Compare
Yes:
|
25ee8bd to
4e12c91
Compare
|
|
|
🚧 At least one of the CI tasks failed. HintsTry to run the tests locally, according to the documentation. However, a CI failure may still
Leave a comment here, if you need help tracking down a confusing failure. |
4e12c91 to
e28c3bd
Compare
|
|
Bicaru20
left a comment
There was a problem hiding this comment.
Concept ACK. I left some comments to try to improve the code.
e28c3bd to
fd7afbe
Compare
|
|
|
Code review ACK fd7afbe. I tested and reviewed the code and everything looks good. |
If the following two events happen: * (likely) the automatic 10 initial connections are not made to all networks * (unlikely) the network-specific logic kicks in almost immediately. It is using exponential distribution with a mean of 5 minutes (`rng.rand_exp_duration(EXTRA_NETWORK_PEER_INTERVAL)`). So if both happen, then the 11th connection may not be the expected private broadcast, but a network-specific connection. Fix this by retrieving the connection type from `destinations_factory()`. This is more flexible because it allows connections to happen in any order and does not break if e.g. the 11th connection is not the expected first private broadcast. This also makes the test run faster: before: 19-44 sec now: 10-25 sec because for example there is no need to wait for the initial 10 automatic outbound connections to be made in order to proceed. Fixes: bitcoin#34387
I2P addresses must use port=0, otherwise `bitcoind` refuses to connect. The test `p2p_private_broadcast.py` cannot simulate connections to I2P peers, so the I2P proxy is set to a dummy `127.0.0.1:1`. Still it is good to pick I2P addresses and attempt connections to increase coverage. However the test uses port=8333 for I2P addresses and thus the connection attempts fail for the "wrong" reason: ``` Error connecting to ...i2p:8333, connection refused due to arbitrary port 8333 ``` Using the proper port=0 makes the failures: ``` Error connecting to ...i2p:0: Cannot connect to 127.0.0.1:1 ``` which will make possible simulated I2P connections once we have a test I2P proxy.
fd7afbe to
da7f70a
Compare
|
|
|
CI failure |
|
ACK da7f70a |
andrewtoth
left a comment
There was a problem hiding this comment.
ACK da7f70a
I must say the connection handling logic is quite complex. Not sure I have a concrete suggestion. Having the first private broadcast connection be "special" and be redirected to node1 and it having its own peer is confusing. Perhaps this case can be split into 2 tests, where all 3 private broadcast connections are "special" and have their own far observer peers and then the other test that just checks broadcast info.
|
|
If the test cases are meant to be independent, an alternative could also be to reset the state between each test case. For example, by restarting the nodes, clearing the mempool/wallet/etc |
|
re-run ci |
Partially my fault for adding the rpc tests in there. That could have been split out independently I think. |
mzumsande
left a comment
There was a problem hiding this comment.
Code Review ACK da7f70a
In general, I don't like for tests to rely on the debug log of the node to make decisions, but I don't see a better way in this case, since the outbound connection logic makes various types of connections on different timers.
Note that instead of a network-specific connection (as explained in the OP), a feeler connection is being made in some of the failed runs linked in the issue, which is also fixed by this.
|
Just an idea: an alternative to checking the debug log for early connection attempts is to change the |
@mzumsande yea. Changing production code, to regex debug logs, doesn't seem robust. |
If the following two events happen:
networks
It is using exponential distribution with a mean of 5 minutes
(
rng.rand_exp_duration(EXTRA_NETWORK_PEER_INTERVAL)).So if both happen, then the 11th connection may not be the expected
private broadcast, but a network-specific connection.
Fix this by retrieving the connection type from
destinations_factory(). This is more flexible because it allowsconnections to happen in any order and does not break if e.g. the 11th
connection is not the expected first private broadcast.
This also makes the test run faster:
before: 19-44 sec
now: 10-25 sec
because for example there is no need to wait for the initial 10
automatic outbound connections to be made in order to proceed.
Fixes: #34387