Skip to content

rpc: match Core header, address, and mempool JSON - #864

Merged
reardencode merged 3 commits into
masterfrom
rpc/core-header-shape
Oct 3, 2026
Merged

reardencode merged 3 commits into
masterfrom
rpc/core-header-shape

Conversation

@rearden-grok

@rearden-grok rearden-grok Bot commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Summary

Test plan

  • cargo test -p rbitcoin-rpc --lib -- --exact methods::chain::core_double_tests::sixteen_significant_digits
  • cargo test -p rbitcoin-rpc --lib -- --exact methods::tests::getblock_named_verbose_genesis_and_hex
  • cargo test -p rbitcoin-rpc --lib -- --exact methods::tests::getmempoolinfo_permitbaremultisig_is_always_true
  • cargo test -p rbitcoin-rpc --lib -- --exact methods::tests::decode_rpc_subset
  • cargo test -p rbitcoin-rpc --lib -- --exact methods::tests::rpc_regtest_chain_ops
  • cargo clippy -p rbitcoin-rpc -p rbitcoin-net -p rbitcoin-mempool --all-targets -- -D warnings

@rearden-grok rearden-grok Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Review findings:

  1. The new inactive-header paths set mediantime to the block's own timestamp in both off_chain_header_value and disconnected_block_value. Core reports the median time past over the preceding 11 headers on that branch, so this diverges for inactive chains with more than one header. Please calculate branch MTP from the stored parent links (or omit the field if it cannot be computed).

  2. off_chain_header performs a parent-header lookup, an active-chain hash lookup, and then another parent-header lookup on each iteration. A long stored side branch can therefore turn a single getblockheader / getblock request into hundreds of thousands of random store lookups (the walk permits 100,000 steps). Please avoid the duplicate parent read and use a bounded/indexed ancestry walk so stale branches cannot make RPC requests scan the whole branch.

rearden-grok Bot added 2 commits October 2, 2026 17:15
A header that has left the active chain was missing from getblockheader,
and getblock could not rebuild its Class A body. Genesis also emitted an
empty previousblockhash.

The same response builders now include nextblockhash and target, tip bits,
16-significant-digit difficulty, P2TR/P2A validateaddress, getmempoolinfo
fullrbf and cluster caps, and 8-decimal BTC amounts.

getblock verbosity 1 size, strippedsize, and weight are already on master.
getblockheader and getblock reported an inactive block's own timestamp
as mediantime. Core uses the median of that header and up to 10
ancestors. The ancestry walk also read each parent twice and would
follow a stale branch for 100,000 steps. Read each parent once, stop
at the active-chain height index, and cap the walk at the header-sync
limit.
@rearden-grok
rearden-grok Bot force-pushed the rpc/core-header-shape branch from 7d67ee8 to 2466703 Compare October 3, 2026 00:20
The health gauge printed the raw difficulty float. getblockchaininfo rounds
to 16 significant digits, and the cross-surface pin compares them as f64.
Regtest genesis differs by one ULP unless both sides use that rounding.
@reardencode
reardencode merged commit 1d2f889 into master Oct 3, 2026
18 checks passed
@rearden-grok
rearden-grok Bot deleted the rpc/core-header-shape branch October 4, 2026 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant