Skip to content

Refactor ChainQuery to be more flexible #2139

Draft
evanlinjin wants to merge 1 commit into
bitcoindevkit:masterfrom
evanlinjin:refactor/sans-io-mtp-chain-query
Draft

Refactor ChainQuery to be more flexible #2139
evanlinjin wants to merge 1 commit into
bitcoindevkit:masterfrom
evanlinjin:refactor/sans-io-mtp-chain-query

Conversation

@evanlinjin

Copy link
Copy Markdown
Member

Description

This builds on top of #2038.

  • ChainQuery can fetch any block-data type (BlockHash, Header).
  • CanonicalViewTask can fetch headers to calculate MTP values.
  • CanoncialTx, CanonicalTxOut has new MTP fields.

Notes to the reviewers

WIP

Changelog notice

WIP

Checklists

All Submissions:

New Features:

  • I've added tests for the new feature
  • I've added docs for the new feature

@evanlinjin evanlinjin force-pushed the refactor/sans-io-mtp-chain-query branch 2 times, most recently from 6faf825 to c1ad161 Compare March 13, 2026 11:13
@evanlinjin evanlinjin self-assigned this Apr 10, 2026
@evanlinjin evanlinjin force-pushed the refactor/sans-io-mtp-chain-query branch 2 times, most recently from bdd7608 to 45bf03a Compare May 6, 2026 12:53
@codecov

codecov Bot commented May 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.63736% with 45 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.30%. Comparing base (6d03fc3) to head (d5d2fae).

Files with missing lines Patch % Lines
crates/chain/src/canonical_view_task.rs 90.78% 10 Missing and 3 partials ⚠️
crates/chain/src/local_chain.rs 72.34% 12 Missing and 1 partial ⚠️
crates/chain/src/canonical.rs 85.41% 7 Missing ⚠️
crates/core/src/block_queries.rs 77.77% 6 Missing ⚠️
crates/chain/src/canonical_task.rs 95.87% 3 Missing and 1 partial ⚠️
crates/chain/src/indexed_tx_graph.rs 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2139      +/-   ##
==========================================
- Coverage   78.65%   78.30%   -0.36%     
==========================================
  Files          30       31       +1     
  Lines        5909     6042     +133     
  Branches      279      281       +2     
==========================================
+ Hits         4648     4731      +83     
- Misses       1185     1237      +52     
+ Partials       76       74       -2     
Flag Coverage Δ
rust 78.30% <87.63%> (-0.36%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@oleonardolima

Copy link
Copy Markdown
Collaborator

@evanlinjin the PR dependency is solved, #2038 landed on master! 🚀 🚀
You can rebase this one, though I think just resetting and cherry-picking the last commits will be easier (sorry for the huge conflicts 😅).

@evanlinjin evanlinjin force-pushed the refactor/sans-io-mtp-chain-query branch 2 times, most recently from 52f2e92 to 3d4f44e Compare June 17, 2026 06:17
Rename `ChainQuery` to `ChainTask`.

Replace `ChainRequest`/`ChainResponse` with a poll-based `ChainTask`
trait. The driver calls `poll()` in a loop, resolving block-height
queries as needed. A generic parameter `B` (default `BlockHash`) lets
tasks receive richer block data (e.g. `Header`) from the chain source.

Add per-transaction and tip MTP fields to `CanonicalView`, computed
optionally via `CanonicalViewTask::with_mtp()`.

Add `BlockQueries` helper for tracking request/resolve state, and
`LocalChain::canonicalize{,_with_mtp}()` convenience methods.
@evanlinjin evanlinjin force-pushed the refactor/sans-io-mtp-chain-query branch from 3d4f44e to d5d2fae Compare June 17, 2026 06:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants