Repository navigation
Conversation
prioritisetransaction accepts any int64 fee_delta, and CTxMemPool::PrioritiseTransaction only saturates the accumulated delta at the int64 limits. With large deltas the modified fees of a cluster add up past int64 in the txgraph chunk calculations (UBSan reports a signed overflow in FeeFrac::operator+=). For example, prioritising a parent by 2^62 and its child by INT64_MAX gives a negative chunk fee in getmempoolcluster, and both transactions are left out of block templates. Reject fee_delta values outside +-MAX_MONEY in the RPC, and clamp the accumulated delta to +-MAX_MONEY in PrioritiseTransaction (which also covers deltas loaded from mempool.dat). The modified fee is updated by the change in the clamped delta.
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. External sites
ReviewsSee the guideline and AI policy for information on the review process.
If your review is incorrectly listed, please copy-paste ConflictsNo conflicts as of last run. |
|
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 |
|
@sedited I looked at current master (a527a00) and both parts are unchanged: @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 |

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.