chore(sdk): make reth-chain-state types generic over receipt (#12667)

This commit is contained in:
Emilia Hane
2024-11-19 21:16:45 +01:00
committed by GitHub
parent fcb5050f87
commit aa34a2795b
10 changed files with 144 additions and 127 deletions

View File

@ -1,3 +1,5 @@
use core::marker::PhantomData;
use crate::{
in_memory::ExecutedBlock, CanonStateNotification, CanonStateNotifications,
CanonStateSubscriptions,
@ -12,8 +14,8 @@ use reth_chainspec::{ChainSpec, EthereumHardfork, MIN_TRANSACTION_GAS};
use reth_execution_types::{Chain, ExecutionOutcome};
use reth_primitives::{
proofs::{calculate_receipt_root, calculate_transaction_root, calculate_withdrawals_root},
BlockBody, Receipt, Receipts, SealedBlock, SealedBlockWithSenders, SealedHeader, Transaction,
TransactionSigned, TransactionSignedEcRecovered,
BlockBody, NodePrimitives, Receipt, Receipts, SealedBlock, SealedBlockWithSenders,
SealedHeader, Transaction, TransactionSigned, TransactionSignedEcRecovered,
};
use reth_trie::{root::state_root_unhashed, updates::TrieUpdates, HashedPostState};
use revm::{db::BundleState, primitives::AccountInfo};
@ -27,7 +29,7 @@ use tokio::sync::broadcast::{self, Sender};
/// Functionality to build blocks for tests and help with assertions about
/// their execution.
#[derive(Debug)]
pub struct TestBlockBuilder {
pub struct TestBlockBuilder<N: NodePrimitives = reth_primitives::EthPrimitives> {
/// The account that signs all the block's transactions.
pub signer: Address,
/// Private key for signing.
@ -40,9 +42,10 @@ pub struct TestBlockBuilder {
pub signer_build_account_info: AccountInfo,
/// Chain spec of the blocks generated by this builder
pub chain_spec: ChainSpec,
_prims: PhantomData<N>,
}
impl Default for TestBlockBuilder {
impl<N: NodePrimitives> Default for TestBlockBuilder<N> {
fn default() -> Self {
let initial_account_info = AccountInfo::from_balance(U256::from(10).pow(U256::from(18)));
let signer_pk = PrivateKeySigner::random();
@ -53,6 +56,7 @@ impl Default for TestBlockBuilder {
signer_pk,
signer_execute_account_info: initial_account_info.clone(),
signer_build_account_info: initial_account_info,
_prims: PhantomData,
}
}
}
@ -289,8 +293,8 @@ impl TestBlockBuilder {
}
/// A test `ChainEventSubscriptions`
#[derive(Clone, Debug, Default)]
pub struct TestCanonStateSubscriptions {
canon_notif_tx: Arc<Mutex<Vec<Sender<CanonStateNotification>>>>,
pub struct TestCanonStateSubscriptions<N: NodePrimitives = reth_primitives::EthPrimitives> {
canon_notif_tx: Arc<Mutex<Vec<Sender<CanonStateNotification<N>>>>>,
}
impl TestCanonStateSubscriptions {