mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore!: make senders fields private (#13752)
This commit is contained in:
@ -648,7 +648,7 @@ impl<N: NodePrimitives> BlockState<N> {
|
|||||||
pub fn sealed_block_with_senders(&self) -> SealedBlockWithSenders<N::Block> {
|
pub fn sealed_block_with_senders(&self) -> SealedBlockWithSenders<N::Block> {
|
||||||
let block = self.block.block().clone();
|
let block = self.block.block().clone();
|
||||||
let senders = self.block.senders().clone();
|
let senders = self.block.senders().clone();
|
||||||
SealedBlockWithSenders { block, senders }
|
SealedBlockWithSenders::new_unchecked(block, senders)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the hash of executed block that determines the state.
|
/// Returns the hash of executed block that determines the state.
|
||||||
@ -840,7 +840,7 @@ impl<N: NodePrimitives> ExecutedBlock<N> {
|
|||||||
///
|
///
|
||||||
/// Note: this clones the block and senders.
|
/// Note: this clones the block and senders.
|
||||||
pub fn sealed_block_with_senders(&self) -> SealedBlockWithSenders<N::Block> {
|
pub fn sealed_block_with_senders(&self) -> SealedBlockWithSenders<N::Block> {
|
||||||
SealedBlockWithSenders { block: (*self.block).clone(), senders: (*self.senders).clone() }
|
SealedBlockWithSenders::new_unchecked((*self.block).clone(), (*self.senders).clone())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a reference to the block's execution outcome
|
/// Returns a reference to the block's execution outcome
|
||||||
|
|||||||
@ -207,9 +207,10 @@ impl<N: NodePrimitives> TestBlockBuilder<N> {
|
|||||||
) -> ExecutedBlock {
|
) -> ExecutedBlock {
|
||||||
let block_with_senders = self.generate_random_block(block_number, parent_hash);
|
let block_with_senders = self.generate_random_block(block_number, parent_hash);
|
||||||
|
|
||||||
|
let (block, senders) = block_with_senders.split();
|
||||||
ExecutedBlock::new(
|
ExecutedBlock::new(
|
||||||
Arc::new(block_with_senders.block.clone()),
|
Arc::new(block),
|
||||||
Arc::new(block_with_senders.senders),
|
Arc::new(senders),
|
||||||
Arc::new(ExecutionOutcome::new(
|
Arc::new(ExecutionOutcome::new(
|
||||||
BundleState::default(),
|
BundleState::default(),
|
||||||
receipts,
|
receipts,
|
||||||
|
|||||||
@ -233,10 +233,9 @@ where
|
|||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|b| {
|
.map(|b| {
|
||||||
let senders = b.senders().unwrap_or_default();
|
let senders = b.senders().unwrap_or_default();
|
||||||
OrderedSealedBlockWithSenders(SealedBlockWithSenders {
|
OrderedSealedBlockWithSenders(SealedBlockWithSenders::new_unchecked(
|
||||||
block: b,
|
b, senders,
|
||||||
senders,
|
))
|
||||||
})
|
|
||||||
})
|
})
|
||||||
.map(Reverse),
|
.map(Reverse),
|
||||||
);
|
);
|
||||||
@ -290,14 +289,13 @@ impl<B: Block> Ord for OrderedSealedBlockWithSenders<B> {
|
|||||||
impl<B: Block> From<SealedBlockFor<B>> for OrderedSealedBlockWithSenders<B> {
|
impl<B: Block> From<SealedBlockFor<B>> for OrderedSealedBlockWithSenders<B> {
|
||||||
fn from(block: SealedBlockFor<B>) -> Self {
|
fn from(block: SealedBlockFor<B>) -> Self {
|
||||||
let senders = block.senders().unwrap_or_default();
|
let senders = block.senders().unwrap_or_default();
|
||||||
Self(SealedBlockWithSenders { block, senders })
|
Self(SealedBlockWithSenders::new_unchecked(block, senders))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<B: Block> From<OrderedSealedBlockWithSenders<B>> for SealedBlockWithSenders<B> {
|
impl<B: Block> From<OrderedSealedBlockWithSenders<B>> for SealedBlockWithSenders<B> {
|
||||||
fn from(value: OrderedSealedBlockWithSenders<B>) -> Self {
|
fn from(value: OrderedSealedBlockWithSenders<B>) -> Self {
|
||||||
let senders = value.0.senders;
|
value.0
|
||||||
Self { block: value.0.block, senders }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1597,10 +1597,11 @@ where
|
|||||||
return Ok(None)
|
return Ok(None)
|
||||||
};
|
};
|
||||||
|
|
||||||
let SealedBlockWithSenders { block, senders } = self
|
let (block, senders) = self
|
||||||
.provider
|
.provider
|
||||||
.sealed_block_with_senders(hash.into(), TransactionVariant::WithHash)?
|
.sealed_block_with_senders(hash.into(), TransactionVariant::WithHash)?
|
||||||
.ok_or_else(|| ProviderError::HeaderNotFound(hash.into()))?;
|
.ok_or_else(|| ProviderError::HeaderNotFound(hash.into()))?
|
||||||
|
.split();
|
||||||
let execution_output = self
|
let execution_output = self
|
||||||
.provider
|
.provider
|
||||||
.get_state(block.number())?
|
.get_state(block.number())?
|
||||||
@ -2452,7 +2453,7 @@ where
|
|||||||
|
|
||||||
let executed: ExecutedBlock<N> = ExecutedBlock {
|
let executed: ExecutedBlock<N> = ExecutedBlock {
|
||||||
block: sealed_block.clone(),
|
block: sealed_block.clone(),
|
||||||
senders: Arc::new(block.senders),
|
senders: Arc::new(block.senders().to_vec()),
|
||||||
execution_output: Arc::new(ExecutionOutcome::from((output, block_number))),
|
execution_output: Arc::new(ExecutionOutcome::from((output, block_number))),
|
||||||
hashed_state: Arc::new(hashed_state),
|
hashed_state: Arc::new(hashed_state),
|
||||||
trie: Arc::new(trie_output),
|
trie: Arc::new(trie_output),
|
||||||
@ -3002,9 +3003,11 @@ mod tests {
|
|||||||
self.persist_blocks(
|
self.persist_blocks(
|
||||||
blocks
|
blocks
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|b| SealedBlockWithSenders {
|
.map(|b| {
|
||||||
block: (*b.block).clone(),
|
SealedBlockWithSenders::new_unchecked(
|
||||||
senders: b.senders.to_vec(),
|
(*b.block).clone(),
|
||||||
|
b.senders().clone(),
|
||||||
|
)
|
||||||
})
|
})
|
||||||
.collect(),
|
.collect(),
|
||||||
);
|
);
|
||||||
@ -3710,7 +3713,7 @@ mod tests {
|
|||||||
for block in &chain_a {
|
for block in &chain_a {
|
||||||
test_harness.tree.state.tree_state.insert_executed(ExecutedBlock {
|
test_harness.tree.state.tree_state.insert_executed(ExecutedBlock {
|
||||||
block: Arc::new(block.block.clone()),
|
block: Arc::new(block.block.clone()),
|
||||||
senders: Arc::new(block.senders.clone()),
|
senders: Arc::new(block.senders().to_vec()),
|
||||||
execution_output: Arc::new(ExecutionOutcome::default()),
|
execution_output: Arc::new(ExecutionOutcome::default()),
|
||||||
hashed_state: Arc::new(HashedPostState::default()),
|
hashed_state: Arc::new(HashedPostState::default()),
|
||||||
trie: Arc::new(TrieUpdates::default()),
|
trie: Arc::new(TrieUpdates::default()),
|
||||||
@ -3721,7 +3724,7 @@ mod tests {
|
|||||||
for block in &chain_b {
|
for block in &chain_b {
|
||||||
test_harness.tree.state.tree_state.insert_executed(ExecutedBlock {
|
test_harness.tree.state.tree_state.insert_executed(ExecutedBlock {
|
||||||
block: Arc::new(block.block.clone()),
|
block: Arc::new(block.block.clone()),
|
||||||
senders: Arc::new(block.senders.clone()),
|
senders: Arc::new(block.senders().to_vec()),
|
||||||
execution_output: Arc::new(ExecutionOutcome::default()),
|
execution_output: Arc::new(ExecutionOutcome::default()),
|
||||||
hashed_state: Arc::new(HashedPostState::default()),
|
hashed_state: Arc::new(HashedPostState::default()),
|
||||||
trie: Arc::new(TrieUpdates::default()),
|
trie: Arc::new(TrieUpdates::default()),
|
||||||
|
|||||||
@ -784,13 +784,13 @@ mod tests {
|
|||||||
let block1_hash = B256::new([15; 32]);
|
let block1_hash = B256::new([15; 32]);
|
||||||
block1.set_block_number(1);
|
block1.set_block_number(1);
|
||||||
block1.set_hash(block1_hash);
|
block1.set_hash(block1_hash);
|
||||||
block1.senders.push(Address::new([4; 20]));
|
block1.push_sender(Address::new([4; 20]));
|
||||||
|
|
||||||
let mut block2: SealedBlockWithSenders = Default::default();
|
let mut block2: SealedBlockWithSenders = Default::default();
|
||||||
let block2_hash = B256::new([16; 32]);
|
let block2_hash = B256::new([16; 32]);
|
||||||
block2.set_block_number(2);
|
block2.set_block_number(2);
|
||||||
block2.set_hash(block2_hash);
|
block2.set_hash(block2_hash);
|
||||||
block2.senders.push(Address::new([4; 20]));
|
block2.push_sender(Address::new([4; 20]));
|
||||||
|
|
||||||
let mut block_state_extended = execution_outcome1;
|
let mut block_state_extended = execution_outcome1;
|
||||||
block_state_extended.extend(execution_outcome2);
|
block_state_extended.extend(execution_outcome2);
|
||||||
|
|||||||
@ -107,7 +107,7 @@ where
|
|||||||
let execute_start = Instant::now();
|
let execute_start = Instant::now();
|
||||||
|
|
||||||
// Unseal the block for execution
|
// Unseal the block for execution
|
||||||
let (block, senders) = block.into_components();
|
let (block, senders) = block.split();
|
||||||
let (header, body) = block.split();
|
let (header, body) = block.split();
|
||||||
let (unsealed_header, hash) = header.split();
|
let (unsealed_header, hash) = header.split();
|
||||||
let block = P::Block::new(unsealed_header, body).with_senders_unchecked(senders);
|
let block = P::Block::new(unsealed_header, body).with_senders_unchecked(senders);
|
||||||
|
|||||||
@ -420,13 +420,13 @@ mod tests {
|
|||||||
|
|
||||||
// Attempt to execute a block with one deposit and one non-deposit transaction
|
// Attempt to execute a block with one deposit and one non-deposit transaction
|
||||||
executor
|
executor
|
||||||
.execute_and_verify_one(&BlockWithSenders {
|
.execute_and_verify_one(&BlockWithSenders::new_unchecked(
|
||||||
block: Block {
|
Block {
|
||||||
header,
|
header,
|
||||||
body: BlockBody { transactions: vec![tx, tx_deposit], ..Default::default() },
|
body: BlockBody { transactions: vec![tx, tx_deposit], ..Default::default() },
|
||||||
},
|
},
|
||||||
senders: vec![addr, addr],
|
vec![addr, addr],
|
||||||
})
|
))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let receipts = executor.receipts();
|
let receipts = executor.receipts();
|
||||||
@ -496,13 +496,13 @@ mod tests {
|
|||||||
|
|
||||||
// attempt to execute an empty block with parent beacon block root, this should not fail
|
// attempt to execute an empty block with parent beacon block root, this should not fail
|
||||||
executor
|
executor
|
||||||
.execute_and_verify_one(&BlockWithSenders {
|
.execute_and_verify_one(&BlockWithSenders::new_unchecked(
|
||||||
block: Block {
|
Block {
|
||||||
header,
|
header,
|
||||||
body: BlockBody { transactions: vec![tx, tx_deposit], ..Default::default() },
|
body: BlockBody { transactions: vec![tx, tx_deposit], ..Default::default() },
|
||||||
},
|
},
|
||||||
senders: vec![addr, addr],
|
vec![addr, addr],
|
||||||
})
|
))
|
||||||
.expect("Executing a block while canyon is active should not fail");
|
.expect("Executing a block while canyon is active should not fail");
|
||||||
|
|
||||||
let receipts = executor.receipts();
|
let receipts = executor.receipts();
|
||||||
|
|||||||
@ -91,7 +91,7 @@ pub struct BlockWithSenders<B = Block> {
|
|||||||
#[deref_mut]
|
#[deref_mut]
|
||||||
pub block: B,
|
pub block: B,
|
||||||
/// List of senders that match the transactions in the block
|
/// List of senders that match the transactions in the block
|
||||||
pub senders: Vec<Address>,
|
senders: Vec<Address>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<B: reth_primitives_traits::Block> BlockWithSenders<B> {
|
impl<B: reth_primitives_traits::Block> BlockWithSenders<B> {
|
||||||
@ -105,6 +105,16 @@ impl<B: reth_primitives_traits::Block> BlockWithSenders<B> {
|
|||||||
(block.body().transactions().len() == senders.len()).then_some(Self { block, senders })
|
(block.body().transactions().len() == senders.len()).then_some(Self { block, senders })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns all senders of the transactions in the block.
|
||||||
|
pub fn senders(&self) -> &[Address] {
|
||||||
|
&self.senders
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns an iterator over all senders in the block.
|
||||||
|
pub fn senders_iter(&self) -> impl Iterator<Item = &Address> {
|
||||||
|
self.senders.iter()
|
||||||
|
}
|
||||||
|
|
||||||
/// Seal the block with a known hash.
|
/// Seal the block with a known hash.
|
||||||
///
|
///
|
||||||
/// WARNING: This method does not perform validation whether the hash is correct.
|
/// WARNING: This method does not perform validation whether the hash is correct.
|
||||||
@ -122,7 +132,7 @@ impl<B: reth_primitives_traits::Block> BlockWithSenders<B> {
|
|||||||
|
|
||||||
/// Split Structure to its components
|
/// Split Structure to its components
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn into_components(self) -> (B, Vec<Address>) {
|
pub fn split(self) -> (B, Vec<Address>) {
|
||||||
(self.block, self.senders)
|
(self.block, self.senders)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -483,7 +493,7 @@ pub struct SealedBlockWithSenders<B: reth_primitives_traits::Block = Block> {
|
|||||||
#[serde(bound = "SealedBlock<B::Header, B::Body>: Serialize + serde::de::DeserializeOwned")]
|
#[serde(bound = "SealedBlock<B::Header, B::Body>: Serialize + serde::de::DeserializeOwned")]
|
||||||
pub block: SealedBlock<B::Header, B::Body>,
|
pub block: SealedBlock<B::Header, B::Body>,
|
||||||
/// List of senders that match transactions from block.
|
/// List of senders that match transactions from block.
|
||||||
pub senders: Vec<Address>,
|
senders: Vec<Address>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<B: reth_primitives_traits::Block> Default for SealedBlockWithSenders<B> {
|
impl<B: reth_primitives_traits::Block> Default for SealedBlockWithSenders<B> {
|
||||||
@ -493,6 +503,14 @@ impl<B: reth_primitives_traits::Block> Default for SealedBlockWithSenders<B> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<B: reth_primitives_traits::Block> SealedBlockWithSenders<B> {
|
impl<B: reth_primitives_traits::Block> SealedBlockWithSenders<B> {
|
||||||
|
/// New sealed block with sender
|
||||||
|
pub const fn new_unchecked(
|
||||||
|
block: SealedBlock<B::Header, B::Body>,
|
||||||
|
senders: Vec<Address>,
|
||||||
|
) -> Self {
|
||||||
|
Self { block, senders }
|
||||||
|
}
|
||||||
|
|
||||||
/// New sealed block with sender. Return none if len of tx and senders does not match
|
/// New sealed block with sender. Return none if len of tx and senders does not match
|
||||||
pub fn new(block: SealedBlock<B::Header, B::Body>, senders: Vec<Address>) -> Option<Self> {
|
pub fn new(block: SealedBlock<B::Header, B::Body>, senders: Vec<Address>) -> Option<Self> {
|
||||||
(block.body.transactions().len() == senders.len()).then_some(Self { block, senders })
|
(block.body.transactions().len() == senders.len()).then_some(Self { block, senders })
|
||||||
@ -500,16 +518,26 @@ impl<B: reth_primitives_traits::Block> SealedBlockWithSenders<B> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<B: reth_primitives_traits::Block> SealedBlockWithSenders<B> {
|
impl<B: reth_primitives_traits::Block> SealedBlockWithSenders<B> {
|
||||||
|
/// Returns all senders of the transactions in the block.
|
||||||
|
pub fn senders(&self) -> &[Address] {
|
||||||
|
&self.senders
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns an iterator over all senders in the block.
|
||||||
|
pub fn senders_iter(&self) -> impl Iterator<Item = &Address> {
|
||||||
|
self.senders.iter()
|
||||||
|
}
|
||||||
|
|
||||||
/// Split Structure to its components
|
/// Split Structure to its components
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn into_components(self) -> (SealedBlock<B::Header, B::Body>, Vec<Address>) {
|
pub fn split(self) -> (SealedBlock<B::Header, B::Body>, Vec<Address>) {
|
||||||
(self.block, self.senders)
|
(self.block, self.senders)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the unsealed [`BlockWithSenders`]
|
/// Returns the unsealed [`BlockWithSenders`]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn unseal(self) -> BlockWithSenders<B> {
|
pub fn unseal(self) -> BlockWithSenders<B> {
|
||||||
let (block, senders) = self.into_components();
|
let (block, senders) = self.split();
|
||||||
let (header, body) = block.split();
|
let (header, body) = block.split();
|
||||||
let header = header.unseal();
|
let header = header.unseal();
|
||||||
BlockWithSenders::new_unchecked(B::new(header, body), senders)
|
BlockWithSenders::new_unchecked(B::new(header, body), senders)
|
||||||
@ -555,6 +583,22 @@ impl<B: reth_primitives_traits::Block> SealedBlockWithSenders<B> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(any(test, feature = "test-utils"))]
|
||||||
|
impl<B> SealedBlockWithSenders<B>
|
||||||
|
where
|
||||||
|
B: reth_primitives_traits::Block,
|
||||||
|
{
|
||||||
|
/// Returns a mutable reference to the recovered senders.
|
||||||
|
pub fn senders_mut(&mut self) -> &mut Vec<Address> {
|
||||||
|
&mut self.senders
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Appends the sender to the list of senders.
|
||||||
|
pub fn push_sender(&mut self, sender: Address) {
|
||||||
|
self.senders.push(sender);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(any(test, feature = "arbitrary"))]
|
#[cfg(any(test, feature = "arbitrary"))]
|
||||||
impl<'a, B> arbitrary::Arbitrary<'a> for SealedBlockWithSenders<B>
|
impl<'a, B> arbitrary::Arbitrary<'a> for SealedBlockWithSenders<B>
|
||||||
where
|
where
|
||||||
|
|||||||
@ -426,6 +426,6 @@ pub trait LoadPendingBlock:
|
|||||||
results,
|
results,
|
||||||
);
|
);
|
||||||
|
|
||||||
Ok((SealedBlockWithSenders { block: block.seal_slow(), senders }, receipts))
|
Ok((SealedBlockWithSenders::new_unchecked(block.seal_slow(), senders), receipts))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -80,7 +80,7 @@ where
|
|||||||
// `from_block_with_transactions`, however we need to compute the length before
|
// `from_block_with_transactions`, however we need to compute the length before
|
||||||
let block_length = block.block.length();
|
let block_length = block.block.length();
|
||||||
let transactions = block.block.body().transactions().to_vec();
|
let transactions = block.block.body().transactions().to_vec();
|
||||||
let transactions_with_senders = transactions.into_iter().zip(block.senders);
|
let transactions_with_senders = transactions.into_iter().zip(block.senders_iter().copied());
|
||||||
let transactions = transactions_with_senders
|
let transactions = transactions_with_senders
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.map(|(idx, (tx, sender))| {
|
.map(|(idx, (tx, sender))| {
|
||||||
|
|||||||
@ -115,7 +115,7 @@ where
|
|||||||
if self.disallow.contains(&message.proposer_fee_recipient) {
|
if self.disallow.contains(&message.proposer_fee_recipient) {
|
||||||
return Err(ValidationApiError::Blacklist(message.proposer_fee_recipient))
|
return Err(ValidationApiError::Blacklist(message.proposer_fee_recipient))
|
||||||
}
|
}
|
||||||
for (sender, tx) in block.senders.iter().zip(block.transactions()) {
|
for (sender, tx) in block.senders_iter().zip(block.transactions()) {
|
||||||
if self.disallow.contains(sender) {
|
if self.disallow.contains(sender) {
|
||||||
return Err(ValidationApiError::Blacklist(*sender))
|
return Err(ValidationApiError::Blacklist(*sender))
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1211,10 +1211,10 @@ mod tests {
|
|||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
provider.pending_block_with_senders()?,
|
provider.pending_block_with_senders()?,
|
||||||
Some(reth_primitives::SealedBlockWithSenders {
|
Some(reth_primitives::SealedBlockWithSenders::new_unchecked(
|
||||||
block: block.clone(),
|
block.clone(),
|
||||||
senders: block.senders().unwrap()
|
block.senders().unwrap()
|
||||||
})
|
))
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(provider.pending_block_and_receipts()?, Some((block, vec![])));
|
assert_eq!(provider.pending_block_and_receipts()?, Some((block, vec![])));
|
||||||
|
|||||||
@ -2800,7 +2800,7 @@ impl<TX: DbTxMut + DbTx + 'static, N: NodeTypesForProvider + 'static> BlockWrite
|
|||||||
|
|
||||||
// Ensures we have all the senders for the block's transactions.
|
// Ensures we have all the senders for the block's transactions.
|
||||||
for (transaction, sender) in
|
for (transaction, sender) in
|
||||||
block.block.body().transactions().iter().zip(block.senders.iter())
|
block.block.body().transactions().iter().zip(block.senders_iter())
|
||||||
{
|
{
|
||||||
let hash = transaction.tx_hash();
|
let hash = transaction.tx_hash();
|
||||||
|
|
||||||
|
|||||||
@ -240,7 +240,10 @@ fn block1(number: BlockNumber) -> (SealedBlockWithSenders, ExecutionOutcome) {
|
|||||||
header.parent_hash = B256::ZERO;
|
header.parent_hash = B256::ZERO;
|
||||||
let block = SealedBlock::new(SealedHeader::seal(header), body);
|
let block = SealedBlock::new(SealedHeader::seal(header), body);
|
||||||
|
|
||||||
(SealedBlockWithSenders { block, senders: vec![Address::new([0x30; 20])] }, execution_outcome)
|
(
|
||||||
|
SealedBlockWithSenders::new_unchecked(block, vec![Address::new([0x30; 20])]),
|
||||||
|
execution_outcome,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Block two that points to block 1
|
/// Block two that points to block 1
|
||||||
@ -304,7 +307,10 @@ fn block2(
|
|||||||
header.parent_hash = parent_hash;
|
header.parent_hash = parent_hash;
|
||||||
let block = SealedBlock::new(SealedHeader::seal(header), body);
|
let block = SealedBlock::new(SealedHeader::seal(header), body);
|
||||||
|
|
||||||
(SealedBlockWithSenders { block, senders: vec![Address::new([0x31; 20])] }, execution_outcome)
|
(
|
||||||
|
SealedBlockWithSenders::new_unchecked(block, vec![Address::new([0x31; 20])]),
|
||||||
|
execution_outcome,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Block three that points to block 2
|
/// Block three that points to block 2
|
||||||
@ -368,7 +374,10 @@ fn block3(
|
|||||||
header.parent_hash = parent_hash;
|
header.parent_hash = parent_hash;
|
||||||
let block = SealedBlock::new(SealedHeader::seal(header), body);
|
let block = SealedBlock::new(SealedHeader::seal(header), body);
|
||||||
|
|
||||||
(SealedBlockWithSenders { block, senders: vec![Address::new([0x31; 20])] }, execution_outcome)
|
(
|
||||||
|
SealedBlockWithSenders::new_unchecked(block, vec![Address::new([0x31; 20])]),
|
||||||
|
execution_outcome,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Block four that points to block 3
|
/// Block four that points to block 3
|
||||||
@ -457,7 +466,10 @@ fn block4(
|
|||||||
header.parent_hash = parent_hash;
|
header.parent_hash = parent_hash;
|
||||||
let block = SealedBlock::new(SealedHeader::seal(header), body);
|
let block = SealedBlock::new(SealedHeader::seal(header), body);
|
||||||
|
|
||||||
(SealedBlockWithSenders { block, senders: vec![Address::new([0x31; 20])] }, execution_outcome)
|
(
|
||||||
|
SealedBlockWithSenders::new_unchecked(block, vec![Address::new([0x31; 20])]),
|
||||||
|
execution_outcome,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Block five that points to block 4
|
/// Block five that points to block 4
|
||||||
@ -543,5 +555,8 @@ fn block5(
|
|||||||
header.parent_hash = parent_hash;
|
header.parent_hash = parent_hash;
|
||||||
let block = SealedBlock::new(SealedHeader::seal(header), body);
|
let block = SealedBlock::new(SealedHeader::seal(header), body);
|
||||||
|
|
||||||
(SealedBlockWithSenders { block, senders: vec![Address::new([0x31; 20])] }, execution_outcome)
|
(
|
||||||
|
SealedBlockWithSenders::new_unchecked(block, vec![Address::new([0x31; 20])]),
|
||||||
|
execution_outcome,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -127,8 +127,8 @@ mod tests {
|
|||||||
let tx3_hash = B256::random(); // Non-EIP-4844 transaction
|
let tx3_hash = B256::random(); // Non-EIP-4844 transaction
|
||||||
|
|
||||||
// Creating a first block with EIP-4844 transactions
|
// Creating a first block with EIP-4844 transactions
|
||||||
let block1 = SealedBlockWithSenders {
|
let block1 = SealedBlockWithSenders::new_unchecked(
|
||||||
block: SealedBlock::new(
|
SealedBlock::new(
|
||||||
SealedHeader::new(Header { number: 10, ..Default::default() }, B256::random()),
|
SealedHeader::new(Header { number: 10, ..Default::default() }, B256::random()),
|
||||||
BlockBody {
|
BlockBody {
|
||||||
transactions: vec![
|
transactions: vec![
|
||||||
@ -152,13 +152,13 @@ mod tests {
|
|||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
..Default::default()
|
Default::default(),
|
||||||
};
|
);
|
||||||
|
|
||||||
// Creating a second block with EIP-1559 and EIP-2930 transactions
|
// Creating a second block with EIP-1559 and EIP-2930 transactions
|
||||||
// Note: This block does not contain any EIP-4844 transactions
|
// Note: This block does not contain any EIP-4844 transactions
|
||||||
let block2 = SealedBlockWithSenders {
|
let block2 = SealedBlockWithSenders::new_unchecked(
|
||||||
block: SealedBlock::new(
|
SealedBlock::new(
|
||||||
SealedHeader::new(Header { number: 11, ..Default::default() }, B256::random()),
|
SealedHeader::new(Header { number: 11, ..Default::default() }, B256::random()),
|
||||||
BlockBody {
|
BlockBody {
|
||||||
transactions: vec![
|
transactions: vec![
|
||||||
@ -176,8 +176,8 @@ mod tests {
|
|||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
..Default::default()
|
Default::default(),
|
||||||
};
|
);
|
||||||
|
|
||||||
// Extract blocks from the chain
|
// Extract blocks from the chain
|
||||||
let chain: Chain = Chain::new(vec![block1, block2], Default::default(), None);
|
let chain: Chain = Chain::new(vec![block1, block2], Default::default(), None);
|
||||||
|
|||||||
Reference in New Issue
Block a user