diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5cb7bb8..ed89155 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -93,7 +93,7 @@ jobs: - name: Unit tests env: RISC0_DEV_MODE: "1" - run: cargo test --workspace --features no_docker + run: cargo test --workspace - name: Test valid proof env: @@ -108,3 +108,27 @@ jobs: RISC0_DEV_MODE: "1" run: cargo run --bin integration-tests -- ./integration-tests/configs/debug/ all + artifacts: + runs-on: ubuntu-latest + timeout-minutes: 60 + + name: artifacts + steps: + - uses: actions/checkout@v5 + + - uses: ./.github/actions/install-risc0 + + - name: Install just + run: cargo install just + + - name: Build artifacts + run: just build-artifacts + + - name: Check if artifacts match repository + run: | + if ! git diff --exit-code artifacts/; then + echo "❌ Artifacts in the repository are out of date!" + echo "Please run 'just build-artifacts' and commit the changes." + exit 1 + fi + echo "✅ Artifacts are up to date" diff --git a/Cargo.toml b/Cargo.toml index f1d9a26..14856d0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,7 +33,6 @@ sequencer_core = { path = "sequencer_core" } sequencer_rpc = { path = "sequencer_rpc" } sequencer_runner = { path = "sequencer_runner" } wallet = { path = "wallet" } -program_methods = { path = "program_methods" } test_program_methods = { path = "test_program_methods" } tokio = { version = "1.28.2", features = [ diff --git a/Justfile b/Justfile new file mode 100644 index 0000000..b867d6f --- /dev/null +++ b/Justfile @@ -0,0 +1,19 @@ +set shell := ["bash", "-eu", "-o", "pipefail", "-c"] + +default: + @just --list + +# ---- Configuration ---- +METHODS_PATH := "program_methods" +TEST_METHODS_PATH := "test_program_methods" +ARTIFACTS := "artifacts" + +# ---- Artifacts build ---- +build-artifacts: + @echo "🔨 Building artifacts" + @for methods_path in {{METHODS_PATH}} {{TEST_METHODS_PATH}}; do \ + echo "Building artifacts for $methods_path"; \ + cargo risczero build --manifest-path $methods_path/guest/Cargo.toml; \ + mkdir -p {{ARTIFACTS}}/$methods_path; \ + cp target/riscv32im-risc0-zkvm-elf/docker/*.bin {{ARTIFACTS}}/$methods_path; \ + done diff --git a/artifacts/program_methods/authenticated_transfer.bin b/artifacts/program_methods/authenticated_transfer.bin new file mode 100644 index 0000000..c37e42c Binary files /dev/null and b/artifacts/program_methods/authenticated_transfer.bin differ diff --git a/artifacts/program_methods/burner.bin b/artifacts/program_methods/burner.bin new file mode 100644 index 0000000..3205584 Binary files /dev/null and b/artifacts/program_methods/burner.bin differ diff --git a/artifacts/program_methods/chain_caller.bin b/artifacts/program_methods/chain_caller.bin new file mode 100644 index 0000000..a60b14e Binary files /dev/null and b/artifacts/program_methods/chain_caller.bin differ diff --git a/artifacts/program_methods/claimer.bin b/artifacts/program_methods/claimer.bin new file mode 100644 index 0000000..ca38718 Binary files /dev/null and b/artifacts/program_methods/claimer.bin differ diff --git a/artifacts/program_methods/data_changer.bin b/artifacts/program_methods/data_changer.bin new file mode 100644 index 0000000..53c0b28 Binary files /dev/null and b/artifacts/program_methods/data_changer.bin differ diff --git a/artifacts/program_methods/extra_output.bin b/artifacts/program_methods/extra_output.bin new file mode 100644 index 0000000..94738ec Binary files /dev/null and b/artifacts/program_methods/extra_output.bin differ diff --git a/artifacts/program_methods/minter.bin b/artifacts/program_methods/minter.bin new file mode 100644 index 0000000..fbf644e Binary files /dev/null and b/artifacts/program_methods/minter.bin differ diff --git a/artifacts/program_methods/missing_output.bin b/artifacts/program_methods/missing_output.bin new file mode 100644 index 0000000..d6216ea Binary files /dev/null and b/artifacts/program_methods/missing_output.bin differ diff --git a/artifacts/program_methods/modified_transfer.bin b/artifacts/program_methods/modified_transfer.bin new file mode 100644 index 0000000..35f8ee9 Binary files /dev/null and b/artifacts/program_methods/modified_transfer.bin differ diff --git a/artifacts/program_methods/nonce_changer.bin b/artifacts/program_methods/nonce_changer.bin new file mode 100644 index 0000000..e6e965a Binary files /dev/null and b/artifacts/program_methods/nonce_changer.bin differ diff --git a/artifacts/program_methods/pinata.bin b/artifacts/program_methods/pinata.bin new file mode 100644 index 0000000..0936256 Binary files /dev/null and b/artifacts/program_methods/pinata.bin differ diff --git a/artifacts/program_methods/pinata_token.bin b/artifacts/program_methods/pinata_token.bin new file mode 100644 index 0000000..7f6f694 Binary files /dev/null and b/artifacts/program_methods/pinata_token.bin differ diff --git a/artifacts/program_methods/privacy_preserving_circuit.bin b/artifacts/program_methods/privacy_preserving_circuit.bin new file mode 100644 index 0000000..67be5c4 Binary files /dev/null and b/artifacts/program_methods/privacy_preserving_circuit.bin differ diff --git a/artifacts/program_methods/program_owner_changer.bin b/artifacts/program_methods/program_owner_changer.bin new file mode 100644 index 0000000..cc76295 Binary files /dev/null and b/artifacts/program_methods/program_owner_changer.bin differ diff --git a/artifacts/program_methods/simple_balance_transfer.bin b/artifacts/program_methods/simple_balance_transfer.bin new file mode 100644 index 0000000..9054b2c Binary files /dev/null and b/artifacts/program_methods/simple_balance_transfer.bin differ diff --git a/artifacts/program_methods/token.bin b/artifacts/program_methods/token.bin new file mode 100644 index 0000000..d7528c2 Binary files /dev/null and b/artifacts/program_methods/token.bin differ diff --git a/artifacts/test_program_methods/authenticated_transfer.bin b/artifacts/test_program_methods/authenticated_transfer.bin new file mode 100644 index 0000000..c37e42c Binary files /dev/null and b/artifacts/test_program_methods/authenticated_transfer.bin differ diff --git a/artifacts/test_program_methods/burner.bin b/artifacts/test_program_methods/burner.bin new file mode 100644 index 0000000..3205584 Binary files /dev/null and b/artifacts/test_program_methods/burner.bin differ diff --git a/artifacts/test_program_methods/chain_caller.bin b/artifacts/test_program_methods/chain_caller.bin new file mode 100644 index 0000000..a60b14e Binary files /dev/null and b/artifacts/test_program_methods/chain_caller.bin differ diff --git a/artifacts/test_program_methods/claimer.bin b/artifacts/test_program_methods/claimer.bin new file mode 100644 index 0000000..ca38718 Binary files /dev/null and b/artifacts/test_program_methods/claimer.bin differ diff --git a/artifacts/test_program_methods/data_changer.bin b/artifacts/test_program_methods/data_changer.bin new file mode 100644 index 0000000..53c0b28 Binary files /dev/null and b/artifacts/test_program_methods/data_changer.bin differ diff --git a/artifacts/test_program_methods/extra_output.bin b/artifacts/test_program_methods/extra_output.bin new file mode 100644 index 0000000..94738ec Binary files /dev/null and b/artifacts/test_program_methods/extra_output.bin differ diff --git a/artifacts/test_program_methods/minter.bin b/artifacts/test_program_methods/minter.bin new file mode 100644 index 0000000..fbf644e Binary files /dev/null and b/artifacts/test_program_methods/minter.bin differ diff --git a/artifacts/test_program_methods/missing_output.bin b/artifacts/test_program_methods/missing_output.bin new file mode 100644 index 0000000..d6216ea Binary files /dev/null and b/artifacts/test_program_methods/missing_output.bin differ diff --git a/artifacts/test_program_methods/modified_transfer.bin b/artifacts/test_program_methods/modified_transfer.bin new file mode 100644 index 0000000..35f8ee9 Binary files /dev/null and b/artifacts/test_program_methods/modified_transfer.bin differ diff --git a/artifacts/test_program_methods/nonce_changer.bin b/artifacts/test_program_methods/nonce_changer.bin new file mode 100644 index 0000000..e6e965a Binary files /dev/null and b/artifacts/test_program_methods/nonce_changer.bin differ diff --git a/artifacts/test_program_methods/pinata.bin b/artifacts/test_program_methods/pinata.bin new file mode 100644 index 0000000..0936256 Binary files /dev/null and b/artifacts/test_program_methods/pinata.bin differ diff --git a/artifacts/test_program_methods/pinata_token.bin b/artifacts/test_program_methods/pinata_token.bin new file mode 100644 index 0000000..7f6f694 Binary files /dev/null and b/artifacts/test_program_methods/pinata_token.bin differ diff --git a/artifacts/test_program_methods/privacy_preserving_circuit.bin b/artifacts/test_program_methods/privacy_preserving_circuit.bin new file mode 100644 index 0000000..67be5c4 Binary files /dev/null and b/artifacts/test_program_methods/privacy_preserving_circuit.bin differ diff --git a/artifacts/test_program_methods/program_owner_changer.bin b/artifacts/test_program_methods/program_owner_changer.bin new file mode 100644 index 0000000..cc76295 Binary files /dev/null and b/artifacts/test_program_methods/program_owner_changer.bin differ diff --git a/artifacts/test_program_methods/simple_balance_transfer.bin b/artifacts/test_program_methods/simple_balance_transfer.bin new file mode 100644 index 0000000..9054b2c Binary files /dev/null and b/artifacts/test_program_methods/simple_balance_transfer.bin differ diff --git a/artifacts/test_program_methods/token.bin b/artifacts/test_program_methods/token.bin new file mode 100644 index 0000000..d7528c2 Binary files /dev/null and b/artifacts/test_program_methods/token.bin differ diff --git a/integration_tests/Cargo.toml b/integration_tests/Cargo.toml index 529eb65..52c6e38 100644 --- a/integration_tests/Cargo.toml +++ b/integration_tests/Cargo.toml @@ -5,7 +5,7 @@ edition = "2024" [dependencies] nssa_core = { workspace = true, features = ["host"] } -nssa = { workspace = true, features = ["no_docker"] } +nssa.workspace = true sequencer_core = { workspace = true, features = ["testnet"] } sequencer_runner.workspace = true wallet.workspace = true diff --git a/integration_tests/data_changer.bin b/integration_tests/data_changer.bin deleted file mode 100644 index eb28a62..0000000 Binary files a/integration_tests/data_changer.bin and /dev/null differ diff --git a/integration_tests/src/data_changer.bin b/integration_tests/src/data_changer.bin deleted file mode 100644 index 3d062c3..0000000 Binary files a/integration_tests/src/data_changer.bin and /dev/null differ diff --git a/integration_tests/src/test_suite_map.rs b/integration_tests/src/test_suite_map.rs index 8e42640..1b5e61d 100644 --- a/integration_tests/src/test_suite_map.rs +++ b/integration_tests/src/test_suite_map.rs @@ -1596,7 +1596,10 @@ pub fn prepare_function_map() -> HashMap { pub async fn test_program_deployment() { info!("########## test program deployment ##########"); - let binary_filepath: PathBuf = NSSA_PROGRAM_FOR_TEST_DATA_CHANGER.parse().unwrap(); + let manifest_dir = env!("CARGO_MANIFEST_DIR"); + let binary_filepath: PathBuf = PathBuf::from(manifest_dir) + .join("../artifacts/test_program_methods") + .join(NSSA_PROGRAM_FOR_TEST_DATA_CHANGER); let command = Command::DeployProgram { binary_filepath: binary_filepath.clone(), diff --git a/nssa/Cargo.toml b/nssa/Cargo.toml index ccb07f4..78dea7c 100644 --- a/nssa/Cargo.toml +++ b/nssa/Cargo.toml @@ -8,7 +8,6 @@ nssa_core = { workspace = true, features = ["host"] } thiserror.workspace = true risc0-zkvm.workspace = true -program_methods = { workspace = true, optional = true } serde.workspace = true sha2.workspace = true rand.workspace = true @@ -27,4 +26,3 @@ hex-literal = "1.0.0" [features] default = [] -no_docker = ["program_methods"] diff --git a/nssa/build.rs b/nssa/build.rs index 8fe6dbe..020b838 100644 --- a/nssa/build.rs +++ b/nssa/build.rs @@ -1,44 +1,21 @@ -fn main() { - if cfg!(feature = "no_docker") { - println!("cargo:warning=NO_DOCKER feature enabled – deterministic build skipped"); - return; - } - - build_deterministic().expect("Deterministic build failed"); -} - -fn build_deterministic() -> Result<(), Box> { - use std::{env, fs, path::PathBuf, process::Command}; +use std::{env, fs, path::PathBuf}; +fn main() -> Result<(), Box> { let manifest_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR")?); let out_dir = PathBuf::from(env::var("OUT_DIR")?); let mod_dir = out_dir.join("program_methods"); let mod_file = mod_dir.join("mod.rs"); + let program_methods_dir = manifest_dir.join("../artifacts/program_methods/"); - println!("cargo:rerun-if-changed=../program_methods/guest/src"); - println!("cargo:rerun-if-changed=../program_methods/guest/Cargo.toml"); + println!("cargo:rerun-if-changed={}", program_methods_dir.display()); - let build_cur_dir = manifest_dir.join("..").canonicalize()?; - let guest_manifest = build_cur_dir.join("program_methods/guest/Cargo.toml"); - let status = Command::new("cargo") - .current_dir(build_cur_dir) - .args(["risczero", "build", "--manifest-path"]) - .arg(&guest_manifest) - .status()?; - if !status.success() { - return Err("Risc0 deterministic build failed".into()); - } - - let target_dir = - manifest_dir.join("../program_methods/guest/target/riscv32im-risc0-zkvm-elf/docker/"); - - let bins = fs::read_dir(&target_dir)? + let bins = fs::read_dir(&program_methods_dir)? .filter_map(Result::ok) .filter(|e| e.path().extension().is_some_and(|ext| ext == "bin")) .collect::>(); if bins.is_empty() { - return Err(format!("No .bin files found in {:?}", target_dir).into()); + return Err(format!("No .bin files found in {:?}", program_methods_dir).into()); } fs::create_dir_all(&mod_dir)?; diff --git a/nssa/src/lib.rs b/nssa/src/lib.rs index e7182c9..de4b65b 100644 --- a/nssa/src/lib.rs +++ b/nssa/src/lib.rs @@ -1,12 +1,7 @@ -#[cfg(not(feature = "no_docker"))] pub mod program_methods { include!(concat!(env!("OUT_DIR"), "/program_methods/mod.rs")); } -#[cfg(feature = "no_docker")] -#[allow(clippy::single_component_path_imports)] -use program_methods; - pub mod encoding; pub mod error; mod merkle_tree;