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
multiprocess compatibility updates #28721
Conversation
Needed to deserialize some types from spans like CScripts
…work across processes Needed to fix new wallet_groups.py and wallet_resendwallettransactions.py tests with multiprocess bitcoin-node executable.
… segfault Coin serialize method segfaults if IsSpent condition is true. This caused multiprocess code to segfault when serializing the Coin& output argument to of the Node::getUnspentOutput method if the coin was not found. Segfault could be triggered by double clicking and viewing transaction details in the GUI transaction list. Fix this by replacing Coin& output argument with optional<Coin> return value to avoid trying to serializing spent coins.
Needed by multiprocess support code to pass parsed configuration to a spawned process.
Also add test to make sure this doesn't get broken in the future. This was breaking vector<bool> serialization in multiprocess code because template current deduction guides would make it appear like vector<bool> could be converted to a span, but then the actual conversion to span would fail.
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.
I didn't review the Span commit yet.
ACK 28bddf9 🍍
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: ACK 28bddf90ccbb3a58d30210b6102220fa6253229f 🍍
5sCvwzO8Gj/WV/7QAif56fxTc3QT8+G/qXnBh/ZHH/rKxUb25SXW7I3/m26dnr0KfVVDVQGfar78kL1Yc4E5Dg==
src/wallet/load.cpp
Outdated
{ | ||
for (const std::shared_ptr<CWallet>& pwallet : GetWallets(context)) { | ||
pwallet->postInitProcess(); | ||
} | ||
|
||
// Schedule periodic wallet flushes and tx rebroadcasts | ||
if (context.args->GetBoolArg("-flushwallet", DEFAULT_FLUSHWALLET)) { | ||
scheduler.scheduleEvery([&context] { MaybeCompactWalletDB(context); }, std::chrono::milliseconds{500}); | ||
context.scheduler->scheduleEvery([&context] { MaybeCompactWalletDB(context); }, std::chrono::milliseconds{500}); |
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.
nit in 62a0cea: Use 500ms
while touching this?
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.
src/wallet/interfaces.cpp
Outdated
void flush() override { return FlushWallets(m_context); } | ||
void stop() override { return StopWallets(m_context); } | ||
void setMockTime(int64_t time) override { return SetMockTime(time); } | ||
void schedulerMockForward(std::chrono::seconds delta) override { m_context.scheduler->MockForward(delta); } |
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.
nit in 62a0cea: Missing Assert()
to turn UB into a crash?
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.
src/qt/transactiondesc.cpp
Outdated
@@ -360,12 +360,11 @@ QString TransactionDesc::toHTML(interfaces::Node& node, interfaces::Wallet& wall | |||
{ | |||
COutPoint prevout = txin.prevout; | |||
|
|||
Coin prev; | |||
if(node.getUnspentOutput(prevout, prev)) | |||
if (auto prev{node.getUnspentOutput(prevout)}) | |||
{ |
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.
nit in 22edd79: Move to the above line while touching? (clang-format)
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: #28721 (comment)
nit in 22edd79: Move to the above line while touching? (clang-format)
Thanks, updated
src/qt/transactiondesc.cpp
Outdated
{ | ||
{ | ||
strHTML += "<li>"; | ||
const CTxOut &vout = prev.out; | ||
const CTxOut &vout = prev->out; |
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.
nit in 22edd79: Clang-format while touching this line?
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.
// https://stackoverflow.com/questions/68759148/sfinae-to-detect-the-explicitness-of-a-ctad-deduction-guide | ||
// https://stackoverflow.com/questions/16568986/what-happens-when-you-call-data-on-a-stdvectorbool | ||
template<typename T> | ||
using DataResult = std::remove_pointer_t<decltype(std::declval<T&>().data())>; |
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.
1fba885: I wonder if it is easier to just delete the content of this file and replace it with using Span = std::span
?
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: #28721 (comment)
1fba885: I wonder if it is easier to just delete the content of this file and replace it with
using Span = std::span
?
Switching from Span to std::span might work, but it's a bigger change and I'd expect it to require other fixes and not just be a drop-in replacement.
If replacing span gets implemented and merged first, that's great and this commit can be dropped. But otherwise the actual code change here is small. I wouldn't want multiprocess code to depend on replacing span when there is a direct fix here which is 3 lines and is just adding two !std::is_void_v
checks.
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.
Appreciate the review
Updated 28bddf9 -> 3b70f7b (pr/ipcfix.2
-> pr/ipcfix.3
, compare) with review suggestions.
// https://stackoverflow.com/questions/68759148/sfinae-to-detect-the-explicitness-of-a-ctad-deduction-guide | ||
// https://stackoverflow.com/questions/16568986/what-happens-when-you-call-data-on-a-stdvectorbool | ||
template<typename T> | ||
using DataResult = std::remove_pointer_t<decltype(std::declval<T&>().data())>; |
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: #28721 (comment)
1fba885: I wonder if it is easier to just delete the content of this file and replace it with
using Span = std::span
?
Switching from Span to std::span might work, but it's a bigger change and I'd expect it to require other fixes and not just be a drop-in replacement.
If replacing span gets implemented and merged first, that's great and this commit can be dropped. But otherwise the actual code change here is small. I wouldn't want multiprocess code to depend on replacing span when there is a direct fix here which is 3 lines and is just adding two !std::is_void_v
checks.
src/qt/transactiondesc.cpp
Outdated
@@ -360,12 +360,11 @@ QString TransactionDesc::toHTML(interfaces::Node& node, interfaces::Wallet& wall | |||
{ | |||
COutPoint prevout = txin.prevout; | |||
|
|||
Coin prev; | |||
if(node.getUnspentOutput(prevout, prev)) | |||
if (auto prev{node.getUnspentOutput(prevout)}) | |||
{ |
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: #28721 (comment)
nit in 22edd79: Move to the above line while touching? (clang-format)
Thanks, updated
src/qt/transactiondesc.cpp
Outdated
{ | ||
{ | ||
strHTML += "<li>"; | ||
const CTxOut &vout = prev.out; | ||
const CTxOut &vout = prev->out; |
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.
src/wallet/interfaces.cpp
Outdated
void flush() override { return FlushWallets(m_context); } | ||
void stop() override { return StopWallets(m_context); } | ||
void setMockTime(int64_t time) override { return SetMockTime(time); } | ||
void schedulerMockForward(std::chrono::seconds delta) override { m_context.scheduler->MockForward(delta); } |
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.
src/wallet/load.cpp
Outdated
{ | ||
for (const std::shared_ptr<CWallet>& pwallet : GetWallets(context)) { | ||
pwallet->postInitProcess(); | ||
} | ||
|
||
// Schedule periodic wallet flushes and tx rebroadcasts | ||
if (context.args->GetBoolArg("-flushwallet", DEFAULT_FLUSHWALLET)) { | ||
scheduler.scheduleEvery([&context] { MaybeCompactWalletDB(context); }, std::chrono::milliseconds{500}); | ||
context.scheduler->scheduleEvery([&context] { MaybeCompactWalletDB(context); }, std::chrono::milliseconds{500}); |
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 3b70f7b |
1 similar comment
ACK 3b70f7b |
re-ACK 3b70f7b 🎆 Show signatureSignature:
|
This is a collection of small changes to interfaces and code which were needed as part of multiprocess PR #10102, but have been moved here to make that PR smaller.
All of these changes are refactoring changes which do not affect behavior of current code
This PR is part of the process separation project.