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

Dependency Version Mismatch for alloy-rpc-types in foundry-common #6772

Closed
2 tasks
supernovahs opened this issue Jan 12, 2024 · 10 comments · Fixed by #6799
Closed
2 tasks

Dependency Version Mismatch for alloy-rpc-types in foundry-common #6772

supernovahs opened this issue Jan 12, 2024 · 10 comments · Fixed by #6799
Labels
T-bug Type: bug

Comments

@supernovahs
Copy link

Component

Chisel

Have you ensured that all of these are up to date?

  • Foundry
  • Foundryup

What version of Foundry are you on?

No response

What command(s) is the bug in?

No response

Operating System

macOS (Apple Silicon)

Describe the bug

When adding chisel as a dependency from the foundry-rs GitHub repository, I encountered a version mismatch error for alloy-rpc-types. The required version ^0.1.0 is not available on crates.io, which leads to a failure when building my project.

Steps to Reproduce

  1. Add chisel as a git dependency in my project's Cargo.toml:

[dependencies]
chisel = { git = "https://github.com/foundry-rs/foundry", package = "chisel" }

Run cargo build.

Expected Behavior

The project should fetch the required alloy-* crates from the specified git repositories and build successfully.

Current Behavior

Cargo fails to find the required ^0.1.0 version of alloy-rpc-types, as it seems to be unavailable on crates.io. The error message suggests there might be a version that was updated and not re-vendored.

Error

error: failed to select a version for the requirement `alloy-rpc-types = "^0.1.0"`
candidate versions found which didn't match: 0.0.0-reserved
location searched: crates.io index
required by package `foundry-common v0.2.0 (https://github.com/foundry-rs/foundry#b320027a)`

Possible Solutions

If alloy-rpc-types is an internal dependency or is located in a different repository, could you please advise on how to include it correctly?
If the version ^0.1.0 is supposed to be available on crates.io, could there be a missing publish step?
If this is an issue with vendoring, would it be possible to get instructions on how to vendor the necessary crates for chisel?

@supernovahs supernovahs added the T-bug Type: bug label Jan 12, 2024
@supernovahs
Copy link
Author

fyi, this same error is for all alloy crates, not just for alloy-rpc-types
And also for evm inspectors

@kallydev
Copy link
Contributor

As alloy has not yet released version 0.1.0 on crates.io, foundry directly specifies the git url as the source in the patch section of Cargo.toml.

https://doc.rust-lang.org/cargo/reference/overriding-dependencies.html#the-patch-section

foundry/Cargo.toml

Lines 203 to 231 in d2372db

[patch.crates-io]
ethers = { git = "https://github.com/gakonst/ethers-rs", rev = "f0e5b194f09c533feb10d1a686ddb9e5946ec107" }
ethers-core = { git = "https://github.com/gakonst/ethers-rs", rev = "f0e5b194f09c533feb10d1a686ddb9e5946ec107" }
ethers-contract = { git = "https://github.com/gakonst/ethers-rs", rev = "f0e5b194f09c533feb10d1a686ddb9e5946ec107" }
ethers-contract-abigen = { git = "https://github.com/gakonst/ethers-rs", rev = "f0e5b194f09c533feb10d1a686ddb9e5946ec107" }
ethers-providers = { git = "https://github.com/gakonst/ethers-rs", rev = "f0e5b194f09c533feb10d1a686ddb9e5946ec107" }
ethers-signers = { git = "https://github.com/gakonst/ethers-rs", rev = "f0e5b194f09c533feb10d1a686ddb9e5946ec107" }
ethers-middleware = { git = "https://github.com/gakonst/ethers-rs", rev = "f0e5b194f09c533feb10d1a686ddb9e5946ec107" }
ethers-solc = { git = "https://github.com/gakonst/ethers-rs", rev = "f0e5b194f09c533feb10d1a686ddb9e5946ec107" }
# alloy-consensus = { git = "https://github.com/alloy-rs/alloy" }
alloy-json-rpc = { git = "https://github.com/alloy-rs/alloy" }
alloy-providers = { git = "https://github.com/alloy-rs/alloy" }
alloy-pubsub = { git = "https://github.com/alloy-rs/alloy" }
alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy" }
alloy-rpc-trace-types = { git = "https://github.com/alloy-rs/alloy" }
alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy" }
alloy-signer = { git = "https://github.com/alloy-rs/alloy" }
alloy-transport = { git = "https://github.com/alloy-rs/alloy" }
alloy-transport-http = { git = "https://github.com/alloy-rs/alloy" }
alloy-transport-ipc = { git = "https://github.com/alloy-rs/alloy" }
alloy-transport-ws = { git = "https://github.com/alloy-rs/alloy" }
revm = { git = "https://github.com/bluealloy/revm", branch = "reth_freeze" }
revm-primitives = { git = "https://github.com/bluealloy/revm", branch = "reth_freeze" }
revm-interpreter = { git = "https://github.com/bluealloy/revm", branch = "reth_freeze" }
revm-precompile = { git = "https://github.com/bluealloy/revm", branch = "reth_freeze" }
revm-inspectors = { git = "https://github.com/paradigmxyz/evm-inspectors" }

Or just define it in the dependencies section.

[dependencies]
alloy-providers = { version = "0.1.0", git = "https://github.com/alloy-rs/alloy" }
alloy-pubsub = { version = "0.1.0", git = "https://github.com/alloy-rs/alloy" }
alloy-network = { version = "0.1.0", git = "https://github.com/alloy-rs/alloy" }
alloy-rpc-client = { version = "0.1.0", git = "https://github.com/alloy-rs/alloy" }
alloy-transport-http = { version = "0.1.0", git = "https://github.com/alloy-rs/alloy" }
alloy-rpc-types = { version = "0.1.0", git = "https://github.com/alloy-rs/alloy" }
...

@supernovahs
Copy link
Author

supernovahs commented Jan 12, 2024

[[patch.crates-io]
alloy-json-rpc = { git = "https://github.com/alloy-rs/alloy" }
alloy-providers = { git = "https://github.com/alloy-rs/alloy" }
alloy-pubsub = { git = "https://github.com/alloy-rs/alloy" }
alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy" }
alloy-rpc-trace-types = { git = "https://github.com/alloy-rs/alloy" }
alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy" }
alloy-signer = { git = "https://github.com/alloy-rs/alloy" }
alloy-transport = { git = "https://github.com/alloy-rs/alloy" }
alloy-transport-http = { git = "https://github.com/alloy-rs/alloy" }
alloy-transport-ipc = { git = "https://github.com/alloy-rs/alloy" }
alloy-transport-ws = { git = "https://github.com/alloy-rs/alloy" }
revm-inspectors = { git = "https://github.com/paradigmxyz/evm-inspectors" }

Doing this
But getting error

error[E0308]: mismatched types
   --> /Users/supernovahs/.cargo/git/checkouts/foundry-f7cca724e93059b0/b320027/crates/evm/core/src/opts.rs:128:25
    |
128 |                 caller: self.sender,
    |                         ^^^^^^^^^^^ expected `revm::revm_primitives::Address`, found `alloy_primitives::Address`
    |
 |_^
    = note: perhaps two different versions of crate `alloy_primitives` are being used?
    = note: this error originates in the macro `wrap_fixed_bytes` (in Nightly builds, run with -Z macro-backtrace for more info)

@kallydev
Copy link
Contributor

[dependencies]
clap = { version = "4", features = ["derive", "env", "unicode", "wrap_help"] }
rustyline = "12"
chisel = {git = "https://github.com/foundry-rs/foundry", package = "chisel"}
alloy-json-rpc = { git = "https://github.com/alloy-rs/alloy" }
alloy-providers = { git = "https://github.com/alloy-rs/alloy" }
alloy-pubsub = { git = "https://github.com/alloy-rs/alloy" }
alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy" }
alloy-rpc-trace-types = { git = "https://github.com/alloy-rs/alloy" }
alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy" }
alloy-signer = { git = "https://github.com/alloy-rs/alloy" }
alloy-transport = { git = "https://github.com/alloy-rs/alloy" }
alloy-transport-http = { git = "https://github.com/alloy-rs/alloy" }
alloy-transport-ipc = { git = "https://github.com/alloy-rs/alloy" }
alloy-transport-ws = { git = "https://github.com/alloy-rs/alloy" }
revm-inspectors = { git = "https://github.com/paradigmxyz/evm-inspectors" }

Doing this But getting error

error: failed to select a version for the requirement `alloy-rpc-types = "^0.1.0"`
candidate versions found which didn't match: 0.0.0-reserved
location searched: crates.io index
required by package `chisel v0.2.0 (https://github.com/foundry-rs/foundry#b320027a)`
    ... which satisfies git dependency `chisel` (locked to 0.2.0) of package `dwarf v0.1.0 (/Users/supernovahs/Desktop/dwarf)`
if you are looking for the prerelease package it needs to be specified explicitly
    alloy-rpc-types = { version = "0.0.0-reserved" }
perhaps a crate was updated and forgotten to be re-vendored?

You also need to specify version 0.1.0 for alloy.

@supernovahs
Copy link
Author

[package]
name = "dwarf"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
clap = { version = "4", features = ["derive", "env", "unicode", "wrap_help"] }
rustyline = "12"
chisel = {git = "https://github.com/foundry-rs/foundry", package = "chisel"}
alloy-json-rpc = { version = "0.1.0",git = "https://github.com/alloy-rs/alloy" }
alloy-providers = { version = "0.1.0",git = "https://github.com/alloy-rs/alloy" }
alloy-pubsub = { version = "0.1.0",git = "https://github.com/alloy-rs/alloy" }
alloy-rpc-client = { version = "0.1.0",git = "https://github.com/alloy-rs/alloy" }
alloy-rpc-trace-types = { version = "0.1.0",git = "https://github.com/alloy-rs/alloy" }
alloy-rpc-types = { version = "0.1.0",git = "https://github.com/alloy-rs/alloy" }
alloy-signer = { version = "0.1.0",git = "https://github.com/alloy-rs/alloy" }
alloy-transport = { version = "0.1.0",git = "https://github.com/alloy-rs/alloy" }
alloy-transport-http = { version = "0.1.0",git = "https://github.com/alloy-rs/alloy" }
alloy-transport-ipc = { version = "0.1.0",git = "https://github.com/alloy-rs/alloy" }
alloy-transport-ws = { version = "0.1.0",git = "https://github.com/alloy-rs/alloy" }
revm-inspectors = { version = "0.1.0",git = "https://github.com/paradigmxyz/evm-inspectors" }

Error

error: failed to select a version for the requirement `alloy-rpc-types = "^0.1.0"`
candidate versions found which didn't match: 0.0.0-reserved
location searched: crates.io index
required by package `chisel v0.2.0 (https://github.com/foundry-rs/foundry#b320027a)`
    ... which satisfies git dependency `chisel` (locked to 0.2.0) of package `dwarf v0.1.0 (/Users/supernovahs/Desktop/dwarf)`
if you are looking for the prerelease package it needs to be specified explicitly
    alloy-rpc-types = { version = "0.0.0-reserved" }
perhaps a crate was updated and forgotten to be re-vendored?

@supernovahs
Copy link
Author

It's not working for me .

error[E0308]: mismatched types
--> /Users/supernovahs/.cargo/git/checkouts/foundry-f7cca724e93059b0/b320027/crates/evm/core/src/opts.rs:128:25
|
128 | caller: self.sender,
| ^^^^^^^^^^^ expected revm::revm_primitives::Address, found alloy_primitives::Address
|
|_^
= note: perhaps two different versions of crate alloy_primitives are being used?
= note: this error originates in the macro wrap_fixed_bytes (in Nightly builds, run with -Z macro-

Getting many errors across 

```
    = note: perhaps two different versions of crate `alloy_primitives` are being used?
= note: this error originates in the macro `wrap_fixed_bytes` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: a value of type Vec<(revm::revm_primitives::Address, Vec<alloy_primitives::Uint<256, 4>>)> cannot be built from an iterator over elements of type (alloy_primitives::Address, _)
--> /Users/supernovahs/.cargo/git/checkouts/foundry-f7cca724e93059b0/b320027/crates/evm/core/src/utils.rs:214:10
|
214 | .collect();
| ^^^^^^^ value of type Vec<(revm::revm_primitives::Address, Vec<alloy_primitives::Uint<256, 4>>)> cannot be built from std::iter::Iterator<Item=(alloy_primitives::Address, _)>
|
= help: the trait FromIterator<(alloy_primitives::Address, _)> is not implemented for Vec<(revm::revm_primitives::Address, Vec<alloy_primitives::Uint<256, 4>>)>
= help: the trait FromIterator<(revm::revm_primitives::Address, Vec<alloy_primitives::Uint<256, 4>>)> is implemented for Vec<(revm::revm_primitives::Address, Vec<alloy_primitives::Uint<256, 4>>)>
= help: for that trait implementation, expected revm::revm_primitives::Address, found alloy_primitives::Address
note: the method call chain might not have had the expected associated types
--> /Users/supernovahs/.cargo/git/checkouts/foundry-f7cca724e93059b0/b320027/crates/evm/core/src/utils.rs:205:10
|
200 | env.tx.access_list = tx
| ______-
201 | | .access_list
| |
- this expression has type Option<Vec<AccessListItem>>
...
204 | .into_iter()
| ----------- Iterator::Item is AccessListItem here
205 | .map(|item| {
| ^
206 | | (
207 | | item.address,
208 | | item.storage_keys
... |
212 | | )
213 | | })
| |
^ Iterator::Item changed to (Address, _) here
note: required by a bound in std::iter::Iterator::collect
--> /Users/supernovahs/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/iter/traits/iterator.rs:2050:19
|
2050 | fn collect<B: FromIteratorSelf::Item>(self) -> B
| ^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in Iterator::collect

error[E0308]: mismatched types
--> /Users/supernovahs/.cargo/git/checkouts/foundry-f7cca724e93059b0/b320027/crates/evm/core/src/utils.rs:216:19
|
216 | env.tx.data = alloy_primitives::Bytes(tx.input.0.clone());
| ----------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected revm::revm_precompile::Bytes, found alloy_primitives::Bytes
| |
| expected due to the type of this binding
|
= note: alloy_primitives::Bytes and revm::revm_precompile::Bytes have similar names, but are actually distinct types
note: alloy_primitives::Bytes is defined in crate alloy_primitives
--> /Users/supernovahs/.cargo/registry/src/index.crates.io-6f17d22bba15001f/alloy-primitives-0.6.0/src/bytes/mod.rs:20:1
|
20 | pub struct Bytes(pub bytes::Bytes);
| ^^^^^^^^^^^^^^^^
note: revm::revm_precompile::Bytes is defined in crate alloy_primitives
--> /Users/supernovahs/.cargo/registry/src/index.crates.io-6f17d22bba15001f/alloy-primitives-0.4.2/src/bytes/mod.rs:17:1
|
17 | pub struct Bytes(pub bytes::Bytes);
| ^^^^^^^^^^^^^^^^
= note: perhaps two different versions of crate alloy_primitives are being used?

error[E0631]: type mismatch in function arguments
--> /Users/supernovahs/.cargo/git/checkouts/foundry-f7cca724e93059b0/b320027/crates/evm/core/src/utils.rs:217:36
|
217 | env.tx.transact_to = tx.to.map(TransactTo::Call).unwrap_or_else(TransactTo::create)
| --- ^^^^^^^^^^^^^^^^
| | |
| | expected due to this
| | found signature defined here
| required by a bound introduced by this call
|
= note: expected function signature fn(alloy_primitives::Address) -> _
found function signature fn(revm::revm_primitives::Address) -> _
note: required by a bound in std::option::Option::<T>::map
--> /Users/supernovahs/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/option.rs:1069:12
|
1067 | pub fn map<U, F>(self, f: F) -> Option
| --- required by a bound in this associated function
1068 | where
1069 | F: FnOnce(T) -> U,
| ^^^^^^^^^^^^^^ required by this bound in Option::<T>::map
help: consider wrapping the function in a closure
|
217 | env.tx.transact_to = tx.to.map(|arg0: alloy_primitives::Address| TransactTo::Call(/* revm::revm_primitives::Address */)).unwrap_or_else(TransactTo::create)
| +++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++++++

error[E0308]: mismatched types
--> /Users/supernovahs/.cargo/git/checkouts/foundry-f7cca724e93059b0/b320027/crates/evm/core/src/opts.rs:128:25
|
128 | caller: self.sender,
| ^^^^^^^^^^^ expected revm::revm_primitives::Address, found alloy_primitives::Address
|
= note: alloy_primitives::Address and revm::revm_primitives::Address have similar names, but are actually distinct types
note: alloy_primitives::Address is defined in crate alloy_primitives
--> /Users/supernovahs/.cargo/registry/src/index.crates.io-6f17d22bba15001f/alloy-primitives-0.6.0/src/bits/address.rs:45:1
|
45 | / wrap_fixed_bytes!(
46 | | // we implement Display with the checksum, so we don't derive it
47 | | extra_derives: [],
48 | | /// An Ethereum address, 20 bytes in length.
... |
86 | | pub struct Address<20>;
87 | | );
| |^
note: revm::revm_primitives::Address is defined in crate alloy_primitives
--> /Users/supernovahs/.cargo/registry/src/index.crates.io-6f17d22bba15001f/alloy-primitives-0.4.2/src/bits/address.rs:45:1
|
45 | / wrap_fixed_bytes!(
46 | | // we implement Display with the checksum, so we don't derive it
47 | | extra_derives: [],
48 | | /// An Ethereum address, 20 bytes in length.
... |
86 | | pub struct Address<20>;
87 | | );
| |
^
= note: perhaps two different versions of crate alloy_primitives are being used?
= note: this error originates in the macro wrap_fixed_bytes (in Nightly builds, run with -Z macro-backtrace for more info)

Some errors have detailed explanations: E0046, E0053, E0107, E0191, E0277, E0308, E0407, E0599, E0631.
For more information about an error, try rustc --explain E0046.
error: could not compile foundry-evm-core (lib) due to 177 previous errors

```

@supernovahs
Copy link
Author

trying to clean cache maybe that 's the problem

@DaniPopes
Copy link
Member

cargo new test
cd test
cargo add foundry-evm --git https://github.com/foundry-rs/foundry
# Paste [patch] from foundry-rs/foundry/Cargo.toml into local Cargo.toml
cargo r

@supernovahs
Copy link
Author

supernovahs commented Jan 15, 2024

 Desktop % cargo new test_version
     Created binary (application) `test_version` package
supernovahs@supernova Desktop % cd test_version/
supernovahs@supernova test_version % cargo add foundry-evm --git https://github.com/foundry-rs/foundry
    Updating git repository `https://github.com/foundry-rs/foundry`
      Adding foundry-evm (git) to dependencies.
             Features:
             + rustls
             - openssl
    Updating git repository `https://github.com/foundry-rs/foundry`
    Updating crates.io index
error: failed to select a version for the requirement `alloy-rpc-types = "^0.1.0"`
candidate versions found which didn't match: 0.0.0-reserved
location searched: crates.io index
required by package `foundry-evm v0.2.0 (https://github.com/foundry-rs/foundry#c5fd67bc)`
    ... which satisfies git dependency `foundry-evm` of package `test_version v0.1.0 (/Users/supernovahs/Desktop/test_version)`
if you are looking for the prerelease package it needs to be specified explicitly
    alloy-rpc-types = { version = "0.0.0-reserved" }
perhaps a crate was updated and forgotten to be re-vendored?
supernovahs@supernova test_version % code .


@DaniPopes

@DaniPopes
Copy link
Member

I see, don't know how I managed to make it work initially but #6799 should fix it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-bug Type: bug
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants