mirror of
https://github.com/logos-blockchain/lssa-zkvm-testing.git
synced 2026-01-02 13:23:08 +00:00
RISC0 instructions added
This commit is contained in:
parent
9288e419bc
commit
b4799f009a
@ -12,3 +12,4 @@ To run test, corresponding to zkVM of choise read
|
||||
- [Valida](./valida/README.md)
|
||||
- [SP1](./sp1/README.md)
|
||||
- [Nexus](./nexus/README.md)
|
||||
- [RISC0](./risc0/README.md)
|
||||
|
||||
31
risc0/README.md
Normal file
31
risc0/README.md
Normal file
@ -0,0 +1,31 @@
|
||||
# Test run instructions
|
||||
|
||||
To run corresponding tests in `RISC0` some preparations have to be done.
|
||||
|
||||
We assume, that one is in `risc0` folder.
|
||||
|
||||
Firstly, move into [scripts_and_tools](./scripts_and_tools/) directory.
|
||||
|
||||
Next, run
|
||||
|
||||
```sh
|
||||
./risc0_setup.sh
|
||||
```
|
||||
|
||||
This will fetch all necessary components for benchmarking.
|
||||
|
||||
Next, to prove execution we need to build one of the tests, we will use `simple_arithmetic_test` as an example.
|
||||
|
||||
Run
|
||||
|
||||
```sh
|
||||
./risc0_bench_arithmetic.sh
|
||||
```
|
||||
|
||||
This will compile benchmark, generate proof and prins statictics.
|
||||
|
||||
Alternatively, for memory test, you can do
|
||||
|
||||
```sh
|
||||
./risc0_bench_memory.sh
|
||||
```
|
||||
@ -20,7 +20,7 @@ pub fn new_jobs() -> Vec<Job> {
|
||||
let mut jobs = Vec::new();
|
||||
for iterations in [100] {
|
||||
jobs.push(Job::new(
|
||||
format!("simlpe_arithmetic_test-{iterations}"),
|
||||
format!("simple_arithmetic_test-{iterations}"),
|
||||
risc0_benchmark_methods::SIMPLE_ARITHMETIC_TEST_ELF,
|
||||
risc0_benchmark_methods::SIMPLE_ARITHMETIC_TEST_ID.into(),
|
||||
to_vec(&iterations).unwrap(),
|
||||
93
risc0/benchmark_tests/main.rs
Normal file
93
risc0/benchmark_tests/main.rs
Normal file
@ -0,0 +1,93 @@
|
||||
// Copyright 2024 RISC Zero, Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// This is based on zk-benchmarking: https://github.com/delendum-xyz/zk-benchmarking
|
||||
|
||||
use std::path::PathBuf;
|
||||
|
||||
use clap::{Parser, Subcommand};
|
||||
use enum_iterator::Sequence;
|
||||
use risc0_benchmark::{benches::*, run_jobs, Job};
|
||||
use tracing_subscriber::EnvFilter;
|
||||
|
||||
#[derive(Parser)]
|
||||
#[command(author, version, about, long_about = None)]
|
||||
struct Cli {
|
||||
// CSV output file
|
||||
#[arg(long, value_name = "FILE", default_value = "metrics.csv")]
|
||||
out: PathBuf,
|
||||
|
||||
#[command(subcommand)]
|
||||
command: Option<Command>,
|
||||
}
|
||||
|
||||
#[derive(Eq, PartialEq, Subcommand, Sequence)]
|
||||
enum Command {
|
||||
All,
|
||||
BigBlake2b,
|
||||
BigBlake3,
|
||||
BigKeccak,
|
||||
BigSha2,
|
||||
EcdsaVerify,
|
||||
Ed25519Verify,
|
||||
Fibonacci,
|
||||
IterBlake2b,
|
||||
IterBlake3,
|
||||
IterKeccak,
|
||||
IterSha2,
|
||||
Membership,
|
||||
Sudoku,
|
||||
SimpleArithmeticTest,
|
||||
MemAllocVecTest,
|
||||
}
|
||||
|
||||
impl Command {
|
||||
fn get_jobs(&self) -> Vec<Job> {
|
||||
match self {
|
||||
Command::All => enum_iterator::all::<Command>()
|
||||
.skip_while(|x| *x == Command::All)
|
||||
.flat_map(|x| x.get_jobs())
|
||||
.collect(),
|
||||
Command::BigBlake2b => big_blake2b::new_jobs(),
|
||||
Command::BigBlake3 => big_blake3::new_jobs(),
|
||||
Command::BigKeccak => big_keccak::new_jobs(),
|
||||
Command::BigSha2 => big_sha2::new_jobs(),
|
||||
Command::EcdsaVerify => ecdsa_verify::new_jobs(),
|
||||
Command::Ed25519Verify => ed25519_verify::new_jobs(),
|
||||
Command::Fibonacci => fibonacci::new_jobs(),
|
||||
Command::IterBlake2b => iter_blake2b::new_jobs(),
|
||||
Command::IterBlake3 => iter_blake3::new_jobs(),
|
||||
Command::IterKeccak => iter_keccak::new_jobs(),
|
||||
Command::IterSha2 => iter_sha2::new_jobs(),
|
||||
Command::Membership => membership::new_jobs(),
|
||||
Command::Sudoku => sudoku::new_jobs(),
|
||||
Command::SimpleArithmeticTest => simple_arithmetic_test::new_jobs(),
|
||||
Command::MemAllocVecTest => mem_alloc_vec_test::new_jobs(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn init_logging() {
|
||||
tracing_subscriber::fmt()
|
||||
.with_env_filter(EnvFilter::from_default_env())
|
||||
.init();
|
||||
}
|
||||
|
||||
fn main() {
|
||||
init_logging();
|
||||
|
||||
let cli = Cli::parse();
|
||||
let cmd = cli.command.unwrap_or(Command::All);
|
||||
run_jobs(&cli.out, cmd.get_jobs());
|
||||
}
|
||||
29
risc0/benchmark_tests/mod.rs
Normal file
29
risc0/benchmark_tests/mod.rs
Normal file
@ -0,0 +1,29 @@
|
||||
// Copyright 2024 RISC Zero, Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
pub mod big_blake2b;
|
||||
pub mod big_blake3;
|
||||
pub mod big_keccak;
|
||||
pub mod big_sha2;
|
||||
pub mod ecdsa_verify;
|
||||
pub mod ed25519_verify;
|
||||
pub mod fibonacci;
|
||||
pub mod iter_blake2b;
|
||||
pub mod iter_blake3;
|
||||
pub mod iter_keccak;
|
||||
pub mod iter_sha2;
|
||||
pub mod membership;
|
||||
pub mod sudoku;
|
||||
pub mod simple_arithmetic_test;
|
||||
pub mod mem_alloc_vec_test;
|
||||
3
risc0/scripts_and_tools/risc0_bench_arithmetic.sh
Normal file
3
risc0/scripts_and_tools/risc0_bench_arithmetic.sh
Normal file
@ -0,0 +1,3 @@
|
||||
cd risc0/benchmarks/
|
||||
cargo run --release -- simple-arithmetic-test
|
||||
cd ../../
|
||||
3
risc0/scripts_and_tools/risc0_bench_memory.sh
Normal file
3
risc0/scripts_and_tools/risc0_bench_memory.sh
Normal file
@ -0,0 +1,3 @@
|
||||
cd risc0/benchmarks/
|
||||
cargo run --release -- mem-alloc-vec-test
|
||||
cd ../../
|
||||
19
risc0/scripts_and_tools/risc0_setup.sh
Normal file
19
risc0/scripts_and_tools/risc0_setup.sh
Normal file
@ -0,0 +1,19 @@
|
||||
git clone https://github.com/risc0/risc0.git
|
||||
|
||||
cp ../benchmark_tests/guest_programs/mem_alloc_vec_test.rs risc0/benchmarks/methods/guest/src/bin/
|
||||
|
||||
cp ../benchmark_tests/guest_programs/simple_arithmetic_test.rs risc0/benchmarks/methods/guest/src/bin/
|
||||
|
||||
cp ../benchmark_tests/bench_programs/mem_alloc_vec_test.rs risc0/benchmarks/src/benches/
|
||||
|
||||
cp ../benchmark_tests/bench_programs/simple_arithmetic_test.rs risc0/benchmarks/src/benches/
|
||||
|
||||
cd risc0/benchmarks/src/benches/
|
||||
rm -rf mod.rs
|
||||
cd ..
|
||||
rm -rf main.rs
|
||||
cd ../../../
|
||||
|
||||
cp ../benchmark_tests/mod.rs risc0/benchmarks/src/benches/
|
||||
|
||||
cp ../benchmark_tests/main.rs risc0/benchmarks/src/
|
||||
Loading…
x
Reference in New Issue
Block a user