-
Notifications
You must be signed in to change notification settings - Fork 35.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
refactor: Make m_count_with_* in CTxMemPoolEntry int64_t, drop UBSAN supp #27890
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -370,17 +370,17 @@ void CTxMemPoolEntry::UpdateDescendantState(int32_t modifySize, CAmount modifyFe | |
nSizeWithDescendants += modifySize; | ||
assert(nSizeWithDescendants > 0); | ||
nModFeesWithDescendants = SaturatingAdd(nModFeesWithDescendants, modifyFee); | ||
nCountWithDescendants += uint64_t(modifyCount); | ||
assert(int64_t(nCountWithDescendants) > 0); | ||
Comment on lines
-373
to
-374
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In commit "refactor: Make m_count_with_* in CTxMemPoolEntry int64_t, drop UBSAN supp" (fa76f0d) Nice to see these casts go away. I thought it was confusing for this to intentionally a cast negative value to be unsigned and then rely on the way unsigned math wraps around (#23962 (comment)). Clearer to just use signed numbers. |
||
m_count_with_descendants += modifyCount; | ||
assert(m_count_with_descendants > 0); | ||
} | ||
|
||
void CTxMemPoolEntry::UpdateAncestorState(int32_t modifySize, CAmount modifyFee, int64_t modifyCount, int64_t modifySigOps) | ||
{ | ||
nSizeWithAncestors += modifySize; | ||
assert(nSizeWithAncestors > 0); | ||
nModFeesWithAncestors = SaturatingAdd(nModFeesWithAncestors, modifyFee); | ||
nCountWithAncestors += uint64_t(modifyCount); | ||
assert(int64_t(nCountWithAncestors) > 0); | ||
m_count_with_ancestors += modifyCount; | ||
assert(m_count_with_ancestors > 0); | ||
nSigOpCostWithAncestors += modifySigOps; | ||
assert(int(nSigOpCostWithAncestors) >= 0); | ||
} | ||
|
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.
In commit "refactor: Make m_count_with_* in CTxMemPoolEntry int64_t, drop UBSAN supp" (fa76f0d)
Maybe add a comment that this is intentionally returning uint64_t instead of int64_t for backwards compatibility.
Otherwise it might not be clear that a conversion is happening intentionally or which of the two types is wrong.
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 don't think any type is wrong, because the underlying (and thus returned) value is never negative. So the result should always be the same, regardless of the return type. Anyone should be free to pick whatever type they want. It is just that I didn't want to change it here, because it may cause warnings in other code, see #23962 (comment), which I think shouldn't have been changed either, on a second thought.