m_bip152_highbandwith{to,from}
, nTimeOffset
, nVersion
, m_greates_common_version
.
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
See 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.
Reviewers, 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.
121@@ -122,15 +122,15 @@ static RPCHelpMan getpeerinfo()
122 {RPCResult::Type::NUM, "bytessent", "The total bytes sent"},
123 {RPCResult::Type::NUM, "bytesrecv", "The total bytes received"},
124 {RPCResult::Type::NUM_TIME, "conntime", "The " + UNIX_EPOCH_TIME + " of the connection"},
125- {RPCResult::Type::NUM, "timeoffset", "The time offset in seconds"},
126+ {RPCResult::Type::NUM, "timeoffset", /*optional=*/true, "The time offset in seconds"},
What’s the goal of this refactor?
This is continuing the work outlined here: https://github.com/bitcoin/bitcoin/issues/19398
@fanquake: drahtbot is misinterpreting your question :)
I think moving these is a good idea. The amount of code touched and the number of conflicting PRs is annoying though.
Might be better to move the elements individually when they’re useful for some patch that makes an observable change, though, rather than in a dedicated refactoring pr with no immediate benefit?
16@@ -17,9 +17,9 @@ def set_test_params(self):
17
18 def peer_info(self, from_node, to_node):
19 """Query from_node for its getpeerinfo about to_node."""
20- for peerinfo in self.nodes[from_node].getpeerinfo():
21- if "(testnode%i)" % to_node in peerinfo['subver']:
22- return peerinfo
23+ for peer in self.nodes[from_node].getpeerinfo():
subver
should no-longer be needed now that these fields are non-optional?
Commit message also mentions marking the field optional, but that no-longer happens (and doesn’t need to).
183@@ -184,6 +184,8 @@ static constexpr double MAX_ADDR_RATE_PER_SECOND{0.1};
184 static constexpr size_t MAX_ADDR_PROCESSING_TOKEN_BUCKET{MAX_ADDR_TO_SEND};
185 /** The compactblocks version we support. See BIP 152. */
186 static constexpr uint64_t CMPCTBLOCKS_VERSION{2};
187+/** Seed for the randomizer for the nonce field in version messages. SHA256("localhostnonce")[0:8] */
188+static constexpr uint64_t RANDOMIZER_ID_LOCALHOSTNONCE = 0xd93e69e2bbfa5735ULL;
In c25f0f1719fbda24a9dbfeb8e1c9d253d55807c2 could:
0static constexpr uint64_t RANDOMIZER_ID_LOCALHOSTNONCE{0xd93e69e2bbfa5735UL};
404@@ -405,6 +405,10 @@ struct Peer {
405 /** Protocol version indicated by the peer in its initial version message. */
406 std::atomic<int> m_version{0};
407
408+ /** Greates common protocol version that both we and the peer support. Set
Greates
and in the commit message m_greates_common_version
@ajtowns Thank you for having a look!
I think moving these is a good idea. The amount of code touched and the number of conflicting PRs is annoying though.
I generally do not agree with our “we hate rebasing” culture because there is no way to do collaborative development without rebasing. There are ~370 open PRs and avoiding conflicts is basically impossible. Merging something should boil down to whether or not the actual change is worthwhile and shouldn’t depend on whether or not other people can be bothered to rebase their PRs as a result.
The majority of the conflicts here are either drafts, need more work, mine or are failing CI and the rest (afaict) only conflict in a very minor way. But again even if this weren’t the case, I think it should just boil down to whether or not my changes are worthwhile.
Might be better to move the elements individually when they’re useful for some patch that makes an observable change, though, rather than in a dedicated refactoring pr with no immediate benefit?
This would take ten times longer, not reduce the number of conflicts and would likely just end up with someone requesting that I split out the “pure refactoring” commits into their own PR anyway. So we might as well just rip the band-aid of in one go.
How can you say that there is no immediate benefit, when this PR is continuing an ongoing project #19398, that we (as a project) had seemingly agreed on being a worthwhile thing? Basically all PRs related to #19398 have been of this nature. Did they all have no benefit?
How can you say that there is no immediate benefit,
The benefit of refactoring is that it makes future patches easier to write/test/review/etc. An immediate benefit would be that it makes a PR we have right now easier to write/test/review/etc. AFAIK there isn’t an open PR in the repo that this refactoring is making easier to write/test/review/etc, so that’s why I say there’s no immediate benefit.
Basically all PRs related to #19398 have been of this nature. Did they all have no benefit?
I think most of them also had no immediate benefit, yes, which is different to no benefit at all. At least one introduced a bug (#21160 vs #26569 / #26616), which is the opposite of an immediate benefit.
Like I said, I think this is a good idea. But even good ideas need to be prioritised; and for me refactorings default to coming very low on the list – they easily introduce both immediate costs (review of the refactoring, rebasing and re-review of conflicting PRs) and long term costs (when they introduce bugs despite the review), and the benefits are often only theoretical (“someday we might write a patch that this helps”) or a matter of opinion (“this makes the code look better to me”).
This would take ten times longer, not reduce the number of conflicts and would likely just end up with someone requesting that I split out the “pure refactoring” commits into their own PR anyway.
This PR’s been open for ~50 days; if no PR is going to benefit from this change for 500 days, then I’ve got no objection to leaving it unmerged for that long, or closing it and redoing it later. If we do manage a refactoring moratorium, then that will reduce the amount of rebasing of non-refactor PRs. And whether the refactoring is split out into a separate PR doesn’t seem like a big deal either way; the cost is time spent reviewing and rebasing, not in making a PR or not…
3456@@ -3431,6 +3457,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
3457 tx_relay->m_next_inv_send_time == 0s));
3458 }
3459
3460+ WITH_LOCK(m_version_nonces_mutex, m_version_nonces.erase(pfrom.GetId()));
As far as I can see, this is an optimization because entries in m_version_nonces
are only used to prevent self-connects, and at this point we can be sure we didn’t connect to ourselves, so the entry is no longer needed.
A comment here (or somewhere else about this) would be good.
397@@ -398,6 +398,10 @@ struct Peer {
398 /** Peer selected us as (compact blocks) high-bandwidth peer (BIP152). */
399 std::atomic<bool> m_bip152_highbandwidth_from{false};
400
401+ /** Time offset computed during the version handshake based on the
402+ * timestamp the peer send in the initial version message. */
Concept ACK
I do think that several of the conflicting PRs should be higher prio than this, but I also think that the rebases this will cause will be rather trivial in most of the cases.
Needs rebase if still relevant
Rebased
Needs rebase if still relevant
Thanks, rebased
Most of the stats in CNodeStateStats are now taken from the Peer object.
Rename the struct to PeerStats.
-BEGIN VERIFY SCRIPT-
ren() { sed -i "s:\<$1\>:$2:g" $(git grep -l "\<$1\>" ./src ./test); }
ren CNodeStateStats PeerStats
ren GetNodeStateStats GetPeerStats
ren nodeStateStats m_peer_stats
ren statestats peer_stats
ren fNodeStateStatsAvailable m_peer_stats_available
ren fStateStats peer_stats_available
-END VERIFY SCRIPT-
Also rename to m_clean_subversion.
Since the subversion is now contained in the Peer object, it may not be
available in `getpeerinfo` while the peer connection is being torn down.
Update the rpc help text to mark the field optional and update the tests
to tolerate the field being absent.
Handle version nonces entirely within net_processing.
🐙 This pull request conflicts with the target branch and needs rebase.