-
Notifications
You must be signed in to change notification settings - Fork 1.2k
fix: missing mutex for bls::operator== #6722
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
base: develop
Are you sure you want to change the base?
Conversation
potentially it is not really related changes, and each commit can go to it's own PR. I am open for suggestions to split it to several PRs. |
WalkthroughThe changes update several components related to BLS signature handling and deterministic masternode state management. In the BLS wrapper class, internal buffer initialization and synchronization logic are revised, including always copying buffers in the assignment operator, refining serialization and equality checks to improve thread safety, and removing the 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (3)
💤 Files with no reviewable changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (6)
🔇 Additional comments (4)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
utACK 52abb92
src/evo/dmnstate.h
Outdated
@@ -255,7 +255,6 @@ class CDeterministicMNStateDiff | |||
|
|||
if (read_pubkey) { | |||
SER_READ(obj, obj.fields |= Field_nVersion); | |||
SER_READ(obj, obj.state.pubKeyOperator.SetLegacy(obj.state.nVersion == ProTxVersion::LegacyBLS)); |
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.
how does this not break stuff? Also, seems unrelated to "missing mutex"
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.
it's strange, that it indeed breaks stuff (see Udjin's comment).
Un-serialization of CBLSLazyWrapper
set legacy flag and second call of SetLegacy
looks llke double work
template<typename Stream>
inline void Unserialize(Stream& s, const bool specificLegacyScheme) const
{
std::unique_lock<std::mutex> l(mutex);
s.read(AsWritableBytes(Span{vecBytes.data(), BLSObject::SerSize}));
bufValid = std::any_of(vecBytes.begin(), vecBytes.end(), [](uint8_t c) { return c != 0; });
bufLegacyScheme = specificLegacyScheme;
objInitialized = false;
hash.SetNull();
}
once it's deserialized, proper flag should set already:
READWRITE(CBLSLazyPublicKeyVersionWrapper(const_cast<CBLSLazyPublicKey&>(obj.state.pubKeyOperator), obj.state.nVersion == ProTxVersion::LegacyBLS));
That's strange.
I removed all non-related commits from PR
src/bls/bls.h
Outdated
} else { | ||
obj.Reset(); |
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.
why drop this?
src/bls/bls.h
Outdated
if (!objInitialized) { | ||
if (bufValid && bufLegacyScheme != specificLegacyScheme) { | ||
obj.SetBytes(vecBytes, bufLegacyScheme); | ||
vecBytes = obj.ToBytes(specificLegacyScheme); | ||
} | ||
} else { | ||
if (!bufValid || (bufLegacyScheme != specificLegacyScheme)) { | ||
vecBytes = obj.ToBytes(specificLegacyScheme); | ||
bufValid = true; | ||
bufLegacyScheme = specificLegacyScheme; | ||
hash.SetNull(); | ||
} |
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.
why re-work this?
protx listdiff 850325 850326
check updatedMNs
develop:
{
"892048b276a248b44e0e0c498fe0133e19a9a19ff03d2a6201779759a9e597fc": {
"version": 2,
"pubKeyOperator": "a7676e9a8ef4eaafcf47451801388500aaa1c1994c5df1619eb3b54b83dfab28c7969b262454c0397fe6fc14dc8c62d9"
}
},
this PR:
{
"892048b276a248b44e0e0c498fe0133e19a9a19ff03d2a6201779759a9e597fc": {
"version": 2,
"pubKeyOperator": "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
}
},
Let's keep it focused maybe and keep a488c8d only |
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.
utACK a488c8d
Issue being fixed or feature implemented
Somehow, CBLSLazyWrapper works correctly till now and does not cause any failures even
CBLSLazyWrapper::operator==()
doesn't have mutex inside. Let's fix it!What was done?
Added mutex to operator== for CBLSWrapper; added ptrs comparision to operator== in case of compare
A==A
to avoid deadlock.How Has This Been Tested?
Run unit / functional tests.
Breaking Changes
N/A
Checklist: