Skip to content

Commit 358fa04

Browse files
committed
minimize
1 parent 9f748bc commit 358fa04

3 files changed

Lines changed: 33 additions & 56 deletions

File tree

bin/lumen/src/consensus_builder.rs

Lines changed: 0 additions & 32 deletions
This file was deleted.

bin/lumen/src/main.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
pub mod attributes;
99
pub mod builder;
10-
pub mod consensus_builder;
1110
pub mod error;
1211
pub mod validator;
1312

@@ -18,6 +17,7 @@ use alloy_rpc_types::engine::{
1817
use clap::Parser;
1918
use lumen_rollkit::{
2019
config::RollkitConfig,
20+
consensus::RollkitConsensusBuilder,
2121
rpc::txpool::{RollkitTxpoolApiImpl, RollkitTxpoolApiServer},
2222
};
2323
use reth_ethereum::{
@@ -43,7 +43,6 @@ use tracing::info;
4343
use crate::{
4444
attributes::{RollkitEnginePayloadAttributes, RollkitEnginePayloadBuilderAttributes},
4545
builder::{RollkitArgs, RollkitPayloadBuilderBuilder},
46-
consensus_builder::RollkitConsensusBuilder,
4746
validator::RollkitEngineValidatorBuilder,
4847
};
4948

@@ -141,7 +140,7 @@ where
141140
RollkitPayloadBuilderBuilder::new(&self.args),
142141
))
143142
.network(EthereumNetworkBuilder::default())
144-
.consensus(RollkitConsensusBuilder)
143+
.consensus(RollkitConsensusBuilder::default())
145144
}
146145

147146
fn add_ons(&self) -> Self::AddOns {

crates/rollkit/src/consensus.rs

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,43 @@
33
use reth_chainspec::ChainSpec;
44
use reth_consensus::{Consensus, ConsensusError, FullConsensus, HeaderValidator};
55
use reth_consensus_common::validation::validate_body_against_header;
6+
use reth_ethereum::node::builder::{components::ConsensusBuilder, BuilderContext};
67
use reth_ethereum_consensus::EthBeaconConsensus;
78
use reth_ethereum_primitives::{Block, BlockBody, EthPrimitives, Receipt};
89
use reth_execution_types::BlockExecutionResult;
10+
use reth_node_api::{FullNodeTypes, NodeTypes};
911
use reth_primitives::{GotExpected, GotExpectedBoxed, RecoveredBlock, SealedBlock, SealedHeader};
1012
use std::sync::Arc;
1113

14+
/// Builder for `RollkitConsensus`
15+
#[derive(Debug, Default, Clone)]
16+
#[non_exhaustive]
17+
pub struct RollkitConsensusBuilder;
18+
19+
impl RollkitConsensusBuilder {
20+
/// Create a new `RollkitConsensusBuilder`
21+
pub const fn new() -> Self {
22+
Self
23+
}
24+
25+
/// Build the consensus implementation
26+
pub fn build(chain_spec: Arc<ChainSpec>) -> Arc<RollkitConsensus> {
27+
Arc::new(RollkitConsensus::new(chain_spec))
28+
}
29+
}
30+
31+
impl<Node> ConsensusBuilder<Node> for RollkitConsensusBuilder
32+
where
33+
Node: FullNodeTypes,
34+
Node::Types: NodeTypes<ChainSpec = ChainSpec, Primitives = EthPrimitives>,
35+
{
36+
type Consensus = Arc<dyn FullConsensus<EthPrimitives, Error = ConsensusError>>;
37+
38+
async fn build_consensus(self, ctx: &BuilderContext<Node>) -> eyre::Result<Self::Consensus> {
39+
Ok(Arc::new(RollkitConsensus::new(ctx.chain_spec())) as Self::Consensus)
40+
}
41+
}
42+
1243
/// Rollkit consensus implementation that allows blocks with the same timestamp.
1344
///
1445
/// This consensus implementation wraps the standard Ethereum beacon consensus
@@ -111,24 +142,3 @@ impl FullConsensus<EthPrimitives> for RollkitConsensus {
111142
<EthBeaconConsensus<ChainSpec> as FullConsensus<EthPrimitives>>::validate_block_post_execution(&self.inner, block, result)
112143
}
113144
}
114-
115-
/// Builder for `RollkitConsensus`
116-
#[derive(Debug, Default, Clone)]
117-
#[non_exhaustive]
118-
pub struct RollkitConsensusBuilder;
119-
120-
impl RollkitConsensusBuilder {
121-
/// Create a new `RollkitConsensusBuilder`
122-
pub const fn new() -> Self {
123-
Self
124-
}
125-
}
126-
127-
// Instead of implementing the generic ConsensusBuilder trait,
128-
// we'll use a direct approach that works with the node builder
129-
impl RollkitConsensusBuilder {
130-
/// Build the consensus implementation
131-
pub fn build(chain_spec: Arc<ChainSpec>) -> Arc<RollkitConsensus> {
132-
Arc::new(RollkitConsensus::new(chain_spec))
133-
}
134-
}

0 commit comments

Comments
 (0)