mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
refactor: remove Receipts struct (#14130)
This commit is contained in:
@ -11,9 +11,7 @@ use parking_lot::RwLock;
|
||||
use reth_chainspec::ChainInfo;
|
||||
use reth_execution_types::{Chain, ExecutionOutcome};
|
||||
use reth_metrics::{metrics::Gauge, Metrics};
|
||||
use reth_primitives::{
|
||||
EthPrimitives, NodePrimitives, Receipts, RecoveredBlock, SealedBlock, SealedHeader,
|
||||
};
|
||||
use reth_primitives::{EthPrimitives, NodePrimitives, RecoveredBlock, SealedBlock, SealedHeader};
|
||||
use reth_primitives_traits::{BlockBody as _, SignedTransaction};
|
||||
use reth_storage_api::StateProviderBox;
|
||||
use reth_trie::{updates::TrieUpdates, HashedPostState};
|
||||
@ -648,7 +646,7 @@ impl<N: NodePrimitives> BlockState<N> {
|
||||
}
|
||||
|
||||
/// Returns the `Receipts` of executed block that determines the state.
|
||||
pub fn receipts(&self) -> &Receipts<N::Receipt> {
|
||||
pub fn receipts(&self) -> &Vec<Vec<N::Receipt>> {
|
||||
&self.block.execution_outcome().receipts
|
||||
}
|
||||
|
||||
@ -660,12 +658,12 @@ impl<N: NodePrimitives> BlockState<N> {
|
||||
let receipts = self.receipts();
|
||||
|
||||
debug_assert!(
|
||||
receipts.receipt_vec.len() <= 1,
|
||||
receipts.len() <= 1,
|
||||
"Expected at most one block's worth of receipts, found {}",
|
||||
receipts.receipt_vec.len()
|
||||
receipts.len()
|
||||
);
|
||||
|
||||
receipts.receipt_vec.first().cloned().unwrap_or_default()
|
||||
receipts.first().cloned().unwrap_or_default()
|
||||
}
|
||||
|
||||
/// Returns a vector of __parent__ `BlockStates`.
|
||||
@ -1244,7 +1242,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_state_receipts() {
|
||||
let receipts = Receipts { receipt_vec: vec![vec![Receipt::default()]] };
|
||||
let receipts = vec![vec![Receipt::default()]];
|
||||
let mut test_block_builder: TestBlockBuilder = TestBlockBuilder::default();
|
||||
let block =
|
||||
test_block_builder.get_executed_block_with_receipts(receipts.clone(), B256::random());
|
||||
@ -1532,7 +1530,7 @@ mod tests {
|
||||
test_block_builder.get_executed_block_with_number(2, block1.recovered_block.hash());
|
||||
|
||||
let sample_execution_outcome = ExecutionOutcome {
|
||||
receipts: Receipts::from_iter([vec![], vec![]]),
|
||||
receipts: vec![vec![], vec![]],
|
||||
requests: vec![Requests::default(), Requests::default()],
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
@ -217,7 +217,7 @@ mod tests {
|
||||
use alloy_consensus::BlockBody;
|
||||
use alloy_primitives::{b256, B256};
|
||||
use reth_execution_types::ExecutionOutcome;
|
||||
use reth_primitives::{Receipt, Receipts, SealedBlock, TransactionSigned, TxType};
|
||||
use reth_primitives::{Receipt, SealedBlock, TransactionSigned, TxType};
|
||||
|
||||
#[test]
|
||||
fn test_commit_notification() {
|
||||
@ -334,7 +334,7 @@ mod tests {
|
||||
};
|
||||
|
||||
// Wrap the receipt in a `Receipts` structure, as expected in the `ExecutionOutcome`.
|
||||
let receipts = Receipts { receipt_vec: vec![vec![receipt1.clone()]] };
|
||||
let receipts = vec![vec![receipt1.clone()]];
|
||||
|
||||
// Define an `ExecutionOutcome` with the created receipts.
|
||||
let execution_outcome = ExecutionOutcome { receipts, ..Default::default() };
|
||||
@ -393,7 +393,7 @@ mod tests {
|
||||
success: false,
|
||||
..Default::default()
|
||||
};
|
||||
let old_receipts = Receipts { receipt_vec: vec![vec![old_receipt.clone()]] };
|
||||
let old_receipts = vec![vec![old_receipt.clone()]];
|
||||
|
||||
let old_execution_outcome =
|
||||
ExecutionOutcome { receipts: old_receipts, ..Default::default() };
|
||||
@ -424,7 +424,7 @@ mod tests {
|
||||
success: true,
|
||||
..Default::default()
|
||||
};
|
||||
let new_receipts = Receipts { receipt_vec: vec![vec![new_receipt.clone()]] };
|
||||
let new_receipts = vec![vec![new_receipt.clone()]];
|
||||
|
||||
let new_execution_outcome =
|
||||
ExecutionOutcome { receipts: new_receipts, ..Default::default() };
|
||||
|
||||
@ -19,8 +19,7 @@ use reth_chainspec::{ChainSpec, EthereumHardfork, MIN_TRANSACTION_GAS};
|
||||
use reth_execution_types::{Chain, ExecutionOutcome};
|
||||
use reth_primitives::{
|
||||
transaction::SignedTransactionIntoRecoveredExt, BlockBody, EthPrimitives, NodePrimitives,
|
||||
Receipt, Receipts, Recovered, RecoveredBlock, SealedBlock, SealedHeader, Transaction,
|
||||
TransactionSigned,
|
||||
Receipt, Recovered, RecoveredBlock, SealedBlock, SealedHeader, Transaction, TransactionSigned,
|
||||
};
|
||||
use reth_primitives_traits::{
|
||||
proofs::{calculate_receipt_root, calculate_transaction_root, calculate_withdrawals_root},
|
||||
@ -204,11 +203,11 @@ impl<N: NodePrimitives> TestBlockBuilder<N> {
|
||||
fork
|
||||
}
|
||||
|
||||
/// Gets an [`ExecutedBlockWithTrieUpdates`] with [`BlockNumber`], [`Receipts`] and parent hash.
|
||||
/// Gets an [`ExecutedBlockWithTrieUpdates`] with [`BlockNumber`], receipts and parent hash.
|
||||
fn get_executed_block(
|
||||
&mut self,
|
||||
block_number: BlockNumber,
|
||||
receipts: Receipts,
|
||||
receipts: Vec<Vec<Receipt>>,
|
||||
parent_hash: B256,
|
||||
) -> ExecutedBlockWithTrieUpdates {
|
||||
let block_with_senders = self.generate_random_block(block_number, parent_hash);
|
||||
@ -227,10 +226,10 @@ impl<N: NodePrimitives> TestBlockBuilder<N> {
|
||||
)
|
||||
}
|
||||
|
||||
/// Generates an [`ExecutedBlockWithTrieUpdates`] that includes the given [`Receipts`].
|
||||
/// Generates an [`ExecutedBlockWithTrieUpdates`] that includes the given receipts.
|
||||
pub fn get_executed_block_with_receipts(
|
||||
&mut self,
|
||||
receipts: Receipts,
|
||||
receipts: Vec<Vec<Receipt>>,
|
||||
parent_hash: B256,
|
||||
) -> ExecutedBlockWithTrieUpdates {
|
||||
let number = rand::thread_rng().gen::<u64>();
|
||||
@ -243,7 +242,7 @@ impl<N: NodePrimitives> TestBlockBuilder<N> {
|
||||
block_number: BlockNumber,
|
||||
parent_hash: B256,
|
||||
) -> ExecutedBlockWithTrieUpdates {
|
||||
self.get_executed_block(block_number, Receipts { receipt_vec: vec![vec![]] }, parent_hash)
|
||||
self.get_executed_block(block_number, vec![vec![]], parent_hash)
|
||||
}
|
||||
|
||||
/// Generates a range of executed blocks with ascending block numbers.
|
||||
@ -296,12 +295,12 @@ impl<N: NodePrimitives> TestBlockBuilder<N> {
|
||||
|
||||
let execution_outcome = ExecutionOutcome::new(
|
||||
bundle_state_builder.build(),
|
||||
vec![vec![]].into(),
|
||||
vec![vec![]],
|
||||
block.number,
|
||||
Vec::new(),
|
||||
);
|
||||
|
||||
execution_outcome.with_receipts(Receipts::from(receipts))
|
||||
execution_outcome.with_receipts(vec![receipts])
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user