chore: remove block_to_payload_v1 (#14143)

Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
Arpit Temani
2025-02-01 16:36:35 +05:30
committed by GitHub
parent 5c7df17a48
commit 209b44829e
11 changed files with 22 additions and 47 deletions

3
Cargo.lock generated
View File

@ -7260,7 +7260,6 @@ dependencies = [
"reth-primitives-traits",
"reth-provider",
"reth-revm",
"reth-rpc-types-compat",
"reth-trie",
"revm-primitives",
"serde",
@ -7382,7 +7381,6 @@ dependencies = [
"reth-payload-primitives",
"reth-payload-validator",
"reth-primitives",
"reth-rpc-types-compat",
"serde",
"serde_json",
"sha2 0.10.8",
@ -8378,7 +8376,6 @@ dependencies = [
"reth-primitives-traits",
"reth-provider",
"reth-revm",
"reth-rpc-types-compat",
"reth-transaction-pool",
"revm",
"sha2 0.10.8",

View File

@ -2904,7 +2904,7 @@ mod tests {
use alloy_primitives::Bytes;
use alloy_rlp::Decodable;
use alloy_rpc_types_engine::{
CancunPayloadFields, ExecutionPayloadSidecar, ExecutionPayloadV3,
CancunPayloadFields, ExecutionPayloadSidecar, ExecutionPayloadV1, ExecutionPayloadV3,
};
use assert_matches::assert_matches;
use reth_chain_state::{test_utils::TestBlockBuilder, BlockState};
@ -2916,7 +2916,6 @@ mod tests {
use reth_evm::test_utils::MockExecutorProvider;
use reth_primitives_traits::Block as _;
use reth_provider::test_utils::MockEthProvider;
use reth_rpc_types_compat::engine::block_to_payload_v1;
use reth_trie::{updates::TrieUpdates, HashedPostState};
use std::{
str::FromStr,
@ -3455,7 +3454,7 @@ mod tests {
let block = Block::decode(&mut data.as_ref()).unwrap();
let sealed = block.seal_slow();
let hash = sealed.hash();
let payload = block_to_payload_v1(sealed.clone());
let payload = ExecutionPayloadV1::from_block_unchecked(hash, &sealed.clone().into_block());
let mut test_harness = TestHarness::new(HOLESKY.clone());
@ -3495,7 +3494,8 @@ mod tests {
let data = Bytes::from_str(s).unwrap();
let block: Block = Block::decode(&mut data.as_ref()).unwrap();
let sealed = block.seal_slow();
let payload = block_to_payload_v1(sealed);
let payload =
ExecutionPayloadV1::from_block_unchecked(sealed.hash(), &sealed.clone().into_block());
let mut test_harness =
TestHarness::new(HOLESKY.clone()).with_backfill_state(BackfillSyncState::Active);

View File

@ -18,7 +18,6 @@ reth-errors.workspace = true
reth-chainspec.workspace = true
reth-consensus-common.workspace = true
reth-fs-util.workspace = true
reth-rpc-types-compat.workspace = true
reth-engine-primitives.workspace = true
reth-payload-validator.workspace = true
reth-evm.workspace = true

View File

@ -17,7 +17,6 @@ reth-primitives.workspace = true
reth-engine-primitives.workspace = true
reth-payload-primitives.workspace = true
reth-payload-validator.workspace = true
reth-rpc-types-compat.workspace = true
# alloy
alloy-primitives.workspace = true

View File

@ -11,7 +11,6 @@ use alloy_rpc_types_engine::{
use core::convert::Infallible;
use reth_payload_primitives::{BuiltPayload, PayloadBuilderAttributes};
use reth_primitives::{EthPrimitives, SealedBlock};
use reth_rpc_types_compat::engine::payload::block_to_payload_v1;
/// Contains the built payload.
///
@ -118,7 +117,10 @@ impl BuiltPayload for &EthBuiltPayload {
// V1 engine_getPayloadV1 response
impl From<EthBuiltPayload> for ExecutionPayloadV1 {
fn from(value: EthBuiltPayload) -> Self {
block_to_payload_v1(Arc::unwrap_or_clone(value.block))
Self::from_block_unchecked(
value.block().hash(),
&Arc::unwrap_or_clone(value.block).into_block(),
)
}
}

View File

@ -19,7 +19,6 @@ reth-primitives-traits.workspace = true
reth-revm = { workspace = true, features = ["witness"] }
reth-transaction-pool.workspace = true
reth-provider.workspace = true
reth-rpc-types-compat.workspace = true
reth-evm.workspace = true
reth-execution-types.workspace = true
reth-payload-builder.workspace = true

View File

@ -21,7 +21,7 @@ use reth_optimism_primitives::{OpBlock, OpPrimitives, OpTransactionSigned};
use reth_payload_builder::EthPayloadBuilderAttributes;
use reth_payload_primitives::{BuiltPayload, PayloadBuilderAttributes};
use reth_primitives::{transaction::WithEncoded, SealedBlock};
use reth_rpc_types_compat::engine::payload::block_to_payload_v1;
use std::sync::Arc;
/// Optimism Payload Builder Attributes
@ -229,7 +229,10 @@ impl BuiltPayload for &OpBuiltPayload {
// V1 engine_getPayloadV1 response
impl From<OpBuiltPayload> for ExecutionPayloadV1 {
fn from(value: OpBuiltPayload) -> Self {
block_to_payload_v1(Arc::unwrap_or_clone(value.block))
Self::from_block_unchecked(
value.block().hash(),
&Arc::unwrap_or_clone(value.block).into_block(),
)
}
}

View File

@ -12,7 +12,6 @@ use reth_primitives::{Block, TransactionSigned};
use reth_primitives_traits::block::Block as _;
use reth_rpc_api::clients::EngineApiClient;
use reth_rpc_layer::JwtSecret;
use reth_rpc_types_compat::engine::payload::block_to_payload_v1;
#[allow(unused_must_use)]
async fn test_basic_engine_calls<C>(client: &C)
@ -20,7 +19,11 @@ where
C: ClientT + SubscriptionClientT + Sync + EngineApiClient<EthEngineTypes>,
{
let block = Block::<_>::default().seal_slow();
EngineApiClient::new_payload_v1(client, block_to_payload_v1(block.clone())).await;
EngineApiClient::new_payload_v1(
client,
ExecutionPayloadV1::from_block_unchecked(block.hash(), &block.clone().into_block()),
)
.await;
EngineApiClient::new_payload_v2(
client,
ExecutionPayloadInputV2 {

View File

@ -10,7 +10,6 @@ use alloy_rpc_types_engine::{
use assert_matches::assert_matches;
use reth_primitives::{Block, SealedBlock, TransactionSigned};
use reth_primitives_traits::proofs;
use reth_rpc_types_compat::engine::payload::block_to_payload_v1;
use reth_testing_utils::generators::{
self, random_block, random_block_range, BlockParams, BlockRangeParams, Rng,
};
@ -99,7 +98,8 @@ fn payload_validation_conversion() {
);
// Invalid encoded transactions
let mut payload_with_invalid_txs: ExecutionPayloadV1 = block_to_payload_v1(block);
let mut payload_with_invalid_txs =
ExecutionPayloadV1::from_block_unchecked(block.hash(), &block.into_block());
payload_with_invalid_txs.transactions.iter_mut().for_each(|tx| {
*tx = Bytes::new();

View File

@ -1,3 +1,2 @@
//! Standalone functions for engine specific rpc type conversions
pub mod payload;
pub use payload::block_to_payload_v1;

View File

@ -2,34 +2,8 @@
//! Ethereum's Engine
use alloy_eips::{eip2718::Encodable2718, eip4895::Withdrawals};
use alloy_primitives::U256;
use alloy_rpc_types_engine::{payload::ExecutionPayloadBodyV1, ExecutionPayloadV1};
use reth_primitives::{Block, SealedBlock};
use reth_primitives_traits::{BlockBody as _, SignedTransaction};
/// Converts [`SealedBlock`] to [`ExecutionPayloadV1`]
pub fn block_to_payload_v1<T: SignedTransaction>(
value: SealedBlock<Block<T>>,
) -> ExecutionPayloadV1 {
let transactions =
value.body().transactions.iter().map(|tx| tx.encoded_2718().into()).collect::<Vec<_>>();
ExecutionPayloadV1 {
parent_hash: value.parent_hash,
fee_recipient: value.beneficiary,
state_root: value.state_root,
receipts_root: value.receipts_root,
logs_bloom: value.logs_bloom,
prev_randao: value.mix_hash,
block_number: value.number,
gas_limit: value.gas_limit,
gas_used: value.gas_used,
timestamp: value.timestamp,
extra_data: value.extra_data.clone(),
base_fee_per_gas: U256::from(value.base_fee_per_gas.unwrap_or_default()),
block_hash: value.hash(),
transactions,
}
}
use alloy_rpc_types_engine::payload::ExecutionPayloadBodyV1;
use reth_primitives_traits::BlockBody as _;
/// Converts a [`reth_primitives_traits::Block`] to [`ExecutionPayloadBodyV1`]
pub fn convert_to_payload_body_v1(