Skip to content

Commit

Permalink
draft no std
Browse files Browse the repository at this point in the history
  • Loading branch information
ratankaliani committed Sep 17, 2024
1 parent 0cc5a34 commit ce6ffa1
Show file tree
Hide file tree
Showing 49 changed files with 204 additions and 153 deletions.
59 changes: 32 additions & 27 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 7 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ tree_hash = "0.7.0"
sha2 = "0.9"
bls12_381 = { version = "0.8.0", features = ["experimental"] }

anyhow = { version = "1.0", default-features = false }

# execution
alloy = { version = "0.2.1", features = [
"rpc-types",
Expand All @@ -43,14 +45,14 @@ alloy = { version = "0.2.1", features = [
"sol-types",
"network",
"ssz",
]}
] }
revm = { version = "12.1.0", default-features = false, features = [
"std",
"serde",
"optional_block_gas_limit",
"optional_eip3607",
"optional_no_base_fee",
]}
] }
triehash-ethereum = { git = "https://github.com/openethereum/parity-ethereum", rev = "55c90d4016505317034e3e98f699af07f5404b63" }

# async/futures
Expand All @@ -60,16 +62,16 @@ tokio = { version = "1", features = ["rt", "sync", "macros"] }

# io
reqwest = { version = "0.12.4", features = ["json"] }
serde = { version = "1.0.143", features = ["derive"] }
serde = { version = "1.0.143", features = ["derive"], default-features = false }
serde_json = "1.0.85"

# misc
eyre = "0.6.8"
hex = "0.4.3"
toml = "0.5.9"
tracing = "0.1.37"
chrono = "0.4.23"
thiserror = "1.0.37"
thiserror = { version = "1.0.37", default-features = false }
thiserror-no-std = "2.0.2"
superstruct = "0.7.0"
openssl = { version = "0.10", features = ["vendored"] }
zduny-wasm-timer = "0.2.8"
Expand All @@ -96,7 +98,6 @@ serde = { version = "1.0.154", features = ["derive"] }
[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
alloy = { version = "0.2.1", features = ["full"] }
tokio = { version = "1", features = ["full"] }
eyre = "0.6.8"
dirs = "5.0.1"
tracing-subscriber = { version = "0.3.17", features = ["env-filter"] }
tracing = "0.1.37"
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ use std::{path::PathBuf, str::FromStr, env};

use helios::{client::ClientBuilder, config::networks::Network, types::BlockTag, prelude::*};
use alloy::primitives::{utils, Address};
use eyre::Result;
use anyhow::Result;

#[tokio::main]
async fn main() -> Result<()> {
Expand Down Expand Up @@ -136,7 +136,7 @@ Below we demonstrate fetching checkpoints from the community-maintained list of
> This is a community-maintained list and thus no security guarantees are provided. Attacks on your light client can occur if malicious checkpoints are set in the list. Please use the explicit `checkpoint` flag, environment variable, or config setting with an updated, and verified checkpoint.
```rust
use eyre::Result;
use anyhow::Result;
use helios::config::{checkpoints, networks};

#[tokio::main]
Expand Down
12 changes: 6 additions & 6 deletions benches/harness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use std::{path::PathBuf, str::FromStr};
/// The `build` method will fetch a list of [CheckpointFallbackService](config::CheckpointFallbackService)s from a community-mainained list by ethPandaOps.
/// This list is NOT guaranteed to be secure, but is provided in good faith.
/// The raw list can be found here: https://github.com/ethpandaops/checkpoint-sync-health-checks/blob/master/_data/endpoints.yaml
pub async fn fetch_mainnet_checkpoint() -> eyre::Result<B256> {
pub async fn fetch_mainnet_checkpoint() -> anyhow::Result<B256> {
let cf = config::CheckpointFallback::new().build().await.unwrap();
cf.fetch_latest_checkpoint(&networks::Network::MAINNET)
.await
Expand All @@ -26,11 +26,11 @@ pub async fn fetch_mainnet_checkpoint() -> eyre::Result<B256> {
/// The client is parameterized with a [FileDB](client::FileDB).
/// It will also use the environment variable `MAINNET_EXECUTION_RPC` to connect to a mainnet node.
/// The client will use `https://www.lightclientdata.org` as the consensus RPC.
pub fn construct_mainnet_client(rt: &tokio::runtime::Runtime) -> eyre::Result<Client<FileDB>> {
pub fn construct_mainnet_client(rt: &tokio::runtime::Runtime) -> anyhow::Result<Client<FileDB>> {
rt.block_on(inner_construct_mainnet_client())
}

pub async fn inner_construct_mainnet_client() -> eyre::Result<Client<FileDB>> {
pub async fn inner_construct_mainnet_client() -> anyhow::Result<Client<FileDB>> {
let benchmark_rpc_url = std::env::var("MAINNET_EXECUTION_RPC")?;
let mut client = client::ClientBuilder::new()
.network(networks::Network::MAINNET)
Expand All @@ -45,7 +45,7 @@ pub async fn inner_construct_mainnet_client() -> eyre::Result<Client<FileDB>> {

pub async fn construct_mainnet_client_with_checkpoint(
checkpoint: B256,
) -> eyre::Result<Client<FileDB>> {
) -> anyhow::Result<Client<FileDB>> {
let benchmark_rpc_url = std::env::var("MAINNET_EXECUTION_RPC")?;
let mut client = client::ClientBuilder::new()
.network(networks::Network::MAINNET)
Expand Down Expand Up @@ -75,7 +75,7 @@ pub fn construct_runtime() -> tokio::runtime::Runtime {
/// The client is parameterized with a [FileDB](client::FileDB).
/// It will also use the environment variable `GOERLI_EXECUTION_RPC` to connect to a mainnet node.
/// The client will use `http://testing.prater.beacon-api.nimbus.team` as the consensus RPC.
pub fn construct_goerli_client(rt: &tokio::runtime::Runtime) -> eyre::Result<Client<FileDB>> {
pub fn construct_goerli_client(rt: &tokio::runtime::Runtime) -> anyhow::Result<Client<FileDB>> {
rt.block_on(async {
let benchmark_rpc_url = std::env::var("GOERLI_EXECUTION_RPC")?;
let mut client = client::ClientBuilder::new()
Expand All @@ -94,7 +94,7 @@ pub fn get_balance(
rt: &tokio::runtime::Runtime,
client: Client<FileDB>,
address: &str,
) -> eyre::Result<U256> {
) -> anyhow::Result<U256> {
rt.block_on(async {
let block = BlockTag::Latest;
let address = Address::from_str(address)?;
Expand Down
2 changes: 1 addition & 1 deletion cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ path = "src/main.rs"

[dependencies]
tokio.workspace = true
eyre.workspace = true
anyhow.workspace = true
tracing.workspace = true
futures.workspace = true
alloy.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::{
use alloy::primitives::B256;
use clap::Parser;
use dirs::home_dir;
use eyre::Result;
use anyhow::Result;
use futures::executor::block_on;
use tracing::{error, info};
use tracing_subscriber::filter::{EnvFilter, LevelFilter};
Expand Down
2 changes: 1 addition & 1 deletion client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ edition = "2021"

[dependencies]
alloy.workspace = true
eyre.workspace = true
anyhow.workspace = true
serde.workspace = true
hex.workspace = true
futures.workspace = true
Expand Down
4 changes: 2 additions & 2 deletions client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use alloy::primitives::{Address, Bytes, B256, U256};
use alloy::rpc::types::{
Filter, Log, SyncStatus, Transaction, TransactionReceipt, TransactionRequest,
};
use eyre::{eyre, Result};
use anyhow::{anyhow, Result};
use tracing::{info, warn};
use zduny_wasm_timer::Delay;

Expand Down Expand Up @@ -112,7 +112,7 @@ impl ClientBuilder {
let config = self
.config
.as_ref()
.ok_or(eyre!("missing network config"))?;
.ok_or(anyhow!("missing network config"))?;
config.to_base_config()
};

Expand Down
2 changes: 1 addition & 1 deletion client/src/errors.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use eyre::Report;
use anyhow::Report;

Check failure on line 1 in client/src/errors.rs

View workflow job for this annotation

GitHub Actions / check

unresolved import `anyhow::Report`

Check failure on line 1 in client/src/errors.rs

View workflow job for this annotation

GitHub Actions / test

unresolved import `anyhow::Report`
use thiserror::Error;

use common::errors::BlockNotFoundError;
Expand Down
4 changes: 2 additions & 2 deletions client/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use alloy::primitives::{Address, Bytes, B256, U256};
use alloy::rpc::types::{
Filter, Log, SyncInfo, SyncStatus, Transaction, TransactionReceipt, TransactionRequest,
};
use eyre::{eyre, Result};
use anyhow::{anyhow, Result};
use zduny_wasm_timer::{SystemTime, UNIX_EPOCH};

use common::types::{Block, BlockTag};
Expand Down Expand Up @@ -119,7 +119,7 @@ impl<DB: Database> Node<DB> {
let value = account.slots.get(&slot);
match value {
Some(value) => Ok(*value),
None => Err(eyre!("slot not found")),
None => Err(anyhow!("slot not found")),
}
}

Expand Down
2 changes: 1 addition & 1 deletion client/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use alloy::primitives::{Address, Bytes, B256, U256, U64};
use alloy::rpc::types::{
Filter, Log, SyncStatus, Transaction, TransactionReceipt, TransactionRequest,
};
use eyre::Result;
use anyhow::Result;
use jsonrpsee::{
core::{async_trait, server::Methods, Error},
proc_macros::rpc,
Expand Down
3 changes: 2 additions & 1 deletion common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ edition = "2021"

[dependencies]
alloy = { version = "0.2.1", features = ["rpc-types"] }
eyre.workspace = true
anyhow.workspace = true
serde.workspace = true
hex.workspace = true
serde_json.workspace = true
superstruct.workspace = true
thiserror.workspace = true
thiserror-no-std.workspace = true
tracing.workspace = true
zduny-wasm-timer.workspace = true
Loading

0 comments on commit ce6ffa1

Please sign in to comment.