-
Notifications
You must be signed in to change notification settings - Fork 36.5k
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
Avoid internet traffic from tests #31339
Comments
Having no fully end-to-end tests sounds a bit dangerous, since it's part of the fundamental behavior of Bitcoin, not sure we should completely mock that away (i.e. certain bugs could creep in that work locally only - no idea how that would be possible, but that's exactly the point). |
Which tests are you seeing this from? Neither the unit nor functional tests should be making outside connections. This has certainly been discussed/avoided previously so may be a recent regression. |
I have the idea to log non local traffic with iptables -A OUTPUT -m addrtype \! --dst-type LOCAL -j LOG --log-prefix "eeeee1" --log-level emerg
iptables -A OUTPUT -j LOG --log-prefix "eeeee2" --log-level emerg
... generate some traffic with telnet and ping ...
# confirm some packets matched:
iptables -v -x -n -L
...
2024-11-21T11:38:45.5295264Z Chain OUTPUT (policy ACCEPT 19 packets, 1264 bytes)
2024-11-21T11:38:45.5296495Z pkts bytes target prot opt in out source destination
2024-11-21T11:38:45.5298695Z 13 828 LOG 0 -- * * 0.0.0.0/0 0.0.0.0/0 ADDRTYPE match dst-type !LOCAL LOG flags 0 level 0 prefix "eeeee1"
2024-11-21T11:38:45.5300746Z 19 1264 LOG 0 -- * * 0.0.0.0/0 0.0.0.0/0 LOG flags 0 level 0 prefix "eeeee2"
... but nothing about those is found in ps ax
2024-11-21T11:38:45.5842111Z PID TTY STAT TIME COMMAND
2024-11-21T11:38:45.5842436Z 1 pts/0 Ss+ 0:00 /bin/bash
2024-11-21T11:38:45.5842983Z 36 ? Ss 0:00 bash /home/runner/work/_temp/ci/test/03_test_script.sh
2024-11-21T11:38:45.5843441Z 68 ? R 0:00 ps ax So syslog is not running, but still |
@l0rinc the current end to end tests do communicate locally via the @fanquake Honestly, I forgot which test was that. During latest coredev I investigated that briefly with @maflcko or @0xB10C (?) and we observed the non local traffic with |
I think it makes sense to enforce this in CI (and have a tracking issue or pull for that). Otherwise, it is easy to regress, like in #30529 (comment) However, if there is a violation of this, or a bug, it would be good to add exact steps to reproduce, or an explanation. Claiming that this is broken on "Ubuntu 28.04 LTS" doesn't seem helpful to uncover the bug, if there is one. Related: #30030 |
Concept ACK |
Maybe it was #29605 (comment) (I independently ran into that a few weeks ago and included a fix in #31142) |
I think that was us back then, we looked at rpc_net.py and found this line: bitcoin/test/functional/rpc_net.py Line 253 in 17834bd
Opened #31343 for a proposed fix of this instance (maybe there are more).
Concept ACK |
@theStack, yes, it was that one, to Lets keep the focus here on enforcing this in the CI, rather than individual tests that do that. I couldn't find the output of Using
(full log at https://github.com/vasild/bitcoin/actions/runs/11972758832/job/33380324078?pr=4) |
Did you consider running the docker container in CI with https://docs.docker.com/engine/network/drivers/none/ Edit: Oh, I noticed we already have Edit 2: |
Good point, but I don't think this works conceptually to turn any and all network access in the tests into a failure, because a failure to access the network in the tests may not always lead to a test failure. |
@0xB10C my wish is to catch and report these, not just block them silently (only) from the CI environments. |
988721d test: avoid internet traffic in rpc_net.py (Sebastian Falbesoner) Pull request description: In order to avoid connecting to the internet in the functional test `rpc_net.py`, specify a non-working proxy (parameter `-proxy=127.0.0.1:1`, same approach as in #31142) for the nodes. There is at least one known instance where this is currently happening on master where a connection attempt to a public IP is made (see also the discussion in #31339): https://github.com/bitcoin/bitcoin/blob/17834bd1976df7a2ff6c2f5f05a59ae3fd3f6875/test/functional/rpc_net.py#L253 Can be tested by running ``` $ sudo tcpdump -i eth0 host 11.22.33.44 ``` both on master and the PR branch and verifying that no packets appear in the tcpdump in the latter anymore. ACKs for top commit: achow101: ACK 988721d tdb3: ACK 988721d vasild: ACK 988721d Tree-SHA512: 0f51fedccbfac0f80a7e6f9c5ba9193d0c20b5a788553c7cd7e583225df7b1151b86cd848d6ccf61f7b2de848f0ac98d73d7b5db100aa54fe8cbeeb4c0549106
Current behaviour
Tests should not try to open connections to the internet because:
Expected behaviour
Tests should only open local connections (e.g. on the
lo
interface).Enforce this in the CI, having it to detect non-local traffic and fail accordingly.
Steps to reproduce
Run the functional tests and monitor the traffic.
Relevant log output
No response
How did you obtain Bitcoin Core
Compiled from source
What version of Bitcoin Core are you using?
master@22ef95dbe3e467039e6cd18988e66557d94041d1
Operating system and version
Ubuntu 28.04 LTS
The text was updated successfully, but these errors were encountered: