Skip to content

Commit

Permalink
Fallback to AURA if unable to construct ring verifier
Browse files Browse the repository at this point in the history
  • Loading branch information
davxy committed May 13, 2024
1 parent 6d8080d commit 72b1a65
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions substrate/frame/sassafras/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
#![warn(unused_must_use, unsafe_code, unused_variables, unused_imports, missing_docs)]
#![cfg_attr(not(feature = "std"), no_std)]

use log::{debug, trace, warn};
use log::{debug, error, trace, warn};
use scale_codec::{Decode, Encode, MaxEncodedLen};
use scale_info::TypeInfo;

Expand Down Expand Up @@ -495,11 +495,15 @@ impl<T: Config> Pallet<T> {
let pks: Vec<_> = authorities.iter().map(|auth| *auth.as_ref()).collect();

debug!(target: LOG_TARGET, "Building ring verifier (ring size: {})", pks.len());
let verifier_key = ring_ctx
.verifier_key(&pks)
.expect("Failed to build ring verifier key. This is a bug");

RingVerifierKey::<T>::put(verifier_key);
let maybe_verifier_key = ring_ctx.verifier_key(&pks);
if maybe_verifier_key.is_none() {
error!(
target: LOG_TARGET,
"Failed to build verifier key. This should never happen,\n
falling back to AURA for next epoch as last resort"
);
}
RingVerifierKey::<T>::set(maybe_verifier_key);
}

/// Enact an epoch change.
Expand Down

0 comments on commit 72b1a65

Please sign in to comment.