chore: move calculate tx root to blockbody trait (#13209)

This commit is contained in:
Matthias Seitz
2024-12-07 13:17:11 +01:00
committed by GitHub
parent 42a1ba3a82
commit 410d361638
3 changed files with 8 additions and 13 deletions

View File

@ -7,9 +7,8 @@ use alloy_eips::{
};
use reth_chainspec::{EthChainSpec, EthereumHardforks};
use reth_consensus::ConsensusError;
use reth_primitives::{
BlockBody, BlockBodyTxExt, EthereumHardfork, GotExpected, SealedBlock, SealedHeader,
};
use reth_primitives::{BlockBody, EthereumHardfork, GotExpected, SealedBlock, SealedHeader};
use reth_primitives_traits::BlockBody as _;
use revm_primitives::calc_excess_blob_gas;
/// Gas used needs to be less than gas limit. Gas used is going to be checked after execution.

View File

@ -7,7 +7,7 @@ use crate::{
use alloc::{fmt, vec::Vec};
use alloy_consensus::Transaction;
use alloy_eips::{eip2718::Encodable2718, eip4844::DATA_GAS_PER_BLOB, eip4895::Withdrawals};
use alloy_primitives::Bytes;
use alloy_primitives::{Bytes, B256};
/// Helper trait that unifies all behaviour required by transaction to support full node operations.
pub trait FullBlockBody: BlockBody<Transaction: FullSignedTx> {}
@ -44,6 +44,11 @@ pub trait BlockBody:
/// Consume the block body and return a [`Vec`] of transactions.
fn into_transactions(self) -> Vec<Self::Transaction>;
/// Calculate the transaction root for the block body.
fn calculate_tx_root(&self) -> B256 {
alloy_consensus::proofs::calculate_transaction_root(self.transactions())
}
/// Returns block withdrawals if any.
fn withdrawals(&self) -> Option<&Withdrawals>;

View File

@ -3,7 +3,6 @@ use crate::{
BlockWithSenders, SealedBlock,
};
use alloc::vec::Vec;
use alloy_eips::eip2718::Encodable2718;
use reth_primitives_traits::{Block, BlockBody, SealedHeader, SignedTransaction};
use revm_primitives::{Address, B256};
@ -91,14 +90,6 @@ impl<T: Block> BlockExt for T {}
/// Extension trait for [`BlockBody`] adding helper methods operating with transactions.
pub trait BlockBodyTxExt: BlockBody {
/// Calculate the transaction root for the block body.
fn calculate_tx_root(&self) -> B256
where
Self::Transaction: Encodable2718,
{
crate::proofs::calculate_transaction_root(self.transactions())
}
/// Recover signer addresses for all transactions in the block body.
fn recover_signers(&self) -> Option<Vec<Address>>
where