babe: make secondary slot randomness available on-chain (#7053)

* babe: make secondary slot randomness available on-chain

* babe: extract out vrf_output function

* babe: add missing comment

* babe: fix incorrectly storing primary randomness

* babe: add test for onchain author vrf

* babe: fix reviewer nits

* runtime: bump spec_version

* babe: remove outer Option for AuthorVrfRandomness

* babe: fix reviewer nits on doc strings

* babe: move make_vrf_output to mock.rs

* babe: cleanup docs

* babe: kill ephemeral entry instead of take

* babe: use type alias for maybe randomness

Co-authored-by: André Silva <andrerfosilva@gmail.com>
This commit is contained in:
Jon Häggblad
2020-10-15 10:32:12 +02:00
committed by GitHub
parent 1164ced041
commit a297e447f2
5 changed files with 173 additions and 47 deletions
@@ -110,6 +110,15 @@ impl PreDigest {
PreDigest::SecondaryPlain(_) | PreDigest::SecondaryVRF(_) => 0,
}
}
/// Returns the VRF output, if it exists.
pub fn vrf_output(&self) -> Option<&VRFOutput> {
match self {
PreDigest::Primary(primary) => Some(&primary.vrf_output),
PreDigest::SecondaryVRF(secondary) => Some(&secondary.vrf_output),
PreDigest::SecondaryPlain(_) => None,
}
}
}
/// Information about the next epoch. This is broadcast in the first block