Skip to content

Feature imcompatibility of rpc and async-interface #998

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
tnull opened this issue May 29, 2023 · 0 comments
Open

Feature imcompatibility of rpc and async-interface #998

tnull opened this issue May 29, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@tnull
Copy link
Contributor

tnull commented May 29, 2023

Describe the bug
In LDK Node we're currently using an async Esplora client to sync LDK and BDK with the chain. To this end, we enable the async-interface feature. We're however looking into adding RPC support in v0.2, which would require the rpc feature. However, enabling both features in incompatible as RpcBlockchain doesn't implement the async variants of the traits:

error[E0195]: lifetime parameters or bounds on method `get_capabilities` do not match the trait declaration
   --> /Users/ero/.cargo/registry/src/github.com-1ecc6299db9ec823/bdk-0.28.0/src/blockchain/rpc.rs:157:24
    |
157 |     fn get_capabilities(&self) -> HashSet<Capability> {
    |                        ^ lifetimes do not match method in trait
    |
   ::: /Users/ero/.cargo/registry/src/github.com-1ecc6299db9ec823/bdk-0.28.0/src/blockchain/mod.rs:92:5
    |
92  |     /// Return the set of [`Capability`] supported by this backend
    |     -------------------------------------------------------------- this bound might be missing in the impl
93  |     fn get_capabilities(&self) -> HashSet<Capability>;
    |        ----------------------- lifetimes in impl do not match this method in trait

error[E0195]: lifetime parameters or bounds on method `broadcast` do not match the trait declaration
   --> /Users/ero/.cargo/registry/src/github.com-1ecc6299db9ec823/bdk-0.28.0/src/blockchain/rpc.rs:161:17
    |
161 |     fn broadcast(&self, tx: &Transaction) -> Result<(), Error> {
    |                 ^ lifetimes do not match method in trait
    |
   ::: /Users/ero/.cargo/registry/src/github.com-1ecc6299db9ec823/bdk-0.28.0/src/blockchain/mod.rs:94:5
    |
94  |     /// Broadcast a transaction
    |     --------------------------- this bound might be missing in the impl
95  |     fn broadcast(&self, tx: &Transaction) -> Result<(), Error>;
    |        ---------------------------------- lifetimes in impl do not match this method in trait

error[E0195]: lifetime parameters or bounds on method `estimate_fee` do not match the trait declaration
   --> /Users/ero/.cargo/registry/src/github.com-1ecc6299db9ec823/bdk-0.28.0/src/blockchain/rpc.rs:165:20
    |
165 |     fn estimate_fee(&self, target: usize) -> Result<FeeRate, Error> {
    |                    ^ lifetimes do not match method in trait
    |
   ::: /Users/ero/.cargo/registry/src/github.com-1ecc6299db9ec823/bdk-0.28.0/src/blockchain/mod.rs:96:5
    |
96  |     /// Estimate the fee rate required to confirm a transaction in a given `target` of blocks
    |     ----------------------------------------------------------------------------------------- this bound might be missing in the impl
97  |     fn estimate_fee(&self, target: usize) -> Result<FeeRate, Error>;
    |        ---------------------------------- lifetimes in impl do not match this method in trait

error[E0195]: lifetime parameters or bounds on method `get_tx` do not match the trait declaration
   --> /Users/ero/.cargo/registry/src/github.com-1ecc6299db9ec823/bdk-0.28.0/src/blockchain/rpc.rs:178:14
    |
178 |     fn get_tx(&self, txid: &Txid) -> Result<Option<Transaction>, Error> {
    |              ^ lifetimes do not match method in trait
    |
   ::: /Users/ero/.cargo/registry/src/github.com-1ecc6299db9ec823/bdk-0.28.0/src/blockchain/mod.rs:110:5
    |
110 |     /// Fetch a transaction given its txid
    |     -------------------------------------- this bound might be missing in the impl
111 |     fn get_tx(&self, txid: &Txid) -> Result<Option<Transaction>, Error>;
    |        -------------------------- lifetimes in impl do not match this method in trait

error[E0195]: lifetime parameters or bounds on method `get_height` do not match the trait declaration
   --> /Users/ero/.cargo/registry/src/github.com-1ecc6299db9ec823/bdk-0.28.0/src/blockchain/rpc.rs:184:18
    |
184 |     fn get_height(&self) -> Result<u32, Error> {
    |                  ^ lifetimes do not match method in trait
    |
   ::: /Users/ero/.cargo/registry/src/github.com-1ecc6299db9ec823/bdk-0.28.0/src/blockchain/mod.rs:103:5
    |
103 |     /// Return the current height
    |     ----------------------------- this bound might be missing in the impl
104 |     fn get_height(&self) -> Result<u32, Error>;
    |        ----------------- lifetimes in impl do not match this method in trait

error[E0195]: lifetime parameters or bounds on method `get_block_hash` do not match the trait declaration
   --> /Users/ero/.cargo/registry/src/github.com-1ecc6299db9ec823/bdk-0.28.0/src/blockchain/rpc.rs:190:22
    |
190 |     fn get_block_hash(&self, height: u64) -> Result<BlockHash, Error> {
    |                      ^ lifetimes do not match method in trait
    |
   ::: /Users/ero/.cargo/registry/src/github.com-1ecc6299db9ec823/bdk-0.28.0/src/blockchain/mod.rs:117:5
    |
117 |     /// fetch block hash given its height
    |     ------------------------------------- this bound might be missing in the impl
118 |     fn get_block_hash(&self, height: u64) -> Result<BlockHash, Error>;
    |        ---------------------------------- lifetimes in impl do not match this method in trait

error[E0195]: lifetime parameters or bounds on method `wallet_setup` do not match the trait declaration
   --> /Users/ero/.cargo/registry/src/github.com-1ecc6299db9ec823/bdk-0.28.0/src/blockchain/rpc.rs:196:20
    |
196 |       fn wallet_setup<D>(&self, db: &RefCell<D>, prog: Box<dyn Progress>) -> Result<(), Error>
    |                      ^^^ lifetimes do not match method in trait
197 | /     where
198 | |         D: BatchDatabase,
    | |_________________________- this `where` clause might not match the one in the trait
    |
   ::: /Users/ero/.cargo/registry/src/github.com-1ecc6299db9ec823/bdk-0.28.0/src/blockchain/mod.rs:124:5
    |
124 |       /// Setup the backend and populate the internal database for the first time
    |       --------------------------------------------------------------------------- this bound might be missing in the impl
...
135 |       fn wallet_setup<D: BatchDatabase>(
    |                      ------------------
    |                      | |
    |                      | this bound might be missing in the impl
    |                      lifetimes in impl do not match this method in trait

For more information about this error, try `rustc --explain E0195`.
error: could not compile `bdk` due to 7 previous errors
exit 101

To Reproduce
Create new Rust project, add the BDK dependency:

bdk = { version = "0.28.0", default-features = false, features = ["std", "async-interface", "rpc"]}

Expected behavior
async-interface and rpc should be compatible, at least on a type level. We don't require the client to be actually async, but we need to at least have to have the chance of switching between EsploraBlockchain and RpcBlockchain in code. Note the emphasis on in code as we really don't want to have to mirror BDK's design decisions and expose chain data switching via features rather than builder-style methods.

Build environment
BDK 0.28.0

(cc @orbitalturtle, thanks for pointing this out!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Discussion
Development

No branches or pull requests

1 participant