diff --git a/Cargo.lock b/Cargo.lock index 89ebd6a97..28d1b6d67 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3965,7 +3965,6 @@ dependencies = [ "openvm-stark-backend", "openvm-stark-sdk", "rand", - "rayon", "serde", "serde-big-array", "serde_with", @@ -3980,17 +3979,13 @@ name = "openvm-native-compiler" version = "0.2.0-alpha" dependencies = [ "backtrace", - "cfg-if", "hex", "itertools 0.13.0", "lazy_static", "metrics", "num-bigint 0.4.6", - "num-bigint-dig", "num-integer", - "num-traits", "openvm-circuit", - "openvm-circuit-primitives", "openvm-instructions", "openvm-instructions-derive", "openvm-native-circuit", @@ -4003,13 +3998,11 @@ dependencies = [ "p3-symmetric", "rand", "serde", - "serde_json", "snark-verifier-sdk", "strum", "strum_macros", "test-case", "test-log", - "tracing", "zkhash", ] @@ -4032,58 +4025,28 @@ dependencies = [ "openvm-instructions", "openvm-native-compiler", "openvm-native-transpiler", - "openvm-stark-backend", "p3-baby-bear", "p3-field", "proc-macro2", "quote", "strum", "strum_macros", - "syn 2.0.95", ] [[package]] -name = "openvm-native-integration-test" +name = "openvm-native-integration-tests" version = "0.2.0-alpha" dependencies = [ - "bincode 2.0.0-rc.3", - "clap", - "criterion", - "derive-new", - "derive_more 1.0.0", "eyre", - "hex", - "k256", - "metrics", - "num-bigint-dig", - "openvm-algebra-circuit", - "openvm-algebra-transpiler", - "openvm-benchmarks", "openvm-build", "openvm-circuit", - "openvm-circuit-primitives-derive", - "openvm-ecc-circuit", - "openvm-ecc-transpiler", - "openvm-keccak256-circuit", - "openvm-keccak256-guest", - "openvm-keccak256-transpiler", "openvm-native-circuit", - "openvm-native-compiler", - "openvm-native-recursion", "openvm-native-transpiler", - "openvm-rv32im-circuit", "openvm-rv32im-transpiler", "openvm-sdk", - "openvm-stark-backend", - "openvm-stark-sdk", + "openvm-toolchain-tests", "openvm-transpiler", - "pprof", - "rand_chacha", - "serde", - "tempfile", - "tiny-keccak", - "tokio", - "tracing", + "p3-baby-bear", ] [[package]] @@ -4118,22 +4081,9 @@ dependencies = [ name = "openvm-native-transpiler" version = "0.2.0-alpha" dependencies = [ - "derive-new", - "derive_more 1.0.0", - "openvm-circuit", - "openvm-circuit-derive", - "openvm-circuit-primitives-derive", "openvm-instructions", - "openvm-native-circuit", - "openvm-native-compiler", - "openvm-rv32im-circuit", - "openvm-stark-backend", "openvm-transpiler", - "p3-baby-bear", "p3-field", - "serde", - "strum", - "strum_macros", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index d77ae0ca7..746b574a5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,7 +37,7 @@ members = [ "extensions/native/recursion", "extensions/native/transpiler", "extensions/native/guest-macro", - "extensions/native/guest-macro/test", + "extensions/native/tests", "extensions/algebra/circuit", "extensions/algebra/transpiler", "extensions/algebra/guest", diff --git a/crates/toolchain/build/src/lib.rs b/crates/toolchain/build/src/lib.rs index adaf5d5b9..f84a379b4 100644 --- a/crates/toolchain/build/src/lib.rs +++ b/crates/toolchain/build/src/lib.rs @@ -34,7 +34,12 @@ pub fn get_package(manifest_dir: impl AsRef) -> Package { .manifest_path(&manifest_path) .no_deps() .exec() - .expect("cargo metadata command failed"); + .unwrap_or_else(|e| { + panic!( + "cargo metadata command failed for manifest path: {}: {e:?}", + manifest_path.display() + ) + }); let mut matching: Vec = manifest_meta .packages .into_iter() diff --git a/extensions/native/circuit/Cargo.toml b/extensions/native/circuit/Cargo.toml index 8fe5e29ad..d4564c486 100644 --- a/extensions/native/circuit/Cargo.toml +++ b/extensions/native/circuit/Cargo.toml @@ -29,7 +29,6 @@ eyre.workspace = true serde.workspace = true serde-big-array.workspace = true serde_with.workspace = true -rayon.workspace = true [dev-dependencies] openvm-stark-sdk = { workspace = true } diff --git a/extensions/native/compiler/Cargo.toml b/extensions/native/compiler/Cargo.toml index 569e36cf9..173830b76 100644 --- a/extensions/native/compiler/Cargo.toml +++ b/extensions/native/compiler/Cargo.toml @@ -16,25 +16,19 @@ openvm-stark-backend = { workspace = true } openvm-native-compiler-derive = { workspace = true } openvm-instructions = { workspace = true } openvm-instructions-derive = { workspace = true } -openvm-circuit-primitives = { workspace = true } openvm-stark-sdk = { workspace = true } openvm-circuit = { workspace = true } openvm-rv32im-transpiler = { workspace = true } # disable jemalloc to be compatible with stark-backend snark-verifier-sdk = { workspace = true, optional = true } -tracing.workspace = true itertools.workspace = true serde.workspace = true -serde_json.workspace = true backtrace = { workspace = true, features = ["serde"] } strum_macros = "0.26.4" -num-bigint-dig.workspace = true num-bigint.workspace = true num-integer.workspace = true -num-traits.workspace = true metrics = { workspace = true, optional = true } -cfg-if = { workspace = true } strum = { workspace = true } [dev-dependencies] diff --git a/extensions/native/guest-macro/Cargo.toml b/extensions/native/guest-macro/Cargo.toml index 2880c456e..090e4122a 100644 --- a/extensions/native/guest-macro/Cargo.toml +++ b/extensions/native/guest-macro/Cargo.toml @@ -10,7 +10,6 @@ repository.workspace = true proc-macro = true [dependencies] -syn = { version = "2.0", features = ["parsing"] } quote = "1.0" proc-macro2 = "1.0" openvm-instructions = { workspace = true } @@ -18,7 +17,6 @@ openvm-native-compiler = { workspace = true } openvm-native-transpiler = { workspace = true } p3-field = { workspace = true } p3-baby-bear = { workspace = true } -openvm-stark-backend = { workspace = true } [dev-dependencies] strum.workspace = true diff --git a/extensions/native/guest-macro/test/Cargo.toml b/extensions/native/guest-macro/test/Cargo.toml deleted file mode 100644 index c33767c8c..000000000 --- a/extensions/native/guest-macro/test/Cargo.toml +++ /dev/null @@ -1,69 +0,0 @@ -[package] -name = "openvm-native-integration-test" -version.workspace = true -authors.workspace = true -edition.workspace = true -homepage.workspace = true -repository.workspace = true -license.workspace = true - -[dependencies] -openvm-build.workspace = true -openvm-circuit.workspace = true -openvm-circuit-primitives-derive.workspace = true -openvm-sdk.workspace = true -openvm-stark-backend.workspace = true -openvm-stark-sdk.workspace = true -openvm-transpiler.workspace = true -openvm-native-transpiler.workspace = true - -openvm-algebra-circuit.workspace = true -openvm-algebra-transpiler.workspace = true -openvm-ecc-circuit.workspace = true -openvm-ecc-transpiler.workspace = true -openvm-keccak256-circuit.workspace = true -openvm-keccak256-transpiler.workspace = true -openvm-keccak256-guest.workspace = true -openvm-native-circuit.workspace = true -openvm-native-compiler.workspace = true -openvm-native-recursion = { workspace = true, features = ["test-utils"] } -openvm-rv32im-circuit.workspace = true -openvm-rv32im-transpiler.workspace = true - -openvm-benchmarks = { path = "../../../../benchmarks" } - -clap = { version = "4.5.9", features = ["derive", "env"] } -eyre.workspace = true -tempfile.workspace = true -metrics.workspace = true -tracing.workspace = true -hex.workspace = true -tokio = { version = "1.41.1", features = ["rt", "rt-multi-thread", "macros"] } -rand_chacha = { version = "0.3", default-features = false } -k256 = { workspace = true, features = ["ecdsa"] } -tiny-keccak.workspace = true -derive-new.workspace = true -derive_more = { workspace = true, features = ["from"] } -num-bigint-dig = { workspace = true, features = ["std", "serde"] } -serde.workspace = true -bincode = { version = "2.0.0-rc.3" } - -[dev-dependencies] -criterion = { version = "0.5", features = ["html_reports"] } -pprof = { version = "0.13", features = [ - "criterion", - "flamegraph", - "frame-pointer", -] } - -[features] -default = ["parallel", "mimalloc", "bench-metrics"] -bench-metrics = ["openvm-native-recursion/bench-metrics"] -profiling = ["openvm-sdk/profiling"] -aggregation = [] -static-verifier = ["openvm-native-recursion/static-verifier"] -parallel = ["openvm-native-recursion/parallel"] -mimalloc = ["openvm-circuit/mimalloc"] -jemalloc = ["openvm-circuit/jemalloc"] -jemalloc-prof = ["openvm-circuit/jemalloc-prof"] -nightly-features = ["openvm-circuit/nightly-features"] \ No newline at end of file diff --git a/extensions/native/guest-macro/test/program/Cargo.toml b/extensions/native/guest-macro/test/program/Cargo.toml deleted file mode 100644 index 14f4a9319..000000000 --- a/extensions/native/guest-macro/test/program/Cargo.toml +++ /dev/null @@ -1,20 +0,0 @@ -[workspace] -[package] -name = "openvm-native-integration-test-program" -version = "0.0.0" -edition = "2021" - -[dependencies] -openvm = { path = "../../../../../crates/toolchain/openvm" } -openvm-native-guest-macro = { path = "../..", default-features = false } - -[features] -default = [] -std = ["openvm/std"] - -[build-dependencies] -openvm-native-compiler = { path = "../../../compiler", default-features = false } -openvm-native-transpiler = { path = "../../../transpiler", default-features = false } -openvm-instructions = { path = "../../../../../crates/toolchain/instructions", default-features = false } -openvm-stark-sdk = { git = "https://github.com/openvm-org/stark-backend.git", rev = "c785515", default-features = false } -openvm-stark-backend = { git = "https://github.com/openvm-org/stark-backend.git", rev = "c785515", default-features = false } \ No newline at end of file diff --git a/extensions/native/guest-macro/test/src/main.rs b/extensions/native/guest-macro/test/src/main.rs deleted file mode 100644 index c46cc8395..000000000 --- a/extensions/native/guest-macro/test/src/main.rs +++ /dev/null @@ -1,49 +0,0 @@ -#![allow(unused_variables)] -#![allow(unused_imports)] - -use clap::Parser; -use eyre::Result; -use openvm_benchmarks::utils::{bench_from_exe, build_bench_program, BenchmarkCli}; -use openvm_circuit::arch::{instructions::exe::VmExe, VmConfig}; -use openvm_keccak256_circuit::Keccak256Rv32Config; -use openvm_keccak256_transpiler::Keccak256TranspilerExtension; -use openvm_native_circuit::Rv32WithKernelsConfig; -use openvm_native_transpiler::LongFormTranspilerExtension; -use openvm_rv32im_transpiler::{ - Rv32ITranspilerExtension, Rv32IoTranspilerExtension, Rv32MTranspilerExtension, -}; -use openvm_sdk::{config::AppConfig, StdIn}; -use openvm_stark_sdk::{ - bench::run_with_metric_collection, - config::{ - baby_bear_poseidon2::BabyBearPoseidon2Engine, - fri_params::standard_fri_params_with_100_bits_conjectured_security, FriParameters, - }, - engine::StarkFriEngine, - p3_baby_bear::BabyBear, -}; -use openvm_transpiler::{transpiler::Transpiler, FromElf}; - -fn main() -> Result<()> { - let args = BenchmarkCli::parse(); - - let elf = args.build_bench_program("../../extensions/native/guest-macro/test/program")?; - let exe = VmExe::from_elf( - elf.clone(), - Transpiler::::default() - .with_extension(Rv32ITranspilerExtension) - .with_extension(Rv32MTranspilerExtension) - .with_extension(Rv32IoTranspilerExtension) - .with_extension(LongFormTranspilerExtension), - )?; - - args.bench_from_exe( - "test_kernel", - Rv32WithKernelsConfig::default(), - exe, - StdIn::default(), - ) - .unwrap(); - - Ok(()) -} diff --git a/extensions/native/tests/Cargo.toml b/extensions/native/tests/Cargo.toml new file mode 100644 index 000000000..857db630a --- /dev/null +++ b/extensions/native/tests/Cargo.toml @@ -0,0 +1,25 @@ +[package] +name = "openvm-native-integration-tests" +version.workspace = true +authors.workspace = true +edition.workspace = true +homepage.workspace = true +repository.workspace = true +license.workspace = true + +[dependencies] +openvm-circuit.workspace = true +openvm-sdk.workspace = true +openvm-build.workspace = true +openvm-transpiler.workspace = true +openvm-native-transpiler.workspace = true +openvm-native-circuit.workspace = true +openvm-rv32im-transpiler.workspace = true +openvm-toolchain-tests.workspace = true +p3-baby-bear.workspace = true + +eyre.workspace = true + +[features] +default = ["parallel"] +parallel = ["openvm-circuit/parallel"] diff --git a/extensions/native/tests/programs/Cargo.toml b/extensions/native/tests/programs/Cargo.toml new file mode 100644 index 000000000..fb95321cf --- /dev/null +++ b/extensions/native/tests/programs/Cargo.toml @@ -0,0 +1,20 @@ +[workspace] +[package] +name = "openvm-native-integration-test-program" +version = "0.0.0" +edition = "2021" + +[dependencies] +openvm = { path = "../../../../crates/toolchain/openvm" } +openvm-native-guest-macro = { path = "../../guest-macro", default-features = false } + +[features] +default = [] +std = ["openvm/std"] + +[build-dependencies] +openvm-native-compiler = { path = "../../compiler", default-features = false } +openvm-native-transpiler = { path = "../../transpiler", default-features = false } +openvm-instructions = { path = "../../../../crates/toolchain/instructions", default-features = false } +openvm-stark-sdk = { git = "https://github.com/openvm-org/stark-backend.git", rev = "c785515", default-features = false } # FIXME +openvm-stark-backend = { git = "https://github.com/openvm-org/stark-backend.git", rev = "c785515", default-features = false } diff --git a/extensions/native/guest-macro/test/program/build.rs b/extensions/native/tests/programs/build.rs similarity index 100% rename from extensions/native/guest-macro/test/program/build.rs rename to extensions/native/tests/programs/build.rs diff --git a/extensions/native/guest-macro/test/program/compiler_output.txt b/extensions/native/tests/programs/compiler_output.txt similarity index 100% rename from extensions/native/guest-macro/test/program/compiler_output.txt rename to extensions/native/tests/programs/compiler_output.txt diff --git a/extensions/native/guest-macro/test/program/src/main.rs b/extensions/native/tests/programs/src/main.rs similarity index 100% rename from extensions/native/guest-macro/test/program/src/main.rs rename to extensions/native/tests/programs/src/main.rs diff --git a/extensions/native/tests/src/lib.rs b/extensions/native/tests/src/lib.rs new file mode 100644 index 000000000..cee6a6954 --- /dev/null +++ b/extensions/native/tests/src/lib.rs @@ -0,0 +1,40 @@ +#[cfg(test)] +mod tests { + use eyre::Result; + use openvm_build::{GuestOptions, TargetFilter}; + use openvm_circuit::{arch::instructions::exe::VmExe, utils::air_test}; + use openvm_native_circuit::Rv32WithKernelsConfig; + use openvm_native_transpiler::LongFormTranspilerExtension; + use openvm_rv32im_transpiler::{ + Rv32ITranspilerExtension, Rv32IoTranspilerExtension, Rv32MTranspilerExtension, + }; + use openvm_sdk::Sdk; + use openvm_toolchain_tests::get_programs_dir; + use openvm_transpiler::{transpiler::Transpiler, FromElf}; + use p3_baby_bear::BabyBear; + + #[test] + fn test_native_kernel() -> Result<()> { + let sdk = Sdk; + + let elf = sdk.build( + GuestOptions::default(), + get_programs_dir!(), + &Some(TargetFilter { + kind: "bin".to_string(), + name: "openvm-native-integration-test-program".to_string(), + }), + )?; + let exe = VmExe::from_elf( + elf.clone(), + Transpiler::::default() + .with_extension(Rv32ITranspilerExtension) + .with_extension(Rv32MTranspilerExtension) + .with_extension(Rv32IoTranspilerExtension) + .with_extension(LongFormTranspilerExtension), + )?; + + air_test(Rv32WithKernelsConfig::default(), exe); + Ok(()) + } +} diff --git a/extensions/native/transpiler/Cargo.toml b/extensions/native/transpiler/Cargo.toml index 7e12921c8..45c5e27bf 100644 --- a/extensions/native/transpiler/Cargo.toml +++ b/extensions/native/transpiler/Cargo.toml @@ -9,22 +9,5 @@ repository.workspace = true [dependencies] openvm-instructions = { workspace = true } -openvm-native-compiler = { workspace = true } openvm-transpiler = { workspace = true } p3-field = { workspace = true } -p3-baby-bear = { workspace = true } -openvm-circuit-derive = { workspace = true } -openvm-rv32im-circuit = { workspace = true } -derive-new = { workspace = true } -openvm-circuit = { workspace = true } -openvm-native-circuit = { workspace = true } -derive_more = { workspace = true } -serde = { workspace = true } -strum = { workspace = true } -openvm-circuit-primitives-derive = { workspace = true } -openvm-stark-backend = { workspace = true } - -[dev-dependencies] -strum.workspace = true -strum_macros.workspace = true -openvm-instructions.workspace = true