-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expand Prover-Client to Support Multiple ZkVm (#516)
* feat: add risc0 and sp1 as features * feat: support multiple hosts
- Loading branch information
Showing
9 changed files
with
199 additions
and
67 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,7 @@ mod prover; | |
mod proving_ops; | ||
mod rpc_server; | ||
mod task; | ||
mod zkvm; | ||
|
||
#[tokio::main] | ||
async fn main() { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
use strata_zkvm::ZkVmHost; | ||
|
||
use crate::primitives::vms::ProofVm; | ||
|
||
pub mod native; | ||
#[cfg(feature = "risc0")] | ||
pub mod risc0; | ||
#[cfg(feature = "sp1")] | ||
pub mod sp1; | ||
|
||
#[cfg(all(feature = "risc0", not(feature = "sp1")))] | ||
pub fn get_host(vm: ProofVm) -> impl ZkVmHost { | ||
risc0::get_host(vm) | ||
} | ||
|
||
#[cfg(all(feature = "sp1", not(feature = "risc0")))] | ||
pub fn get_host(vm: ProofVm) -> impl ZkVmHost { | ||
sp1::get_host(vm) | ||
} | ||
|
||
// Native Host is used if both risc0 and sp1 are disabled | ||
#[cfg(all(not(feature = "sp1"), not(feature = "risc0")))] | ||
pub fn get_host(vm: ProofVm) -> impl ZkVmHost { | ||
native::get_host(vm) | ||
} | ||
|
||
// Use SP1 if both risc0 and sp1 are enabled | ||
#[cfg(all(feature = "sp1", feature = "risc0"))] | ||
pub fn get_host(vm: ProofVm) -> impl ZkVmHost { | ||
sp1::get_host(vm) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
use std::sync::Arc; | ||
|
||
use strata_native_zkvm_adapter::{NativeHost, NativeMachine}; | ||
use strata_proofimpl_btc_blockspace::logic::process_blockspace_proof_outer; | ||
use strata_proofimpl_checkpoint::process_checkpoint_proof_outer; | ||
use strata_proofimpl_cl_agg::process_cl_agg; | ||
use strata_proofimpl_cl_stf::process_cl_stf; | ||
use strata_proofimpl_evm_ee_stf::process_block_transaction_outer; | ||
use strata_proofimpl_l1_batch::process_l1_batch_proof; | ||
|
||
/// A mock verification key used in native mode when proof verification is not performed. | ||
/// | ||
/// This constant provides a placeholder value for scenarios where a verification key is | ||
/// required by a function signature, but actual verification is skipped. | ||
const MOCK_VK: [u32; 8] = [0u32; 8]; | ||
|
||
pub fn get_host(vm: ProofVm) -> impl ZkVmHost { | ||
match vm { | ||
ProofVm::BtcProving => NativeHost { | ||
process_proof: Arc::new(Box::new(move |zkvm: &NativeMachine| { | ||
process_blockspace_proof_outer(zkvm); | ||
Ok(()) | ||
})), | ||
}, | ||
ProofVm::L1Batch => NativeHost { | ||
process_proof: Arc::new(Box::new(move |zkvm: &NativeMachine| { | ||
process_l1_batch_proof(zkvm, &MOCK_VK); | ||
Ok(()) | ||
})), | ||
}, | ||
ProofVm::ELProving => NativeHost { | ||
process_proof: Arc::new(Box::new(move |zkvm: &NativeMachine| { | ||
process_block_transaction_outer(zkvm); | ||
Ok(()) | ||
})), | ||
}, | ||
ProofVm::CLProving => NativeHost { | ||
process_proof: Arc::new(Box::new(move |zkvm: &NativeMachine| { | ||
process_cl_stf(zkvm, &MOCK_VK); | ||
Ok(()) | ||
})), | ||
}, | ||
ProofVm::CLAggregation => NativeHost { | ||
process_proof: Arc::new(Box::new(move |zkvm: &NativeMachine| { | ||
process_cl_agg(zkvm, &MOCK_VK); | ||
Ok(()) | ||
})), | ||
}, | ||
ProofVm::Checkpoint => NativeHost { | ||
process_proof: Arc::new(Box::new(move |zkvm: &NativeMachine| { | ||
process_checkpoint_proof_outer(zkvm, &MOCK_VK, &MOCK_VK); | ||
Ok(()) | ||
})), | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
use strata_risc0_adapter::Risc0Host; | ||
use strata_risc0_guest_builder::{ | ||
GUEST_RISC0_BTC_BLOCKSPACE_ELF, GUEST_RISC0_CHECKPOINT_ELF, GUEST_RISC0_CL_AGG_ELF, | ||
GUEST_RISC0_CL_STF_ELF, GUEST_RISC0_EVM_EE_STF_ELF, GUEST_RISC0_L1_BATCH_ELF, | ||
}; | ||
|
||
pub fn get_host(vm: ProofVm) -> impl ZkVmHost { | ||
match vm { | ||
ProofVm::BtcProving => Risc0Host::init(GUEST_RISC0_BTC_BLOCKSPACE_ELF), | ||
ProofVm::L1Batch => Risc0Host::init(GUEST_RISC0_L1_BATCH_ELF), | ||
ProofVm::ELProving => Risc0Host::init(GUEST_RISC0_EVM_EE_STF_ELF), | ||
ProofVm::CLProving => Risc0Host::init(GUEST_RISC0_CL_STF_ELF), | ||
ProofVm::CLAggregation => Risc0Host::init(GUEST_RISC0_CL_AGG_ELF), | ||
ProofVm::Checkpoint => Risc0Host::init(GUEST_RISC0_CHECKPOINT_ELF), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
use strata_sp1_adapter::SP1Host; | ||
use strata_sp1_guest_builder::*; | ||
use strata_zkvm::ZkVmHost; | ||
|
||
use crate::primitives::vms::ProofVm; | ||
|
||
pub fn get_host(vm: ProofVm) -> impl ZkVmHost { | ||
match vm { | ||
ProofVm::BtcProving => SP1Host::new_from_bytes( | ||
&GUEST_BTC_BLOCKSPACE_ELF, | ||
&GUEST_BTC_BLOCKSPACE_PK, | ||
&GUEST_BTC_BLOCKSPACE_VK, | ||
), | ||
ProofVm::L1Batch => SP1Host::new_from_bytes( | ||
&GUEST_BTC_BLOCKSPACE_ELF, | ||
&GUEST_BTC_BLOCKSPACE_PK, | ||
&GUEST_BTC_BLOCKSPACE_VK, | ||
), | ||
ProofVm::ELProving => SP1Host::new_from_bytes( | ||
&GUEST_EVM_EE_STF_ELF, | ||
&GUEST_EVM_EE_STF_PK, | ||
&GUEST_EVM_EE_STF_VK, | ||
), | ||
ProofVm::CLProving => { | ||
SP1Host::new_from_bytes(&GUEST_CL_STF_ELF, &GUEST_CL_STF_PK, &GUEST_CL_STF_VK) | ||
} | ||
ProofVm::CLAggregation => { | ||
SP1Host::new_from_bytes(&GUEST_CL_AGG_ELF, &GUEST_CL_AGG_PK, &GUEST_CL_AGG_VK) | ||
} | ||
ProofVm::Checkpoint => SP1Host::new_from_bytes( | ||
&GUEST_CHECKPOINT_ELF, | ||
&GUEST_CHECKPOINT_PK, | ||
&GUEST_CHECKPOINT_VK, | ||
), | ||
} | ||
} |