grandpa: update to finality-grandpa v0.12.0 (#5853)

* grandpa: update to v0.12.0

* grandpa: fix tests

* grandpa: better validation of authority set invariants

* grandpa: avoid duplicating invalid authority list check

* grandpa: add missing doc

* grandpa: better validation of expect proofs

* grandpa: fix test compilation

* grandpa: fix tests

* grandpa: add test for AuthoritySet invariants

* grandpa: bump finality-grandpa to v0.12.0
This commit is contained in:
André Silva
2020-04-30 21:03:30 +01:00
committed by GitHub
parent 43e8268ae1
commit d2967ba4b6
13 changed files with 238 additions and 90 deletions
@@ -29,7 +29,7 @@ use std::{borrow::Cow, pin::Pin, task::{Context, Poll}};
use crate::environment::SharedVoterSetState;
use sp_finality_grandpa::{AuthorityList, GRANDPA_ENGINE_ID};
use super::gossip::{self, GossipValidator};
use super::{AuthorityId, VoterSet, Round, SetId};
use super::{VoterSet, Round, SetId};
#[derive(Debug)]
pub(crate) enum Event {
@@ -142,11 +142,15 @@ fn voter_set_state() -> SharedVoterSetState<Block> {
use crate::authorities::AuthoritySet;
use crate::environment::VoterSetState;
use finality_grandpa::round::State as RoundState;
use sp_core::H256;
use sp_core::{crypto::Public, H256};
use sp_finality_grandpa::AuthorityId;
let state = RoundState::genesis((H256::zero(), 0));
let base = state.prevote_ghost.unwrap();
let voters = AuthoritySet::genesis(Vec::new());
let voters = vec![(AuthorityId::from_slice(&[1; 32]), 1)];
let voters = AuthoritySet::genesis(voters).unwrap();
let set_state = VoterSetState::live(
0,
&voters,
@@ -212,7 +216,7 @@ impl sc_network_gossip::ValidatorContext<Block> for NoopContext {
fn good_commit_leads_to_relay() {
let private = [Ed25519Keyring::Alice, Ed25519Keyring::Bob, Ed25519Keyring::Charlie];
let public = make_ids(&private[..]);
let voter_set = Arc::new(public.iter().cloned().collect::<VoterSet<AuthorityId>>());
let voter_set = Arc::new(VoterSet::new(public.iter().cloned()).unwrap());
let round = 1;
let set_id = 1;
@@ -360,7 +364,7 @@ fn bad_commit_leads_to_report() {
let _ = env_logger::try_init();
let private = [Ed25519Keyring::Alice, Ed25519Keyring::Bob, Ed25519Keyring::Charlie];
let public = make_ids(&private[..]);
let voter_set = Arc::new(public.iter().cloned().collect::<VoterSet<AuthorityId>>());
let voter_set = Arc::new(VoterSet::new(public.iter().cloned()).unwrap());
let round = 1;
let set_id = 1;