Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/prover.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ jobs:
ZKVM_MOCK: "1"
ZKVM_PROFILING: "1"
run: |
export ASM_PARAMS_JSON="$(cat bin/prover-perf/asm-params.json)"
cargo run --release -p strata-asm-prover-perf -- \
--post-to-gh \
--github-token "${{ secrets.GITHUB_TOKEN }}" \
Expand All @@ -68,4 +69,6 @@ jobs:
env:
ZKVM_MOCK: "1"
ZKVM_PROFILING: "1"
run: cargo run --release -p strata-asm-prover-perf -- --programs asm-stf
run: |
export ASM_PARAMS_JSON="$(cat bin/prover-perf/asm-params.json)"
cargo run --release -p strata-asm-prover-perf -- --programs asm-stf
2 changes: 1 addition & 1 deletion .justfile
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ check-github-actions-security:

# Generate reports and profiling data for proofs
prover-eval: prover-clean
cd {{prover_perf_eval_dir}} && RUST_LOG=info ZKVM_MOCK=1 ZKVM_PROFILING=1 cargo run --release -- --programs {{prover_programs}}
cd {{prover_perf_eval_dir}} && ASM_PARAMS_JSON="$(cat asm-params.json)" RUST_LOG=info ZKVM_MOCK=1 ZKVM_PROFILING=1 cargo run --release -- --programs {{prover_programs}}

# Cleans up profiling data generated by prover eval
prover-clean:
Expand Down
10 changes: 9 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ members = [
# binaries listed separately
"bin/asm-runner",
"bin/prover-perf",
"guest-builder/sp1",
]

[workspace.lints]
Expand Down
2 changes: 1 addition & 1 deletion bin/asm-runner/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ moho-runtime-impl.workspace = true
moho-runtime-interface.workspace = true
moho-types.workspace = true
strata-asm-rpc.workspace = true
strata-btc-verification.workspace = true
strata-bridge-common.workspace = true
strata-btc-verification.workspace = true

strata-asm-common.workspace = true
strata-asm-params.workspace = true
Expand Down
5 changes: 1 addition & 4 deletions bin/prover-perf/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ doc = false
[dependencies]
moho-recursive-proof = { workspace = true, features = ["test-utils"] }
strata-asm-proof-impl = { workspace = true, features = ["test-utils"] }
strata-asm-sp1-guest-builder = { path = "../../guest-builder/sp1" }

zkaleido = { workspace = true, features = ["perf"] }

Expand All @@ -29,10 +30,6 @@ reqwest = { version = "0.12.28", default-features = false, features = [
] }
serde_json.workspace = true
sp1-sdk = "5.2.1"
# FIXME: (@prajwolrg) use a proper tag
zkaleido-sp1-host = { git = "https://github.com/alpenlabs/zkaleido", tag = "v0.1.0-alpha-rc22", features = [
"perf",
] }

[build-dependencies]
sp1-build = "5.2.1"
64 changes: 64 additions & 0 deletions bin/prover-perf/asm-params.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
"magic": "ALPN",
"l1_view": {
"blk": {
"height": 50462976,
"blkid": "0405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20212223"
},
"next_target": 656811300,
"epoch_start_timestamp": 724183336,
"last_11_timestamps": [
791555372,
858927408,
926299444,
993671480,
1061043516,
1128415552,
1195787588,
1263159624,
1330531660,
1397903696,
1465275732
]
},
"subprotocols": [
{
"Admin": {
"strata_administrator": {
"keys": [
"02bedfa2fa42d906565519bee43875608a09e06640203a6c7a43569150c7cbe7c5"
],
"threshold": 1
},
"strata_sequencer_manager": {
"keys": [
"03cf59a1a5ef092ced386f2651b610d3dd2cc6806bb74a8eab95c1f3b2f3d81772",
"02343edde4a056e00af99aa49de60df03859d1b79ebbc4f3f6da8fbd0053565de3"
],
"threshold": 1
},
"confirmation_depth": 144,
"max_seqno_gap": 10
}
},
{
"Checkpoint": {
"sequencer_predicate": "Sp1Groth16",
"checkpoint_predicate": "AlwaysAccept",
"genesis_l1_height": 3334849731,
"genesis_ol_blkid": "c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6"
}
},
{
"Bridge": {
"operators": [
"02becdf7aab195ab0a42ba2f2eca5b7fa5a246267d802c627010e1672f08657f70"
],
"denomination": 0,
"assignment_duration": 0,
"operator_fee": 0,
"recovery_delay": 0
}
}
]
}
6 changes: 0 additions & 6 deletions bin/prover-perf/build.rs

This file was deleted.

11 changes: 3 additions & 8 deletions bin/prover-perf/src/programs/asm_stf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,14 @@ use std::fs;
use strata_asm_proof_impl::{
program::AsmStfProofProgram, test_utils::create_runtime_input_and_spec,
};
use strata_asm_sp1_guest_builder::ASM_ELF_PATH;
use zkaleido::{PerformanceReport, ZkVmProgramPerf};
use zkaleido_sp1_host::SP1Host;

const ASM_STF_ELF_PATH: &str = env!("SP1_ELF_guest-sp1-asm");

fn load_elf() -> Vec<u8> {
fs::read(ASM_STF_ELF_PATH)
.unwrap_or_else(|err| panic!("failed to read guest elf at {ASM_STF_ELF_PATH}: {err}"))
}

pub(crate) fn gen_perf_report() -> PerformanceReport {
let (input, _spec) = create_runtime_input_and_spec();
let elf = load_elf();
let elf = fs::read(ASM_ELF_PATH)
.unwrap_or_else(|err| panic!("failed to read guest elf at {ASM_ELF_PATH}: {err}"));
let host = SP1Host::init(&elf);
AsmStfProofProgram::perf_report(&input, &host).expect("failed to generate performance report")
}
12 changes: 4 additions & 8 deletions bin/prover-perf/src/programs/moho.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,18 @@ use moho_recursive_proof::{
test_utils::{create_input, SchnorrPredicate},
MohoRecursiveProgram,
};
use strata_asm_sp1_guest_builder::MOHO_ELF_PATH;
use zkaleido::{PerformanceReport, ZkVmProgramPerf};
use zkaleido_sp1_host::SP1Host;

const MOHO_ELF_PATH: &str = env!("SP1_ELF_guest-sp1-moho");

fn load_elf() -> Vec<u8> {
fs::read(MOHO_ELF_PATH)
.unwrap_or_else(|err| panic!("failed to read guest elf at {MOHO_ELF_PATH}: {err}"))
}

pub(crate) fn gen_perf_report() -> PerformanceReport {
// TODO(STR-2797): Use Groth16Predicate instead of SchnorrPredicate
let moho = SchnorrPredicate::new();
let step = SchnorrPredicate::new();
let input = create_input(1, 2, None, &moho, &step);
let elf = load_elf();

let elf = fs::read(MOHO_ELF_PATH)
.unwrap_or_else(|err| panic!("failed to read guest elf at {MOHO_ELF_PATH}: {err}"));
let host = SP1Host::init(&elf);
MohoRecursiveProgram::perf_report(&input, &host).expect("failed to generate performance report")
}
27 changes: 26 additions & 1 deletion crates/params/src/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ use serde::{Deserialize, Serialize};
use strata_btc_types::GenesisL1View;
use strata_l1_txfmt::MagicBytes;

use crate::subprotocols::SubprotocolInstance;
use crate::subprotocols::{
AdministrationInitConfig, BridgeV1InitConfig, CheckpointInitConfig, SubprotocolInstance,
};

/// Top-level parameters for an ASM instance.
///
Expand All @@ -23,6 +25,29 @@ pub struct AsmParams {
pub subprotocols: Vec<SubprotocolInstance>,
}

impl AsmParams {
pub fn admin_config(&self) -> Option<&AdministrationInitConfig> {
self.subprotocols.iter().find_map(|s| match s {
SubprotocolInstance::Admin(cfg) => Some(cfg),
_ => None,
})
}

pub fn bridge_config(&self) -> Option<&BridgeV1InitConfig> {
self.subprotocols.iter().find_map(|s| match s {
SubprotocolInstance::Bridge(cfg) => Some(cfg),
_ => None,
})
}

pub fn checkpoint_config(&self) -> Option<&CheckpointInitConfig> {
self.subprotocols.iter().find_map(|s| match s {
SubprotocolInstance::Checkpoint(cfg) => Some(cfg),
_ => None,
})
}
}

#[cfg(feature = "arbitrary")]
impl<'a> Arbitrary<'a> for AsmParams {
fn arbitrary(u: &mut Unstructured<'a>) -> arbitrary::Result<Self> {
Expand Down
7 changes: 7 additions & 0 deletions crates/spec/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,10 @@ strata-asm-proto-administration.workspace = true
strata-asm-proto-bridge-v1.workspace = true
strata-asm-proto-checkpoint.workspace = true
strata-l1-txfmt.workspace = true

[target.'cfg(target_os = "zkvm")'.dependencies]
serde_json.workspace = true

[build-dependencies]
serde_json.workspace = true
strata-asm-params.workspace = true
23 changes: 23 additions & 0 deletions crates/spec/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
use std::env;

use strata_asm_params::AsmParams;

fn main() {
println!("cargo::rerun-if-env-changed=ASM_PARAMS_JSON");

let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap_or_default();
if target_os != "zkvm" {
return;
}

let json = match env::var("ASM_PARAMS_JSON") {
Ok(v) => v,
Err(_) => {
panic!("ASM_PARAMS_JSON env var must be set when building for target_os = zkvm");
}
};

// Validate the JSON deserializes into a valid AsmParams.
let _: AsmParams =
serde_json::from_str(&json).expect("ASM_PARAMS_JSON does not deserialize into AsmParams");
}
Loading
Loading