Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stake tracker improvements (migration and try-state checks OK in Polkadot) #4673

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
897 changes: 440 additions & 457 deletions Cargo.lock

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions polkadot/runtime/westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ parameter_types! {
pub const VoterBagThresholds: &'static [u64] = &bag_thresholds::VOTER_THRESHOLDS;
pub const TargetBagThresholds: &'static [u128] = &bag_thresholds::TARGET_THRESHOLDS;

pub const VoterUpdateMode: pallet_stake_tracker::VoterUpdateMode = pallet_stake_tracker::VoterUpdateMode::Strict;
pub const VoterUpdateMode: pallet_stake_tracker::VoterUpdateMode = pallet_stake_tracker::VoterUpdateMode::Lazy;
}

type VoterBagsListInstance = pallet_bags_list::Instance1;
Expand Down Expand Up @@ -1685,8 +1685,7 @@ pub mod migrations {
}

/// Unreleased migrations. Add new ones here:
pub type Unreleased =
(pallet_staking::migrations::single_block::v15::MigrateV14ToV15<Runtime>,);
pub type Unreleased = ();
}

/// Unchecked extrinsic type as expected by this runtime.
Expand Down
549 changes: 351 additions & 198 deletions polkadot/runtime/westend/src/weights/pallet_staking.rs

Large diffs are not rendered by default.

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 @@ -704,7 +704,7 @@ impl pallet_staking::Config for Runtime {
}

parameter_types! {
pub const VoterUpdateMode: pallet_stake_tracker::VoterUpdateMode = pallet_stake_tracker::VoterUpdateMode::Strict;
pub const VoterUpdateMode: pallet_stake_tracker::VoterUpdateMode = pallet_stake_tracker::VoterUpdateMode::Lazy;
}

impl pallet_stake_tracker::Config for Runtime {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ impl pallet_bags_list::Config<TargetBagsListInstance> for Runtime {
}

parameter_types! {
pub static UpdateMode: VoterUpdateMode = VoterUpdateMode::Strict;
pub static UpdateMode: VoterUpdateMode = VoterUpdateMode::Lazy;
}

impl pallet_stake_tracker::Config for Runtime {
Expand Down
4 changes: 2 additions & 2 deletions substrate/frame/staking/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ pallet-session = { path = "../session", default-features = false, features = [
"historical",
] }
pallet-authorship = { path = "../authorship", default-features = false }
pallet-stake-tracker = { path = "./stake-tracker", default-features = false }
sp-application-crypto = { path = "../../primitives/application-crypto", default-features = false, features = ["serde"] }
frame-election-provider-support = { path = "../election-provider-support", default-features = false }
log = { workspace = true }
Expand All @@ -45,9 +46,8 @@ sp-tracing = { path = "../../primitives/tracing" }
sp-core = { path = "../../primitives/core" }
sp-npos-elections = { path = "../../primitives/npos-elections" }
pallet-timestamp = { path = "../timestamp" }
pallet-stake-tracker = { path = "./stake-tracker" }
pallet-staking-reward-curve = { path = "reward-curve" }
pallet-bags-list = { path = "../bags-list" }
pallet-bags-list = { path = "../bags-list", default-features = false, features = ["try-runtime"] }
pallet-migrations = { path = "../migrations" }
substrate-test-utils = { path = "../../test-utils" }
frame-benchmarking = { path = "../benchmarking" }
Expand Down
34 changes: 5 additions & 29 deletions substrate/frame/staking/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1145,7 +1145,7 @@ mod benchmarks {

assert_eq!(
Staking::<T>::status(&voter),
Ok(StakerStatus::Nominator(vec![dangling_target.clone(), other_target.clone()]))
Ok(StakerStatus::Nominator(vec![other_target.clone(), dangling_target.clone()]))
);

#[extrinsic_call]
Expand Down Expand Up @@ -1214,7 +1214,7 @@ mod benchmarks {

impl_benchmark_test_suite!(
Staking,
crate::mock::ExtBuilder::default().has_stakers(true).set_voter_list_lazy(),
crate::mock::ExtBuilder::default().has_stakers(true),
crate::mock::Test,
exec_name = build_and_execute
);
Expand All @@ -1228,7 +1228,7 @@ mod tests {

#[test]
fn create_validators_with_nominators_for_era_works() {
ExtBuilder::default().build_and_execute(|| {
ExtBuilder::default().try_state(false).build_and_execute(|| {
let v = 10;
let n = 100;

Expand All @@ -1254,7 +1254,7 @@ mod tests {

#[test]
fn create_validator_with_nominators_works() {
ExtBuilder::default().build_and_execute(|| {
ExtBuilder::default().try_state(false).build_and_execute(|| {
let n = 10;

let (validator_stash, nominators) = create_validator_with_nominators::<Test>(
Expand Down Expand Up @@ -1285,7 +1285,7 @@ mod tests {

#[test]
fn add_slashing_spans_works() {
ExtBuilder::default().build_and_execute(|| {
ExtBuilder::default().try_state(false).build_and_execute(|| {
let n = 10;

let (validator_stash, _nominators) = create_validator_with_nominators::<Test>(
Expand Down Expand Up @@ -1315,28 +1315,4 @@ mod tests {
}
});
}

// TODO: SelectedBenchmark not exposed by v2?
/*
#[test]
fn test_payout_all() {
ExtBuilder::default().build_and_execute(|| {
let v = 10;
let n = 100;

let selected_benchmark = SelectedBenchmark::payout_all;
let c = vec![
(frame_benchmarking::BenchmarkParameter::v, v),
(frame_benchmarking::BenchmarkParameter::n, n),
];

assert_ok!(
<SelectedBenchmark as frame_benchmarking::BenchmarkingSetup<Test>>::unit_test_instance(
&selected_benchmark,
&c,
)
);
});
}
*/
}
Loading
Loading