forked from openvm-org/openvm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfibonacci.rs
78 lines (74 loc) · 2.53 KB
/
fibonacci.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#![allow(unused_variables)]
#![allow(unused_imports)]
use clap::Parser;
use eyre::Result;
use metrics::gauge;
use openvm_benchmarks::utils::{bench_from_exe, build_bench_program, BenchmarkCli};
use openvm_circuit::arch::{
instructions::{exe::VmExe, program::DEFAULT_MAX_NUM_PUBLIC_VALUES},
VirtualMachine,
};
use openvm_native_circuit::NativeConfig;
use openvm_native_compiler::conversion::CompilerOptions;
use openvm_native_recursion::testing_utils::inner::build_verification_program;
use openvm_rv32im_circuit::Rv32ImConfig;
use openvm_rv32im_transpiler::{
Rv32ITranspilerExtension, Rv32IoTranspilerExtension, Rv32MTranspilerExtension,
};
use openvm_sdk::{
commit::{commit_app_exe, generate_leaf_committed_exe},
config::AppConfig,
keygen::{leaf_keygen, AppProvingKey},
prover::{AggStarkProver, AppProver, LeafProver},
Sdk, StdIn,
};
use openvm_stark_backend::p3_field::AbstractField;
use openvm_stark_sdk::{
bench::run_with_metric_collection,
config::{
baby_bear_poseidon2::BabyBearPoseidon2Engine,
fri_params::standard_fri_params_with_100_bits_conjectured_security, FriParameters,
},
engine::StarkFriEngine,
p3_baby_bear::BabyBear,
};
use openvm_transpiler::{transpiler::Transpiler, FromElf};
use tracing::info_span;
fn main() -> Result<()> {
let cli_args = BenchmarkCli::parse();
let app_fri_params = standard_fri_params_with_100_bits_conjectured_security(
cli_args.app_log_blowup.unwrap_or(2),
);
let leaf_fri_params = standard_fri_params_with_100_bits_conjectured_security(
cli_args.agg_log_blowup.unwrap_or(2),
);
let app_config = AppConfig {
app_fri_params: app_fri_params.into(),
app_vm_config: Rv32ImConfig::default(),
leaf_fri_params: leaf_fri_params.into(),
compiler_options: Default::default(),
};
let elf = build_bench_program("fibonacci")?;
let exe = VmExe::from_elf(
elf,
Transpiler::<BabyBear>::default()
.with_extension(Rv32ITranspilerExtension)
.with_extension(Rv32MTranspilerExtension)
.with_extension(Rv32IoTranspilerExtension),
)?;
run_with_metric_collection("OUTPUT_PATH", || -> Result<()> {
let n = 100_000u64;
let mut stdin = StdIn::default();
stdin.write(&n);
bench_from_exe(
"fibonacci_program",
app_config,
exe,
stdin,
#[cfg(feature = "aggregation")]
true,
#[cfg(not(feature = "aggregation"))]
false,
)
})
}