Skip to content
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

Compact filter #26

Merged
merged 12 commits into from
Jun 2, 2021
Merged

Conversation

rajarshimaitra
Copy link
Contributor

@rajarshimaitra rajarshimaitra commented May 8, 2021

Description

This PR adds the compact filter configuration to connect bdk-cli with a Bitcoin Core node serving compact filters.

Note to Reviewers

I have updated the Readme doc with new usage instruction. If thats not clear (because github doesn't show .md outputs in PR) below is the instruction:

To sync a wallet to Bitcoin Core node (assuming a regtest node at 127.0.0.1:18444) serving compact filters:

Then run:

cargo run --features compact_filters -- --network regtest wallet --node 127.0.0.1:18444 --descriptor "wpkh(tpubEBr4i6yk5nf5DAaJpsi9N2pPYBeJ7fZ5Z9rmN4977iYLCGco1VyjB9tvvuvYtfZzjD5A8igzgw3HeWeeKFmanHYqksqZXYXGsw5zjnj7KM9/*)" sync

Checklists

All Submissions:

  • I've signed all my commits
  • I followed the contribution guidelines
  • I ran cargo fmt and cargo clippy before committing

New Features:

  • I've added tests for the new feature
  • I've added docs for the new feature
  • I've updated CHANGELOG.md

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

@rajarshimaitra
Copy link
Contributor Author

rajarshimaitra commented May 16, 2021

Updated with the requested changes.

This adds a compact filter configuration to connect the wallet with a Bitcoin core node serving compact filters. Esplora and Compact filter configs are first parsed, and fall back to default electrum config if none of them are provided.
Readme updated to include instruction to connect to Bitcoin Core node serving compact filters.
This will append the wallet name provided via configuration flag to
bdk-cli into the data directory. So the current structure of datadir
is `~/.bdk-bitcoin/compact_filters/<wallet-name>.

This will let bdk-cli keep multiple wallet directories simultaneously.
@rajarshimaitra
Copy link
Contributor Author

Updated the database_path to include wallet-name provided with cli args, or use the default name.

The objective is to keep multiple wallet data directories separate.

This PR is ready for a second look.

src/lib.rs Outdated
pub passwd: Option<String>,

/// Sets the light client network address
#[structopt(name = "ADDRESS:PORT", short = "n", long = "node")]
Copy link
Member

Choose a reason for hiding this comment

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

Similar to ElectrumOpts server, I'd set a default_value for CompactFiltersOpts address ("node") to "127.0.0.1:18444", hopefully in the future we'll be able to make this optional and find our peers via dns seed discovery if none are given. But for now I think it's ok to just default to what most people will probably be testing with. This also give an example to show users the expected format. I'd also add to the description to make it clear this is peer full node address, something like: "Sets the compact block filter enabled full node address"

Copy link
Contributor Author

@rajarshimaitra rajarshimaitra May 25, 2021

Choose a reason for hiding this comment

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

Yes agreed. Also enabling conn_count to start multiple connections to the same node. This parameter is not used right now.

Also thinking about having --node as a list of ADDRS:PORT strings. Instead of one address, user can give multiple addresses and wallet will make a total of no. of address * conn_count connections.

Does that make sense?

Copy link
Member

Choose a reason for hiding this comment

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

Sounds good but I don't think anyone has tested the CBF blockchain code with multiple nodes, just with multiple connections to the same node. But seems like it should work and maybe now is a good time to test it. Worst case we go back to just connecting to a single node multiple times.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ya. Updated the code. Planning to run that exact test too. Even if a multiple node connection doesn't work, the user can still give a single node address and it will resume standard behavior.

This PR makes the following changes:
    - Proxy configuration is moved into a separate `ProxyOpt` structure
    inside `WalletOpts`. `ProxyOpts` are only enabled for
    `compact_filters` and `electrum` features.

    - `--node` config can now take `vec<String>` and make `conn_count`
    number of connections to each node.
@rajarshimaitra
Copy link
Contributor Author

Updated with requested changes. Code is ready for further testing and review.

@rajarshimaitra
Copy link
Contributor Author

Update for Reviewers

There is a likely error like this while trying to connect to a full node.

$ ./target/debug/bdk-cli --network regtest wallet --node 127.0.0.1:18444 --descriptor $desc sync
[2021-05-26T14:18:18Z ERROR bdk_cli] CompactFilters(InvalidHeaders)

This happens while connecting to fresh instant of regtest-box while having the old ~/.bdk-bitcoin/compact_filters datadir. The previous filters are not valid for the new regtest node.

Solution is to to delete the datadir, then run.

@notmandatory
Copy link
Member

Looks like the electrum test is failing, I can show you how to spin up docker to run the tests. The steps are also on the bitcoin-regtest-box README under Local bdk testing.

@rajarshimaitra
Copy link
Contributor Author

rajarshimaitra commented May 27, 2021

@notmandatory Yes, the doc tests were failing as I forgot to change them to be compatible with the current WalletOpts structure. The tests should pass now.

Note:

Looks like the electrum test is failing, I can show you how to spin up docker to run the tests.

It doesn't need docker containers to run the bdk-cli tests. That also means we are not covering any functional tests with bdk-cli. I think that's ok because BDK functionalities are already tested upstream.

Doc tests were failing due to incompatibility with recent changes made
into the `walletOpts` structure.
Copy link
Member

@notmandatory notmandatory left a comment

Choose a reason for hiding this comment

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

ACK f22828d

Will merge tomorrow if no one has any objections.

@notmandatory notmandatory merged commit f22828d into bitcoindevkit:master Jun 2, 2021
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.

3 participants