Reputation: 15
I'm reading a rust project. Deleting the workspace cargo.toml
and run test in eth_rpc_client
gives out following error. I'm speculating if there's something around patch.crate-io, but cargo.toml
of eth_rpc_client
use same version as workspace does.
➜ eth_rpc_client git:(master) ✗ cargo test
Updating crates.io index
Updating git repository `https://github.com/aurora-is-near/lighthouse.git`
error: failed to select a version for the requirement `eth2_hashing = "^0.3.0"`
candidate versions found which didn't match: 0.2.0, 0.1.0
location searched: crates.io index
required by package `merkle_proof v0.2.0 (https://github.com/aurora-is-near/lighthouse.git?tag=v3.5.1-wasm#ce4e2b44)`
... which satisfies git dependency `merkle_proof` of package `eth_rpc_client v0.1.0 (/Users/paulyu/paul_playground/rainbow-bridge/eth2near/eth_rpc_client)`
.
├── Cargo.lock
├── Cargo.toml // workspace cargo.toml
├── contract_wrapper
├── eth2-contract-init
├── eth2near-block-relay
├── eth2near-block-relay-rs
├── eth_rpc_client
├── ethashproof
├── finality-update-verify
├── logger
├── rust-toolchain
└── target
workspace Cargo.toml
[workspace]
members = [
"contract_wrapper",
"eth2-contract-init",
"eth2near-block-relay-rs",
"eth_rpc_client",
"finality-update-verify",
"logger",
]
[patch]
[patch.crates-io]
eth2_ssz = { git = "https://github.com/aurora-is-near/lighthouse.git", tag = "v3.5.1-wasm" }
eth2_ssz_types = { git = "https://github.com/aurora-is-near/lighthouse.git", tag = "v3.5.1-wasm" }
eth2_hashing = { git = "https://github.com/aurora-is-near/lighthouse.git", tag = "v3.5.1-wasm" }
tree_hash = { git = "https://github.com/aurora-is-near/lighthouse.git", tag = "v3.5.1-wasm"}
tree_hash_derive = { git = "https://github.com/aurora-is-near/lighthouse.git", tag = "v3.5.1-wasm"}
eth2_serde_utils = { git = "https://github.com/aurora-is-near/lighthouse.git", tag = "v3.5.1-wasm" }
eth2_ssz_derive = { git = "https://github.com/aurora-is-near/lighthouse.git", tag = "v3.5.1-wasm" }
package Cargo.toml
[package]
name = "eth_rpc_client"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
types = { git = "https://github.com/aurora-is-near/lighthouse.git", tag = "v3.5.1-wasm" }
tree_hash = { git = "https://github.com/aurora-is-near/lighthouse.git", tag = "v3.5.1-wasm" }
merkle_proof = { git = "https://github.com/aurora-is-near/lighthouse.git", tag = "v3.5.1-wasm" }
eth2_hashing = { git = "https://github.com/aurora-is-near/lighthouse.git", tag = "v3.5.1-wasm" }
eth2_ssz = { git = "https://github.com/aurora-is-near/lighthouse.git", tag = "v3.5.1-wasm" }
log = { version = "0.4", features = ["std", "serde"] }
serde_json = "1.0.74"
serde = { version = "1.0", features = ["derive"] }
ethereum-types = { version = "0.14.1", features = ["rlp", "serialize"], default-features = false }
reqwest = { version = "0.11", features = ["blocking"] }
eth-types = { path = "../../contracts/near/eth-types/" }
contract_wrapper = { path = "../contract_wrapper" }
clap = { version = "3.1.6", features = ["derive"] }
tokio = { version = "1.1", features = ["macros", "rt", "time"] }
env_logger = "0.9.0"
borsh = "0.9.3"
futures = { version = "0.3.21", default-features = false }
async-std = "1.12.0"
hex = "*"
toml = "0.5.9"
finality-update-verify = { path = "../finality-update-verify" }
atomic_refcell = "0.1.8"
bitvec = "*"
prometheus = { version = "0.9", features = ["process"] }
lazy_static = "1.4"
warp = "0.2"
thread = "*"
dotenv = "0.15.0"
ref: https://github.com/aurora-is-near/rainbow-bridge/tree/master/eth2near
Upvotes: 0
Views: 212
Reputation: 60787
Yes, the [patch]
section is very important.
The eth2_hashing
dependency in your eth_rpc_client
crate points to the correct GitHub repository, but that's not what is causing the error. Notice the "required by package merkle_proof" in the error message. If we look at the Cargo.toml
of the merkle_proof package, it contains:
[dependencies]
eth2_hashing = "0.3.0"
This will try to look for version 0.3.0 of it on crates.io, which doesn't exist. Having the [patch]
section will essentially redirect where that package is found.
To resolve this, you can either change all the packages in your GitHub repository to point to each other explicitly, or include a [patch.crates-io]
in your eth_rpc_client
package. If you have multiple packages needing it, consider keeping them in a workspace so you can have your patches all in one place.
Upvotes: 1