-
Notifications
You must be signed in to change notification settings - Fork 37.7k
Make it possible to disable Tor binds and abort startup on bind failure #22729
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
Conversation
cc @hebasto |
|
|
CI failure https://cirrus-ci.com/task/5600680695037952: 89/217 - feature_bind_extra.py failed, Duration: 31 s
stdout:
2021-08-17T14:41:23.064000Z TestFramework (INFO): Initializing test directory /tmp/cirrus-ci-build/ci/scratch/test_runner/test_runner_₿_🏃_20210817_143957/feature_bind_extra_170
2021-08-17T14:41:23.064000Z TestFramework (INFO): Checking for Linux
2021-08-17T14:41:53.701000Z TestFramework (ERROR): Assertion failed
Traceback (most recent call last):
File "/tmp/cirrus-ci-build/ci/scratch/build/bitcoin-x86_64-pc-linux-gnu/test/functional/test_framework/test_framework.py", line 530, in start_nodes
node.wait_for_rpc_connection()
File "/tmp/cirrus-ci-build/ci/scratch/build/bitcoin-x86_64-pc-linux-gnu/test/functional/test_framework/test_node.py", line 225, in wait_for_rpc_connection
'bitcoind exited with status {} during initialization'.format(self.process.returncode)))
test_framework.test_node.FailedToStartError: [node 0] bitcoind exited with status 1 during initialization
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/tmp/cirrus-ci-build/ci/scratch/build/bitcoin-x86_64-pc-linux-gnu/test/functional/test_framework/test_framework.py", line 130, in main
self.setup()
File "/tmp/cirrus-ci-build/ci/scratch/build/bitcoin-x86_64-pc-linux-gnu/test/functional/test_framework/test_framework.py", line 285, in setup
self.setup_network()
File "/tmp/cirrus-ci-build/ci/scratch/build/bitcoin-x86_64-pc-linux-gnu/test/functional/feature_bind_extra.py", line 95, in setup_network
self.setup_nodes()
File "/tmp/cirrus-ci-build/ci/scratch/build/bitcoin-x86_64-pc-linux-gnu/test/functional/test_framework/test_framework.py", line 404, in setup_nodes
self.start_nodes()
File "/tmp/cirrus-ci-build/ci/scratch/build/bitcoin-x86_64-pc-linux-gnu/test/functional/test_framework/test_framework.py", line 533, in start_nodes
self.stop_nodes()
File "/tmp/cirrus-ci-build/ci/scratch/build/bitcoin-x86_64-pc-linux-gnu/test/functional/test_framework/test_framework.py", line 548, in stop_nodes
node.stop_node(wait=wait, wait_until_stopped=False)
File "/tmp/cirrus-ci-build/ci/scratch/build/bitcoin-x86_64-pc-linux-gnu/test/functional/test_framework/test_node.py", line 323, in stop_node
self.stop(wait=wait)
File "/tmp/cirrus-ci-build/ci/scratch/build/bitcoin-x86_64-pc-linux-gnu/test/functional/test_framework/test_node.py", line 183, in __getattr__
assert self.rpc_connected and self.rpc is not None, self._node_msg("Error: no RPC connection")
AssertionError: [node 0] Error: no RPC connection
2021-08-17T14:41:53.753000Z TestFramework (INFO): Stopping nodes |
#20234 For reference for related changes. I might propose some Tor doc clarifications in a separate PR. There has been a lot of confusion around |
Concept ACK (will review in more detail). It would be better if any error in binding configuration stopped the process, not just onion-related ones, as it can lead to surprising outcomes. But historically there were some issues with libevent in getting this right see #14968. |
*except the bind on IPv6 any address
I agree. Changed. If we want to also do the same for * then we would have to check whether |
The first commit ceeb317 After #22727 (comment) I am even more convinced that this is the right approach as it reduces user surprises (and those surprises can have highly undesirable outcomes). It must be possible to disable the binding on For example our functional testing framework starts >1 bitcoind and all of them collide on |
There is no reason for the test framework to be creating Tor binds at all. It's kind of surprising to me that it does by default but I understand why. I think the long term solution would be to only create the Tor bind when either requested through a command line flag, or when it succesfully connects to Tor (e.g. in |
|
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. 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. |
|
This would also help binding on the proper address and announcing it to the tor daemon. If tor and bitcoind run on the same machine the default But it gets more involved in setups where tor is on another machine. Then the default There is also the special case If we postpone the binding to after we have connected to tor control, then we can automatically figure out the best address to bind to and announce that (if one is not explicitly configured). #26484 is related, thanks @schildbach! |
In the Tor case, this prevents us from telling the Tor daemon to send our incoming connections from the Tor network to an address where we do not listen (we tried to listen but failed probably because another application is already listening). In the other cases (IPv4/IPv6 binds) this also prevents unpleasant surprises caused by continuing operations even on bind failure. For example, another application may be listening on portX, bitcoind tries to bind on portX and portY, only succeeds with portY and continues operation leaving the user thinking that his bitcoind is listening on portX whereas another application is listening (the error message in the log could easily be missed). Avoid having the functional testing framework start multiple `bitcoind`s that try to listen on the same `127.0.0.1:18445` (Tor listen for regtest) if `bind_to_localhost_only` is set to `False`. Also fix a typo in `test-shell.md` related to `bind_to_localhost_only`. Fixes bitcoin#22727
|
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 bca346a
The current solution means most test nodes in the functional test suite will now bind to an onion port even though the vast majority are not testing Tor
Only tests that use
bind_to_localhost_only
will do. We have 5 such tests.
We have 5 tests that disable bind_to_localhost_only
, all the others will bind=127.0.0.1
. Having that will result in your new has_explicit_bind
being true for the majority of tests, which will lead to your later added binds not being set for the majority of tests.
=> So only the 5 tests that disable bind_to_localhost_only
will get into this Tor exception. Good, thanks for correcting me on how many tests are impacted!
The previous incarnation of this PR (8c30871) had the tests not bind on Tor, because it is not needed (the vast majority are not testing Tor), but you did not like that.
What I do not like is the special casing inside of test_node.py that feels like a dirty workaround to me instead of having individual tests pass in the arguments they require (such as -listenonion), which in turn leads to binding of otherwise inactive Tor ports. But looking back at the comment history I understand how bitcoind
behaves by default might be the underlying reason preventing this cleaner proposal from being implemented.
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 bca346a
Changes since last ACK extremely minimal, cleaning up one line in the test
Show Signature
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
ACK bca346a97056748f1e3fb899f336d56d9fd45a64
-----BEGIN PGP SIGNATURE-----
iQIzBAEBCAAdFiEE5hdzzW4BBA4vG9eM5+KYS2KJyToFAmaRhAIACgkQ5+KYS2KJ
yTr7nA//Sq7hxrI2I5/n/paZ+F6aMbZSxIkv7ynizzr3WfzBimoFmh+RcXkpyg5I
OK32DfJbKod4U1EgkTXY6RkjF8uYftCqLugF9qwDKC4NhkWQxEjepxX75Vrs2qtr
mZkg49HMpxb6Kj3xm/Mulj0cEgKcIyxlrNPN/AeQq/M+iBEymkBTNBMVowipAh9Z
b/B74kPiA5/D2Lk8Xp4ffd2JFpVyScDXa9CgJv7kg6mS/Jr3V/kQJ6EaIBJlcCPZ
iag0HdTXkrXOjOKDhLPgMn4sENOKBPQtpTvlZTmkyVFEAdiDo2aFaZGUwQrbRILk
GDeuQqLKWHk7ypgW3oevUzdEtfKTO2vf53m2VuzM4opQTgyx9F5OzQbYPHDc+oKQ
K3Lsort48CIReEkXnnVdtkifmJLUnDyV3qpBB2r7TMoT144089kjPbbkPafjVTzL
05l4QeAnNLS5ERrm9wTBKiSzxassRNSMOS2gH4RgWmbixchSrq0PCTJc+TBYIrRi
uLUaqZDJZTsIHw+c789nmfG08PT6r9i5LDWBEGMF176lffkuKaXD1eB7nn0wHzWQ
nS8wHmGLND4NXNJiM5j1jPnuBuHwB3ZYVab6eqzaKO3ovTfh1xzHPr5K8OksxRHP
jwwUhWJ9t6VEUZM6g/NnfA8wmGYb9F//45o3YiPol6+kNW4QKrA=
=m0K0
-----END PGP SIGNATURE-----
pinheadmz's public key is on keybase
ACK bca346a |
After \bitcoin#22729, if a `-bind` is set, we no longer bind `127.0.0.1:8334` as an onion port by default.
After bitcoin#22729 if `-bind=127.0.0.1` is used, then bitcoind will not automatically also bind on `127.0.0.1:8334`.
6d33e13 doc: tor.md: use -bind=127.0.0.1:8334=onion for the Tor bind (David Gumberg) a7f5d18 doc: add release notes for #22729 (Vasil Dimov) Pull request description: Add release notes for #22729. ACKs for top commit: davidgumberg: reACK 6d33e13 willcl-ark: ACK 6d33e13 Tree-SHA512: 9d7e66ee1d0bb1d75b8273707d30f20915d5040a768c2c5cd47c84997df2645c8bec35db6c09dc77ab917836622411b924373816cbc83c4be38e2e9156a139d8
When the bind option is replaced in the bitcoin.conf, bitcoind will attempd to bind to the default tor listening port. If another bitcoind is running that is already bound to that port, the bind will fail which, since bitcoin#22729, causes the test to fail.
When the bind option is replaced in the bitcoin.conf, bitcoind will attempd to bind to the default tor listening port. If another bitcoind is running that is already bound to that port, the bind will fail which, since bitcoin#22729, causes the test to fail. This failure can be avoided by explicitly binding the tor port when the bind is removed.
When the bind option is replaced in the bitcoin.conf, bitcoind will attempd to bind to the default tor listening port. If another bitcoind is running that is already bound to that port, the bind will fail which, since bitcoin#22729, causes the test to fail. This failure can be avoided by explicitly binding the tor port when the bind is removed.
When the bind option is replaced in the bitcoin.conf, bitcoind will attempd to bind to the default tor listening port. If another bitcoind is running that is already bound to that port, the bind will fail which, since bitcoin#22729, causes the test to fail. This failure can be avoided by explicitly binding the tor port when the bind is removed.
082779d test: Add explicit onion bind to p2p_permissions (Ava Chow) Pull request description: When the bind option is replaced in the bitcoin.conf, bitcoind will attempd to bind to the default tor listening port. If another bitcoind is running that is already bound to that port, the bind will fail which, since #22729, causes the test to fail. This failure can be avoided by explicitly binding the tor port when the bind is removed. ACKs for top commit: tdb3: ACK 082779d theStack: re-ACK 082779d glozow: ACK 082779d Tree-SHA512: 4acb69ea2e00aeacf9e7c9ab9595ceaf0e0d2adbd795602034b2184197d9bad54c7bc9f3da43ef9c52a71869fe96ba8c87fc5b7c37880f258f5a2aaab2b4046c
After bitcoin/bitcoin#22729 if `-bind=127.0.0.1` is used, then bitcoind will not automatically also bind on `127.0.0.1:8334`.
Summary: ``` Make it possible to disable the Tor binding on 127.0.0.1:8334 and stop startup if any P2P bind fails instead of "if all P2P binds fail". ``` Backport of [[bitcoin/bitcoin#22729 | core#22729]]. Depends on D17661. Test Plan: ninja check-functional Reviewers: #bitcoin_abc, PiRK Reviewed By: #bitcoin_abc, PiRK Subscribers: PiRK Differential Revision: https://reviews.bitcoinabc.org/D17662
Summary: ``` Make it possible to disable the Tor binding on 127.0.0.1:8334 and stop startup if any P2P bind fails instead of "if all P2P binds fail". ``` Backport of [[bitcoin/bitcoin#22729 | core#22729]]. Depends on D17661. Test Plan: ninja check-functional Reviewers: #bitcoin_abc, PiRK Reviewed By: #bitcoin_abc, PiRK Subscribers: PiRK Differential Revision: https://reviews.bitcoinabc.org/D17662
Make it possible to disable the Tor binding on
127.0.0.1:8334
and stop startup if any P2P bind fails instead of "if all P2P binds fail".Fixes #22726
Fixes #22727