-
Notifications
You must be signed in to change notification settings - Fork 37.7k
Refactor message transport packaging #16562
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
Conversation
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsNo conflicts as of last run. |
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.
This is more a concept comment than code review. Looks like this approach causes reallocations? If the goal is to factor out from CConnman::PushMessage
have you considered something like class MessageWriterV1 : public MessageWriter
? The message writer V1 would still push 2 buffers to vSendMsg
(vSendMsg
should be accessible to the message writer). In other words, CConnman
wouldn't be responsible to push to vSendMsg
).
586b0b3
to
b840e42
Compare
@promag: yes. You'r right. The insert/reallocation was stupid. Slighly changed the approach. It is now also avoiding the behavior change. Also removed the unused return value (will eventually come back with the v2 implementation). |
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 b840e42, code reviewed, tests ok. Feel free to add comments if you rebase.
b840e42
to
88ddebb
Compare
Rebased this PR for you as well: master...dongcarl:2020-01-net_refactor_2-rebased |
88ddebb
to
16d6113
Compare
Thanks @dongcarl. Pushed your rebased version. |
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.
semiACK 16d6113 ran functional+unit tests.
While reading the code I found one observable difference which is the replacement of HEADER_SIZE
with serializedHeader.size()
. I'm not exactly sure which should be used here(they should be the same but maybe there's some DOS vector i'm missing)
other than that the pointer is allocated in the constructor so there shouldn't be a way to call it when null.
ACK 16d6113 FWIW Possible followup: Add properly formatted Doxygen comments (something like what's already in the abstract class) for, and/or rename |
Code review ACK 16d6113
@elichai I don't think there is a risk of DoS here, |
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 16d6113 🙎
Show signature and timestamp
Signature:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
ACK 16d6113f4faa901e248adb693d4768a9e5019a16 🙎
-----BEGIN PGP SIGNATURE-----
iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
pUhcGwv+Igl6tmkV78gSSi8EZt3582CuubMrSdBrB8UJ62ukEZVAmotmNR3ShTjM
rAmpiY7bxU0/2hW6Nr1YFo7t3FZ15dNPX2fTClctXXeLVFJdc1fSUwUg/oeRoJtm
T2CftFTfDrbU2o7HeX7rZvYSuieIl/SFBmNQ+w4jG8AFh4bCHH3pQVC7ueJhIHIx
qxKx9GNzwGOn3/rKCXj9vkEKRxHs/vGFDh4WYRezhEWkVvpe6996IiUMYVsIgyqm
npuGyOYoBmaSxj4z9PFHrL58AnnuRlUKy/1B0MyHz5v789b2swFn1iw5L9JTzOvh
dI9W2w7vkUnIaudUn1Z5dNPmVG8k7tmMAYvxE7TrhD1UgBRe2QYyNMt8CEJerxOd
50xlIKikLZxzL1ASwxatzPSKMl2ITprvIMrtoI0RrS1tPtfcXLnx10yr7EJ0dAxB
ZLs3GWZah5d/XLMDcyBSGWtiuWS+nkws4dAmZIlwBI/Qcm55dXAuW+Wocj59mtDE
QdnFfvp/
=gFtP
-----END PGP SIGNATURE-----
Timestamp of file with hash 2ae5b6b8bcff0b2640a243d5665c57ba947e1d6ef581e8eb4aa04cfd1b160d31 -
@@ -2703,6 +2716,7 @@ CNode::CNode(NodeId idIn, ServiceFlags nLocalServicesIn, int nMyStartingHeightIn | |||
} | |||
|
|||
m_deserializer = MakeUnique<V1TransportDeserializer>(V1TransportDeserializer(Params().MessageStart(), SER_NETWORK, INIT_PROTO_VERSION)); | |||
m_serializer = MakeUnique<V1TransportSerializer>(V1TransportSerializer()); |
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.
Any reason this needs to call the copy(or move) constructor?
m_serializer = MakeUnique<V1TransportSerializer>(V1TransportSerializer()); | |
m_serializer = MakeUnique<V1TransportSerializer>(); |
Any chance we can move forward with the It should hopefully be trivial to review :) |
16d6113 Refactor message transport packaging (Jonas Schnelli) Pull request description: This PR factors out transport packaging logic from `CConnman::PushMessage()`. It's similar to bitcoin#16202 (where we refactor deserialization). This allows implementing a new message transport protocol like BIP324. ACKs for top commit: dongcarl: ACK 16d6113 FWIW ariard: Code review ACK 16d6113 elichai: semiACK 16d6113 ran functional+unit tests. MarcoFalke: ACK 16d6113 🙎 Tree-SHA512: 8c2f8ab9f52e9b94327973ae15019a08109d5d9f9247492703a842827c5b5d634fc0411759e0bb316d824c586614b0220c2006410851933613bc143e58f7e6c1
@practicalswift: are you working on fuzz testing the serializing part? |
16d6113 Refactor message transport packaging (Jonas Schnelli) Pull request description: This PR factors out transport packaging logic from `CConnman::PushMessage()`. It's similar to bitcoin#16202 (where we refactor deserialization). This allows implementing a new message transport protocol like BIP324. ACKs for top commit: dongcarl: ACK 16d6113 FWIW ariard: Code review ACK 16d6113 elichai: semiACK 16d6113 ran functional+unit tests. MarcoFalke: ACK 16d6113 🙎 Tree-SHA512: 8c2f8ab9f52e9b94327973ae15019a08109d5d9f9247492703a842827c5b5d634fc0411759e0bb316d824c586614b0220c2006410851933613bc143e58f7e6c1
Summary: ``` This PR factors out transport packaging logic from CConnman::PushMessage(). It's similar to #16202 (where we refactor deserialization). This allows implementing a new message transport protocol like BIP324. ``` Backport of core [[bitcoin/bitcoin#16562 | PR16562]]. Test Plan: ninja all check-all Reviewers: #bitcoin_abc, PiRK, jasonbcox Reviewed By: #bitcoin_abc, PiRK, jasonbcox Differential Revision: https://reviews.bitcoinabc.org/D8374
@jonasschnelli: I've attempt to extend the test to serialization in #22029. I've also discovered that the deserialization does not proceed 60-70% of the time due to a failed checksum test. Will try to address that and increase coverage in another commit this week. |
This PR factors out transport packaging logic from
CConnman::PushMessage()
.It's similar to #16202 (where we refactor deserialization).
This allows implementing a new message transport protocol like BIP324.