Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Champii committed Jun 11, 2024
1 parent cc58586 commit 0cadcfb
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 32 deletions.
4 changes: 2 additions & 2 deletions core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ use raiko_lib::{
utils::HeaderHasher,
};
use serde_json::Value;
use std::{collections::HashMap, hint::black_box};
use std::{collections::BTreeMap, hint::black_box};
use tracing::{debug, error, info, warn};

pub mod interfaces;
pub mod preflight;
pub mod prover;
pub mod provider;

pub type MerkleProof = HashMap<Address, EIP1186AccountProofResponse>;
pub type MerkleProof = BTreeMap<Address, EIP1186AccountProofResponse>;

pub struct Raiko {
l1_chain_spec: ChainSpec,
Expand Down
2 changes: 1 addition & 1 deletion core/src/preflight.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use raiko_lib::{
Measurement,
};
use serde::{Deserialize, Serialize};
use std::{collections::{HashSet, BTreeSet}, sync::Arc};
use std::{collections::BTreeSet, sync::Arc};
use tracing::{debug, info, warn};

pub async fn preflight<BDP: BlockDataProvider>(
Expand Down
2 changes: 1 addition & 1 deletion host/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub mod interfaces;
pub mod metrics;
pub mod server;

use std::{alloc, collections::BTreeMap, path::PathBuf};
use std::{alloc, path::PathBuf};

use anyhow::Context;
use cap::Cap;
Expand Down
1 change: 0 additions & 1 deletion lib/src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ 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;

Expand Down
11 changes: 6 additions & 5 deletions lib/src/primitives/mpt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use core::{
fmt::{Debug, Write},
iter, mem,
};
use std::collections::BTreeMap;

use alloy_primitives::{b256, TxNumber, B256, U256};
use alloy_rlp::Encodable;
Expand Down Expand Up @@ -1032,15 +1033,15 @@ pub fn shorten_node_path(node: &MptNode) -> Vec<MptNode> {

pub fn proofs_to_tries(
state_root: B256,
parent_proofs: HashMap<Address, EIP1186AccountProofResponse>,
proofs: HashMap<Address, EIP1186AccountProofResponse>,
) -> Result<(MptNode, HashMap<Address, StorageEntry>)> {
parent_proofs: BTreeMap<Address, EIP1186AccountProofResponse>,
proofs: BTreeMap<Address, EIP1186AccountProofResponse>,
) -> Result<(MptNode, BTreeMap<Address, StorageEntry>)> {
// if no addresses are provided, return the trie only consisting of the state root
if parent_proofs.is_empty() {
return Ok((node_from_digest(state_root), HashMap::new()));
return Ok((node_from_digest(state_root), BTreeMap::new()));
}

let mut storage: HashMap<Address, StorageEntry> = HashMap::with_capacity(parent_proofs.len());
let mut storage: BTreeMap<Address, StorageEntry> = BTreeMap::new();

let mut state_nodes = HashMap::new();
let mut state_root_node = MptNode::default();
Expand Down
11 changes: 0 additions & 11 deletions provers/sp1/driver/src/distributed/prover.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
use std::env;

use super::worker::Worker;
use alloy_primitives::B256;
use alloy_sol_types::SolValue;
use raiko_lib::{
input::{GuestInput, GuestOutput},
protocol_instance::ProtocolInstance,
prover::{to_proof, Proof, Prover, ProverConfig, ProverResult},
};
use sha3::{self, Digest};
use sp1_sdk::{ProverClient, SP1Stdin};

use crate::{Sp1Response, ELF};
Expand Down Expand Up @@ -36,13 +32,6 @@ impl Prover for Sp1DistributedProver {

return Self::run_as_orchestrator(input, output, &config).await;
}

fn instance_hash(pi: ProtocolInstance) -> B256 {
let data = (pi.transition.clone(), pi.prover, pi.meta_hash()).abi_encode();

let hash: [u8; 32] = sha3::Keccak256::digest(data).into();
hash.into()
}
}

impl Sp1DistributedProver {
Expand Down
11 changes: 0 additions & 11 deletions provers/sp1/driver/src/local.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
use std::env;

use alloy_primitives::B256;
use alloy_sol_types::SolValue;
use raiko_lib::{
input::{GuestInput, GuestOutput},
protocol_instance::ProtocolInstance,
prover::{to_proof, Proof, Prover, ProverConfig, ProverResult},
};
use sha3::{self, Digest};
use sp1_sdk::{ProverClient, SP1Stdin};

use crate::{Sp1Response, ELF};
Expand Down Expand Up @@ -54,11 +50,4 @@ impl Prover for Sp1Prover {
output,
}))
}

fn instance_hash(pi: ProtocolInstance) -> B256 {
let data = (pi.transition.clone(), pi.prover, pi.meta_hash()).abi_encode();

let hash: [u8; 32] = sha3::Keccak256::digest(data).into();
hash.into()
}
}

0 comments on commit 0cadcfb

Please sign in to comment.