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

dependencies: Remove duplicate bitcoin dependency #28

Closed
wants to merge 1 commit into from

Conversation

GeneFerneau
Copy link
Contributor

Update bitcoincore_rpc dependency, remove direct dependency on bitcoin, and use bitcoincore_rpc::bitcoin as bitcoin

Resolves #18

Update bitcoincore_rpc dependency, remove direct dependency on bitcoin,
and use bitcoincore_rpc::bitcoin as bitcoin

Resolves bitcoin-teleport#18
@codecov-commenter
Copy link

Codecov Report

Merging #28 (b493e9e) into master (237c8ae) will increase coverage by 0.07%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #28      +/-   ##
==========================================
+ Coverage   81.60%   81.68%   +0.07%     
==========================================
  Files           8        8              
  Lines        2571     2571              
==========================================
+ Hits         2098     2100       +2     
+ Misses        473      471       -2     
Impacted Files Coverage Δ
src/contracts.rs 92.22% <ø> (ø)
src/main.rs 43.08% <ø> (ø)
src/maker_protocol.rs 85.67% <ø> (ø)
src/messages.rs 86.90% <ø> (ø)
src/taker_protocol.rs 95.07% <ø> (ø)
src/wallet_sync.rs 78.45% <ø> (ø)
src/offerbook_sync.rs 85.91% <0.00%> (+2.81%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 237c8ae...b493e9e. Read the comment docs.

@chris-belcher
Copy link
Contributor

Thanks for the PR

#bitcoincore-rpc = {git="https://github.com/rust-bitcoin/rust-bitcoincore-rpc"}
bitcoin-wallet = "1.1.0"
bitcoin = "0.25"
Copy link
Contributor

Choose a reason for hiding this comment

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

On further thoughts.

I am not sure if its a good idea to use bitcoin from a derived crate like bitcoincore-rpc, even though it might expose it publicly.

We will be using bitcoin quite heavily through out the project, we might wanna move up in our bitcoin version (or add extra feature we need in bitcoin). For example encoding/decoding tests require rand feature of bitcoin.

I think because we might wanna use bitcoin in all of its capability, its better to use our own dependency of bitcoin, and not rely on the exposed dependency of derived crates.

So specific to this case, i think duplicating bitcoin dependency is better than latter running into weird cargo dep issues.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, later if we decide to use some other bitcoin derived crates like rust-miniscript and if it has a different bitcoin dep version, cargo will be duplicating the bitcoin deps anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We will be using bitcoin quite heavily through out the project, we might wanna move up in our bitcoin version (or add extra feature we need in bitcoin).

Right, I would think it's pretty easy to add back the bitcoin dependency when that need comes up, and/or make a PR upstream to bitcoincore_rpc to add a feature(s) that expose bitcoin features. Currently the need isn't in the code base, and this PR cleans up an unnecessary duplicate dependency.

For example encoding/decoding tests require rand feature of bitcoin

That can be handled with a test dependency that doesn't affect the main build, but I get your point. What do you think of the idea I mention above?

Also, later if we decide to use some other bitcoin derived crates like rust-miniscript and if it has a different bitcoin dep version, cargo will be duplicating the bitcoin deps anyway.

That's a hypothetical problem that can be handled when it comes up. The problem doesn't exist in the current code base.

@mojoX911
Copy link
Contributor

mojoX911 commented Aug 3, 2021

In general I am not in favor of using a parent dependency from a derived dependency. That makes the code look ugly and also reduces flexibility.

When cargo downloads two different version of same deps, it generally means that there are different requirements at different deps. Which is the case here between bitcoin and bitcoin-wallet (not bitcoin-rpc). The latest release of bitcoin-wallet requires bitcoin 0.21.0 and all other dependency in our crate resolves to bitcoin 0.25.2. Thus cargo maintains two different version of bitcoin.

So using bitcoin-rpc as a source of bitcoin doesn't fix this issue. We still have duplicate bitcoin crate.

This can be seen in the cargo lock as below

[[package]]
name = "bitcoin"
version = "0.25.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aefc9be9f17185f4ebccae6575d342063f775924d57df0000edb1880c0fb7095"
dependencies = [
 "bech32",
 "bitcoin_hashes 0.9.7",
 "secp256k1 0.19.0",
 "serde",
]

[[package]]
name = "bitcoincore-rpc-json"
version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "76d488ec31e9cb6726c361be5160f7d2aaace89a0681acf1f476b8fada770b6e"
dependencies = [
 "bitcoin 0.25.2",
 "hex",
 "serde",
 "serde_json",
]

[[package]]
name = "bitcoin-wallet"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b99191e69b23808ee29120a67cc4f6f1628c59ef3fdb48a779f4002c780f39c8"
dependencies = [
 "bitcoin 0.21.0",
 "bitcoin_hashes 0.7.6",
 "rand 0.7.3",
 "rust-crypto",
 "secp256k1 0.15.5",
 "serde",
 "serde_derive",
]

So our bitcoin and bitcoin-rpc are actually in sync. Its the wallet thing that causes this problem.

This should be fixed once bitcoin-wallet upstream releases their 1.1.0 with bitcoin 0.26.0. This is in their current master.

You can check that duplication goes away by making only the following changes in Cargo.toml. This converge all the bitcoin deps into 0.26.2.

[dependencies]
bitcoincore-rpc = "^0.13.0"
bitcoin-wallet = {git = "https://github.com/rust-bitcoin/rust-wallet", branch = "master"}
bitcoin = "0.26"  

@mojoX911
Copy link
Contributor

mojoX911 commented Aug 3, 2021

To confirm further you could let cargo figure the best case scenario by specifying wild card deps like this

[dependencies]
bitcoincore-rpc = "*"
bitcoin-wallet = "*"
bitcoin = "*"  

And it resolves into this

[[package]]
name = "bitcoincore-rpc-json"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "977e55a945ab1e3c446dea93267876703c15e07c7d6eeb1dfa1766b3190c560f"
dependencies = [
 "bitcoin 0.26.2",
 "hex",
 "serde",
 "serde_json",
]

[[package]]
name = "bitcoin-wallet"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b99191e69b23808ee29120a67cc4f6f1628c59ef3fdb48a779f4002c780f39c8"
dependencies = [
 "bitcoin 0.21.0",
 "bitcoin_hashes 0.7.6",
 "rand 0.7.3",
 "rust-crypto",
 "secp256k1 0.15.3",
 "serde",
 "serde_derive",
]

So its really the bitcoin-wallet as the source of duplication.

And in this specific scenario i think its reasonable just to wait for upstream and have it solved automatically, than change our code base for it.

@GeneFerneau GeneFerneau closed this Aug 4, 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.

Dependency duplication for bitcoin*
4 participants