-
Notifications
You must be signed in to change notification settings - Fork 38
Conversation
Resolves: #112 Re-syncing of a BEEFY node is done by calling validator_set() as part of finality notification processing. If a BEEFY node is out-of-sync, upon receiving a finality notification, it will either
|
beefy-gadget/src/worker.rs
Outdated
// NOTE: currently we act as if this block has been finalized by BEEFY as we perform | ||
// the validator set changes instantly (insecure). Once proper validator set changes | ||
// are implemented this should be removed | ||
self.best_finalized_block = Some(*notification.header.number()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a little bit confusing and I think we still miss a bit of logic. Let me elaborate.
We have two block variables that both affect should_vote_on
:
best_finalized_block
best_block_voted_on
I think we kept confusing the two and probably the implementation instructions were incorrect.
So the should_vote_on
formula should be roughly something like that:
(best_observed_block - best_beefy_finalized_block).next_power_of_two()
The logic for current variables:
best_finalized_block
=best_observed_block
, but with extraNone
value right after starting up (will be set toSome
on first notification).best_block_voted_on
= in case the node is voting, this will get updated with last vote.
I think we need to change the logic (and names) of best_block_voted_on
instead of best_finalized_block
. Basically:
best_finalized_block
should simply be updated every time we receive GRANDPA finality notification (IMHO we should even call itbest_grandpa_block
). It can be boostraped withself.client.info().best_finalized
.best_beefy_block
should beNone
initially and should only be updated in every case from this list:- We conclude a round (i.e there exists
SignedCommitment
). - We transition to a new validator set.
- We conclude a round (i.e there exists
The second case is obviously a temporary measure for Milestone 1
.
* use best_finalized, prevent race * make best_finalized_block an Option, should_vote_on bails on None * Bump futures from 0.3.13 to 0.3.14 * Revert futures bump * Revert "Revert futures bump" This reverts commit a1b5e7e. * Revert "Bump futures from 0.3.13 to 0.3.14" This reverts commit a4e508b. * debug msg if the bail voting * validator_set() * local_id() * get rid of worker state * Apply review suggestions * fix should_vote_on()
Changes we have identified for
Milestone 1
:init_validator_set()
should usebest_finalized
and notbest_hash
client.info()
should be stored to prevent racesbest_finalized_block
should be optionalshould_vote()
should bail ifbest_finalized_block
isNone
That should cover a non-optimized happy case.