Dispatch on-disabled digests from consensus modules (#3055)

* on-disable primitives for engines

* dispatch on-disabled digests from SRML consensus

* bump runtime versions

* use find_map
This commit is contained in:
Robert Habermeier
2019-07-08 16:22:15 +02:00
committed by Gavin Wood
parent 3d72844710
commit 13b9e49688
11 changed files with 140 additions and 72 deletions
@@ -40,6 +40,29 @@ pub const VRF_PROOF_LENGTH: usize = 64;
/// The length of the public key
pub const PUBLIC_KEY_LENGTH: usize = 32;
/// The index of an authority.
pub type AuthorityIndex = u64;
/// A slot number.
pub type SlotNumber = u64;
/// The weight of an authority.
pub type Weight = u64;
/// An consensus log item for BABE.
#[derive(Decode, Encode)]
pub enum ConsensusLog {
/// The epoch has changed. This provides information about the
/// epoch _after_ next: what slot number it will start at, who are the authorities (and their weights)
/// and the next epoch randomness. The information for the _next_ epoch should already
/// be available.
#[codec(index = "1")]
NextEpochData(SlotNumber, Vec<(AuthorityId, Weight)>, [u8; VRF_OUTPUT_LENGTH]),
/// Disable the authority with given index.
#[codec(index = "2")]
OnDisabled(AuthorityIndex),
}
/// Configuration data used by the BABE consensus engine.
#[derive(Copy, Clone, Hash, PartialEq, Eq, Debug, Encode, Decode)]
pub struct BabeConfiguration {
+3 -3
View File
@@ -17,7 +17,7 @@
//! Private implementation details of BABE digests.
use primitives::sr25519::Signature;
use babe_primitives::{self, BABE_ENGINE_ID};
use babe_primitives::{self, BABE_ENGINE_ID, SlotNumber};
use runtime_primitives::{DigestItem, generic::OpaqueDigestItemId};
use std::fmt::Debug;
use parity_codec::{Decode, Encode, Codec, Input};
@@ -33,8 +33,8 @@ use schnorrkel::{vrf::{VRFProof, VRFOutput, VRF_OUTPUT_LENGTH, VRF_PROOF_LENGTH}
pub struct BabePreDigest {
pub(super) vrf_output: VRFOutput,
pub(super) proof: VRFProof,
pub(super) index: u64,
pub(super) slot_num: u64,
pub(super) index: babe_primitives::AuthorityIndex,
pub(super) slot_num: SlotNumber,
}
/// The prefix used by BABE for its VRF keys.