Skip to content

Conversation

oleonardolima
Copy link
Contributor

Description

Notes to the reviewers

Changelog notice

Checklists

All Submissions:

New Features:

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

Bugfixes:

  • This pull request breaks the existing API
  • I've added tests to reproduce the issue which are now passing
  • I'm linking the issue being fixed by this PR

@oleonardolima oleonardolima self-assigned this Sep 25, 2025
@oleonardolima oleonardolima force-pushed the docs/add-new-filter-iter-example branch from 64cdf71 to dc7c9bb Compare September 25, 2025 03:56
oleonardolima and others added 6 commits September 29, 2025 11:47
…ionTask`

introduces `CanonicalizationTask` that implements canonicalization using a
request/response pattern, removing direct dependency on `ChainOracle`.

- add `CanonicalizationTask` with request/response pattern for chain queries
- track confirmed anchors to eliminate redundant queries
- handle direct vs transitive anchor determination
- return complete `CanonicalView` with correct chain positions
- add `LocalChain::handle_canonicalization_request` helper
- export `CanonicalizationTask`, `CanonicalizationRequest`, `CanonicalizationResponse`

BREAKING CHANGE: replaces direct `ChainOracle` querying in canonical iteration
with a new request/response pattern through `CanonicalizationTask`.
Changes `CanonicalizationRequest` to a struct and `CanonicalizationResponse` to
`Option<A>` to process all anchors for a transaction in a single request.

- convert `CanonicalizationRequest` from enum to struct with anchors vector
- change `CanonicalizationResponse` to `Option<A>` returning best confirmed anchor
- batch all anchors for a transaction in one request instead of one-by-one
- simplify `process_anchored_txs` to queue all anchors at once
- add transitive anchor checking back in `mark_canonical()`

This reduces round trips between `CanonicalizationTask` and `ChainOracle` while
maintaining the same functionality. The API is cleaner with a struct-based
request that mirrors how `scan_anchors` worked in the original `CanonicalIter`.

BREAKING CHANGE: `CanonicalizationRequest` and `CanonicalizationResponse` types
have changed from enums to struct/type alias respectively.
- Replace `CanonicalView::new()` constructor with internal `CanonicalView::new()` for use by `CanonicalizationTask`
- Remove `TxGraph::try_canonical_view()` and `TxGraph::canonical_view()` methods
- Add `TxGraph::canonicalization_task()` method to create canonicalization tasks
- Add `LocalChain::canonicalize()` method to process tasks and return `CanonicalView`'s
- Update `IndexedTxGraph` to delegate canonicalization to underlying `TxGraph`

The new API separates canonicalization logic from I/O operations:
- Create canonicalization task: `graph.canonicalization_task(params)`
- Execute canonicalization: `chain.canonicalize(task, chain_tip)`

BREAKING CHANGE: Remove `CanonicalView::new()` and `TxGraph::canonical_view()` methods in favor of task-based approach
- Delete entire `canonical_iter.rs` file and its module declaration
- Move `CanonicalReason`, `ObservedIn`, and `CanonicalizationParams` to `canonical_task.rs`
- Update module exports to use `pub use canonical_task::*` instead of selective exports

BREAKING CHANGE: `CanonicalIter` and all its exports are removed
…icalizationTask`

Introduce a new `ChainQuery` trait in `bdk_core` that provides an
interface for query-based operations against blockchain data. This trait
enables sans-IO patterns for algorithms that need to interact with blockchain
oracles without directly performing I/O.

The `CanonicalizationTask` now implements this trait, making it more composable
and allowing the query pattern to be reused for other blockchain query operations.

- Add `ChainQuery` trait with associated types for Request, Response, Context, and Result
- Implement `ChainQuery` for `CanonicalizationTask` with `BlockId` as context

BREAKING CHANGE: `CanonicalizationTask::finish()` now requires a `BlockId` parameter

Co-Authored-By: Claude <noreply@anthropic.com>
Make `ChainRequest`/`ChainResponse` generic over block identifier types to enable
reuse beyond BlockId. Move `chain_tip` into `ChainRequest` for better encapsulation
and simpler API.

- Make `ChainRequest` and `ChainResponse` generic types with `BlockId` as default
- Add `chain_tip` field to `ChainRequest` to make it self-contained
- Change `ChainQuery` trait to use generic parameter `B` for block identifier type
- Remove `chain_tip` parameter from `LocalChain::canonicalize()` method
- Rename `ChainQuery::Result` to `ChainQuery::Output` for clarity

BREAKING CHANGE:
- `ChainRequest` now has a `chain_tip` field and is generic over block identifier type
- `ChainResponse` is now generic with default type parameter `BlockId`
- `ChainQuery` trait now takes a generic parameter `B = BlockId`
- `LocalChain::canonicalize()` no longer takes a `chain_tip` parameter

Co-authored-by: Claude <noreply@anthropic.com>
@oleonardolima oleonardolima force-pushed the docs/add-new-filter-iter-example branch 2 times, most recently from ecd9199 to 3a9302f Compare September 30, 2025 06:25
@oleonardolima oleonardolima changed the title docs(example): introduce new FilterIterV2 example w/o LocalChain docs(example): introduce new ChainQuery usage examples Oct 1, 2025
@oleonardolima oleonardolima force-pushed the docs/add-new-filter-iter-example branch 2 times, most recently from c9981b3 to 4a01624 Compare October 2, 2025 01:41
Add `example_chain_query` package with two implementations demonstrating
the new `ChainQuery` trait usage without full chain storage:

- rpc_oracle: Bitcoin Core RPC with synchronous ChainOracle trait
- kyoto_oracle: BIP157/158 compact filters with async Kyoto client

Both examples showcase `CanonicalizationTask` API for lightweight chain
verification using on-demand block queries instead of storing all headers.

Co-authored-by: Claude <noreply@anthropic.com>
@oleonardolima oleonardolima force-pushed the docs/add-new-filter-iter-example branch from 4a01624 to 9578c02 Compare October 2, 2025 01:49
…zation

- convert `unprocessed_anchored_txs` from iterator to `VecDeque`
- remove `pending_anchor_checks` queue entirely
- collect anchored transactions upfront instead of lazy iteration
- make `LocalChain::canonicalize()` generic over `ChainQuery` trait
…nQuery`

Allow any type implementing `ChainQuery` trait instead of requiring
`CanonicalizationTask` specifically.
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.

1 participant