Could squash, given that the other pull was closed?
Commits have been reordered to keep changes focused.
shaavan
commented at 3:35 pm on January 4, 2022:
contributor
Concept ACK
I think it makes sense to use int64_t consistently for all transaction sizes.
I have yet to thoroughly review the file to check if all the transaction size variables are correctly covered in this PR; I still find some that could use a proper type assignment.
Here. The type of entry_size can be changed to int64_t. This will lead to making appropriate changes at the other places in the file.
Here. Type of totalSizeWithAncestors could be changed.
Btw I was curious about one thing. In line 232 in this file, there is implicit typecasting occurring:
0totalSizeWithAncestors += stageit->GetTxSize();
because type of totalSizeWithAncestors is size_t and return type of GetTxSize() is changed to int64_t in this PR (line 114) . Shouldn’t it cause implicit-conversion-warning for this.
glozow
commented at 4:13 pm on January 4, 2022:
member
Concept ACK to unifying types for transaction sizes. But if we’re going to do this, why use a signed type? We don’t have negative sizes, do we?
maflcko
commented at 4:54 pm on January 4, 2022:
member
Concept ACK to unifying types for transaction sizes. But if we’re going to do this, why use a signed type? We don’t have negative sizes, do we?
The rule of thumb is to use signed types for anything that involves arithmetic operations (addition or subtraction). Obviously the standard library doesn’t make that easy with size_t being unsigned.
hebasto
commented at 8:54 am on January 5, 2022:
member
luke-jr
commented at 7:27 am on January 12, 2022:
member
Concept NACK [edit: to 64-bit sizes, which this PR no longer is]. This wastes memory for no benefit - we should probably go to int32_t instead.
Transactions should never approach 2 GB, and it doesn’t make sense to calculate a sum that large either (the largest package that could fit in a block is 4 MB).
If using int32_t produces warnings somewhere, those warnings are probably real issues that should be fixed.
DrahtBot added the label
Needs rebase
on Jan 20, 2022
hebasto force-pushed
on Jan 24, 2022
hebasto renamed this:
Use int64_t type for transaction sizes consistently
Use int32_t type for transaction sizes consistently
on Jan 24, 2022
hebasto renamed this:
Use int32_t type for transaction sizes consistently
Use int32_t type for transaction size/weight consistently
on Jan 24, 2022
hebasto
commented at 10:33 pm on January 24, 2022:
member
I think it makes sense to use int64_t consistently for all transaction sizes.
You are right. But such a pr could be unmanageable in size. So here, in the first commit, the minimal set of changes included which makes the second commit possible and concise. Other changes left for follow ups.
DrahtBot removed the label
Needs rebase
on Jan 25, 2022
DrahtBot added the label
Needs rebase
on Jan 25, 2022
maflcko removed the label
Mempool
on Jan 25, 2022
maflcko added the label
Consensus
on Jan 25, 2022
hebasto force-pushed
on Jan 25, 2022
hebasto
commented at 9:23 am on January 25, 2022:
member
Rebased 295a4f08728213270a0958680594c7548832ccfa -> 960f996449694fbf67ed0e70f0c1a81323cf151c (pr23962.03 -> pr23962.04) due to the conflict with #21464.
DrahtBot removed the label
Needs rebase
on Jan 25, 2022
shaavan
commented at 2:45 pm on January 25, 2022:
contributor
Changes since my review:
Replaced int64_t with int32_t for the transaction variables. This is done for the reason suggested in this comment, with which I agree.
Rebased over the current master.
I observed the following implicit conversion warning:
Ideally, this needs to be addressed by changing the ancestor_size_limit to int32_t and making other subsequent changes. But for this PR, we can go with at-place manual conversion, if that’s possible.
@hebasto
You are right. But such a pr could be unmanageable in size. So here, in the first commit, the minimal set of changes included which makes the second commit possible and concise. Other changes left for follow ups.
That makes sense. Let’s take up changing small sections of transaction_size variables one by one in follow-ups.
hebasto force-pushed
on Jan 31, 2022
hebasto
commented at 5:29 pm on January 31, 2022:
member
I observed the following implicit conversion warning:
Must be fixed now.
DrahtBot added the label
Needs rebase
on Feb 1, 2022
shaavan
commented at 10:26 am on February 1, 2022:
contributor
Changes since my last review:
Argument type of ancestor_size_limit in CTxMemPool::UpdateForDescendants function changed from uint64_t -> int64_t
I tried experimenting with converting the type of ancestor_size_limit to int32_t, and it compiled successfully without warnings.
So what do you think about converting this argument type to int32_t instead of int64_t. This would be in line with our end goal to do so for all transaction size/weight variables?
kiminuo
commented at 10:10 am on February 2, 2022:
contributor
DrahtBot added the label
Needs rebase
on Mar 8, 2022
hebasto renamed this:
Use int32_t type for transaction size/weight consistently
Use `int32_t` type for transaction size/weight consistently
on Apr 16, 2022
hebasto force-pushed
on Apr 16, 2022
hebasto
commented at 10:38 am on April 16, 2022:
member
DrahtBot removed the label
Needs rebase
on Apr 16, 2022
DrahtBot added the label
Needs rebase
on Jun 20, 2022
shaavan
commented at 1:10 pm on June 21, 2022:
contributor
Changes since my last review:
PR rebased on master
Suggestion:
I want to propose one suggestion.
The variables named modifySize deals with transaction size and are added with transaction size variables on multiple occasions. For example:
nSizeWithDescendants += modifySize;
However, its type is kept as int64_t.
This might be a deliberate choice based on the maximum possible size of integer that maybe get stored in it. But in case it’s not, I would suggest changing its type to int32_t.
I was able to successfully compile this PR with the following related diff:
DrahtBot removed the label
Needs rebase
on Jul 20, 2022
DrahtBot added the label
Needs rebase
on Sep 12, 2022
stickies-v
commented at 2:34 pm on October 6, 2022:
contributor
Concept ACK. Using 32 bits seems appropriate for sizes of transactions and transaction sets. Under the 100kb standardness rule, an unconfirmed transaction cannot exceed 400,000WU, which means this should never overflow for sets <= (2^31)/400,000 = 5,368 (unconfirmed) transactions which seems sufficient given the current limitations on ancestors and descendants, with room to grow.
Moving to signed integers seems like a worthwhile trade-off: half the range, but increased visibility into unexpected under/overflows.
I’ll do a full review once it’s rebased.
hebasto force-pushed
on Oct 6, 2022
hebasto
commented at 3:04 pm on October 6, 2022:
member
hebasto renamed this:
Use `int32_t` type for transaction size/weight consistently
Use `int32_t` type for most transaction size/weight values
on Dec 3, 2022
DrahtBot removed the label
Needs rebase
on Dec 3, 2022
DrahtBot added the label
Needs rebase
on Dec 6, 2022
hebasto force-pushed
on Dec 7, 2022
hebasto
commented at 12:42 pm on December 7, 2022:
member
Rebased 316a53a838be66bc15354d96a0376c9ffdbac61f -> 50e872ba71726488158097a7085c7c99ded1c777 (pr23962.10 -> pr23962.11) due to the conflict with #26609.
DrahtBot removed the label
Needs rebase
on Dec 7, 2022
DrahtBot added the label
Needs rebase
on Dec 21, 2022
hebasto force-pushed
on Jan 13, 2023
hebasto
commented at 11:02 am on January 13, 2023:
member
Rebased 50e872ba71726488158097a7085c7c99ded1c777 -> 93daff4b4577a07994b57218df9bb83bed7bf743 (pr23962.11 -> pr23962.12) due to the conflict with #26265 and #26289 .
DrahtBot removed the label
Needs rebase
on Jan 13, 2023
murchandamus
commented at 7:52 pm on January 13, 2023:
contributor
ACK93daff4b4577a07994b57218df9bb83bed7bf743
achow101
commented at 6:50 pm on January 18, 2023:
member
ISTM we should also change GetBlockWeight, GetTransactionInputWeight, GetVirtualTransactionSize, and GetVirtualTransactionInputSize to also use int32_t?
hebasto
commented at 4:27 pm on January 23, 2023:
member
ISTM we should also change GetBlockWeight, GetTransactionInputWeight, GetVirtualTransactionSize, and GetVirtualTransactionInputSize to also use int32_t?
Agree. But I’d rather leave this PR as is, because suggested changes does look trivial and could be left for follow ups. For example, GetVirtualTransactionSize involves arithmetic operations with int64_t nSigOpCost, and additional changes/checks could be required.
achow101
commented at 8:33 pm on January 26, 2023:
member
ACK93daff4b4577a07994b57218df9bb83bed7bf743
hebasto
commented at 1:38 pm on March 22, 2023:
member
In commit “Remove txmempool implicit-integer-sign-change sanitizer suppressions” (93daff4b4577a07994b57218df9bb83bed7bf743)
IIUC, the code here casting modifyCount to be unsigned and adding it even though modifyCount might be negative is safe because the standard guarantees that:
Casting modifyCount to uint64_t produces an equivalent value mod 264
Adding two uint64_t values is performed mod 264
Also, the new code is equivalent to previous code because previous code was just doing the same conversion implicitly.
However, it seems like it be nice to follow up by making nCountWithDescendants signed so the two casts could be dropped. So:
I agree with the suggested changes. In addition, it seems reasonable to combine them with making signed nCountWithAncestors and return types of the related getter methods as well. I’d leave such changes for a follow up. Or do you prefer to incorporate them in here?
Either way seems fine. I suggested it for a followup because it isn’t directly related to using a consistent type for transaction sizes. If you will make a follow up PR, you could consider dropping the second commit from this PR to avoid churn, since the second commit 93daff4b4577a07994b57218df9bb83bed7bf743 also isn’t directly related to tx sizes. But whatever you want to do is fine.
murchandamus
commented at 7:19 pm on June 12, 2023:
Re-reviewing this basically from scratch, I stumble here. int32_t should be big enough to represent the weight of more than 5,000 max standard weight transactions. Are we actually bumping into overflow issues with int32_t somewhere for size with descendants?
I see that this was brought up before, so I assume it was left a 64-bit value to limit the scope of this PR. Is that right?
DrahtBot requested review from achow101
on Jun 12, 2023
DrahtBot requested review from ryanofsky
on Jun 12, 2023
ryanofsky approved
ryanofsky
commented at 7:39 pm on June 12, 2023:
contributor
Code review ACK3ef756a5b558a1dd2fcb93bc0d4237707aa04f3f. Since last review, just rebased with more type changes in test and tracing code
hebasto marked this as ready for review
on Jun 12, 2023
DrahtBot removed the label
CI failed
on Jun 12, 2023
achow101
commented at 9:52 pm on June 12, 2023:
member
ACK3ef756a5b558a1dd2fcb93bc0d4237707aa04f3f
DrahtBot removed review request from achow101
on Jun 12, 2023
achow101
commented at 9:59 pm on June 12, 2023:
member
Something that just occurred to me: do/should we consider tracepoints to be a stable api? Since this changes the types for some of the tracepoints, this would ostensibly break any third party programs that rely on those tracepoints.
hebasto
commented at 6:06 am on June 13, 2023:
member
The silent conflict with the #26531 has been resolved in the recent push. As this PR touches tracepoints now, @0xB10C@virtu maybe you want to look into it?
Something that just occurred to me: do/should we consider tracepoints to be a stable api?
No, we shouldn’t. I think that classes like CTxMemPoolEntry and their public access method return types should be considered as mempool implementation details for all purposes. Maybe tracepoint docs need an explicit note about that?
0xB10C
commented at 2:14 pm on June 13, 2023:
contributor
ACK3ef756a5b558a1dd2fcb93bc0d4237707aa04f3f. I’ve focused my testing and code review on the tracepoint related changes. The docs, the test, and the mempool_monitor.py demo script are updated. I ran the interface_usdt_mempool.py test and the mempool_monitor.py script. The mempool_monitor.py output looks correct.
Something that just occurred to me: do/should we consider tracepoints to be a stable api?
No, we shouldn’t. I think that classes like CTxMemPoolEntry and their public access method return types should be considered as mempool implementation details for all purposes.
The goal of the tracepoints is to expose implementation details. This means, if an implementation detail changes, the tracepoint interface can change too. As an extreme example: If we’d remove the mempool, we’d also drop the mempool tracepoints. Third party programs have to adapt in this case.
achow101 merged this
on Jun 13, 2023
achow101 closed this
on Jun 13, 2023
hebasto deleted the branch
on Jun 13, 2023
sidhujag referenced this in commit
753f92b891
on Jun 15, 2023
maflcko
commented at 3:27 pm on June 15, 2023:
member
This causes warnings when compiling for 32 bit?
0txmempool.cpp:174:60: error: comparison of integers of different signs: 'long long' and 'uint64_t' (aka 'unsigned long long') [-Werror,-Wsign-compare]
1 if (stageit->GetSizeWithDescendants() + entry_size > static_cast<uint64_t>(limits.descendant_size_vbytes)) {
2 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
31 error generated.
hebasto
commented at 3:34 pm on June 15, 2023:
member
This causes warnings when compiling for 32 bit?
The relevant CI tasks logs are clean. How to reproduce it?
maflcko
commented at 3:53 pm on June 15, 2023:
member
Steps to reproduce:
( cd depends && make HOST=i686-pc-linux-gnu CC='clang -m32' CXX='clang++ -m32 -Wsign-compare' NO_QT=1 NO_WALLET=1 NO_ZMQ=1 NO_UPNP=1 NO_NATPMP=1 -j $(nproc) ) && ./autogen.sh && CONFIG_SITE="$PWD/depends/i686-pc-linux-gnu/share/config.site" ./configure && make -j $(nproc) src/bitcoind
glozow
commented at 12:51 pm on July 20, 2023:
member
This causes warnings when compiling for 32 bit?
@hebasto did you end up looking into this?
hebasto
commented at 1:29 pm on July 20, 2023:
member
This is a metadata mirror of the GitHub repository
bitcoin/bitcoin.
This site is not affiliated with GitHub.
Content is generated from a GitHub metadata backup.
generated: 2024-11-21 15:12 UTC
This site is hosted by @0xB10C More mirrored repositories can be found on mirror.b10c.me