chore: use BlockWithParent for StageError (#13198)

This commit is contained in:
Dan Cline
2024-12-09 19:21:46 -05:00
committed by GitHub
parent 980e62a5b8
commit c9bd64018a
15 changed files with 117 additions and 75 deletions

View File

@ -1,7 +1,11 @@
//! Generators for different data structures like block headers, block bodies and ranges of those.
use alloy_consensus::{Header, Transaction as _, TxLegacy};
use alloy_eips::eip4895::{Withdrawal, Withdrawals};
use alloy_eips::{
eip1898::BlockWithParent,
eip4895::{Withdrawal, Withdrawals},
NumHash,
};
use alloy_primitives::{Address, BlockNumber, Bytes, TxKind, B256, U256};
pub use rand::Rng;
use rand::{
@ -95,6 +99,15 @@ pub fn random_header_range<R: Rng>(
headers
}
/// Generate a random [`BlockWithParent`].
pub fn random_block_with_parent<R: Rng>(
rng: &mut R,
number: u64,
parent: Option<B256>,
) -> BlockWithParent {
BlockWithParent { parent: parent.unwrap_or_default(), block: NumHash::new(number, rng.gen()) }
}
/// Generate a random [`SealedHeader`].
///
/// The header is assumed to not be correct if validated.