Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(tree): add more insert block debug logs #11078

Merged
merged 1 commit into from
Sep 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions crates/engine/tree/src/tree/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2106,15 +2106,18 @@ where
&mut self,
block: SealedBlockWithSenders,
) -> Result<InsertPayloadOk2, InsertBlockErrorKindTwo> {
debug!(target: "engine::tree", block=?block.num_hash(), "Inserting new block into tree");
if self.block_by_hash(block.hash())?.is_some() {
return Ok(InsertPayloadOk2::AlreadySeen(BlockStatus2::Valid))
}

let start = Instant::now();

trace!(target: "engine::tree", block=?block.num_hash(), "Validating block consensus");
// validate block consensus rules
self.validate_block(&block)?;

trace!(target: "engine::tree", block=?block.num_hash(), parent=?block.parent_hash, "Fetching block state provider");
let Some(state_provider) = self.state_provider(block.parent_hash)? else {
// we don't have the state required to execute this block, buffering it and find the
// missing parent block
Expand Down Expand Up @@ -2144,6 +2147,7 @@ where
return Err(e.into())
}

trace!(target: "engine::tree", block=?block.num_hash(), "Executing block");
let executor = self.executor_provider.executor(StateProviderDatabase::new(&state_provider));

let block_number = block.number;
Expand All @@ -2156,8 +2160,8 @@ where
.metrics
.executor
.metered((&block, U256::MAX).into(), |input| executor.execute(input))?;
debug!(target: "engine::tree", elapsed=?exec_time.elapsed(), ?block_number, "Executed block");

trace!(target: "engine::tree", elapsed=?exec_time.elapsed(), ?block_number, "Executed block");
if let Err(err) = self.consensus.validate_block_post_execution(
&block,
PostExecutionInput::new(&output.receipts, &output.requests),
Expand All @@ -2174,6 +2178,7 @@ where

let hashed_state = HashedPostState::from_bundle_state(&output.state.state);

trace!(target: "engine::tree", block=?BlockNumHash::new(block_number, block_hash), "Calculating block state root");
let root_time = Instant::now();
let mut state_root_result = None;

Expand All @@ -2189,7 +2194,7 @@ where
{
Ok((state_root, trie_output)) => Some((state_root, trie_output)),
Err(ProviderError::ConsistentView(error)) => {
debug!(target: "engine", %error, "Parallel state root computation failed consistency check, falling back");
debug!(target: "engine::tree", %error, "Parallel state root computation failed consistency check, falling back");
None
}
Err(error) => return Err(error.into()),
Expand All @@ -2199,7 +2204,7 @@ where
let (state_root, trie_output) = if let Some(result) = state_root_result {
result
} else {
debug!(target: "engine", persistence_in_progress, "Failed to compute state root in parallel");
debug!(target: "engine::tree", persistence_in_progress, "Failed to compute state root in parallel");
state_provider.state_root_with_updates(hashed_state.clone())?
};

Expand Down Expand Up @@ -2251,6 +2256,7 @@ where
};
self.emit_event(EngineApiEvent::BeaconConsensus(engine_event));

debug!(target: "engine::tree", block=?BlockNumHash::new(block_number, block_hash), "Finished inserting block");
Ok(InsertPayloadOk2::Inserted(BlockStatus2::Valid))
}

Expand Down
Loading