-
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
net: Refactor message parsing (CNetMessage), adds flexibility #14046
net: Refactor message parsing (CNetMessage), adds flexibility #14046
Conversation
Any reason to not use |
I think shared is fine here and does allow more flexible handling in future with little cost (ref counting) |
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. |
utACK 59a7ce0f9de950b64c5e89dd29ebcd0b607b982e |
Adding an extra memory allocation for every network message isn't free. I'm concerned that we may be falling into overusing sharedptr "just in case", which is bad because it leaks performance in a diffuse way that doesn't show up well in profiles. Please don't use sharedptr where unique will work. If something new comes in in the future that needs a sharedptr then we can switch then. |
@gmaxwell To be clear, I agree we should avoid |
59a7ce0
to
f63893d
Compare
@sipa, @gmaxwell: However, I changed this PR now to use Thanks @251labs for the review, implemented all your suggestions. |
e43f3b7
to
837beb4
Compare
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.
Fix commit message "Use shared pointers for CNetMessage handling".
837beb4
to
689e20d
Compare
Fixed commit message issue reported by @promag |
7c1f556
to
c2f9c04
Compare
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.
c2f9c04583a3ffcae4a54d85bb49def58e79cef2 looks reasonable to me
c2f9c04
to
562a51a
Compare
Rebased. |
562a51a
to
daa4562
Compare
utACK c2f9c04. |
Is it really necessary to make Seems like you could just create a CNetMessageSerializer class (with different instances), to which some of the current |
@jonasschnelli Mind to follow up on @sipa's question? I have removed this from high priority for now, but happy to add back when you addressed the question. |
daa4562
to
48d789f
Compare
48d789f
to
a4803d3
Compare
a4803d3
to
c5816dc
Compare
Rebased |
Approach NACK. This is overkill; the message parsing/serializing logic can just move out of CNetMessage to avoid turning it into a virtual class. |
@sipa: Thanks for the review. Currently turning this into the approach you mentioned. I think it's doable though not super convinced right now due to the state necessary in parsing/serialization (hash, MAC). |
Needs rebase |
ed2dc5e Add override/final modifiers to V1TransportDeserializer (Pieter Wuille) f342a5e Make resetting implicit in TransportDeserializer::Read() (Pieter Wuille) 6a91499 Remove oversized message detection from log and interface (Pieter Wuille) b0e10ff Force CNetMessage::m_recv to use std::move (Jonas Schnelli) efecb74 Use adapter pattern for the network deserializer (Jonas Schnelli) 1a5c656 Remove transport protocol knowhow from CNetMessage / net processing (Jonas Schnelli) 6294ecd Refactor: split network transport deserializing from message container (Jonas Schnelli) Pull request description: **This refactors the network message deserialization.** * It transforms the `CNetMessage` into a transport protocol agnostic message container. * A new class `TransportDeserializer` (unique pointer of `CNode`) is introduced, handling the network buffer reading and the decomposing to a `CNetMessage` * **No behavioral changes** (in terms of disconnecting, punishing) * Moves the checksum finalizing into the `SocketHandler` thread (finalizing was in `ProcessMessages` before) The **optional last commit** makes the `TransportDeserializer` following an adapter pattern (polymorphic interface) to make it easier to later add a V2 transport protocol deserializer. Intentionally not touching the sending part. Pre-Requirement for BIP324 (v2 message transport protocol). Replacement for #14046 and inspired by a [comment](#14046 (comment)) from sipa ACKs for top commit: promag: Code review ACK ed2dc5e. marcinja: Code review ACK ed2dc5e ryanofsky: Code review ACK ed2dc5e. 4 cleanup commits added since last review. Unaddressed comments: ariard: Code review and tested ACK ed2dc5e. Tree-SHA512: bab8d87464e2e8742529e488ddcdc8650f0c2025c9130913df00a0b17ecdb9a525061cbbbd0de0251b76bf75a8edb72e3ad0dbf5b79e26f2ad05d61b4e4ded6d
Superseded. Closing. |
This refactors the code how incoming messages gets handled.
It adds flexibility for adding new transport types (encryption handshake, new message format).
This is a subset of #14032 and a pre-requirement for BIP151.