mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
refactor: split consensus crate (#1814)
This commit is contained in:
15
Cargo.lock
generated
15
Cargo.lock
generated
@ -4569,7 +4569,7 @@ dependencies = [
|
||||
"metrics-exporter-prometheus",
|
||||
"metrics-util",
|
||||
"proptest",
|
||||
"reth-consensus",
|
||||
"reth-beacon-consensus",
|
||||
"reth-db",
|
||||
"reth-discv4",
|
||||
"reth-downloaders",
|
||||
@ -4598,6 +4598,16 @@ dependencies = [
|
||||
"tui",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "reth-beacon-consensus"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"reth-consensus-common",
|
||||
"reth-interfaces",
|
||||
"reth-primitives",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "reth-codecs"
|
||||
version = "0.1.0"
|
||||
@ -4614,7 +4624,7 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "reth-consensus"
|
||||
name = "reth-consensus-common"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"assert_matches",
|
||||
@ -4622,7 +4632,6 @@ dependencies = [
|
||||
"reth-interfaces",
|
||||
"reth-primitives",
|
||||
"reth-provider",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
[workspace]
|
||||
members = [
|
||||
"bin/reth",
|
||||
"crates/consensus",
|
||||
"crates/consensus/beacon",
|
||||
"crates/consensus/common",
|
||||
"crates/executor",
|
||||
"crates/interfaces",
|
||||
"crates/metrics/metrics-derive",
|
||||
|
||||
@ -16,7 +16,7 @@ reth-staged-sync = { path = "../../crates/staged-sync" }
|
||||
reth-stages = { path = "../../crates/stages"}
|
||||
reth-interfaces = { path = "../../crates/interfaces", features = ["test-utils"] }
|
||||
reth-transaction-pool = { path = "../../crates/transaction-pool", features = ["test-utils"] }
|
||||
reth-consensus = { path = "../../crates/consensus" }
|
||||
reth-beacon-consensus = { path = "../../crates/consensus/beacon" }
|
||||
reth-executor = { path = "../../crates/executor" }
|
||||
reth-rpc-engine-api = { path = "../../crates/rpc/rpc-engine-api" }
|
||||
reth-rpc-builder = { path = "../../crates/rpc/rpc-builder" }
|
||||
|
||||
@ -5,7 +5,7 @@ use crate::{
|
||||
use clap::{crate_version, Parser};
|
||||
use eyre::Context;
|
||||
use futures::{Stream, StreamExt};
|
||||
use reth_consensus::beacon::BeaconConsensus;
|
||||
use reth_beacon_consensus::BeaconConsensus;
|
||||
use reth_db::mdbx::{Env, WriteMap};
|
||||
use reth_downloaders::{
|
||||
bodies::bodies::BodiesDownloaderBuilder,
|
||||
|
||||
@ -13,7 +13,7 @@ use events::NodeEvent;
|
||||
use eyre::Context;
|
||||
use fdlimit::raise_fd_limit;
|
||||
use futures::{pin_mut, stream::select as stream_select, Stream, StreamExt};
|
||||
use reth_consensus::beacon::BeaconConsensus;
|
||||
use reth_beacon_consensus::BeaconConsensus;
|
||||
use reth_db::{
|
||||
database::Database,
|
||||
mdbx::{Env, WriteMap},
|
||||
|
||||
@ -7,7 +7,7 @@ use crate::{
|
||||
prometheus_exporter,
|
||||
};
|
||||
use clap::{Parser, ValueEnum};
|
||||
use reth_consensus::beacon::BeaconConsensus;
|
||||
use reth_beacon_consensus::BeaconConsensus;
|
||||
use reth_downloaders::bodies::bodies::BodiesDownloaderBuilder;
|
||||
use reth_primitives::ChainSpec;
|
||||
use reth_provider::{ShareableDatabase, Transaction};
|
||||
|
||||
@ -1,22 +0,0 @@
|
||||
[package]
|
||||
name = "reth-consensus"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
license = "MIT OR Apache-2.0"
|
||||
repository = "https://github.com/paradigmxyz/reth"
|
||||
readme = "README.md"
|
||||
|
||||
[dependencies]
|
||||
# reth
|
||||
reth-primitives = { path = "../primitives" }
|
||||
reth-interfaces = { path = "../interfaces" }
|
||||
reth-provider = { path = "../storage/provider" }
|
||||
|
||||
# async
|
||||
tokio = { version = "1", features = ["sync"] }
|
||||
|
||||
[dev-dependencies]
|
||||
reth-interfaces = { path = "../interfaces", features = ["test-utils"] }
|
||||
reth-provider = { path = "../storage/provider", features = ["test-utils"] }
|
||||
assert_matches = "1.5.0"
|
||||
mockall = "0.11.3"
|
||||
19
crates/consensus/beacon/Cargo.toml
Normal file
19
crates/consensus/beacon/Cargo.toml
Normal file
@ -0,0 +1,19 @@
|
||||
[package]
|
||||
name = "reth-beacon-consensus"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
license = "MIT OR Apache-2.0"
|
||||
repository = "https://github.com/paradigmxyz/reth"
|
||||
readme = "README.md"
|
||||
|
||||
[dependencies]
|
||||
# reth
|
||||
reth-consensus-common = { path = "../common" }
|
||||
reth-primitives = { path = "../../primitives" }
|
||||
reth-interfaces = { path = "../../interfaces" }
|
||||
|
||||
# async
|
||||
tokio = { version = "1", features = ["sync"] }
|
||||
|
||||
[dev-dependencies]
|
||||
reth-interfaces = { path = "../../interfaces", features = ["test-utils"] }
|
||||
@ -1,9 +1,8 @@
|
||||
//! Consensus for ethereum network
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::validation;
|
||||
use reth_consensus_common::validation;
|
||||
use reth_interfaces::consensus::{Consensus, ConsensusError, ForkchoiceState};
|
||||
use reth_primitives::{ChainSpec, Hardfork, SealedBlock, SealedHeader, EMPTY_OMMER_ROOT, U256};
|
||||
use std::sync::Arc;
|
||||
use tokio::sync::watch;
|
||||
|
||||
use super::BeaconConsensusBuilder;
|
||||
13
crates/consensus/beacon/src/lib.rs
Normal file
13
crates/consensus/beacon/src/lib.rs
Normal file
@ -0,0 +1,13 @@
|
||||
#![warn(missing_docs, unreachable_pub, unused_crate_dependencies)]
|
||||
#![deny(unused_must_use, rust_2018_idioms)]
|
||||
#![doc(test(
|
||||
no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))
|
||||
))]
|
||||
//! Beacon consensus implementation.
|
||||
|
||||
mod beacon_consensus;
|
||||
mod builder;
|
||||
|
||||
pub use beacon_consensus::BeaconConsensus;
|
||||
pub use builder::BeaconConsensusBuilder;
|
||||
20
crates/consensus/common/Cargo.toml
Normal file
20
crates/consensus/common/Cargo.toml
Normal file
@ -0,0 +1,20 @@
|
||||
[package]
|
||||
name = "reth-consensus-common"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
license = "MIT OR Apache-2.0"
|
||||
repository = "https://github.com/paradigmxyz/reth"
|
||||
readme = "README.md"
|
||||
|
||||
[dependencies]
|
||||
# reth
|
||||
reth-primitives = { path = "../../primitives" }
|
||||
reth-interfaces = { path = "../../interfaces" }
|
||||
reth-provider = { path = "../../storage/provider" }
|
||||
|
||||
|
||||
[dev-dependencies]
|
||||
reth-interfaces = { path = "../../interfaces", features = ["test-utils"] }
|
||||
reth-provider = { path = "../../storage/provider", features = ["test-utils"] }
|
||||
assert_matches = "1.5.0"
|
||||
mockall = "0.11.3"
|
||||
@ -4,10 +4,8 @@
|
||||
no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))
|
||||
))]
|
||||
//! Consensus algorithms for Ethereum.
|
||||
|
||||
/// Beacon consensus implementation.
|
||||
pub mod beacon;
|
||||
//! Commonly used consensus methods.
|
||||
|
||||
/// Collection of consensus validation methods.
|
||||
pub mod validation;
|
||||
@ -1,8 +1,8 @@
|
||||
//! Collection of methods for block validation.
|
||||
use reth_interfaces::{consensus::ConsensusError, Result as RethResult};
|
||||
use reth_primitives::{
|
||||
BlockNumber, ChainSpec, Hardfork, Header, InvalidTransactionError, SealedBlock, SealedHeader,
|
||||
Transaction, TransactionSignedEcRecovered, TxEip1559, TxEip2930, TxLegacy,
|
||||
constants, BlockNumber, ChainSpec, Hardfork, Header, InvalidTransactionError, SealedBlock,
|
||||
SealedHeader, Transaction, TransactionSignedEcRecovered, TxEip1559, TxEip2930, TxLegacy,
|
||||
};
|
||||
use reth_provider::{AccountProvider, HeaderProvider, WithdrawalsProvider};
|
||||
use std::{
|
||||
@ -10,8 +10,6 @@ use std::{
|
||||
time::SystemTime,
|
||||
};
|
||||
|
||||
use reth_primitives::constants;
|
||||
|
||||
/// Validate header standalone
|
||||
pub fn validate_header_standalone(
|
||||
header: &SealedHeader,
|
||||
@ -1,7 +0,0 @@
|
||||
//! Beacon consensus implementation.
|
||||
|
||||
mod beacon_consensus;
|
||||
mod builder;
|
||||
|
||||
pub use beacon_consensus::BeaconConsensus;
|
||||
pub use builder::BeaconConsensusBuilder;
|
||||
Reference in New Issue
Block a user