Skip to content
Snippets Groups Projects
  1. May 15, 2024
    • shamil-gadelshin's avatar
      Change forks pruning algorithm. (#3962) · 9c69bb98
      shamil-gadelshin authored
      
      This PR changes the fork calculation and pruning algorithm to enable
      future block header pruning. It's required because the previous
      algorithm relied on the block header persistence. It follows the
      [related
      discussion](https://github.com/paritytech/polkadot-sdk/issues/1570)
      
      The previous code contained this comment describing the situation:
      ```
      	/// Note a block height finalized, displacing all leaves with number less than the finalized
      	/// block's.
      	///
      	/// Although it would be more technically correct to also prune out leaves at the
      	/// same number as the finalized block, but with different hashes, the current behavior
      	/// is simpler and our assumptions about how finalization works means that those leaves
      	/// will be pruned soon afterwards anyway.
      	pub fn finalize_height(&mut self, number: N) -> FinalizationOutcome<H, N> {
      ```
      
      The previous algorithm relied on the existing block headers to prune
      forks later and to enable block header pruning we need to clear all
      obsolete forks right after the block finalization to not depend on the
      related block headers in the future.
      
      ---------
      
      Co-authored-by: default avatarBastian Köcher <git@kchr.de>