mirror of
https://github.com/bitcoin/bitcoin
synced 2026-12-04 10:17:37 +00:00
mempool: keep prioritisetransaction deltas within MAX_MONEY #36367
No reviewers
Labels
No labels
Android
Backport
Block storage
Brainstorming
Bug
Build system
CI failed
Consensus
Data corruption
Descriptors
Docs
DrahtBot Guix build requested
Feature
Fuzzing
GUI
Good First Review
IPC
Insufficient Review
Kernel
Linux/Unix
Mempool
Mining
Needs Backport (31.x)
Needs Backport (32.x)
Needs Benchmark
Needs Conceptual Review
Needs backport (30.x)
Needs rebase
Needs release note
Net
P2P
PSBT
Privacy
Private Broadcast
Questions and Help
RPC/REST/ZMQ
Refactoring
Resource usage
Review club
Scripts and tools
Settings
TX fees and policy
Tests
Tracking Issue
UTXO Db and Indexes
Up for grabs
Upstream
Utils/log/libs
Validation
Waiting for author
Wallet
Windows
good first issue
interfaces
macOS
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
bitcoin/bitcoin!36367
Loading…
Reference in a new issue
No description provided.
Delete branch "fix-prioritisetransaction-delta-range"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
prioritisetransactiontakesfee_deltaas any int64.CTxMemPool::PrioritiseTransactionstacks deltas withSaturatingAdd, so the accumulated delta and the modified fee can go up toINT64_MAX. The cluster mempool then adds modified fees of several transactions together inFeeFrac(util/feefrac.h:108) without overflow checks.For example, with a parent and child in the mempool:
getmempoolclusterreportschunkfee: -46116860184.27356705getblocktemplatecontains neither transaction, and the next block mined has only the coinbasefeefrac.h:108:13: runtime error: signed integer overflow, reached from linearization viagetrawmempoolThere's no use for a delta larger than the total money supply, so this:
fee_deltaoutside-MAX_MONEY..MAX_MONEYin the RPC with "fee_delta out of range"-MAX_MONEY..MAX_MONEYinPrioritiseTransaction, which also covers deltas loaded from mempool.dat, and updates the modified fee by the change in the clamped deltaWith each modified fee bounded by 2 * MAX_MONEY, cluster sums stay far away from int64 limits.
The new
test_fee_delta_limitsinmining_prioritisetransaction.pychecks the RPC range error, that stacked deltas stop atMAX_MONEY, that the chunk fees add up, and that both transactions are in the block template. It fails on master ("No exception raised").mempool_persist.py,mempool_packages.py,rpc_packages.pyand the miner/rbf/txpackage unit tests pass.AI tools were used to help find this issue and to prepare the patch and test.
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
External sites
Reviews
See the guideline and AI policy for information on the review process.
If your review is incorrectly listed, please copy-paste
<!--meta-tag:bot-skip-->into the comment that the bot should ignore.Conflicts
No conflicts as of last run.
Earlier concerns remain unresolved; see the full report for their current assessments.
🔵 Suggestion · RPC help omits the new fee-delta limits
The prioritisetransaction help describes addition and subtraction without explaining the new accepted range or that successful calls can apply less than the requested adjustment.
Location:
src/rpc/mining.cpp:564(head).🔵 Suggestion · The fee-delta test never reaches the cumulative lower bound
The negative calls only cancel positive deltas, so removing the -MAX_MONEY floor would leave the new assertions unaffected.
Location:
test/functional/mining_prioritisetransaction.py:114(head).🔵 Suggestion · Persisted int64-extreme deltas lack boundary assertions
The new regression test rejects oversized RPC inputs before mempool arithmetic, leaving the clamp's handling of raw int64 deltas from mempool.dat without deterministic boundary coverage.
Location:
test/functional/mining_prioritisetransaction.py:98(head).Review coverage was incomplete.
Reviewed:
0d168345063e· Full review report · Previous reportspermalink
There's been recent work in this area, is this still an issue? Can you give this a quick look @ismaelsadeeq?
Concept ACK, why max money? I think preventing it from overflowing should be the goal here; having the fee above max money won't hurt; it's just a way to prioritise txs during inclusion in the block template.
I think it is just a best-effort attempt to prevent
SaturatingAdd(delta, nFeeDelta)to saturate too often. Though, I haven't yet looked if this is possible/testable.@sedited I looked at current master (
a527a0077a) and both parts are unchanged:CTxMemPool::PrioritiseTransactionstill stacks deltas withSaturatingAdd, andFeeFrac::operator+=still adds the fees without an overflow check. So the parent/child example from the description should still lead to the negative chunk fee and the empty block template. The only related open PR I found is #35511 (CAmountas a class), which doesn't change this arithmetic.@ismaelsadeeq agreed, preventing the overflow is the actual goal, a large fee itself is harmless. Some bound on the delta is needed for that, though, and MAX_MONEY was the obvious one: no meaningful delta is larger than the total supply, and with every modified fee at most 2 * MAX_MONEY the sum over a whole cluster stays far below the int64 limit. As maflcko said, it also keeps
SaturatingAddfrom saturating in practice. If you'd rather cap it somewhere else, e.g. only at the point where fees are summed, I'm happy to change it.