Skip to content

Commit 22dea2b

Browse files
dapplionjimmygchen
andauthored
Include block root in publish block logs (sigp#8111)
Debugging sigp#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>
1 parent 93b8f46 commit 22dea2b

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

beacon_node/http_api/src/publish_blocks.rs

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use std::sync::Arc;
2525
use std::sync::atomic::{AtomicBool, Ordering};
2626
use std::time::Duration;
2727
use tokio::sync::mpsc::UnboundedSender;
28-
use tracing::{Span, debug, debug_span, error, info, instrument, warn};
28+
use tracing::{Span, debug, debug_span, error, field, info, instrument, warn};
2929
use tree_hash::TreeHash;
3030
use types::{
3131
AbstractExecPayload, BeaconBlockRef, BlobSidecar, BlobsList, BlockImportSource,
@@ -80,7 +80,7 @@ impl<T: BeaconChainTypes> ProvenancedBlock<T, Arc<SignedBeaconBlock<T::EthSpec>>
8080
name = SPAN_PUBLISH_BLOCK,
8181
level = "info",
8282
skip_all,
83-
fields(?block_root, ?validation_level, provenance = tracing::field::Empty)
83+
fields(block_root = field::Empty, ?validation_level, block_slot = field::Empty, provenance = field::Empty)
8484
)]
8585
pub async fn publish_block<T: BeaconChainTypes, B: IntoGossipVerifiedBlock<T>>(
8686
block_root: Option<Hash256>,
@@ -103,12 +103,16 @@ pub async fn publish_block<T: BeaconChainTypes, B: IntoGossipVerifiedBlock<T>>(
103103
} else {
104104
"builder"
105105
};
106-
let current_span = Span::current();
107-
current_span.record("provenance", provenance);
108106

109107
let block = unverified_block.inner_block();
108+
let block_root = block_root.unwrap_or_else(|| block.canonical_root());
109+
110+
let current_span = Span::current();
111+
current_span.record("provenance", provenance);
112+
current_span.record("block_root", field::display(block_root));
113+
current_span.record("block_slot", field::display(block.slot()));
110114

111-
debug!(slot = %block.slot(), "Signed block received in HTTP API");
115+
debug!("Signed block received in HTTP API");
112116

113117
/* actually publish a block */
114118
let publish_block_p2p = move |block: Arc<SignedBeaconBlock<T::EthSpec>>,
@@ -152,12 +156,6 @@ pub async fn publish_block<T: BeaconChainTypes, B: IntoGossipVerifiedBlock<T>>(
152156

153157
// Gossip verify the block and blobs/data columns separately.
154158
let gossip_verified_block_result = unverified_block.into_gossip_verified_block(&chain);
155-
let block_root = block_root.unwrap_or_else(|| {
156-
gossip_verified_block_result.as_ref().map_or_else(
157-
|_| block.canonical_root(),
158-
|verified_block| verified_block.block_root,
159-
)
160-
});
161159

162160
let should_publish_block = gossip_verified_block_result.is_ok();
163161
if BroadcastValidation::Gossip == validation_level && should_publish_block {
@@ -309,9 +307,8 @@ pub async fn publish_block<T: BeaconChainTypes, B: IntoGossipVerifiedBlock<T>>(
309307
.into_response())
310308
}
311309
}
312-
Err(BlockError::DuplicateImportStatusUnknown(root)) => {
310+
Err(BlockError::DuplicateImportStatusUnknown(_)) => {
313311
debug!(
314-
block_root = ?root,
315312
slot = %block.slot(),
316313
"Block previously seen"
317314
);

0 commit comments

Comments
 (0)