diff --git a/host/tests/common/mod.rs b/host/tests/common/mod.rs index 0f0204346..132a1c3ec 100644 --- a/host/tests/common/mod.rs +++ b/host/tests/common/mod.rs @@ -1,4 +1,6 @@ -use raiko_core::interfaces::{ProofRequestOpt, ProverSpecificOpts}; +use std::str::FromStr; + +use raiko_core::interfaces::{ProofRequestOpt, ProofType, ProverSpecificOpts}; use raiko_host::{server::serve, ProverState}; use raiko_lib::consts::{Network, SupportedChainSpecs}; use serde::Deserialize; @@ -109,8 +111,9 @@ pub async fn make_request() -> anyhow::Result { // Get block to test with. let block_number = find_recent_block(Network::TaikoMainnet).await?; - // TODO:(petar) Change prover type based on the prover we want to test. Probably should be - // read from the environment. + let proof_type = + ProofType::from_str(&std::env::var("PROOF_TYPE").unwrap_or_else(|_| "native".to_owned()))?; + Ok(ProofRequestOpt { block_number: Some(block_number), l1_inclusive_block_number: None, @@ -120,7 +123,7 @@ pub async fn make_request() -> anyhow::Result { "8008500000000000000000000000000000000000000000000000000000000000".to_owned(), ), prover: Some("0x70997970C51812dc3A010C7d01b50e0d17dc79C8".to_owned()), - proof_type: Some("native".to_owned()), + proof_type: Some(proof_type), blob_proof_type: Some("kzg_versioned_hash".to_string()), prover_args: ProverSpecificOpts { native: None, diff --git a/makefile b/makefile index ba666ff5f..00bf6077c 100644 --- a/makefile +++ b/makefile @@ -13,7 +13,7 @@ test: TEST=1 RUN=1 ./script/build.sh $(TARGET) integration: - CONFIG_PATH="config/config.json" cargo test -F integration run_scenarios_sequentially + CONFIG_PATH="config/config.json" ./script/integration.sh $(TARGET) fmt: @cargo fmt --all --check diff --git a/script/integration.sh b/script/integration.sh new file mode 100755 index 000000000..0c791a729 --- /dev/null +++ b/script/integration.sh @@ -0,0 +1,58 @@ +#!/usr/bin/env bash + +# Any error will result in failure +set -e + +TOOLCHAIN_RISC0=+nightly-2024-04-18 +TOOLCHAIN_SP1=+nightly-2024-04-18 +TOOLCHAIN_SGX=+nightly-2024-04-18 +export PROOF_TYPE="$1" + +check_toolchain() { + local TOOLCHAIN=$1 + + # Remove the plus sign from the toolchain name + TOOLCHAIN=${TOOLCHAIN#+} + + # Function to check if the toolchain is installed + exist() { + rustup toolchain list | grep "$TOOLCHAIN" >/dev/null + } + + # Main script logic + if exist; then + echo "Toolchain $TOOLCHAIN exists" + else + echo "Installing Rust toolchain: $TOOLCHAIN" + rustup install "$TOOLCHAIN" + fi +} + +if [ "$CPU_OPT" = "1" ]; then + export RUSTFLAGS='-C target-cpu=native' + echo "Enable cpu optimization with host RUSTFLAGS" +fi + +# NATIVE +if [ -z "$1" ] || [ "$1" == "native" ]; then + cargo test -F integration run_scenarios_sequentially +fi + +# SGX +if [ "$1" == "sgx" ]; then + check_toolchain $TOOLCHAIN_SGX + cargo ${TOOLCHAIN_SGX} test -F "sgx enable integration" run_scenarios_sequentially +fi + +# RISC0 +if [ "$1" == "risc0" ]; then + check_toolchain $TOOLCHAIN_RISC0 + ./script/setup-bonsai.sh + cargo ${TOOLCHAIN_RISC0} test -F "risc0 enable integation" run_scenarios_sequentially +fi + +# SP1 +if [ "$1" == "sp1" ]; then + check_toolchain $TOOLCHAIN_SP1 + cargo ${TOOLCHAIN_SP1} test -F "sp1 enable integration" run_scenarios_sequentially +fi