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

Improve staking payout performance #1313

Merged
merged 16 commits into from
Nov 16, 2023
3 changes: 2 additions & 1 deletion pallet/account-migration/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,13 @@ impl darwinia_deposit::Config for Runtime {
}

impl darwinia_staking::Config for Runtime {
type Currency = Balances;
type Deposit = Deposit;
type InflationManager = ();
type Kton = Dummy;
type MaxDeposits = ();
type MaxUnstakings = ();
type MinStakingDuration = ();
type OnSessionEnd = ();
type Ring = Dummy;
type RuntimeEvent = RuntimeEvent;
type WeightInfo = ();
Expand Down
2 changes: 1 addition & 1 deletion pallet/staking/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ darwinia-deposit = { workspace = true, features = ["std"] }

# substrate
dc-inflation = { workspace = true, features = ["std"] }
pallet-assets = { workspace = true, features = ["std"] }
pallet-assets = { workspace = true, features = ["runtime-benchmarks", "std"] }
pallet-balances = { workspace = true, features = ["std"] }
pallet-session = { workspace = true, features = ["std"] }
pallet-timestamp = { workspace = true, features = ["std"] }
Expand Down
24 changes: 24 additions & 0 deletions pallet/staking/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,30 @@ mod benchmarks {
_(RawOrigin::Signed(a));
}

#[benchmark]
fn payout() {
let a = frame_benchmarking::whitelisted_caller::<T::AccountId>();
let sender = a.clone();

<PreviousExposures<T>>::insert(
&a,
Exposure {
commission: Perbill::zero(),
vote: 32,
nominators: (0..32)
.map(|i| IndividualExposure {
who: frame_benchmarking::account("", i, i),
vote: 1,
})
.collect(),
},
);
<Unpaid<T>>::insert(&a, 500);

#[extrinsic_call]
_(RawOrigin::Signed(sender), a);
}

#[benchmark]
fn set_collator_count() {
// Worst-case scenario:
Expand Down
Loading
Loading