mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 07:37:57 +00:00
* Companion for substrate #13889 * Remove leftover * Remove removed dependency * Remove sp-consensus-vrf from lock * Revert "Remove sp-consensus-vrf from lock" This reverts commit 2269ca1e32df89272e8fd4544292204db387f436. * Fix after substrate modifications * Fix tests to use new VRF Signature type * Don't rely of Deref trait * Fix test * Further code simplification * Reuse garbage_vrf_signature * update lockfile for {"substrate"} --------- Co-authored-by: parity-processbot <>
This commit is contained in:
@@ -16,8 +16,7 @@
|
||||
|
||||
//! Types relevant for approval.
|
||||
|
||||
pub use sp_consensus_babe::Slot;
|
||||
pub use sp_consensus_vrf::schnorrkel::{Randomness, VRFOutput, VRFProof};
|
||||
pub use sp_consensus_babe::{Randomness, Slot, VrfOutput, VrfProof, VrfSignature, VrfTranscript};
|
||||
|
||||
use parity_scale_codec::{Decode, Encode};
|
||||
use polkadot_primitives::{
|
||||
@@ -82,8 +81,8 @@ pub enum AssignmentCertKind {
|
||||
pub struct AssignmentCert {
|
||||
/// The criterion which is claimed to be met by this cert.
|
||||
pub kind: AssignmentCertKind,
|
||||
/// The VRF showing the criterion is met.
|
||||
pub vrf: (VRFOutput, VRFProof),
|
||||
/// The VRF signature showing the criterion is met.
|
||||
pub vrf: VrfSignature,
|
||||
}
|
||||
|
||||
/// An assignment criterion which refers to the candidate under which the assignment is
|
||||
@@ -144,7 +143,7 @@ pub enum ApprovalError {
|
||||
|
||||
/// An unsafe VRF output. Provide BABE Epoch info to create a `RelayVRFStory`.
|
||||
pub struct UnsafeVRFOutput {
|
||||
vrf_output: VRFOutput,
|
||||
vrf_output: VrfOutput,
|
||||
slot: Slot,
|
||||
authority_index: u32,
|
||||
}
|
||||
@@ -170,12 +169,12 @@ impl UnsafeVRFOutput {
|
||||
let pubkey = schnorrkel::PublicKey::from_bytes(author.as_slice())
|
||||
.map_err(ApprovalError::SchnorrkelSignature)?;
|
||||
|
||||
let transcript = babe_primitives::make_transcript(randomness, self.slot, epoch_index);
|
||||
let transcript = sp_consensus_babe::make_transcript(randomness, self.slot, epoch_index);
|
||||
|
||||
let inout = self
|
||||
.vrf_output
|
||||
.0
|
||||
.attach_input_hash(&pubkey, transcript)
|
||||
.attach_input_hash(&pubkey, transcript.0)
|
||||
.map_err(ApprovalError::SchnorrkelSignature)?;
|
||||
Ok(RelayVRFStory(inout.make_bytes(RELAY_VRF_STORY_CONTEXT)))
|
||||
}
|
||||
@@ -187,21 +186,18 @@ impl UnsafeVRFOutput {
|
||||
/// the digest has type `SecondaryPlain`, which Substrate nodes do
|
||||
/// not produce or accept anymore.
|
||||
pub fn babe_unsafe_vrf_info(header: &Header) -> Option<UnsafeVRFOutput> {
|
||||
use babe_primitives::digests::{CompatibleDigestItem, PreDigest};
|
||||
use babe_primitives::digests::CompatibleDigestItem;
|
||||
|
||||
for digest in &header.digest.logs {
|
||||
if let Some(pre) = digest.as_babe_pre_digest() {
|
||||
let slot = pre.slot();
|
||||
let authority_index = pre.authority_index();
|
||||
|
||||
// exhaustive match to defend against upstream variant changes.
|
||||
let vrf_output = match pre {
|
||||
PreDigest::Primary(primary) => primary.vrf_output,
|
||||
PreDigest::SecondaryVRF(secondary) => secondary.vrf_output,
|
||||
PreDigest::SecondaryPlain(_) => return None,
|
||||
};
|
||||
|
||||
return Some(UnsafeVRFOutput { vrf_output, slot, authority_index })
|
||||
return pre.vrf_signature().map(|sig| UnsafeVRFOutput {
|
||||
vrf_output: sig.output.clone(),
|
||||
slot,
|
||||
authority_index,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user