risc0 / risc0-foundry-template

Template for integrating RISC Zero and Ethereum using Foundry and Bonsai
https://risczero.com
84 stars 46 forks source link

Pre-build `forge ffi` within the build script #85

Closed capossele closed 2 months ago

capossele commented 4 months ago

With this addition, running cargo build from the root folder results in also building the forge ffi cli of the risc0-ethereum crate.

Solves #83

nategraf commented 4 months ago

Would it be possible to instead declare the ffi CLI a a dev dependency of risc0-ethereum-contracts, or possibly of the template workspace? I think this would be a cleaner way to achieve the same results, unless it doesn't work for some reason.

capossele commented 4 months ago

Would it be possible to instead declare the ffi CLI a a dev dependency of risc0-ethereum-contracts, or possibly of the template workspace? I think this would be a cleaner way to achieve the same results, unless it doesn't work for some reason.

Yeah I've tried a couple of different approaches similar to what you have suggested but they were all unsuccessful mainly because cargo does not really like working with two different virtual workspaces

nategraf commented 4 months ago

Hmmmm... maybe we can address this issue, and the issue with the location of Elf.sol and ImageID.sol by adding a Forge remapping as part of build.rs to point into the correct folder in the target directory, where the source code for both risc0-ethereum-contracts and risc0-forge-ffi will be cloned. If this works, it could also potentially allow us to drop risc0-ethereum-contracts as a submodule. It's a bit speculative, but I think worth trying.

capossele commented 2 months ago

Closing for now, I'll reopen once https://github.com/risc0/risc0-ethereum/pull/120 gets merged