Skip to content
Open
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
20 changes: 12 additions & 8 deletions beacon_node/http_api/src/publish_blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,9 @@ pub async fn publish_block<T: BeaconChainTypes, B: IntoGossipVerifiedBlock<T>>(
current_span.record("provenance", provenance);

let block = unverified_block.inner_block();
let block_root = block.canonical_root();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. We can do block_root.unwrap_or_else here, as block root is already calculated when calling from the publish blinded block path.
  2. If you record this to the span, the block_root field will be available to both the span and all logs in this function:
current_span.record("block_root", ?block_root);


debug!(slot = %block.slot(), "Signed block received in HTTP API");
debug!(slot = %block.slot(), ?block_root, "Signed block received in HTTP API");

/* actually publish a block */
let publish_block_p2p = move |block: Arc<SignedBeaconBlock<T::EthSpec>>,
Expand All @@ -128,6 +129,7 @@ pub async fn publish_block<T: BeaconChainTypes, B: IntoGossipVerifiedBlock<T>>(

info!(
slot = %block.slot(),
?block_root,
publish_delay_ms = publish_delay.as_millis(),
"Signed block published to network via HTTP API"
);
Expand All @@ -152,18 +154,13 @@ 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 {
if let Some(block_publishing_delay) = block_publishing_delay_for_testing {
debug!(
?block_publishing_delay,
?block_root,
"Publishing block with artificial delay"
);
tokio::time::sleep(block_publishing_delay).await;
Expand Down Expand Up @@ -210,7 +207,11 @@ pub async fn publish_block<T: BeaconChainTypes, B: IntoGossipVerifiedBlock<T>>(
return if let BroadcastValidation::Gossip = validation_level {
Err(warp_utils::reject::broadcast_without_import(msg))
} else {
error!(reason = &msg, "Invalid blob provided to HTTP API");
error!(
reason = &msg,
?block_root,
"Invalid blob provided to HTTP API"
);
Err(warp_utils::reject::custom_bad_request(msg))
};
}
Expand All @@ -228,6 +229,7 @@ pub async fn publish_block<T: BeaconChainTypes, B: IntoGossipVerifiedBlock<T>>(
if !delay.is_zero() {
debug!(
?data_column_publishing_delay,
?block_root,
"Publishing data columns with artificial delay"
);
tokio::time::sleep(delay).await;
Expand Down Expand Up @@ -255,6 +257,7 @@ pub async fn publish_block<T: BeaconChainTypes, B: IntoGossipVerifiedBlock<T>>(
} else {
error!(
reason = &msg,
?block_root,
"Invalid data column during block publication"
);
Err(warp_utils::reject::custom_bad_request(msg))
Expand Down Expand Up @@ -336,6 +339,7 @@ pub async fn publish_block<T: BeaconChainTypes, B: IntoGossipVerifiedBlock<T>>(
Err(e) => {
warn!(
%slot,
?block_root,
error = %e,
"Not publishing block - not gossip verified"
);
Expand Down
Loading