Skip to content

Commit 5dc4fde

Browse files
authored
feat: verifiable-api (#505)
* feat: init verifiable-api crate * handle empty account or storage value in proof verification * fixup * impl get_filter_logs handler * impl more methods * impl get_logs, lots of refactor * single account endpoint * remove redundant Get from response types * divide into server, client, types crates * new common crate to avoid cyclic deps * verifiable_api in config and usage * impl create_access_list * add wasm binding for eth_getStorageAt * fix getAccount storage, getLogs * make it work with opstack * fix receipt proof logic * replace MAX_SUPPORTED_LOGS_NUMBER with MAX_SUPPORTED_BLOCKS_TO_PROVE_FOR_LOGS * fix clippy warns * some cleanup & add usage in README * update cli args & README.md * move logic from handlers to ApiService * impl all used methods in verifiable api * make new traits wasm compat * add get_block and make code optional * use camelCase in paths for consistency * handle error in VerifiableApiClient * refactor with ExecutionInner & dyn dispatch * address review comments * refactor with new ExecutionSpec trait * tests for ApiService & ExecutionInnerClient * refactor into VerifiableApiServer struct * also test verifiable-api in rpc_equivalance tests * fix clippy, update README * support transaction_detail_flag in get_block * fix code_hash verification * impl create_access_list in Evm * expose eth_createAccessList, block param in eth_estimateGas * expose eth_getProof in RPC * address review comments * doc-strings, openapi.yaml and handler for same * fix err handling in Evm.create_access_list * validateTx flag in createExtendedAccessList
1 parent e52d85a commit 5dc4fde

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+17544
-1595
lines changed

Cargo.lock

Lines changed: 1106 additions & 648 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,16 @@ exclude = ["benches"]
88
[workspace]
99
members = [
1010
"cli",
11+
"common",
1112
"core",
1213
"ethereum",
1314
"ethereum/consensus-core",
1415
"opstack",
1516
"helios-ts",
17+
"tests/test-utils", # ToDo(@eshaan7): find a better way to include this
18+
"verifiable-api/client",
19+
"verifiable-api/server",
20+
"verifiable-api/types",
1621
]
1722

1823
default-members = ["cli"]
@@ -83,14 +88,18 @@ typenum = "1.17.0"
8388
######################################
8489

8590
[dependencies]
91+
helios-common = { path = "./common" }
8692
helios-core = { path = "./core" }
8793
helios-ethereum = { path = "./ethereum" }
8894
helios-opstack = { path = "./opstack" }
8995

9096
[dev-dependencies]
91-
tokio = { version = "1", features = ["full"] }
97+
tokio.workspace = true
98+
futures.workspace = true
99+
url.workspace = true
100+
serde.workspace = true
92101
dotenv = "0.15.0"
93-
serde = { version = "1.0.154", features = ["derive"] }
102+
helios-verifiable-api-server = { path = "verifiable-api/server" }
94103

95104
[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
96105
alloy = { version = "0.9.1", features = ["full"] }

benches/get_balance.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
use std::str::FromStr;
2+
13
use alloy::primitives::Address;
24
use criterion::{criterion_group, criterion_main, Criterion};
3-
use helios_core::types::BlockTag;
4-
use std::str::FromStr;
5+
6+
use helios_common::types::BlockTag;
57

68
mod harness;
79

benches/get_code.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
use std::str::FromStr;
2+
13
use alloy::primitives::Address;
24
use criterion::{criterion_group, criterion_main, Criterion};
3-
use helios_core::types::BlockTag;
4-
use std::str::FromStr;
5+
6+
use helios_common::types::BlockTag;
57

68
mod harness;
79

benches/harness.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
#![allow(dead_code)]
2+
use std::{path::PathBuf, str::FromStr};
3+
24
use alloy::primitives::{Address, B256, U256};
3-
use helios_core::types::BlockTag;
5+
6+
use helios_common::types::BlockTag;
47
use helios_ethereum::{
58
config::{checkpoints, networks},
69
database::FileDB,
710
EthereumClient, EthereumClientBuilder,
811
};
9-
use std::{path::PathBuf, str::FromStr};
1012

1113
/// Fetches the latest mainnet checkpoint from the fallback service.
1214
///

benches/sync.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use alloy::primitives::Address;
22
use criterion::{criterion_group, criterion_main, Criterion};
3-
use helios_core::types::BlockTag;
3+
4+
use helios_common::types::BlockTag;
45

56
mod harness;
67

cli/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ dirs = "5.0.1"
2121
ctrlc = "3.2.3"
2222
url = "2.5.0"
2323

24+
# self crates
25+
helios-common = { path = "../common" }
2426
helios-core = { path = "../core" }
2527
helios-ethereum = { path = "../ethereum" }
2628
helios-opstack = { path = "../opstack" }

cli/src/main.rs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,18 @@ use eyre::Result;
1515
use figment::providers::Serialized;
1616
use figment::value::Value;
1717
use futures::executor::block_on;
18+
use tracing::{error, info};
19+
use tracing_subscriber::filter::{EnvFilter, LevelFilter};
20+
use tracing_subscriber::FmtSubscriber;
21+
use url::Url;
22+
23+
use helios_common::network_spec::NetworkSpec;
1824
use helios_core::client::Client;
1925
use helios_core::consensus::Consensus;
20-
use helios_core::network_spec::NetworkSpec;
2126
use helios_ethereum::config::{cli::CliConfig, Config as EthereumConfig};
2227
use helios_ethereum::database::FileDB;
2328
use helios_ethereum::{EthereumClient, EthereumClientBuilder};
2429
use helios_opstack::{config::Config as OpStackConfig, OpStackClient, OpStackClientBuilder};
25-
use tracing::{error, info};
26-
use tracing_subscriber::filter::{EnvFilter, LevelFilter};
27-
use tracing_subscriber::FmtSubscriber;
28-
use url::Url;
2930

3031
#[tokio::main]
3132
async fn main() -> Result<()> {
@@ -128,6 +129,8 @@ struct EthereumArgs {
128129
checkpoint: Option<B256>,
129130
#[clap(short, long, env, value_parser = parse_url)]
130131
execution_rpc: Option<Url>,
132+
#[clap(long, env, value_parser = parse_url)]
133+
execution_verifiable_api: Option<Url>,
131134
#[clap(short, long, env, value_parser = parse_url)]
132135
consensus_rpc: Option<Url>,
133136
#[clap(short, long, env)]
@@ -162,6 +165,7 @@ impl EthereumArgs {
162165
CliConfig {
163166
checkpoint: self.checkpoint,
164167
execution_rpc: self.execution_rpc.clone(),
168+
execution_verifiable_api: self.execution_verifiable_api.clone(),
165169
consensus_rpc: self.consensus_rpc.clone(),
166170
data_dir: self
167171
.data_dir
@@ -186,6 +190,8 @@ struct OpStackArgs {
186190
rpc_port: Option<u16>,
187191
#[clap(short, long, env, value_parser = parse_url)]
188192
execution_rpc: Option<Url>,
193+
#[clap(long, env, value_parser = parse_url)]
194+
execution_verifiable_api: Option<Url>,
189195
#[clap(short, long, env, value_parser = parse_url)]
190196
consensus_rpc: Option<Url>,
191197
#[clap(
@@ -226,6 +232,10 @@ impl OpStackArgs {
226232
user_dict.insert("execution_rpc", Value::from(rpc.to_string()));
227233
}
228234

235+
if let Some(api) = &self.execution_verifiable_api {
236+
user_dict.insert("execution_verifiable_api", Value::from(api.to_string()));
237+
}
238+
229239
if let Some(rpc) = &self.consensus_rpc {
230240
user_dict.insert("consensus_rpc", Value::from(rpc.to_string()));
231241
}

common/Cargo.toml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[package]
2+
name = "helios-common"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
[dependencies]
7+
alloy.workspace = true
8+
serde.workspace = true
9+
serde_json.workspace = true
10+
revm.workspace = true
11+
eyre.workspace = true

common/src/execution_mode.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#[derive(Clone)]
2+
pub enum ExecutionMode {
3+
Rpc(String),
4+
VerifiableApi(String),
5+
}
6+
7+
impl ExecutionMode {
8+
pub fn from_urls(rpc: Option<String>, verifiable_api: Option<String>) -> Self {
9+
match (rpc, verifiable_api) {
10+
// we prioritize verifiable_api over rpc
11+
(_, Some(verifiable_api)) => Self::VerifiableApi(verifiable_api),
12+
(Some(rpc), None) => Self::Rpc(rpc),
13+
(None, None) => panic!("Must specify either execution_rpc or execution_verifiable_api"),
14+
}
15+
}
16+
}

0 commit comments

Comments
 (0)