Make bdk_bitcoind_rpc emitters support any checkpoint data type#2105
Make bdk_bitcoind_rpc emitters support any checkpoint data type#2105evanlinjin wants to merge 3 commits intobitcoindevkit:masterfrom
bdk_bitcoind_rpc emitters support any checkpoint data type#2105Conversation
|
This couples nicely with Floresta, since we already keep a chain of headers. Cool idea. |
c989f8f to
cd404c6
Compare
…dress Refactor block mining in `TestEnv` to use `getblocktemplate` RPC properly: - Add `MineParams` struct to configure mining (empty blocks, custom timestamp, custom coinbase address) - Add `mine_block()` method that builds blocks from the template with proper BIP34 coinbase scriptSig, witness commitment, and merkle root - Add `min_time_for_next_block()` and `get_block_template()` helpers - Refactor `mine_empty_block()` to use the new `mine_block()` API - Include mempool transactions when `empty: false`
Proposal - Make
|
This allows us to use any subset of a `Header` to construct checkpoint data. Currently, only `BlockHash` and `Header` implement this. Chain sources can bound the checkpoint data generic to this trait, so all checkpoint data types that implement `FromBlockHeader` is supported by the chain source.
cd404c6 to
912d0f7
Compare
912d0f7 to
b76cb25
Compare
| /// Trait that converts [`Header`] to subset data. | ||
| pub trait FromBlockHeader { | ||
| /// Returns the subset data from a block `header`. | ||
| fn from_blockheader(header: Header) -> Self; | ||
| } |
There was a problem hiding this comment.
@evanlinjin Can you clarify why the new trait it's really need ? Can't we achieve the same by just implementing ToBlockHash for Header ? (I'll do another round to better understand it)
There was a problem hiding this comment.
We want Header -> checkpoint data. So a chain-source crate can provide the Header, and the checkpoint data can be made from that.
Description
Make
bdk_bitcoind_rpcemitters support emittingCheckPointupdates with bothBlockHashandHeaderdata. To make this easier to implement, abdk_core::fromBlockHashtrait is introduced.Rationale
I think BDK should move towards making
Headerthe most-used checkpoint data type (so chain-sources should be able to output that!). This allows us to accurately calculate time (MTP), provides the merkle root for verification (maybe anchors in the future can include the merkle proof), and provides theprev_blockhashvalue.However, we cannot force this change as users may want persisted data to be compatible with newer versions of BDK (and retain their
BlockId-based persistence data).Changelog notice
Checklists
All Submissions:
New Features: