Skip to content

Commit

Permalink
feat(ci): add support for testing different proof types
Browse files Browse the repository at this point in the history
  • Loading branch information
petarvujovic98 committed Aug 23, 2024
1 parent 81350f9 commit 7908631
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 5 deletions.
11 changes: 7 additions & 4 deletions host/tests/common/mod.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -109,8 +111,9 @@ pub async fn make_request() -> anyhow::Result<ProofRequestOpt> {
// 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,
Expand All @@ -120,7 +123,7 @@ pub async fn make_request() -> anyhow::Result<ProofRequestOpt> {
"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,
Expand Down
2 changes: 1 addition & 1 deletion makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
58 changes: 58 additions & 0 deletions script/integration.sh
Original file line number Diff line number Diff line change
@@ -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

Check warning on line 51 in script/integration.sh

View workflow job for this annotation

GitHub Actions / check-for-typos

"integation" should be "integration".
fi

# SP1
if [ "$1" == "sp1" ]; then
check_toolchain $TOOLCHAIN_SP1
cargo ${TOOLCHAIN_SP1} test -F "sp1 enable integration" run_scenarios_sequentially
fi

0 comments on commit 7908631

Please sign in to comment.