1. Jan 13, 2023
  2. Nov 21, 2022
    • 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
  3. Nov 09, 2022
    • Robert Hambrock's avatar
      Consolidate and deduplicate MMR API methods (#12530) · 53f97350
      Robert Hambrock authored
      
      
      * histor. batch proof: make best block arg optional
      
      * correct testing range
      
      * make generate_batch_proof stub for historical
      
      * merge generate_{historical_}batch_proof functions
      
      * merge generate_{batch_}proof functions
      
      * merge verify_{batch_}proof functions
      
      * merge verify_{batch_}proof_stateless functions
      
      * remove {Leaf}Proof
      
      Not utilized by API anymore, so superfluous.
      Removal consistent with prior changes to just use "batch" proof API.
      
      * rename BatchProof->Proof
      
      no need to qualify if only one universal proof type.
      
      * cleanup
      
      * expose verify_proof rpc api
      
      * document verify_proof
      
      * expose verify_proof_stateless rpc api
      
      * add optional BlockHash to mmr_root rpc api
      
      * fixup! expose verify_proof rpc api
      
      * fix documentation phrasing
      
      Co-authored-by: default avatarAdrian Catangiu <[email protected]>
      
      * documentation grammar
      
      Co-authored-by: default avatarAdrian Catangiu <[email protected]>
      
      * define mmr error msgs together with error enum
      
      Co-authored-by: default avatarSerban Iorga <[email protected]>
      
      * fixup! define mmr error msgs together with error enum
      
      * map decoding errors to CallError::InvalidParams
      
      Co-authored-by: default avatarSerban Iorga <[email protected]>
      
      * fixup! map decoding errors to CallError::InvalidParams
      
      Co-authored-by: default avatarAdrian Catangiu <[email protected]>
      Co-authored-by: parity-processbot <>
      Co-authored-by: default avatarSerban Iorga <[email protected]>
      53f97350
  4. Oct 18, 2022
  5. Oct 13, 2022
  6. Oct 07, 2022
  7. Oct 06, 2022
    • Adrian Catangiu's avatar
      Add pluggable BEEFY payload constructors (#12428) · b91d2dfd
      Adrian Catangiu authored
      * primitives/beefy: move Payload to its own file
      
      * primitives/beefy: add Payload tests
      
      * primitives/beefy: add MmrRootProvider as custom BEEFY payload provider
      
      * client/beefy: use generic BEEFY 'PayloadProvider'
      
      * primitives/beefy: rename Payload::new to Payload::from_single_entry for clarity
      
      * fix visibility
      
      * fix cargo doc
      b91d2dfd
  8. Oct 05, 2022
  9. Sep 29, 2022
  10. Sep 21, 2022
  11. Jul 29, 2022
    • 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
  12. Jun 22, 2022
    • Adrian Catangiu's avatar
      pallet-beefy-mmr: add API for BEEFY Authority Sets (#11406) · 3018051c
      Adrian Catangiu authored
      
      
      * pallet-beefy: add Config::OnNewValidatorSet type
      
      Add a hook to pallet-beefy for doing specific work when
      BEEFY validator set changes.
      
      For example, this can be used by pallet-beefy-mmr to cache
      a lightweight MMR root over validators and make it available
      to light clients.
      
      * pallet-beefy-mmr: implement OnNewValidatorSet
      
      Implement pallet-beefy::OnNewValidatorSet to be notified of BEEFY
      validator set changes. Use the notifications to compute and cache
      a light weight 'BEEFY authority set' which is an MMR root over
      BEEFY validator set plus some extra info.
      
      Previously, pallet-beefy-mmr was interogating pallet-beefy about
      validator set id on every block to find out when it needs to recompute
      the authority set.
      By using the event-driven approach in this commit, we also save one
      extra state interogation per block.
      
      * pallet-beefy-mmr: add new authority_set() API
      
      Expose current and next BEEFY authority sets through runtime API.
      These can be directly used by light clients to avoid having them
      compute them themselves based on BEEFY validator sets.
      
      Signed-off-by: default avataracatangiu <[email protected]>
      
      * rename BeefyMmr exposed runtime api
      3018051c
  13. Apr 01, 2022
  14. Feb 08, 2022
  15. Jan 03, 2022
  16. Dec 21, 2021
  17. Dec 20, 2021
  18. Dec 15, 2021
  19. Dec 03, 2021
  20. Dec 01, 2021
  21. Nov 22, 2021
  22. Sep 23, 2021