[24.x] backport rpc: Require NodeStateStats object in getpeerinfo #26457
pull jonatack wants to merge 1 commits into bitcoin:24.x from jonatack:24_x_backports changing 1 files +8 −0-
jonatack commented at 3:03 am on November 5, 2022: contributorBackports #26515.
-
DrahtBot added the label Backport on Nov 5, 2022
-
hebasto commented at 10:54 am on November 5, 2022: memberI doubt whether changes in translatable strings should be backported, as they will be unnoticed by translators.
-
in src/bitcoin-cli.cpp:645 in 0e4b959e0a outdated
641@@ -642,7 +642,7 @@ class NetinfoRequestHandler : public BaseRequestHandler 642 " send Time since last message sent to the peer, in seconds\n" 643 " recv Time since last message received from the peer, in seconds\n" 644 " txn Time since last novel transaction received from the peer and accepted into our mempool, in minutes\n" 645- " \"*\" - the peer requested we not relay transactions to it (relaytxes is false)\n" 646+ " \"*\" - we do not relay transactions to this peer (relaytxes is false)\n"
luke-jr commented at 3:37 pm on November 5, 2022:Sorry for the late comment, but where did this behaviour change? Or was the previous description always wrong?
I can only find (in 24.x) that the data moved around, possibly making it sometimes unavailable, but no behaviour changes…
jonatack commented at 5:40 pm on November 5, 2022:More the latter, I think: #25923 (review), #25176 (review).luke-jr commented at 3:38 pm on November 5, 2022: memberI doubt whether changes in translatable strings should be backported, as they will be unnoticed by translators.
Better to have an correct English string, than an incorrect native string. Assuming it is a fix.
mzumsande commented at 10:36 pm on November 15, 2022: contributorI was trying to understand how it is possible that
relaytxes
orminfeefilter
ofgetpeerinfo
can be non-existent (see also related IRC discussion): During connection setup (both inbound or outbound), we always first callInitializeNode()
before we add the new node tom_nodes
.InitializeNode()
adds aCNodeState
entry tom_node_states
and aPeerRef
tom_peer_map
. In thegetpeerinfo
RPC, we callconnman.GetNodeStats()
which loops overm_nodes
and returns copies of its entries. So if there is am_nodes
entry, there should always also be a CNodeState and a PeerRef for this peer at this exact point in time.The only situation I can think of in which
peerman.GetNodeStateStats()
could returnfalse
is if there is a race, such that a peer was returned from theGetNodeStats()
call ofgetpeerinfo
, but has been disconnected and removed when we callpeerman.GetNodeStateStats()
a bit later. I could verify this by adding a sleep afterGetNodeStats()
here, and manually disconnecting a peer before the RPC could continue. Maybe the best way to deal with that is just not reporting the already disconnected peer ingetpeerinfo
, and making the RPC result fields non-optional again. Thoughts on this?As for the impact: I think that the chance of hitting this without an artificially added sleep is quite low, so unless you fire up a getpeerinfo call multiple times in a second, you probably will never get into the situation where
relaytxes
orminfeefilter
are missing.maflcko commented at 8:33 am on November 16, 2022: memberMaybe the best way to deal with that is just not reporting the already disconnected peer in getpeerinfo, and making the RPC result fields non-optional again. Thoughts on this?
I always assumed that this may also happen when the CNode is spun up. Good to know it only happens on disconnect. However, I don’t think this will help us, as the
relaytxes
change was done on purpose, because you don’t know when the peer is going to send you their version message and what it contains. So I think the changes here are correct.maflcko approvedmaflcko commented at 8:33 am on November 16, 2022: memberlgtmin src/rpc/net.cpp:117 in 4b5f99e926 outdated
113@@ -114,7 +114,7 @@ static RPCHelpMan getpeerinfo() 114 { 115 {RPCResult::Type::STR, "SERVICE_NAME", "the service name if it is recognised"} 116 }}, 117- {RPCResult::Type::BOOL, "relaytxes", /*optional=*/true, "Whether we relay transactions to this peer"}, 118+ {RPCResult::Type::BOOL, "relaytxes", /*optional=*/true, "Whether we relay transactions to this peer (not available while peer connection is being set up)"},
jonatack commented at 6:38 pm on November 17, 2022:Agree, the intermittently absent state of the field was occurring at disconnection rather than at connection.mzumsande commented at 3:36 pm on November 16, 2022: contributorI don’t think this will help us, as the
relaytxes
change was done on purpose, because you don’t know when the peer is going to send you their version message and what it contains. So I think the changes here are correct.This PR targeted for backport only includes the doc changes wrt
relaytxes
, the functional change b54d8de243b6f04e6a328e9c0cbff7a17dd7fa1e of #26328 to report 3 states is not included here - also see comment below.DrahtBot commented at 3:36 pm on November 16, 2022: contributorThe following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
Reviews
See the guideline for information on the review process.
Type Reviewers ACK fanquake If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.
jonatack commented at 4:18 am on November 17, 2022: contributorjonatack commented at 4:21 am on November 17, 2022: contributorAs for the impact: I think that the chance of hitting this without an artificially added sleep is quite low, so unless you fire up a getpeerinfo call multiple times in a second, you probably will never get into the situation where
relaytxes
orminfeefilter
are missing.I do hit this for relaytxes more than rarely, but you may be correct that it happens only during peer deconnection. Edit: yes, peer disconnection.
maflcko referenced this in commit 82fe672ea0 on Nov 17, 2022bitcoin deleted a comment on Nov 17, 2022maflcko commented at 9:28 am on November 17, 2022: memberBetter to have an correct English string, than an incorrect native string. Assuming it is a fix.
On a second thought, I don’t think this should be backported, because it is not a regression, thus not a blocker at this stage of the release cycle.
No objection to a 24.1 backport, assuming it is a fix, but right now we should probably focus on real regressions/blockers/bugs for 24.0
maflcko added this to the milestone 24.1 on Nov 17, 2022maflcko removed this from the milestone 24.1 on Nov 17, 2022jonatack commented at 6:02 pm on November 17, 2022: contributorIt seems doubtful now as to whether making therelaytxes
andminfeefilter
fields intermittently absent brought any benefit (other than developers looking more into the code). However, I don’t think here is any doubt that it is a potential regression for users. One that is perhaps minor, but without a compelling reason to have done so.sidhujag referenced this in commit 1b969ba2d0 on Nov 18, 2022fanquake commented at 10:53 am on December 5, 2022: memberMaybe mark this as a draft for now? This is dependant on multiple other PRs (26328, which also has an alternative in 26516). It also needs updating to remove changes that are incorrect (4b5f99e9268e18748d0146250d3d403f80e409e0 - #26457 (review)), and to remove commits which are backporting changes that have since been reverted in master, i.e 0e4b959e0a3874233b1549f9e7a257f47d40539f (reverted in https://github.com/bitcoin-core/gui/pull/681).maflcko referenced this in commit 3d974960d3 on Dec 19, 2022sidhujag referenced this in commit bbc8a636d4 on Dec 19, 2022jonatack marked this as a draft on Jan 10, 2023jonatack force-pushed on Jan 10, 2023fanquake commented at 3:24 pm on January 11, 2023: memberConcept ~0 on backporting 24cbea4274b68823eccce8507ac348ed161f4aa9 and 5c03df1fce744fbc357e32f66f9a50b8e609c386 (which partially reverts the change in the prior commit). In master, we now only return this data if we have it (#26515), and if anything, it might make more sense to just backport that. We also haven’t had any reports of this being an issue post release.
995cdbf210a3a05fe1f991b9772f0b4e12bafe76 seems ok, but is then also partially reverted in the following commit: a34312b3b7231f5e8fc97c2b3746f1e3c1d29206.
Same in the last two commits. fe335508b9d9645d119c75fc06b7eb93473db538 is backported, only to be partially reverted it in the following commit: ba28fa73d65a96581961bdf088c82d37181c7e91.
If we are going to do this, it’d be nice to make the changes in a way where half the commits aren’t just (partially) reverting changes from the prior commit.
jonatack commented at 4:54 pm on January 11, 2023: contributorThanks, agree we should backport https://github.com/bitcoin/bitcoin/commit/6fefd49527fa0ed9535e54f2a3e76fe2599b2350. Is it fine to squash the order-dependent commits here and list their metadata in the same backport commit?. Edit: agree it’s enough to only backport #26515.jonatack renamed this:
[24.x] backports for tx relay changes in getpeerinfo/netinfo/gui
[24.x] backport rpc: skip getpeerinfo for a peer without CNodeStateStats
on Jan 11, 2023jonatack force-pushed on Jan 11, 2023rpc: Require NodeStateStats object in getpeerinfo
There is no situation in which CNodeStateStats could be missing for a legitimate reason - this can only happen if there is a race condition between peer disconnection and the getpeerinfo call, in which case the disconnected peer doesn't need to be included in the response. Github-Pull: bitcoin#26515 Rebased-From: 6fefd49
jonatack force-pushed on Jan 11, 2023fanquake commented at 12:21 pm on January 18, 2023: memberagree it’s enough to only backport #26515.
Should this be undrafted then, given that PR is what it currently backports?
cc @mzumsande
maflcko added this to the milestone 24.1 on Jan 19, 2023jonatack marked this as ready for review on Jan 19, 2023fanquake approvedfanquake commented at 11:21 am on January 20, 2023: memberACK e72313e6b3fbf865e0eaa9aee0a555b7a7fe6850fanquake merged this on Jan 20, 2023fanquake closed this on Jan 20, 2023
jonatack deleted the branch on Jan 20, 2023fanquake renamed this:
[24.x] backport rpc: skip getpeerinfo for a peer without CNodeStateStats
[24.x] backport rpc: Require NodeStateStats object in getpeerinfo
on Mar 12, 2023DrahtBot renamed this:
[24.x] backport rpc: Require NodeStateStats object in getpeerinfo
[24.x] backport rpc: Require NodeStateStats object in getpeerinfo
on Mar 12, 2023fanquake referenced this in commit 9e05de1d70 on Mar 13, 2023bitcoin locked this on Mar 11, 2024
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: 2024-12-23 15:12 UTC
More mirrored repositories can be found on mirror.b10c.me