Skip to content
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

Net: Move ping data to net_processing #20721

Merged
merged 6 commits into from
Feb 16, 2021

Conversation

jnewbery
Copy link
Contributor

@jnewbery jnewbery commented Dec 19, 2020

This continues the work of moving application layer data into net_processing, by moving all ping data into the new Peer object added in #19607.

For motivation, see #19398.

@fanquake fanquake added the P2P label Dec 19, 2020
@bitcoin bitcoin deleted a comment from sheffine Dec 21, 2020
@bitcoin bitcoin deleted a comment from sheffine Dec 21, 2020
@bitcoin bitcoin deleted a comment from sipa Dec 21, 2020
@jnewbery jnewbery marked this pull request as draft December 21, 2020 10:04
@jnewbery jnewbery marked this pull request as ready for review December 22, 2020 13:46
@jnewbery
Copy link
Contributor Author

Rebased on master. This is now ready for review.

Copy link
Contributor

@ajtowns ajtowns left a comment

Choose a reason for hiding this comment

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

Seems okay. Though, "jnewbery deleted a comment from sipa 3 days ago" ?

src/net_processing.cpp Outdated Show resolved Hide resolved
src/net_processing.h Outdated Show resolved Hide resolved
src/test/denialofservice_tests.cpp Outdated Show resolved Hide resolved
@DrahtBot
Copy link
Contributor

DrahtBot commented Dec 23, 2020

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

Conflicts

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.

@jnewbery
Copy link
Contributor Author

"jnewbery deleted a comment from sipa 3 days ago" ?

ha. There were two comments from sheffine saying "why are you emailing me?" and one from sipa saying "sheffine, you're confused", so I deleted them all to reduce noise.

@sipa
Copy link
Member

sipa commented Dec 23, 2020

Censorship!!!

(yes, that's indeed what happened)

@jnewbery
Copy link
Contributor Author

Thanks for the review @ajtowns. I'll move the commits around a bit to address your comments.

Copy link
Contributor

@murchandamus murchandamus left a comment

Choose a reason for hiding this comment

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

Can't really comment on the overall goal, as I don't really have a lot of context regarding either locks, mutexes, or peer management, but the linked motivation sounded good to me. The PR is easy to follow and each step makes sense to me. I found the first commit message to be a bit confusing:

No need to create another shared_ptr if ProcessMessages() already
has one in hand.

I take it to mean something along the lines of "Instead of creating another shared ptr, let's pass one that the callsite already has on hand.".

code review ACK 6f0309b

Copy link
Member

@glozow glozow left a comment

Choose a reason for hiding this comment

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

Concept ACK, although I have a bit of confusion about what constitutes net vs application layer, namely why best ping is still in CNode. You broke a few functional tests by removing minping from copyStats() which I assume is accidental?
For renaming, I personally think "best" is more informative than "min" but there's some inconsistency in naming now. It's still called 'minping' in getpeerinfo and m_min_ping_usec in CNodeStats.

src/net_processing.h Outdated Show resolved Hide resolved
src/net.h Outdated Show resolved Hide resolved
src/net.cpp Show resolved Hide resolved
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.

Concept ACK

A couple of thoughts on preliminary quick skim-through.

src/net.h Outdated Show resolved Hide resolved
src/rpc/net.cpp Outdated Show resolved Hide resolved
@jnewbery
Copy link
Contributor Author

@jnewbery
Copy link
Contributor Author

rebased

@jnewbery
Copy link
Contributor Author

Rebased

@glozow
Copy link
Member

glozow commented Feb 15, 2021

reACK a5e15ae

rebase-only by git range-diff a3ec04b...a5e15ae

Copy link
Contributor

@amitiuttarwar amitiuttarwar left a comment

Choose a reason for hiding this comment

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

ACK a5e15ae

lost track of the different versions so just re-reviewed the whole diff commit by commit.

definitely like having the m_peer_connect_timeout check as a function in net more than duplicating system time check in net_processing

in the future, I think it could make sense to have -peertimeout be limited to regtest. it's hidden behind debug-help, but technically possible on mainnet. I don't see how it'd be useful on mainnet though.

src/net.cpp Show resolved Hide resolved
src/net.h Show resolved Hide resolved
@maflcko
Copy link
Member

maflcko commented Feb 16, 2021

In the scripted diff I don't like that it may modify non-git user files (e.g. a net.h.rej file) in the same folder. Would be better to use git grep -l '...', which would also simplify review, as reviewers don't have to call git grep to verify the replacement was complete over all files, including docs.

review ACK a5e15ae 🥉

Show signature and timestamp

Signature:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

review ACK a5e15ae45ccae7948a6c5b95e6621f01afb88d55 🥉
-----BEGIN PGP SIGNATURE-----

iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
pUhixgv9EHlcd7Eo4IXpSgu8XZbUGYox8iHe1MU0pdDdnGPBjdnoB71xvMNUczaF
vDqmc9jIEfT19pPXGJfnOGQ53oWatA9be22GiLjZtjIA+w7slyjnTJ/WM2LCxA1V
EWX2X57ad+DwEHW7YCzmf5pxxm/KK9TV3h3kE9I1yUGwg6FR5INfIyzssPqULAt2
8BexUMoXXaqeAV6WOJRq/9wdtOcv2WwD7YLc340VjdmRRRkVflySKnx0/m2x6oo8
b3zBYj3YC6+UVmPRD2YIexoG+XHAVGXbc2kFRkeJ/Puknt7pWyurIsF6w+dgzM7B
YrsLzEwgO7mO4xvXfvHYwNKuNX3WJTFJ+gpL1dIN7UlJQis4p3bl56Sxtyw6cKM+
d8VZtjYkTcEpL3jKJYnIk4fHFA6WmHaRp7b4FQr6400G2bznF6AHMC2h0z5Jqhpy
63XIWO9kD89mIPxNgzUxA+id/3SoaNPRN0Mj62RxTWmbpRX2gIvCvF/MRZJsdEuC
TQhwMCuo
=FZw8
-----END PGP SIGNATURE-----

Timestamp of file with hash f094bc0ee463f6bec56659b9f20c20ab75a2f829388e57c839500e90f3c196a3 -

@fanquake fanquake merged commit 9bbf08b into bitcoin:master Feb 16, 2021
@jnewbery jnewbery deleted the 2020-12-ping-in-peer branch February 16, 2021 10:55
src/rpc/net.cpp Show resolved Hide resolved
src/net_processing.cpp Show resolved Hide resolved
jnewbery added a commit to jnewbery/bitcoin that referenced this pull request Feb 16, 2021
- rename to ShouldRunInactivityChecks (bitcoin#20721 (comment))
- take optional time now (bitcoin#20721 (comment))
- call from within InactivityChecks (bitcoin#20721 (comment))
- update comment (bitcoin#20721 (comment))
- change ordering of inequality (bitcoin#20721 (comment))
- make inline (bitcoin#20721 (comment))
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Feb 16, 2021
jnewbery added a commit to jnewbery/bitcoin that referenced this pull request Feb 17, 2021
- rename to ShouldRunInactivityChecks (bitcoin#20721 (comment))
- take optional time now (bitcoin#20721 (comment))
- call from within InactivityChecks (bitcoin#20721 (comment))
- update comment (bitcoin#20721 (comment))
- change ordering of inequality (bitcoin#20721 (comment))
jnewbery added a commit to jnewbery/bitcoin that referenced this pull request Feb 17, 2021
- rename to ShouldRunInactivityChecks (bitcoin#20721 (comment))
- take optional time now (bitcoin#20721 (comment))
- call from within InactivityChecks (bitcoin#20721 (comment))
- update comment (bitcoin#20721 (comment))
- change ordering of inequality (bitcoin#20721 (comment))
jnewbery added a commit to jnewbery/bitcoin that referenced this pull request Feb 18, 2021
- rename to ShouldRunInactivityChecks (bitcoin#20721 (comment))
- take optional time now (bitcoin#20721 (comment))
- call from within InactivityChecks (bitcoin#20721 (comment))
- update comment (bitcoin#20721 (comment))
- change ordering of inequality (bitcoin#20721 (comment))
jnewbery added a commit to jnewbery/bitcoin that referenced this pull request Feb 22, 2021
- rename to ShouldRunInactivityChecks (bitcoin#20721 (comment))
- take optional time now (bitcoin#20721 (comment))
- call from within InactivityChecks (bitcoin#20721 (comment))
- update comment (bitcoin#20721 (comment))
- change ordering of inequality (bitcoin#20721 (comment))
jnewbery added a commit to jnewbery/bitcoin that referenced this pull request Feb 26, 2021
- rename to ShouldRunInactivityChecks (bitcoin#20721 (comment))
- take optional time now (bitcoin#20721 (comment))
- call from within InactivityChecks (bitcoin#20721 (comment))
- update comment (bitcoin#20721 (comment))
- change ordering of inequality (bitcoin#20721 (comment))
jnewbery added a commit to jnewbery/bitcoin that referenced this pull request Mar 30, 2021
- rename to ShouldRunInactivityChecks (bitcoin#20721 (comment))
- take optional time now (bitcoin#20721 (comment))
- call from within InactivityChecks (bitcoin#20721 (comment))
- update comment (bitcoin#20721 (comment))
- change ordering of inequality (bitcoin#20721 (comment))
jnewbery added a commit to jnewbery/bitcoin that referenced this pull request Apr 1, 2021
- rename to ShouldRunInactivityChecks (bitcoin#20721 (comment))
- take optional time now (bitcoin#20721 (comment))
- call from within InactivityChecks (bitcoin#20721 (comment))
- update comment (bitcoin#20721 (comment))
- change ordering of inequality (bitcoin#20721 (comment))
laanwj added a commit that referenced this pull request Apr 1, 2021
5ed535a [net] Changes to RunInactivityChecks (John Newbery)

Pull request description:

  Updates the RunInactivityChecks() function:

  - rename to ShouldRunInactivityChecks (#20721 (comment))
  - take optional time now (#20721 (comment))
  - call from within InactivityChecks (#20721 (comment))
  - update comment (#20721 (comment))
  - change ordering of inequality (#20721 (comment))
  - ~make inline (#20721 (comment)

ACKs for top commit:
  laanwj:
    Code review ACK 5ed535a

Tree-SHA512: e6ac8e8cce5cddc84a52a40c908634c25f58be74512d642840d7bd7fa65c3d90a0f46cc19e4865b3fae7c933138247f58356167a60a5c519305cfd6d05e51f51
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Apr 1, 2021
…20721

5ed535a [net] Changes to RunInactivityChecks (John Newbery)

Pull request description:

  Updates the RunInactivityChecks() function:

  - rename to ShouldRunInactivityChecks (bitcoin#20721 (comment))
  - take optional time now (bitcoin#20721 (comment))
  - call from within InactivityChecks (bitcoin#20721 (comment))
  - update comment (bitcoin#20721 (comment))
  - change ordering of inequality (bitcoin#20721 (comment))
  - ~make inline (bitcoin#20721 (comment)

ACKs for top commit:
  laanwj:
    Code review ACK 5ed535a

Tree-SHA512: e6ac8e8cce5cddc84a52a40c908634c25f58be74512d642840d7bd7fa65c3d90a0f46cc19e4865b3fae7c933138247f58356167a60a5c519305cfd6d05e51f51
Fabcien pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Jan 25, 2022
Summary:
Refactor only. No change in behaviour.

Partial backport of [[bitcoin/bitcoin#20721 | core#20721]]:
bitcoin/bitcoin@f8b3058

Ref T1696.

Test Plan:
  ninja all check-all

Reviewers: #bitcoin_abc, PiRK

Reviewed By: #bitcoin_abc, PiRK

Maniphest Tasks: T1696

Differential Revision: https://reviews.bitcoinabc.org/D10873
Fabcien pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Jan 25, 2022
Summary:
```
Moves the logic to prevent running inactivity checks until the peer has been connected for -peertimeout time into its own function. This will be reused by net_processing later.
```

Partial backport of [[bitcoin/bitcoin#20721 | core#20721]]:
bitcoin/bitcoin@1a07600

Depends on D10873.

Ref T1696.

Test Plan:
  ninja all check-all

Reviewers: #bitcoin_abc, PiRK

Reviewed By: #bitcoin_abc, PiRK

Maniphest Tasks: T1696

Differential Revision: https://reviews.bitcoinabc.org/D10875
Fabcien pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Jan 25, 2022
Summary:
Partial backport of [[bitcoin/bitcoin#20721 | core#20721]]:
bitcoin/bitcoin@0b43b81

Ref T1696.

Depends on D10875.

Test Plan:
  ninja all check-all

Reviewers: #bitcoin_abc, PiRK

Reviewed By: #bitcoin_abc, PiRK

Maniphest Tasks: T1696

Differential Revision: https://reviews.bitcoinabc.org/D10876
Fabcien pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Jan 25, 2022
Summary:
```
Ping messages are an application-level mechanism. Move timeout
logic from net to net processing.
```

Partial backport of [[bitcoin/bitcoin#20721 | core#20721]]:
bitcoin/bitcoin@dd2646d

Ref T1696.

Test Plan:
  ninja all check-all

Reviewers: #bitcoin_abc, PiRK

Reviewed By: #bitcoin_abc, PiRK

Maniphest Tasks: T1696

Differential Revision: https://reviews.bitcoinabc.org/D10877
Fabcien added a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Jan 26, 2022
Summary:
Partial backport of [[bitcoin/bitcoin#20721 | core#20721]]:
bitcoin/bitcoin@45dcf22

Depends on D10898.

Ref T1696.

Test Plan:
  ninja all check-all

Reviewers: #bitcoin_abc, PiRK

Reviewed By: #bitcoin_abc, PiRK

Maniphest Tasks: T1696

Differential Revision: https://reviews.bitcoinabc.org/D10899
Fabcien pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Jan 26, 2022
Summary:
Original script:
```
-BEGIN VERIFY SCRIPT-
sed -i 's/fPingQueued/m_ping_queued/g' src/net_processing.cpp
sed -i 's/nMinPingUsecTime/m_min_ping_time/g' src/net.* src/net_processing.cpp src/test/net_tests.cpp
sed -i 's/nPingNonceSent/m_ping_nonce_sent/g' src/net_processing.cpp
sed -i 's/nPingUsecTime/m_last_ping_time/g' src/net.*
-END VERIFY SCRIPT-
```

Completes backport of [[bitcoin/bitcoin#20721 | core#20721]]:
bitcoin/bitcoin@a5e15ae

Depends on D10899.

Ref T1696.

Test Plan:
  ninja all check-all

Reviewers: #bitcoin_abc, PiRK

Reviewed By: #bitcoin_abc, PiRK

Maniphest Tasks: T1696

Differential Revision: https://reviews.bitcoinabc.org/D10900
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Aug 16, 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.