refactor using cargo workspaces
This commit is contained in:
parent
57ecba8fd2
commit
1d810caa92
|
@ -333,6 +333,28 @@ dependencies = [
|
||||||
"generic-array 0.14.6",
|
"generic-array 0.14.6",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "client"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"blst",
|
||||||
|
"bytes",
|
||||||
|
"common",
|
||||||
|
"consensus",
|
||||||
|
"ethers",
|
||||||
|
"execution",
|
||||||
|
"eyre",
|
||||||
|
"futures",
|
||||||
|
"hex",
|
||||||
|
"jsonrpsee",
|
||||||
|
"reqwest",
|
||||||
|
"revm",
|
||||||
|
"serde",
|
||||||
|
"ssz-rs",
|
||||||
|
"tokio",
|
||||||
|
"toml",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "coins-bip32"
|
name = "coins-bip32"
|
||||||
version = "0.7.0"
|
version = "0.7.0"
|
||||||
|
@ -390,6 +412,45 @@ dependencies = [
|
||||||
"thiserror",
|
"thiserror",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "common"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"blst",
|
||||||
|
"bytes",
|
||||||
|
"ethers",
|
||||||
|
"eyre",
|
||||||
|
"futures",
|
||||||
|
"hex",
|
||||||
|
"jsonrpsee",
|
||||||
|
"reqwest",
|
||||||
|
"revm",
|
||||||
|
"serde",
|
||||||
|
"ssz-rs",
|
||||||
|
"tokio",
|
||||||
|
"toml",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "consensus"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"blst",
|
||||||
|
"bytes",
|
||||||
|
"common",
|
||||||
|
"ethers",
|
||||||
|
"eyre",
|
||||||
|
"futures",
|
||||||
|
"hex",
|
||||||
|
"jsonrpsee",
|
||||||
|
"reqwest",
|
||||||
|
"revm",
|
||||||
|
"serde",
|
||||||
|
"ssz-rs",
|
||||||
|
"tokio",
|
||||||
|
"toml",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "const-oid"
|
name = "const-oid"
|
||||||
version = "0.9.0"
|
version = "0.9.0"
|
||||||
|
@ -791,6 +852,27 @@ version = "2.5.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0"
|
checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "execution"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"blst",
|
||||||
|
"bytes",
|
||||||
|
"common",
|
||||||
|
"consensus",
|
||||||
|
"ethers",
|
||||||
|
"eyre",
|
||||||
|
"futures",
|
||||||
|
"hex",
|
||||||
|
"jsonrpsee",
|
||||||
|
"reqwest",
|
||||||
|
"revm",
|
||||||
|
"serde",
|
||||||
|
"ssz-rs",
|
||||||
|
"tokio",
|
||||||
|
"toml",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "eyre"
|
name = "eyre"
|
||||||
version = "0.6.8"
|
version = "0.6.8"
|
||||||
|
@ -1599,6 +1681,8 @@ version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"blst",
|
"blst",
|
||||||
"bytes",
|
"bytes",
|
||||||
|
"client",
|
||||||
|
"common",
|
||||||
"ethers",
|
"ethers",
|
||||||
"eyre",
|
"eyre",
|
||||||
"futures",
|
"futures",
|
||||||
|
|
28
Cargo.toml
28
Cargo.toml
|
@ -1,21 +1,9 @@
|
||||||
[package]
|
[workspace]
|
||||||
name = "lightclient"
|
|
||||||
version = "0.1.0"
|
|
||||||
edition = "2021"
|
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
members = [
|
||||||
|
"cli",
|
||||||
[dependencies]
|
"client",
|
||||||
reqwest = { version = "0.11", features = ["json"] }
|
"common",
|
||||||
tokio = { version = "1", features = ["full"] }
|
"consensus",
|
||||||
eyre = "0.6.8"
|
"execution",
|
||||||
serde = { version = "1.0.143", features = ["derive"] }
|
]
|
||||||
hex = "0.4.3"
|
|
||||||
ssz-rs = { git = "https://github.com/ralexstokes/ssz-rs" }
|
|
||||||
blst = "0.3.10"
|
|
||||||
ethers = "0.17.0"
|
|
||||||
jsonrpsee = { version = "0.15.1", features = ["full"] }
|
|
||||||
revm = "1.9.0"
|
|
||||||
bytes = "1.2.1"
|
|
||||||
futures = "0.3.23"
|
|
||||||
toml = "0.5.9"
|
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
[package]
|
||||||
|
name = "lightclient"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
reqwest = { version = "0.11", features = ["json"] }
|
||||||
|
tokio = { version = "1", features = ["full"] }
|
||||||
|
eyre = "0.6.8"
|
||||||
|
serde = { version = "1.0.143", features = ["derive"] }
|
||||||
|
hex = "0.4.3"
|
||||||
|
ssz-rs = { git = "https://github.com/ralexstokes/ssz-rs" }
|
||||||
|
blst = "0.3.10"
|
||||||
|
ethers = "0.17.0"
|
||||||
|
jsonrpsee = { version = "0.15.1", features = ["full"] }
|
||||||
|
revm = "1.9.0"
|
||||||
|
bytes = "1.2.1"
|
||||||
|
futures = "0.3.23"
|
||||||
|
toml = "0.5.9"
|
||||||
|
|
||||||
|
client = { path = "../client" }
|
||||||
|
common = { path = "../common" }
|
|
@ -6,11 +6,6 @@ use tokio::time::sleep;
|
||||||
use client::{rpc::Rpc, Client};
|
use client::{rpc::Rpc, Client};
|
||||||
use common::config::Config;
|
use common::config::Config;
|
||||||
|
|
||||||
pub mod client;
|
|
||||||
pub mod common;
|
|
||||||
pub mod consensus;
|
|
||||||
pub mod execution;
|
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<()> {
|
async fn main() -> Result<()> {
|
||||||
let config = Config::from_file(Path::new("./configs/goerli.toml"))?;
|
let config = Config::from_file(Path::new("./configs/goerli.toml"))?;
|
|
@ -0,0 +1,25 @@
|
||||||
|
[package]
|
||||||
|
name = "client"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
reqwest = { version = "0.11", features = ["json"] }
|
||||||
|
tokio = { version = "1", features = ["full"] }
|
||||||
|
eyre = "0.6.8"
|
||||||
|
serde = { version = "1.0.143", features = ["derive"] }
|
||||||
|
hex = "0.4.3"
|
||||||
|
ssz-rs = { git = "https://github.com/ralexstokes/ssz-rs" }
|
||||||
|
blst = "0.3.10"
|
||||||
|
ethers = "0.17.0"
|
||||||
|
jsonrpsee = { version = "0.15.1", features = ["full"] }
|
||||||
|
revm = "1.9.0"
|
||||||
|
bytes = "1.2.1"
|
||||||
|
futures = "0.3.23"
|
||||||
|
toml = "0.5.9"
|
||||||
|
|
||||||
|
common = { path = "../common" }
|
||||||
|
consensus = { path = "../consensus" }
|
||||||
|
execution = { path = "../execution" }
|
|
@ -3,11 +3,11 @@ use std::sync::Arc;
|
||||||
use ethers::prelude::{Address, U256};
|
use ethers::prelude::{Address, U256};
|
||||||
use eyre::Result;
|
use eyre::Result;
|
||||||
|
|
||||||
use crate::common::config::Config;
|
use common::config::Config;
|
||||||
use crate::consensus::types::Header;
|
use consensus::types::Header;
|
||||||
use crate::consensus::ConsensusClient;
|
use consensus::ConsensusClient;
|
||||||
use crate::execution::evm::Evm;
|
use execution::evm::Evm;
|
||||||
use crate::execution::ExecutionClient;
|
use execution::ExecutionClient;
|
||||||
|
|
||||||
pub struct Client {
|
pub struct Client {
|
||||||
consensus: ConsensusClient,
|
consensus: ConsensusClient,
|
|
@ -12,7 +12,7 @@ use jsonrpsee::{
|
||||||
proc_macros::rpc,
|
proc_macros::rpc,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::common::utils::{hex_str_to_bytes, u64_to_hex_string};
|
use common::utils::{hex_str_to_bytes, u64_to_hex_string};
|
||||||
|
|
||||||
use super::Client;
|
use super::Client;
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
[package]
|
||||||
|
name = "common"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
reqwest = { version = "0.11", features = ["json"] }
|
||||||
|
tokio = { version = "1", features = ["full"] }
|
||||||
|
eyre = "0.6.8"
|
||||||
|
serde = { version = "1.0.143", features = ["derive"] }
|
||||||
|
hex = "0.4.3"
|
||||||
|
ssz-rs = { git = "https://github.com/ralexstokes/ssz-rs" }
|
||||||
|
blst = "0.3.10"
|
||||||
|
ethers = "0.17.0"
|
||||||
|
jsonrpsee = { version = "0.15.1", features = ["full"] }
|
||||||
|
revm = "1.9.0"
|
||||||
|
bytes = "1.2.1"
|
||||||
|
futures = "0.3.23"
|
||||||
|
toml = "0.5.9"
|
|
@ -1,2 +1,3 @@
|
||||||
pub mod config;
|
pub mod config;
|
||||||
|
pub mod types;
|
||||||
pub mod utils;
|
pub mod utils;
|
|
@ -0,0 +1,3 @@
|
||||||
|
use ssz_rs::Vector;
|
||||||
|
|
||||||
|
pub type Bytes32 = Vector<u8, 32>;
|
|
@ -2,7 +2,7 @@ use ethers::prelude::Address;
|
||||||
use eyre::Result;
|
use eyre::Result;
|
||||||
use ssz_rs::{Node, Vector};
|
use ssz_rs::{Node, Vector};
|
||||||
|
|
||||||
use crate::consensus::types::Bytes32;
|
use super::types::Bytes32;
|
||||||
|
|
||||||
pub fn hex_str_to_bytes(s: &str) -> Result<Vec<u8>> {
|
pub fn hex_str_to_bytes(s: &str) -> Result<Vec<u8>> {
|
||||||
let stripped = s.strip_prefix("0x").unwrap_or(s);
|
let stripped = s.strip_prefix("0x").unwrap_or(s);
|
|
@ -0,0 +1,24 @@
|
||||||
|
[package]
|
||||||
|
name = "consensus"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
reqwest = { version = "0.11", features = ["json"] }
|
||||||
|
tokio = { version = "1", features = ["full"] }
|
||||||
|
eyre = "0.6.8"
|
||||||
|
serde = { version = "1.0.143", features = ["derive"] }
|
||||||
|
hex = "0.4.3"
|
||||||
|
ssz-rs = { git = "https://github.com/ralexstokes/ssz-rs" }
|
||||||
|
blst = "0.3.10"
|
||||||
|
ethers = "0.17.0"
|
||||||
|
jsonrpsee = { version = "0.15.1", features = ["full"] }
|
||||||
|
revm = "1.9.0"
|
||||||
|
bytes = "1.2.1"
|
||||||
|
futures = "0.3.23"
|
||||||
|
toml = "0.5.9"
|
||||||
|
|
||||||
|
common = { path = "../common" }
|
||||||
|
|
|
@ -5,10 +5,12 @@ use blst::BLST_ERROR;
|
||||||
use eyre::Result;
|
use eyre::Result;
|
||||||
use ssz_rs::prelude::*;
|
use ssz_rs::prelude::*;
|
||||||
|
|
||||||
|
use common::config::Config;
|
||||||
|
use common::types::*;
|
||||||
|
use common::utils::*;
|
||||||
|
|
||||||
use super::rpc::Rpc;
|
use super::rpc::Rpc;
|
||||||
use super::types::*;
|
use super::types::*;
|
||||||
use crate::common::config::Config;
|
|
||||||
use crate::common::utils::*;
|
|
||||||
|
|
||||||
pub struct ConsensusClient {
|
pub struct ConsensusClient {
|
||||||
rpc: Rpc,
|
rpc: Rpc,
|
|
@ -2,11 +2,11 @@ use eyre::Result;
|
||||||
use serde::de::Error;
|
use serde::de::Error;
|
||||||
use ssz_rs::prelude::*;
|
use ssz_rs::prelude::*;
|
||||||
|
|
||||||
use crate::common::utils::hex_str_to_bytes;
|
use common::types::Bytes32;
|
||||||
|
use common::utils::hex_str_to_bytes;
|
||||||
|
|
||||||
pub type BLSPubKey = Vector<u8, 48>;
|
pub type BLSPubKey = Vector<u8, 48>;
|
||||||
pub type SignatureBytes = Vector<u8, 96>;
|
pub type SignatureBytes = Vector<u8, 96>;
|
||||||
pub type Bytes32 = Vector<u8, 32>;
|
|
||||||
pub type Address = Vector<u8, 20>;
|
pub type Address = Vector<u8, 20>;
|
||||||
pub type LogsBloom = Vector<u8, 256>;
|
pub type LogsBloom = Vector<u8, 256>;
|
||||||
pub type Transaction = List<u8, 1073741824>;
|
pub type Transaction = List<u8, 1073741824>;
|
|
@ -0,0 +1,24 @@
|
||||||
|
[package]
|
||||||
|
name = "execution"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
reqwest = { version = "0.11", features = ["json"] }
|
||||||
|
tokio = { version = "1", features = ["full"] }
|
||||||
|
eyre = "0.6.8"
|
||||||
|
serde = { version = "1.0.143", features = ["derive"] }
|
||||||
|
hex = "0.4.3"
|
||||||
|
ssz-rs = { git = "https://github.com/ralexstokes/ssz-rs" }
|
||||||
|
blst = "0.3.10"
|
||||||
|
ethers = "0.17.0"
|
||||||
|
jsonrpsee = { version = "0.15.1", features = ["full"] }
|
||||||
|
revm = "1.9.0"
|
||||||
|
bytes = "1.2.1"
|
||||||
|
futures = "0.3.23"
|
||||||
|
toml = "0.5.9"
|
||||||
|
|
||||||
|
common = { path = "../common" }
|
||||||
|
consensus = { path = "../consensus" }
|
|
@ -6,8 +6,9 @@ use eyre::Result;
|
||||||
use revm::{AccountInfo, Bytecode, Database, Env, TransactOut, TransactTo, EVM};
|
use revm::{AccountInfo, Bytecode, Database, Env, TransactOut, TransactTo, EVM};
|
||||||
use tokio::runtime::Runtime;
|
use tokio::runtime::Runtime;
|
||||||
|
|
||||||
|
use consensus::types::ExecutionPayload;
|
||||||
|
|
||||||
use super::ExecutionClient;
|
use super::ExecutionClient;
|
||||||
use crate::consensus::types::ExecutionPayload;
|
|
||||||
|
|
||||||
pub struct Evm {
|
pub struct Evm {
|
||||||
evm: EVM<ProofDB>,
|
evm: EVM<ProofDB>,
|
|
@ -6,11 +6,12 @@ use ethers::utils::keccak256;
|
||||||
use ethers::utils::rlp::encode;
|
use ethers::utils::rlp::encode;
|
||||||
use eyre::Result;
|
use eyre::Result;
|
||||||
|
|
||||||
|
use common::utils::hex_str_to_bytes;
|
||||||
|
use consensus::types::ExecutionPayload;
|
||||||
|
|
||||||
use super::proof::{encode_account, verify_proof};
|
use super::proof::{encode_account, verify_proof};
|
||||||
use super::rpc::Rpc;
|
use super::rpc::Rpc;
|
||||||
use super::types::Account;
|
use super::types::Account;
|
||||||
use crate::common::utils::hex_str_to_bytes;
|
|
||||||
use crate::consensus::types::ExecutionPayload;
|
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct ExecutionClient {
|
pub struct ExecutionClient {
|
|
@ -1,7 +1,7 @@
|
||||||
use ethers::utils::keccak256;
|
use ethers::utils::keccak256;
|
||||||
use ethers::utils::rlp::{decode_list, RlpStream};
|
use ethers::utils::rlp::{decode_list, RlpStream};
|
||||||
|
|
||||||
use crate::execution::types::Proof;
|
use super::types::Proof;
|
||||||
|
|
||||||
pub fn verify_proof(proof: &Vec<Vec<u8>>, root: &Vec<u8>, path: &Vec<u8>, value: &Vec<u8>) -> bool {
|
pub fn verify_proof(proof: &Vec<Vec<u8>>, root: &Vec<u8>, path: &Vec<u8>, value: &Vec<u8>) -> bool {
|
||||||
let mut expected_hash = root.clone();
|
let mut expected_hash = root.clone();
|
|
@ -7,7 +7,7 @@ use jsonrpsee::{
|
||||||
rpc_params,
|
rpc_params,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::common::utils::{address_to_hex_string, hex_str_to_bytes, u64_to_hex_string};
|
use common::utils::{address_to_hex_string, hex_str_to_bytes, u64_to_hex_string};
|
||||||
|
|
||||||
use super::types::Proof;
|
use super::types::Proof;
|
||||||
|
|
|
@ -5,7 +5,7 @@ use eyre::Result;
|
||||||
use serde::de::Error;
|
use serde::de::Error;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
|
||||||
use crate::common::utils::hex_str_to_bytes;
|
use common::utils::hex_str_to_bytes;
|
||||||
|
|
||||||
#[derive(Deserialize, Debug)]
|
#[derive(Deserialize, Debug)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
Loading…
Reference in New Issue