Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Runtime Task Executor + Example for staking slashing spans #8197

Closed
wants to merge 17 commits into from
Closed
11 changes: 6 additions & 5 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@ parameter_types! {
.get(DispatchClass::Normal)
.max_extrinsic.expect("Normal extrinsics have a weight limit configured; qed")
.saturating_sub(BlockExecutionWeight::get());
pub SlashTaskWeight: Weight = RuntimeBlockWeights::get().max_block / 2;
}

impl pallet_staking::Config for Runtime {
Expand Down Expand Up @@ -508,6 +509,7 @@ impl pallet_staking::Config for Runtime {
// a single extrinsic.
type OffchainSolutionWeightLimit = OffchainSolutionWeightLimit;
type ElectionProvider = ElectionProviderMultiPhase;
type TaskExecutor = frame_support::executor::SinglePassExecutor<pallet_staking::SlashTask<Self>, SlashTaskWeight>;
type WeightInfo = pallet_staking::weights::SubstrateWeight<Runtime>;
}

Expand Down
1 change: 1 addition & 0 deletions frame/babe/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ impl pallet_staking::Config for Test {
type MinSolutionScoreBump = ();
type OffchainSolutionWeightLimit = ();
type ElectionProvider = onchain::OnChainSequentialPhragmen<Self>;
type TaskExecutor = frame_support::executor::SinglePassExecutor<pallet_staking::SlashTask<Self>>;
type WeightInfo = ();
}

Expand Down
1 change: 1 addition & 0 deletions frame/grandpa/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ impl pallet_staking::Config for Test {
type MinSolutionScoreBump = ();
type OffchainSolutionWeightLimit = ();
type ElectionProvider = onchain::OnChainSequentialPhragmen<Self>;
type TaskExecutor = frame_support::executor::SinglePassExecutor<pallet_staking::SlashTask<Self>>;
type WeightInfo = ();
}

Expand Down
1 change: 1 addition & 0 deletions frame/offences/benchmarking/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ impl pallet_staking::Config for Test {
type MinSolutionScoreBump = ();
type OffchainSolutionWeightLimit = ();
type ElectionProvider = onchain::OnChainSequentialPhragmen<Self>;
type TaskExecutor = frame_support::executor::SinglePassExecutor<pallet_staking::SlashTask<Self>>;
type WeightInfo = ();
}

Expand Down
1 change: 1 addition & 0 deletions frame/session/benchmarking/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ impl pallet_staking::Config for Test {
type MinSolutionScoreBump = ();
type OffchainSolutionWeightLimit = ();
type ElectionProvider = onchain::OnChainSequentialPhragmen<Self>;
type TaskExecutor = frame_support::executor::SinglePassExecutor<pallet_staking::SlashTask<Self>>;
type WeightInfo = ();
}

Expand Down
1 change: 1 addition & 0 deletions frame/staking/fuzzer/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,5 +190,6 @@ impl pallet_staking::Config for Test {
type UnsignedPriority = ();
type OffchainSolutionWeightLimit = ();
type WeightInfo = ();
type TaskExecutor = frame_support::executor::SinglePassExecutor<pallet_staking::SlashTask<Self>>;
type ElectionProvider = MockElectionProvider;
}
4 changes: 2 additions & 2 deletions frame/staking/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ benchmarks! {

// all nominators now should be nominating our validator...
for n in nominator_stashes.iter() {
assert!(Nominators::<T>::get(n).unwrap().targets.contains(&stash));
assert!(Nominators::<T>::get(n).unwrap().targets.iter().any(|(t, _)| t == &stash));
}

// we need the unlookuped version of the nominator stash for the kick.
Expand All @@ -256,7 +256,7 @@ benchmarks! {
verify {
// all nominators now should *not* be nominating our validator...
for n in nominator_stashes.iter() {
assert!(!Nominators::<T>::get(n).unwrap().targets.contains(&stash));
assert!(!Nominators::<T>::get(n).unwrap().targets.iter().map(|(t, _)| t).collect::<Vec<_>>().contains(&&stash));
kianenigma marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down
Loading