Improve parent lookup logging (#5451)

* upgrade parent lookup result processing logs to debug, use display instead of debug for BlockError in case a blob parent unknown error is hit, add block root to BlockIsAlreadyKnown

* fix compile

* fix compile

* fix compile
This commit is contained in:
realbigsean 2024-03-22 14:16:13 -04:00 committed by GitHub
parent 5ce16192c7
commit 21cdc64bfe
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 30 additions and 22 deletions

View File

@ -2651,7 +2651,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
// If the block is relevant, add it to the filtered chain segment. // If the block is relevant, add it to the filtered chain segment.
Ok(_) => filtered_chain_segment.push((block_root, block)), Ok(_) => filtered_chain_segment.push((block_root, block)),
// If the block is already known, simply ignore this block. // If the block is already known, simply ignore this block.
Err(BlockError::BlockIsAlreadyKnown) => continue, Err(BlockError::BlockIsAlreadyKnown(_)) => continue,
// If the block is the genesis block, simply ignore this block. // If the block is the genesis block, simply ignore this block.
Err(BlockError::GenesisBlock) => continue, Err(BlockError::GenesisBlock) => continue,
// If the block is is for a finalized slot, simply ignore this block. // If the block is is for a finalized slot, simply ignore this block.
@ -2879,7 +2879,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
.fork_choice_read_lock() .fork_choice_read_lock()
.contains_block(&block_root) .contains_block(&block_root)
{ {
return Err(BlockError::BlockIsAlreadyKnown); return Err(BlockError::BlockIsAlreadyKnown(blob.block_root()));
} }
if let Some(event_handler) = self.event_handler.as_ref() { if let Some(event_handler) = self.event_handler.as_ref() {
@ -2911,7 +2911,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
.fork_choice_read_lock() .fork_choice_read_lock()
.contains_block(&block_root) .contains_block(&block_root)
{ {
return Err(BlockError::BlockIsAlreadyKnown); return Err(BlockError::BlockIsAlreadyKnown(block_root));
} }
if let Some(event_handler) = self.event_handler.as_ref() { if let Some(event_handler) = self.event_handler.as_ref() {

View File

@ -190,7 +190,7 @@ pub enum BlockError<T: EthSpec> {
/// ## Peer scoring /// ## Peer scoring
/// ///
/// The block is valid and we have already imported a block with this hash. /// The block is valid and we have already imported a block with this hash.
BlockIsAlreadyKnown, BlockIsAlreadyKnown(Hash256),
/// The block slot exceeds the MAXIMUM_BLOCK_SLOT_NUMBER. /// The block slot exceeds the MAXIMUM_BLOCK_SLOT_NUMBER.
/// ///
/// ## Peer scoring /// ## Peer scoring
@ -832,7 +832,7 @@ impl<T: BeaconChainTypes> GossipVerifiedBlock<T> {
// already know this block. // already know this block.
let fork_choice_read_lock = chain.canonical_head.fork_choice_read_lock(); let fork_choice_read_lock = chain.canonical_head.fork_choice_read_lock();
if fork_choice_read_lock.contains_block(&block_root) { if fork_choice_read_lock.contains_block(&block_root) {
return Err(BlockError::BlockIsAlreadyKnown); return Err(BlockError::BlockIsAlreadyKnown(block_root));
} }
// Do not process a block that doesn't descend from the finalized root. // Do not process a block that doesn't descend from the finalized root.
@ -966,7 +966,7 @@ impl<T: BeaconChainTypes> GossipVerifiedBlock<T> {
SeenBlock::Slashable => { SeenBlock::Slashable => {
return Err(BlockError::Slashable); return Err(BlockError::Slashable);
} }
SeenBlock::Duplicate => return Err(BlockError::BlockIsAlreadyKnown), SeenBlock::Duplicate => return Err(BlockError::BlockIsAlreadyKnown(block_root)),
SeenBlock::UniqueNonSlashable => {} SeenBlock::UniqueNonSlashable => {}
}; };
@ -1784,7 +1784,7 @@ pub fn check_block_relevancy<T: BeaconChainTypes>(
.fork_choice_read_lock() .fork_choice_read_lock()
.contains_block(&block_root) .contains_block(&block_root)
{ {
return Err(BlockError::BlockIsAlreadyKnown); return Err(BlockError::BlockIsAlreadyKnown(block_root));
} }
Ok(block_root) Ok(block_root)

View File

@ -1087,7 +1087,7 @@ async fn block_gossip_verification() {
assert!( assert!(
matches!( matches!(
unwrap_err(harness.chain.verify_block_for_gossip(Arc::new(block.clone())).await), unwrap_err(harness.chain.verify_block_for_gossip(Arc::new(block.clone())).await),
BlockError::BlockIsAlreadyKnown, BlockError::BlockIsAlreadyKnown(_),
), ),
"should register any valid signature against the proposer, even if the block failed later verification" "should register any valid signature against the proposer, even if the block failed later verification"
); );
@ -1115,7 +1115,7 @@ async fn block_gossip_verification() {
.verify_block_for_gossip(block.clone()) .verify_block_for_gossip(block.clone())
.await .await
.expect_err("should error when processing known block"), .expect_err("should error when processing known block"),
BlockError::BlockIsAlreadyKnown BlockError::BlockIsAlreadyKnown(_)
), ),
"the second proposal by this validator should be rejected" "the second proposal by this validator should be rejected"
); );

View File

@ -113,7 +113,7 @@ pub async fn publish_block<T: BeaconChainTypes, B: IntoGossipVerifiedBlockConten
let (gossip_verified_block, gossip_verified_blobs) = let (gossip_verified_block, gossip_verified_blobs) =
match block_contents.into_gossip_verified_block(&chain) { match block_contents.into_gossip_verified_block(&chain) {
Ok(b) => b, Ok(b) => b,
Err(BlockContentsError::BlockError(BlockError::BlockIsAlreadyKnown)) Err(BlockContentsError::BlockError(BlockError::BlockIsAlreadyKnown(_)))
| Err(BlockContentsError::BlobError( | Err(BlockContentsError::BlobError(
beacon_chain::blob_verification::GossipBlobError::RepeatBlob { .. }, beacon_chain::blob_verification::GossipBlobError::RepeatBlob { .. },
)) => { )) => {
@ -133,7 +133,7 @@ pub async fn publish_block<T: BeaconChainTypes, B: IntoGossipVerifiedBlockConten
log, log,
"Not publishing block - not gossip verified"; "Not publishing block - not gossip verified";
"slot" => slot, "slot" => slot,
"error" => ?e "error" => %e
); );
return Err(warp_utils::reject::custom_bad_request(e.to_string())); return Err(warp_utils::reject::custom_bad_request(e.to_string()));
} }

View File

@ -963,7 +963,7 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
self.propagate_validation_result(message_id, peer_id, MessageAcceptance::Ignore); self.propagate_validation_result(message_id, peer_id, MessageAcceptance::Ignore);
return None; return None;
} }
Err(BlockError::BlockIsAlreadyKnown) => { Err(BlockError::BlockIsAlreadyKnown(_)) => {
debug!( debug!(
self.log, self.log,
"Gossip block is already known"; "Gossip block is already known";

View File

@ -276,7 +276,7 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
"slot" => %slot, "slot" => %slot,
); );
} }
Err(BlockError::BlockIsAlreadyKnown) => { Err(BlockError::BlockIsAlreadyKnown(_)) => {
debug!( debug!(
self.log, self.log,
"Blobs have already been imported"; "Blobs have already been imported";
@ -639,7 +639,7 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
peer_action: Some(PeerAction::LowToleranceError), peer_action: Some(PeerAction::LowToleranceError),
}) })
} }
BlockError::BlockIsAlreadyKnown => { BlockError::BlockIsAlreadyKnown(_) => {
// This can happen for many reasons. Head sync's can download multiples and parent // This can happen for many reasons. Head sync's can download multiples and parent
// lookups can download blocks before range sync // lookups can download blocks before range sync
Ok(()) Ok(())

View File

@ -811,7 +811,7 @@ impl<T: BeaconChainTypes> BlockLookups<T> {
let root = lookup.block_root(); let root = lookup.block_root();
trace!(self.log, "Single block processing failed"; "block" => %root, "error" => %e); trace!(self.log, "Single block processing failed"; "block" => %root, "error" => %e);
match e { match e {
BlockError::BlockIsAlreadyKnown => { BlockError::BlockIsAlreadyKnown(_) => {
// No error here // No error here
return Ok(None); return Ok(None);
} }
@ -898,17 +898,17 @@ impl<T: BeaconChainTypes> BlockLookups<T> {
match &result { match &result {
BlockProcessingResult::Ok(status) => match status { BlockProcessingResult::Ok(status) => match status {
AvailabilityProcessingStatus::Imported(block_root) => { AvailabilityProcessingStatus::Imported(block_root) => {
trace!(self.log, "Parent block processing succeeded"; &parent_lookup, "block_root" => ?block_root) debug!(self.log, "Parent block processing succeeded"; &parent_lookup, "block_root" => ?block_root)
} }
AvailabilityProcessingStatus::MissingComponents(_, block_root) => { AvailabilityProcessingStatus::MissingComponents(_, block_root) => {
trace!(self.log, "Parent missing parts, triggering single block lookup "; &parent_lookup,"block_root" => ?block_root) debug!(self.log, "Parent missing parts, triggering single block lookup "; &parent_lookup,"block_root" => ?block_root)
} }
}, },
BlockProcessingResult::Err(e) => { BlockProcessingResult::Err(e) => {
trace!(self.log, "Parent block processing failed"; &parent_lookup, "error" => %e) debug!(self.log, "Parent block processing failed"; &parent_lookup, "error" => %e)
} }
BlockProcessingResult::Ignored => { BlockProcessingResult::Ignored => {
trace!( debug!(
self.log, self.log,
"Parent block processing job was ignored"; "Parent block processing job was ignored";
"action" => "re-requesting block", "action" => "re-requesting block",
@ -954,7 +954,7 @@ impl<T: BeaconChainTypes> BlockLookups<T> {
self.request_parent(parent_lookup, cx); self.request_parent(parent_lookup, cx);
} }
BlockProcessingResult::Ok(AvailabilityProcessingStatus::Imported(_)) BlockProcessingResult::Ok(AvailabilityProcessingStatus::Imported(_))
| BlockProcessingResult::Err(BlockError::BlockIsAlreadyKnown { .. }) => { | BlockProcessingResult::Err(BlockError::BlockIsAlreadyKnown(_)) => {
// Check if the beacon processor is available // Check if the beacon processor is available
let Some(beacon_processor) = cx.beacon_processor_if_enabled() else { let Some(beacon_processor) = cx.beacon_processor_if_enabled() else {
return trace!( return trace!(

View File

@ -458,7 +458,11 @@ fn test_parent_lookup_happy_path() {
rig.expect_empty_network(); rig.expect_empty_network();
// Processing succeeds, now the rest of the chain should be sent for processing. // Processing succeeds, now the rest of the chain should be sent for processing.
bl.parent_block_processed(chain_hash, BlockError::BlockIsAlreadyKnown.into(), &mut cx); bl.parent_block_processed(
chain_hash,
BlockError::BlockIsAlreadyKnown(block_root).into(),
&mut cx,
);
rig.expect_parent_chain_process(); rig.expect_parent_chain_process();
let process_result = BatchProcessResult::Success { let process_result = BatchProcessResult::Success {
was_non_empty: true, was_non_empty: true,
@ -1117,7 +1121,11 @@ fn test_same_chain_race_condition() {
// the processing result // the processing result
if i + 2 == depth { if i + 2 == depth {
// one block was removed // one block was removed
bl.parent_block_processed(chain_hash, BlockError::BlockIsAlreadyKnown.into(), &mut cx) bl.parent_block_processed(
chain_hash,
BlockError::BlockIsAlreadyKnown(block.canonical_root()).into(),
&mut cx,
)
} else { } else {
bl.parent_block_processed( bl.parent_block_processed(
chain_hash, chain_hash,