Skip to content

Commit

Permalink
fix bug of session rotating twice in parachain staking
Browse files Browse the repository at this point in the history
  • Loading branch information
talhadaar committed Dec 4, 2024
1 parent d971ef0 commit 479fb54
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions pallets/parachain-staking/src/migrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use crate::{
pallet::{Config, Pallet, OLD_STAKING_ID, STAKING_ID},
types::{AccountIdOf, Candidate, OldCandidate},
CandidatePool, ForceNewRound,
CandidatePool, ForceNewRound, Round,
};
use frame_support::{
pallet_prelude::{GetStorageVersion, StorageVersion, ValueQuery},
Expand Down Expand Up @@ -94,9 +94,16 @@ mod upgrade {
Versions::default() as u16
);

// force start new session
<ForceNewRound<T>>::put(true);
weight_writes += 1;
let round = Round::<T>::get();
let now = <frame_system::Pallet<T>>::block_number();
weight_reads += 2;
// Force new round if round wasn't about to be rotated anyway
if !round.should_update(now) {
// force start new session
<ForceNewRound<T>>::put(true);
weight_writes += 1;
log::info!("Will force new round for token economy V2.");
}

log::info!("V11 Migrating Done.");
}
Expand Down

0 comments on commit 479fb54

Please sign in to comment.