Skip to content
  • Alexandru Vasile's avatar
    chainHead: Ensure reasonable distance between leaf and finalized block (#3562) · 287b116c
    Alexandru Vasile authored
    
    
    This PR ensure that the distance between any leaf and the finalized
    block is within a reasonable distance.
    
    For a new subscription, the chainHead has to provide all blocks between
    the leaves of the chain and the finalized block.
     When the distance between a leaf and the finalized block is large:
     - The tree route is costly to compute
     - We could deliver an unbounded number of blocks (potentially millions)
    (For more details see
    https://github.com/paritytech/polkadot-sdk/pull/3445#discussion_r1507210283)
    
    The configuration of the ChainHead is extended with:
    - suspend on lagging distance: When the distance between any leaf and
    the finalized block is greater than this number, the subscriptions are
    suspended for a given duration.
    - All active subscriptions are terminated with the `Stop` event, all
    blocks are unpinned and data discarded.
    - For incoming subscriptions, until the suspended period expires the
    subscriptions will immediately receive the `Stop` event.
        - Defaults to 128 blocks
    - suspended duration: The amount of time for which subscriptions are
    suspended
        - Defaults to 30 seconds
     
     
     cc @paritytech/subxt-team
    
    ---------
    
    Signed-off-by: default avatarAlexandru Vasile <[email protected]>
    Co-authored-by: default avatarSebastian Kunert <[email protected]>
    287b116c