chore: misc SealedBlock prep (#13736)

This commit is contained in:
Matthias Seitz
2025-01-08 16:07:52 +01:00
committed by GitHub
parent b5734bfb65
commit f2521b54de
6 changed files with 12 additions and 36 deletions

View File

@ -640,7 +640,7 @@ impl<N: NodePrimitives> BlockState<N> {
pub fn block_with_senders(&self) -> BlockWithSenders<N::Block> {
let block = self.block.block().clone();
let senders = self.block.senders().clone();
let (header, body) = block.split_header_body();
let (header, body) = block.split();
BlockWithSenders::new_unchecked(N::Block::new(header.unseal(), body), senders)
}

View File

@ -108,7 +108,7 @@ where
// Unseal the block for execution
let (block, senders) = block.into_components();
let (header, body) = block.split_header_body();
let (header, body) = block.split();
let (unsealed_header, hash) = header.split();
let block = P::Block::new(unsealed_header, body).with_senders_unchecked(senders);

View File

@ -429,7 +429,7 @@ where
// put response hashes back into bodies map since we aren't returning them as a
// response
for block in valid_responses {
let (header, body) = block.split_header_body();
let (header, body) = block.split();
self.bodies.insert(header, BodyResponse::Validated(body));
}

View File

@ -5,7 +5,7 @@ use crate::{
use alloc::vec::Vec;
use alloy_consensus::Header;
use alloy_eips::{eip2718::Encodable2718, eip4895::Withdrawals};
use alloy_primitives::{Address, Bytes, B256};
use alloy_primitives::{Address, B256};
use alloy_rlp::{Decodable, Encodable, RlpDecodable, RlpEncodable};
use derive_more::{Deref, DerefMut};
#[cfg(any(test, feature = "arbitrary"))]
@ -212,25 +212,11 @@ impl<H, B> SealedBlock<H, B> {
/// Splits the [`BlockBody`] and [`SealedHeader`] into separate components
#[inline]
pub fn split_header_body(self) -> (SealedHeader<H>, B) {
pub fn split(self) -> (SealedHeader<H>, B) {
(self.header, self.body)
}
}
impl SealedBlock {
/// Returns whether or not the block contains any blob transactions.
#[inline]
pub fn has_eip4844_transactions(&self) -> bool {
self.body.has_eip4844_transactions()
}
/// Returns whether or not the block contains any eip-7702 transactions.
#[inline]
pub fn has_eip7702_transactions(&self) -> bool {
self.body.has_eip7702_transactions()
}
}
impl<H, B> SealedBlock<H, B>
where
B: reth_primitives_traits::BlockBody,
@ -369,16 +355,6 @@ where
{
Block::new(self.header.unseal(), self.body)
}
/// Returns a vector of encoded 2718 transactions.
///
/// This is also known as `raw transactions`.
///
/// See also [`Encodable2718`].
#[doc(alias = "raw_transactions")]
pub fn encoded_2718_transactions(&self) -> Vec<Bytes> {
self.body.encoded_2718_transactions()
}
}
impl<H: InMemorySize, B: InMemorySize> InMemorySize for SealedBlock<H, B> {
@ -457,7 +433,7 @@ impl<B: reth_primitives_traits::Block> SealedBlockWithSenders<B> {
#[inline]
pub fn unseal(self) -> BlockWithSenders<B> {
let (block, senders) = self.into_components();
let (header, body) = block.split_header_body();
let (header, body) = block.split();
let header = header.unseal();
BlockWithSenders::new_unchecked(B::new(header, body), senders)
}

View File

@ -525,7 +525,7 @@ mod tests {
stage_progress,
BlockParams { parent: preblocks.last().map(|b| b.hash()), ..Default::default() },
)
.split_header_body();
.split();
let mut header = header.unseal();
header.state_root = state_root(

View File

@ -232,7 +232,7 @@ fn block1(number: BlockNumber) -> (SealedBlockWithSenders, ExecutionOutcome) {
b256!("5d035ccb3e75a9057452ff060b773b213ec1fc353426174068edfc3971a0b6bd")
);
let (header, mut body) = TEST_BLOCK.clone().split_header_body();
let (header, mut body) = TEST_BLOCK.clone().split();
body.withdrawals = Some(Withdrawals::new(vec![Withdrawal::default()]));
let mut header = header.unseal();
header.number = number;
@ -294,7 +294,7 @@ fn block2(
b256!("90101a13dd059fa5cca99ed93d1dc23657f63626c5b8f993a2ccbdf7446b64f8")
);
let (header, mut body) = TEST_BLOCK.clone().split_header_body();
let (header, mut body) = TEST_BLOCK.clone().split();
body.withdrawals = Some(Withdrawals::new(vec![Withdrawal::default()]));
let mut header = header.unseal();
@ -359,7 +359,7 @@ fn block3(
extended.extend(execution_outcome.clone());
let state_root = bundle_state_root(&extended);
let (header, mut body) = TEST_BLOCK.clone().split_header_body();
let (header, mut body) = TEST_BLOCK.clone().split();
body.withdrawals = Some(Withdrawals::new(vec![Withdrawal::default()]));
let mut header = header.unseal();
header.number = number;
@ -448,7 +448,7 @@ fn block4(
extended.extend(execution_outcome.clone());
let state_root = bundle_state_root(&extended);
let (header, mut body) = TEST_BLOCK.clone().split_header_body();
let (header, mut body) = TEST_BLOCK.clone().split();
body.withdrawals = Some(Withdrawals::new(vec![Withdrawal::default()]));
let mut header = header.unseal();
header.number = number;
@ -534,7 +534,7 @@ fn block5(
extended.extend(execution_outcome.clone());
let state_root = bundle_state_root(&extended);
let (header, mut body) = TEST_BLOCK.clone().split_header_body();
let (header, mut body) = TEST_BLOCK.clone().split();
body.withdrawals = Some(Withdrawals::new(vec![Withdrawal::default()]));
let mut header = header.unseal();
header.number = number;