Skip to content

Conversation

maflcko
Copy link
Member

@maflcko maflcko commented Jan 3, 2022

A file-wide suppression is problematic because it will wave through future violations, potentially bugs.

Fix that by using per-statement casts.

This refactor doesn't change behavior because the now explicit casts were previously done implicitly.

Similar to commit 8b5a4de

@DrahtBot
Copy link
Contributor

DrahtBot commented Jan 3, 2022

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #23629 (refactor tests to fix ubsan suppressions by MarcoFalke)
  • #21464 (Mempool Update Cut-Through Optimization by JeremyRubin)
  • #17786 (refactor: Nuke policy/fees->mempool circular dependencies by hebasto)

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.

@hebasto
Copy link
Member

hebasto commented Jan 3, 2022

Could we just avoid conversion from int64_t to size_t in

bitcoin/src/txmempool.cpp

Lines 114 to 117 in 75a227e

size_t CTxMemPoolEntry::GetTxSize() const
{
return GetVirtualTransactionSize(nTxWeight, sigOpCost);
}
and return int64_t?

@maflcko
Copy link
Member Author

maflcko commented Jan 3, 2022

Yes, potentially. Though, the goal of this pull is to keep all integer widths and types the same, only make implicit conversions explicit for the reasons mentioned in OP. Also, changing the return type of GetTxSize won't fix the implicit conversion for modifySize, which is already int64_t, so I think the changes here are needed either way.

@maflcko
Copy link
Member Author

maflcko commented Jan 3, 2022

I've checked that the binary doesn't change with clang -O2 on my system. (It does change with gcc, seemingly because functions are for some reason re-ordered in the object file).

@hebasto
Copy link
Member

hebasto commented Jan 3, 2022

Yes, potentially. Though, the goal of this pull is to keep all integer widths and types the same, only make implicit conversions explicit for the reasons mentioned in OP.

A conversion sequence int64_t --> size_t --> int64_t looks unneeded, doesn't it? Maybe it deserves its own PR?

Also, changing the return type of GetTxSize won't fix the implicit conversion for modifySize, which is already int64_t, so I think the changes here are needed either way.

Sure. ACK on uint64_t(modifySize) and uint64_t(modifyCount).

@maflcko
Copy link
Member Author

maflcko commented Jan 3, 2022

Maybe it deserves its own PR?

Yes, this should be done in another PR. I briefly looked into this, but this touches policy and miner as well. (It is a bit of a can of worms like #23633)

Copy link
Member

@hebasto hebasto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK fa4314f, I have reviewed the code and it looks OK, I agree it can be merged.

@hebasto
Copy link
Member

hebasto commented Jan 3, 2022

Maybe it deserves its own PR?

Yes, this should be done in another PR.

Done in #23962.

Copy link
Contributor

@shaavan shaavan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK fa4314f

  • I agree with the motivation of this PR.

A file-wide suppression is problematic because it will wave through future violations, potentially bugs.

  • Checked that each variable is properly typecasted explicitly.
  • Since the line implicit-integer-sign-change:txmempool.cpp has been removed from santizer_supression/urban list, and the CI passed successfully, that means as of now, there are no more variables in txmempool.cpp that requires explicit type conversion.

@maflcko
Copy link
Member Author

maflcko commented Jan 4, 2022

Done in #23962.

Thanks, closing this for now to avoid merge conflicts.

@maflcko maflcko closed this Jan 4, 2022
@maflcko maflcko deleted the 2201-remTxPool branch January 4, 2022 09:33
@bitcoin bitcoin locked and limited conversation to collaborators Jan 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants