diff --git a/polkadot/node/core/approval-voting/src/import.rs b/polkadot/node/core/approval-voting/src/import.rs index 68dd5e59043251eca381fbb1df9fc6362ca7dcdb..eef3d306f409bf30942a3e840a7e6f93ba6e4155 100644 --- a/polkadot/node/core/approval-voting/src/import.rs +++ b/polkadot/node/core/approval-voting/src/import.rs @@ -636,13 +636,26 @@ pub(crate) async fn handle_new_head( match imported_block_info(ctx, env, block_hash, &block_header).await? { Some(i) => imported_blocks_and_info.push((block_hash, block_header, i)), None => { - // Such errors are likely spurious, but this prevents us from getting gaps - // in the approval-db. - tracing::warn!( - target: LOG_TARGET, - "Unable to gather info about imported block {:?}. Skipping chain.", - (block_hash, block_header.number), - ); + // It's possible that we've lost a race with finality. + let (tx, rx) = oneshot::channel(); + ctx.send_message( + ChainApiMessage::FinalizedBlockHash(block_header.number.clone(), tx).into() + ).await; + + let lost_to_finality = match rx.await { + Ok(Ok(Some(h))) if h != block_hash => true, + _ => false, + }; + + if !lost_to_finality { + // Such errors are likely spurious, but this prevents us from getting gaps + // in the approval-db. + tracing::warn!( + target: LOG_TARGET, + "Unable to gather info about imported block {:?}. Skipping chain.", + (block_hash, block_header.number), + ); + } return Ok(Vec::new()); },