-
Notifications
You must be signed in to change notification settings - Fork 37.7k
serialization: Support for multiple parameters #28929
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. Code CoverageFor detailed information about the code coverage, see the test coverage report. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. 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.
Concept ACK
Concept ACK |
334f75a
to
97338ee
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.
Updated 334f75a -> 97338ee (pr/iparams.1
-> pr/iparams.2
, compare) adding comments and improving test
This commit makes a minimal change to the ParamsStream class to let it retrieve multiple parameters. Followup commits after this commit clean up code using ParamsStream and make it easier to set multiple parameters. Currently it is only possible to attach one serialization parameter to a stream at a time. For example, it is not possible to set a parameter controlling the transaction format and a parameter controlling the address format at the same time because one parameter will override the other. This limitation is inconvenient for multiprocess code since it is not possible to create just one type of stream and serialize any object to it. Instead it is necessary to create different streams for different object types, which requires extra boilerplate and makes using the new parameter fields a lot more awkward than the older version and type fields. Fix this problem by allowing an unlimited number of serialization stream parameters to be set, and allowing them to be requested by type. Later parameters will still override earlier parameters, but only if they have the same type. This change requires replacing the stream.GetParams() method with a stream.GetParams<T>() method in order for serialization code to retrieve the desired parameters. This change is more verbose, but probably a good thing for readability because previously it could be difficult to know what type the GetParams() method would return, and now it is more obvious.
Rebased 97338ee -> ffc1e9f ( |
|
Updated ffc1e9f -> 3c31173 ( re: #28929 (comment)
Fixed, thanks. Also renamed variables in the test to make it more readable |
nit: |
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.
did not review the last commit 3c31173 🚔
Show signature
Signature:
untrusted comment: signature from minisign secret key on empty file; verify via: minisign -Vm "${path_to_any_empty_file}" -P RWTRmVTMeKV5noAMqVlsMugDDCyyTSbA3Re5AkUrhvLVln0tSaFWglOw -x "${path_to_this_whole_four_line_signature_blob}"
RUTRmVTMeKV5npGrKx1nqXCw5zeVHdtdYURB/KlyA/LMFgpNCs+SkW9a8N95d+U4AP1RJMi+krxU1A3Yux4bpwZNLvVBKy0wLgM=
trusted comment: did not review the last commit 3c311734d2fc6a4ca410f254ba3c8e923d58be70 🚔
HgBPRyZaqsA6IWO/nWpFwiv5/omKRQ3fZmFGkrNfInSb0WBx0SgqbIdQPEkb2NkO/KoxscmLPJRXjk2Ia3ixCA==
3c31173
to
e02ab15
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.
Updated 3c31173 -> e02ab15 (pr/iparams.4
-> pr/iparams.5
, compare) using && and std::forward to support rvalue substream arguments and adding tests and documentation
e02ab15
to
33d99ba
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.
Updated e02ab15 -> 33d99ba (pr/iparams.5
-> pr/iparams.6
, compare) adding a new commit simplifying usage of ParamsStream in net.cpp, and fixing inaccurate lifetimebound 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.
left some comments/nits. Feel free to ignore.
very nice. lgtm ACK 33d99ba 👆
Show signature
Signature:
untrusted comment: signature from minisign secret key on empty file; verify via: minisign -Vm "${path_to_any_empty_file}" -P RWTRmVTMeKV5noAMqVlsMugDDCyyTSbA3Re5AkUrhvLVln0tSaFWglOw -x "${path_to_this_whole_four_line_signature_blob}"
RUTRmVTMeKV5npGrKx1nqXCw5zeVHdtdYURB/KlyA/LMFgpNCs+SkW9a8N95d+U4AP1RJMi+krxU1A3Yux4bpwZNLvVBKy0wLgM=
trusted comment: very nice. lgtm ACK 33d99bad01 👆
vYXG8JolRRudeR/EvljO02nNhTpLVh7ae9EjSBP82mgGSRDkUFhYYlnx9S2EOpzD0z1dE4QHOEHx7YYNx8ksAQ==
33d99ba
to
9dc839a
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.
Updated 33d99ba -> 9dc839a (pr/iparams.6
-> pr/iparams.7
, compare) applying various suggestions and splitting commits
ACK 9dc839a 📇 Show signatureSignature:
|
9dc839a
to
40f5055
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.
Updated 9dc839a -> 40f5055 (pr/iparams.7
-> pr/iparams.8
, compare) using concept to replace bool nested
as suggested
ACK 40f5055 🎦 Show signatureSignature:
|
utACK 40f5055 |
40f5055
to
8d491ae
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.
Updated 40f5055 -> 8d491ae (pr/iparams.8
-> pr/iparams.9
, compare) just adding const
as suggested
ACK 8d491ae 🔵 Show signatureSignature:
|
@theuni any chance you'd be interested in reviewing this? (There are 7 commits so this looks looks like a bigger change, but all the complexity is basically in the first commit, the other commits are small or obvious changes.) |
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.
Nice, reviewing this was fun.
ACK 8d491ae
@@ -1142,6 +1146,24 @@ class ParamsStream | |||
return m_substream.template GetParams<P>(); | |||
} | |||
} | |||
|
|||
//! Get reference to underlying stream. | |||
auto& GetStream() |
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.
Are you going to be using this method for other purposes besides tests and as an internal getter?
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.
re: #28929 (comment)
Are you going to be using this method for other purposes besides tests and as an internal getter?
I could see some other uses. Initially this was just added for testing, but then marco pointed out it could be used as an internal getter in #28929 (comment) to avoid recursion in read, write, size, etc methods. The other case it might be useful is if you have have a custom stream type like a file or socket and want to call some method on that stream that ParamsStream() is not wrapping, without having to pass around separate pointers to both streams.
auto& GetStream() | ||
{ | ||
if constexpr (ContainsStream<SubStream>) { | ||
return m_substream.GetStream(); |
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.
Just a comment: This does indeed not trigger clang-tidy's recursion check (I'm guessing because of the constexpr condition).
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.
Thanks for the review!
@@ -1142,6 +1146,24 @@ class ParamsStream | |||
return m_substream.template GetParams<P>(); | |||
} | |||
} | |||
|
|||
//! Get reference to underlying stream. | |||
auto& GetStream() |
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.
re: #28929 (comment)
Are you going to be using this method for other purposes besides tests and as an internal getter?
I could see some other uses. Initially this was just added for testing, but then marco pointed out it could be used as an internal getter in #28929 (comment) to avoid recursion in read, write, size, etc methods. The other case it might be useful is if you have have a custom stream type like a file or socket and want to call some method on that stream that ParamsStream() is not wrapping, without having to pass around separate pointers to both streams.
utACK 8d491ae |
@ryanofsky Sorry for not getting to this before merge. Will give it a look tomorrow. |
Currently it is only possible to attach one serialization parameter to a stream at a time. For example, it is not possible to set a parameter controlling the transaction format and a parameter controlling the address format at the same time because one parameter will override the other.
This limitation is inconvenient for multiprocess code since it is not possible to create just one type of stream and serialize any object to it. Instead it is necessary to create different streams for different object types, which requires extra boilerplate and makes using the new parameter fields a lot more awkward than the older version and type fields.
Fix this problem by allowing an unlimited number of serialization stream parameters to be set, and allowing them to be requested by type. Later parameters will still override earlier parameters, but only if they have the same type.
For an example of different ways multiple parameters can be set, see the new
with_params_multi
unit test.This change requires replacing the
stream.GetParams()
method with astream.GetParams<T>()
method in order for serialization code to retrieve the desired parameters. The change is more verbose, but probably a good thing for readability because previously it could be difficult to know what type theGetParams()
method would return, and now it is more obvious.This PR is part of the process separation project.