Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

abigen.rs example #1213

Closed
samlaf opened this issue May 3, 2022 · 7 comments
Closed

abigen.rs example #1213

samlaf opened this issue May 3, 2022 · 7 comments
Labels
bug Something isn't working

Comments

@samlaf
Copy link

samlaf commented May 3, 2022

Version

ethers-addressbook v0.1.0 (/home/samlaf/devel/ethereum/ethers-rs/ethers-addressbook)
├── ethers-core v0.6.0 (/home/samlaf/devel/ethereum/ethers-rs/ethers-core)
ethers-contract v0.6.0 (/home/samlaf/devel/ethereum/ethers-rs/ethers-contract)
├── ethers-contract-abigen v0.6.0 (/home/samlaf/devel/ethereum/ethers-rs/ethers-contract/ethers-contract-abigen)
│   ├── ethers-core v0.6.0 (/home/samlaf/devel/ethereum/ethers-rs/ethers-core) (*)
├── ethers-contract-derive v0.6.0 (proc-macro) (/home/samlaf/devel/ethereum/ethers-rs/ethers-contract/ethers-contract-derive)
│   ├── ethers-contract-abigen v0.6.0 (/home/samlaf/devel/ethereum/ethers-rs/ethers-contract/ethers-contract-abigen) (*)
│   ├── ethers-core v0.6.0 (/home/samlaf/devel/ethereum/ethers-rs/ethers-core) (*)
├── ethers-core v0.6.0 (/home/samlaf/devel/ethereum/ethers-rs/ethers-core) (*)
├── ethers-derive-eip712 v0.2.0 (proc-macro) (/home/samlaf/devel/ethereum/ethers-rs/ethers-core/ethers-derive-eip712)
│   ├── ethers-core v0.6.0 (/home/samlaf/devel/ethereum/ethers-rs/ethers-core) (*)
├── ethers-providers v0.6.0 (/home/samlaf/devel/ethereum/ethers-rs/ethers-providers)
│   ├── ethers-core v0.6.0 (/home/samlaf/devel/ethereum/ethers-rs/ethers-core) (*)
├── ethers-contract-abigen v0.6.0 (/home/samlaf/devel/ethereum/ethers-rs/ethers-contract/ethers-contract-abigen) (*)
├── ethers-contract-derive v0.6.0 (proc-macro) (/home/samlaf/devel/ethereum/ethers-rs/ethers-contract/ethers-contract-derive) (*)
├── ethers-core v0.6.0 (/home/samlaf/devel/ethereum/ethers-rs/ethers-core) (*)
├── ethers-derive-eip712 v0.2.0 (proc-macro) (/home/samlaf/devel/ethereum/ethers-rs/ethers-core/ethers-derive-eip712) (*)
├── ethers-middleware v0.6.0 (/home/samlaf/devel/ethereum/ethers-rs/ethers-middleware)
│   ├── ethers-contract v0.6.0 (/home/samlaf/devel/ethereum/ethers-rs/ethers-contract) (*)
│   ├── ethers-core v0.6.0 (/home/samlaf/devel/ethereum/ethers-rs/ethers-core) (*)
│   ├── ethers-etherscan v0.2.0 (/home/samlaf/devel/ethereum/ethers-rs/ethers-etherscan)
│   │   ├── ethers-core v0.6.0 (/home/samlaf/devel/ethereum/ethers-rs/ethers-core) (*)
│   │   ├── ethers-solc v0.3.0 (/home/samlaf/devel/ethereum/ethers-rs/ethers-solc)
│   │   │   ├── ethers-core v0.6.0 (/home/samlaf/devel/ethereum/ethers-rs/ethers-core) (*)
│   ├── ethers-providers v0.6.0 (/home/samlaf/devel/ethereum/ethers-rs/ethers-providers) (*)
│   ├── ethers-signers v0.6.0 (/home/samlaf/devel/ethereum/ethers-rs/ethers-signers)
│   │   ├── ethers-core v0.6.0 (/home/samlaf/devel/ethereum/ethers-rs/ethers-core) (*)
│   │   ├── ethers-contract v0.6.0 (/home/samlaf/devel/ethereum/ethers-rs/ethers-contract) (*)
│   │   ├── ethers-derive-eip712 v0.2.0 (proc-macro) (/home/samlaf/devel/ethereum/ethers-rs/ethers-core/ethers-derive-eip712) (*)
│   ├── ethers-providers v0.6.0 (/home/samlaf/devel/ethereum/ethers-rs/ethers-providers) (*)
│   ├── ethers-solc v0.3.0 (/home/samlaf/devel/ethereum/ethers-rs/ethers-solc) (*)
├── ethers-providers v0.6.0 (/home/samlaf/devel/ethereum/ethers-rs/ethers-providers) (*)
├── ethers-signers v0.6.0 (/home/samlaf/devel/ethereum/ethers-rs/ethers-signers) (*)
├── ethers-solc v0.3.0 (/home/samlaf/devel/ethereum/ethers-rs/ethers-solc) (*)
ethers-core v0.6.0 (/home/samlaf/devel/ethereum/ethers-rs/ethers-core) (*)
ethers-etherscan v0.2.0 (/home/samlaf/devel/ethereum/ethers-rs/ethers-etherscan) (*)
ethers-middleware v0.6.0 (/home/samlaf/devel/ethereum/ethers-rs/ethers-middleware) (*)
ethers-providers v0.6.0 (/home/samlaf/devel/ethereum/ethers-rs/ethers-providers) (*)
ethers-signers v0.6.0 (/home/samlaf/devel/ethereum/ethers-rs/ethers-signers) (*)
ethers-solc v0.3.0 (/home/samlaf/devel/ethereum/ethers-rs/ethers-solc) (*)

Platform
Linux samlaf-msi 5.13.0-40-generic #45~20.04.1-Ubuntu SMP Mon Apr 4 09:38:31 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

Description

When running the abigen.rs example, I get this error

> RUST_BACKTRACE=1 cargo run -p ethers --example abigen 
    Finished dev [unoptimized + debuginfo] target(s) in 0.11s
     Running `target/debug/examples/abigen`
Generating bindings for examples/contract.sol

thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', examples/abigen.rs:15:60
stack backtrace:
   0: rust_begin_unwind
             at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/panicking.rs:584:5
   1: core::panicking::panic_fmt
             at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/core/src/panicking.rs:143:14
   2: core::panicking::panic
             at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/core/src/panicking.rs:48:5
   3: core::option::Option<T>::unwrap
             at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/core/src/option.rs:752:21
   4: abigen::main
             at ./examples/abigen.rs:15:19
   5: core::ops::function::FnOnce::call_once
             at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/core/src/ops/function.rs:227:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

I printed contracts (let contracts = Solc::default().compile_source(&contract)?;) and it says

CompilerOutput { errors: [Error { source_location: None, secondary_source_locations: [], type: "JSONError", component: "general", severity: Error, error_code: None, message: "Invalid EVM version requested.", formatted_message: Some("Invalid EVM version requested.") }], sources: {}, contracts: {} }

Any idea as to what is happening here?

@samlaf samlaf added the bug Something isn't working label May 3, 2022
@anajuliabit
Copy link

same issue here, any updates @samlaf ?

@mattsse
Copy link
Collaborator

mattsse commented Oct 23, 2022

this example uses the default solc binary, which is solc or SOLC_PATH env var:

fn default() -> Self {
if let Ok(solc) = std::env::var("SOLC_PATH") {
return Solc::new(solc)
}
#[cfg(not(target_arch = "wasm32"))]
{
if let Some(solc) = Solc::svm_global_version()
.and_then(|vers| Solc::find_svm_installed_version(&vers.to_string()).ok())
.flatten()
{
return solc
}
}
Solc::new(SOLC)

could you retry after setting solc path?

btw you can easily manage installs with svm-rs

feel free to open a PR to add some notes here as well.

@dbelv
Copy link
Contributor

dbelv commented Nov 19, 2022

so testing this, without solc (and no env set) I get:

Generating bindings for examples/contract.sol

Error: "solc": No such file or directory (os error 2)

Location:
    examples/abigen.rs:14:25

With fake env vars, similiar results (not the same error above, but still an error). Moving to svm-rs over my install (just installed release like CI) I get:

Generating bindings for examples/contract.sol

thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', examples/abigen.rs:15:60
stack backtrace:
   0: rust_begin_unwind
             at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/panicking.rs:584:5
   1: core::panicking::panic_fmt
             at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/core/src/panicking.rs:142:14
   2: core::panicking::panic
             at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/core/src/panicking.rs:48:5
   3: core::option::Option<T>::unwrap
             at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/core/src/option.rs:775:21
   4: abigen::main
             at ./examples/abigen.rs:15:19
   5: core::ops::function::FnOnce::call_once
             at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/core/src/ops/function.rs:248:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

My setup now has solc at "~/bin/solc" and "~/.cargo/bin/solc".
When forcing "~/bin/solc" to be at the front of the PATH cargo still selects the one under .cargo and fails.
When using SOLC_PATH=~/bin/solc RUST_BACKTRACE=1 cargo run -p ethers --example abigen --features="ethers-solc" it works.
When using SOLC_PATH=~/.cargo/bin/solc RUST_BACKTRACE=1 cargo run -p ethers --example abigen --features="ethers-solc" it fails.

Might be an issue with svm-rs installs (paths/libs?) or having another on the PATH. Will continue to dig.

@dbelv
Copy link
Contributor

dbelv commented Nov 19, 2022

Recommendation would be to install solc as the CI pipeline does:

mkdir -p "$HOME/bin"
wget -q https://github.com/ethereum/solidity/releases/download/v0.8.10/solc-static-linux -O $HOME/bin/solc
chmod u+x "$HOME/bin/solc"

and in your .bashrc (or whatever shell you are using) add:

export PATH=$PATH:$HOME/bin/solc
export SOLC_PATH=$HOME/bin/solc

Which will make ethers-rs use the independent compiled version. But I do believe this is an issue with svm-rs installs and not ether-rs.

Edit was a fool and forgot to switch solc versions. I believe this is actually an issue with the version of solc installed.

@dbelv
Copy link
Contributor

dbelv commented Nov 19, 2022

@samlaf @anajuliabit Minimum solc version is 0.8.10, can you please install atleast that version (or higher) and re-run (you should no longer get the error above).

@dbelv
Copy link
Contributor

dbelv commented Jan 4, 2023

@mattsse @gakonst Given the error was able to be re-produced with the suspected solc path issue (#1213 (comment)) and no follow up from OP/interested parties I think we are right to close this issue.

@gakonst
Copy link
Owner

gakonst commented Jan 4, 2023

Right. Seems like this should work with right Solc.

@gakonst gakonst closed this as not planned Won't fix, can't repro, duplicate, stale Jan 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants