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,11 @@ pub struct EngineArgs {
/// Enable state root task /// Enable state root task
#[arg(long = "engine.state-root-task", conflicts_with = "legacy")] #[arg(long = "engine.state-root-task", conflicts_with = "legacy")]
pub state_root_task_enabled: bool, pub state_root_task_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", conflicts_with = "legacy")]
pub state_root_task_compare_updates: bool,
} }
impl Default for EngineArgs { impl Default for EngineArgs {
@ -53,6 +58,7 @@ impl Default for EngineArgs {
persistence_threshold: DEFAULT_PERSISTENCE_THRESHOLD, persistence_threshold: DEFAULT_PERSISTENCE_THRESHOLD,
memory_block_buffer_target: DEFAULT_MEMORY_BLOCK_BUFFER_TARGET, memory_block_buffer_target: DEFAULT_MEMORY_BLOCK_BUFFER_TARGET,
state_root_task_enabled: false, state_root_task_enabled: false,
state_root_task_compare_updates: false,
} }
} }
} }
@ -77,7 +83,8 @@ fn main() {
let engine_tree_config = TreeConfig::default() let engine_tree_config = TreeConfig::default()
.with_persistence_threshold(engine_args.persistence_threshold) .with_persistence_threshold(engine_args.persistence_threshold)
.with_memory_block_buffer_target(engine_args.memory_block_buffer_target) .with_memory_block_buffer_target(engine_args.memory_block_buffer_target)
.with_state_root_task(engine_args.state_root_task_enabled); .with_state_root_task(engine_args.state_root_task_enabled)
.with_always_compare_trie_updates(engine_args.state_root_task_compare_updates);
let handle = builder let handle = builder
.with_types_and_provider::<EthereumNode, BlockchainProvider<_>>() .with_types_and_provider::<EthereumNode, BlockchainProvider<_>>()
.with_components(EthereumNode::components()) .with_components(EthereumNode::components())

View File

@ -703,6 +703,9 @@ Engine:
--engine.state-root-task --engine.state-root-task
Enable state root task Enable state root task
--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
Logging: Logging:
--log.stdout.format <FORMAT> --log.stdout.format <FORMAT>
The format to use for logs written to stdout The format to use for logs written to stdout

View File

@ -43,6 +43,9 @@ pub struct TreeConfig {
max_execute_block_batch_size: usize, max_execute_block_batch_size: usize,
/// Whether to use the new state root task calculation method instead of parallel calculation /// Whether to use the new state root task calculation method instead of parallel calculation
use_state_root_task: bool, 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 { impl Default for TreeConfig {
@ -54,6 +57,7 @@ impl Default for TreeConfig {
max_invalid_header_cache_length: DEFAULT_MAX_INVALID_HEADER_CACHE_LENGTH, max_invalid_header_cache_length: DEFAULT_MAX_INVALID_HEADER_CACHE_LENGTH,
max_execute_block_batch_size: DEFAULT_MAX_EXECUTE_BLOCK_BATCH_SIZE, max_execute_block_batch_size: DEFAULT_MAX_EXECUTE_BLOCK_BATCH_SIZE,
use_state_root_task: false, use_state_root_task: false,
always_compare_trie_updates: false,
} }
} }
} }
@ -67,6 +71,7 @@ impl TreeConfig {
max_invalid_header_cache_length: u32, max_invalid_header_cache_length: u32,
max_execute_block_batch_size: usize, max_execute_block_batch_size: usize,
use_state_root_task: bool, use_state_root_task: bool,
always_compare_trie_updates: bool,
) -> Self { ) -> Self {
Self { Self {
persistence_threshold, persistence_threshold,
@ -75,6 +80,7 @@ impl TreeConfig {
max_invalid_header_cache_length, max_invalid_header_cache_length,
max_execute_block_batch_size, max_execute_block_batch_size,
use_state_root_task, use_state_root_task,
always_compare_trie_updates,
} }
} }
@ -108,6 +114,12 @@ impl TreeConfig {
self.use_state_root_task 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. /// Setter for persistence threshold.
pub const fn with_persistence_threshold(mut self, persistence_threshold: u64) -> Self { pub const fn with_persistence_threshold(mut self, persistence_threshold: u64) -> Self {
self.persistence_threshold = persistence_threshold; self.persistence_threshold = persistence_threshold;
@ -152,4 +164,14 @@ impl TreeConfig {
self.use_state_root_task = use_state_root_task; self.use_state_root_task = use_state_root_task;
self 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" "Task state root finished"
); );
if task_state_root != block.header().state_root() ||
self.config.always_compare_trie_updates()
{
if task_state_root != block.header().state_root() { if task_state_root != block.header().state_root() {
debug!(target: "engine::tree", "Task state root does not match block state root"); debug!(target: "engine::tree", "Task state root does not match block state root");
}
let (regular_root, regular_updates) = let (regular_root, regular_updates) =
state_provider.state_root_with_updates(hashed_state.clone())?; state_provider.state_root_with_updates(hashed_state.clone())?;