#36478 rpc: Check named args names and result field names at compile time

ReviewabilityReviewsAgreementSize
#36478 maflcko rpc: Check named args names and result field names at compile timeReady1Strong81 + 11 tests
  • Enforce naming conventions on RPC argument and result field names at compile time
  • Prevent developer confusion and bugs caused by malformed or non-standard RPC field names
  • Ready to review
  • Strong support with substantive testing (fametrano)
  • Verified RPC help diffs, compile times, and compile-time rejection of invalid names (fametrano)
  • Author declined a suggestion to reject empty alias parts at compile time (fametrano)
  • 81 lines added or modified outside tests
  • 11 lines added or modified in tests
  • 43 lines removed in total
  • 9 files, 2 commits
RPC / REST / ZMQ#46 of 55
P3 · cleanup
  • P3 because it catches malformed RPC argument and result field names at compile time
  • Enforces consistent naming conventions across RPC declarations without runtime overhead
Reviewability: ReadyStalePaused
Agreement: StrongPositivePositive w/ caveatsNeutralMildDisputedBlockedCrickets
Reviews: current code-review ACKs, then (+stale ACKs) and -NACKs; greener = more ACKs.
Size: lines added or modified outside tests, then in tests; greener = smaller.

Goal

Introduces C++20 consteval wrappers to enforce character restrictions on RPC argument and result field names at compile time. It also updates several existing RPC documentation strings containing slashes, brackets, or spaces to conform to the new naming rules, and disables clang-tidy's modernize-use-emplace check.

Problem: Inconsistently formatted or non-standard RPC argument and result field names (such as containing slashes or spaces) create developer confusion and potential bugs across RPC interfaces without any automated mechanism to catch them during compilation.

Evidence of importance:

  • The PR description notes: 'Generally, such names should be `snake_case`. Otherwise, there are bugs and confusion', citing PR #35317.

Scope: Also renames several RPC documentation keys across mining, net, and wallet RPCs to comply with the new consteval character rules, and removes modernize-use-emplace from .clang-tidy because clang-tidy suggests emplace calls that fail with consteval constructors.

Risk of a mistake: medium (rpc_api, tooling). Renaming field names in RPC documentation or introducing overly restrictive compile-time checks could break downstream schema parsers or reject valid RPC parameter definitions.

Changed since the previous assessment: Diff provided; confirms the consteval name validators and updates non-conforming RPC doc keys.

Reviewability

Ready

Nothing known that would invalidate a review now.

Waiting on (from the thread read):

  • reviewer: fametrano to follow up on author declining the suggestion, or further review 2026-10-26

Agreement

Strong

substantive support, no open objection (fametrano)

Thread notes: Author replied to fametrano's suggestion regarding empty alias list parts, declining to add compile-time checks as unnecessary.

Objections, suggestions, and questions:

ReviewerTypeHarm, request, or questionStatusMust beAuthor repliedQuote
fametrano (none)suggestion, correctnessReject alias lists containing empty parts (e.g., "a||b", "|", "a|") at compile time to prevent named arguments called ""answered · author declined, explaining empty strings carry no risk and don't need compile-time lintingansweredyes2026-10-25: 'Alias lists with empty parts still compile, such as "a||b", "|" and "a|". At runtime the empty part becomes a named argument called "". Rejecting it may be worth it while you are here.'
Status from: 2026-10-26: maflcko: 'I'd say that is fine, because there is no risk.'

Support:

  • fametrano (none) (Tested ACK, 2026-10-25) [both]: Tested base vs head RPC help and openrpc output diffs, verified compile times of touched files, and tested compile-time rejection of various invalid argument and result names

Participants:

  • fametrano (none, support, 1 statements 2026-10-25 to 2026-10-25): tested ACK; suggested rejecting empty parts in alias lists

Files

17 lines under test/bench/ci.

  • src/rpc/util.h +57/-12
  • src/rpc/blockchain.cpp +10/-10
  • src/test/rpc_tests.cpp +11/-6
  • src/rpc/rawtransaction_util.cpp +5/-5
  • src/wallet/rpc/addresses.cpp +3/-3
  • src/rpc/mempool.cpp +2/-2
  • src/rpc/mining.cpp +2/-2
  • src/rpc/net.cpp +2/-2
  • src/.clang-tidy +0/-1

Card

The short text the ranking pass compares across PRs.

Adds C++20 consteval compile-time verification for RPC argument names and result field names to reject confusing characters like slashes and spaces during the build. This addresses developer confusion and parameter naming bugs such as those discussed in PR #35317. Several existing RPC documentation field names are adjusted to comply, and clang-tidy's modernize-use-emplace check is disabled to allow push_back with consteval types.

Data

dossier JSON · extract JSON · model ledger, generated 2026-10-27T01:27, confidence high, input hash bc4b783ae8907c6b
thread read through 2026-10-26 (3 statements), head fabdf113d3
labels: RPC/REST/ZMQ

Categories

RPC / REST / ZMQ

P3 · cleanup

Compile-time enforcement catches malformed RPC argument and result field names early during development. The PR description notes that 'Generally, such names should be `snake_case`. Otherwise, there are bugs and confusion', improving consistency across RPC declarations.

Membership: Carries RPC/REST/ZMQ label and modifies the core RPC argument and documentation utility definitions in src/rpc/util.h.

Factors: security/stability 0, bug 0, performance 0, user value 0, leverage 1