From ba38bc46bbc2405db67f37fb4c55bdd37212dea9 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Sat, 14 Dec 2024 17:43:36 +0400 Subject: [PATCH] chore: make ensure_well_formed_payload generic over transaction --- Cargo.lock | 1 + crates/payload/validator/Cargo.toml | 1 + crates/payload/validator/src/lib.rs | 15 ++++++++------- crates/primitives/src/block.rs | 6 ++---- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c8073c551af2..4a9c9f2adc0e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8733,6 +8733,7 @@ dependencies = [ "alloy-rpc-types", "reth-chainspec", "reth-primitives", + "reth-primitives-traits", "reth-rpc-types-compat", ] diff --git a/crates/payload/validator/Cargo.toml b/crates/payload/validator/Cargo.toml index 2662b987f889..fee8d01d2baa 100644 --- a/crates/payload/validator/Cargo.toml +++ b/crates/payload/validator/Cargo.toml @@ -15,6 +15,7 @@ workspace = true # reth reth-chainspec.workspace = true reth-primitives.workspace = true +reth-primitives-traits.workspace = true reth-rpc-types-compat.workspace = true # alloy diff --git a/crates/payload/validator/src/lib.rs b/crates/payload/validator/src/lib.rs index 57772de25879..30f1ca02b964 100644 --- a/crates/payload/validator/src/lib.rs +++ b/crates/payload/validator/src/lib.rs @@ -12,7 +12,8 @@ use alloy_rpc_types::engine::{ ExecutionPayload, ExecutionPayloadSidecar, MaybeCancunPayloadFields, PayloadError, }; use reth_chainspec::EthereumHardforks; -use reth_primitives::{BlockExt, SealedBlock}; +use reth_primitives::{BlockBody, BlockExt, Header, SealedBlock}; +use reth_primitives_traits::SignedTransaction; use reth_rpc_types_compat::engine::payload::try_into_block; use std::sync::Arc; @@ -59,9 +60,9 @@ impl ExecutionPayloadValidator { /// /// Ensures that the number of blob versioned hashes matches the number hashes included in the /// _separate_ `block_versioned_hashes` of the cancun payload fields. - fn ensure_matching_blob_versioned_hashes( + fn ensure_matching_blob_versioned_hashes( &self, - sealed_block: &SealedBlock, + sealed_block: &SealedBlock>, cancun_fields: &MaybeCancunPayloadFields, ) -> Result<(), PayloadError> { let num_blob_versioned_hashes = sealed_block.blob_versioned_hashes_iter().count(); @@ -112,11 +113,11 @@ impl ExecutionPayloadValidator { /// /// This validates versioned hashes according to the Engine API Cancun spec: /// - pub fn ensure_well_formed_payload( + pub fn ensure_well_formed_payload( &self, payload: ExecutionPayload, sidecar: ExecutionPayloadSidecar, - ) -> Result { + ) -> Result>, PayloadError> { let expected_hash = payload.block_hash(); // First parse the block @@ -144,7 +145,7 @@ impl ExecutionPayloadValidator { return Err(PayloadError::PostCancunWithoutCancunFields) } } else { - if sealed_block.has_eip4844_transactions() { + if sealed_block.body.has_eip4844_transactions() { // cancun not active but blob transactions present return Err(PayloadError::PreCancunBlockWithBlobTransactions) } @@ -169,7 +170,7 @@ impl ExecutionPayloadValidator { } if !self.is_prague_active_at_timestamp(sealed_block.timestamp) && - sealed_block.has_eip7702_transactions() + sealed_block.body.has_eip7702_transactions() { return Err(PayloadError::PrePragueBlockWithEip7702Transactions) } diff --git a/crates/primitives/src/block.rs b/crates/primitives/src/block.rs index 8691cfa101bf..36d1b382a33c 100644 --- a/crates/primitives/src/block.rs +++ b/crates/primitives/src/block.rs @@ -10,9 +10,7 @@ use alloy_rlp::{Decodable, Encodable, RlpDecodable, RlpEncodable}; use derive_more::{Deref, DerefMut}; #[cfg(any(test, feature = "arbitrary"))] pub use reth_primitives_traits::test_utils::{generate_valid_header, valid_header_strategy}; -use reth_primitives_traits::{ - BlockBody as _, InMemorySize, MaybeSerdeBincodeCompat, SignedTransaction, Transaction, -}; +use reth_primitives_traits::{BlockBody as _, InMemorySize, SignedTransaction, Transaction}; use serde::{Deserialize, Serialize}; /// Ethereum full block. @@ -36,7 +34,7 @@ impl Default for Block { impl reth_primitives_traits::Block for Block where - T: SignedTransaction + Encodable + Decodable + MaybeSerdeBincodeCompat, + T: SignedTransaction, { type Header = Header; type Body = BlockBody;