From b4f11f1fa5b467bff4cdbd5ef7a5f7c6c7ccf9b0 Mon Sep 17 00:00:00 2001 From: kunxian xia Date: Tue, 9 Dec 2025 14:15:32 +0800 Subject: [PATCH] run stark with app vk --- Cargo.lock | 25 +++++++++++++------------ crates/host-bench/src/lib.rs | 19 ++++++++++++++++--- reproduce.sh | 14 +++++++++++++- 3 files changed, 42 insertions(+), 16 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7e00ce635..861338c1e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1673,7 +1673,7 @@ dependencies = [ [[package]] name = "cargo-ceno" version = "0.1.0" -source = "git+https://github.com/scroll-tech/ceno?branch=master#3b6aac2a76d5d5d91bdf1c056756a0b16f53f02a" +source = "git+https://github.com/scroll-tech/ceno?branch=master#fe2f215b05cae01fcdd0582ef8261b8a40070f57" dependencies = [ "anyhow", "bincode 1.3.3", @@ -1822,7 +1822,7 @@ dependencies = [ [[package]] name = "ceno-examples" version = "0.1.0" -source = "git+https://github.com/scroll-tech/ceno?branch=master#3b6aac2a76d5d5d91bdf1c056756a0b16f53f02a" +source = "git+https://github.com/scroll-tech/ceno?branch=master#fe2f215b05cae01fcdd0582ef8261b8a40070f57" dependencies = [ "glob", ] @@ -1842,7 +1842,7 @@ dependencies = [ [[package]] name = "ceno_crypto" version = "0.1.0" -source = "git+https://github.com/scroll-tech/ceno?branch=master#3b6aac2a76d5d5d91bdf1c056756a0b16f53f02a" +source = "git+https://github.com/scroll-tech/ceno?branch=master#fe2f215b05cae01fcdd0582ef8261b8a40070f57" dependencies = [ "ceno_keccak", "ceno_sha2", @@ -1864,7 +1864,7 @@ dependencies = [ [[package]] name = "ceno_emul" version = "0.1.0" -source = "git+https://github.com/scroll-tech/ceno?branch=master#3b6aac2a76d5d5d91bdf1c056756a0b16f53f02a" +source = "git+https://github.com/scroll-tech/ceno?branch=master#fe2f215b05cae01fcdd0582ef8261b8a40070f57" dependencies = [ "anyhow", "ceno_rt", @@ -1895,7 +1895,7 @@ dependencies = [ [[package]] name = "ceno_host" version = "0.1.0" -source = "git+https://github.com/scroll-tech/ceno?branch=master#3b6aac2a76d5d5d91bdf1c056756a0b16f53f02a" +source = "git+https://github.com/scroll-tech/ceno?branch=master#fe2f215b05cae01fcdd0582ef8261b8a40070f57" dependencies = [ "anyhow", "ceno_emul", @@ -1907,7 +1907,7 @@ dependencies = [ [[package]] name = "ceno_keccak" version = "0.1.0" -source = "git+https://github.com/scroll-tech/ceno?branch=master#3b6aac2a76d5d5d91bdf1c056756a0b16f53f02a" +source = "git+https://github.com/scroll-tech/ceno?branch=master#fe2f215b05cae01fcdd0582ef8261b8a40070f57" dependencies = [ "ceno_syscall 0.1.0 (git+https://github.com/scroll-tech/ceno-patch?branch=main)", "tiny-keccak", @@ -1916,7 +1916,7 @@ dependencies = [ [[package]] name = "ceno_recursion" version = "0.1.0" -source = "git+https://github.com/scroll-tech/ceno?branch=master#3b6aac2a76d5d5d91bdf1c056756a0b16f53f02a" +source = "git+https://github.com/scroll-tech/ceno?branch=master#fe2f215b05cae01fcdd0582ef8261b8a40070f57" dependencies = [ "bincode 1.3.3", "ceno-examples", @@ -1959,7 +1959,7 @@ dependencies = [ [[package]] name = "ceno_rt" version = "0.1.0" -source = "git+https://github.com/scroll-tech/ceno?branch=master#3b6aac2a76d5d5d91bdf1c056756a0b16f53f02a" +source = "git+https://github.com/scroll-tech/ceno?branch=master#fe2f215b05cae01fcdd0582ef8261b8a40070f57" dependencies = [ "getrandom 0.2.16", "getrandom 0.3.3", @@ -1969,7 +1969,7 @@ dependencies = [ [[package]] name = "ceno_sha2" version = "0.1.0" -source = "git+https://github.com/scroll-tech/ceno?branch=master#3b6aac2a76d5d5d91bdf1c056756a0b16f53f02a" +source = "git+https://github.com/scroll-tech/ceno?branch=master#fe2f215b05cae01fcdd0582ef8261b8a40070f57" dependencies = [ "ceno_syscall 0.1.0 (git+https://github.com/scroll-tech/ceno-patch?branch=main)", "digest 0.10.7", @@ -1988,7 +1988,7 @@ source = "git+https://github.com/scroll-tech/ceno-patch#e6ef2986f4e5522ead8d8509 [[package]] name = "ceno_zkvm" version = "0.1.0" -source = "git+https://github.com/scroll-tech/ceno?branch=master#3b6aac2a76d5d5d91bdf1c056756a0b16f53f02a" +source = "git+https://github.com/scroll-tech/ceno?branch=master#fe2f215b05cae01fcdd0582ef8261b8a40070f57" dependencies = [ "base64 0.22.1", "bincode 1.3.3", @@ -2007,6 +2007,7 @@ dependencies = [ "gkr_iop", "glob", "itertools 0.13.0", + "metrics", "mpcs", "multilinear_extensions", "ndarray", @@ -2686,7 +2687,7 @@ dependencies = [ [[package]] name = "derive" version = "0.1.0" -source = "git+https://github.com/scroll-tech/ceno?branch=master#3b6aac2a76d5d5d91bdf1c056756a0b16f53f02a" +source = "git+https://github.com/scroll-tech/ceno?branch=master#fe2f215b05cae01fcdd0582ef8261b8a40070f57" dependencies = [ "quote", "syn 1.0.109", @@ -3657,7 +3658,7 @@ dependencies = [ [[package]] name = "gkr_iop" version = "0.1.0" -source = "git+https://github.com/scroll-tech/ceno?branch=master#3b6aac2a76d5d5d91bdf1c056756a0b16f53f02a" +source = "git+https://github.com/scroll-tech/ceno?branch=master#fe2f215b05cae01fcdd0582ef8261b8a40070f57" dependencies = [ "bincode 1.3.3", "cuda_hal", diff --git a/crates/host-bench/src/lib.rs b/crates/host-bench/src/lib.rs index 2dd14bb90..f61350f8c 100644 --- a/crates/host-bench/src/lib.rs +++ b/crates/host-bench/src/lib.rs @@ -132,6 +132,9 @@ pub struct HostArgs { #[arg(long)] pub output_dir: Option, + #[arg(long)] + pub app_vk_path: Option, + /// If specified, loads the app proving key from this path. #[arg(long)] pub app_pk_path: Option, @@ -302,6 +305,7 @@ pub async fn run_ceno_reth_benchmark(args: HostArgs) -> eyre::Result<()> { MultiProver::new(0, 1, (1 << 30) * 8 / 4 / 2, MAX_CYCLE_PER_SHARD), ); + // init app prover and app pk/vk ceno_sdk.init_base_prover(max_num_variables, security_level); info!("setup ceno sdk done in {:?}", start.elapsed()); @@ -314,6 +318,12 @@ pub async fn run_ceno_reth_benchmark(args: HostArgs) -> eyre::Result<()> { ceno_sdk.set_agg_pk(agg_pk); } + if let Some(app_vk_path) = args.app_vk_path.as_ref() { + let app_vk = read_object_from_file(app_vk_path)?; + // reset app vk + ceno_sdk.set_app_vk(app_vk); + } + let program_name = format!("reth.{}.block_{}", args.mode, args.block_number); run_with_metric_collection("OUTPUT_PATH", || { @@ -514,14 +524,17 @@ pub async fn run_ceno_reth_benchmark(args: HostArgs) -> eyre::Result<()> { BenchMode::GenerateFixtures => { // generate pk,vk if needed let _app_pk = ceno_sdk.get_app_pk(); + let app_vk = ceno_sdk.get_app_vk(); let agg_pk = ceno_sdk.init_agg_pk(); let fixture_path = args.fixtures_path.unwrap(); // TODO serialize ceno app pk - // let mut app_pk_path = fixture_path.clone(); - // app_pk_path.push("app_pk.bitcode"); - // fs::write(app_pk_path, bitcode::serialize(&app_pk)?)?; + + // serialize ceno app vk + let mut app_pk_path = fixture_path.clone(); + app_pk_path.push("app_vk.bitcode"); + fs::write(app_pk_path, bitcode::serialize(&app_vk)?)?; let mut agg_pk_path = fixture_path.clone(); agg_pk_path.push("agg_pk.bitcode"); diff --git a/reproduce.sh b/reproduce.sh index af331767f..f06116686 100755 --- a/reproduce.sh +++ b/reproduce.sh @@ -3,6 +3,17 @@ export CENO_GPU_CACHE_LEVEL=0 export RUSTFLAGS="-C target-feature=+avx2" export RUST_LOG=info,ceno_zkvm=debug +if [ -f "fixtures/app_vk.bitcode" ]; then + echo "App VK fixture already exists." +else + cargo run --features "jemalloc" --config net.git-fetch-with-cli=true \ + --bin ceno-reth-benchmark-bin --profile release -- \ + --block-number 23587691 \ + --rpc-url https://eth-mainnet.g.alchemy.com/v2/dpJmxzwalHmaOsZwAB-Djvz2N651QahS \ + --fixtures-path fixtures --cache-dir block_data --output-dir output \ + --mode generate-fixtures 2>&1 | tee fixture_generation.log +fi + # 1. generate app proof in release mode if [ -f "output/app_proof.bitcode" ]; then echo "App proof already exists, skipping generation." @@ -18,5 +29,6 @@ fi cargo run --features "jemalloc,gpu" --config net.git-fetch-with-cli=true \ --bin ceno-reth-benchmark-bin --release -- --block-number 23587691 \ --rpc-url https://eth-mainnet.g.alchemy.com/v2/dpJmxzwalHmaOsZwAB-Djvz2N651QahS \ - --cache-dir block_data --output-dir output --app-proofs output/app_proof.bitcode \ + --app-vk-path fixtures/app_vk.bitcode --app-proofs output/app_proof.bitcode \ + --cache-dir block_data --output-dir output \ --mode prove-stark-only 2>&1 | tee stark.log