mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 19:09:54 +00:00
chore(tree): improved debug logging for block insertion (#11958)
This commit is contained in:
@ -259,6 +259,7 @@ impl TreeState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
debug!(target: "engine::tree", ?upper_bound, ?last_persisted_hash, "Removed canonical blocks from the tree");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Removes all blocks that are below the finalized block, as well as removing non-canonical
|
/// Removes all blocks that are below the finalized block, as well as removing non-canonical
|
||||||
@ -1593,7 +1594,7 @@ where
|
|||||||
/// Returns an error if we failed to fetch the state from the database.
|
/// Returns an error if we failed to fetch the state from the database.
|
||||||
fn state_provider(&self, hash: B256) -> ProviderResult<Option<StateProviderBox>> {
|
fn state_provider(&self, hash: B256) -> ProviderResult<Option<StateProviderBox>> {
|
||||||
if let Some((historical, blocks)) = self.state.tree_state.blocks_by_hash(hash) {
|
if let Some((historical, blocks)) = self.state.tree_state.blocks_by_hash(hash) {
|
||||||
trace!(target: "engine::tree", %hash, "found canonical state for block in memory");
|
debug!(target: "engine::tree", %hash, %historical, "found canonical state for block in memory");
|
||||||
// the block leads back to the canonical chain
|
// the block leads back to the canonical chain
|
||||||
let historical = self.provider.state_by_block_hash(historical)?;
|
let historical = self.provider.state_by_block_hash(historical)?;
|
||||||
return Ok(Some(Box::new(MemoryOverlayStateProvider::new(historical, blocks))))
|
return Ok(Some(Box::new(MemoryOverlayStateProvider::new(historical, blocks))))
|
||||||
@ -1601,13 +1602,13 @@ where
|
|||||||
|
|
||||||
// the hash could belong to an unknown block or a persisted block
|
// the hash could belong to an unknown block or a persisted block
|
||||||
if let Some(header) = self.provider.header(&hash)? {
|
if let Some(header) = self.provider.header(&hash)? {
|
||||||
trace!(target: "engine::tree", %hash, number = %header.number, "found canonical state for block in database");
|
debug!(target: "engine::tree", %hash, number = %header.number, "found canonical state for block in database");
|
||||||
// the block is known and persisted
|
// the block is known and persisted
|
||||||
let historical = self.provider.state_by_block_hash(hash)?;
|
let historical = self.provider.state_by_block_hash(hash)?;
|
||||||
return Ok(Some(historical))
|
return Ok(Some(historical))
|
||||||
}
|
}
|
||||||
|
|
||||||
trace!(target: "engine::tree", %hash, "no canonical state found for block");
|
debug!(target: "engine::tree", %hash, "no canonical state found for block");
|
||||||
|
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
@ -2137,7 +2138,8 @@ where
|
|||||||
&mut self,
|
&mut self,
|
||||||
block: SealedBlockWithSenders,
|
block: SealedBlockWithSenders,
|
||||||
) -> Result<InsertPayloadOk2, InsertBlockErrorKindTwo> {
|
) -> Result<InsertPayloadOk2, InsertBlockErrorKindTwo> {
|
||||||
debug!(target: "engine::tree", block=?block.num_hash(), "Inserting new block into tree");
|
debug!(target: "engine::tree", block=?block.num_hash(), parent = ?block.parent_hash, state_root = ?block.state_root, "Inserting new block into tree");
|
||||||
|
|
||||||
if self.block_by_hash(block.hash())?.is_some() {
|
if self.block_by_hash(block.hash())?.is_some() {
|
||||||
return Ok(InsertPayloadOk2::AlreadySeen(BlockStatus2::Valid))
|
return Ok(InsertPayloadOk2::AlreadySeen(BlockStatus2::Valid))
|
||||||
}
|
}
|
||||||
@ -2206,7 +2208,7 @@ where
|
|||||||
|
|
||||||
let hashed_state = HashedPostState::from_bundle_state(&output.state.state);
|
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");
|
trace!(target: "engine::tree", block=?sealed_block.num_hash(), "Calculating block state root");
|
||||||
let root_time = Instant::now();
|
let root_time = Instant::now();
|
||||||
let mut state_root_result = None;
|
let mut state_root_result = None;
|
||||||
|
|
||||||
@ -2232,7 +2234,7 @@ where
|
|||||||
let (state_root, trie_output) = if let Some(result) = state_root_result {
|
let (state_root, trie_output) = if let Some(result) = state_root_result {
|
||||||
result
|
result
|
||||||
} else {
|
} else {
|
||||||
debug!(target: "engine::tree", persistence_in_progress, "Failed to compute state root in parallel");
|
debug!(target: "engine::tree", block=?sealed_block.num_hash(), persistence_in_progress, "Failed to compute state root in parallel");
|
||||||
state_provider.state_root_with_updates(hashed_state.clone())?
|
state_provider.state_root_with_updates(hashed_state.clone())?
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -2252,7 +2254,7 @@ where
|
|||||||
|
|
||||||
let root_elapsed = root_time.elapsed();
|
let root_elapsed = root_time.elapsed();
|
||||||
self.metrics.block_validation.record_state_root(&trie_output, root_elapsed.as_secs_f64());
|
self.metrics.block_validation.record_state_root(&trie_output, root_elapsed.as_secs_f64());
|
||||||
debug!(target: "engine::tree", ?root_elapsed, ?block_number, "Calculated state root");
|
debug!(target: "engine::tree", ?root_elapsed, block=?sealed_block.num_hash(), "Calculated state root");
|
||||||
|
|
||||||
let executed = ExecutedBlock {
|
let executed = ExecutedBlock {
|
||||||
block: sealed_block.clone(),
|
block: sealed_block.clone(),
|
||||||
@ -2301,6 +2303,7 @@ where
|
|||||||
let mut input = TrieInput::default();
|
let mut input = TrieInput::default();
|
||||||
|
|
||||||
if let Some((historical, blocks)) = self.state.tree_state.blocks_by_hash(parent_hash) {
|
if let Some((historical, blocks)) = self.state.tree_state.blocks_by_hash(parent_hash) {
|
||||||
|
debug!(target: "engine::tree", %parent_hash, %historical, "Calculating state root in parallel, parent found in memory");
|
||||||
// Retrieve revert state for historical block.
|
// Retrieve revert state for historical block.
|
||||||
let revert_state = consistent_view.revert_state(historical)?;
|
let revert_state = consistent_view.revert_state(historical)?;
|
||||||
input.append(revert_state);
|
input.append(revert_state);
|
||||||
@ -2311,6 +2314,7 @@ where
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// The block attaches to canonical persisted parent.
|
// The block attaches to canonical persisted parent.
|
||||||
|
debug!(target: "engine::tree", %parent_hash, "Calculating state root in parallel, parent found in disk");
|
||||||
let revert_state = consistent_view.revert_state(parent_hash)?;
|
let revert_state = consistent_view.revert_state(parent_hash)?;
|
||||||
input.append(revert_state);
|
input.append(revert_state);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user