feat: merge BlockBodyTxExt trait into BlockBody (#13613)

Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
DevOrbitlabs
2025-01-03 22:57:59 +07:00
committed by GitHub
parent afdffadafd
commit 8f854cbbb6
6 changed files with 46 additions and 34 deletions

View File

@ -1,6 +1,6 @@
use crate::{
traits::BlockExt, transaction::SignedTransactionIntoRecoveredExt, BlockBodyTxExt, GotExpected,
RecoveredTx, SealedHeader, TransactionSigned,
traits::BlockExt, transaction::SignedTransactionIntoRecoveredExt, GotExpected, RecoveredTx,
SealedHeader, TransactionSigned,
};
use alloc::vec::Vec;
use alloy_consensus::Header;

View File

@ -1,7 +1,4 @@
use crate::{
transaction::{recover_signers, recover_signers_unchecked},
BlockWithSenders, SealedBlock,
};
use crate::{BlockWithSenders, SealedBlock};
use alloc::vec::Vec;
use reth_primitives_traits::{Block, BlockBody, SealedHeader, SignedTransaction};
use revm_primitives::{Address, B256};
@ -52,7 +49,6 @@ pub trait BlockExt: Block {
///
/// If the number of senders does not match the number of transactions in the block, this falls
/// back to manually recovery, but _without ensuring that the signature has a low `s` value_.
/// See also [`recover_signers_unchecked`]
///
/// Returns an error if a signature is invalid.
#[track_caller]
@ -87,28 +83,3 @@ pub trait BlockExt: Block {
}
impl<T: Block> BlockExt for T {}
/// Extension trait for [`BlockBody`] adding helper methods operating with transactions.
pub trait BlockBodyTxExt: BlockBody {
/// Recover signer addresses for all transactions in the block body.
fn recover_signers(&self) -> Option<Vec<Address>>
where
Self::Transaction: SignedTransaction,
{
recover_signers(self.transactions(), self.transactions().len())
}
/// Recover signer addresses for all transactions in the block body _without ensuring that the
/// signature has a low `s` value_.
///
/// Returns `None`, if some transaction's signature is invalid, see also
/// [`recover_signers_unchecked`].
fn recover_signers_unchecked(&self) -> Option<Vec<Address>>
where
Self::Transaction: SignedTransaction,
{
recover_signers_unchecked(self.transactions(), self.transactions().len())
}
}
impl<T: BlockBody> BlockBodyTxExt for T {}