Skip to content

cli: Detect port errors in rpcconnect and rpcport - #29521

Merged
achow101 merged 2 commits into
bitcoin:masterfrom
tdb3:20240229_rpcconnectinvalidportdetection
Jun 11, 2024
Merged

achow101 merged 2 commits into
bitcoin:masterfrom
tdb3:20240229_rpcconnectinvalidportdetection

Conversation

@tdb3

@tdb3 tdb3 commented Feb 29, 2024 •

Copy link
Copy Markdown
Contributor

Adds invalid port detection to bitcoin-cli for -rpcconnect and -rpcport.

In addition to detecting malformed/invalid ports (e.g. those outside of the 16-bit port range, not numbers, etc.), bitcoin-cli also now considers usage of port 0 to be invalid. bitcoin-cli previously considered port 0 to be valid and attempted to use it to reach bitcoind.

Functional tests were added for invalid port detection as well as port prioritization.
Additionally, a warning is provided when a port is specified in both -rpcconnect and -rpcport.

This PR is an alternate approach to PR #27820 (e.g. SplitHostPort is unmodified).

Considered an alternative to 127.0.0.1 being specified in functional tests, but at first glance, this might need an update to test_framework/util.py (e.g. rpc_url), which might be left to a future PR.

@DrahtBot

DrahtBot commented Feb 29, 2024 •

Copy link
Copy Markdown
Contributor

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Code Coverage

For detailed information about the code coverage, see the test coverage report.

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK cbergqvist, S3RK, achow101
Stale ACK rkrux, davidgumberg, marcofleon

If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

Comment thread src/bitcoin-cli.cpp Resolved
@davidgumberg

Copy link
Copy Markdown
Contributor

crACK 46c91a2

@tdb3

tdb3 commented Mar 12, 2024

Copy link
Copy Markdown
Contributor Author

Thanks for the review @davidgumberg!
Added the suggestions (force pushed).
Responses inline.

@cbergqvist cbergqvist left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 6e779d83232025ba83e2bd79bd07d2299410193d

Testing

Ran ./test/functional/test_runner.py --extended and got two failures feature_index_prune.py and wallet_importdescriptors.py --descriptors. Reran on the base of the PR, 1105aa4 and got both failures, so shouldn't be related. Will investigate further.

Code

I like how you limited the scope of variables introduced in this PR, I wish fewer lines were needed for the added error detection, but I didn't figure out a way to shrink it either.

Some would suggest breaking out to a function, but since it's only used here I agree it's better to inline it.

Comment thread src/bitcoin-cli.cpp Outdated
Comment on lines 762 to 770

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style: narrow scope of rpcport_arg since it is only used inside the if-block. (In this case the outer scope ends it anyway, this is just a general rule of thumb).

Naming: rpcport_port -> rpcport_int since the former is a bit repetitive and the latter at least describes its purpose somewhat, despite being a bit Hungarian.

Suggested change
std::optional<std::string> rpcport_arg = gArgs.GetArg("-rpcport");
if (rpcport_arg.has_value()) {
std::optional<uint16_t> rpcport_port{ToIntegral<uint16_t>(rpcport_arg.value())};
if (!rpcport_port.has_value() || rpcport_port.value() == 0) {
throw std::runtime_error(strprintf("Invalid port provided in -rpcport: %s", rpcport_arg.value()));
}
// Use the valid port provided
port = rpcport_port.value();
if (std::optional<std::string> rpcport_arg = gArgs.GetArg("-rpcport")) {
std::optional<uint16_t> rpcport_int{ToIntegral<uint16_t>(rpcport_arg.value())};
if (!rpcport_int.has_value() || rpcport_int.value() == 0) {
throw std::runtime_error(strprintf("Invalid port provided in -rpcport: %s", rpcport_arg.value()));
}
// Use the valid port provided
port = rpcport_int.value();

@tdb3 tdb3 Mar 30, 2024 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good suggestions. I've implemented these changes and added a small comment to increase readability (since operator bool of std::optional is being used).

@tdb3

tdb3 commented Mar 30, 2024

Copy link
Copy Markdown
Contributor Author

Thank you for the review @cbergqvist!
Implemented your suggestions and rebased.

@rkrux rkrux left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK cb4f9fc

Testing Methodolgy:

  1. Ran make, which was successful.
  2. Ran functional tests, all passed.
  3. Tried the following cli commands in terminal while the daemon was running:
➜  bitcoin git:(20240229_rpcconnectinvalidportdetection) ✗ bcli -rpcconnect=127.0.0.1:notaport help
error: Invalid port provided in -rpcconnect: 127.0.0.1:notaport
➜  bitcoin git:(20240229_rpcconnectinvalidportdetection) ✗ bcli -rpcconnect=127.0.0.1:-1 help
error: Invalid port provided in -rpcconnect: 127.0.0.1:-1
➜  bitcoin git:(20240229_rpcconnectinvalidportdetection) ✗ bcli -rpcconnect=127.0.0.1:65536 help
error: Invalid port provided in -rpcconnect: 127.0.0.1:65536
➜  bitcoin git:(20240229_rpcconnectinvalidportdetection) ✗ bcli -rpcport=notaport help
error: Invalid port provided in -rpcport: notaport
➜  bitcoin git:(20240229_rpcconnectinvalidportdetection) ✗ bcli -rpcport=-1 help
error: Invalid port provided in -rpcport: -1

➜  bitcoin git:(20240229_rpcconnectinvalidportdetection) ✗ bcli -rpcconnect=127.0.0.1:9000 -rpcport=8332 getblockcount
Warning: Port specified in both -rpcconnect and -rpcport. Using -rpcport 8332
448483

Comment thread src/bitcoin-cli.cpp Resolved
Comment thread src/bitcoin-cli.cpp Resolved
@DrahtBot
DrahtBot requested a review from cbergqvist March 30, 2024 08:05
@tdb3

tdb3 commented Mar 30, 2024 •

Copy link
Copy Markdown
Contributor Author

ACK cb4f9fc

Thank you for the review and testing @rkrux!
Will add a note to the description about usage of port 0 now considered invalid.

@cbergqvist cbergqvist left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK cb4f9fc5847a7e53fe45d54b1fddf504dee5af82

Verified coverage by changing the new C++ code-block to always throw and ran test/functional/interface_bitcoin_cli.py, confirming the exception message, reset to only PR changes and re-ran test/functional/interface_bitcoin_cli.py successfully.

Ran ./test/functional/test_runner.py --extended --jobs=16 --timeout-factor=1 and saw the same unrelated tests error out as on the previous version of this PR. Still investigating.

@marcofleon marcofleon left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested ACK. The new error handling code looks good to me upon review. Ran the daemon and gave invalid values for rpcconnect and rpcport and the proper error messages came up. The behavior of port 0 being invalid is consistent with src/init.cpp. Ran interface_bitcoin_cli.py too and there were no issues with the added tests.

@tdb3

tdb3 commented Apr 2, 2024

Copy link
Copy Markdown
Contributor Author

Tested ACK. The new error handling code looks good to me upon review. Ran the daemon and gave invalid values for rpcconnect and rpcport and the proper error messages came up. The behavior of port 0 being invalid is consistent with src/init.cpp. Ran interface_bitcoin_cli.py too and there were no issues with the added tests.

Thank you for reviewing, @marcofleon!

@davidgumberg

Copy link
Copy Markdown
Contributor

ACK cb4f9fc

The changes in bitcoin-cli.cpp since the last ACK look good to me, and the test coverage is more extensive.

Tested with make check and running the functional test suite.

I also verified that passing bad ports to rpcconnect and rpcport trigger the warning.

@DrahtBot
DrahtBot requested a review from marcofleon April 3, 2024 17:16

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In caa5242f84a6e1ef90b8a44c1206c7b5b942a00c "cli: Sanitize ports in rpcconnect and rpcport"

This will fail if you just have a regtest node running independent of the test:

2024-04-22T22:30:22.751000Z TestFramework (ERROR): Assertion failed
Traceback (most recent call last):
  File "/home/ava/bitcoin/bitcoin/29521/test/functional/test_framework/util.py", line 122, in assert_raises_process_error
    fun(*args, **kwds)
  File "/home/ava/bitcoin/bitcoin/29521/test/functional/test_framework/test_node.py", line 821, in __call__
    return self.cli.send_cli(self.command, *args, **kwargs)
  File "/home/ava/bitcoin/bitcoin/29521/test/functional/test_framework/test_node.py", line 886, in send_cli
    raise subprocess.CalledProcessError(returncode, self.binary, output=cli_stderr)
subprocess.CalledProcessError: Command '/home/ava/bitcoin/bitcoin/29521/src/bitcoin-cli' returned non-zero exit status 1.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/ava/bitcoin/bitcoin/29521/test/functional/test_framework/test_framework.py", line 132, in main
    self.run_test()
  File "/home/ava/bitcoin/bitcoin/29521/test/functional/interface_bitcoin_cli.py", line 136, in run_test
    assert_raises_process_error(1, "Could not connect to the server 127.0.0.1:18443", self.nodes[0].cli("-rpcconnect=127.0.0.1").echo)
  File "/home/ava/bitcoin/bitcoin/29521/test/functional/test_framework/util.py", line 127, in assert_raises_process_error
    raise AssertionError("Expected substring not found:" + e.output)
AssertionError: Expected substring not found:error: Authorization failed: Incorrect rpcuser or rpcpassword

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking a look and trying it out @achow101. Much appreciated.

Good point. Yes, the test would fail if an independent node is running on 18443.

Although not ideal, do you think this would be reasonable since a warning is provided when bitcoind is running independently? (i.e. WARNING! There is already a bitcoind process running on this system. Tests may fail unexpectedly due to resource contention!)

Alternatively, the assert statement could be removed, but that seems a bit lacking, since it seems good to check for default port usage (even if the current check is limited to the default regtest port).

Could also look into refactoring a bit, but that might lead to touching a bit more code than desirable.

Thoughts?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say it should be avoided to use test outside of the allowed range assigned to this test case. Each test is assigned 12, or so, p2p and rpc ports. I think this test can be dropped, because if the default behavior changed, pretty much every developer would notice quickly anyway?

@tdb3 tdb3 Apr 24, 2024 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that sounds reasonable. Overall, port error checking and associated functional test cases introduce an improvement. Removed the "18443" test and pushed.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this line and it seemed to pass

assert_raises_process_error(1, 'timeout on transient error: Could not connect to the server 127.0.0.1:::', self.nodes[0].cli("-rpcconnect=127.0.0.1::").echo)

looks like SplitHostPort does not throw an exception if there are two colons and no port provided

I am unsure if that is needed logic in SplitHostPort

I'm seeing the same error when I do
self.nodes[0].cli("-rpcconnect=127.0.0.256")
probably because 255 is the max value

@tdb3 tdb3 Apr 27, 2024 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @kevkevinpal. Good example of why review is valued. Your findings nudged me to add some assert test statements (which otherwise wouldn't be present) to help cover cases involving IPv6 hosts.

We're experiencing the result of the scope of SplitHostPort(). SplitHostPort() extracts the host and port. Although the port is validated, host is not (and the function declaration comment header mentions validating the port, but doesn't mention validating the host).

/**
* Splits socket address string into host string and port value.
* Validates port value.
*
* @param[in] in The socket address string to split.
* @param[out] portOut Port-portion of the input, if found and parsable.
* @param[out] hostOut Host-portion of the input, if found.
* @return true if port-portion is absent or within its allowed range, otherwise false
*/
bool SplitHostPort(std::string_view in, uint16_t& portOut, std::string& hostOut);

SplitHostPort() is treating "127.0.0.1::" as an IPv6 host since "::" is used for IPv6 address shortening. SplitHostPort() detects no port as part of the input string, which would be why Could not connect to the server 127.0.0.1:::18443 is the error provided for src/bitcoin-cli -rpcconnect=127.0.0.1:: getblockcount (the ":18443" is tacked on the end because it's the default port for regtest).

An enhancement would be to perform a validation of the host received from SplitHostPort() before bitcoin-cli attempts to contact the host. I'm thinking we would need to first define what is "valid" and what is "invalid" for use with bitcoin-cli. The gist of this kind of checking seems to be present in CNetAddr. In general, I would think bitcoin-cli shouldn't be overly restrictive in what it lets the user attempt to use as a host.

bitcoin/src/netaddress.h

Lines 157 to 181 in 7fee0ca

[[nodiscard]] bool IsIPv4() const { return m_net == NET_IPV4; } // IPv4 mapped address (::FFFF:0:0/96, 0.0.0.0/0)
[[nodiscard]] bool IsIPv6() const { return m_net == NET_IPV6; } // IPv6 address (not mapped IPv4, not Tor)
bool IsRFC1918() const; // IPv4 private networks (10.0.0.0/8, 192.168.0.0/16, 172.16.0.0/12)
bool IsRFC2544() const; // IPv4 inter-network communications (198.18.0.0/15)
bool IsRFC6598() const; // IPv4 ISP-level NAT (100.64.0.0/10)
bool IsRFC5737() const; // IPv4 documentation addresses (192.0.2.0/24, 198.51.100.0/24, 203.0.113.0/24)
bool IsRFC3849() const; // IPv6 documentation address (2001:0DB8::/32)
bool IsRFC3927() const; // IPv4 autoconfig (169.254.0.0/16)
bool IsRFC3964() const; // IPv6 6to4 tunnelling (2002::/16)
bool IsRFC4193() const; // IPv6 unique local (FC00::/7)
bool IsRFC4380() const; // IPv6 Teredo tunnelling (2001::/32)
bool IsRFC4843() const; // IPv6 ORCHID (deprecated) (2001:10::/28)
bool IsRFC7343() const; // IPv6 ORCHIDv2 (2001:20::/28)
bool IsRFC4862() const; // IPv6 autoconfig (FE80::/64)
bool IsRFC6052() const; // IPv6 well-known prefix for IPv4-embedded address (64:FF9B::/96)
bool IsRFC6145() const; // IPv6 IPv4-translated address (::FFFF:0:0:0/96) (actually defined in RFC2765)
bool IsHeNet() const; // IPv6 Hurricane Electric - https://he.net (2001:0470::/36)
[[nodiscard]] bool IsTor() const { return m_net == NET_ONION; }
[[nodiscard]] bool IsI2P() const { return m_net == NET_I2P; }
[[nodiscard]] bool IsCJDNS() const { return m_net == NET_CJDNS; }
[[nodiscard]] bool HasCJDNSPrefix() const { return m_addr[0] == CJDNS_PREFIX; }
bool IsLocal() const;
bool IsRoutable() const;
bool IsInternal() const;
bool IsValid() const;

For now, it might make the most sense to leave the enhancement of host validation to a new PR since this PR is focused on port error detection.

@cbergqvist cbergqvist left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reACK 867a673bcfd3ca254c306d8cf0c68d4ceb163f97

Inspected git range-diff cb4f9fc~2..cb4f9fc 867a673~2..867a673.

Passed --extended functional tests (-feature_dbcrash, excluded, some others skipped due to configuration). Passed make check.

Comment on lines 118 to 119

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(IMO it's slightly cleaner to split the test into --ipv4 and --ipv6 variants similar to rpc_bind.py, that way it becomes explicit whether that part of the test coverage is being skipped or not. This being more of a parsing-test, I guess it is not on the critical end of the spectrum. Also it's just a minor part of interface_bitcoin_cli.py so I completely understand the resistance to breaking it out).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @cbergqvist. Good observation.

Looks like rpc_bind.py uses --ipv4 and --ipv6 arguments to run the test exclusively with ipv4 or ipv6 (not both), which at first glance doesn't seem to be desirable for interface_bitcoin_cli.py (dependence on network type is a somewhat small part of the test). I could see there being value in refactoring interface_bitcoin_cli.py to include wider coverage of bitcoin-cli with ipv4 and ipv6, but I'm thinking this sort of refactor would be a good follow-up PR rather than included in the scope of this PR.

In the interim, I did push a minor update to add a log message stating when ipv6 testing is being skipped (and also opportunistically rebased).

@DrahtBot
DrahtBot requested a review from rkrux May 8, 2024 22:33
@tdb3

tdb3 commented May 13, 2024

Copy link
Copy Markdown
Contributor Author

Seeing a CI error for arm-linux-gnueabihf-g++ (on a line unchanged in this latest push). Will look into this.

In function ‘UniValue CallRPC(BaseRequestHandler*, const std::string&, const std::vector<std::__cxx11::basic_string<char> >&, const std::optional<std::__cxx11::basic_string<char> >&)’,
    inlined from ‘UniValue ConnectAndCallRPC(BaseRequestHandler*, const std::string&, const std::vector<std::__cxx11::basic_string<char> >&, const std::optional<std::__cxx11::basic_string<char> >&)’ at bitcoin-cli.cpp:908:31:
bitcoin-cli.cpp:764:42: error: ‘result’ may be used uninitialized [-Werror=maybe-uninitialized]
  764 |             if (!rpcport_int.has_value() || rpcport_int.value() == 0) {
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from bitcoin-cli.cpp:23:
./util/strencodings.h: In function ‘UniValue ConnectAndCallRPC(BaseRequestHandler*, const std::string&, const std::vector<std::__cxx11::basic_string<char> >&, const std::optional<std::__cxx11::basic_string<char> >&)’:
./util/strencodings.h:184:7: note: ‘result’ was declared here
  184 |     T result;
      |       ^~~~~~
cc1plus: all warnings being treated as errors

@DrahtBot

Copy link
Copy Markdown
Contributor

🚧 At least one of the CI tasks failed. Make sure to run all tests locally, according to the
documentation.

Possibly this is due to a silent merge conflict (the changes in this pull request being
incompatible with the current code in the target branch). If so, make sure to rebase on the latest
commit of the target branch.

Leave a comment here, if you need help tracking down a confusing failure.

Debug: https://github.com/bitcoin/bitcoin/runs/24877615319

Comment thread src/bitcoin-cli.cpp Outdated
Comment on lines 763 to 764

@maflcko maflcko May 13, 2024 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
std::optional<uint16_t> rpcport_int{ToIntegral<uint16_t>(rpcport_arg.value())};
if (!rpcport_int.has_value() || rpcport_int.value() == 0) {
port=ToIntegral<uint16_t>(rpcport_arg).value_or(0);
if (port == 0) {

if you treat 0 as invalid, there is no need to also have nullopt be invalid as well, no?

This should also fix the false-positive compiler warning?

An alternative would be to suppress the false-positive warning in the CI task config.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ToIntegral itself returns a std::optional unfortunately so the suggested change won't compile as is Super-weird that this error popped up now.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I placed the ) in the wrong place, I think. However, value_or exists and should be compile-able. See https://en.cppreference.com/w/cpp/utility/optional/value_or

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that new version should work. Another possible variant.. but no way to know if the compiler becomes happier:

Suggested change
std::optional<uint16_t> rpcport_int{ToIntegral<uint16_t>(rpcport_arg.value())};
if (!rpcport_int.has_value() || rpcport_int.value() == 0) {
const uint16_t rpcport_int{ToIntegral<uint16_t>(rpcport_arg.value()).value_or(0)};
if (rpcport_int == 0) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no way to know if the compiler becomes happier:

If it compiles locally, the code should be fine. If the CI warning persists, it should be disabled in the CI task config. (you can test by pushing, or running locally)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks all for the suggestions. Pushed an update.
Since locally I have x86_64 (and not arm), I tried configuring/compiling with --enable-werror added to ./configure (to minimize excess CI churn). Interestingly enough, this didn't result in the same warning as seen on arm CI.

@tdb3 tdb3 May 14, 2024 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No luck with the arm CI again. Will try playing with the specific stage locally more (https://github.com/bitcoin/bitcoin/tree/master/ci).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a false positive, so it needs to be disabled, like in the other CI tasks.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in #30144

tdb3 added 2 commits May 13, 2024 12:14
Adds error handling of invalid ports to rpcconnect and rpcport,
with associated functional tests.
Adds a warning when both -rpcconnect and -rpcport define
a port to be used.

@marcofleon marcofleon left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re-ACK e208fb5. I successfully compiled and built (make check passed) on my Arm64 machine but the CI error is related to 32-bit machines if I'm not mistaken so might not be relevant.

Either way, the port error detection looks good to me. Clear comments and more readable since my last review. I also successfully ran the functional test. I modified the test using valid ports and mixed -rpcconnect and -rpcport configurations to ensure robustness. The test handled everything correctly.

@cbergqvist cbergqvist left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re ACK 24bc46c

Inspected git range-diff 867a673~2..867a673 24bc46c~2..24bc46c.

Ran same tests as last time (#29521) with same results.

Tried to repro a boiled down version of the mysterious compiler warning but was unable to reproduce it. Here is what I ended up with: https://godbolt.org/z/fh5KcbbeW
(Not sure about the legalese around uploading Bitcoin Core source to Godbolt but just pasting ToIntegral() shouldn't be that bad).

@DrahtBot
DrahtBot requested a review from marcofleon May 20, 2024 10:33
fanquake added a commit that referenced this pull request May 22, 2024
…task

fa73431 ci: Add mising -Wno-error=maybe-uninitialized to armhf task (MarcoFalke)

Pull request description:

  This happens after bd597c3 in many pull requests as a silent merge conflict. For example:

  * #29720 (comment)
  * #29521 (comment)
  * (Probably many undetected, because the CI task was not yet re-run)
  * ...

ACKs for top commit:
  fjahr:
    utACK fa73431
  fanquake:
    ACK fa73431 - many fixed with 13.x

Tree-SHA512: 6e6ff8dc6f3c6a2abcd04c4203d3468f6e98c1ad3a4da4ad0037a9ee2cbec6bec079a5f778aba0273e38e173849927abcdfcfba7643d08ed66c1168cb89fab08
@S3RK

S3RK commented Jun 10, 2024

Copy link
Copy Markdown
Contributor

light code review ACK 24bc46c

@achow101

Copy link
Copy Markdown
Member

ACK 24bc46c

@achow101
achow101 merged commit 1bcc91a into bitcoin:master Jun 11, 2024
luke-jr pushed a commit to bitcoinknots/bitcoin that referenced this pull request Aug 1, 2024
Adds error handling of invalid ports to rpcconnect and rpcport,
with associated functional tests.

Github-Pull: bitcoin#29521
Rebased-From: e208fb5
luke-jr pushed a commit to bitcoinknots/bitcoin that referenced this pull request Aug 1, 2024
Adds a warning when both -rpcconnect and -rpcport define
a port to be used.

Github-Pull: bitcoin#29521
Rebased-From: 24bc46c
Comment thread src/bitcoin-cli.cpp
// If there was a valid port provided in rpcconnect,
// rpcconnect_port is non-zero.
if (rpcconnect_port != 0) {
tfm::format(std::cerr, "Warning: Port specified in both -rpcconnect and -rpcport. Using -rpcport %u\n", port);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm seeing something a bit unexpected here which is that the IP address passed to rpcconnect is still respected even though the port is ignored / overridden by rpcport. This came to my attention in the interface_bitcoin_cli test while working on another branch where I'd borked ipv6. This line in the test unexpectedly tried to connect to bitcoin on ::1 even though the port passed to rpcconnect was junk:

assert_equal(BLOCKS, self.nodes[0].cli("-rpcconnect=[::1]:18999", f'-rpcport={node_rpc_port}').getblockcount())

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on second thought, this behavior does make sense if a user is crazy enough to pass IP:port and then a second port

@bitcoin bitcoin locked and limited conversation to collaborators Sep 19, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.