我正在尝试使用玩具代码示例,我的
Cargo.toml
是:
[package]
name = "reth_mempool"
version = "0.1.0"
edition = "2021"
[dependencies]
reth-transaction-pool = { git = "https://github.com/paradigmxyz/reth.git", tag = "v0.2.0-beta.5"}
我在编译 reth-primitives 时遇到很多错误。第一个是:
error[E0308]: mismatched types
--> /home/ittay/.cargo/git/checkouts/reth-36d3ea1d1152b20c/54f75cd/crates/primitives/src/chain/spec.rs:28:28
|
28 | genesis_hash: Some(b256!(
| _______________________----_^
| | |
| | arguments to this enum variant are incorrect
29 | | "d4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3"
30 | | )),
| |_________^ expected `alloy_primitives::FixedBytes<32>`, found `revm_primitives::FixedBytes<32>`
|
= note: `revm_primitives::FixedBytes<32>` and `alloy_primitives::FixedBytes<32>` have similar names, but are actually distinct types
note: `revm_primitives::FixedBytes<32>` is defined in crate `alloy_primitives`
--> /home/ittay/.cargo/registry/src/index.crates.io-6f17d22bba15001f/alloy-primitives-0.7.0/src/bits/fixed.rs:33:1
|
33 | pub struct FixedBytes<const N: usize>(#[into_iterator(owned, ref, ref_mut)] pub [u8; N]);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: `alloy_primitives::FixedBytes<32>` is defined in crate `alloy_primitives`
--> /home/ittay/.cargo/registry/src/index.crates.io-6f17d22bba15001f/alloy-primitives-0.6.4/src/bits/fixed.rs:33:1
|
33 | pub struct FixedBytes<const N: usize>(#[into_iterator(owned, ref, ref_mut)] pub [u8; N]);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: perhaps two different versions of crate `alloy_primitives` are being used?
help: the type constructed contains `revm_primitives::FixedBytes<32>` due to the type of the argument passed
--> /home/ittay/.cargo/git/checkouts/reth-36d3ea1d1152b20c/54f75cd/crates/primitives/src/chain/spec.rs:28:23
|
28 | genesis_hash: Some(b256!(
| ________________________^____-
| | _______________________|
| ||
29 | || "d4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3"
30 | || )),
| ||_________-^
| |__________|
| this argument influences the type of `Some`
note: tuple variant defined here
--> /home/ittay/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs:578:5
|
578 | Some(#[stable(feature = "rust1", since = "1.0.0")] T),
| ^^^^
确实,合金基元出现在 0.6.4 和 0.7.0 中。
如果我签出 reth 存储库(使用相同的标签)并构建,它就可以工作并且
cargo tree
显示它仅使用 0.7.0。
我不知道为什么使用0.6.4。我该如何解决这个问题?
作为奖励,我很乐意解释为什么货物甚至允许在多个版本中使用同一个库(根据
cargo tree
,有时对于同一个板条箱)。看来这几乎总是会导致冲突。
您可能需要使用resolver版本2来解决问题。
自 Rust 1.51.0 起,Cargo 选择支持新的功能解析器,可以使用
resolver = "2"
中的 Cargo.toml
激活。
此外,在
edition = "2021"
中写 Cargo.toml
也会暗示 resolver = "2"
。
您可以在货物手册中查看此部分了解详情。