Skip to content

esplora: paged history, summary fields, and tx JSON - #861

Merged
reardencode merged 3 commits into
masterfrom
esplora/nullcount-http
Oct 3, 2026
Merged

reardencode merged 3 commits into
masterfrom
esplora/nullcount-http

Conversation

@rearden-grok

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

Copy link
Copy Markdown
Contributor

Summary

Fixes the Esplora HTTP defects in #850, #852, #856, and #857.

  • Paged /txs, /txs/chain, and /txs/summary are served when a script has more creates than --max-sh-creates. The full join (and the last-1 slot) is still built when the script is under the cap, so wallet reuse is unchanged. Unpaged stats and /utxo still return 503.
  • /txs/summary rows include tx_position (the tx's index in its block). ?asof= is accepted on /txs/summary and /txs/summary/:last, which COMPAT.md already documented. The page size stays 25, matching COMPAT.md; mempool.space's unpaged full history is left unchanged.
  • Tx JSON omits an empty witness. inner_redeemscript_asm is only the P2SH redeem script. inner_witnessscript_asm is a P2WSH witness script (including P2SH-P2WSH) or a Taproot script-path leaf (annex stripped). A key-path spend and an unknown prevout emit neither inner field.
  • GET /block/:hash/txs/:start at or past the last tx returns 404 start index out of range. A start that is not a multiple of 25 stays 400.

Test plan

  • cargo test -p rbitcoin-query --lib sh_history_caps
  • cargo test -p rbitcoin-esplora --lib esplora_sh_join_and_template
  • cargo test -p rbitcoin-esplora --lib esplora_tcp_wallet_mempool_and_replace
  • cargo test -p rbitcoin-esplora --lib vin_inner_scripts_follow_prevout_type
  • cargo test -p rbitcoin-esplora --lib block_txs_past_end_is_not_found
  • cargo clippy -p rbitcoin-esplora -p rbitcoin-query --all-targets -- -D warnings

Comment thread crates/rbitcoin-esplora/src/tx_json.rs Dismissed

@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 finding:

The new tx_position lookup loads the complete transaction-FK list for each distinct block height in a summary page via block_tx_fks, then linearly searches it. A 25-row page can therefore add up to 25 random on-disk list reads and allocate/scan each whole block list, even though each row needs only one transaction's position. Please add a position lookup that addresses the needed transaction directly, or otherwise bound and measure this extra IO for summary requests.

@rearden-grok
rearden-grok Bot force-pushed the esplora/nullcount-http branch from 275f68a to d95027d Compare October 3, 2026 00:02
rearden-grok Bot added 3 commits October 2, 2026 17:20
A live Esplora page built the unpaged scripthash join, so any script
over --max-sh-creates returned 503 on /txs, /txs/chain, and
/txs/summary. Skip that join only when the cap would refuse it, and
still fill the last-1 slot when the script is under the cap.

/txs/summary rows now include tx_position, and ?asof= is accepted on
that route. The page stays 25 rows. Tx JSON omits an empty witness
and emits inner redeem/witness scripts only for the prevout type.
/block/:hash/txs/:start at or past the last tx is 404.

Fixes #850, #852, #856, and #857.
The node journey still expected an empty 200 page one past the last tx.
electrs and the handler return 404.
A summary page loaded each block's full transaction-fk list to find one
index. Class A membership is a contiguous (first, count) span, so the
index is an offset and the page keeps one span per height.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants