-
Notifications
You must be signed in to change notification settings - Fork 38.8k
net: Fix Discover() not running when using -bind=0.0.0.0:port #32757
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
base: master
Are you sure you want to change the base?
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/32757. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please copy-paste ConflictsNo conflicts as of last run. |
5d5bf98 to
b17208d
Compare
|
Concept ACK Removing duplicate code from |
b17208d to
776b7ee
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.
utACK 776b7ee
I consider you could report error message when running in original codebase, and in comparison with this PR one. Or you can find related issue and declare to fix them, it could be clearer for reviewers.
yuvicc
left a comment
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.
lgtm ACK 776b7ee5855f7572798eff3014030bcc53aa7393
vasild
left a comment
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.
Approach ACK 776b7ee585
776b7ee to
99f8a6b
Compare
|
vasild thanks for the suggestions...about the In your patch, node 2 only has ['-discover', f'-whitebind=0.0.0.0:{self.bind_ports[2]}'], # Explicit -whitebind=0.0.0.0However, when I tried this configuration, I encountered port conflicts because the test framework automatically adds an onion bind to node 2, which conflicts with the port already used by node 1. Test Results: Without dummy onion bind (your suggested configuration): With dummy onion bind current implementation: The issue is that when using only To avoid this, I added a dummy onion bind: ['-discover', f'-whitebind=0.0.0.0:{self.bind_ports[2]}', f'-bind=127.0.0.1:{self.bind_ports[2]+100}=onion']This ensures the test runs successfully while still testing the intended |
|
🚧 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. |
4fdc0b1 to
ad3f60b
Compare
pinheadmz
left a comment
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.
ACK ad3f60b0ea59dbbe7aedcfdcca1caddefffe6976
Built and tested on macos/arm64 and debian/x86. Reviewed code changes which are minimal, this PR searches bind settings for 0.0.0.0 specifically to call Discover() which attempts to add local addresses for peer advertising. Also adds test coverage using 1.1.1.1 and 2.2.2.2 which I was able to set up and check locally on both platforms. Also tested on main.
I would really like to know if its possible to run this test in CI as vasild suggested here and if so, should probably be added to this PR
Show Signature
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
ACK ad3f60b0ea59dbbe7aedcfdcca1caddefffe6976
-----BEGIN PGP SIGNATURE-----
iQIzBAEBCAAdFiEE5hdzzW4BBA4vG9eM5+KYS2KJyToFAmh2awsACgkQ5+KYS2KJ
yTouuhAAmT1tLlOOKdhryZE9K+44Bcsn6prMoLono71Dzf+U+hkQpfxaCcwlI17c
hIW51zz/KZWTudgkDLSWU1RMhCDxMk8XFRdh47TD13OhOVrFJF3Al/uCrMFTXOB5
mPX2c7v6xOvx6DRlqZlCNDKKTOV1gPIM3+vyScmPA68Vh4ibxwzfYK9Lr0ss92fA
ceyCZttPOV6v57dazDn2Lm3siGWfS0+urnwf02TIlShklfW6+juz9AWfa8cmHw8E
GjO0D/r6BNW0TSeHSgt8jpxkVuGxl6opVkn+295hkZ4m9PM44eq7C1avK3yL9exl
LlsGdk9e/vsesJZne+hnppux1xivbfRbze0Z2J3fOpSdckU8mL8TpJlnyoRbQXAo
l3Cawmarwjm7sSQBRZsnAHNw6dN8qQ3ICkCPvK86UG8GLXhG76hcQBZY/NmwMqg7
hl8Np64L3bpH8dHU1Q/9gxHy6h3lPw9GNiOZFaQVvGQZicTzY7WxjhHcAevEHDvu
h9JxUBUPyroHxQkX2vDVBiyLM5pz8FtUOb7MWj5K0bFE1fg6IuY8XZog4BC/zWUL
eTLX330l883y2WoUrILAyrSe1B0HSt0SEh5yOqdwaBAuJ3lcvpht50D+0Z3wPvXU
FShlGSxgvUHBAaDSf/7aG3d48uYkoSKKnek5i65RZIG1oViucUE=
=snJ5
-----END PGP SIGNATURE-----
pinheadmz's public key is on openpgp.org
ad3f60b to
894fc0c
Compare
pinheadmz
left a comment
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.
Thanks for fixing the nit in the test.
In general, nit-fixes should be squashed (not added as an extra commit) so the final commit history is clean and perfect ;-)
Also I think you rebased on master which is ok, but it makes review slightly harder because my local copy of your branch is now dozens of commits different from the current state of the PR. I used git range-diff to isolate the changes which is why its not like, a super hard rule, but again in general, try not to rebase on master unless you have to (to fix a conflict, include other merged commits, etc)
57588f7 to
a9b7542
Compare
vasild
left a comment
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.
Almost ACK a9b7542b6ea1af770d93cbbf5bb55dae6841334f
I encountered port conflicts because the test framework automatically adds an onion bind to node 2,
Hmm, I think it is not the test framework but bitcoind itself that adds the onion bind. To figure out how bitcoind is started, e.g. for nodes[2] I look at /tmp/bitcoin_func_test_.../node2/regtest/debug.log for the lines like:
...
Config file arg: [regtest] shrinkdebugfile="0"
Config file arg: [regtest] unsafesqlitesync="1"
Command-line arg: bind="127.0.0.1:23642=onion"
Command-line arg: datadir="/tmp/bitcoin_func_test_h7qvveos/node2"
...
which conflicts with the port already used by node 1
Are you sure it is nodes[1] and nodes[2] conflicting? What is the error message? What is the output of ./test/functional/combine_logs.py |grep 'Bound to'? I got nodes[2] to bind the whitebind and tor on the same port, see my comment below.
8613ebd to
1dc6b1e
Compare
vasild
left a comment
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.
ACK 1dc6b1e8b04363107b4b44cbf42f8a25f2efabfe
Thank you!
pinheadmz
left a comment
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.
ACK 1dc6b1e8b04363107b4b44cbf42f8a25f2efabfe
Built and tested on macos/arm64. Reviewed code, minimal changes since last ACK, addressing clean-ups in the test. Tested on mainnet and compared against master to check that local address was discovered when -bind=0.0.0.0
Show Signature
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
ACK 1dc6b1e8b04363107b4b44cbf42f8a25f2efabfe
-----BEGIN PGP SIGNATURE-----
iQIzBAEBCAAdFiEE5hdzzW4BBA4vG9eM5+KYS2KJyToFAmiA9C8ACgkQ5+KYS2KJ
yTpmvhAAkvyMzMl7iYnSoSFwv/PJs0zGzXbr+iYzp8IrIoNNS7tTZj5S3a4uc6LA
i2aWgAG8NfEcW696R42h6bL2XTIRmLvxbYQyhpZAZRWK9oydK27e2sopsdQFJVxa
+wWcRqjhPLt7vOqzp/BkEQwlU60GLEZ7k52/xfs873F9MhU/u37DD2PkcNvf9nAQ
Y3fNlJYFEA1RBNIBLWTEwkYtKeWS+n2un+nj1APTqHH6rNHRODSYWe/LU2GG2et0
r2JTPEr0bADMi0P5+K8CZEUSsIcnDEcYc+UmayDEKvQu6kvZHXg0LQuNMHRlo7fM
uns5ZK5O+e4AVlBdICGRC70+qWL2C7WOd87gOFqsUYYyz1poYgnvEYHb+mHQh9Ti
juXof2FvxmV6cgdyZJtsAW78poT7Iwkb5Kn3767gum+Y4cGAAOUthVkwxFSZLBuI
j8T5oNC6AUcKegNhrwYD8uZJta/RNGW0Rzud1MQklE4lvmAwSKPJbDR9yHhuwh7R
XFaJmjIR7lE+RGEisQ3fO9FI8KmiUZgovHLaRzBITcTDINhtbyakWeanZHgqto8+
KCsIsoaM/Gk+QCvZifCfdrMxSuTickcCU8XQS53RhTgskAYxluQ4DFGputFi55T7
rXH1m+1hjgF0CmHF4PtiR8uApS1M8KmEnveepIUNbrrjxnTll6o=
=2P0/
-----END PGP SIGNATURE-----
pinheadmz's public key is on openpgp.org
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.
Does the changed test succeed for others? I tried to follow the instructions and get
test 2025-07-23T21:50:01.787971Z TestFramework (ERROR): Address 1.1.1.1 not found in node0's local addresses: []
test 2025-07-23T21:50:01.788044Z TestFramework (ERROR): Assertion failed
Traceback (most recent call last):
File "XXX/bitcoin/32757_bind0000/test/functional/test_framework/test_framework.py", line 195, in main
self.run_test()
File "XXX/32757_bind0000/build/test/functional/feature_bind_port_discover.py", line 97, in run_test
assert False
It also fails on master with the different error assert found_addr1 like #31336 describes.
As an aside, ifconfig is deprecated by many linux versions and should probably be replaced by ip (though not necessary to do it here).
[Edit]: Using Ubuntu 24.04.2 LTS
|
Test worked for me on mac and failed as expected without 1.1.1.1 and 2.2.2.2 On my system the command was |
ok, you don't add it to the loopback interface. |
|
Also seeing @mzumsande's observation if I add the addresses to loopback, but not if I add them to a different interface. I think it's reasonable to filter out all loopback addresses, so the resolution is probably to just update the instructions to have the addresses bound to a non-loopback interface. |
|
If @b-l-u-e is going to retouch to update the instructions in the test comment I'd also really like to see those instructions executed in a CI test as well. |
|
For me it would also be ok to leave the resolution of #31336 for a separate PR - but this PR shouldn't claim to solve the issue then. |
51f8d08 to
210dd40
Compare
|
found the issues raised and found the cause. The test was failing because the instructions were wrong. The original instructions told users to use loopback interfaces ( This is what issue #31336 reported - users following the instructions got empty local addresses. mzumsande: identified that the test was failing with "Address 1.1.1.1 not found in node0's local addresses: []" and noticed that pinheadmz: confirmed the test worked on macOS with non-loopback interfaces ( achow101: confirmed mzumsande observation that loopback addresses don't work, but non-loopback addresses do work and suggested updating the instructions to use non-loopback interfaces. I tested both scenarios
This makes the loopback filtering working as intended. updated the test instructions to be more educational and flexible
regarding #31336 The test logic itself is correct - the problem was jthe instructions were wrong. |
|
I ran these commands on Ubuntu 22.04: sudo ip addr add 1.1.1.1/32 dev wlo1 ./build/bin/bitcoind -regtest -bind=0.0.0.0:18444 -discover -daemon Result on master: Result on PR: Conclusion: |
vasild
left a comment
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.
ACK 210dd40
It suffices to prefix only the first line of the commit message with "test:".
Yes am still working on this |
210dd40 to
e0463f3
Compare
vasild
left a comment
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.
ACK e0463f3
frankomosh
left a comment
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.
e0463f3 to
8c5f2b4
Compare
Signed-off-by: b-l-u-e <[email protected]>
…dd comprehensive test coverage Signed-off-by: b-l-u-e <[email protected]>
8c5f2b4 to
37855ae
Compare
This PR fixes two related issues with address discovery when using explicit bind addresses in Bitcoin Core:
feature_bind_port_discover.pyis failing #31336When using
-bind=0.0.0.0:port(or-bind=::), theDiscover()function was not being executed because the code only checked thebind_on_anyflag. This led to two problems:feature_bind_port_discover.pywould fail, as it expects local addresses to be discovered in these cases.This PR:
bind_on_anyand any bind addresses usingIsBindAny()Ensures
Discover()runs when binding to 0.0.0.0 or ::, even if specified explicitly.The node will now discover its own addresses when using explicit "any" binds, matching user expectations and fixing the test.
The semantic meaning of
bind_on_anyis preserved as defined innet.h:The functional test
feature_bind_port_discover.pyis updated to use dynamic ports instead of hardcoded ones, improving reliability.How this PR Differs from #31492
bind_on_any(seenet.h).IsBindAny()on bind addresses, without modifyingGetListenPort().DefaultOnionServiceTarget().References
Closes #31293
The #31336 has the overall test failure and requires both this PR and #33362 to be fully resolved.