Skip to content

Commit

Permalink
feat(cli): add use-caching-and-prewarming flag
Browse files Browse the repository at this point in the history
  • Loading branch information
Rjected committed Jan 30, 2025
1 parent 6ab1528 commit ecc3410
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
3 changes: 3 additions & 0 deletions book/cli/reth/node.md
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,9 @@ Engine:
--engine.state-root-task
Enable state root task
--engine.caching-and-prewarming
Enable cross-block caching and parallel prewarming
--engine.state-root-task-compare-updates
Enable comparing trie updates from the state root task to the trie updates from the regular state root calculation
Expand Down
17 changes: 17 additions & 0 deletions crates/engine/tree/src/tree/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,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 use cross-block caching and parallel prewarming
use_caching_and_prewarming: bool,
}

impl Default for TreeConfig {
Expand All @@ -58,12 +60,14 @@ impl Default for TreeConfig {
max_execute_block_batch_size: DEFAULT_MAX_EXECUTE_BLOCK_BATCH_SIZE,
use_state_root_task: false,
always_compare_trie_updates: false,
use_caching_and_prewarming: false,
}
}
}

impl TreeConfig {
/// Create engine tree configuration.
#[allow(clippy::too_many_arguments)]
pub const fn new(
persistence_threshold: u64,
memory_block_buffer_target: u64,
Expand All @@ -72,6 +76,7 @@ impl TreeConfig {
max_execute_block_batch_size: usize,
use_state_root_task: bool,
always_compare_trie_updates: bool,
use_caching_and_prewarming: bool,
) -> Self {
Self {
persistence_threshold,
Expand All @@ -81,6 +86,7 @@ impl TreeConfig {
max_execute_block_batch_size,
use_state_root_task,
always_compare_trie_updates,
use_caching_and_prewarming,
}
}

Expand Down Expand Up @@ -114,6 +120,11 @@ impl TreeConfig {
self.use_state_root_task
}

/// Returns whether or not cross-block caching and parallel prewarming should be used.
pub const fn use_caching_and_prewarming(&self) -> bool {
self.use_caching_and_prewarming
}

/// Returns whether to always compare trie updates from the state root task to the trie updates
/// from the regular state root calculation.
pub const fn always_compare_trie_updates(&self) -> bool {
Expand Down Expand Up @@ -165,6 +176,12 @@ impl TreeConfig {
self
}

/// Setter for whether to use the new state root task calculation method.
pub const fn with_caching_and_prewarming(mut self, use_caching_and_prewarming: bool) -> Self {
self.use_caching_and_prewarming = use_caching_and_prewarming;
self
}

/// Setter for whether to always compare trie updates from the state root task to the trie
/// updates from the regular state root calculation.
pub const fn with_always_compare_trie_updates(
Expand Down
5 changes: 5 additions & 0 deletions crates/node/core/src/args/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ pub struct EngineArgs {
#[arg(long = "engine.state-root-task")]
pub state_root_task_enabled: bool,

/// Enable cross-block caching and parallel prewarming
#[arg(long = "engine.caching-and-prewarming")]
pub caching_and_prewarming_enabled: bool,

/// Enable comparing trie updates from the state root task to the trie updates from the regular
/// state root calculation.
#[arg(long = "engine.state-root-task-compare-updates")]
Expand All @@ -33,6 +37,7 @@ impl Default for EngineArgs {
memory_block_buffer_target: DEFAULT_MEMORY_BLOCK_BUFFER_TARGET,
state_root_task_enabled: false,
state_root_task_compare_updates: false,
caching_and_prewarming_enabled: false,
}
}
}
Expand Down

0 comments on commit ecc3410

Please sign in to comment.