Skip to content

Commit

Permalink
clippy & fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
CeciliaZ030 committed Jun 22, 2024
1 parent 142da60 commit 78514e4
Show file tree
Hide file tree
Showing 6 changed files with 108 additions and 110 deletions.
15 changes: 8 additions & 7 deletions core/src/interfaces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ use crate::{merge, prover::NativeProver};
use alloy_primitives::{Address, B256};
use clap::{Args, ValueEnum};
use raiko_lib::{
input::{GuestInput, GuestOutput}, primitives::eip4844::proof_of_equivalence, prover::{Proof, Prover, ProverError}
input::{GuestInput, GuestOutput},
prover::{Proof, Prover, ProverError},
};
use serde::{Deserialize, Serialize};
use serde_json::Value;
Expand Down Expand Up @@ -136,8 +137,8 @@ impl ProofType {
{
output.proof_of_equivalence = proof_of_equivalence(input);
return sp1_driver::Sp1Prover::run(input, output, config)
.await
.map_err(|e| e.into());
.await
.map_err(|e| e.into());
}
#[cfg(not(feature = "sp1"))]
Err(RaikoError::FeatureNotSupportedError(self.clone()))
Expand All @@ -147,8 +148,8 @@ impl ProofType {
{
output.proof_of_equivalence = proof_of_equivalence(input);
return risc0_driver::Risc0Prover::run(input, output, config)
.await
.map_err(|e| e.into());
.await
.map_err(|e| e.into());
}
#[cfg(not(feature = "risc0"))]
Err(RaikoError::FeatureNotSupportedError(self.clone()))
Expand All @@ -159,8 +160,8 @@ impl ProofType {
// Sgx guest runs proof_of_version_hash
output.proof_of_equivalence = None;
return sgx_prover::SgxProver::run(input, output, config)
.await
.map_err(|e| e.into());
.await
.map_err(|e| e.into());
}
#[cfg(not(feature = "sgx"))]
Err(RaikoError::FeatureNotSupportedError(self.clone()))
Expand Down
10 changes: 7 additions & 3 deletions core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,11 @@ impl Raiko {
)?;

// proof_of_equivalence is generated depending on prover type
let output = GuestOutput { header, hash: pi, proof_of_equivalence: None };
let output = GuestOutput {
header,
hash: pi,
proof_of_equivalence: None,
};

Ok(output)
}
Expand Down Expand Up @@ -293,9 +297,9 @@ mod tests {
let proof_type = get_proof_type_from_env();
// Skip test on SP1 for now because it's too slow on CI
if !(is_ci() && proof_type == ProofType::Sp1) {
let network = Network::Ethereum.to_string();
let network = Network::TaikoMainnet.to_string();
let l1_network = Network::Ethereum.to_string();
let block_number = 19707175;
let block_number = 88970;
let taiko_chain_spec = SupportedChainSpecs::default()
.get_chain_spec(&network)
.unwrap();
Expand Down
22 changes: 10 additions & 12 deletions core/src/preflight.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ use raiko_lib::{
TaikoProverData,
},
primitives::{
self, eip4844::{self, get_kzg_proof_commitment, set_commitment_proof, MAINNET_KZG_TRUSTED_SETUP, KzgField, KzgGroup},
mpt::proofs_to_tries
eip4844::{self, set_commitment_proof, MAINNET_KZG_TRUSTED_SETUP},
mpt::proofs_to_tries,
},
utils::{generate_transactions, to_header, zlib_compress_data},
Measurement,
};
use serde::{Deserialize, Serialize};
use std::{collections::HashSet, sync::Arc};
use std::collections::HashSet;
use tracing::{debug, info, warn};

pub async fn preflight<BDP: BlockDataProvider>(
Expand Down Expand Up @@ -294,13 +294,11 @@ async fn prepare_taiko_chain_input(
let blob = get_blob_data(&beacon_rpc_url, slot_id, blob_hash).await?;

let kzg_settings = eip4844::MAINNET_KZG_TRUSTED_SETUP.as_ref().clone();
let (proof, commitment) = eip4844::get_kzg_proof_commitment(&blob, &kzg_settings)
.map_err(|e| anyhow!(e))?;
set_commitment_proof(&proof, &commitment)
.map_err(|e| anyhow!(e))?;

(blob, Some(blob_hash), Some(kzg_settings))
let (proof, commitment) =
eip4844::get_kzg_proof_commitment(&blob, &kzg_settings).map_err(|e| anyhow!(e))?;
set_commitment_proof(&proof, &commitment).map_err(|e| anyhow!(e))?;

(blob, Some(blob_hash), Some(kzg_settings))
} else {
// Get the tx list data directly from the propose transaction data
let proposal_call = proposeBlockCall::abi_decode(&proposal_tx.input, false)
Expand Down Expand Up @@ -367,10 +365,10 @@ fn preflight_blob_versioned_hash(blob_str: &str) -> [u8; 32] {
let kzg_settings = MAINNET_KZG_TRUSTED_SETUP.as_ref();
let blob = Blob::from_bytes(&blob_bytes).expect("Could not create blob");
let commitment = eip4844::blob_to_kzg_commitment_rust(
&eip4844::deserialize_blob_rust(&blob).expect("Could not deserialize blob"),
kzg_settings
&eip4844::deserialize_blob_rust(&blob).expect("Could not deserialize blob"),
kzg_settings,
)
.expect("Could not create kzg commitment from blob");
.expect("Could not create kzg commitment from blob");
let version_hash: [u8; 32] = eip4844::commitment_to_version_hash(&commitment.to_bytes()).0;
version_hash
}
Expand Down
4 changes: 2 additions & 2 deletions lib/src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ use core::fmt::Debug;
#[cfg(feature = "std")]
use std::path::PathBuf;

use crate::primitives::eip4844::{KzgField, TaikoKzgSettings};
use alloy_consensus::Header as AlloyConsensusHeader;
use alloy_rpc_types::Withdrawal as AlloyWithdrawal;
use alloy_sol_types::{sol, SolCall};
use anyhow::{anyhow, Result};
use revm::primitives::HashMap;
use serde::{Deserialize, Serialize};
use serde_with::serde_as;
use crate::primitives::eip4844::{KzgField, TaikoKzgSettings};

#[cfg(not(feature = "std"))]
use crate::no_std::*;
Expand Down Expand Up @@ -112,7 +112,7 @@ pub struct GuestOutput {
#[serde_as(as = "RlpHexBytes")]
pub header: AlloyConsensusHeader,
pub hash: B256,
pub proof_of_equivalence: Option<KzgField>
pub proof_of_equivalence: Option<KzgField>,
}

sol! {
Expand Down
Loading

0 comments on commit 78514e4

Please sign in to comment.