mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-29 13:48:00 +00:00
Correct BABE randomness by calculating InOut bytes directly in pallet (#5876)
* vrf: remove Raw* types * babe: remove Raw* types * pallet-babe: switch representation of RawVRFOutput to Randomness * pallet-babe: calculate inout within the pallet * Remove make_transcript duplication * Bump spec version * Fix frame tests * and_then -> map * Always enable u64_backend * Fix nostd compile * fix import: should not use std * Remove unused definition of RawVRFOutput * Remove unused import of RuntimeDebug Co-authored-by: Gavin Wood <gavin@parity.io>
This commit is contained in:
@@ -25,6 +25,7 @@ pub mod inherents;
|
||||
pub use sp_consensus_vrf::schnorrkel::{
|
||||
Randomness, VRF_PROOF_LENGTH, VRF_OUTPUT_LENGTH, RANDOMNESS_LENGTH
|
||||
};
|
||||
pub use merlin::Transcript;
|
||||
|
||||
use codec::{Encode, Decode};
|
||||
use sp_std::vec::Vec;
|
||||
@@ -39,6 +40,9 @@ mod app {
|
||||
/// The prefix used by BABE for its VRF keys.
|
||||
pub const BABE_VRF_PREFIX: &[u8] = b"substrate-babe-vrf";
|
||||
|
||||
/// BABE VRFInOut context.
|
||||
pub static BABE_VRF_INOUT_CONTEXT: &[u8] = b"BabeVRFInOutContext";
|
||||
|
||||
/// A Babe authority keypair. Necessarily equivalent to the schnorrkel public key used in
|
||||
/// the main Babe module. If that ever changes, then this must, too.
|
||||
#[cfg(feature = "std")]
|
||||
@@ -76,6 +80,19 @@ pub type BabeAuthorityWeight = u64;
|
||||
/// The weight of a BABE block.
|
||||
pub type BabeBlockWeight = u32;
|
||||
|
||||
/// Make a VRF transcript from given randomness, slot number and epoch.
|
||||
pub fn make_transcript(
|
||||
randomness: &Randomness,
|
||||
slot_number: u64,
|
||||
epoch: u64,
|
||||
) -> Transcript {
|
||||
let mut transcript = Transcript::new(&BABE_ENGINE_ID);
|
||||
transcript.append_u64(b"slot number", slot_number);
|
||||
transcript.append_u64(b"current epoch", epoch);
|
||||
transcript.append_message(b"chain randomness", &randomness[..]);
|
||||
transcript
|
||||
}
|
||||
|
||||
/// An consensus log item for BABE.
|
||||
#[derive(Decode, Encode, Clone, PartialEq, Eq)]
|
||||
pub enum ConsensusLog {
|
||||
|
||||
Reference in New Issue
Block a user