Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
6c1ffa1
feat: init verifiable-api crate
eshaan7 Feb 5, 2025
5d5f77b
handle empty account or storage value in proof verification
eshaan7 Feb 7, 2025
9f9f7d2
fixup
eshaan7 Feb 7, 2025
b69a235
impl get_filter_logs handler
eshaan7 Feb 6, 2025
821965b
fix merge conflicts
eshaan7 Feb 7, 2025
5a15742
impl more methods
eshaan7 Feb 7, 2025
8409eb7
impl get_logs, lots of refactor
eshaan7 Feb 7, 2025
249f1af
single account endpoint
eshaan7 Feb 10, 2025
265f7f3
remove redundant Get from response types
eshaan7 Feb 10, 2025
66bc83f
divide into server, client, types crates
eshaan7 Feb 10, 2025
b293b3f
new common crate to avoid cyclic deps
eshaan7 Feb 11, 2025
9be23d5
merge with master
eshaan7 Feb 11, 2025
c99886f
verifiable_api in config and usage
eshaan7 Feb 11, 2025
86fac3b
impl create_access_list
eshaan7 Feb 12, 2025
1040329
add wasm binding for eth_getStorageAt
eshaan7 Feb 13, 2025
657e0ef
fix getAccount storage, getLogs
eshaan7 Feb 13, 2025
96ac664
fix getAccount storage, getLogs
eshaan7 Feb 14, 2025
27403c8
make it work with opstack
eshaan7 Feb 14, 2025
918d397
fix merge conflicts with master
eshaan7 Feb 17, 2025
0b49b92
fix receipt proof logic
eshaan7 Feb 17, 2025
d638b79
replace MAX_SUPPORTED_LOGS_NUMBER with MAX_SUPPORTED_BLOCKS_TO_PROVE_…
eshaan7 Feb 17, 2025
85488e7
fix clippy warns
eshaan7 Feb 17, 2025
3b5d425
some cleanup & add usage in README
eshaan7 Feb 18, 2025
0218b4a
update cli args & README.md
eshaan7 Feb 19, 2025
0fffb5f
move logic from handlers to ApiService
eshaan7 Feb 20, 2025
236a905
impl all used methods in verifiable api
eshaan7 Feb 21, 2025
aea9141
make new traits wasm compat
eshaan7 Feb 21, 2025
77dbd28
add get_block and make code optional
eshaan7 Feb 22, 2025
57702b0
use camelCase in paths for consistency
eshaan7 Feb 22, 2025
c21754f
handle error in VerifiableApiClient
eshaan7 Feb 24, 2025
9864ba5
refactor with ExecutionInner & dyn dispatch
eshaan7 Feb 24, 2025
07caf4f
address review comments
eshaan7 Feb 25, 2025
c044a83
refactor with new ExecutionSpec trait
eshaan7 Feb 25, 2025
f043d11
tests for ApiService & ExecutionInnerClient
eshaan7 Feb 26, 2025
adbbf6b
refactor into VerifiableApiServer struct
eshaan7 Feb 27, 2025
656ef89
also test verifiable-api in rpc_equivalance tests
eshaan7 Feb 27, 2025
2aa2511
fix merge conflicts with master
eshaan7 Feb 27, 2025
3848111
fix clippy, update README
eshaan7 Feb 27, 2025
bd2243e
support transaction_detail_flag in get_block
eshaan7 Feb 27, 2025
10090e7
fix code_hash verification
eshaan7 Feb 28, 2025
4e005ab
impl create_access_list in Evm
eshaan7 Feb 28, 2025
0b5f4bb
fix merge conflicts with master
eshaan7 Mar 2, 2025
6cefbd8
expose eth_createAccessList, block param in eth_estimateGas
eshaan7 Mar 3, 2025
099f993
expose eth_getProof in RPC
eshaan7 Mar 3, 2025
5206b89
address review comments
eshaan7 Mar 6, 2025
46ea202
doc-strings, openapi.yaml and handler for same
eshaan7 Mar 6, 2025
767e897
Merge branch 'master' into feat/verifiable-api
eshaan7 Mar 6, 2025
0f4711e
fix err handling in Evm.create_access_list
eshaan7 Mar 7, 2025
77b838d
validateTx flag in createExtendedAccessList
eshaan7 Mar 7, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,754 changes: 1,106 additions & 648 deletions Cargo.lock

Large diffs are not rendered by default.

13 changes: 11 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,16 @@ exclude = ["benches"]
[workspace]
members = [
"cli",
"common",
"core",
"ethereum",
"ethereum/consensus-core",
"opstack",
"helios-ts",
"tests/test-utils", # ToDo(@eshaan7): find a better way to include this
"verifiable-api/client",
"verifiable-api/server",
"verifiable-api/types",
]

default-members = ["cli"]
Expand Down Expand Up @@ -83,14 +88,18 @@ typenum = "1.17.0"
######################################

[dependencies]
helios-common = { path = "./common" }
helios-core = { path = "./core" }
helios-ethereum = { path = "./ethereum" }
helios-opstack = { path = "./opstack" }

[dev-dependencies]
tokio = { version = "1", features = ["full"] }
tokio.workspace = true
futures.workspace = true
url.workspace = true
serde.workspace = true
dotenv = "0.15.0"
serde = { version = "1.0.154", features = ["derive"] }
helios-verifiable-api-server = { path = "verifiable-api/server" }

[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
alloy = { version = "0.9.1", features = ["full"] }
Expand Down
6 changes: 4 additions & 2 deletions benches/get_balance.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use std::str::FromStr;

use alloy::primitives::Address;
use criterion::{criterion_group, criterion_main, Criterion};
use helios_core::types::BlockTag;
use std::str::FromStr;

use helios_common::types::BlockTag;

mod harness;

Expand Down
6 changes: 4 additions & 2 deletions benches/get_code.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use std::str::FromStr;

use alloy::primitives::Address;
use criterion::{criterion_group, criterion_main, Criterion};
use helios_core::types::BlockTag;
use std::str::FromStr;

use helios_common::types::BlockTag;

mod harness;

Expand Down
6 changes: 4 additions & 2 deletions benches/harness.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
#![allow(dead_code)]
use std::{path::PathBuf, str::FromStr};

use alloy::primitives::{Address, B256, U256};
use helios_core::types::BlockTag;

use helios_common::types::BlockTag;
use helios_ethereum::{
config::{checkpoints, networks},
database::FileDB,
EthereumClient, EthereumClientBuilder,
};
use std::{path::PathBuf, str::FromStr};

/// Fetches the latest mainnet checkpoint from the fallback service.
///
Expand Down
3 changes: 2 additions & 1 deletion benches/sync.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use alloy::primitives::Address;
use criterion::{criterion_group, criterion_main, Criterion};
use helios_core::types::BlockTag;

use helios_common::types::BlockTag;

mod harness;

Expand Down
2 changes: 2 additions & 0 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ dirs = "5.0.1"
ctrlc = "3.2.3"
url = "2.5.0"

# self crates
helios-common = { path = "../common" }
helios-core = { path = "../core" }
helios-ethereum = { path = "../ethereum" }
helios-opstack = { path = "../opstack" }
20 changes: 15 additions & 5 deletions cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,18 @@ use eyre::Result;
use figment::providers::Serialized;
use figment::value::Value;
use futures::executor::block_on;
use tracing::{error, info};
use tracing_subscriber::filter::{EnvFilter, LevelFilter};
use tracing_subscriber::FmtSubscriber;
use url::Url;

use helios_common::network_spec::NetworkSpec;
use helios_core::client::Client;
use helios_core::consensus::Consensus;
use helios_core::network_spec::NetworkSpec;
use helios_ethereum::config::{cli::CliConfig, Config as EthereumConfig};
use helios_ethereum::database::FileDB;
use helios_ethereum::{EthereumClient, EthereumClientBuilder};
use helios_opstack::{config::Config as OpStackConfig, OpStackClient, OpStackClientBuilder};
use tracing::{error, info};
use tracing_subscriber::filter::{EnvFilter, LevelFilter};
use tracing_subscriber::FmtSubscriber;
use url::Url;

#[tokio::main]
async fn main() -> Result<()> {
Expand Down Expand Up @@ -128,6 +129,8 @@ struct EthereumArgs {
checkpoint: Option<B256>,
#[clap(short, long, env, value_parser = parse_url)]
execution_rpc: Option<Url>,
#[clap(long, env, value_parser = parse_url)]
execution_verifiable_api: Option<Url>,
#[clap(short, long, env, value_parser = parse_url)]
consensus_rpc: Option<Url>,
#[clap(short, long, env)]
Expand Down Expand Up @@ -162,6 +165,7 @@ impl EthereumArgs {
CliConfig {
checkpoint: self.checkpoint,
execution_rpc: self.execution_rpc.clone(),
execution_verifiable_api: self.execution_verifiable_api.clone(),
consensus_rpc: self.consensus_rpc.clone(),
data_dir: self
.data_dir
Expand All @@ -186,6 +190,8 @@ struct OpStackArgs {
rpc_port: Option<u16>,
#[clap(short, long, env, value_parser = parse_url)]
execution_rpc: Option<Url>,
#[clap(long, env, value_parser = parse_url)]
execution_verifiable_api: Option<Url>,
#[clap(short, long, env, value_parser = parse_url)]
consensus_rpc: Option<Url>,
#[clap(
Expand Down Expand Up @@ -226,6 +232,10 @@ impl OpStackArgs {
user_dict.insert("execution_rpc", Value::from(rpc.to_string()));
}

if let Some(api) = &self.execution_verifiable_api {
user_dict.insert("execution_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
11 changes: 11 additions & 0 deletions common/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[package]
name = "helios-common"
version = "0.1.0"
edition = "2021"

[dependencies]
alloy.workspace = true
serde.workspace = true
serde_json.workspace = true
revm.workspace = true
eyre.workspace = true
16 changes: 16 additions & 0 deletions common/src/execution_mode.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#[derive(Clone)]
pub enum ExecutionMode {
Rpc(String),
VerifiableApi(String),
}

impl ExecutionMode {
pub fn from_urls(rpc: Option<String>, verifiable_api: Option<String>) -> Self {
match (rpc, verifiable_api) {
// we prioritize verifiable_api over rpc
(_, Some(verifiable_api)) => Self::VerifiableApi(verifiable_api),
(Some(rpc), None) => Self::Rpc(rpc),
(None, None) => panic!("Must specify either execution_rpc or execution_verifiable_api"),
}
}
}
File renamed without changes.
4 changes: 4 additions & 0 deletions common/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
pub mod execution_mode;
pub mod fork_schedule;
pub mod network_spec;
pub mod types;
File renamed without changes.
126 changes: 126 additions & 0 deletions common/src/types.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
use std::fmt::Display;

use alloy::{
consensus::Account as TrieAccount,
eips::{BlockId, BlockNumberOrTag},
primitives::{Bytes, B256, U256},
rpc::types::EIP1186StorageProof,
};
use eyre::{eyre, Report, Result};
use serde::{de::Error, Deserialize, Serialize};

#[derive(Default, Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct Account {
pub account: TrieAccount,
#[serde(skip_serializing_if = "Option::is_none")]
pub code: Option<Bytes>,
pub account_proof: Vec<Bytes>,
pub storage_proof: Vec<EIP1186StorageProof>,
}

impl Account {
/// Retrieve the value at the given storage slot.
pub fn get_storage_value(&self, slot: B256) -> Option<U256> {
self.storage_proof
.iter()
.find_map(|EIP1186StorageProof { key, value, .. }| {
if key.as_b256() == slot {
Some(*value)
} else {
None
}
})
}
}

#[derive(Debug, Clone, Copy)]
pub enum BlockTag {
Latest,
Finalized,
Number(u64),
}

impl From<u64> for BlockTag {
fn from(num: u64) -> Self {
BlockTag::Number(num)
}
}

impl Display for BlockTag {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let formatted = match self {
Self::Latest => "latest".to_string(),
Self::Finalized => "finalized".to_string(),
Self::Number(num) => num.to_string(),
};

write!(f, "{formatted}")
}
}

impl<'de> Deserialize<'de> for BlockTag {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
let block: String = serde::Deserialize::deserialize(deserializer)?;
let parse_error = D::Error::custom("could not parse block tag");

let block_tag = match block.as_str() {
"latest" => BlockTag::Latest,
"finalized" => BlockTag::Finalized,
_ => match block.strip_prefix("0x") {
Some(hex_block) => {
let num = u64::from_str_radix(hex_block, 16).map_err(|_| parse_error)?;

BlockTag::Number(num)
}
None => {
let num = block.parse().map_err(|_| parse_error)?;

BlockTag::Number(num)
}
},
};

Ok(block_tag)
}
}

impl From<BlockTag> for BlockId {
fn from(block_tag: BlockTag) -> Self {
match block_tag {
BlockTag::Latest => BlockId::latest(),
BlockTag::Finalized => BlockId::finalized(),
BlockTag::Number(num) => BlockId::Number(num.into()),
}
}
}

impl TryFrom<BlockNumberOrTag> for BlockTag {
type Error = Report;

fn try_from(tag: BlockNumberOrTag) -> Result<Self, Self::Error> {
match tag {
BlockNumberOrTag::Number(num) => Ok(BlockTag::Number(num)),
BlockNumberOrTag::Latest => Ok(BlockTag::Latest),
BlockNumberOrTag::Finalized => Ok(BlockTag::Finalized),
other => Err(eyre!("block tag {other} is not supported")),
}
}
}

impl TryFrom<BlockId> for BlockTag {
type Error = Report;

fn try_from(block_id: BlockId) -> Result<Self, Self::Error> {
match block_id {
BlockId::Number(BlockNumberOrTag::Number(num)) => Ok(BlockTag::Number(num)),
BlockId::Number(BlockNumberOrTag::Latest) => Ok(BlockTag::Latest),
BlockId::Number(BlockNumberOrTag::Finalized) => Ok(BlockTag::Finalized),
BlockId::Number(other) => Err(eyre!("block tag {other} is not supported")),
BlockId::Hash(_) => Err(eyre!("block hash is not supported")),
}
}
}
8 changes: 8 additions & 0 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ version = "0.8.2"
edition = "2021"

[dependencies]
# self crates
helios-common = { path = "../common" }
helios-verifiable-api-client = { path = "../verifiable-api/client" }

# execution
alloy.workspace = true
alloy-trie.workspace = true
Expand Down Expand Up @@ -36,3 +40,7 @@ wasmtimer = "0.2.0"

[target.wasm32-unknown-unknown.dependencies]
parking_lot = { version = "0.12.2" }

[dev-dependencies]
helios-test-utils = { path = "../tests/test-utils" }
helios-ethereum = { path = "../ethereum" }
Loading
Loading