Include block root in publish block logs (#8111)

Debugging https://github.com/sigp/lighthouse/issues/8104 it would have been helpful to quickly see in the logs that a specific block was submitted into the HTTP API.

Because we want to optimize the block root computation we don't include it in the logs, and just log the block slot. I believe we can take a minute performance hit to have the block root in all the logs during block publishing.


  


Co-Authored-By: dapplion <35266934+dapplion@users.noreply.github.com>

Co-Authored-By: Jimmy Chen <jchen.tc@gmail.com>
This commit is contained in:
Lion - dapplion
2025-11-11 01:40:32 -03:00
committed by GitHub
parent 93b8f4686d
commit 22dea2bc32

View File

@@ -25,7 +25,7 @@ use std::sync::Arc;
use std::sync::atomic::{AtomicBool, Ordering};
use std::time::Duration;
use tokio::sync::mpsc::UnboundedSender;
use tracing::{Span, debug, debug_span, error, info, instrument, warn};
use tracing::{Span, debug, debug_span, error, field, info, instrument, warn};
use tree_hash::TreeHash;
use types::{
AbstractExecPayload, BeaconBlockRef, BlobSidecar, BlobsList, BlockImportSource,
@@ -80,7 +80,7 @@ impl<T: BeaconChainTypes> ProvenancedBlock<T, Arc<SignedBeaconBlock<T::EthSpec>>
name = SPAN_PUBLISH_BLOCK,
level = "info",
skip_all,
fields(?block_root, ?validation_level, provenance = tracing::field::Empty)
fields(block_root = field::Empty, ?validation_level, block_slot = field::Empty, provenance = field::Empty)
)]
pub async fn publish_block<T: BeaconChainTypes, B: IntoGossipVerifiedBlock<T>>(
block_root: Option<Hash256>,
@@ -103,12 +103,16 @@ pub async fn publish_block<T: BeaconChainTypes, B: IntoGossipVerifiedBlock<T>>(
} else {
"builder"
};
let current_span = Span::current();
current_span.record("provenance", provenance);
let block = unverified_block.inner_block();
let block_root = block_root.unwrap_or_else(|| block.canonical_root());
debug!(slot = %block.slot(), "Signed block received in HTTP API");
let current_span = Span::current();
current_span.record("provenance", provenance);
current_span.record("block_root", field::display(block_root));
current_span.record("block_slot", field::display(block.slot()));
debug!("Signed block received in HTTP API");
/* actually publish a block */
let publish_block_p2p = move |block: Arc<SignedBeaconBlock<T::EthSpec>>,
@@ -152,12 +156,6 @@ pub async fn publish_block<T: BeaconChainTypes, B: IntoGossipVerifiedBlock<T>>(
// Gossip verify the block and blobs/data columns separately.
let gossip_verified_block_result = unverified_block.into_gossip_verified_block(&chain);
let block_root = block_root.unwrap_or_else(|| {
gossip_verified_block_result.as_ref().map_or_else(
|_| block.canonical_root(),
|verified_block| verified_block.block_root,
)
});
let should_publish_block = gossip_verified_block_result.is_ok();
if BroadcastValidation::Gossip == validation_level && should_publish_block {
@@ -309,9 +307,8 @@ pub async fn publish_block<T: BeaconChainTypes, B: IntoGossipVerifiedBlock<T>>(
.into_response())
}
}
Err(BlockError::DuplicateImportStatusUnknown(root)) => {
Err(BlockError::DuplicateImportStatusUnknown(_)) => {
debug!(
block_root = ?root,
slot = %block.slot(),
"Block previously seen"
);