Skip to content

feature: Migrate Raiko functionality to this repository #5

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

Open
wants to merge 10 commits into
base: development/merge-raiko
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
641 changes: 641 additions & 0 deletions benchmarks/raiko-risc0-builder/Cargo.lock

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions benchmarks/raiko-risc0-builder/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[package]
name = "raiko-risc0-builder"
version = "0.1.0"
edition = "2021"

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

[dependencies]
raiko-pipeline = { git = "https://github.com/NethermindEth/raiko-proof-aggregation", branch = "zkvm-benchmarks-surge", features = ["risc0"] }

# Override a transitive dependency because latest isn't compatible with outdated risc0 rust version
bytemuck_derive = { version = "=1.6.0" }

[features]
test = []
bench = []
82 changes: 82 additions & 0 deletions benchmarks/raiko-risc0-builder/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
use raiko_pipeline::{
parse_metadata, rerun_if_changed, CommandBuilder, GuestMetadata, Metadata, Pipeline,
};
use std::path::PathBuf;

fn main() {
let pipeline = Risc0Pipeline::new("benchmarks/raiko-risc0", "release");
pipeline.bins(&["raiko-risc0"], "benchmarks/raiko-risc0/elf");
}

pub struct Risc0Pipeline {
pub meta: Metadata,
pub profile: String,
}

impl Pipeline for Risc0Pipeline {
fn new(root: &str, profile: &str) -> Self {
raiko_pipeline::ROOT_DIR.get_or_init(|| PathBuf::from(root));
Risc0Pipeline {
meta: parse_metadata(root),
profile: profile.to_string(),
}
}

fn builder(&self) -> CommandBuilder {
let mut builder = CommandBuilder::new(&self.meta, "riscv32im-risc0-zkvm-elf", "risc0")
.rust_flags(&[
"passes=lower-atomic",
"link-arg=-Ttext=0x00200800",
"panic=abort",
])
.cc_compiler("gcc".into())
.c_flags(&[
"/opt/riscv/bin/riscv32-unknown-elf-gcc",
"-march=rv32im",
"-mstrict-align",
"-falign-functions=2",
])
.custom_args(&["--ignore-rust-version"]);
// Cannot use /.rustup/toolchains/risc0/bin/cargo, use regular cargo
builder.unset_cargo();
builder
}

fn bins(&self, names: &[&str], dest: &str) {
rerun_if_changed(&[]);
let bins = self.meta.get_bins(names);
let builder = self.builder();
let executor = builder.build_command(&self.profile, &bins);
println!(
"executor: \n ${:?}\ntargets: \n {:?}",
executor.cmd, executor.artifacts
);
if executor.artifacts.is_empty() {
panic!("No artifacts to build");
}
executor
.execute()
.expect("Execution failed")
.risc0_placement(dest)
.expect("Failed to export Risc0 artifacts");
}

fn tests(&self, names: &[&str], dest: &str) {
rerun_if_changed(&[]);
let tests = self.meta.get_tests(names);
let builder = self.builder();
let executor = builder.test_command(&self.profile, &tests);
println!(
"executor: \n ${:?}\ntargets: \n {:?}",
executor.cmd, executor.artifacts
);
if executor.artifacts.is_empty() {
panic!("No artifacts to build");
}
executor
.execute()
.expect("Execution failed")
.risc0_placement(dest)
.expect("Failed to export Risc0 artifacts");
}
}
Loading