Skip to content

Optimize Esplora witness resolution - #20

Merged
zoedberg merged 2 commits into
rgb-protocol:masterfrom
Jainakin:hardik/esplora-single-call-witness-resolution
Aug 27, 2026
Merged

Optimize Esplora witness resolution#20
zoedberg merged 2 commits into
rgb-protocol:masterfrom
Jainakin:hardik/esplora-single-call-witness-resolution

Conversation

@Jainakin

@Jainakin Jainakin commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Summary

  • replace the blocking Esplora resolver's sequential get_tx() and get_tx_status() calls with one get_tx_info() request
  • preserve confirmed, tentative, unresolved, invalid-height, and typed resolver-error behavior
  • rely on the existing CheckedWitnessResolver boundary for transaction-identity validation instead of duplicating that policy in the transport adapter
  • add deterministic loopback coverage for the combined endpoint and failure paths

Current head: 650370c6603d9d7f2810b91489f41444acfc867f. The branch contains the focused resolver commit plus maintainer commit 650370c fixing the current nightly Infallible conversion build. Both commits have verified signatures, and the current head is reviewer-approved.

Motivation

Each RGB witness resolution previously performed two sequential Esplora round trips: one for the raw transaction and one for its status. High-history consignments repeat this operation across validation and acceptance, making wall time proportional to both witness count and network latency.

The combined Esplora /tx/{txid} response contains both transaction and status data. This reduces each resolution from two HTTP requests to one without adding cache, concurrency, persistence, or protocol-state semantics.

Controlled 88-history result

The same 88-witness consignment was replayed through the RGB validation/import/acceptance path behind a deterministic Signet-like latency proxy:

Resolver Full replay HTTP requests Unique witnesses
Existing raw + status requests 234.59 s 176 88
Combined transaction-info request 120.84 s 88 88

This is a 1.94x speedup, or a 48.5% wall-time reduction, in the controlled latency model. It is not a production Signet SLA claim. The benefit is removal of one network round trip per resolution, not lower payload bandwidth.

Correctness coverage

Deterministic tests cover:

  • confirmed witnesses through one /tx/{txid} request
  • unconfirmed witnesses through one /tx/{txid} request
  • missing transactions returning Unresolved
  • zero confirmation height returning InvalidResolverData
  • malformed JSON retaining the existing typed resolver error

The reviewer-requested helper names are applied, and the redundant adapter-level txid checks were removed. The focused resolver behavior is covered by deterministic tests, and the aggregate Codecov check passes on the current head.

Validation

  • focused Esplora resolver suite: 5/5 passed
  • all 50 checks reported for the current head pass, including formatting, clippy, docs, no-default, feature, WASM, stable, beta, nightly, MSRV, coverage, Linux, and macOS

Scope

This PR is intentionally Esplora-only. It adds no cache, worker pool, persistent state, Electrum behavior, WASM transport, RGB acceptance change, or Lightning funding change.

  • rgb-ops #18 remains the separate native Electrum batching PR.
  • rgb-lib #79 remains the separate RGB-lib integration for the Electrum batch response.

This change does not parallelize witness resolution or remove repeated validation/acceptance passes. It only makes each Esplora resolution one request so subsequent parallel resolution does not retain the current two-request cost per witness.

@codecov

codecov Bot commented Aug 20, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.03960% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/persistence/stock.rs 0.0% 4 Missing ⚠️

📢 Thoughts on this report? Let us know!

@Jainakin
Jainakin marked this pull request as ready for review August 20, 2026 17:47

@zoedberg zoedberg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@Jainakin Thanks, nice catch! Please address the requested changes, amend them to keep a single commit, sign it with gpg and rebase it on the updated master tip (d7e96f6)

Comment thread src/indexers/esplora_blocking.rs Outdated
Comment thread src/indexers/esplora_blocking.rs Outdated
Comment thread src/indexers/esplora_blocking.rs Outdated
Resolve transaction data and confirmation status through one Esplora tx-info request. Add deterministic confirmed, unconfirmed, missing, invalid-height, and malformed-response coverage.
@Jainakin
Jainakin force-pushed the hardik/esplora-single-call-witness-resolution branch from f7ff867 to b5edb2f Compare August 27, 2026 17:19
@zoedberg
zoedberg force-pushed the hardik/esplora-single-call-witness-resolution branch from 00cc158 to 650370c Compare August 27, 2026 18:14

@zoedberg zoedberg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, thank you!

@zoedberg
zoedberg merged commit 650370c into rgb-protocol:master Aug 27, 2026
25 checks passed
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