@@ -43,7 +43,8 @@ use sp_timestamp::OnTimestampSet;
4343use sp_consensus_babe:: {
4444 digests:: { NextConfigDescriptor , NextEpochDescriptor , PreDigest } ,
4545 inherents:: { BabeInherentData , INHERENT_IDENTIFIER } ,
46- BabeAuthorityWeight , ConsensusLog , Epoch , EquivocationProof , Slot , BABE_ENGINE_ID ,
46+ BabeAuthorityWeight , ConsensusLog , EquivocationProof , Slot , BABE_ENGINE_ID , StandaloneEpoch ,
47+ BabeEpochConfiguration ,
4748} ;
4849use sp_consensus_vrf:: schnorrkel;
4950use sp_inherents:: { InherentData , InherentIdentifier , MakeFatalError , ProvideInherent } ;
@@ -188,6 +189,9 @@ decl_storage! {
188189 // variable to its underlying value.
189190 pub Randomness get( fn randomness) : schnorrkel:: Randomness ;
190191
192+ /// The Current epoch configuration.
193+ EpochConfig : Option <BabeEpochConfiguration >;
194+
191195 /// Next epoch configuration, if changed.
192196 NextEpochConfig : Option <NextConfigDescriptor >;
193197
@@ -486,6 +490,8 @@ impl<T: Config> Module<T> {
486490 Self :: deposit_consensus ( ConsensusLog :: NextEpochData ( next_epoch) ) ;
487491
488492 if let Some ( next_config) = NextEpochConfig :: take ( ) {
493+ let config: BabeEpochConfiguration = next_config. clone ( ) . into ( ) ;
494+ EpochConfig :: put ( config) ;
489495 Self :: deposit_consensus ( ConsensusLog :: NextConfigData ( next_config) ) ;
490496 }
491497 }
@@ -498,30 +504,38 @@ impl<T: Config> Module<T> {
498504 }
499505
500506 /// Produces information about the current epoch.
501- pub fn current_epoch ( ) -> Epoch {
502- Epoch {
507+ pub fn current_epoch ( ) -> StandaloneEpoch {
508+ let epoch_config = EpochConfig :: get ( ) . unwrap ( ) ;
509+
510+ StandaloneEpoch {
503511 epoch_index : EpochIndex :: get ( ) ,
504512 start_slot : Self :: current_epoch_start ( ) ,
505513 duration : T :: EpochDuration :: get ( ) ,
506514 authorities : Self :: authorities ( ) ,
507515 randomness : Self :: randomness ( ) ,
516+ c : epoch_config. c ,
517+ allowed_slots : epoch_config. allowed_slots ,
508518 }
509519 }
510520
511521 /// Produces information about the next epoch (which was already previously
512522 /// announced).
513- pub fn next_epoch ( ) -> Epoch {
523+ pub fn next_epoch ( ) -> StandaloneEpoch {
514524 let next_epoch_index = EpochIndex :: get ( ) . checked_add ( 1 ) . expect (
515525 "epoch index is u64; it is always only incremented by one; \
516526 if u64 is not enough we should crash for safety; qed.",
517527 ) ;
518528
519- Epoch {
529+ let epoch_config = EpochConfig :: get ( ) . unwrap ( ) ;
530+
531+ StandaloneEpoch {
520532 epoch_index : next_epoch_index,
521533 start_slot : Self :: epoch_start ( next_epoch_index) ,
522534 duration : T :: EpochDuration :: get ( ) ,
523535 authorities : NextAuthorities :: get ( ) ,
524536 randomness : NextRandomness :: get ( ) ,
537+ c : epoch_config. c ,
538+ allowed_slots : epoch_config. allowed_slots ,
525539 }
526540 }
527541
0 commit comments