Skip to content
  • Adrian Catangiu's avatar
    Lean BEEFY to Full BEEFY - don't skip (older) mandatory blocks and import justifications (#11821) · 1c6867c6
    Adrian Catangiu authored
    
    
    * client/beefy: don't accept vote for older rounds
    
    * client/beefy: clean up and reorg the worker struct
    
    * client/beefy: first step towards Full BEEFY
    
    The first step from Lean->Full BEEFY is to have the worker
    enforce uninterrupted line of BEEFY finalized mandatory blocks.
    
    There is one mandatory block per session (the first block in the
    session). As such, votes processing and votes generation now
    enforces that all mandatory blocks are finalized in strict
    monotonically increasing sequence and no block 'N' will be worked
    on if there is any GRANDPA finalized but BEEFY non-final mandatory
    block 'M', where 'M < N'.
    
    Implementation details:
    
    - Introduced 'VoterOracle' to separate the voting decisions logic,
      and track new/pending sessions.
    
    - New sessions get queued up with the worker operating either:
      1. up-to-date - all mandatory blocks leading up to current GRANDPA
         finalized: queue has ONE element, the 'current session' where
         `mandatory_done == true`,
      2. lagging behind GRANDPA: queue has [1, N] elements, where all
         `mandatory_done == false`.
         In this state, everytime a session gets its mandatory block
         BEEFY finalized, the session is popped off the queue,
         eventually getting to operating mode `1. up-to-date`.
    
    - Votes get triaged and those that fall withing the `VoterOracle`
      allowed window get processed, the others get dropped if stale,
      or buffered for later processing (when they reach the window).
    
    - Worker general code was also updated to fall in one of two roles:
      1. react to external events and change internal 'state',
      2. generate events/votes based on internal 'state'.
    
    Signed-off-by: default avataracatangiu <[email protected]>
    
    * client/beefy: sketch idea for block import and sync
    
    Signed-off-by: default avataracatangiu <[email protected]>
    
    * client/beefy: add BEEFY block import
    
    * client/beefy: process justifications from block import
    
    * client/beefy: add TODOs for sync protocol
    
    * client/beefy: add more docs and comments
    
    * client/beefy-rpc: fix RPC error
    
    * client/beefy: verify justification validity on block import
    
    * client/beefy: more tests
    
    * client/beefy: small fixes
    
    - first handle and note the self vote before gossiping it,
    - don't shortcircuit on err when processing pending votes.
    
    * client/beefy: remove invalid justifications at block import
    
    * todo: beefy block import tests
    
    * RFC: ideas for multiple justifications per block
    
    * Revert "RFC: ideas for multiple justifications per block"
    
    This reverts commit 8256fb07d3124db69daf252720b3c0208202624d.
    
    * client/beefy: append justif to backend on block import
    
    * client/beefy: groundwork for block import test
    
    * client/beefy: groundwork2 for block import test
    
    * client/beefy: groundwork3 for block import test
    
    * client/beefy: add block import test
    
    * client/beefy: add required trait bounds to block import builder
    
    * remove client from beefy block import, backend gets the job done
    
    Signed-off-by: default avataracatangiu <[email protected]>
    1c6867c6