From 6018f90da7c4097aea31b61e5370b85b10a80467 Mon Sep 17 00:00:00 2001 From: bgallois <benjamin@gallois.cc> Date: Thu, 10 Oct 2024 09:43:37 +0200 Subject: [PATCH] fix unset CurrentPoolIndex during first evaluation period --- pallets/distance/src/lib.rs | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/pallets/distance/src/lib.rs b/pallets/distance/src/lib.rs index f63a8d613..f1866bf17 100644 --- a/pallets/distance/src/lib.rs +++ b/pallets/distance/src/lib.rs @@ -81,10 +81,13 @@ pub use traits::*; pub use types::*; pub use weights::WeightInfo; -use frame_support::traits::{ - fungible::{self, hold, Credit, Mutate, MutateHold}, - tokens::Precision, - OnUnbalanced, StorageVersion, +use frame_support::{ + traits::{ + fungible::{self, hold, Credit, Mutate, MutateHold}, + tokens::Precision, + OnUnbalanced, StorageVersion, + }, + DefaultNoBound, }; use sp_distance::{InherentError, INHERENT_IDENTIFIER}; use sp_inherents::{InherentData, InherentIdentifier}; @@ -288,6 +291,19 @@ pub mod pallet { TargetMustBeUnvalidated, } + #[pallet::genesis_config] + #[derive(DefaultNoBound)] + pub struct GenesisConfig<T: Config> { + pub _config: core::marker::PhantomData<T>, + } + + #[pallet::genesis_build] + impl<T: Config> BuildGenesisConfig for GenesisConfig<T> { + fn build(&self) { + CurrentPoolIndex::<T>::put(0u32); + } + } + #[pallet::hooks] impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> { fn on_initialize(block: BlockNumberFor<T>) -> Weight -- GitLab