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

Unable to compile foundry master in projects that depend on foundry crates #3179

Closed
2 tasks
sveitser opened this issue Sep 12, 2022 · 11 comments · Fixed by #3183
Closed
2 tasks

Unable to compile foundry master in projects that depend on foundry crates #3179

sveitser opened this issue Sep 12, 2022 · 11 comments · Fixed by #3183
Labels
C-anvil Command: anvil T-bug Type: bug

Comments

@sveitser
Copy link

Component

Anvil

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

Linux

Describe the bug

Foundry currently relies on the Cargo.lock file to pin ethers to gakonst/ethers-rs@91d8c21.

Crates that use foundry as a dependency will have the ethers dependencies of foundry crates resolve to the latest version that is incompatible since gakonst/ethers-rs#1682 was merged:

    Checking foundry-evm v0.2.0 (https://github.com/foundry-rs/foundry#63c71b4f)
error[E0308]: mismatched types
   --> /home/lulu/.cargo-nix/git/checkouts/foundry-f7cca724e93059b0/63c71b4/evm/src/trace/mod.rs:356:26
    |
356 |             memory: Some(step.memory.data().clone()),
    |                     ---- ^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `H256`, found `u8`
    |                     |
    |                     arguments to this enum variant are incorrect
    |
    = note: expected struct `Vec<H256>`
               found struct `Vec<u8>`
note: tuple variant defined here
   --> /nix/store/c8x06y0ppgqyh7qgh1qaxa71pqh5igwk-rust-minimal-1.63.0/lib/rustlib/src/rust/library/core/src/option.rs:526:5
    |
526 |     Some(#[stable(feature = "rust1", since = "1.0.0")] T),
    |     ^^^^

error[E0308]: mismatched types
   --> /home/lulu/.cargo-nix/git/checkouts/foundry-f7cca724e93059b0/63c71b4/evm/src/trace/mod.rs:358:17
    |
358 |             pc: U256::from(step.pc),
    |                 ^^^^^^^^^^^^^^^^^^^ expected `u64`, found struct `ethers::prelude::U256`

error[E0277]: a value of type `BTreeMap<H256, H256>` cannot be built from an iterator over elements of type `(ethers::prelude::H160, _)`
    --> /home/lulu/.cargo-nix/git/checkouts/foundry-f7cca724e93059b0/63c71b4/evm/src/trace/mod.rs:362:17
     |
361  |               storage: Some(
     |                        ---- required by a bound introduced by this call
362  | /                 step.state
363  | |                     .iter()
364  | |                     .map(|(key, value)| {
365  | |                         (
...    |
375  | |                     })
376  | |                     .collect(),
     | |______________________________^ value of type `BTreeMap<H256, H256>` cannot be built from `std::iter::Iterator<Item=(ethers::prelude::H160, _)>`
     |
     = help: the trait `FromIterator<(ethers::prelude::H160, _)>` is not implemented for `BTreeMap<H256, H256>`
     = help: the trait `FromIterator<(K, V)>` is implemented for `BTreeMap<K, V>`
note: required by a bound in `std::iter::Iterator::collect`
    --> /nix/store/c8x06y0ppgqyh7qgh1qaxa71pqh5igwk-rust-minimal-1.63.0/lib/rustlib/src/rust/library/core/src/iter/traits/iterator.rs:1788:19
     |
1788 |     fn collect<B: FromIterator<Self::Item>>(self) -> B
     |                   ^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `std::iter::Iterator::collect`

Some errors have detailed explanations: E0277, E0308.
For more information about an error, try `rustc --explain E0277`.
error: could not compile `foundry-evm` due to 3 previous errors

If one patches ethers to gakonst/ethers-rs@91d8c21 compiling foundry-evm fails with

    Checking foundry-evm v0.2.0 (https://github.com/foundry-rs/foundry#63c71b4f)
error[E0004]: non-exhaustive patterns: `OptimismGoerli`, `Aurora` and `AuroraTestnet` not covered
  --> /home/lulu/.cargo-nix/registry/src/github.com-1ecc6299db9ec823/ethers-etherscan-0.17.0/src/lib.rs:78:29
   |
78 |         let api_key = match chain {
   |                             ^^^^^ patterns `OptimismGoerli`, `Aurora` and `AuroraTestnet` not covered
   |
note: `ethers_core::types::Chain` defined here
  --> /home/lulu/.cargo-nix/git/checkouts/ethers-rs-c3a7c0a0ae0fe6be/91d8c21/ethers-core/src/types/chain.rs:49:5
   |
26 | / pub enum Chain {
27 | |     Mainnet = 1,
28 | |     Morden = 2,
29 | |     Ropsten = 3,
...  |
49 | |     OptimismGoerli = 420,
   | |     ^^^^^^^^^^^^^^ not covered
...  |
67 | |     Aurora = 1313161554,
   | |     ^^^^^^ not covered
68 | |     AuroraTestnet = 1313161555,
   | |     ^^^^^^^^^^^^^ not covered
69 | | }
   | |_-
   = note: the matched value is of type `ethers_core::types::Chain`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms
   |
113~             }
114+             OptimismGoerli | Aurora | AuroraTestnet => todo!()
@sveitser sveitser added the T-bug Type: bug label Sep 12, 2022
@sveitser sveitser changed the title Unable to compile foundry master in projects that depend on use foundry crates Unable to compile foundry master in projects that depend on foundry crates Sep 12, 2022
@mattsse
Copy link
Member

mattsse commented Sep 12, 2022

do you also have a revm dependency?
try bumping your ethers dep as well

@sveitser
Copy link
Author

sveitser commented Sep 12, 2022

I do have an revm dependency too yes.

I'm not quite sure what you mean by bumping ethers, ethers is resolved to the latest master commit.

To reproduce the issue one create a new project and add for example anvil as a dependency.

[package]
name = "foundry-compilation-issue"
version = "0.1.0"
edition = "2021"

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

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

cargo check then fails with the same errors

    Checking foundry-evm v0.2.0 (https://github.com/foundry-rs/foundry#63c71b4f)
error[E0308]: mismatched types
   --> /home/lulu/.cargo-nix/git/checkouts/foundry-f7cca724e93059b0/63c71b4/evm/src/trace/mod.rs:356:26
    |
356 |             memory: Some(step.memory.data().clone()),
    |                     ---- ^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `H256`, found `u8`
    |                     |
    |                     arguments to this enum variant are incorrect
    |
    = note: expected struct `Vec<H256>`
               found struct `Vec<u8>`
note: tuple variant defined here
   --> /nix/store/c8x06y0ppgqyh7qgh1qaxa71pqh5igwk-rust-minimal-1.63.0/lib/rustlib/src/rust/library/core/src/option.rs:526:5
    |
526 |     Some(#[stable(feature = "rust1", since = "1.0.0")] T),
    |     ^^^^

error[E0308]: mismatched types
   --> /home/lulu/.cargo-nix/git/checkouts/foundry-f7cca724e93059b0/63c71b4/evm/src/trace/mod.rs:358:17
    |
358 |             pc: U256::from(step.pc),
    |                 ^^^^^^^^^^^^^^^^^^^ expected `u64`, found struct `ethers::prelude::U256`

error[E0277]: a value of type `BTreeMap<H256, H256>` cannot be built from an iterator over elements of type `(ethers::prelude::H160, _)`
    --> /home/lulu/.cargo-nix/git/checkouts/foundry-f7cca724e93059b0/63c71b4/evm/src/trace/mod.rs:362:17
     |
361  |               storage: Some(
     |                        ---- required by a bound introduced by this call
362  | /                 step.state
363  | |                     .iter()
364  | |                     .map(|(key, value)| {
365  | |                         (
...    |
375  | |                     })
376  | |                     .collect(),
     | |______________________________^ value of type `BTreeMap<H256, H256>` cannot be built from `std::iter::Iterator<Item=(ethers::prelude::H160, _)>`
     |
     = help: the trait `FromIterator<(ethers::prelude::H160, _)>` is not implemented for `BTreeMap<H256, H256>`
     = help: the trait `FromIterator<(K, V)>` is implemented for `BTreeMap<K, V>`
note: required by a bound in `std::iter::Iterator::collect`
    --> /nix/store/c8x06y0ppgqyh7qgh1qaxa71pqh5igwk-rust-minimal-1.63.0/lib/rustlib/src/rust/library/core/src/iter/traits/iterator.rs:1788:19
     |
1788 |     fn collect<B: FromIterator<Self::Item>>(self) -> B
     |                   ^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `std::iter::Iterator::collect`

Some errors have detailed explanations: E0277, E0308.
For more information about an error, try `rustc --explain E0277`.
error: could not compile `foundry-evm` due to 3 previous errors

$  cargo tree | grep 'ethers\|revm\|anvil'      
└── anvil v0.1.0 (https://github.com/foundry-rs/foundry#63c71b4f)
    ├── anvil-core v0.1.0 (https://github.com/foundry-rs/foundry#63c71b4f)
    │   ├── ethers-core v0.17.0 (https://github.com/gakonst/ethers-rs#162e0de2)
    │   │   ├── ethers v0.17.0 (https://github.com/gakonst/ethers-rs#162e0de2)
    │   │   │   ├── ethers-addressbook v0.17.0 (https://github.com/gakonst/ethers-rs#162e0de2)
    │   │   │   │   ├── ethers-core v0.17.0 (https://github.com/gakonst/ethers-rs#162e0de2) (*)
    │   │   │   ├── ethers-contract v0.17.0 (https://github.com/gakonst/ethers-rs#162e0de2)
    │   │   │   │   ├── ethers-contract-abigen v0.17.0 (https://github.com/gakonst/ethers-rs#162e0de2)
    │   │   │   │   │   ├── ethers-core v0.17.0 (https://github.com/gakonst/ethers-rs#162e0de2) (*)
    │   │   │   │   ├── ethers-contract-derive v0.17.0 (proc-macro) (https://github.com/gakonst/ethers-rs#162e0de2)
    │   │   │   │   │   ├── ethers-contract-abigen v0.17.0 (https://github.com/gakonst/ethers-rs#162e0de2)
    │   │   │   │   │   │   ├── ethers-core v0.17.0 (https://github.com/gakonst/ethers-rs#162e0de2)
    │   │   │   │   │   ├── ethers-core v0.17.0 (https://github.com/gakonst/ethers-rs#162e0de2) (*)
    │   │   │   │   ├── ethers-core v0.17.0 (https://github.com/gakonst/ethers-rs#162e0de2) (*)
    │   │   │   │   ├── ethers-providers v0.17.0 (https://github.com/gakonst/ethers-rs#162e0de2)
    │   │   │   │   │   ├── ethers-core v0.17.0 (https://github.com/gakonst/ethers-rs#162e0de2) (*)
    │   │   │   ├── ethers-core v0.17.0 (https://github.com/gakonst/ethers-rs#162e0de2) (*)
    │   │   │   ├── ethers-etherscan v0.17.0 (https://github.com/gakonst/ethers-rs#162e0de2)
    │   │   │   │   ├── ethers-core v0.17.0 (https://github.com/gakonst/ethers-rs#162e0de2) (*)
    │   │   │   ├── ethers-middleware v0.17.0 (https://github.com/gakonst/ethers-rs#162e0de2)
    │   │   │   │   ├── ethers-contract v0.17.0 (https://github.com/gakonst/ethers-rs#162e0de2) (*)
    │   │   │   │   ├── ethers-core v0.17.0 (https://github.com/gakonst/ethers-rs#162e0de2) (*)
    │   │   │   │   ├── ethers-etherscan v0.17.0 (https://github.com/gakonst/ethers-rs#162e0de2) (*)
    │   │   │   │   ├── ethers-providers v0.17.0 (https://github.com/gakonst/ethers-rs#162e0de2) (*)
    │   │   │   │   ├── ethers-signers v0.17.0 (https://github.com/gakonst/ethers-rs#162e0de2)
    │   │   │   │   │   ├── ethers-core v0.17.0 (https://github.com/gakonst/ethers-rs#162e0de2) (*)
    │   │   │   ├── ethers-providers v0.17.0 (https://github.com/gakonst/ethers-rs#162e0de2) (*)
    │   │   │   ├── ethers-signers v0.17.0 (https://github.com/gakonst/ethers-rs#162e0de2) (*)
    │   │   │   └── ethers-solc v0.17.0 (https://github.com/gakonst/ethers-rs#162e0de2)
    │   │   │       ├── ethers-core v0.17.0 (https://github.com/gakonst/ethers-rs#162e0de2) (*)
    │   │   │   ├── ethers-core v0.17.0 (https://github.com/gakonst/ethers-rs#162e0de2) (*)
    │   │   │   ├── ethers-providers v0.17.0 (https://github.com/gakonst/ethers-rs#162e0de2) (*)
    │   │   │   ├── ethers-solc v0.17.0 (https://github.com/gakonst/ethers-rs#162e0de2) (*)
    │   │   │   │   ├── ethers-core v0.17.0 (https://github.com/gakonst/ethers-rs#162e0de2) (*)
    │   │   │   │   ├── ethers-etherscan v0.17.0 (https://github.com/gakonst/ethers-rs#162e0de2) (*)
    │   │   │   │   ├── ethers-solc v0.17.0 (https://github.com/gakonst/ethers-rs#162e0de2) (*)
    │   │   │   ├── ethers-addressbook v0.17.0 (https://github.com/gakonst/ethers-rs#162e0de2) (*)
    │   │   │   ├── ethers-contract v0.17.0 (https://github.com/gakonst/ethers-rs#162e0de2) (*)
    │   │   │   ├── ethers-core v0.17.0 (https://github.com/gakonst/ethers-rs#162e0de2) (*)
    │   │   │   ├── ethers-etherscan v0.17.0 (https://github.com/gakonst/ethers-rs#162e0de2) (*)
    │   │   │   ├── ethers-providers v0.17.0 (https://github.com/gakonst/ethers-rs#162e0de2) (*)
    │   │   │   ├── ethers-solc v0.17.0 (https://github.com/gakonst/ethers-rs#162e0de2) (*)
    │   │   │   │   ├── ethers-core v0.17.0 (https://github.com/gakonst/ethers-rs#162e0de2) (*)
    │   │   ├── revm v2.0.0
    │   │   │   ├── revm_precompiles v1.1.1
    ├── anvil-rpc v0.1.0 (https://github.com/foundry-rs/foundry#63c71b4f)
    ├── anvil-server v0.1.0 (https://github.com/foundry-rs/foundry#63c71b4f)
    │   ├── anvil-rpc v0.1.0 (https://github.com/foundry-rs/foundry#63c71b4f) (*)
    ├── ethers v0.17.0 (https://github.com/gakonst/ethers-rs#162e0de2) (*)
    │   ├── ethers v0.17.0 (https://github.com/gakonst/ethers-rs#162e0de2) (*)
    ├── revm_precompiles v1.1.1 (*)

@sveitser
Copy link
Author

Sorry I copied the wrong traceback. Will update it.

@mattsse
Copy link
Member

mattsse commented Sep 12, 2022

what's your rust version?
can you try after running rustup update

@sveitser
Copy link
Author

rustc 1.63.0 (4b91a6ea7 2022-08-08)

I'm not using rustup. But as I mentioned just before I copied the wrong traceback into the issue. It should be fixed now.

@mattsse
Copy link
Member

mattsse commented Sep 12, 2022

iirc revm requires at least 1.64

@sveitser
Copy link
Author

The revm CI runs with 1.63 so I think that shouldn't be the problem.

https://github.com/bluealloy/revm/runs/8284537901?check_suite_focus=true#step:3:13

I get the same compilation errors if I run cargo update -p ethers followed by cargo check in the foundry repo (on latest master 63c71b4)

@mattsse
Copy link
Member

mattsse commented Sep 12, 2022

does it work with 1.64?

@rkrasiuk rkrasiuk added the C-anvil Command: anvil label Sep 12, 2022
@sveitser
Copy link
Author

I get the same errors with rustc 1.64.0-beta.6 (25912c097 2022-09-09) installed via rustup.

@mattsse
Copy link
Member

mattsse commented Sep 12, 2022

this turned out to be an issue where we haven't bumped breaking changes from ethers-rs yet, you can patch ethers-rs until #3183 lands

@sveitser
Copy link
Author

Thanks @mattsse Patching doesn't work for me as I mentioned in the original issue post. I'm not in urgent need of a fix though, so no problem!

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

Successfully merging a pull request may close this issue.

3 participants