diff --git a/functional-tests/env.bash b/functional-tests/env.bash index 56c221c2e..956ef4026 100644 --- a/functional-tests/env.bash +++ b/functional-tests/env.bash @@ -2,4 +2,3 @@ export RUST_LOG=trace,hyper=warn,soketto=warn,jsonrpsee-server=warn,mio=warn export NO_COLOR=1 export PATH=$PATH:$(realpath ../target/release) export RUST_BACKTRACE=1 -export ELF_BASE_PATH=~/Codes/strata/elfs/sp1/ diff --git a/functional-tests/run_test.sh b/functional-tests/run_test.sh index e9b7a0b5c..84679d6a5 100755 --- a/functional-tests/run_test.sh +++ b/functional-tests/run_test.sh @@ -12,7 +12,7 @@ fi # Conditionally run cargo build based on PROVER_TEST if [ ! -z $PROVER_TEST ]; then echo "Running on sp1-mock mode" - cargo build --release -F sp1-builder + cargo build --release -F sp1-mock-builder export PATH=$(realpath ../target/release/):$PATH else echo "Running on seq mode" diff --git a/functional-tests/tests/prover/prover_el_dispatch.py b/functional-tests/tests/prover/prover_el_dispatch.py index eae8ef7e9..9787c003b 100644 --- a/functional-tests/tests/prover/prover_el_dispatch.py +++ b/functional-tests/tests/prover/prover_el_dispatch.py @@ -36,5 +36,5 @@ def main(self, ctx: flexitest.RunContext): self.debug(f"using task id: {task_id}") assert task_id is not None - time_out = 60 + time_out = 30 wait_for_proof_with_time_out(prover_client_rpc, task_id, time_out=time_out) diff --git a/provers/sp1/build.rs b/provers/sp1/build.rs index c602ba2b9..936f00f27 100644 --- a/provers/sp1/build.rs +++ b/provers/sp1/build.rs @@ -7,13 +7,12 @@ use std::{ use cfg_if::cfg_if; cfg_if! { - if #[cfg(feature = "sp1-dev")] { -use bincode::{deserialize, serialize}; -use cargo_metadata::MetadataCommand; -use sha2::{Digest, Sha256}; -use sp1_helper::{build_program_with_args, BuildArgs}; -use sp1_sdk::{HashableKey, ProverClient, SP1VerifyingKey}; - + if #[cfg(all(feature = "sp1-dev", not(debug_assertions)))] { + use bincode::{deserialize, serialize}; + use cargo_metadata::MetadataCommand; + use sha2::{Digest, Sha256}; + use sp1_helper::{build_program_with_args, BuildArgs}; + use sp1_sdk::{HashableKey, ProverClient, SP1VerifyingKey}; } } @@ -169,7 +168,7 @@ fn get_output_dir() -> PathBuf { } /// Checks if the cache is valid by comparing the expected ID with the saved ID. -#[cfg(feature = "sp1-dev")] +#[cfg(all(feature = "sp1-dev", not(debug_assertions)))] fn is_cache_valid(expected_id: &[u8; 32], paths: &[PathBuf; 4]) -> bool { // Check if any required files are missing if paths.iter().any(|path| !path.exists()) { @@ -186,7 +185,7 @@ fn is_cache_valid(expected_id: &[u8; 32], paths: &[PathBuf; 4]) -> bool { } /// Ensures the cache is valid and returns the ELF contents and SP1 Verifying Key. -#[cfg(feature = "sp1-dev")] +#[cfg(all(feature = "sp1-dev", not(debug_assertions)))] fn ensure_cache_validity(program: &str) -> Result { let cache_dir = format!("{}/cache", program); let paths = ["elf", "id", "vk", "pk"] @@ -223,8 +222,19 @@ fn ensure_cache_validity(program: &str) -> Result { } /// Generates the ELF contents and VK hash for a given program. -#[cfg(feature = "sp1-dev")] +#[cfg(all(feature = "sp1-dev", not(debug_assertions)))] fn generate_elf_contents_and_vk_hash(program: &str) -> ([u32; 8], String) { + // Check if the Clippy linter is enabled by examining the "RUSTC_WORKSPACE_WRAPPER" environment + // variable. If it contains "clippy-driver", Clippy is active; in that case, return mock ELF + // contents and VK hash. + let is_clippy_enabled = std::env::var("RUSTC_WORKSPACE_WRAPPER") + .map(|val| val.contains("clippy-driver")) + .unwrap_or(false); + + if is_clippy_enabled { + return get_mock_elf_contents_and_vk_hash(); + } + let mut build_args = BuildArgs { ..Default::default() }; @@ -261,8 +271,12 @@ fn generate_elf_contents_and_vk_hash(program: &str) -> ([u32; 8], String) { (vk.hash_u32(), vk.bytes32()) } -#[cfg(not(feature = "sp1-dev"))] +#[cfg(debug_assertions)] fn generate_elf_contents_and_vk_hash(_program: &str) -> ([u32; 8], String) { + get_mock_elf_contents_and_vk_hash() +} + +fn get_mock_elf_contents_and_vk_hash() -> ([u32; 8], String) { ( [0u32; 8], "0x0000000000000000000000000000000000000000000000000000000000000000".to_owned(), @@ -270,7 +284,7 @@ fn generate_elf_contents_and_vk_hash(_program: &str) -> ([u32; 8], String) { } /// Copies the compiled ELF file of the specified program to its cache directory. -#[cfg(feature = "sp1-dev")] +#[cfg(all(feature = "sp1-dev", not(debug_assertions)))] fn migrate_elf(program: &str) { // Get the build directory from the environment let sp1_build_dir = diff --git a/provers/tests/Cargo.toml b/provers/tests/Cargo.toml index 46adf26d4..ccca82b57 100644 --- a/provers/tests/Cargo.toml +++ b/provers/tests/Cargo.toml @@ -19,6 +19,7 @@ zkaleido.workspace = true # sp1 strata-sp1-guest-builder = { path = "../sp1", optional = true, features = [ "prover", + "sp1-dev", ] } zkaleido-sp1-adapter = { workspace = true, optional = true, features = [ "prover",