diff --git a/bin/reth-bench/src/bench/new_payload_fcu.rs b/bin/reth-bench/src/bench/new_payload_fcu.rs index 2866cf8fb45c..12caecbd033e 100644 --- a/bin/reth-bench/src/bench/new_payload_fcu.rs +++ b/bin/reth-bench/src/bench/new_payload_fcu.rs @@ -12,13 +12,14 @@ use crate::{ valid_payload::{call_forkchoice_updated, call_new_payload}, }; use alloy_primitives::B256; -use alloy_provider::Provider; +use alloy_provider::{network::AnyRpcBlock, Provider}; use alloy_rpc_types_engine::ForkchoiceState; use clap::Parser; use csv::Writer; use reth_cli_runner::CliContext; use reth_node_core::args::BenchmarkArgs; use reth_primitives::SealedBlock; +use reth_primitives_traits::SealedHeader; use reth_rpc_types_compat::engine::payload::block_to_payload; use std::time::Instant; use tracing::{debug, info}; @@ -46,7 +47,7 @@ impl Command { let block_res = block_provider.get_block_by_number(next_block.into(), true.into()).await; let block = block_res.unwrap().unwrap(); - let block: SealedBlock = block.try_into().unwrap(); + let block = from_any_rpc_block(block); let head_block_hash = block.hash(); let safe_block_hash = block_provider .get_block_by_number(block.number.saturating_sub(32).into(), false.into()); @@ -161,3 +162,19 @@ impl Command { Ok(()) } } + +// TODO(mattsse): integrate in alloy +pub(crate) fn from_any_rpc_block(block: AnyRpcBlock) -> SealedBlock { + let block = block.inner; + let block_hash = block.header.hash; + let block = block.try_map_transactions(|tx| tx.try_into()).unwrap(); + + SealedBlock::from_sealed_parts( + SealedHeader::new(block.header.inner.into_header_with_defaults(), block_hash), + reth_primitives::BlockBody { + transactions: block.transactions.into_transactions().collect(), + ommers: Default::default(), + withdrawals: block.withdrawals.map(|w| w.into_inner().into()), + }, + ) +} diff --git a/bin/reth-bench/src/bench/new_payload_only.rs b/bin/reth-bench/src/bench/new_payload_only.rs index 4485e3fa79ec..f72b9f2d5d6a 100644 --- a/bin/reth-bench/src/bench/new_payload_only.rs +++ b/bin/reth-bench/src/bench/new_payload_only.rs @@ -3,6 +3,7 @@ use crate::{ bench::{ context::BenchContext, + new_payload_fcu::from_any_rpc_block, output::{ NewPayloadResult, TotalGasOutput, TotalGasRow, GAS_OUTPUT_SUFFIX, NEW_PAYLOAD_OUTPUT_SUFFIX, @@ -16,7 +17,6 @@ use clap::Parser; use csv::Writer; use reth_cli_runner::CliContext; use reth_node_core::args::BenchmarkArgs; -use reth_primitives::SealedBlock; use reth_rpc_types_compat::engine::payload::block_to_payload; use std::time::Instant; use tracing::{debug, info}; @@ -46,7 +46,7 @@ impl Command { let block_res = block_provider.get_block_by_number(next_block.into(), true.into()).await; let block = block_res.unwrap().unwrap(); - let block: SealedBlock = block.try_into().unwrap(); + let block = from_any_rpc_block(block); next_block += 1; sender.send(block).await.unwrap(); diff --git a/crates/engine/invalid-block-hooks/src/witness.rs b/crates/engine/invalid-block-hooks/src/witness.rs index a0c986e4384a..596931c29638 100644 --- a/crates/engine/invalid-block-hooks/src/witness.rs +++ b/crates/engine/invalid-block-hooks/src/witness.rs @@ -10,7 +10,7 @@ use reth_evm::{ ConfigureEvm, }; use reth_primitives::{NodePrimitives, SealedBlockWithSenders, SealedHeader}; -use reth_primitives_traits::SignedTransaction; +use reth_primitives_traits::{Block, BlockBody, SignedTransaction}; use reth_provider::{BlockExecutionOutput, ChainSpecProvider, StateProviderFactory}; use reth_revm::{ database::StateProviderDatabase, db::states::bundle_state::BundleRetention, @@ -99,7 +99,7 @@ where // Re-execute all of the transactions in the block to load all touched accounts into // the cache DB. - for tx in block.transactions() { + for tx in block.body().transactions() { self.evm_config.fill_tx_env( evm.tx_mut(), tx, @@ -113,10 +113,8 @@ where // use U256::MAX here for difficulty, because fetching it is annoying // NOTE: This is not mut because we are not doing the DAO irregular state change here - let balance_increments = post_block_balance_increments( - self.provider.chain_spec().as_ref(), - &block.clone().unseal().block, - ); + let balance_increments = + post_block_balance_increments(self.provider.chain_spec().as_ref(), block.block()); // increment balances db.increment_balances(balance_increments)?; diff --git a/crates/rpc/rpc-engine-api/src/engine_api.rs b/crates/rpc/rpc-engine-api/src/engine_api.rs index da798c82c6c0..751ad78ac582 100644 --- a/crates/rpc/rpc-engine-api/src/engine_api.rs +++ b/crates/rpc/rpc-engine-api/src/engine_api.rs @@ -1155,7 +1155,7 @@ mod tests { let expected = blocks .iter() .cloned() - .map(|b| Some(ExecutionPayloadBodyV1::from_block(b.into_block::()))) + .map(|b| Some(ExecutionPayloadBodyV1::from_block(b.into_block()))) .collect::>(); let res = api.get_payload_bodies_by_range_v1(start, count).await.unwrap(); @@ -1197,7 +1197,7 @@ mod tests { if first_missing_range.contains(&b.number) { None } else { - Some(ExecutionPayloadBodyV1::from_block(b.into_block::())) + Some(ExecutionPayloadBodyV1::from_block(b.into_block())) } }) .collect::>(); @@ -1216,7 +1216,7 @@ mod tests { { None } else { - Some(ExecutionPayloadBodyV1::from_block(b.into_block::())) + Some(ExecutionPayloadBodyV1::from_block(b.into_block())) } }) .collect::>(); diff --git a/crates/rpc/rpc-engine-api/tests/it/payload.rs b/crates/rpc/rpc-engine-api/tests/it/payload.rs index 5ebd97f9d652..69ea5bb175c0 100644 --- a/crates/rpc/rpc-engine-api/tests/it/payload.rs +++ b/crates/rpc/rpc-engine-api/tests/it/payload.rs @@ -33,7 +33,7 @@ fn payload_body_roundtrip() { BlockRangeParams { tx_count: 0..2, ..Default::default() }, ) { let payload_body: ExecutionPayloadBodyV1 = - ExecutionPayloadBodyV1::from_block(block.clone().into_block::()); + ExecutionPayloadBodyV1::from_block(block.clone().into_block()); assert_eq!( Ok(block.body().transactions.clone()), diff --git a/crates/static-file/static-file/src/static_file_producer.rs b/crates/static-file/static-file/src/static_file_producer.rs index fcbbb9e3b0a3..38d68c9f9a23 100644 --- a/crates/static-file/static-file/src/static_file_producer.rs +++ b/crates/static-file/static-file/src/static_file_producer.rs @@ -292,7 +292,7 @@ mod tests { let tx = db.factory.db_ref().tx_mut().expect("init tx"); for block in &blocks { - TestStageDB::insert_header(None, &tx, block.sealed_header(), U256::ZERO) + TestStageDB::insert_header(None, &tx, &block.clone_sealed_header(), U256::ZERO) .expect("insert block header"); } tx.commit().expect("commit tx"); diff --git a/testing/ef-tests/src/cases/blockchain_test.rs b/testing/ef-tests/src/cases/blockchain_test.rs index 77df3106b164..98a64f9bab99 100644 --- a/testing/ef-tests/src/cases/blockchain_test.rs +++ b/testing/ef-tests/src/cases/blockchain_test.rs @@ -91,11 +91,11 @@ impl Case for BlockchainTestCase { // Insert initial test state into the provider. provider.insert_historical_block( - SealedBlock::new( - case.genesis_block_header.clone().into(), + SealedBlock::seal_parts( + case.genesis_block_header.clone(), BlockBody::default(), ) - .try_with_senders() + .try_recover() .unwrap(), )?; case.pre.write_to_db(provider.tx_ref())?; @@ -111,7 +111,8 @@ impl Case for BlockchainTestCase { // Decode and insert blocks, creating a chain of blocks for the test case. let last_block = case.blocks.iter().try_fold(None, |_, block| { - let decoded = SealedBlock::decode(&mut block.rlp.as_ref())?; + let decoded = + SealedBlock::::decode(&mut block.rlp.as_ref())?; provider .insert_historical_block(decoded.clone().try_with_senders().unwrap())?; Ok::, Error>(Some(decoded))