Skip to content

Commit

Permalink
Increase MaxInvulnerables to 20 + fix migrations msg
Browse files Browse the repository at this point in the history
  • Loading branch information
re-gius committed Nov 26, 2024
1 parent 9ca25a1 commit 10e7295
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 13 deletions.
2 changes: 1 addition & 1 deletion polkadot/runtime/test-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ impl pallet_staking::Config for Runtime {
type EventListeners = ();
type WeightInfo = ();
type DisablingStrategy = pallet_staking::UpToLimitWithReEnablingDisablingStrategy;
type MaxInvulnerables = ConstU32<4>;
type MaxInvulnerables = ConstU32<20>;
}

parameter_types! {
Expand Down
2 changes: 1 addition & 1 deletion polkadot/runtime/westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,7 @@ impl pallet_staking::Config for Runtime {
type EventListeners = (NominationPools, DelegatedStaking);
type WeightInfo = weights::pallet_staking::WeightInfo<Runtime>;
type DisablingStrategy = pallet_staking::UpToLimitWithReEnablingDisablingStrategy;
type MaxInvulnerables = frame_support::traits::ConstU32<4>;
type MaxInvulnerables = frame_support::traits::ConstU32<20>;
}

impl pallet_fast_unstake::Config for Runtime {
Expand Down
2 changes: 1 addition & 1 deletion substrate/bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ impl pallet_staking::Config for Runtime {
type WeightInfo = pallet_staking::weights::SubstrateWeight<Runtime>;
type BenchmarkingConfig = StakingBenchmarkingConfig;
type DisablingStrategy = pallet_staking::UpToLimitWithReEnablingDisablingStrategy;
type MaxInvulnerables = ConstU32<4>;
type MaxInvulnerables = ConstU32<20>;
}

impl pallet_fast_unstake::Config for Runtime {
Expand Down
28 changes: 19 additions & 9 deletions substrate/frame/staking/src/migrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,25 +67,28 @@ pub mod v17 {
pub struct VersionUncheckedMigrateV16ToV17<T>(core::marker::PhantomData<T>);
impl<T: Config> UncheckedOnRuntimeUpgrade for VersionUncheckedMigrateV16ToV17<T> {
fn on_runtime_upgrade() -> Weight {
let mut migration_errors = false;

let old_disabled_validators = v16::DisabledValidators::<T>::get();
// BoundedVec with MaxWinners limit, this should always work
let disabled_validators_maybe = BoundedVec::try_from(old_disabled_validators);
match disabled_validators_maybe {
Ok(disabled_validators) => DisabledValidators::<T>::set(disabled_validators),
Err(_) => log!(warn, "Migration failed for DisabledValidators from v16 to v17."),
Err(_) => {
log!(warn, "Migration failed for DisabledValidators from v16 to v17.");
migration_errors = true;
},
}

let old_invulnerables = v16::Invulnerables::<T>::get();
let old_invulnerables_len = old_invulnerables.len();
// BoundedVec with MaxWinners limit, this should always work
let invulnerables_maybe = BoundedVec::try_from(old_invulnerables);
match invulnerables_maybe {
Ok(invulnerables) => Invulnerables::<T>::set(invulnerables),
Err(_) => log!(
warn,
"Migration failed for Invulnerables from v16 to v17: {} old invulnerables may get lost.",
old_invulnerables_len,
),
Err(_) => {
log!(warn, "Migration failed for Invulnerables from v16 to v17.");
migration_errors = true;
},
}

for (era_index, era_rewards) in v16::ErasRewardPoints::<T>::iter() {
Expand All @@ -101,11 +104,18 @@ pub mod v17 {
};
ErasRewardPoints::<T>::insert(era_index, bounded_era_rewards);
},
Err(_) => log!(warn, "Migration failed for ErasRewardPoints from v16 to v17."),
Err(_) => {
log!(warn, "Migration failed for ErasRewardPoints from v16 to v17.");
migration_errors = true;
},
}
}

log!(info, "v17 applied successfully.");
if migration_errors {
log!(warn, "v17 applied with some errors.");
} else {
log!(info, "v17 applied successfully.");
}
T::DbWeight::get().reads_writes(1, 1)
}
}
Expand Down
2 changes: 1 addition & 1 deletion substrate/frame/staking/src/pallet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ pub mod pallet {
type MaxControllersInDeprecationBatch = ConstU32<100>;
type EventListeners = ();
type DisablingStrategy = crate::UpToLimitDisablingStrategy;
type MaxInvulnerables = ConstU32<4>;
type MaxInvulnerables = ConstU32<20>;
#[cfg(feature = "std")]
type BenchmarkingConfig = crate::TestBenchmarkingConfig;
type WeightInfo = ();
Expand Down

0 comments on commit 10e7295

Please sign in to comment.