beefy: initialize voter from genesis and fix initial sync (#11959)
* client/beefy: use backend instead of client where possible
* client/beefy: initialize voter from genesis
Now that we have justifications import, we can drop the "lean beefy"
behaviour and start building justifications chain from Genesis with
containing all past sessions' mandatory blocks justifications.
* client/beefy: walk finality tree_route to catch session changes
* client/beefy: fix block import
During initial block import blocks are not finalized, so trying to
validate and append justifications within block import fails (for
initial network sync imported blocks).
Changes:
- Move justification validation to _after_ `inner.block_import()`,
so block is imported in backend and runtime api can be called to
get the BEEFY authorities for said block.
- Move append-to-backend for imported BEEFY justification to voter,
because it already has the required logic to BEEFY-finalize blocks
only after GRANDPA finalized them.
- Mark voting rounds as concluded when finalizing through
imported justifications as well as when finalizing through voting.
* client/beefy: valid justifications are one per block number
The only way we'd get _different_ _validated_ justifications for same
block number is if authorities are double voting, which will be handled
later.
* client/beefy: process incoming justifs during major sync
* client/beefy: correct voter initialization
BEEFY voter should resume voting from either:
- last BEEFY finalized block,
- session start,
whichever is closest to head.
* client/beefy: test voter initialization
* client/beefy: impl review suggestions
Signed-off-by:
acatangiu <adrian@parity.io>
Showing
- substrate/client/beefy/src/import.rs 20 additions, 55 deletionssubstrate/client/beefy/src/import.rs
- substrate/client/beefy/src/round.rs 18 additions, 10 deletionssubstrate/client/beefy/src/round.rs
- substrate/client/beefy/src/tests.rs 5 additions, 7 deletionssubstrate/client/beefy/src/tests.rs
- substrate/client/beefy/src/worker.rs 299 additions, 75 deletionssubstrate/client/beefy/src/worker.rs
Please register or sign in to comment