Skip to content

Commit

Permalink
chore(repo): merge updates from main
Browse files Browse the repository at this point in the history
  • Loading branch information
petarvujovic98 committed May 25, 2024
1 parent 3a9bf8d commit f8011b4
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 48 deletions.
26 changes: 0 additions & 26 deletions core/src/interfaces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use alloy_primitives::{Address, B256};
use clap::{Args, ValueEnum};
use raiko_lib::{
input::{GuestInput, GuestOutput},
protocol_instance::ProtocolInstance,
prover::{Proof, Prover, ProverError},
};
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -124,31 +123,6 @@ impl FromStr for ProofType {
}

impl ProofType {
/// Get the instance hash for the protocol instance depending on the proof type.
pub fn instance_hash(&self, pi: ProtocolInstance) -> RaikoResult<B256> {
match self {
ProofType::Native => Ok(NativeProver::instance_hash(pi)),
ProofType::Sp1 => {
#[cfg(feature = "sp1")]
return Ok(sp1_driver::Sp1Prover::instance_hash(pi));

Err(RaikoError::FeatureNotSupportedError(self.clone()))
}
ProofType::Risc0 => {
#[cfg(feature = "risc0")]
return Ok(risc0_driver::Risc0Prover::instance_hash(pi));

Err(RaikoError::FeatureNotSupportedError(self.clone()))
}
ProofType::Sgx => {
#[cfg(feature = "sgx")]
return Ok(sgx_prover::SgxProver::instance_hash(pi));

Err(RaikoError::FeatureNotSupportedError(self.clone()))
}
}
}

/// Run the prover driver depending on the proof type.
pub async fn run_prover(
&self,
Expand Down
9 changes: 3 additions & 6 deletions core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ use alloy_primitives::{Address, FixedBytes};
use alloy_rpc_types::EIP1186AccountProofResponse;
use raiko_lib::{
builder::{BlockBuilderStrategy, TaikoStrategy},
consts::ChainSpec,
consts::{ChainSpec, VerifierType},
input::{GuestInput, GuestOutput, TaikoProverData},
protocol_instance::assemble_protocol_instance,
protocol_instance::ProtocolInstance,
prover::Proof,
utils::HeaderHasher,
};
Expand Down Expand Up @@ -69,10 +69,7 @@ impl Raiko {
info!("Verifying final state using provider data ...");
info!("Final block hash derived successfully. {}", header.hash());
info!("Final block header derived successfully. {header:?}");
let pi = self
.request
.proof_type
.instance_hash(assemble_protocol_instance(input, &header)?)?;
let pi = ProtocolInstance::new(input, &header, VerifierType::None)?.instance_hash();

// Check against the expected value of all fields for easy debugability
let exp = &input.block_header_reference;
Expand Down
10 changes: 3 additions & 7 deletions core/src/prover.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use alloy_primitives::B256;
use raiko_lib::{
consts::VerifierType,
input::{GuestInput, GuestOutput},
protocol_instance::{assemble_protocol_instance, ProtocolInstance},
protocol_instance::ProtocolInstance,
prover::{to_proof, Proof, Prover, ProverError, ProverResult},
};
use serde::{Deserialize, Serialize};
Expand All @@ -26,15 +26,11 @@ impl Prover for NativeProver {
return Err(ProverError::GuestError("Unexpected output".to_owned()));
};

assemble_protocol_instance(&input, &header)
ProtocolInstance::new(&input, &header, VerifierType::None)
.map_err(|e| ProverError::GuestError(e.to_string()))?;

to_proof(Ok(NativeResponse {
output: output.clone(),
}))
}

fn instance_hash(_pi: ProtocolInstance) -> B256 {
B256::default()
}
}
4 changes: 1 addition & 3 deletions host/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,7 @@ impl ProverState {
opts.merge_from_file()?;

let chain_specs = if let Some(cs_path) = &opts.chain_spec_path {
let chain_specs = SupportedChainSpecs::merge_from_file(cs_path.clone())
.unwrap_or(SupportedChainSpecs::default());
chain_specs
SupportedChainSpecs::merge_from_file(cs_path.clone()).unwrap_or_default()
} else {
SupportedChainSpecs::default()
};
Expand Down
6 changes: 4 additions & 2 deletions lib/src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,18 @@ const DEFAULT_CHAIN_SPECS: &str = include_str!("../../host/config/chain_spec_lis
#[derive(Clone, Debug)]
pub struct SupportedChainSpecs(HashMap<String, ChainSpec>);

impl SupportedChainSpecs {
pub fn default() -> Self {
impl Default for SupportedChainSpecs {
fn default() -> Self {
let deserialized: Vec<ChainSpec> = serde_json::from_str(DEFAULT_CHAIN_SPECS).unwrap();
let chain_spec_list = deserialized
.iter()
.map(|cs| (cs.name.clone(), cs.clone()))
.collect::<HashMap<String, ChainSpec>>();
SupportedChainSpecs(chain_spec_list)
}
}

impl SupportedChainSpecs {
#[cfg(feature = "std")]
pub fn merge_from_file(file_path: PathBuf) -> Result<SupportedChainSpecs> {
let mut known_chain_specs = SupportedChainSpecs::default();
Expand Down
7 changes: 3 additions & 4 deletions lib/src/protocol_instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,12 @@ impl ProtocolInstance {
.collect::<Vec<_>>();

let gas_limit: u64 = header.gas_limit.try_into().unwrap();
let verifier_address = input
let verifier_address = (*input
.chain_spec
.verifier_address
.get(&proof_type)
.unwrap_or(&None)
.clone()
.unwrap_or_default();
.unwrap_or(&None))
.unwrap_or_default();

let pi = ProtocolInstance {
transition: Transition {
Expand Down

0 comments on commit f8011b4

Please sign in to comment.