mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 12:11:09 +00:00
VRF refactory (#13889)
* First iteration to encapsulate schnorrkel and merlin usage * Remove schnorkel direct dependency from BABE pallet * Remove schnorrkel direct dependency from BABE client * Trivial renaming for VrfTranscript data and value * Better errors * Expose a function to get a schnorrkel friendly transcript * Keep the vrf signature stuff together (preventing some clones around) * Fix tests * Remove vrf agnostic transcript and define it as an associated type for VrfSigner and VrfVerifier * Fix babe pallet mock * Inner types are required to be public for polkadot * Update client/consensus/babe/src/verification.rs Co-authored-by: Koute <koute@users.noreply.github.com> * Nit * Remove Deref implementations * make_bytes as a method * Trigger CI --------- Co-authored-by: Koute <koute@users.noreply.github.com>
This commit is contained in:
@@ -19,14 +19,15 @@
|
||||
|
||||
use super::{
|
||||
AllowedSlots, AuthorityId, AuthorityIndex, AuthoritySignature, BabeAuthorityWeight,
|
||||
BabeEpochConfiguration, Slot, BABE_ENGINE_ID,
|
||||
BabeEpochConfiguration, Randomness, Slot, BABE_ENGINE_ID,
|
||||
};
|
||||
use codec::{Decode, Encode, MaxEncodedLen};
|
||||
use scale_info::TypeInfo;
|
||||
|
||||
use sp_core::sr25519::vrf::VrfSignature;
|
||||
use sp_runtime::{DigestItem, RuntimeDebug};
|
||||
use sp_std::vec::Vec;
|
||||
|
||||
use sp_consensus_vrf::schnorrkel::{Randomness, VRFOutput, VRFProof};
|
||||
use codec::{Decode, Encode, MaxEncodedLen};
|
||||
use scale_info::TypeInfo;
|
||||
|
||||
/// Raw BABE primary slot assignment pre-digest.
|
||||
#[derive(Clone, RuntimeDebug, Encode, Decode, MaxEncodedLen, TypeInfo)]
|
||||
@@ -35,10 +36,8 @@ pub struct PrimaryPreDigest {
|
||||
pub authority_index: super::AuthorityIndex,
|
||||
/// Slot
|
||||
pub slot: Slot,
|
||||
/// VRF output
|
||||
pub vrf_output: VRFOutput,
|
||||
/// VRF proof
|
||||
pub vrf_proof: VRFProof,
|
||||
/// VRF signature
|
||||
pub vrf_signature: VrfSignature,
|
||||
}
|
||||
|
||||
/// BABE secondary slot assignment pre-digest.
|
||||
@@ -62,10 +61,8 @@ pub struct SecondaryVRFPreDigest {
|
||||
pub authority_index: super::AuthorityIndex,
|
||||
/// Slot
|
||||
pub slot: Slot,
|
||||
/// VRF output
|
||||
pub vrf_output: VRFOutput,
|
||||
/// VRF proof
|
||||
pub vrf_proof: VRFProof,
|
||||
/// VRF signature
|
||||
pub vrf_signature: VrfSignature,
|
||||
}
|
||||
|
||||
/// A BABE pre-runtime digest. This contains all data required to validate a
|
||||
@@ -118,11 +115,10 @@ impl PreDigest {
|
||||
}
|
||||
|
||||
/// Returns the VRF output and proof, if they exist.
|
||||
pub fn vrf(&self) -> Option<(&VRFOutput, &VRFProof)> {
|
||||
pub fn vrf_signature(&self) -> Option<&VrfSignature> {
|
||||
match self {
|
||||
PreDigest::Primary(primary) => Some((&primary.vrf_output, &primary.vrf_proof)),
|
||||
PreDigest::SecondaryVRF(secondary) =>
|
||||
Some((&secondary.vrf_output, &secondary.vrf_proof)),
|
||||
PreDigest::Primary(primary) => Some(&primary.vrf_signature),
|
||||
PreDigest::SecondaryVRF(secondary) => Some(&secondary.vrf_signature),
|
||||
PreDigest::SecondaryPlain(_) => None,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user