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: misc SealedBlock prep #13736

Merged
merged 1 commit into from
Jan 8, 2025
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
2 changes: 1 addition & 1 deletion crates/chain-state/src/in_memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
2 changes: 1 addition & 1 deletion crates/exex/exex/src/backfill/job.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion crates/net/p2p/src/full_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down
30 changes: 3 additions & 27 deletions crates/primitives/src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"))]
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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> {
Expand Down Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion crates/stages/stages/src/stages/merkle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
10 changes: 5 additions & 5 deletions crates/storage/provider/src/test_utils/blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Loading