Skip to content

Commit cfde951

Browse files
authored
feat(engine): run sync state root if not enough parallelism (#20127)
1 parent 07bca4f commit cfde951

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

crates/engine/primitives/src/config.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ pub struct TreeConfig {
9797
state_provider_metrics: bool,
9898
/// Cross-block cache size in bytes.
9999
cross_block_cache_size: u64,
100-
/// Whether the host has enough parallelism to run state root task.
100+
/// Whether the host has enough parallelism to run state root in parallel.
101101
has_enough_parallelism: bool,
102102
/// Whether multiproof task should chunk proof targets.
103103
multiproof_chunking_enabled: bool,
@@ -385,12 +385,17 @@ impl TreeConfig {
385385
self
386386
}
387387

388-
/// Setter for has enough parallelism.
388+
/// Setter for whether or not the host has enough parallelism to run state root in parallel.
389389
pub const fn with_has_enough_parallelism(mut self, has_enough_parallelism: bool) -> Self {
390390
self.has_enough_parallelism = has_enough_parallelism;
391391
self
392392
}
393393

394+
/// Whether or not the host has enough parallelism to run state root in parallel.
395+
pub const fn has_enough_parallelism(&self) -> bool {
396+
self.has_enough_parallelism
397+
}
398+
394399
/// Setter for state provider metrics.
395400
pub const fn with_state_provider_metrics(mut self, state_provider_metrics: bool) -> Self {
396401
self.state_provider_metrics = state_provider_metrics;

crates/engine/tree/src/tree/payload_validator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,7 @@ where
857857
/// Note: Use state root task only if prefix sets are empty, otherwise proof generation is
858858
/// too expensive because it requires walking all paths in every proof.
859859
const fn plan_state_root_computation(&self) -> StateRootStrategy {
860-
if self.config.state_root_fallback() {
860+
if self.config.state_root_fallback() || !self.config.has_enough_parallelism() {
861861
StateRootStrategy::Synchronous
862862
} else if self.config.use_state_root_task() {
863863
StateRootStrategy::StateRootTask

0 commit comments

Comments
 (0)