Fix longest chain finalization target lookup (#13289)

* Finalization target should be chosed as some ancestor of SelectChain::best_chain

* More test assertions

* Improve docs

* Removed stale docs

* Rename 'target' to 'base' in lookup method

* Fix typo

* Apply suggestions from code review

Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>

* Rename 'target_hash' to 'base_hash' in 'SelectChain::finality_target()'

* Apply suggestions from code review

Co-authored-by: Anton <anton.kalyaev@gmail.com>

* Docs improvement

* Doc fix

* Apply suggestions from code review

Co-authored-by: Bastian Köcher <git@kchr.de>

* Apply more code suggestions

---------

Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>
Co-authored-by: Anton <anton.kalyaev@gmail.com>
Co-authored-by: Bastian Köcher <git@kchr.de>
This commit is contained in:
Davide Galassi
2023-02-11 18:35:04 +01:00
committed by GitHub
parent 9a8bbbab03
commit d48fc58729
5 changed files with 242 additions and 149 deletions
@@ -43,14 +43,14 @@ pub trait SelectChain<Block: BlockT>: Sync + Send + Clone {
/// finalize.
async fn best_chain(&self) -> Result<<Block as BlockT>::Header, Error>;
/// Get the best descendent of `target_hash` that we should attempt to
/// finalize next, if any. It is valid to return the given `target_hash`
/// Get the best descendent of `base_hash` that we should attempt to
/// finalize next, if any. It is valid to return the given `base_hash`
/// itself if no better descendent exists.
async fn finality_target(
&self,
target_hash: <Block as BlockT>::Hash,
base_hash: <Block as BlockT>::Hash,
_maybe_max_number: Option<NumberFor<Block>>,
) -> Result<<Block as BlockT>::Hash, Error> {
Ok(target_hash)
Ok(base_hash)
}
}