From 6f6c4f61e04ce07513cfa12f844c64b504d09825 Mon Sep 17 00:00:00 2001 From: Bjerg Date: Thu, 22 Dec 2022 12:05:49 +0100 Subject: [PATCH] refactor: rename `EthConsensus` (#572) Closes #566 --- bin/reth/src/node/mod.rs | 4 ++-- crates/consensus/src/consensus.rs | 14 ++++++++------ crates/consensus/src/lib.rs | 2 +- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/bin/reth/src/node/mod.rs b/bin/reth/src/node/mod.rs index cd4a24ce43..e8cd55e91d 100644 --- a/bin/reth/src/node/mod.rs +++ b/bin/reth/src/node/mod.rs @@ -10,7 +10,7 @@ use clap::{crate_version, Parser}; use eyre::WrapErr; use metrics_exporter_prometheus::PrometheusBuilder; use metrics_util::layers::{PrefixLayer, Stack}; -use reth_consensus::EthConsensus; +use reth_consensus::BeaconConsensus; use reth_db::{ cursor::DbCursorRO, database::Database, @@ -105,7 +105,7 @@ impl Command { } let chain_id = self.chain.consensus.chain_id; - let consensus = Arc::new(EthConsensus::new(self.chain.consensus.clone())); + let consensus = Arc::new(BeaconConsensus::new(self.chain.consensus.clone())); let genesis_hash = init_genesis(db.clone(), self.chain.genesis.clone())?; info!("Connecting to p2p"); diff --git a/crates/consensus/src/consensus.rs b/crates/consensus/src/consensus.rs index 4132077588..ca1611f715 100644 --- a/crates/consensus/src/consensus.rs +++ b/crates/consensus/src/consensus.rs @@ -1,20 +1,22 @@ //! Consensus for ethereum network - use crate::{verification, Config}; use reth_interfaces::consensus::{Consensus, Error, ForkchoiceState}; use reth_primitives::{BlockLocked, BlockNumber, SealedHeader, H256}; use tokio::sync::{watch, watch::error::SendError}; -/// Ethereum consensus -pub struct EthConsensus { +/// Ethereum beacon consensus +/// +/// This consensus engine does basic checks as outlined in the execution specs, +/// but otherwise defers consensus on what the current chain is to a consensus client. +pub struct BeaconConsensus { /// Watcher over the forkchoice state channel: (watch::Sender, watch::Receiver), /// Configuration config: Config, } -impl EthConsensus { - /// Create a new instance of [EthConsensus] +impl BeaconConsensus { + /// Create a new instance of [BeaconConsensus] pub fn new(config: Config) -> Self { Self { channel: watch::channel(ForkchoiceState { @@ -35,7 +37,7 @@ impl EthConsensus { } } -impl Consensus for EthConsensus { +impl Consensus for BeaconConsensus { fn fork_choice_state(&self) -> watch::Receiver { self.channel.1.clone() } diff --git a/crates/consensus/src/lib.rs b/crates/consensus/src/lib.rs index 2f7356542a..65797f2c32 100644 --- a/crates/consensus/src/lib.rs +++ b/crates/consensus/src/lib.rs @@ -14,5 +14,5 @@ pub mod consensus; pub mod verification; pub use config::Config; -pub use consensus::EthConsensus; +pub use consensus::BeaconConsensus; pub use reth_interfaces::consensus::Error;