feat(tree): --engine.state-root-task-compare-updates (#13763)

This commit is contained in:
Alexey Shekhirin
2025-01-10 12:30:50 +00:00
committed by GitHub
parent 69f9e1628a
commit c601712147
4 changed files with 40 additions and 3 deletions

View File

@ -43,6 +43,9 @@ pub struct TreeConfig {
max_execute_block_batch_size: usize,
/// Whether to use the new state root task calculation method instead of parallel calculation
use_state_root_task: bool,
/// 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,
}
impl Default for TreeConfig {
@ -54,6 +57,7 @@ impl Default for TreeConfig {
max_invalid_header_cache_length: DEFAULT_MAX_INVALID_HEADER_CACHE_LENGTH,
max_execute_block_batch_size: DEFAULT_MAX_EXECUTE_BLOCK_BATCH_SIZE,
use_state_root_task: false,
always_compare_trie_updates: false,
}
}
}
@ -67,6 +71,7 @@ impl TreeConfig {
max_invalid_header_cache_length: u32,
max_execute_block_batch_size: usize,
use_state_root_task: bool,
always_compare_trie_updates: bool,
) -> Self {
Self {
persistence_threshold,
@ -75,6 +80,7 @@ impl TreeConfig {
max_invalid_header_cache_length,
max_execute_block_batch_size,
use_state_root_task,
always_compare_trie_updates,
}
}
@ -108,6 +114,12 @@ impl TreeConfig {
self.use_state_root_task
}
/// 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 {
self.always_compare_trie_updates
}
/// Setter for persistence threshold.
pub const fn with_persistence_threshold(mut self, persistence_threshold: u64) -> Self {
self.persistence_threshold = persistence_threshold;
@ -152,4 +164,14 @@ impl TreeConfig {
self.use_state_root_task = use_state_root_task;
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(
mut self,
always_compare_trie_updates: bool,
) -> Self {
self.always_compare_trie_updates = always_compare_trie_updates;
self
}
}

View File

@ -2372,8 +2372,13 @@ where
"Task state root finished"
);
if task_state_root != block.header().state_root() {
debug!(target: "engine::tree", "Task state root does not match block state root");
if task_state_root != block.header().state_root() ||
self.config.always_compare_trie_updates()
{
if task_state_root != block.header().state_root() {
debug!(target: "engine::tree", "Task state root does not match block state root");
}
let (regular_root, regular_updates) =
state_provider.state_root_with_updates(hashed_state.clone())?;