Skip to content

Commit 198ba18

Browse files
mattssepetarjuki7
andauthored
chore: remove Beacon from type names (paradigmxyz#17868)
Co-authored-by: petarjuki7 <[email protected]>
1 parent 7577ab8 commit 198ba18

File tree

19 files changed

+88
-86
lines changed

19 files changed

+88
-86
lines changed

bin/reth/src/ress.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use reth_ethereum_primitives::EthPrimitives;
22
use reth_evm::ConfigureEvm;
33
use reth_network::{protocol::IntoRlpxSubProtocol, NetworkProtocols};
44
use reth_network_api::FullNetwork;
5-
use reth_node_api::BeaconConsensusEngineEvent;
5+
use reth_node_api::ConsensusEngineEvent;
66
use reth_node_core::args::RessArgs;
77
use reth_provider::providers::{BlockchainProvider, ProviderNodeTypes};
88
use reth_ress_protocol::{NodeType, ProtocolState, RessProtocolHandler};
@@ -19,7 +19,7 @@ pub fn install_ress_subprotocol<P, E, N>(
1919
evm_config: E,
2020
network: N,
2121
task_executor: TaskExecutor,
22-
engine_events: EventStream<BeaconConsensusEngineEvent<EthPrimitives>>,
22+
engine_events: EventStream<ConsensusEngineEvent<EthPrimitives>>,
2323
) -> eyre::Result<()>
2424
where
2525
P: ProviderNodeTypes<Primitives = EthPrimitives>,

crates/consensus/debug-client/src/client.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use alloy_consensus::Sealable;
22
use alloy_primitives::B256;
33
use reth_node_api::{
4-
BeaconConsensusEngineHandle, BuiltPayload, EngineApiMessageVersion, ExecutionPayload,
5-
NodePrimitives, PayloadTypes,
4+
BuiltPayload, ConsensusEngineHandle, EngineApiMessageVersion, ExecutionPayload, NodePrimitives,
5+
PayloadTypes,
66
};
77
use reth_primitives_traits::{Block, SealedBlock};
88
use reth_tracing::tracing::warn;
@@ -62,15 +62,15 @@ pub trait BlockProvider: Send + Sync + 'static {
6262
#[derive(Debug)]
6363
pub struct DebugConsensusClient<P: BlockProvider, T: PayloadTypes> {
6464
/// Handle to execution client.
65-
engine_handle: BeaconConsensusEngineHandle<T>,
65+
engine_handle: ConsensusEngineHandle<T>,
6666
/// Provider to get consensus blocks from.
6767
block_provider: P,
6868
}
6969

7070
impl<P: BlockProvider, T: PayloadTypes> DebugConsensusClient<P, T> {
7171
/// Create a new debug consensus client with the given handle to execution
7272
/// client and block provider.
73-
pub const fn new(engine_handle: BeaconConsensusEngineHandle<T>, block_provider: P) -> Self {
73+
pub const fn new(engine_handle: ConsensusEngineHandle<T>, block_provider: P) -> Self {
7474
Self { engine_handle, block_provider }
7575
}
7676
}

crates/engine/local/src/miner.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use alloy_primitives::{TxHash, B256};
55
use alloy_rpc_types_engine::ForkchoiceState;
66
use eyre::OptionExt;
77
use futures_util::{stream::Fuse, StreamExt};
8-
use reth_engine_primitives::BeaconConsensusEngineHandle;
8+
use reth_engine_primitives::ConsensusEngineHandle;
99
use reth_payload_builder::PayloadBuilderHandle;
1010
use reth_payload_primitives::{
1111
BuiltPayload, EngineApiMessageVersion, PayloadAttributesBuilder, PayloadKind, PayloadTypes,
@@ -95,7 +95,7 @@ pub struct LocalMiner<T: PayloadTypes, B> {
9595
/// The payload attribute builder for the engine
9696
payload_attributes_builder: B,
9797
/// Sender for events to engine.
98-
to_engine: BeaconConsensusEngineHandle<T>,
98+
to_engine: ConsensusEngineHandle<T>,
9999
/// The mining mode for the engine
100100
mode: MiningMode,
101101
/// The payload builder for the engine
@@ -115,7 +115,7 @@ where
115115
pub fn new(
116116
provider: impl BlockReader,
117117
payload_attributes_builder: B,
118-
to_engine: BeaconConsensusEngineHandle<T>,
118+
to_engine: ConsensusEngineHandle<T>,
119119
mode: MiningMode,
120120
payload_builder: PayloadBuilderHandle<T>,
121121
) -> Self {

crates/engine/primitives/src/event.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,13 @@ use reth_chain_state::ExecutedBlockWithTrieUpdates;
1414
use reth_ethereum_primitives::EthPrimitives;
1515
use reth_primitives_traits::{NodePrimitives, SealedBlock, SealedHeader};
1616

17+
/// Type alias for backwards compat
18+
#[deprecated(note = "Use ConsensusEngineEvent instead")]
19+
pub type BeaconConsensusEngineEvent<N> = ConsensusEngineEvent<N>;
20+
1721
/// Events emitted by the consensus engine.
1822
#[derive(Clone, Debug)]
19-
pub enum BeaconConsensusEngineEvent<N: NodePrimitives = EthPrimitives> {
23+
pub enum ConsensusEngineEvent<N: NodePrimitives = EthPrimitives> {
2024
/// The fork choice state was updated, and the current fork choice status
2125
ForkchoiceUpdated(ForkchoiceState, ForkchoiceStatus),
2226
/// A block was added to the fork chain.
@@ -33,9 +37,9 @@ pub enum BeaconConsensusEngineEvent<N: NodePrimitives = EthPrimitives> {
3337
LiveSyncProgress(ConsensusEngineLiveSyncProgress),
3438
}
3539

36-
impl<N: NodePrimitives> BeaconConsensusEngineEvent<N> {
40+
impl<N: NodePrimitives> ConsensusEngineEvent<N> {
3741
/// Returns the canonical header if the event is a
38-
/// [`BeaconConsensusEngineEvent::CanonicalChainCommitted`].
42+
/// [`ConsensusEngineEvent::CanonicalChainCommitted`].
3943
pub const fn canonical_header(&self) -> Option<&SealedHeader<N::BlockHeader>> {
4044
match self {
4145
Self::CanonicalChainCommitted(header, _) => Some(header),
@@ -44,7 +48,7 @@ impl<N: NodePrimitives> BeaconConsensusEngineEvent<N> {
4448
}
4549
}
4650

47-
impl<N> Display for BeaconConsensusEngineEvent<N>
51+
impl<N> Display for ConsensusEngineEvent<N>
4852
where
4953
N: NodePrimitives<BlockHeader: BlockHeader>,
5054
{

crates/engine/primitives/src/message.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ use reth_payload_builder_primitives::PayloadBuilderError;
1717
use reth_payload_primitives::{EngineApiMessageVersion, PayloadTypes};
1818
use tokio::sync::{mpsc::UnboundedSender, oneshot};
1919

20+
/// Type alias for backwards compat
21+
#[deprecated(note = "Use ConsensusEngineHandle instead")]
22+
pub type BeaconConsensusEngineHandle<Payload> = ConsensusEngineHandle<Payload>;
23+
2024
/// Represents the outcome of forkchoice update.
2125
///
2226
/// This is a future that resolves to [`ForkChoiceUpdateResult`]
@@ -191,14 +195,14 @@ impl<Payload: PayloadTypes> Display for BeaconEngineMessage<Payload> {
191195
///
192196
/// This type mirrors consensus related functions of the engine API.
193197
#[derive(Debug, Clone)]
194-
pub struct BeaconConsensusEngineHandle<Payload>
198+
pub struct ConsensusEngineHandle<Payload>
195199
where
196200
Payload: PayloadTypes,
197201
{
198202
to_engine: UnboundedSender<BeaconEngineMessage<Payload>>,
199203
}
200204

201-
impl<Payload> BeaconConsensusEngineHandle<Payload>
205+
impl<Payload> ConsensusEngineHandle<Payload>
202206
where
203207
Payload: PayloadTypes,
204208
{

crates/engine/service/src/service.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use futures::{Stream, StreamExt};
22
use pin_project::pin_project;
33
use reth_chainspec::EthChainSpec;
44
use reth_consensus::{ConsensusError, FullConsensus};
5-
use reth_engine_primitives::{BeaconConsensusEngineEvent, BeaconEngineMessage};
5+
use reth_engine_primitives::{BeaconEngineMessage, ConsensusEngineEvent};
66
use reth_engine_tree::{
77
backfill::PipelineSync,
88
download::BasicBlockDownloader,
@@ -130,7 +130,7 @@ where
130130
N: ProviderNodeTypes,
131131
Client: BlockClient<Block = BlockTy<N>> + 'static,
132132
{
133-
type Item = ChainEvent<BeaconConsensusEngineEvent<N::Primitives>>;
133+
type Item = ChainEvent<ConsensusEngineEvent<N::Primitives>>;
134134

135135
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
136136
let mut orchestrator = self.project().orchestrator;

crates/engine/tree/src/engine.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use crate::{
88
use alloy_primitives::B256;
99
use futures::{Stream, StreamExt};
1010
use reth_chain_state::ExecutedBlockWithTrieUpdates;
11-
use reth_engine_primitives::{BeaconConsensusEngineEvent, BeaconEngineMessage};
11+
use reth_engine_primitives::{BeaconEngineMessage, ConsensusEngineEvent};
1212
use reth_ethereum_primitives::EthPrimitives;
1313
use reth_payload_primitives::PayloadTypes;
1414
use reth_primitives_traits::{Block, NodePrimitives, RecoveredBlock};
@@ -191,7 +191,7 @@ impl<Request, N: NodePrimitives> EngineRequestHandler for EngineApiRequestHandle
191191
where
192192
Request: Send,
193193
{
194-
type Event = BeaconConsensusEngineEvent<N>;
194+
type Event = ConsensusEngineEvent<N>;
195195
type Request = Request;
196196
type Block = N::Block;
197197

@@ -279,7 +279,7 @@ impl<T: PayloadTypes, N: NodePrimitives> From<EngineApiRequest<T, N>>
279279
pub enum EngineApiEvent<N: NodePrimitives = EthPrimitives> {
280280
/// Event from the consensus engine.
281281
// TODO(mattsse): find a more appropriate name for this variant, consider phasing it out.
282-
BeaconConsensus(BeaconConsensusEngineEvent<N>),
282+
BeaconConsensus(ConsensusEngineEvent<N>),
283283
/// Backfill action is needed.
284284
BackfillAction(BackfillAction),
285285
/// Block download is needed.
@@ -293,8 +293,8 @@ impl<N: NodePrimitives> EngineApiEvent<N> {
293293
}
294294
}
295295

296-
impl<N: NodePrimitives> From<BeaconConsensusEngineEvent<N>> for EngineApiEvent<N> {
297-
fn from(event: BeaconConsensusEngineEvent<N>) -> Self {
296+
impl<N: NodePrimitives> From<ConsensusEngineEvent<N>> for EngineApiEvent<N> {
297+
fn from(event: ConsensusEngineEvent<N>) -> Self {
298298
Self::BeaconConsensus(event)
299299
}
300300
}

crates/engine/tree/src/tree/mod.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use reth_chain_state::{
1919
};
2020
use reth_consensus::{Consensus, FullConsensus};
2121
use reth_engine_primitives::{
22-
BeaconConsensusEngineEvent, BeaconEngineMessage, BeaconOnNewPayloadError, ExecutionPayload,
22+
BeaconEngineMessage, BeaconOnNewPayloadError, ConsensusEngineEvent, ExecutionPayload,
2323
ForkchoiceStateTracker, OnForkChoiceUpdated,
2424
};
2525
use reth_errors::{ConsensusError, ProviderResult};
@@ -518,7 +518,7 @@ where
518518
.record_payload_validation(validation_start.elapsed().as_secs_f64());
519519

520520
let num_hash = payload.num_hash();
521-
let engine_event = BeaconConsensusEngineEvent::BlockReceived(num_hash);
521+
let engine_event = ConsensusEngineEvent::BlockReceived(num_hash);
522522
self.emit_event(EngineApiEvent::BeaconConsensus(engine_event));
523523

524524
let block_hash = num_hash.hash;
@@ -1064,7 +1064,7 @@ where
10641064
self.state.tree_state.insert_executed(block.clone());
10651065
self.metrics.engine.inserted_already_executed_blocks.increment(1);
10661066
self.emit_event(EngineApiEvent::BeaconConsensus(
1067-
BeaconConsensusEngineEvent::CanonicalBlockAdded(block, now.elapsed()),
1067+
ConsensusEngineEvent::CanonicalBlockAdded(block, now.elapsed()),
10681068
));
10691069
}
10701070
EngineApiRequest::Beacon(request) => {
@@ -1085,7 +1085,7 @@ where
10851085
.set_latest(state, res.outcome.forkchoice_status());
10861086

10871087
// emit an event about the handled FCU
1088-
self.emit_event(BeaconConsensusEngineEvent::ForkchoiceUpdated(
1088+
self.emit_event(ConsensusEngineEvent::ForkchoiceUpdated(
10891089
state,
10901090
res.outcome.forkchoice_status(),
10911091
));
@@ -1626,7 +1626,7 @@ where
16261626

16271627
// insert the head block into the invalid header cache
16281628
self.state.invalid_headers.insert_with_invalid_ancestor(head.hash(), invalid);
1629-
self.emit_event(BeaconConsensusEngineEvent::InvalidBlock(Box::new(head)));
1629+
self.emit_event(ConsensusEngineEvent::InvalidBlock(Box::new(head)));
16301630

16311631
Ok(status)
16321632
}
@@ -1907,7 +1907,7 @@ where
19071907
self.canonical_in_memory_state.notify_canon_state(notification);
19081908

19091909
// emit event
1910-
self.emit_event(BeaconConsensusEngineEvent::CanonicalChainCommitted(
1910+
self.emit_event(ConsensusEngineEvent::CanonicalChainCommitted(
19111911
Box::new(tip),
19121912
start.elapsed(),
19131913
));
@@ -2155,9 +2155,9 @@ where
21552155
// emit insert event
21562156
let elapsed = start.elapsed();
21572157
let engine_event = if is_fork {
2158-
BeaconConsensusEngineEvent::ForkBlockAdded(executed, elapsed)
2158+
ConsensusEngineEvent::ForkBlockAdded(executed, elapsed)
21592159
} else {
2160-
BeaconConsensusEngineEvent::CanonicalBlockAdded(executed, elapsed)
2160+
ConsensusEngineEvent::CanonicalBlockAdded(executed, elapsed)
21612161
};
21622162
self.emit_event(EngineApiEvent::BeaconConsensus(engine_event));
21632163

@@ -2296,7 +2296,7 @@ where
22962296

22972297
// keep track of the invalid header
22982298
self.state.invalid_headers.insert(block.block_with_parent());
2299-
self.emit_event(EngineApiEvent::BeaconConsensus(BeaconConsensusEngineEvent::InvalidBlock(
2299+
self.emit_event(EngineApiEvent::BeaconConsensus(ConsensusEngineEvent::InvalidBlock(
23002300
Box::new(block),
23012301
)));
23022302
Ok(PayloadStatus::new(

crates/engine/tree/src/tree/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ impl TestHarness {
301301
// check for ForkchoiceUpdated event
302302
let event = self.from_tree_rx.recv().await.unwrap();
303303
match event {
304-
EngineApiEvent::BeaconConsensus(BeaconConsensusEngineEvent::ForkchoiceUpdated(
304+
EngineApiEvent::BeaconConsensus(ConsensusEngineEvent::ForkchoiceUpdated(
305305
state,
306306
status,
307307
)) => {

crates/node/api/src/node.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use alloy_rpc_types_engine::JwtSecret;
55
use reth_basic_payload_builder::PayloadBuilder;
66
use reth_consensus::{ConsensusError, FullConsensus};
77
use reth_db_api::{database_metrics::DatabaseMetrics, Database};
8-
use reth_engine_primitives::{BeaconConsensusEngineEvent, BeaconConsensusEngineHandle};
8+
use reth_engine_primitives::{ConsensusEngineEvent, ConsensusEngineHandle};
99
use reth_evm::ConfigureEvm;
1010
use reth_network_api::FullNetwork;
1111
use reth_node_core::node_config::NodeConfig;
@@ -113,9 +113,9 @@ pub struct AddOnsContext<'a, N: FullNodeComponents> {
113113
/// Node configuration.
114114
pub config: &'a NodeConfig<<N::Types as NodeTypes>::ChainSpec>,
115115
/// Handle to the beacon consensus engine.
116-
pub beacon_engine_handle: BeaconConsensusEngineHandle<<N::Types as NodeTypes>::Payload>,
116+
pub beacon_engine_handle: ConsensusEngineHandle<<N::Types as NodeTypes>::Payload>,
117117
/// Notification channel for engine API events
118-
pub engine_events: EventSender<BeaconConsensusEngineEvent<<N::Types as NodeTypes>::Primitives>>,
118+
pub engine_events: EventSender<ConsensusEngineEvent<<N::Types as NodeTypes>::Primitives>>,
119119
/// JWT secret for the node.
120120
pub jwt_secret: JwtSecret,
121121
}

0 commit comments

Comments
 (0)