-
Notifications
You must be signed in to change notification settings - Fork 344
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 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
- Loading branch information
Showing
99 changed files
with
17,544 additions
and
1,595 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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")), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.