Skip to content

[Review] Merge bitcoin/bitcoin#37020: rpc: fix getmempoolfeeratediagram result description - #6

Merged
jonatack merged 1 commit into
bitcoin-v:masterfrom
BTC4Peace:audit/pr-1ea904d983f8
Dec 1, 2026
Merged

jonatack merged 1 commit into
bitcoin-v:masterfrom
BTC4Peace:audit/pr-1ea904d983f8

Conversation

@auditbob

@auditbob auditbob Bot commented Nov 30, 2026

Copy link
Copy Markdown

Upstream commit: bitcoin/bitcoin@1ea904d

0b17fa0ac1091d8097b4da0c0bef896ede35a684 rpc: fix getmempoolfeeratediagram result description (nervana21)

Pull request description:

In #36175, maflcko found that "mempool chunks" was incorrectly rendered as a result branch label.

Fix it to annotate the array instead.

help getmempoolfeeratediagram diff
-Result (mempool chunks):
-[                    (json array)
+Result:
+[                    (json array) mempool chunks
   {                  (json object)
     "weight" : n,    (numeric) cumulative sigops-adjusted weight
     "fee" : n        (numeric) cumulative fee
   },
   ...
 ]

ACKs for top commit:
maflcko:
lgtm ACK 0b17fa0ac1091d8097b4da0c0bef896ede35a684

Tree-SHA512: 7dba3fb9f9b493a9e5f6192456b83bd872e312f70aeb2cc06ee737e4fbb194480aa387391482ea7dda8b283c930873f043cfde7d9665944907af6c84e490d87e

…iption

0b17fa0 rpc: fix getmempoolfeeratediagram result description (nervana21)

Pull request description:

  In bitcoin#36175, maflcko [found](bitcoin#36175 (comment)) that `"mempool chunks"` was incorrectly rendered as a result branch label.

  Fix it to annotate the array instead.

  <details>
  <summary><code>help getmempoolfeeratediagram</code> diff</summary>

  ```diff
  -Result (mempool chunks):
  -[                    (json array)
  +Result:
  +[                    (json array) mempool chunks
     {                  (json object)
       "weight" : n,    (numeric) cumulative sigops-adjusted weight
       "fee" : n        (numeric) cumulative fee
     },
     ...
   ]
  ```

  </details>

ACKs for top commit:
  maflcko:
    lgtm ACK 0b17fa0

Tree-SHA512: 7dba3fb9f9b493a9e5f6192456b83bd872e312f70aeb2cc06ee737e4fbb194480aa387391482ea7dda8b283c930873f043cfde7d9665944907af6c84e490d87e

Cherry-picked-from: bitcoin/bitcoin@1ea904d
@auditbob

auditbob Bot commented Nov 30, 2026

Copy link
Copy Markdown
Author

Post-Merge Audit — 1ea904d983f8841c28cb8240c576e46ac2efe529 (merge of #37020)

1. Summary

Documentation-only fix in the RPC help metadata for getmempoolfeeratediagram. At src/rpc/mempool.cpp:679-690 the top-level result is now constructed as RPCResult{RPCResult::Type::ARR, "", "mempool chunks", {…}}, i.e. through the (Type, key_name, description, inner, opts) overload at src/rpc/util.h:378-384 (forwarding to the (Type, key_name, bool optional, description, …) overload at src/rpc/util.h:360-376, which leaves m_cond empty).

Previously the string occupied the cond slot of the overload at src/rpc/util.h:351-358, so RPCResults::ToDescriptionString (src/rpc/util.cpp:621-638) took the result += "\nResult (" + r.m_cond + "):\n"; branch at line 633. Now it takes the "\nResult:\n" branch at line 631, and the string is emitted by RPCResult::ToSections's Description() lambda for Type::ARR (src/rpc/util.cpp:1024-1027, 1077-1092), producing [ (json array) mempool chunks. The claimed help diff in the commit message matches the code paths I read. The RPC handler itself (src/rpc/mempool.cpp:696-713) is untouched.

2. Consensus & Validation

None. The handler body (EnsureAnyMemPool, LOCK(mempool.cs), mempool.GetFeerateDiagram(), weight/fee serialization at src/rpc/mempool.cpp:696-713) is byte-identical before/after, and only static RPCResult metadata changed. RPCResult::MatchesType (src/rpc/util.cpp:1154-1218) reads only m_type, m_inner, m_key_name, m_optional, and m_opts.skip_type_check — never m_description/m_cond — so -rpcdoccheck behaviour is unchanged.

3. Security, P2P & DoS

None. No new input parsing, allocation, or user-controlled data; the change is a compile-time literal moved between fields of a help struct. RPCResult::CheckInnerDoc (src/rpc/util.cpp:1220-1229) is still satisfied: Type::ARR requires non-empty m_inner, and the inner OBJ element list is unchanged, so no CHECK_NONFATAL abort path is reachable.

4. Concurrency & Locking

None. Help metadata is static; the LOCK(mempool.cs) scope in the handler (src/rpc/mempool.cpp:698-711) is unchanged, and no lock ordering is affected.

5. Code Quality & Test Coverage

  • Verified fix completeness: after the change, every remaining RPCResult{"<string>", …} first-argument string in src/rpc/ is a genuine condition (for verbose = 0/1/2, for verbose = false and mempool_sequence = true, mode "stats", mode "mallocinfo", If the block was accepted, Otherwise, etc.) — observed at src/rpc/blockchain.cpp:646,666,843-856,1223-1224,2376,2584,2592, src/rpc/mempool.cpp:727-737,771-774,830-833,1306-1316, src/rpc/mining.cpp:675-677,1081-1082, src/rpc/node.cpp:171,185, src/rpc/output_script.cpp:288,294, src/rpc/rawtransaction.cpp:272-281. No sibling misuse of the cond overload was left behind by this PR.
  • [Nit] The overload set makes this mistake easy and silent: (std::string cond, Type, std::string key, std::string desc, …) at src/rpc/util.h:351-358 versus (Type, std::string key, std::string desc, …) at 378-384 — a description placed one slot early compiles cleanly and only changes rendered help. The CHECK_NONFATAL(!m_cond.empty()) at src/rpc/util.h:347 only catches the empty-condition case, not a prose string in the condition. This specific call is not ambiguous: the bool optional overload at src/rpc/util.h:360-366 is not viable for RPCResult{Type::ARR, "", "mempool chunks", {…}} because the 4th argument is a braced list of RPCResult, not a description string.
  • [Nit] No test asserts the rendered label text. test/functional/rpc_help.py:152-167 (dump_help) generates help for every RPC and validates curl payload JSON, but never asserts content; the only functional user of this RPC is test/functional/mempool_cluster.py:79 (node.getmempoolfeeratediagram()), which checks the JSON result, not the help output. A small assertion on help getmempoolfeeratediagram (or a check rejecting prose in m_cond) would prevent recurrence, but that is optional and outside this PR's scope.
  • Style: the lowercase "mempool chunks" description matches the inner "cumulative sigops-adjusted weight" / "cumulative fee" (src/rpc/mempool.cpp:685-686). Cosmetic nit only: RPCResult{ with the first argument on the following line (src/rpc/mempool.cpp:679-680) is slightly unusual formatting for this file, but valid.

6. Cross-Audit Reconciliation & Post-Merge Verdict

  • Confirmed by both, independently verified: the cond→description overload switch and its rendering consequences (src/rpc/util.h:351-358/378-384, src/rpc/util.cpp:630-635, 1024-1027, 1077-1092); no runtime/consensus/locking/DoS impact; CheckInnerDoc still passes for Type::ARR with non-empty m_inner (src/rpc/util.cpp:1220-1229); handler unchanged.
  • Caught by one and verified: audit_a's claim that no test asserts the help text was confirmed against test/functional/rpc_help.py:152-167 and test/functional/mempool_cluster.py:79; audit_a's "no sibling occurrences left" scan was re-run and confirmed. Audit_b's claim that rpc_help.py/-rpcdoccheck "exercises … ToSections for all registered RPCs" is accurate for generation (that is what makes the runtime-crash check meaningful) but is not an assertion on the label — I refined it into the [Nit] above rather than treating it as coverage of this regression class.
  • Dropped/downgraded: audit_a's [Nit] about lowercase style being a "consistency" concern is trivially true and not actionable; its speculative note that a "careless future edit" could reintroduce the bug is retained only as the overload-hazard [Nit] in §5. No hallucinated symbols or paths were found in either draft; all cited line numbers I checked matched within a line or two of what I read.
  • Overall risk: negligible — help-string-only change in static RPC metadata, no runtime, consensus, P2P, or locking surface. Key lines to glance at: src/rpc/mempool.cpp:679-690 (argument slot) and src/rpc/util.h:347-384 (overload tripwires).

Triage: routine


📊 Token Usage & Review Stats
Stage Model Input Tokens Cache Hit Output Reasoning Total Rounds Latency
Audit A deepseek-flash 52,116 44,288 (85%) 3,425 1,590 55,541 8 42.8s
Audit B gemini-4-neon-high 122,899 72,055 (59%) 3,029 1,950 125,928 6 47.0s
Judge deepseek-flash 63,118 49,664 (79%) 5,142 2,186 68,260 6 49.7s
Total — 238,133 166,007 (70%) 11,596 5,726 249,729 20 139.5s

@auditbob auditbob Bot added audited Automated review completed RPC/REST/ZMQ labels Nov 30, 2026

@jonatack jonatack left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ACK d1ccf4d

@jonatack
jonatack merged commit bf5b3b6 into bitcoin-v:master Dec 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

audited Automated review completed RPC/REST/ZMQ

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants