Skip to content

Commit

Permalink
benches with lazy voter sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
gpestana committed Jun 1, 2024
1 parent 7fcc09b commit b286d3e
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 11 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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
2 changes: 1 addition & 1 deletion substrate/frame/staking/src/benchmarking.rs
Original file line number Diff line number Diff line change
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 Down
6 changes: 3 additions & 3 deletions substrate/frame/staking/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ impl OnStakingUpdate<AccountId, Balance> for EventTracker {
}

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

impl pallet_stake_tracker::Config for Test {
Expand Down Expand Up @@ -565,8 +565,8 @@ impl ExtBuilder {
SkipTryStateCheck::set(!enable);
self
}
pub fn set_voter_list_lazy(self) -> Self {
VoterUpdateMode::set(pallet_stake_tracker::VoterUpdateMode::Lazy);
pub fn set_voter_list_strict(self) -> Self {
VoterUpdateMode::set(pallet_stake_tracker::VoterUpdateMode::Strict);
self
}
pub fn max_winners(self, max: u32) -> Self {
Expand Down
4 changes: 2 additions & 2 deletions substrate/frame/staking/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5169,7 +5169,7 @@ mod sorted_list_provider_integration {

#[test]
fn nominator_bond_unbond_chill_works() {
ExtBuilder::default().build_and_execute(|| {
ExtBuilder::default().set_voter_list_strict().build_and_execute(|| {
Balances::make_free_balance_be(&42, 100);

// initial stakers.
Expand Down Expand Up @@ -5237,7 +5237,7 @@ mod sorted_list_provider_integration {

#[test]
fn validator_validate_chill_works() {
ExtBuilder::default().build_and_execute(|| {
ExtBuilder::default().set_voter_list_strict().build_and_execute(|| {
Balances::make_free_balance_be(&42, 100);

// initial targets.
Expand Down
3 changes: 0 additions & 3 deletions substrate/frame/staking/stake-tracker/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ frame-election-provider-support = { default-features = false, path = "../../elec
frame-support = { default-features = false, path = "../../support" }
frame-system = { default-features = false, path = "../../system" }

log = { version = "0.4.17", default-features = false }

# Optional imports for benchmarking
frame-benchmarking = { path = "../../benchmarking", default-features = false, optional = true }

Expand All @@ -48,7 +46,6 @@ std = [
"frame-election-provider-support/std",
"frame-support/std",
"frame-system/std",
"log/std",
"pallet-bags-list/std",
"pallet-balances/std",
"scale-info/std",
Expand Down

0 comments on commit b286d3e

Please sign in to comment.