Skip to content

Conversation

jnewbery
Copy link
Contributor

@jnewbery jnewbery commented Jul 24, 2020

This PR makes a few minor clean-ups to Misbehaving() in preparation to move it out of the cs_main lock.

There are very minor logging changes but otherwise no functional changes.

@jnewbery
Copy link
Contributor Author

This is the next PR in the #19398 sequence to move application data into net_processing.

Copy link
Member

@jonatack jonatack left a comment

Choose a reason for hiding this comment

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

Pre-linter-appeasement ACK 2b5057d with one logging nit.

I think the last two commits touching Misbehaving() can be squashed; the changes are light and it's easier to review them together.

jnewbery added 3 commits July 25, 2020 15:49
Based on review comments from Marco Falke and Jon Atack.
Misbehaving() could optionally take a debug string for printing to the
log file. Make this mandatory and always provide the string.

A couple of additional minor changes:

- remove the unnecessary forward declaration of Misbehaving()
- don't include the nodeid or newline in the passed debug message.
Misbehaving() adds these itself.
- Make const things const.
- Replace conditional return with assert.
- Don't log the peer's IP address.
- Log the name Misbehaving directly instead of relying on __func__.
@jnewbery jnewbery force-pushed the 2020-07-tidy-misbehavior branch from 2b5057d to a8865f8 Compare July 25, 2020 14:52
@jnewbery
Copy link
Contributor Author

Thanks for the quick review @jonatack

I think the last two commits touching Misbehaving() can be squashed;

Done

Copy link
Contributor

@fjahr fjahr left a comment

Choose a reason for hiding this comment

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

Code review ACK a8865f8

@jonatack
Copy link
Member

ACK a8865f8

Copy link
Contributor

@promag promag left a comment

Choose a reason for hiding this comment

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

Code review ACK a8865f8.

Dunno if this breaks some existing log parser, but it's an easy fix, unless it needs the peer IP.

@jnewbery
Copy link
Contributor Author

jnewbery commented Jul 26, 2020

Thanks for the review @promag!

Dunno if this breaks some existing log parser, but it's an easy fix, unless it needs the peer IP.

We shouldn't be logging the peer IP inside net processing, and the I believe the only other place we do is during the version handshake. See #19472 (comment).

@hebasto
Copy link
Member

hebasto commented Jul 27, 2020

Concept ACK.

Copy link
Contributor

@troygiorshev troygiorshev left a comment

Choose a reason for hiding this comment

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

tACK a8865f8

{
if (howmuch == 0)
return;
assert(howmuch > 0);
Copy link
Contributor

Choose a reason for hiding this comment

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

Bugs me that I can't find a way to check this at compile time (like static_assert), being that we're always giving this parameter an integer literal :/

Copy link
Member

Choose a reason for hiding this comment

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

If you make it a templated function, you can pass in howmuch as a template parameter, enabling static_asserts on it. That may be a bit overkill, though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That may be a bit overkill, though.

And also would cause bloat in the built executable.

It's easy enough to grep all instances of Misbehaving. We don't need to automate everything :)

@fanquake fanquake changed the title Clean up Misbehaving() p2p: clean up Misbehaving() Jul 28, 2020
@fanquake fanquake merged commit 2979a7a into bitcoin:master Jul 28, 2020
@jnewbery jnewbery deleted the 2020-07-tidy-misbehavior branch July 28, 2020 07:27
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Jul 28, 2020
a8865f8 [net processing] Tidy up Misbehaving() (John Newbery)
d15b3af [net processing] Always supply debug message to Misbehaving() (John Newbery)
634144a [net processing] Fixup MaybeDiscourageAndDisconnect() style (John Newbery)

Pull request description:

  This PR makes a few minor clean-ups to `Misbehaving()` in preparation to move it out of the cs_main lock.

  There are very minor logging changes but otherwise no functional changes.

ACKs for top commit:
  troygiorshev:
    tACK a8865f8
  jonatack:
    ACK a8865f8
  fjahr:
    Code review ACK a8865f8
  promag:
    Code review ACK a8865f8.

Tree-SHA512: 98fb4f5f76399715545a1ea19290dcebfc8cb4eff72a1d3555dd3de6e184040bb8668c9651dab21db0dfd8e674e53a5977105ef76547146c9f6fa6b4b9d2ba59
deadalnix pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Jan 6, 2021
Summary:
```
This PR makes a few minor clean-ups to Misbehaving() in preparation to
move it out of the cs_main lock.

There are very minor logging changes but otherwise no functional
changes.
```

Backport of core [[bitcoin/bitcoin#19583 | PR19583]].

Depends on D8792.

Some of our Misbehaving messages are updated to match core messages.

Test Plan:
  ninja all check-all

Reviewers: #bitcoin_abc, majcosta

Reviewed By: #bitcoin_abc, majcosta

Subscribers: majcosta

Differential Revision: https://reviews.bitcoinabc.org/D8793
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Feb 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants