Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
18 changes: 17 additions & 1 deletion crates/engine/primitives/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ pub struct TreeConfig {
/// Whether to always compare trie updates from the state root task to the trie updates from
/// the regular state root calculation.
always_compare_trie_updates: bool,
/// Whether to disable state cache.
disable_state_cache: bool,
/// Whether to disable parallel prewarming.
disable_prewarming: bool,
/// Whether to disable the parallel sparse trie state root algorithm.
Expand Down Expand Up @@ -143,6 +145,7 @@ impl Default for TreeConfig {
max_execute_block_batch_size: DEFAULT_MAX_EXECUTE_BLOCK_BATCH_SIZE,
legacy_state_root: false,
always_compare_trie_updates: false,
disable_state_cache: false,
disable_prewarming: false,
disable_parallel_sparse_trie: false,
state_provider_metrics: false,
Expand Down Expand Up @@ -173,6 +176,7 @@ impl TreeConfig {
max_execute_block_batch_size: usize,
legacy_state_root: bool,
always_compare_trie_updates: bool,
disable_state_cache: bool,
disable_prewarming: bool,
disable_parallel_sparse_trie: bool,
state_provider_metrics: bool,
Expand All @@ -197,6 +201,7 @@ impl TreeConfig {
max_execute_block_batch_size,
legacy_state_root,
always_compare_trie_updates,
disable_state_cache,
disable_prewarming,
disable_parallel_sparse_trie,
state_provider_metrics,
Expand Down Expand Up @@ -271,7 +276,12 @@ impl TreeConfig {
self.disable_parallel_sparse_trie
}

/// Returns whether or not parallel prewarming should be used.
/// Returns whether or not state cache is disabled.
pub const fn disable_state_cache(&self) -> bool {
self.disable_state_cache
}

/// Returns whether or not parallel prewarming is disabled.
pub const fn disable_prewarming(&self) -> bool {
self.disable_prewarming
}
Expand Down Expand Up @@ -363,6 +373,12 @@ impl TreeConfig {
self
}

/// Setter for whether to disable state cache.
pub const fn without_state_cache(mut self, disable_state_cache: bool) -> Self {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

without is weird to me but i see its used by others as well

self.disable_state_cache = disable_state_cache;
self
}

/// Setter for whether to disable parallel prewarming.
pub const fn without_prewarming(mut self, disable_prewarming: bool) -> Self {
self.disable_prewarming = disable_prewarming;
Expand Down
15 changes: 9 additions & 6 deletions crates/engine/tree/src/tree/payload_validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,8 @@ where
)
.into())
};
let state_provider = ensure_ok!(provider_builder.build());
let mut state_provider: Box<dyn StateProvider> =
Box::new(ensure_ok!(provider_builder.build()));
drop(_enter);

// fetch parent block
Expand Down Expand Up @@ -396,11 +397,13 @@ where

// Use cached state provider before executing, used in execution after prewarming threads
// complete
let state_provider = CachedStateProvider::new_with_caches(
state_provider,
handle.caches(),
handle.cache_metrics(),
);
if !self.config.disable_state_cache() {
state_provider = Box::new(CachedStateProvider::new_with_caches(
state_provider,
handle.caches(),
handle.cache_metrics(),
));
};

// Execute the block and handle any execution errors
let (output, senders) = match if self.config.state_provider_metrics() {
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 @@ -35,6 +35,10 @@ pub struct EngineArgs {
#[deprecated]
pub caching_and_prewarming_enabled: bool,

/// Disable state cache
#[arg(long = "engine.disable-state-cache")]
pub state_cache_disabled: bool,

/// Disable parallel prewarming
#[arg(long = "engine.disable-prewarming", alias = "engine.disable-caching-and-prewarming")]
pub prewarming_disabled: bool,
Expand Down Expand Up @@ -130,6 +134,7 @@ impl Default for EngineArgs {
legacy_state_root_task_enabled: false,
state_root_task_compare_updates: false,
caching_and_prewarming_enabled: true,
state_cache_disabled: false,
prewarming_disabled: false,
parallel_sparse_trie_enabled: true,
parallel_sparse_trie_disabled: false,
Expand Down Expand Up @@ -157,6 +162,7 @@ impl EngineArgs {
.with_persistence_threshold(self.persistence_threshold)
.with_memory_block_buffer_target(self.memory_block_buffer_target)
.with_legacy_state_root(self.legacy_state_root_task_enabled)
.without_state_cache(self.state_cache_disabled)
.without_prewarming(self.prewarming_disabled)
.with_disable_parallel_sparse_trie(self.parallel_sparse_trie_disabled)
.with_state_provider_metrics(self.state_provider_metrics)
Expand Down
3 changes: 3 additions & 0 deletions docs/vocs/docs/pages/cli/op-reth/node.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -885,6 +885,9 @@ Engine:
--engine.legacy-state-root
Enable legacy state root

--engine.disable-state-cache
Disable state cache

--engine.disable-prewarming
Disable parallel prewarming

Expand Down
3 changes: 3 additions & 0 deletions docs/vocs/docs/pages/cli/reth/node.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -885,6 +885,9 @@ Engine:
--engine.legacy-state-root
Enable legacy state root

--engine.disable-state-cache
Disable state cache

--engine.disable-prewarming
Disable parallel prewarming

Expand Down
Loading