Skip to content

Commit

Permalink
verifiable_api in config and usage
Browse files Browse the repository at this point in the history
  • Loading branch information
eshaan7 committed Feb 11, 2025
1 parent 9be23d5 commit c99886f
Show file tree
Hide file tree
Showing 22 changed files with 590 additions and 370 deletions.
9 changes: 9 additions & 0 deletions cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ struct EthereumArgs {
#[clap(short, long, env, value_parser = parse_url)]
execution_rpc: Option<Url>,
#[clap(short, long, env, value_parser = parse_url)]
verifiable_api: Option<Url>,
#[clap(short, long, env, value_parser = parse_url)]
consensus_rpc: Option<Url>,
#[clap(short, long, env)]
data_dir: Option<String>,
Expand Down Expand Up @@ -163,6 +165,7 @@ impl EthereumArgs {
CliConfig {
checkpoint: self.checkpoint,
execution_rpc: self.execution_rpc.clone(),
verifiable_api: self.verifiable_api.clone(),
consensus_rpc: self.consensus_rpc.clone(),
data_dir: self
.data_dir
Expand All @@ -188,6 +191,8 @@ struct OpStackArgs {
#[clap(short, long, env, value_parser = parse_url)]
execution_rpc: Option<Url>,
#[clap(short, long, env, value_parser = parse_url)]
verifiable_api: Option<Url>,
#[clap(short, long, env, value_parser = parse_url)]
consensus_rpc: Option<Url>,
#[clap(
short = 'w',
Expand Down Expand Up @@ -227,6 +232,10 @@ impl OpStackArgs {
user_dict.insert("execution_rpc", Value::from(rpc.to_string()));
}

if let Some(api) = &self.verifiable_api {
user_dict.insert("verifiable_api", Value::from(api.to_string()));
}

if let Some(rpc) = &self.consensus_rpc {
user_dict.insert("consensus_rpc", Value::from(rpc.to_string()));
}
Expand Down
3 changes: 2 additions & 1 deletion core/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ pub struct Client<N: NetworkSpec, C: Consensus<N::BlockResponse>> {
impl<N: NetworkSpec, C: Consensus<N::BlockResponse>> Client<N, C> {
pub fn new(
execution_rpc: &str,
verifiable_api: Option<&str>,
consensus: C,
fork_schedule: ForkSchedule,
#[cfg(not(target_arch = "wasm32"))] rpc_address: Option<SocketAddr>,
) -> Result<Self> {
let node = Node::new(execution_rpc, consensus, fork_schedule)?;
let node = Node::new(execution_rpc, verifiable_api, consensus, fork_schedule)?;
let node = Arc::new(node);

#[cfg(not(target_arch = "wasm32"))]
Expand Down
6 changes: 4 additions & 2 deletions core/src/client/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use alloy::rpc::types::{Filter, FilterChanges, Log, SyncInfo, SyncStatus};
use eyre::{eyre, Result};

use helios_common::{fork_schedule::ForkSchedule, network_spec::NetworkSpec, types::BlockTag};
use helios_verifiable_api_client::VerifiableApiClient;

use crate::consensus::Consensus;
use crate::errors::ClientError;
Expand All @@ -18,14 +19,15 @@ use crate::time::{SystemTime, UNIX_EPOCH};

pub struct Node<N: NetworkSpec, C: Consensus<N::BlockResponse>> {
pub consensus: C,
pub execution: Arc<ExecutionClient<N, HttpRpc<N>>>,
pub execution: Arc<ExecutionClient<N, HttpRpc<N>, VerifiableApiClient>>,
pub history_size: usize,
fork_schedule: ForkSchedule,
}

impl<N: NetworkSpec, C: Consensus<N::BlockResponse>> Node<N, C> {
pub fn new(
execution_rpc: &str,
verifiable_api: Option<&str>,
mut consensus: C,
fork_schedule: ForkSchedule,
) -> Result<Self, ClientError> {
Expand All @@ -34,7 +36,7 @@ impl<N: NetworkSpec, C: Consensus<N::BlockResponse>> Node<N, C> {

let state = State::new(block_recv, finalized_block_recv, 256, execution_rpc);
let execution = Arc::new(
ExecutionClient::new(execution_rpc, state, fork_schedule)
ExecutionClient::new(execution_rpc, verifiable_api, state, fork_schedule)
.map_err(ClientError::InternalError)?,
);

Expand Down
23 changes: 0 additions & 23 deletions core/src/execution/client/mod.rs

This file was deleted.

27 changes: 14 additions & 13 deletions core/src/execution/evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use alloy::{
};
use eyre::{Report, Result};
use futures::future::join_all;
use helios_verifiable_api_client::VerifiableApi;
use revm::{
primitives::{
address, AccessListItem, AccountInfo, Address, Bytecode, Bytes, Env, ExecutionResult,
Expand All @@ -24,16 +25,16 @@ use crate::execution::{
ExecutionClient,
};

pub struct Evm<N: NetworkSpec, R: ExecutionRpc<N>> {
execution: Arc<ExecutionClient<N, R>>,
pub struct Evm<N: NetworkSpec, R: ExecutionRpc<N>, A: VerifiableApi<N>> {
execution: Arc<ExecutionClient<N, R, A>>,
chain_id: u64,
tag: BlockTag,
fork_schedule: ForkSchedule,
}

impl<N: NetworkSpec, R: ExecutionRpc<N>> Evm<N, R> {
impl<N: NetworkSpec, R: ExecutionRpc<N>, A: VerifiableApi<N>> Evm<N, R, A> {
pub fn new(
execution: Arc<ExecutionClient<N, R>>,
execution: Arc<ExecutionClient<N, R, A>>,
chain_id: u64,
fork_schedule: ForkSchedule,
tag: BlockTag,
Expand Down Expand Up @@ -119,12 +120,12 @@ impl<N: NetworkSpec, R: ExecutionRpc<N>> Evm<N, R> {
}
}

struct ProofDB<N: NetworkSpec, R: ExecutionRpc<N>> {
state: EvmState<N, R>,
struct ProofDB<N: NetworkSpec, R: ExecutionRpc<N>, A: VerifiableApi<N>> {
state: EvmState<N, R, A>,
}

impl<N: NetworkSpec, R: ExecutionRpc<N>> ProofDB<N, R> {
pub fn new(tag: BlockTag, execution: Arc<ExecutionClient<N, R>>) -> Self {
impl<N: NetworkSpec, R: ExecutionRpc<N>, A: VerifiableApi<N>> ProofDB<N, R, A> {
pub fn new(tag: BlockTag, execution: Arc<ExecutionClient<N, R, A>>) -> Self {
let state = EvmState::new(execution.clone(), tag);
ProofDB { state }
}
Expand All @@ -136,17 +137,17 @@ enum StateAccess {
Storage(Address, U256),
}

struct EvmState<N: NetworkSpec, R: ExecutionRpc<N>> {
struct EvmState<N: NetworkSpec, R: ExecutionRpc<N>, A: VerifiableApi<N>> {
basic: HashMap<Address, AccountInfo>,
block_hash: HashMap<u64, B256>,
storage: HashMap<Address, HashMap<U256, U256>>,
block: BlockTag,
access: Option<StateAccess>,
execution: Arc<ExecutionClient<N, R>>,
execution: Arc<ExecutionClient<N, R, A>>,
}

impl<N: NetworkSpec, R: ExecutionRpc<N>> EvmState<N, R> {
pub fn new(execution: Arc<ExecutionClient<N, R>>, block: BlockTag) -> Self {
impl<N: NetworkSpec, R: ExecutionRpc<N>, A: VerifiableApi<N>> EvmState<N, R, A> {
pub fn new(execution: Arc<ExecutionClient<N, R, A>>, block: BlockTag) -> Self {
Self {
execution,
block,
Expand Down Expand Up @@ -324,7 +325,7 @@ impl<N: NetworkSpec, R: ExecutionRpc<N>> EvmState<N, R> {
}
}

impl<N: NetworkSpec, R: ExecutionRpc<N>> Database for ProofDB<N, R> {
impl<N: NetworkSpec, R: ExecutionRpc<N>, A: VerifiableApi<N>> Database for ProofDB<N, R, A> {
type Error = Report;

fn basic(&mut self, address: Address) -> Result<Option<AccountInfo>, Report> {
Expand Down
Loading

0 comments on commit c99886f

Please sign in to comment.