Skip to content
  • Adrian Catangiu's avatar
    client/beefy: persist voter state (#12712) · 3e7a2778
    Adrian Catangiu authored
    
    
    * client/beefy: prepare worker for persisting state
    
    * client/beefy: persist voter state
    
    * client/beefy: initialize persistent state
    
    * client/beefy: try to vote from the very beginning
    
    Now that voter is initialized from persistent state, it makes
    sense that it can attempt voting right away. This also helps
    the genesis case when we consider block `One` as mandatory.
    
    * client/beefy: add tests for voter state db
    * client/beefy: persist voter state as soon as initialized
    * client/beefy: make sure min-block-delta is at least 1
    * client/beefy: persist state after voting
    
    Persist state after handling self vote to avoid double voting in case
    of voter restarts.
    
    * client/beefy: persist state after handling mandatory block vote
    
    For mandatory blocks we want to make sure we're not losing votes
    in case of crashes or restarts, since voter will not make further
    progress without finalizing them.
    
    * frame/beefy: use GENESIS_AUTHORITY_SET_ID on pallet genesis
    
    * client/beefy: initialize voter at either genesis or last finalized
    To guarantee unbroken chain of mandatory blocks justifications, voter
    will always resume from either last BEEFY-justified block or
    `pallet-beefy` genesis, whichever is more recent.
    
    Initialization walks back the chain from latest GRANDPA finalized
    block looking for one of the above. Along the way, it also records
    and enqueues for processing any BEEFY mandatory blocks that have
    been already GRANDPA finalized but not BEEFY finalized.
    
    * client/beefy: decouple voter init from aux db state load
    * client/beefy: fix voter init tests
    * remove debug prints
    * gadget future must be type ()
    * fix init from last justification
    
    Signed-off-by: default avatarAdrian Catangiu <[email protected]>
    3e7a2778