refactor: rename BundleStateWithReceipts to BlockExecutionOutcome (#8730)

This commit is contained in:
Thomas Coratger
2024-06-11 18:06:49 +02:00
committed by GitHub
parent 95719da049
commit a5d825edb3
43 changed files with 443 additions and 409 deletions

View File

@ -29,9 +29,8 @@ use reth_primitives::{
SealedBlock, SealedBlockWithSenders, Transaction, TransactionSigned, TxEip4844, B256, U256,
};
use reth_provider::{
providers::BlockchainProvider, BlockHashReader, BlockReader, BlockWriter,
BundleStateWithReceipts, ChainSpecProvider, ProviderFactory, StageCheckpointReader,
StateProviderFactory,
providers::BlockchainProvider, BlockHashReader, BlockReader, BlockWriter, ChainSpecProvider,
ExecutionOutcome, ProviderFactory, StageCheckpointReader, StateProviderFactory,
};
use reth_revm::database::StateProviderDatabase;
use reth_rpc_types::engine::{BlobsBundleV1, PayloadAttributes};
@ -273,17 +272,17 @@ impl Command {
let BlockExecutionOutput { state, receipts, requests, .. } =
executor.execute((&block_with_senders.clone().unseal(), U256::MAX).into())?;
let state = BundleStateWithReceipts::new(
let execution_outcome = ExecutionOutcome::new(
state,
receipts.into(),
block.number,
vec![requests.into()],
);
debug!(target: "reth::cli", ?state, "Executed block");
debug!(target: "reth::cli", ?execution_outcome, "Executed block");
let hashed_state = state.hash_state_slow();
let (state_root, trie_updates) = state
let hashed_post_state = execution_outcome.hash_state_slow();
let (state_root, trie_updates) = execution_outcome
.hash_state_slow()
.state_root_with_updates(provider_factory.provider()?.tx_ref())?;
@ -299,8 +298,8 @@ impl Command {
let provider_rw = provider_factory.provider_rw()?;
provider_rw.append_blocks_with_state(
Vec::from([block_with_senders]),
state,
hashed_state,
execution_outcome,
hashed_post_state,
trie_updates,
None,
)?;

View File

@ -17,7 +17,7 @@ use reth_network::NetworkHandle;
use reth_network_api::NetworkInfo;
use reth_primitives::BlockHashOrNumber;
use reth_provider::{
AccountExtReader, BundleStateWithReceipts, ChainSpecProvider, HashingWriter, HeaderProvider,
AccountExtReader, ChainSpecProvider, ExecutionOutcome, HashingWriter, HeaderProvider,
LatestStateProviderRef, OriginalValuesKnown, ProviderFactory, StageCheckpointReader,
StateWriter, StaticFileProviderFactory, StorageReader,
};
@ -147,16 +147,12 @@ impl Command {
)
.into(),
)?;
let block_state = BundleStateWithReceipts::new(
state,
receipts.into(),
block.number,
vec![requests.into()],
);
let execution_outcome =
ExecutionOutcome::new(state, receipts.into(), block.number, vec![requests.into()]);
// Unpacked `BundleState::state_root_slow` function
let (in_memory_state_root, in_memory_updates) =
block_state.hash_state_slow().state_root_with_updates(provider.tx_ref())?;
execution_outcome.hash_state_slow().state_root_with_updates(provider.tx_ref())?;
if in_memory_state_root == block.state_root {
info!(target: "reth::cli", state_root = ?in_memory_state_root, "Computed in-memory state root matches");
@ -173,7 +169,7 @@ impl Command {
.map_err(|_| BlockValidationError::SenderRecoveryError)?,
None,
)?;
block_state.write_to_storage(provider_rw.tx_ref(), None, OriginalValuesKnown::No)?;
execution_outcome.write_to_storage(provider_rw.tx_ref(), None, OriginalValuesKnown::No)?;
let storage_lists = provider_rw.changed_storages_with_range(block.number..=block.number)?;
let storages = provider_rw.plain_state_storages(storage_lists)?;
provider_rw.insert_storage_for_hashing(storages)?;

View File

@ -13,8 +13,8 @@ use reth_node_core::version::SHORT_VERSION;
use reth_optimism_primitives::bedrock_import::is_dup_tx;
use reth_primitives::{Receipts, StaticFileSegment};
use reth_provider::{
BundleStateWithReceipts, OriginalValuesKnown, ProviderFactory, StageCheckpointReader,
StateWriter, StaticFileProviderFactory, StaticFileWriter, StatsReader,
ExecutionOutcome, OriginalValuesKnown, ProviderFactory, StageCheckpointReader, StateWriter,
StaticFileProviderFactory, StaticFileWriter, StatsReader,
};
use reth_stages::StageId;
use std::path::{Path, PathBuf};
@ -131,20 +131,16 @@ where
);
// We're reusing receipt writing code internal to
// `BundleStateWithReceipts::write_to_storage`, so we just use a default empty
// `ExecutionOutcome::write_to_storage`, so we just use a default empty
// `BundleState`.
let bundled_state = BundleStateWithReceipts::new(
Default::default(),
receipts,
first_block,
Default::default(),
);
let execution_outcome =
ExecutionOutcome::new(Default::default(), receipts, first_block, Default::default());
let static_file_producer =
static_file_provider.get_writer(first_block, StaticFileSegment::Receipts)?;
// finally, write the receipts
bundled_state.write_to_storage::<DB::TXMut>(
execution_outcome.write_to_storage::<DB::TXMut>(
&tx,
Some(static_file_producer),
OriginalValuesKnown::Yes,