Simplify BABE pre-digest definitions (#5289)

* Init vrf crate without type alias

* Generic PreDigest definition for BABE

* Fix BABE vrf interface change

* Missing default-features def in sp-consensus-babe

* Fix sp-consensus-babe compile

* frame-babe: fix type inference

* Unify type definitions of vrf output/proof and randomness

* frame-babe: fix tests

* Bump node impl version

* Update cargo lock

* Derive Copy for RawVRFOutput and RawVRFProof

* Fix duplicated derive

Co-authored-by: Gavin Wood <gavin@parity.io>
This commit is contained in:
Wei Tang
2020-03-23 11:53:41 +01:00
committed by GitHub
parent 95d1d668c3
commit 9c7261fab3
17 changed files with 392 additions and 190 deletions
+6 -5
View File
@@ -19,6 +19,7 @@
use super::*;
use mock::{new_test_ext, Babe, System};
use sp_runtime::{traits::OnFinalize, testing::{Digest, DigestItem}};
use sp_consensus_vrf::schnorrkel::{RawVRFOutput, RawVRFProof};
use pallet_session::ShouldEndSession;
const EMPTY_RANDOMNESS: [u8; 32] = [
@@ -31,8 +32,8 @@ const EMPTY_RANDOMNESS: [u8; 32] = [
fn make_pre_digest(
authority_index: sp_consensus_babe::AuthorityIndex,
slot_number: sp_consensus_babe::SlotNumber,
vrf_output: [u8; sp_consensus_babe::VRF_OUTPUT_LENGTH],
vrf_proof: [u8; sp_consensus_babe::VRF_PROOF_LENGTH],
vrf_output: RawVRFOutput,
vrf_proof: RawVRFProof,
) -> Digest {
let digest_data = sp_consensus_babe::digests::RawPreDigest::Primary {
authority_index,
@@ -70,12 +71,12 @@ fn check_module() {
fn first_block_epoch_zero_start() {
new_test_ext(vec![0, 1, 2, 3]).execute_with(|| {
let genesis_slot = 100;
let first_vrf = [1; 32];
let first_vrf = RawVRFOutput([1; 32]);
let pre_digest = make_pre_digest(
0,
genesis_slot,
first_vrf,
[0xff; 64],
first_vrf.clone(),
RawVRFProof([0xff; 64]),
);
assert_eq!(Babe::genesis_slot(), 0);