Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions book/cli/reth/node.md
Original file line number Diff line number Diff line change
Expand Up @@ -768,6 +768,9 @@ Engine:
--engine.precompile-cache
Enable precompile cache

--engine.state-root-fallback
Enable state root fallback, useful for testing

Ress:
--ress.enable
Enable support for `ress` subprotocol
Expand Down
16 changes: 16 additions & 0 deletions crates/engine/primitives/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ pub struct TreeConfig {
reserved_cpu_cores: usize,
/// Whether to enable the precompile cache
precompile_cache_enabled: bool,
/// Whether to use state root fallback for testing
state_root_fallback: bool,
}

impl Default for TreeConfig {
Expand All @@ -96,6 +98,7 @@ impl Default for TreeConfig {
max_proof_task_concurrency: DEFAULT_MAX_PROOF_TASK_CONCURRENCY,
reserved_cpu_cores: DEFAULT_RESERVED_CPU_CORES,
precompile_cache_enabled: false,
state_root_fallback: false,
}
}
}
Expand All @@ -118,6 +121,7 @@ impl TreeConfig {
max_proof_task_concurrency: u64,
reserved_cpu_cores: usize,
precompile_cache_enabled: bool,
state_root_fallback: bool,
) -> Self {
Self {
persistence_threshold,
Expand All @@ -134,6 +138,7 @@ impl TreeConfig {
max_proof_task_concurrency,
reserved_cpu_cores,
precompile_cache_enabled,
state_root_fallback,
}
}

Expand Down Expand Up @@ -204,6 +209,11 @@ impl TreeConfig {
self.precompile_cache_enabled
}

/// Returns whether to use state root fallback.
pub const fn state_root_fallback(&self) -> bool {
self.state_root_fallback
}

/// Setter for persistence threshold.
pub const fn with_persistence_threshold(mut self, persistence_threshold: u64) -> Self {
self.persistence_threshold = persistence_threshold;
Expand Down Expand Up @@ -307,6 +317,12 @@ impl TreeConfig {
self
}

/// Setter for whether to use state root fallback, useful for testing.
pub const fn with_state_root_fallback(mut self, state_root_fallback: bool) -> Self {
self.state_root_fallback = state_root_fallback;
self
}

/// Whether or not to use state root task
pub const fn use_state_root_task(&self) -> bool {
self.has_enough_parallelism && !self.legacy_state_root
Expand Down
13 changes: 10 additions & 3 deletions crates/engine/tree/src/tree/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2161,7 +2161,9 @@ where
//
// See https://github.com/paradigmxyz/reth/issues/12688 for more details
let persisting_kind = self.persisting_kind_for(block.header());
let run_parallel_state_root = persisting_kind.can_run_parallel_state_root();
// don't run parallel if state root fallback is set
let run_parallel_state_root =
persisting_kind.can_run_parallel_state_root() && !self.config.state_root_fallback();

// use prewarming background task
let header = block.clone_sealed_header();
Expand Down Expand Up @@ -2299,8 +2301,13 @@ where
maybe_state_root
} else {
// fallback is to compute the state root regularly in sync
warn!(target: "engine::tree", block=?block_num_hash, ?persisting_kind, "Failed to compute state root in parallel");
self.metrics.block_validation.state_root_parallel_fallback_total.increment(1);
if self.config.state_root_fallback() {
debug!(target: "engine::tree", block=?block_num_hash, "Using state root fallback for testing");
} else {
warn!(target: "engine::tree", block=?block_num_hash, ?persisting_kind, "Failed to compute state root in parallel");
self.metrics.block_validation.state_root_parallel_fallback_total.increment(1);
}

let (root, updates) =
ensure_ok!(state_provider.state_root_with_updates(hashed_state.clone()));
(root, updates, root_time.elapsed())
Expand Down
6 changes: 6 additions & 0 deletions crates/node/core/src/args/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ pub struct EngineArgs {
/// Enable precompile cache
#[arg(long = "engine.precompile-cache", default_value = "false")]
pub precompile_cache_enabled: bool,

/// Enable state root fallback, useful for testing
#[arg(long = "engine.state-root-fallback", default_value = "false")]
pub state_root_fallback: bool,
}

impl Default for EngineArgs {
Expand All @@ -80,6 +84,7 @@ impl Default for EngineArgs {
max_proof_task_concurrency: DEFAULT_MAX_PROOF_TASK_CONCURRENCY,
reserved_cpu_cores: DEFAULT_RESERVED_CPU_CORES,
precompile_cache_enabled: false,
state_root_fallback: false,
}
}
}
Expand All @@ -98,6 +103,7 @@ impl EngineArgs {
.with_max_proof_task_concurrency(self.max_proof_task_concurrency)
.with_reserved_cpu_cores(self.reserved_cpu_cores)
.with_precompile_cache_enabled(self.precompile_cache_enabled)
.with_state_root_fallback(self.state_root_fallback)
}
}

Expand Down
Loading