From 5ca430b64986179f6cb3ed2bbfc278e71a7e256f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Fri, 17 Feb 2023 08:55:14 +0100 Subject: [PATCH] Do not call longest chain by default (#6704) * Do not call longest chain by default We always called longest chain by default just for some potential logging. This was probably some oversight for when this select chain implementation was introduced. * Fix tests --- .../node/service/src/relay_chain_selection.rs | 15 +++------------ polkadot/node/service/src/tests.rs | 2 +- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/polkadot/node/service/src/relay_chain_selection.rs b/polkadot/node/service/src/relay_chain_selection.rs index 2ac5e0ca7f..41bd08e611 100644 --- a/polkadot/node/service/src/relay_chain_selection.rs +++ b/polkadot/node/service/src/relay_chain_selection.rs @@ -203,19 +203,12 @@ where target_hash: Hash, maybe_max_number: Option, ) -> Result { - let longest_chain_best = - self.longest_chain.finality_target(target_hash, maybe_max_number).await?; - if let IsDisputesAwareWithOverseer::Yes(ref selection) = self.selection { selection - .finality_target_with_longest_chain( - target_hash, - longest_chain_best, - maybe_max_number, - ) + .finality_target_with_longest_chain(target_hash, maybe_max_number) .await } else { - Ok(longest_chain_best) + self.longest_chain.finality_target(target_hash, maybe_max_number).await } } } @@ -364,11 +357,9 @@ where pub(crate) async fn finality_target_with_longest_chain( &self, target_hash: Hash, - best_leaf: Hash, maybe_max_number: Option, ) -> Result { let mut overseer = self.overseer.clone(); - gum::trace!(target: LOG_TARGET, ?best_leaf, "Longest chain"); let subchain_head = { let (tx, rx) = oneshot::channel(); @@ -414,7 +405,7 @@ where let subchain_header = self.block_header(subchain_head)?; if subchain_header.number <= max { - gum::trace!(target: LOG_TARGET, ?best_leaf, "Constrained sub-chain head",); + gum::trace!(target: LOG_TARGET, ?subchain_head, "Constrained sub-chain head",); subchain_head } else { let (ancestor_hash, _) = diff --git a/polkadot/node/service/src/tests.rs b/polkadot/node/service/src/tests.rs index 68412f96fa..1a2997fe67 100644 --- a/polkadot/node/service/src/tests.rs +++ b/polkadot/node/service/src/tests.rs @@ -88,7 +88,7 @@ fn test_harness>( let target_hash = case_vars.target_block.clone(); let selection_process = async move { let best = select_relay_chain - .finality_target_with_longest_chain(target_hash, target_hash, None) + .finality_target_with_longest_chain(target_hash, None) .await .unwrap(); finality_target_tx.send(Some(best)).unwrap();