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

[BUG] Building the entire workspace fails (missing req.) #1406

Closed
nuke-web3 opened this issue Feb 1, 2024 · 13 comments · Fixed by #1525
Closed

[BUG] Building the entire workspace fails (missing req.) #1406

nuke-web3 opened this issue Feb 1, 2024 · 13 comments · Fixed by #1525
Assignees
Labels
bug Something isn't working

Comments

@nuke-web3
Copy link
Member

nuke-web3 commented Feb 1, 2024

When checking out a rust project, one of the first things I do is clone & try and build everything. This yields an issue:

 Compiling bonsai-ethereum-contracts v0.6.1 (/home/nuke/git/risc0/bonsai/ethereum)
error: failed to run custom build command for `bonsai-ethereum-contracts v0.6.1 (/risc0/bonsai/ethereum)`

Caused by:
  process didn't exit successfully: `/risc0/target/release/build/bonsai-ethereum-contracts-dada181967ce2843/build-script-build` (exit status: 1)
  --- stderr
  Error: failed to start `forge build`

Steps to Reproduce

  1. git checkout v0.20.1
  2. cargo b -r

Your Environment

  • risc0-zkvm version: v0.20.1
  • Rust version: (rust-toolchain.toml set) 1.73-x86_64-unknown-linux-gnu
  • Platform/OS: PoP!_OS (ubuntu derivative)

Additional context

I may be missing something in my env. or dependencies, I have not explicitly set anything and have not looked deeper for what could be the issue yet. I would hope this requirement would be listed in the top README of the project to build it.

@nuke-web3 nuke-web3 added the bug Something isn't working label Feb 1, 2024
@nuke-web3 nuke-web3 changed the title [BUG] [BUG] cannot build v0.20.1 Feb 1, 2024
@nuke-web3
Copy link
Member Author

nuke-web3 commented Feb 1, 2024

https://book.getfoundry.sh/getting-started/installation is required. I don't see that listed in the top level README or https://dev.risczero.com/api/zkvm/quickstart and as it's specific to those working with Ethereum (not exclusively RISC Zero) I would hope things needing it could be behind a feature flag.

After install forge I get to:

   Compiling risc0-build-kernel v0.20.1 (/risc0/risc0/build_kernel)
error: failed to run custom build command for `fibonacci-methods v0.1.0 (/home/nuke/git/risc0/examples/profiling/methods)`

Caused by:
 process didn't exit successfully: `/risc0/target/release/build/fibonacci-methods-af14d1a24f6f9d54/build-script-build` (exit status: 255)
...........
error: failed to run custom build command for `risc0-zkvm-methods v0.20.1 (/home/nuke/git/risc0/risc0/zkvm/methods)`

Caused by:
  process didn't exit successfully: `/home/nuke/git/risc0/target/release/build/risc0-zkvm-methods-ba6a2f6cbce69e67/build-script-build` (exit status: 255)
  --- stderr
  The 'risc0' toolchain could not be found.
  To install the risc0 toolchain, use cargo-risczero.
  For example:
    cargo binstall cargo-risczero
    cargo risczero install

I understand I need the toolchain installed before being able to build here, but my goal is to build the whole workspace, including the toolchain itself.

With cargo install --path risc0/cargo-risczero/ && cargo risczero install I see that process downloads&installs a specific rust toolchain from github.

I would like a way to have install the tool and required rust toolchain from the repo I have locally. I suppose it's not a big deal to binstall and use that to install the required toolchain though. 🤔

@nuke-web3 nuke-web3 changed the title [BUG] cannot build v0.20.1 [BUG] Building the entire workspace fails (missing req.) Feb 1, 2024
@weikengchen
Copy link
Contributor

I think the readme is not comprehensive enough. But the recommended way so far for the majority of the users is to use binstall since dependencies can be tricky.

@ivolkg
Copy link

ivolkg commented Feb 11, 2024

I have a similar problem here with the toolchain install with binstall

To reproduce

rustup override set nightly
cargo install cargo-binstall
cargo binstall cargo-risczero
cargo risczero install
cargo risczero new _project_
cargo run --release

Enviromnment:

rustup --version
rustup 1.26.0 (2023-11-14)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.78.0-nightly (d44e3b95c 2024-02-09)`
cargo risczero --version
cargo-risczero 0.20.1
System: Archlinux

Behaviour:

... a lot of errors regarding unresolved imports
error: failed to run custom build command for `methods v0.1.0 (/home/isaac/Work/Nethermind/StarkPack/composition/methods)`

Caused by:
  process didn't exit successfully: `$HOME/composition/target/release/build/methods-0af1f24dcc06b353/build-script-build` (exit status: 101)
  --- stdout
  Building guest package methods.composition
  cargo:rerun-if-env-changed=RISC0_SKIP_BUILD
  Using rustc: /home/isaac/.rustup/toolchains/risc0/bin/rustc
  cargo:rerun-if-env-changed=RISC0_RUST_SRC
  Building guest package: cargo build --target riscv32im-risc0-zkvm-elf
  cargo:rerun-if-env-changed=RISC0_BUILD_DEBUG
warning: build failed, waiting for other jobs to finish...

Expected behavior:

Successful proof verification

@weikengchen
Copy link
Contributor

weikengchen commented Feb 12, 2024

Is there a way to provide the error message about unresolved dependencies? Because the rest of the error is more or less generic and doesn't narrow down where the issue comes from.

@ivolkg
Copy link

ivolkg commented Feb 12, 2024

The error message is rather long here are some examples(Note that the build elf is named composition but there is nothing there except the place holder circuit when creating a new project):

composition: error[E0432]: unresolved imports `risc0_circuit_recursion`, `crate::Assumptions`, `crate::ExitCode`, `crate::MaybePruned`, `crate::Output`, `crate::ReceiptClaim`, `crate::ReceiptClaim`, `crate::Assumptions`, `crate::ExitCode`, `crate::InvalidExitCodeError`, `crate::MaybePruned`, `crate::Output`, `crate::PrunedValueError`, `crate::ReceiptClaim`
composition:   --> $HOME/.cargo/registry/src/index.crates.io-6f17d22bba15001f/risc0-zkvm-0.20.1/src/host/receipt.rs:45:5
composition:    |
composition: 45 |     Assumptions, ExitCode, MaybePruned, Output, ReceiptClaim,
composition:    |     ^^^^^^^^^^^  ^^^^^^^^  ^^^^^^^^^^^  ^^^^^^  ^^^^^^^^^^^^
composition:    |
composition:   ::: $HOME/.cargo/registry/src/index.crates.io-6f17d22bba15001f/risc0-zkvm-0.20.1/src/host/recursion/receipt.rs:18:5
composition: error[E0152]: found duplicate lang item `panic_impl`
composition:    --> $HOME/.cargo/registry/src/index.crates.io-6f17d22bba15001f/risc0-zkvm-0.20.1/src/guest/mod.rs:208:1
composition:     |
composition: 208 | fn panic_impl(panic_info: &core::panic::PanicInfo) -> ! {
composition:     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
composition:     |
composition:     = note: the lang item is first defined in crate `std`.
composition:     = note: first definition in `std` loaded from $HOME/.local/share/cargo-risczero/toolchains/x86_64-unknown-linux-gnu_v2024-01-31.1/rust/lib/rustlib/riscv32im-risc0-zkvm-elf/lib/libstd-80f9e71abd889073.rlib
composition: error[E0433]: failed to resolve: use of undeclared crate or module `risc0_circuit_recursion`
composition:   --> $HOME/.cargo/registry/src/index.crates.io-6f17d22bba15001f/risc0-zkvm-0.20.1/src/host/recursion/mod.rs:35:55
composition:    |
composition: 35 | const CIRCUIT: risc0_circuit_recursion::CircuitImpl = risc0_circuit_recursion::CircuitImpl::new();
composition:    |                                                       ^^^^^^^^^^^^^^^^^^^^^^^ use of undeclared crate or module `risc0_circuit_recursion`

More of the unresolved items are related to"

  • risc0_zkp::verify
  • risc0_circuit_recursion
  • self::receipt_claim
  • ark_bn254
  • num_bigint
  • use of undeclared crate or module tracing
  • etc

Basically all artworks and risc0 modules are failing to compile.
My guess is that there is some mismatch between which version is suppose to be access. All Cargo.toml versions are set to 0.20.1, for al olther versions like before September in the main branch the compilation is fine. But for version 0.19 is failing to run examples(within each directory if running in the examples directory it runs the ecdsa example) with errors like:

error: unused import: `valid_control_ids`
  --> .../risc0/zkvm/src/host/recursion/mod.rs:31:25
31 | pub use self::receipt::{valid_control_ids, SuccinctReceipt};
error: mutable reference of mutable static is discouraged
  --> .../risc0/zkvm/src/guest/env.rs:44:35
44 |     unsafe { getrandom::getrandom(&mut MEMORY_IMAGE_ENTROPY).unwrap() };
   |                                   ^^^^^^^^^^^^^^^^^^^^^^^^^ mutable reference of mutable static
help: mutable references are dangerous since if there's any other pointer or reference used for that static while the reference lives, that's UB; use `addr_of_mut!` instead to create a raw pointer
   |
44 |     unsafe { getrandom::getrandom(addr_of_mut!(MEMORY_IMAGE_ENTROPY)).unwrap() };
   |                                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

error: mutable reference of mutable static is discouraged
  --> .../risc0/zkvm/src/guest/env.rs:49:38
   |
49 |         let hasher = core::mem::take(&mut HASHER);
   |                                      ^^^^^^^^^^^ mutable reference of mutable static
help: mutable references are dangerous since if there's any other pointer or reference used for that static while the reference lives, that's UB; use `addr_of_mut!` instead to create a raw pointer
49 |         let hasher = core::mem::take(addr_of_mut!(HASHER));
   |                                      ~~~~~~~~~~~~~~~~~~~~                          ~~~~~~~~~~~~~~~~~~~~

for version 0.19

What I want is to try out the composition feature but it is not working out of the box and AFAIU there is not accesability in older versions

@weikengchen
Copy link
Contributor

So it looks the following:

if you are using the version in the master branch, including the examples, you will also need to use the 0.20 version of cargo-risczero.

To do that, after you pull the repo and the git lfs, run:

cargo install --path risc0/cargo-risczero

This would install the corresponding version of the cargo risczero as well as r0vm which is the execution environment.

@ivolkg
Copy link

ivolkg commented Feb 12, 2024

Ok so doing that it still produces an error when running withing the composition example:

error[E0635]: unknown feature `stdsimd`
  --> $HOME/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ahash-0.8.6/src/lib.rs:99:42
   |
99 | #![cfg_attr(feature = "stdsimd", feature(stdsimd))]
   |                                          ^^^^^^^

For more information about this error, try `rustc --explain E0635`.

in the Cargo.toml risc0-zkvm is set to default-features = false so I don't understand why is trying to access the stdsimd feature.

Regarding the first issue when creating a project outside the repo this toolchain(0.21.0-alpha.1) as well as 0.20.1, 0.20 and 0.19.1
Produces the same error of unresolved imports

Thanks for the help btw

@weikengchen
Copy link
Contributor

There is a related issue or PR. Let me find it. The solution is to force a lower version of ahash.

@weikengchen
Copy link
Contributor

Ok I could not find it. But the idea is to specify a dependency for ahash and use version = "=x.xx.xx" to force a previous version.

@weikengchen
Copy link
Contributor

weikengchen commented Feb 12, 2024

image

The idea is that the current rust toolchain for the risc-zero vm is still before 1.72 but the 0.8.8 version asks for 1.72. Downgrading it to 0.8.7 avoids this situation.

This is a temporary issue that would be resolved after a planned change to up the version of the risc zero rust toolchain.

At this moment, the solution is basically to lower ahash.

@weikengchen
Copy link
Contributor

weikengchen commented Feb 12, 2024

Regarding to your original question, the error message is that the compiler complaining that the code uses a compiler feature that it doesn't know, rather than the user specifying a specific crate feature.

@ivolkg
Copy link

ivolkg commented Feb 12, 2024

Thanks that did solve the problem

@nategraf
Copy link
Contributor

nategraf commented Mar 6, 2024

We are moving the contracts currently in bonsai/contracts into the https://github.com/risc0/risc0-ethereum repository, and this issue should be resolved when we do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants