mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-01-26 07:38:59 -05:00
fix(tree): state root task duration (#14763)
Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
@@ -15,6 +15,7 @@ use alloy_rpc_types_engine::{
|
||||
ForkchoiceState, PayloadStatus, PayloadStatusEnum, PayloadValidationError,
|
||||
};
|
||||
use error::{InsertBlockError, InsertBlockErrorKind, InsertBlockFatalError};
|
||||
use payload_processor::sparse_trie::StateRootComputeOutcome;
|
||||
use persistence_state::CurrentPersistenceAction;
|
||||
use reth_chain_state::{
|
||||
CanonicalInMemoryState, ExecutedBlock, ExecutedBlockWithTrieUpdates,
|
||||
@@ -2386,7 +2387,8 @@ where
|
||||
&block,
|
||||
Box::new(handle.state_hook()),
|
||||
)?;
|
||||
let execution_time = execution_start.elapsed();
|
||||
let execution_finish = Instant::now();
|
||||
let execution_time = execution_finish.duration_since(execution_start);
|
||||
trace!(target: "engine::tree", elapsed = ?execution_time, number=?block_num_hash.number, "Executed block");
|
||||
|
||||
// after executing the block we can stop executing transactions
|
||||
@@ -2421,12 +2423,12 @@ where
|
||||
// background task or try to compute it in parallel
|
||||
if self.config.use_state_root_task() {
|
||||
match handle.state_root() {
|
||||
Ok(res) => {
|
||||
Ok(StateRootComputeOutcome { state_root, trie_updates }) => {
|
||||
// we double check the state root here for good measure
|
||||
// TODO: clean this ups
|
||||
if res.state_root.0 == block.header().state_root() {
|
||||
if state_root == block.header().state_root() {
|
||||
maybe_state_root =
|
||||
Some((res.state_root.0, res.state_root.1, res.total_time))
|
||||
Some((state_root, trie_updates, execution_finish.elapsed()))
|
||||
}
|
||||
}
|
||||
Err(error) => {
|
||||
|
||||
@@ -36,10 +36,10 @@ use std::{
|
||||
};
|
||||
|
||||
pub(crate) mod executor;
|
||||
pub(crate) mod sparse_trie;
|
||||
|
||||
mod multiproof;
|
||||
mod prewarm;
|
||||
mod sparse_trie;
|
||||
|
||||
/// Entrypoint for executing the payload.
|
||||
pub(super) struct PayloadProcessor<N, Evm> {
|
||||
|
||||
@@ -31,7 +31,7 @@ use tracing::{debug, error, trace};
|
||||
/// A trie update that can be applied to sparse trie alongside the proofs for touched parts of the
|
||||
/// state.
|
||||
#[derive(Default, Debug)]
|
||||
pub(super) struct SparseTrieUpdate {
|
||||
pub(crate) struct SparseTrieUpdate {
|
||||
/// The state update that was used to calculate the proof
|
||||
pub(crate) state: HashedPostState,
|
||||
/// The calculated multiproof
|
||||
@@ -401,6 +401,8 @@ pub(crate) struct MultiProofTaskMetrics {
|
||||
pub sparse_trie_update_duration_histogram: Histogram,
|
||||
/// Histogram of sparse trie final update durations.
|
||||
pub sparse_trie_final_update_duration_histogram: Histogram,
|
||||
/// Histogram of sparse trie total durations.
|
||||
pub sparse_trie_total_duration_histogram: Histogram,
|
||||
|
||||
/// Histogram of state updates received.
|
||||
pub state_updates_received_histogram: Histogram,
|
||||
|
||||
@@ -99,22 +99,18 @@ where
|
||||
})?;
|
||||
|
||||
self.metrics.sparse_trie_final_update_duration_histogram.record(start.elapsed());
|
||||
self.metrics.sparse_trie_total_duration_histogram.record(now.elapsed());
|
||||
|
||||
Ok(StateRootComputeOutcome {
|
||||
state_root: (state_root, trie_updates),
|
||||
total_time: now.elapsed(),
|
||||
})
|
||||
Ok(StateRootComputeOutcome { state_root, trie_updates })
|
||||
}
|
||||
}
|
||||
|
||||
/// Outcome of the state root computation, including the state root itself with
|
||||
/// the trie updates and the total time spent.
|
||||
/// the trie updates.
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct StateRootComputeOutcome {
|
||||
/// The computed state root and trie updates
|
||||
pub state_root: (B256, TrieUpdates),
|
||||
/// The total time spent calculating the state root
|
||||
pub total_time: Duration,
|
||||
pub state_root: B256,
|
||||
pub trie_updates: TrieUpdates,
|
||||
}
|
||||
|
||||
/// Aliased for now to not introduce too many changes at once.
|
||||
|
||||
Reference in New Issue
Block a user