{
 "number": 36367,
 "repo": "bitcoin/bitcoin",
 "url": "https://github.com/bitcoin/bitcoin/pull/36367",
 "title": "mempool: keep prioritisetransaction deltas within MAX_MONEY",
 "author": "Bruce039",
 "author_association": "CONTRIBUTOR",
 "created_at": "2026-09-28T14:44:39Z",
 "updated_at": "2026-10-31T22:07:30Z",
 "description_hash": "ac5fe328226e8190",
 "age_days": 34,
 "draft": false,
 "labels": [
  "Mempool"
 ],
 "milestone": null,
 "base": "master",
 "head_sha": "0d168345063e6ba56155bfd97f647bbad4687546",
 "head_ref": "fix-prioritisetransaction-delta-range",
 "head_repo": "Bruce039/bitcoin",
 "head_history": [],
 "additions": 40,
 "deletions": 3,
 "changed_files": 3,
 "commit_count": 1,
 "size_bucket": "S",
 "mergeable_state": "clean",
 "bot": {
  "drahtbot": {
   "present": true,
   "reviews": {},
   "conflicts": []
  }
 },
 "acks_parsed": {},
 "acks_tally": {
  "ack": 0,
  "stale_ack": 0,
  "concept_ack": 0,
  "approach_ack": 0,
  "nack": 0,
  "concept_nack": 0,
  "approach_nack": 0
 },
 "reviews": {
  "approved": 0,
  "changes_requested": 0,
  "distinct_reviewers": []
 },
 "signals": {
  "needs_rebase": false,
  "ci_failed": false,
  "mergeable_state": "clean",
  "last_author_activity": "2026-09-28T14:20:46Z",
  "last_reviewer_activity": null,
  "last_reviewer": null,
  "author_silent_days": 34,
  "waiting_on_author_days": 0,
  "days_since_update": 1
 },
 "refs": {
  "mentioned": [],
  "depends_on": [],
  "fixes": [],
  "linked_issues": [],
  "references": [],
  "conflicts": []
 },
 "stack": {
  "shares_commits_with": [],
  "based_on": [],
  "base_for": []
 },
 "review_paths": [],
 "body": "`prioritisetransaction` takes `fee_delta` as any int64. `CTxMemPool::PrioritiseTransaction` stacks deltas with `SaturatingAdd`, so the accumulated delta and the modified fee can go up to `INT64_MAX`. The cluster mempool then adds modified fees of several transactions together in `FeeFrac` (util/feefrac.h:108) without overflow checks.\n\nFor example, with a parent and child in the mempool:\n\n```\nprioritisetransaction <parent> 0 4611686018427387904\nprioritisetransaction <child> 0 9223372036854775807\n```\n\n- `getmempoolcluster` reports `chunkfee: -46116860184.27356705`\n- `getblocktemplate` contains neither transaction, and the next block mined has only the coinbase\n- UBSan: `feefrac.h:108:13: runtime error: signed integer overflow`, reached from linearization via `getrawmempool`\n\nThere's no use for a delta larger than the total money supply, so this:\n\n- rejects `fee_delta` outside `-MAX_MONEY..MAX_MONEY` in the RPC with \"fee_delta out of range\"\n- clamps the accumulated delta to `-MAX_MONEY..MAX_MONEY` in `PrioritiseTransaction`, which also covers deltas loaded from mempool.dat, and updates the modified fee by the change in the clamped delta\n\nWith each modified fee bounded by 2 * MAX_MONEY, cluster sums stay far away from int64 limits.\n\nThe new `test_fee_delta_limits` in `mining_prioritisetransaction.py` checks the RPC range error, that stacked deltas stop at `MAX_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.py` and the miner/rbf/txpackage unit tests pass.\n\nAI tools were used to help find this issue and to prepare the patch and test.",
 "commits": [
  {
   "sha": "0d168345063e6ba56155bfd97f647bbad4687546",
   "date": "2026-09-28T14:20:46Z",
   "message": "mempool: keep prioritisetransaction deltas within MAX_MONEY\n\nprioritisetransaction accepts any int64 fee_delta, and\nCTxMemPool::PrioritiseTransaction only saturates the accumulated delta\nat the int64 limits. With large deltas the modified fees of a cluster\nadd up past int64 in the txgraph chunk calculations (UBSan reports a\nsigned overflow in FeeFrac::operator+=). For example, prioritising a\nparent by 2^62 and its child by INT64_MAX gives a negative chunk fee\nin getmempoolcluster, and both transactions are left out of block\ntemplates.\n\nReject fee_delta values outside +-MAX_MONEY in the RPC, and clamp the\naccumulated delta to +-MAX_MONEY in PrioritiseTransaction (which also\ncovers deltas loaded from mempool.dat). The modified fee is updated by\nthe change in the clamped delta."
  }
 ],
 "timeline": [],
 "labels_log": [
  {
   "t": "2026-09-28T14:44:48Z",
   "action": "labeled",
   "label": "Mempool",
   "who": "DrahtBot"
  }
 ],
 "state_log": [],
 "text_chars": 2544,
 "text_tokens_estimate": 636,
 "changed_paths": [
  "src/rpc/mining.cpp",
  "src/txmempool.cpp",
  "test/functional/mining_prioritisetransaction.py"
 ],
 "files": [
  {
   "path": "src/rpc/mining.cpp",
   "add": 4,
   "del": 0
  },
  {
   "path": "src/txmempool.cpp",
   "add": 7,
   "del": 3
  },
  {
   "path": "test/functional/mining_prioritisetransaction.py",
   "add": 29,
   "del": 0
  }
 ],
 "test_lines": 29,
 "git": {
  "head": "0d168345063e6ba56155bfd97f647bbad4687546",
  "head_matches_backup": true,
  "base": "05bc2f53ce0cb239c17dbdd6b261bd2db7d2a940",
  "patch_id": "381dea01a57af2b9",
  "commits": [
   {
    "sha": "0d16834506",
    "subject": "mempool: keep prioritisetransaction deltas within MAX_MONEY",
    "files": 3,
    "add": 40,
    "del": 3
   }
  ],
  "patch_truncated": false
 },
 "patch_id": "381dea01a57af2b9",
 "input_hash": "9b04a737d16d0a02",
 "extracted_at": "2026-11-02T01:09:49+00:00"
}