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
Add cargo risczero benchmark
command
#1302
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
This also adds a check to ensure that the downloaded ELF binary has the proper sha256.
risc0/cargo-risczero/Cargo.toml
Outdated
@@ -33,13 +33,17 @@ reqwest-middleware = "0.2" | |||
reqwest-retry = "0.3" | |||
risc0-build = { workspace = true } | |||
risc0-r0vm = { workspace = true, optional = true } | |||
risc0-zkvm = { workspace = true, optional = true } | |||
risc0-zkvm = { workspace = true, default-features = false, features = ["std", "getrandom"] } | |||
risc0-zkvm-methods = { workspace = true, default-features = false } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be dropped, it can't be published
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes!
I was thinking in moving the dependencies we have on risc0-zkvm-methods
to a new crate risc0-zkvm-methods-core
that we could publish, this way we would solve the issue. That way both risc0-zkvm-methods
and cargo-risczero
could depend on risc0-zkvm-methods-core
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think any of the benchmark binaries need any 'core' crates because the interface is very simple. We pass in the number of iterations to run, so there's no types that need to be shared between host and guest.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see... I followed this approach because this would be similar to what we do under /examples
having a core
that can be used both in guest
and host
.
I did the change before seeing this comment. Please let me know if you'd like to revert the new risc0-zkvm-methods-core
and I'll change it 🙇♂️
cargo risczero benchmark
commandcargo risczero benchmark
command
Move code from `risc0-zkvm-methods` to the new crate
This reverts commit 6baaca7.
Also remove all code responsible to download a elf binary from GitHub, replacing it with an `include_bites!` for the elf binary previously generated by xtask.
@flaub , I tried to copy your logic from I have one question on how we ensure that the file generated by Would you have some direction on that? Also, the whole logic for doing the |
mod benchmark { | ||
pub fn build_benchmark_elf(path: &str) { | ||
let benchmark_elf = std::env::current_dir().unwrap().join(path); | ||
if let Ok(content) = std::fs::read(&benchmark_elf) { | ||
std::fs::write(&benchmark_elf, content).unwrap(); | ||
} else { | ||
build_elf(benchmark_elf.to_str().unwrap()); | ||
} | ||
} | ||
|
||
fn build_elf(path: &str) { | ||
let is_success = std::process::Command::new("cargo") | ||
.args(["xtask", "gen-benchmark", "--path", path]) | ||
.status() | ||
.unwrap() | ||
.success(); | ||
assert!(is_success); | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I might have found a way to compile it automatically during build time! 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Giving credit where credit is due, I found it already in our code base :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me - I think it would be good for @flaub to review and approve before merging
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I'll take a pass at this at some point to get it landed
Closes #1301