From 222ab7776c24bf7bacc967e83e55fe667814882d Mon Sep 17 00:00:00 2001 From: Lun-Kai Date: Mon, 18 May 2026 14:11:38 -0700 Subject: [PATCH] chore: rm openvm as direct cargo dep --- Cargo.lock | 210 ++-------------------------------------- Cargo.toml | 3 - crates/sdk/Cargo.toml | 2 - crates/sdk/src/build.rs | 76 ++++++++++++++- 4 files changed, 79 insertions(+), 212 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f6bbb47..bf84b8a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -99,13 +99,12 @@ name = "axiom-sdk" version = "1.1.0" dependencies = [ "bytes", - "cargo_metadata 0.21.0", + "cargo_metadata", "chrono", "dirs", "eyre", "flate2", "hex", - "openvm-build", "reqwest", "rustc_version", "scopeguard", @@ -170,7 +169,7 @@ name = "cargo-axiom" version = "1.1.0" dependencies = [ "axiom-sdk", - "cargo_metadata 0.21.0", + "cargo_metadata", "chrono", "clap", "clap_complete", @@ -183,15 +182,6 @@ dependencies = [ "toml_edit 0.23.4", ] -[[package]] -name = "cargo-platform" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e35af189006b9c0f00a064685c727031e3ed2d8020f7ba284d78cc2671bd36ea" -dependencies = [ - "serde", -] - [[package]] name = "cargo-platform" version = "0.2.0" @@ -211,26 +201,12 @@ dependencies = [ "serde", "serde-untagged", "serde-value", - "thiserror 2.0.16", + "thiserror", "toml", "unicode-xid", "url", ] -[[package]] -name = "cargo_metadata" -version = "0.18.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d886547e41f740c616ae73108f6eb70afe6d940c7bc697cb30f13daec073037" -dependencies = [ - "camino", - "cargo-platform 0.1.9", - "semver", - "serde", - "serde_json", - "thiserror 1.0.69", -] - [[package]] name = "cargo_metadata" version = "0.21.0" @@ -238,12 +214,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5cfca2aaa699835ba88faf58a06342a314a950d2b9686165e038286c30316868" dependencies = [ "camino", - "cargo-platform 0.2.0", + "cargo-platform", "cargo-util-schemas", "semver", "serde", "serde_json", - "thiserror 2.0.16", + "thiserror", ] [[package]] @@ -418,12 +394,6 @@ version = "0.15.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b" -[[package]] -name = "either" -version = "1.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" - [[package]] name = "encode_unicode" version = "1.0.0" @@ -968,15 +938,6 @@ version = "1.70.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" -[[package]] -name = "itertools" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285" -dependencies = [ - "either", -] - [[package]] name = "itoa" version = "1.0.15" @@ -1087,25 +1048,6 @@ dependencies = [ "tempfile", ] -[[package]] -name = "num-bigint" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" -dependencies = [ - "num-integer", - "num-traits", -] - -[[package]] -name = "num-integer" -version = "0.1.46" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" -dependencies = [ - "num-traits", -] - [[package]] name = "num-traits" version = "0.2.19" @@ -1180,47 +1122,6 @@ dependencies = [ "vcpkg", ] -[[package]] -name = "openvm-build" -version = "1.5.0" -source = "git+https://github.com/openvm-org/openvm.git?tag=v1.5.0#2ce7329603999cc86d859a79486652f3a8a27d32" -dependencies = [ - "cargo_metadata 0.18.1", - "eyre", - "openvm-platform", - "serde", - "serde_json", -] - -[[package]] -name = "openvm-custom-insn" -version = "0.1.0" -source = "git+https://github.com/openvm-org/openvm.git?tag=v1.5.0#2ce7329603999cc86d859a79486652f3a8a27d32" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "openvm-platform" -version = "1.5.0" -source = "git+https://github.com/openvm-org/openvm.git?tag=v1.5.0#2ce7329603999cc86d859a79486652f3a8a27d32" -dependencies = [ - "openvm-custom-insn", - "openvm-rv32im-guest", -] - -[[package]] -name = "openvm-rv32im-guest" -version = "1.5.0" -source = "git+https://github.com/openvm-org/openvm.git?tag=v1.5.0#2ce7329603999cc86d859a79486652f3a8a27d32" -dependencies = [ - "openvm-custom-insn", - "p3-field", - "strum_macros", -] - [[package]] name = "option-ext" version = "0.2.0" @@ -1236,43 +1137,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "p3-field" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56aae7630ff6df83fb7421d5bd97df27620e5f0e29422b7e8f6a294d44cce297" -dependencies = [ - "itertools", - "num-bigint", - "p3-maybe-rayon", - "p3-util", - "paste", - "rand", - "serde", - "tracing", -] - -[[package]] -name = "p3-maybe-rayon" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e5669ca75645f99cd001e9d0289a4eeff2bc2cd9dc3c6c3aaf22643966e83df" - -[[package]] -name = "p3-util" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "663b16021930bc600ecada915c6c3965730a3b9d6a6c23434ccf70bfc29d6881" -dependencies = [ - "serde", -] - -[[package]] -name = "paste" -version = "1.0.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" - [[package]] name = "percent-encoding" version = "2.3.2" @@ -1336,21 +1200,6 @@ version = "5.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" -[[package]] -name = "rand" -version = "0.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1" -dependencies = [ - "rand_core", -] - -[[package]] -name = "rand_core" -version = "0.9.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76afc826de14238e6e8c374ddcc1fa19e374fd8dd986b0d2af0d02377261d83c" - [[package]] name = "redox_syscall" version = "0.5.17" @@ -1368,7 +1217,7 @@ checksum = "a4e608c6638b9c18977b00b475ac1f28d14e84b27d8d42f70e0bf1e3dec127ac" dependencies = [ "getrandom 0.2.16", "libredox", - "thiserror 2.0.16", + "thiserror", ] [[package]] @@ -1671,19 +1520,6 @@ version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" -[[package]] -name = "strum_macros" -version = "0.26.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c6bee85a5a24955dc440386795aa378cd9cf82acd5f764469152d2270e581be" -dependencies = [ - "heck", - "proc-macro2", - "quote", - "rustversion", - "syn", -] - [[package]] name = "subtle" version = "2.6.1" @@ -1765,33 +1601,13 @@ dependencies = [ "windows-sys 0.60.2", ] -[[package]] -name = "thiserror" -version = "1.0.69" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" -dependencies = [ - "thiserror-impl 1.0.69", -] - [[package]] name = "thiserror" version = "2.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3467d614147380f2e4e374161426ff399c91084acd2363eaf549172b3d5e60c0" dependencies = [ - "thiserror-impl 2.0.16", -] - -[[package]] -name = "thiserror-impl" -version = "1.0.69" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" -dependencies = [ - "proc-macro2", - "quote", - "syn", + "thiserror-impl", ] [[package]] @@ -1995,21 +1811,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0" dependencies = [ "pin-project-lite", - "tracing-attributes", "tracing-core", ] -[[package]] -name = "tracing-attributes" -version = "0.1.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81383ab64e72a7a8b8e13130c49e3dab29def6d0c7d76a03087b3cf71c5c6903" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "tracing-core" version = "0.1.34" diff --git a/Cargo.toml b/Cargo.toml index af622c6..5b09184 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,9 +9,6 @@ members = ["crates/cli", "crates/sdk"] resolver = "3" [workspace.dependencies] -# OpenVM -openvm-build = { git = "https://github.com/openvm-org/openvm.git", tag = "v1.5.0", default-features = false } - # Axiom Proving API cargo-axiom = { path = "crates/cli", default-features = false } axiom-sdk = { path = "crates/sdk", default-features = false } diff --git a/crates/sdk/Cargo.toml b/crates/sdk/Cargo.toml index 30232cd..244baaa 100644 --- a/crates/sdk/Cargo.toml +++ b/crates/sdk/Cargo.toml @@ -7,8 +7,6 @@ edition.workspace = true license.workspace = true [dependencies] -openvm-build = { workspace = true } - serde = { workspace = true } serde_json = { workspace = true } cargo_metadata = { workspace = true } diff --git a/crates/sdk/src/build.rs b/crates/sdk/src/build.rs index 08a221e..b5ecaa9 100644 --- a/crates/sdk/src/build.rs +++ b/crates/sdk/src/build.rs @@ -11,7 +11,6 @@ use std::{ use eyre::{Context, OptionExt, Result, eyre}; use flate2::{Compression, write::GzEncoder}; -use openvm_build::{cargo_command, get_rustup_toolchain_name}; use reqwest::blocking::Client; use scopeguard::defer; use serde::{Deserialize, Serialize}; @@ -28,6 +27,75 @@ const BUILD_POLLING_INTERVAL_SECS: u64 = 10; pub const AXIOM_CARGO_HOME: &str = "axiom_cargo_home"; +// Mirrors of constants/helpers from `openvm-build`. Keep in sync with the openvm +// version pinned by the proving API (currently v1.6.0). These let the SDK avoid +// pulling in `openvm-build` (and its transitive deps) just to learn the toolchain +// name and to run a guest-target `cargo fetch`. +const DEFAULT_OPENVM_RUST_TOOLCHAIN: &str = "nightly-2025-08-02"; +const OPENVM_RUSTC_TARGET: &str = "riscv32im-risc0-zkvm-elf"; +const OPENVM_TEXT_START: u32 = 0x0020_0800; + +fn openvm_rust_toolchain_name() -> String { + std::env::var("OPENVM_RUST_TOOLCHAIN") + .unwrap_or_else(|_| DEFAULT_OPENVM_RUST_TOOLCHAIN.to_string()) +} + +fn sanitized_cmd(tool: &str) -> std::process::Command { + let mut cmd = std::process::Command::new(tool); + for (key, _) in std::env::vars() { + if key.starts_with("CARGO") && key != "CARGO_HOME" { + cmd.env_remove(key); + } + } + cmd.env_remove("RUSTUP_TOOLCHAIN"); + cmd +} + +/// Equivalent of `openvm_build::cargo_command("fetch", &[])`: a sanitized `cargo +/// fetch` invocation targeting the openvm guest, with the same `-Z build-std` +/// flags and RUSTFLAGS so cfg-gated dependencies resolve identically to openvm's +/// guest build. +fn openvm_guest_cargo_fetch_command() -> std::process::Command { + let toolchain = format!("+{}", openvm_rust_toolchain_name()); + + let rustc_out = sanitized_cmd("rustup") + .args([&toolchain, "which", "rustc"]) + .output() + .expect("rustup failed to find openvm toolchain"); + let rustc = String::from_utf8(rustc_out.stdout).expect("rustc path was not utf8"); + let rustc = rustc.trim().to_string(); + + let mut cmd = sanitized_cmd("cargo"); + cmd.args([ + &toolchain, + "fetch", + "--target", + OPENVM_RUSTC_TARGET, + "-Z", + "build-std=alloc,core,proc_macro,panic_abort,std", + "-Z", + "build-std-features=compiler-builtins-mem", + ]); + + let rust_flags = [ + "-C", + "passes=lower-atomic", + "-C", + &format!("link-arg=-Ttext=0x{:08X}", OPENVM_TEXT_START), + "-C", + "link-arg=--fatal-warnings", + "-C", + "panic=abort", + "--cfg", + "getrandom_backend=\"custom\"", + ] + .join("\x1f"); + + cmd.env("RUSTC", rustc) + .env("CARGO_ENCODED_RUSTFLAGS", rust_flags); + cmd +} + pub trait BuildSdk { fn list_programs( &self, @@ -629,10 +697,10 @@ impl AxiomSdk { if let Some(default_num_gpus) = args.default_num_gpus { url.push_str(&format!("&default_num_gpus={}", default_num_gpus)); } - // Always pass the toolchain version - either from args or from openvm-build default + // Always pass the toolchain version - either from args or from the openvm default let toolchain = args.openvm_rust_toolchain.clone().unwrap_or_else(|| { // Use the same toolchain that was used for cargo fetch - get_rustup_toolchain_name() + openvm_rust_toolchain_name() }); url.push_str(&format!("&openvm_rust_toolchain={}", toolchain)); @@ -1162,7 +1230,7 @@ fn create_tar_archive( } // Fetch 3: Run cargo fetch for some host dependencies (std stuffs) - let mut cmd = cargo_command("fetch", &[]); + let mut cmd = openvm_guest_cargo_fetch_command(); if let Some(ref tc) = openvm_rust_toolchain { cmd.env("OPENVM_RUST_TOOLCHAIN", tc); }