Skip to content

Commit 2c791d8

Browse files
refactor(block): simplify TaikoBlockAssembler and StoredL1Origin conversions (#211)
refactor: simplify TaikoBlockAssembler and StoredL1Origin conversions TaikoBlockAssembler wrapped an EthBlockAssembler that was never used for assembly: assemble_block builds the Taiko header entirely from the execution context and EVM environment, and the inner assembler's only reader was a chain_spec() accessor consumed solely by its own unit test. The assembler is now a stateless unit struct, so TaikoEvmConfig no longer clones a chain spec into it. The owned From<RpcL1Origin> impl for StoredL1Origin duplicated the borrowed impl field-for-field; it now delegates to From<&RpcL1Origin>. Cargo.lock syncs the workspace crate versions left behind by the 1.2.0 release commit. Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
1 parent 1ed7c19 commit 2c791d8

4 files changed

Lines changed: 21 additions & 57 deletions

File tree

Cargo.lock

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/block/src/assembler.rs

Lines changed: 7 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
//! Block assembler implementation for Taiko headers and block bodies.
2-
use std::sync::Arc;
3-
42
use alloy_consensus::{
53
BlockBody, EMPTY_OMMER_ROOT_HASH, Header, TxReceipt, constants::EMPTY_WITHDRAWALS, proofs,
64
};
@@ -12,32 +10,18 @@ use reth_evm::{
1210
block::{BlockExecutionError, BlockExecutorFactory},
1311
execute::{BlockAssembler, BlockAssemblerInput},
1412
};
15-
use reth_evm_ethereum::EthBlockAssembler;
1613
use reth_execution_types::BlockExecutionResult;
1714
use reth_primitives_traits::logs_bloom;
1815
use reth_revm::context::Block as _;
1916

2017
use crate::factory::TaikoBlockExecutionCtx;
21-
use alethia_reth_chainspec::spec::TaikoChainSpec;
2218

2319
/// A block assembler for the Taiko network that implements the `BlockAssembler` trait.
24-
#[derive(Clone, Debug)]
25-
pub struct TaikoBlockAssembler {
26-
/// Underlying Ethereum block assembler configured with Taiko chain spec.
27-
block_assembler: EthBlockAssembler<TaikoChainSpec>,
28-
}
29-
30-
impl TaikoBlockAssembler {
31-
/// Creates a new instance of the [`TaikoBlockAssembler`] with the given chain specification.
32-
pub fn new(chain_spec: Arc<TaikoChainSpec>) -> Self {
33-
Self { block_assembler: EthBlockAssembler::new(chain_spec) }
34-
}
35-
36-
/// Returns a reference to the chain specification.
37-
pub fn chain_spec(&self) -> Arc<TaikoChainSpec> {
38-
self.block_assembler.chain_spec.clone()
39-
}
40-
}
20+
///
21+
/// Taiko headers are assembled entirely from the execution context and EVM environment, so the
22+
/// assembler carries no state.
23+
#[derive(Clone, Copy, Debug, Default)]
24+
pub struct TaikoBlockAssembler;
4125

4226
impl<F> BlockAssembler<F> for TaikoBlockAssembler
4327
where
@@ -118,7 +102,6 @@ where
118102
mod test {
119103
use alloy_consensus::{Header, Signed, TxLegacy};
120104
use alloy_eips::eip7685::{EMPTY_REQUESTS_HASH, Requests};
121-
use alloy_hardforks::ForkCondition;
122105
use alloy_primitives::{Address, B256, Bytes, ChainId, Signature, TxKind, U256};
123106
use reth_evm::{
124107
EvmEnv,
@@ -131,20 +114,11 @@ mod test {
131114

132115
use super::*;
133116
use crate::factory::{TaikoBlockExecutionCtx, TaikoBlockExecutorFactory};
134-
use alethia_reth_chainspec::{TAIKO_DEVNET, hardfork::TaikoHardfork};
135117
use alethia_reth_evm::spec::TaikoSpecId;
136118

137-
#[test]
138-
fn test_get_chain_spec() {
139-
let chain_spec = Arc::new(TaikoChainSpec::default());
140-
let assembler = TaikoBlockAssembler::new(chain_spec.clone());
141-
142-
assert_eq!(assembler.chain_spec(), chain_spec);
143-
}
144-
145119
#[test]
146120
fn assembled_unzen_block_uses_final_zk_gas_as_difficulty() {
147-
let assembler = TaikoBlockAssembler::new(Arc::new(TaikoChainSpec::default()));
121+
let assembler = TaikoBlockAssembler;
148122
let mut evm_env: EvmEnv<TaikoSpecId> = EvmEnv::default();
149123
evm_env.cfg_env.spec = TaikoSpecId::UNZEN;
150124
evm_env.block_env.number = U256::from(1);
@@ -193,9 +167,7 @@ mod test {
193167

194168
#[test]
195169
fn assembled_unzen_block_sets_requests_hash() {
196-
let mut chain_spec = (*TAIKO_DEVNET).as_ref().clone();
197-
chain_spec.inner.hardforks.insert(TaikoHardfork::Unzen, ForkCondition::Timestamp(0));
198-
let assembler = TaikoBlockAssembler::new(Arc::new(chain_spec));
170+
let assembler = TaikoBlockAssembler;
199171
let mut evm_env: EvmEnv<TaikoSpecId> = EvmEnv::default();
200172
evm_env.cfg_env.spec = TaikoSpecId::UNZEN;
201173
evm_env.block_env.number = U256::from(1);

crates/block/src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ impl TaikoEvmConfig {
9999
evm_factory: TaikoEvmFactory,
100100
) -> Self {
101101
Self {
102-
block_assembler: TaikoBlockAssembler::new(chain_spec.clone()),
102+
block_assembler: TaikoBlockAssembler,
103103
executor_factory: TaikoBlockExecutorFactory::new(
104104
RethReceiptBuilder::default(),
105105
chain_spec,

crates/db/src/model.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,7 @@ pub struct StoredL1Origin {
3838
impl From<RpcL1Origin> for StoredL1Origin {
3939
// Converts an `RpcL1Origin` into a `StoredL1Origin`.
4040
fn from(rpc_l1_origin: RpcL1Origin) -> Self {
41-
StoredL1Origin {
42-
block_id: rpc_l1_origin.block_id,
43-
l2_block_hash: rpc_l1_origin.l2_block_hash,
44-
l1_block_height: rpc_l1_origin.l1_block_height.unwrap_or(U256::ZERO),
45-
l1_block_hash: rpc_l1_origin.l1_block_hash.unwrap_or(B256::ZERO),
46-
build_payload_args_id: rpc_l1_origin.build_payload_args_id,
47-
is_forced_inclusion: rpc_l1_origin.is_forced_inclusion,
48-
signature: rpc_l1_origin.signature,
49-
}
41+
Self::from(&rpc_l1_origin)
5042
}
5143
}
5244

0 commit comments

Comments
 (0)