Skip to content

Commit

Permalink
use different ConsistentDbView for each SR calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
fgimenez committed Nov 22, 2024
1 parent 635c53f commit fa4e2d1
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions crates/engine/tree/src/tree/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2199,8 +2199,7 @@ where
let input = self
.compute_trie_input(consistent_view.clone(), block.parent_hash)
.map_err(|e| InsertBlockErrorKindTwo::Other(Box::new(e)))?;
let state_root_config =
StateRootConfig { consistent_view: consistent_view.clone(), input: Arc::new(input) };
let state_root_config = StateRootConfig { consistent_view, input: Arc::new(input) };
let receiver_stream = StdReceiverStream::new(state_root_rx);
let state_root_task = StateRootTask::new(state_root_config, receiver_stream);
let state_root_handle = state_root_task.spawn();
Expand Down Expand Up @@ -2243,6 +2242,7 @@ where
// per thread and it might end up with a different view of the database.
let persistence_in_progress = self.persistence_state.in_progress();
if !persistence_in_progress {
let consistent_view = ConsistentDbView::new_with_latest_tip(self.provider.clone())?;
let mut input = self
.compute_trie_input(consistent_view.clone(), block.parent_hash)
.map_err(|e| InsertBlockErrorKindTwo::Other(Box::new(e)))?;
Expand All @@ -2260,8 +2260,13 @@ where
}

let (state_root, trie_output) = if let Some(result) = state_root_result {
if let Ok(state_root_task_result) = state_root_handle.wait_for_result() {
debug!(target: "engine::tree", block=?sealed_block.num_hash(), state_root_task_result=?state_root_task_result.0, regular_state_root_result = ?result.0);
match state_root_handle.wait_for_result() {
Ok(state_root_task_result) => {
info!(target: "engine::tree", block=?sealed_block.num_hash(), state_root_task_result=?state_root_task_result.0, regular_state_root_result = ?result.0);
}
Err(e) => {
info!(target: "engine::tree", error=?e, "on state root task wait_for_result")
}
}
result
} else {
Expand Down

0 comments on commit fa4e2d1

Please sign in to comment.