Skip to content
This repository was archived by the owner on Nov 11, 2022. It is now read-only.

Milestone 1 #144

Merged
merged 13 commits into from
Apr 14, 2021
Merged

Milestone 1 #144

merged 13 commits into from
Apr 14, 2021

Conversation

adoerr
Copy link
Contributor

@adoerr adoerr commented Apr 9, 2021

Changes we have identified for Milestone 1:

  • init_validator_set() should use best_finalized and not best_hash
  • client.info() should be stored to prevent races
  • best_finalized_block should be optional
  • should_vote() should bail if best_finalized_block is None
  • get rid of worker state
  • handle transition from 'no-pallet' to 'pallet' and vice versa

That should cover a non-optimized happy case.

@adoerr adoerr marked this pull request as draft April 9, 2021 14:29
@adoerr adoerr marked this pull request as ready for review April 12, 2021 19:12
@adoerr adoerr requested a review from tomusdrw April 12, 2021 19:12
@adoerr
Copy link
Contributor Author

adoerr commented Apr 13, 2021

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

  • use the validator set enacted through an AuthoritiesChange digest
  • fetch the validator set from BEEFY on-chain state

Comment on lines 332 to 335
// 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());
Copy link
Contributor

@tomusdrw tomusdrw Apr 13, 2021

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:

  1. best_finalized_block
  2. 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:

  1. best_finalized_block = best_observed_block, but with extra None value right after starting up (will be set to Some on first notification).
  2. 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:

  1. best_finalized_block should simply be updated every time we receive GRANDPA finality notification (IMHO we should even call it best_grandpa_block). It can be boostraped with self.client.info().best_finalized.
  2. best_beefy_block should be None initially and should only be updated in every case from this list:
    1. We conclude a round (i.e there exists SignedCommitment).
    2. We transition to a new validator set.

The second case is obviously a temporary measure for Milestone 1.

@adoerr adoerr merged commit 8638d0e into master Apr 14, 2021
@adoerr adoerr deleted the ad-milestone-1 branch April 14, 2021 04:30
tomusdrw pushed a commit that referenced this pull request Apr 23, 2021
* 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()
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants