diff --git a/substrate/core/consensus/babe/primitives/src/lib.rs b/substrate/core/consensus/babe/primitives/src/lib.rs index 9d69fb14bb..d169406b33 100644 --- a/substrate/core/consensus/babe/primitives/src/lib.rs +++ b/substrate/core/consensus/babe/primitives/src/lib.rs @@ -53,7 +53,7 @@ pub const VRF_PROOF_LENGTH: usize = 64; pub const PUBLIC_KEY_LENGTH: usize = 32; /// The index of an authority. -pub type AuthorityIndex = u64; +pub type AuthorityIndex = u32; /// A slot number. pub type SlotNumber = u64; diff --git a/substrate/core/consensus/babe/src/lib.rs b/substrate/core/consensus/babe/src/lib.rs index fae6fb3c32..50271b0d45 100644 --- a/substrate/core/consensus/babe/src/lib.rs +++ b/substrate/core/consensus/babe/src/lib.rs @@ -321,7 +321,7 @@ impl SlotWorker for BabeWorker w let inherent_digest = BabePreDigest { vrf_proof, vrf_output: inout.to_output(), - authority_index: authority_index as u64, + authority_index: authority_index as u32, slot_number, }; @@ -491,7 +491,7 @@ fn check_header( if slot_number > slot_now { header.digest_mut().push(seal); Ok(CheckedHeader::Deferred(header, slot_number)) - } else if authority_index > authorities.len() as u64 { + } else if authority_index > authorities.len() as u32 { Err(babe_err!("Slot author not found")) } else { let (pre_hash, author) = (header.hash(), &authorities[authority_index as usize].0); @@ -1219,7 +1219,7 @@ pub mod test_helpers { BabePreDigest { vrf_proof, vrf_output: inout.to_output(), - authority_index: authority_index as u64, + authority_index: authority_index as u32, slot_number, } }) diff --git a/substrate/node/runtime/src/lib.rs b/substrate/node/runtime/src/lib.rs index c6b74293b8..5b83ccf679 100644 --- a/substrate/node/runtime/src/lib.rs +++ b/substrate/node/runtime/src/lib.rs @@ -180,9 +180,8 @@ parameter_types! { pub const UncleGenerations: u64 = 0; } -// TODO: #2986 implement this properly impl authorship::Trait for Runtime { - type FindAuthor = (); + type FindAuthor = session::FindAccountFromAuthorIndex; type UncleGenerations = UncleGenerations; type FilterUncle = (); type EventHandler = Staking; diff --git a/substrate/srml/babe/src/lib.rs b/substrate/srml/babe/src/lib.rs index 91ad5f3a85..a47fb04c2f 100644 --- a/substrate/srml/babe/src/lib.rs +++ b/substrate/srml/babe/src/lib.rs @@ -202,8 +202,8 @@ impl RandomnessBeacon for Module { /// A BABE public key pub type BabeKey = [u8; PUBLIC_KEY_LENGTH]; -impl FindAuthor for Module { - fn find_author<'a, I>(digests: I) -> Option where +impl FindAuthor for Module { + fn find_author<'a, I>(digests: I) -> Option where I: 'a + IntoIterator { for (id, mut data) in digests.into_iter() { @@ -341,7 +341,7 @@ impl session::OneSessionHandler for Mod } fn on_disabled(i: usize) { - Self::deposit_consensus(ConsensusLog::OnDisabled(i as u64)) + Self::deposit_consensus(ConsensusLog::OnDisabled(i as u32)) } }