Move and rename ``BeaconConsensus` to `EthBeaconConsensus`` (#8140)

Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
Rupam Dey
2024-05-07 23:11:03 +05:30
committed by GitHub
parent 00f9acb94e
commit e172a8e38a
17 changed files with 48 additions and 44 deletions

20
Cargo.lock generated
View File

@ -6516,13 +6516,13 @@ dependencies = [
"assert_matches",
"futures",
"metrics",
"reth-beacon-consensus-core",
"reth-blockchain-tree",
"reth-config",
"reth-consensus",
"reth-db",
"reth-downloaders",
"reth-engine-primitives",
"reth-ethereum-consensus",
"reth-ethereum-engine-primitives",
"reth-evm",
"reth-evm-ethereum",
@ -6551,15 +6551,6 @@ dependencies = [
"tracing",
]
[[package]]
name = "reth-beacon-consensus-core"
version = "0.2.0-beta.6"
dependencies = [
"reth-consensus",
"reth-consensus-common",
"reth-primitives",
]
[[package]]
name = "reth-blockchain-tree"
version = "0.2.0-beta.6"
@ -6931,6 +6922,15 @@ dependencies = [
"tokio-util",
]
[[package]]
name = "reth-ethereum-consensus"
version = "0.2.0-beta.6"
dependencies = [
"reth-consensus",
"reth-consensus-common",
"reth-primitives",
]
[[package]]
name = "reth-ethereum-engine-primitives"
version = "0.2.0-beta.6"

View File

@ -6,7 +6,7 @@ members = [
"crates/config/",
"crates/consensus/auto-seal/",
"crates/consensus/beacon/",
"crates/consensus/beacon-core/",
"crates/ethereum/consensus/",
"crates/consensus/common/",
"crates/consensus/consensus/",
"crates/ethereum-forks/",
@ -208,7 +208,7 @@ reth = { path = "bin/reth" }
reth-auto-seal-consensus = { path = "crates/consensus/auto-seal" }
reth-basic-payload-builder = { path = "crates/payload/basic" }
reth-beacon-consensus = { path = "crates/consensus/beacon" }
reth-beacon-consensus-core = { path = "crates/consensus/beacon-core" }
reth-ethereum-consensus = { path = "crates/ethereum/consensus" }
reth-blockchain-tree = { path = "crates/blockchain-tree" }
reth-cli-runner = { path = "crates/cli/runner" }
reth-codecs = { path = "crates/storage/codecs" }

View File

@ -14,7 +14,7 @@ use eyre::Context;
use reth_basic_payload_builder::{
BuildArguments, BuildOutcome, Cancelled, PayloadBuilder, PayloadConfig,
};
use reth_beacon_consensus::BeaconConsensus;
use reth_beacon_consensus::EthBeaconConsensus;
use reth_blockchain_tree::{
BlockchainTree, BlockchainTreeConfig, ShareableBlockchainTree, TreeExternals,
};
@ -160,7 +160,8 @@ impl Command {
data_dir.static_files(),
)?;
let consensus: Arc<dyn Consensus> = Arc::new(BeaconConsensus::new(Arc::clone(&self.chain)));
let consensus: Arc<dyn Consensus> =
Arc::new(EthBeaconConsensus::new(Arc::clone(&self.chain)));
let executor = block_executor!(self.chain.clone());

View File

@ -12,7 +12,7 @@ use crate::{
};
use clap::Parser;
use futures::{stream::select as stream_select, StreamExt};
use reth_beacon_consensus::BeaconConsensus;
use reth_beacon_consensus::EthBeaconConsensus;
use reth_cli_runner::CliContext;
use reth_config::{config::EtlConfig, Config};
use reth_consensus::Consensus;
@ -220,7 +220,8 @@ impl Command {
debug!(target: "reth::cli", chain=%self.chain.chain, genesis=?self.chain.genesis_hash(), "Initializing genesis");
init_genesis(provider_factory.clone())?;
let consensus: Arc<dyn Consensus> = Arc::new(BeaconConsensus::new(Arc::clone(&self.chain)));
let consensus: Arc<dyn Consensus> =
Arc::new(EthBeaconConsensus::new(Arc::clone(&self.chain)));
// Configure and build network
let network_secret_path =

View File

@ -12,7 +12,7 @@ use crate::{
};
use backon::{ConstantBuilder, Retryable};
use clap::Parser;
use reth_beacon_consensus::BeaconConsensus;
use reth_beacon_consensus::EthBeaconConsensus;
use reth_cli_runner::CliContext;
use reth_config::Config;
use reth_consensus::Consensus;
@ -156,7 +156,8 @@ impl Command {
info!(target: "reth::cli", target_block_number=self.to, "Finished downloading tip of block range");
// build the full block client
let consensus: Arc<dyn Consensus> = Arc::new(BeaconConsensus::new(Arc::clone(&self.chain)));
let consensus: Arc<dyn Consensus> =
Arc::new(EthBeaconConsensus::new(Arc::clone(&self.chain)));
let block_range_client = FullBlockClient::new(fetch_client, consensus);
// get best block number

View File

@ -10,7 +10,7 @@ use crate::{
use clap::Parser;
use eyre::Context;
use reth_basic_payload_builder::{BasicPayloadJobGenerator, BasicPayloadJobGeneratorConfig};
use reth_beacon_consensus::{hooks::EngineHooks, BeaconConsensus, BeaconConsensusEngine};
use reth_beacon_consensus::{hooks::EngineHooks, BeaconConsensusEngine, EthBeaconConsensus};
use reth_blockchain_tree::{
BlockchainTree, BlockchainTreeConfig, ShareableBlockchainTree, TreeExternals,
};
@ -122,7 +122,8 @@ impl Command {
let provider_factory =
ProviderFactory::new(db.clone(), self.chain.clone(), data_dir.static_files())?;
let consensus: Arc<dyn Consensus> = Arc::new(BeaconConsensus::new(Arc::clone(&self.chain)));
let consensus: Arc<dyn Consensus> =
Arc::new(EthBeaconConsensus::new(Arc::clone(&self.chain)));
let executor = block_executor!(self.chain.clone());

View File

@ -12,7 +12,7 @@ use crate::{
use clap::Parser;
use eyre::Context;
use futures::{Stream, StreamExt};
use reth_beacon_consensus::BeaconConsensus;
use reth_beacon_consensus::EthBeaconConsensus;
use reth_config::{config::EtlConfig, Config};
use reth_consensus::Consensus;
use reth_db::{database::Database, init_db, tables, transaction::DbTx};
@ -129,7 +129,7 @@ impl ImportCommand {
init_genesis(provider_factory.clone())?;
let consensus = Arc::new(BeaconConsensus::new(self.chain.clone()));
let consensus = Arc::new(EthBeaconConsensus::new(self.chain.clone()));
info!(target: "reth::cli", "Consensus engine initialized");
// open file

View File

@ -10,7 +10,7 @@ use crate::{
version::SHORT_VERSION,
};
use clap::Parser;
use reth_beacon_consensus::BeaconConsensus;
use reth_beacon_consensus::EthBeaconConsensus;
use reth_config::{config::EtlConfig, Config};
use reth_db::{init_db, tables, transaction::DbTx};
@ -107,7 +107,7 @@ impl ImportOpCommand {
init_genesis(provider_factory.clone())?;
let consensus = Arc::new(BeaconConsensus::new(self.chain.clone()));
let consensus = Arc::new(EthBeaconConsensus::new(self.chain.clone()));
info!(target: "reth::cli", "Consensus engine initialized");
// open file

View File

@ -14,7 +14,7 @@ use crate::{
version::SHORT_VERSION,
};
use clap::Parser;
use reth_beacon_consensus::BeaconConsensus;
use reth_beacon_consensus::EthBeaconConsensus;
use reth_cli_runner::CliContext;
use reth_config::{config::EtlConfig, Config};
use reth_db::init_db;
@ -169,7 +169,7 @@ impl Command {
let (mut exec_stage, mut unwind_stage): (Box<dyn Stage<_>>, Option<Box<dyn Stage<_>>>) =
match self.stage {
StageEnum::Bodies => {
let consensus = Arc::new(BeaconConsensus::new(self.chain.clone()));
let consensus = Arc::new(EthBeaconConsensus::new(self.chain.clone()));
let mut config = config;
config.peers.trusted_nodes_only = self.network.trusted_only;

View File

@ -1,7 +1,7 @@
//! Unwinding a certain block range
use clap::{Parser, Subcommand};
use reth_beacon_consensus::BeaconConsensus;
use reth_beacon_consensus::EthBeaconConsensus;
use reth_config::{Config, PruneConfig};
use reth_consensus::Consensus;
use reth_db::{database::Database, open_db};
@ -165,7 +165,7 @@ impl Command {
.await?;
let consensus: Arc<dyn Consensus> =
Arc::new(BeaconConsensus::new(provider_factory.chain_spec()));
Arc::new(EthBeaconConsensus::new(provider_factory.chain_spec()));
// building network downloaders using the fetch client
let fetch_client = network.fetch_client().await?;

View File

@ -12,7 +12,7 @@ workspace = true
[dependencies]
# reth
reth-beacon-consensus-core.workspace = true
reth-ethereum-consensus.workspace = true
reth-primitives.workspace = true
reth-interfaces.workspace = true
reth-stages-api.workspace = true
@ -70,6 +70,6 @@ optimism = [
"reth-interfaces/optimism",
"reth-provider/optimism",
"reth-blockchain-tree/optimism",
"reth-beacon-consensus-core/optimism",
"reth-ethereum-consensus/optimism",
"reth-rpc/optimism"
]

View File

@ -1,8 +1,8 @@
//! Sync management for the engine implementation.
use crate::{
engine::metrics::EngineSyncMetrics, BeaconConsensus, BeaconConsensusEngineEvent,
ConsensusEngineLiveSyncProgress,
engine::metrics::EngineSyncMetrics, BeaconConsensusEngineEvent,
ConsensusEngineLiveSyncProgress, EthBeaconConsensus,
};
use futures::FutureExt;
use reth_db::database::Database;
@ -81,7 +81,7 @@ where
Self {
full_block_client: FullBlockClient::new(
client,
Arc::new(BeaconConsensus::new(chain_spec)),
Arc::new(EthBeaconConsensus::new(chain_spec)),
),
pipeline_task_spawner,
pipeline_state: PipelineState::Idle(Some(pipeline)),

View File

@ -1,7 +1,7 @@
use crate::{
engine::hooks::PruneHook, hooks::EngineHooks, BeaconConsensus, BeaconConsensusEngine,
engine::hooks::PruneHook, hooks::EngineHooks, BeaconConsensusEngine,
BeaconConsensusEngineError, BeaconConsensusEngineHandle, BeaconForkChoiceUpdateError,
BeaconOnNewPayloadError, MIN_BLOCKS_FOR_PIPELINE_RUN,
BeaconOnNewPayloadError, EthBeaconConsensus, MIN_BLOCKS_FOR_PIPELINE_RUN,
};
use reth_blockchain_tree::{
config::BlockchainTreeConfig, externals::TreeExternals, BlockchainTree, ShareableBlockchainTree,
@ -322,7 +322,7 @@ where
let consensus: Arc<dyn Consensus> = match self.base_config.consensus {
TestConsensusConfig::Real => {
Arc::new(BeaconConsensus::new(Arc::clone(&self.base_config.chain_spec)))
Arc::new(EthBeaconConsensus::new(Arc::clone(&self.base_config.chain_spec)))
}
TestConsensusConfig::Test => Arc::new(TestConsensus::default()),
};

View File

@ -8,7 +8,7 @@
#![cfg_attr(not(test), warn(unused_crate_dependencies))]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
pub use reth_beacon_consensus_core::BeaconConsensus;
pub use reth_ethereum_consensus::EthBeaconConsensus;
mod engine;
pub use engine::*;

View File

@ -1,5 +1,5 @@
[package]
name = "reth-beacon-consensus-core"
name = "reth-ethereum-consensus"
version.workspace = true
edition.workspace = true
rust-version.workspace = true

View File

@ -19,19 +19,19 @@ use std::{sync::Arc, time::SystemTime};
///
/// This consensus engine does basic checks as outlined in the execution specs.
#[derive(Debug)]
pub struct BeaconConsensus {
pub struct EthBeaconConsensus {
/// Configuration
chain_spec: Arc<ChainSpec>,
}
impl BeaconConsensus {
/// Create a new instance of [BeaconConsensus]
impl EthBeaconConsensus {
/// Create a new instance of [EthBeaconConsensus]
pub fn new(chain_spec: Arc<ChainSpec>) -> Self {
Self { chain_spec }
}
}
impl Consensus for BeaconConsensus {
impl Consensus for EthBeaconConsensus {
fn validate_header(&self, header: &SealedHeader) -> Result<(), ConsensusError> {
validation::validate_header_standalone(header, &self.chain_spec)?;
Ok(())

View File

@ -11,7 +11,7 @@ use futures::{future, future::Either, stream, stream_select, StreamExt};
use reth_auto_seal_consensus::AutoSealConsensus;
use reth_beacon_consensus::{
hooks::{EngineHooks, PruneHook, StaticFileHook},
BeaconConsensus, BeaconConsensusEngine,
BeaconConsensusEngine, EthBeaconConsensus,
};
use reth_blockchain_tree::{
noop::NoopBlockchainTree, BlockchainTree, BlockchainTreeConfig, ShareableBlockchainTree,
@ -116,7 +116,7 @@ where
let consensus: Arc<dyn Consensus> = if ctx.is_dev() {
Arc::new(AutoSealConsensus::new(ctx.chain_spec()))
} else {
Arc::new(BeaconConsensus::new(ctx.chain_spec()))
Arc::new(EthBeaconConsensus::new(ctx.chain_spec()))
};
debug!(target: "reth::cli", "Spawning stages metrics listener task");