mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-15 18:31:05 +00:00
sp-core: Rename VrfOutput to VrfPreOutput (#2534)
This will make more sense after https://github.com/paritytech/polkadot-sdk/pull/2524 since the schnorrkel type for VRF outputs is also renamed in the latest version. Can be reviewed independently though. Can be merged after https://github.com/paritytech/polkadot-sdk/pull/1577 so that there is less pain for @davxy. --------- Co-authored-by: Bastian Köcher <git@kchr.de>
This commit is contained in:
@@ -272,11 +272,11 @@ pub mod pallet {
|
||||
#[pallet::storage]
|
||||
pub type RingVerifierData<T: Config> = StorageValue<_, vrf::RingVerifierData>;
|
||||
|
||||
/// Slot claim vrf-preoutput used to generate per-slot randomness.
|
||||
/// Slot claim VRF pre-output used to generate per-slot randomness.
|
||||
///
|
||||
/// The value is ephemeral and is cleared on block finalization.
|
||||
#[pallet::storage]
|
||||
pub(crate) type ClaimTemporaryData<T> = StorageValue<_, vrf::VrfOutput>;
|
||||
pub(crate) type ClaimTemporaryData<T> = StorageValue<_, vrf::VrfPreOutput>;
|
||||
|
||||
/// Genesis configuration for Sassafras protocol.
|
||||
#[pallet::genesis_config]
|
||||
@@ -324,12 +324,12 @@ pub mod pallet {
|
||||
Self::post_genesis_initialize(claim.slot);
|
||||
}
|
||||
|
||||
let randomness_output = claim
|
||||
let randomness_pre_output = claim
|
||||
.vrf_signature
|
||||
.outputs
|
||||
.pre_outputs
|
||||
.get(0)
|
||||
.expect("Valid claim must have vrf signature; qed");
|
||||
ClaimTemporaryData::<T>::put(randomness_output);
|
||||
.expect("Valid claim must have VRF signature; qed");
|
||||
ClaimTemporaryData::<T>::put(randomness_pre_output);
|
||||
|
||||
let trigger_weight = T::EpochChangeTrigger::trigger::<T>(block_num);
|
||||
|
||||
@@ -346,9 +346,9 @@ pub mod pallet {
|
||||
CurrentSlot::<T>::get(),
|
||||
EpochIndex::<T>::get(),
|
||||
);
|
||||
let randomness_output = ClaimTemporaryData::<T>::take()
|
||||
let randomness_pre_output = ClaimTemporaryData::<T>::take()
|
||||
.expect("Unconditionally populated in `on_initialize`; `on_finalize` is always called after; qed");
|
||||
let randomness = randomness_output
|
||||
let randomness = randomness_pre_output
|
||||
.make_bytes::<RANDOMNESS_LENGTH>(RANDOMNESS_VRF_CONTEXT, &randomness_input);
|
||||
Self::deposit_slot_randomness(&randomness);
|
||||
|
||||
@@ -422,15 +422,15 @@ pub mod pallet {
|
||||
for ticket in tickets {
|
||||
debug!(target: LOG_TARGET, "Checking ring proof");
|
||||
|
||||
let Some(ticket_id_output) = ticket.signature.outputs.get(0) else {
|
||||
debug!(target: LOG_TARGET, "Missing ticket vrf output from ring signature");
|
||||
let Some(ticket_id_pre_output) = ticket.signature.pre_outputs.get(0) else {
|
||||
debug!(target: LOG_TARGET, "Missing ticket VRF pre-output from ring signature");
|
||||
continue
|
||||
};
|
||||
let ticket_id_input =
|
||||
vrf::ticket_id_input(&randomness, ticket.body.attempt_idx, epoch_idx);
|
||||
|
||||
// Check threshold constraint
|
||||
let ticket_id = vrf::make_ticket_id(&ticket_id_input, &ticket_id_output);
|
||||
let ticket_id = vrf::make_ticket_id(&ticket_id_input, &ticket_id_pre_output);
|
||||
if ticket_id >= ticket_threshold {
|
||||
debug!(target: LOG_TARGET, "Ignoring ticket over threshold ({:032x} >= {:032x})", ticket_id, ticket_threshold);
|
||||
continue
|
||||
|
||||
@@ -190,9 +190,9 @@ pub fn make_ticket_body(attempt_idx: u32, pair: &AuthorityPair) -> (TicketId, Ti
|
||||
let randomness = Sassafras::next_randomness();
|
||||
|
||||
let ticket_id_input = vrf::ticket_id_input(&randomness, attempt_idx, epoch);
|
||||
let ticket_id_output = pair.as_inner_ref().vrf_output(&ticket_id_input);
|
||||
let ticket_id_pre_output = pair.as_inner_ref().vrf_pre_output(&ticket_id_input);
|
||||
|
||||
let id = vrf::make_ticket_id(&ticket_id_input, &ticket_id_output);
|
||||
let id = vrf::make_ticket_id(&ticket_id_input, &ticket_id_pre_output);
|
||||
|
||||
// Make a dummy ephemeral public that hopefully is unique within one test instance.
|
||||
// In the tests, the values within the erased public are just used to compare
|
||||
|
||||
Reference in New Issue
Block a user