-
Notifications
You must be signed in to change notification settings - Fork 36.6k
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
refactor: Pass Peer& to Misbehaving() #25144
The head ref may contain hidden characters: "2205-mis-peer-\u{1F6E5}"
Conversation
switch (state.GetResult()) { | ||
case TxValidationResult::TX_RESULT_UNSET: | ||
break; | ||
// The node is providing invalid data: | ||
case TxValidationResult::TX_CONSENSUS: | ||
Misbehaving(nodeid, 100, message); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like the MaybePunish*
calls could accept a Peer&
(and CNodeState&
) as well, and also not be called when the peer is already disconnected?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but only because the message
happens to be empty()
in cases where the peer might be nullptr
/disconnected. I wasn't sure if we want to enforce this correlation.
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK fa825d1
The commit message is rather scarce. It is better if it contains all the info from the PR description. The latter is not part of the immutable git history and may be harder to access, especially if we move away from github at some point.
`Misbehaving` has several coding related issues (ignoring the conceptual issues here for now): * It is public, but it is not supposed to be called from outside of net_processing. Fix that by making it private and creating a public `UnitTestMisbehaving` method for unit testing only. * It doesn't do anything if a `nullptr` is passed. It would be less confusing to just skip the call instead. Fix that by passing `Peer&` to `Misbehaving()`. * It calls `GetPeerRef`, causing `!m_peer_mutex` lock annotations to be propagated. This is harmless, but verbose. Fix it by removing the no longer needed call to `GetPeerRef` and the no longer needed lock annotations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK fa8aa0a
LGTM, otherwise, but did only cursory code review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review ACK fa8aa0a
Misbehaving
has several coding related issues (ignoring the conceptual issues here for now):UnitTestMisbehaving
method for unit testing only.nullptr
is passed. It would be less confusing to just skip the call instead. Fix that by passingPeer&
toMisbehaving()
.GetPeerRef
, causing!m_peer_mutex
lock annotations to be propagated. This is harmless, but verbose. Fix it by removing the no longer needed call toGetPeerRef
and the no longer needed lock annotations.