Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
191 changes: 191 additions & 0 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ members = [

[[bin]]
path = "bin/reth.rs"
name = "reth"
name = "reth"
6 changes: 6 additions & 0 deletions crates/executor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,9 @@ repository = "https://github.com/foundry-rs/reth"
readme = "README.md"

[dependencies]
revm = "2.1"
reth-primitives = { path = "../primitives" }
reth-interfaces = { path = "../interfaces" }
async-trait = "0.1.57"
thiserror = "1.0.37"
anyhow = "1.0"
6 changes: 6 additions & 0 deletions crates/executor/src/cfg.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/// Configuration for executor (TODO)
#[derive(Debug, Clone)]
pub struct Config {
/// Example
pub example: bool,
}
37 changes: 37 additions & 0 deletions crates/executor/src/executor.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#![allow(missing_debug_implementations)]

use crate::Config;
use reth_interfaces::{
consensus::Consensus,
executor::{BlockExecutor, Error, ExecutorDb},
};
use reth_primitives::Block;

/// Main block executor
pub struct Executor {
/// Configuration, Spec and optional flags.
config: Config,
/// Database
db: Box<dyn ExecutorDb>,
/// Consensus
consensus: Box<dyn Consensus>,
}

impl Executor {
/// Create new Executor
pub fn new(config: Config, db: Box<dyn ExecutorDb>, consensus: Box<dyn Consensus>) -> Self {
Self { config, db, consensus }
}

/// Verify block (TODO)
pub fn verify(&self, block: &Block) -> Result<(), Error> {
// TODO example
let _ = self.consensus.validate_header(&block.header);
if self.config.example {
let _block_exist = self.db.get_block(block.header.number);
}
Err(Error::VerificationFailed)
}
}

impl BlockExecutor for Executor {}
6 changes: 6 additions & 0 deletions crates/executor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,9 @@
))]

//! Reth executor executes transaction in block of data.

mod cfg;
/// Executor
pub mod executor;

pub use cfg::Config;
3 changes: 2 additions & 1 deletion crates/interfaces/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ readme = "README.md"
[dependencies]
reth-primitives = { path = "../primitives" }
async-trait = "0.1.57"
thiserror = "1.0.37"
thiserror = "1.0.37"
auto_impl = "1.0"
21 changes: 21 additions & 0 deletions crates/interfaces/src/consensus.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
use async_trait::async_trait;
use reth_primitives::Header;
use thiserror::Error;

/// Consensus is a protocol that chooses canonical chain.
/// We are checking validity of block header here.
#[async_trait]
pub trait Consensus {
/// Validate if header is correct and follows consensus specification
fn validate_header(&self, _header: &Header) -> Result<(), Error> {
Ok(())
}
}

/// Consensus errors (TODO)
#[derive(Error, Debug)]
pub enum Error {
/// Explanatory
#[error("Example of consensus error")]
ConsensusError,
}
Loading