rpc, net: deprecate startingheight field of getpeerinfo RPC #34197

pull theStack wants to merge 1 commits into bitcoin:master from theStack:202601-deprecate-startingheight changing 4 files +16 −3
  1. theStack commented at 6:30 pm on January 3, 2026: contributor

    This PR deprecates the “startingheight” result field of the getpeerinfo RPC, following the discussion in #33990.

    Rationale: the reported starting height of a peer in the VERSION message is untrusted, and it doesn’t seem to be useful anymore (after #20624), so deprecating the corresponding field seems reasonable. After that, it can be removed, along with the m_starting_height field of the Peer / CNodeStats structs, as it is sufficient to show the reported height only once at connection in the debug log.

  2. DrahtBot commented at 6:30 pm on January 3, 2026: contributor

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

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/34197.

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK fjahr, rkrux, janb84, optout21, achow101

    If your review is incorrectly listed, please copy-paste <!–meta-tag:bot-skip–> into the comment that the bot should ignore.

  3. theStack force-pushed on Jan 3, 2026
  4. DrahtBot added the label CI failed on Jan 3, 2026
  5. l0rinc commented at 11:20 pm on January 3, 2026: contributor

    @maflcko, is the RPC build error just a coincidence or related to the change?

     0node0 2026-01-03T18:49:11.149625Z [scheduler] [net.cpp:2439] [StartExtraBlockRelayPeers] [net] enabling extra block-relay-only peers 
     1 node0 2026-01-03T18:51:58.171181Z [addcon] [logging/timer.h:58] [Log] [lock] Enter: lock contention m_nodes_mutex, ./net.cpp:2924 started 
     2 node0 2026-01-03T18:51:58.171263Z [addcon] [logging/timer.h:58] [Log] [lock] Enter: lock contention m_nodes_mutex, ./net.cpp:2924 completed (8μs) 
     3 node0 2026-01-03T18:53:34.189445Z [net] [logging/timer.h:58] [Log] [lock] Enter: lock contention m_nodes_mutex, ./net.cpp:1919 started 
     4 node0 2026-01-03T18:53:34.189518Z [net] [logging/timer.h:58] [Log] [lock] Enter: lock contention m_nodes_mutex, ./net.cpp:1919 completed (8μs) 
     5 node0 2026-01-03T18:57:23.888691Z [net] [logging/timer.h:58] [Log] [lock] Enter: lock contention m_nodes_mutex, ./net.cpp:1992 started 
     6 node0 2026-01-03T18:57:23.888765Z [net] [logging/timer.h:58] [Log] [lock] Enter: lock contention m_nodes_mutex, ./net.cpp:1992 completed (7μs) 
     7 node0 2026-01-03T19:00:51.852776Z [msghand] [logging/timer.h:58] [Log] [lock] Enter: lock contention connman.m_nodes_mutex, ./net.h:1732 started 
     8 node0 2026-01-03T19:00:51.852847Z [msghand] [logging/timer.h:58] [Log] [lock] Enter: lock contention connman.m_nodes_mutex, ./net.h:1732 completed (7μs) 
     9 node0 2026-01-03T19:02:00.260602Z [net] [logging/timer.h:58] [Log] [lock] Enter: lock contention m_nodes_mutex, ./net.cpp:1919 started 
    10 node0 2026-01-03T19:02:00.260673Z [net] [logging/timer.h:58] [Log] [lock] Enter: lock contention m_nodes_mutex, ./net.cpp:1919 completed (7μs) 
    11 node0 2026-01-03T19:03:26.150644Z [scheduler] [net.cpp:2401] [DumpAddresses] [net] Flushed 0 addresses to peers.dat  1ms 
    12 test  2026-01-03T19:08:26.796829Z TestFramework (ERROR): Unexpected exception 
    13                                   Traceback (most recent call last):
    14                                     File "/home/admin/actions-runner/_work/_temp/test/functional/test_framework/authproxy.py", line 174, in _get_response
    15                                       http_response = self.__conn.getresponse()
    16                                                       ^^^^^^^^^^^^^^^^^^^^^^^^^
    17                                     File "/usr/lib/python3.12/http/client.py", line 1430, in getresponse
    18                                       response.begin()
    19                                     File "/usr/lib/python3.12/http/client.py", line 331, in begin
    20                                       version, status, reason = self._read_status()
    21                                                                 ^^^^^^^^^^^^^^^^^^^
    22                                     File "/usr/lib/python3.12/http/client.py", line 292, in _read_status
    23                                       line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
    24                                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    25                                     File "/usr/lib/python3.12/socket.py", line 720, in readinto
    26                                       return self._sock.recv_into(b)
    27                                              ^^^^^^^^^^^^^^^^^^^^^^^
    28                                   TimeoutError: timed out
    29                                   During handling of the above exception, another exception occurred:
    30                                   Traceback (most recent call last):
    31                                     File "/home/admin/actions-runner/_work/_temp/test/functional/test_framework/test_framework.py", line 142, in main
    32                                       self.run_test()
    33                                     File "/home/admin/actions-runner/_work/_temp/build/test/functional/rpc_misc.py", line 96, in run_test
    34                                       assert_equal(node.echoipc("hello"), "hello")
    35                                                    ^^^^^^^^^^^^^^^^^^^^^
    36                                     File "/home/admin/actions-runner/_work/_temp/test/functional/test_framework/coverage.py", line 50, in __call__
    37                                       return_val = self.auth_service_proxy_instance.__call__(*args, **kwargs)
    38                                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    39                                     File "/home/admin/actions-runner/_work/_temp/test/functional/test_framework/authproxy.py", line 137, in __call__
    40                                       response, status = self._request('POST', self.__url.path, postdata.encode('utf-8'))
    41                                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    42                                     File "/home/admin/actions-runner/_work/_temp/test/functional/test_framework/authproxy.py", line 111, in _request
    43                                       return self._get_response()
    44                                              ^^^^^^^^^^^^^^^^^^^^
    45                                     File "/home/admin/actions-runner/_work/_temp/test/functional/test_framework/authproxy.py", line 176, in _get_response
    46                                       raise JSONRPCException({
    47                                   test_framework.authproxy.JSONRPCException: 'echoipc' RPC took longer than 1200.000000 seconds. Consider using larger timeout for calls that take longer to return. (-344)
    48 test  2026-01-03T19:08:26.799425Z TestFramework (DEBUG): Closing down network thread 
    49 test  2026-01-03T19:08:26.849792Z TestFramework (INFO): Not stopping nodes as test failed. The dangling processes will be cleaned up later. 
    50 test  2026-01-03T19:08:26.849948Z TestFramework (WARNING): Not cleaning up dir /home/admin/actions-runner/_work/_temp/ci/scratch/test_runner/test_runner__🏃_20260103_184426/rpc_misc_195 
    51 test  2026-01-03T19:08:26.850011Z TestFramework (ERROR): Test failed. Test logging available at /home/admin/actions-runner/_work/_temp/ci/scratch/test_runner/test_runner__🏃_20260103_184426/rpc_misc_195/test_framework.log 
    52 test  2026-01-03T19:08:26.850114Z TestFramework (ERROR): 
    53 test  2026-01-03T19:08:26.850247Z TestFramework (ERROR): Hint: Call /home/admin/actions-runner/_work/_temp/test/functional/combine_logs.py '/home/admin/actions-runner/_work/_temp/ci/scratch/test_runner/test_runner_₿_🏃_20260103_184426/rpc_misc_195' to consolidate all logs 
    54 test  2026-01-03T19:08:26.850323Z TestFramework (ERROR): 
    55 test  2026-01-03T19:08:26.850350Z TestFramework (ERROR): If this failure happened unexpectedly or intermittently, please file a bug and provide a link or upload of the combined log. 
    56 test  2026-01-03T19:08:26.850393Z TestFramework (ERROR): [https://github.com/bitcoin/bitcoin/issues](https://github.com/bitcoin/bitcoin/issues?q=sort%3Aupdated-desc+is%3Aissue+is%3Aopen) 
    57 test  2026-01-03T19:08:26.850417Z TestFramework (ERROR): 
    58
    59Command '['docker', 'exec', 'e17096029958cd4c898751de0f7114e3aa8d1768801f4bf80974f525e8f4496b', '/home/admin/actions-runner/_work/_temp/ci/test/03_test_script.sh']' returned non-zero exit status 1.
    60 node0 stderr ./rpc/node.cpp:301 echo(const std::string&)::<lambda(const RPCHelpMan&, const JSONRPCRequest&)>: Assertion `request.params[9].get_str() != "trigger_internal_bug"' failed.
    

    Would a https://github.com/bitcoin/bitcoin/blob/fa5f29774872d18febc0df38831a6e45f3de69cc/src/test/rpc_tests.cpp#L539 added to https://github.com/bitcoin/bitcoin/blob/b63428ac9ce2c903670409b3e47b9f6730917ae8/src/rpc/node.cpp#L301 fix it (similarly to the rpc tests)?

  6. mzumsande commented at 11:50 pm on January 3, 2026: contributor

    is the RPC build error just a coincidence or related to the change?

    It’s unrelated, see #34187

  7. in src/rpc/net.cpp:163 in a8531989ad
    159@@ -160,7 +160,7 @@ static RPCHelpMan getpeerinfo()
    160                     {RPCResult::Type::BOOL, "inbound", "Inbound (true) or Outbound (false)"},
    161                     {RPCResult::Type::BOOL, "bip152_hb_to", "Whether we selected peer as (compact blocks) high-bandwidth peer"},
    162                     {RPCResult::Type::BOOL, "bip152_hb_from", "Whether peer selected us as (compact blocks) high-bandwidth peer"},
    163-                    {RPCResult::Type::NUM, "startingheight", "The starting height (block) of the peer"},
    164+                    {RPCResult::Type::NUM, "startingheight", "(DEPRECATED) The starting height (block) of the peer"},
    


    fjahr commented at 0:10 am on January 4, 2026:
    What is the reasoning to not use the IsDeprecatedRPCEnabled/-deprecatedrpc method of deprecation here?

    theStack commented at 1:06 am on January 4, 2026:
    No reasoning other than me being forgetful :) changed to only return the field if -deprecatedrpc=startingheight is passed, and updated the functional test rpc_net.py and the release note accordingly.
  8. rpc, net: deprecate `startingheight` field of `getpeerinfo` RPC
    The reported starting height of a peer in the VERSION message is
    untrusted, and it doesn't seem to be useful anymore (after #20624),
    so deprecating the corresponding "startingheight" field seems
    reasonable. After that, it can be removed, along with the
    `m_starting_height` field of the Peer / CNodeStats structs, as it is
    sufficient to show the reported height only once at connection in the
    debug log.
    4ce3f4a265
  9. theStack force-pushed on Jan 4, 2026
  10. DrahtBot removed the label CI failed on Jan 4, 2026
  11. in test/functional/rpc_net.py:66 in 4ce3f4a265
    61@@ -62,7 +62,10 @@ def seed_addrman(node):
    62 class NetTest(BitcoinTestFramework):
    63     def set_test_params(self):
    64         self.num_nodes = 2
    65-        self.extra_args = [["-minrelaytxfee=0.00001000"], ["-minrelaytxfee=0.00000500"]]
    66+        self.extra_args = [
    67+            ["-minrelaytxfee=0.00001000", "-deprecatedrpc=startingheight"],
    


    fjahr commented at 12:44 pm on January 4, 2026:
    Could also test this in rpc_deprecated.py but seems ok to just use the existing coverage here. We aren’t very consistent with using that file, I guess.
  12. fjahr commented at 12:50 pm on January 4, 2026: contributor
    utACK 4ce3f4a26565e9851af950728cda7bcc2242d0c2
  13. in src/rpc/net.cpp:270 in 4ce3f4a265
    266@@ -267,7 +267,9 @@ static RPCHelpMan getpeerinfo()
    267         obj.pushKV("inbound", stats.fInbound);
    268         obj.pushKV("bip152_hb_to", stats.m_bip152_highbandwidth_to);
    269         obj.pushKV("bip152_hb_from", stats.m_bip152_highbandwidth_from);
    270-        obj.pushKV("startingheight", statestats.m_starting_height);
    271+        if (IsDeprecatedRPCEnabled("startingheight")) {
    


    rkrux commented at 1:34 pm on January 5, 2026:
    I initially got confused that IsDeprecatedRPCEnabled is used for deprecated RPC fields as well because its name suggests that its usage is limited to deprecated RPC methods only. But fine I guess because the context is deprecation, which too is used sparingly.

    fjahr commented at 2:43 pm on January 5, 2026:
    I think the naming works in this context too because what is deprecated is the old behavior of an RPC. Even if it’s just one KV in this case it could be more. Just to give a different perspective :)

    janb84 commented at 3:04 pm on January 5, 2026:
    Had the same confusion but indeed, you could see that the “old version” is deprecated of the getpeerinfo RPC because of the field deprecation. Most importantly is that downstream RPC Users get it ;)
  14. rkrux approved
  15. rkrux commented at 1:34 pm on January 5, 2026: contributor
    crACK 4ce3f4a26565e9851af950728cda7bcc2242d0c2
  16. janb84 commented at 3:17 pm on January 5, 2026: contributor

    cr ACK 4ce3f4a26565e9851af950728cda7bcc2242d0c2

    PR deprecates startingheight field in getpeerinfo RPC because it’s (most probable) use-case “a heuristic for determining if we’re in IBD” isn’t correct anymore.

    It’s good to remove no longer valid RPC fields so that these field do not get mis-used downstream.

    Also did a small test to see if the warnings show up in the RPC help etc. The -deprecatedrpc=startingheight is picked up in bitcoind, could not see outcome because use of Regtest

  17. optout21 commented at 3:51 pm on January 5, 2026: contributor
    crACK 4ce3f4a26565e9851af950728cda7bcc2242d0c2 Also checked the usage of the m_starting_height field; used only in getpeerinfo (as discussed here) and in RPCConsole (RPCConsole::updateDetailWidget()). Future removal seems straightforward once it's deprecated from getpeerinfo`.
  18. achow101 commented at 11:10 pm on January 5, 2026: member
    ACK 4ce3f4a26565e9851af950728cda7bcc2242d0c2
  19. achow101 merged this on Jan 5, 2026
  20. achow101 closed this on Jan 5, 2026

  21. theStack deleted the branch on Jan 5, 2026

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-01-07 03:13 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me