Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: make ensure_well_formed_payload generic over transaction #13404

Merged
merged 1 commit into from
Dec 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/payload/validator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 8 additions & 7 deletions crates/payload/validator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -59,9 +60,9 @@ impl<ChainSpec: EthereumHardforks> ExecutionPayloadValidator<ChainSpec> {
///
/// 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<T: SignedTransaction>(
&self,
sealed_block: &SealedBlock,
sealed_block: &SealedBlock<Header, BlockBody<T>>,
cancun_fields: &MaybeCancunPayloadFields,
) -> Result<(), PayloadError> {
let num_blob_versioned_hashes = sealed_block.blob_versioned_hashes_iter().count();
Expand Down Expand Up @@ -112,11 +113,11 @@ impl<ChainSpec: EthereumHardforks> ExecutionPayloadValidator<ChainSpec> {
///
/// This validates versioned hashes according to the Engine API Cancun spec:
/// <https://github.com/ethereum/execution-apis/blob/fe8e13c288c592ec154ce25c534e26cb7ce0530d/src/engine/cancun.md#specification>
pub fn ensure_well_formed_payload(
pub fn ensure_well_formed_payload<T: SignedTransaction>(
&self,
payload: ExecutionPayload,
sidecar: ExecutionPayloadSidecar,
) -> Result<SealedBlock, PayloadError> {
) -> Result<SealedBlock<Header, BlockBody<T>>, PayloadError> {
let expected_hash = payload.block_hash();

// First parse the block
Expand Down Expand Up @@ -144,7 +145,7 @@ impl<ChainSpec: EthereumHardforks> ExecutionPayloadValidator<ChainSpec> {
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)
}
Expand All @@ -169,7 +170,7 @@ impl<ChainSpec: EthereumHardforks> ExecutionPayloadValidator<ChainSpec> {
}

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)
}
Expand Down
6 changes: 2 additions & 4 deletions crates/primitives/src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -36,7 +34,7 @@ impl<T> Default for Block<T> {

impl<T> reth_primitives_traits::Block for Block<T>
where
T: SignedTransaction + Encodable + Decodable + MaybeSerdeBincodeCompat,
T: SignedTransaction,
{
type Header = Header;
type Body = BlockBody<T>;
Expand Down
Loading