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

Offence implementations can disable offenders independently from slashing #10201

Merged
merged 10 commits into from
Nov 17, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 3 additions & 2 deletions frame/offences/src/migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ pub fn remove_deferred_storage<T: Config>() -> Weight {
let mut weight = T::DbWeight::get().reads_writes(1, 1);
let deferred = <DeferredOffences<T>>::take();
wigy-opensource-developer marked this conversation as resolved.
Show resolved Hide resolved
log::info!(target: "runtime::offences", "have {} deferred offences, applying.", deferred.len());
for (offences, perbill, session, disable) in deferred.iter() {
let consumed = T::OnOffenceHandler::on_offence(&offences, &perbill, *session, *disable);
for (offences, perbill, session, disable_strategy) in deferred.iter() {
let consumed =
T::OnOffenceHandler::on_offence(&offences, &perbill, *session, *disable_strategy);
weight = weight.saturating_add(consumed);
}

Expand Down
6 changes: 3 additions & 3 deletions frame/staking/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -764,12 +764,12 @@ pub(crate) fn on_offence_in_era(
>],
slash_fraction: &[Perbill],
era: EraIndex,
disable: DisableStrategy,
disable_strategy: DisableStrategy,
) {
let bonded_eras = crate::BondedEras::<Test>::get();
for &(bonded_era, start_session) in bonded_eras.iter() {
if bonded_era == era {
let _ = Staking::on_offence(offenders, slash_fraction, start_session, disable);
let _ = Staking::on_offence(offenders, slash_fraction, start_session, disable_strategy);
return
} else if bonded_era > era {
break
Expand All @@ -781,7 +781,7 @@ pub(crate) fn on_offence_in_era(
offenders,
slash_fraction,
Staking::eras_start_session_index(era).unwrap(),
disable,
disable_strategy,
);
} else {
panic!("cannot slash in era {}", era);
Expand Down
2 changes: 1 addition & 1 deletion primitives/staking/src/offence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ pub trait OnOffenceHandler<Reporter, Offender, Res> {
///
/// The `session` parameter is the session index of the offence.
///
/// The `disable` parameter decides if the offenders need to be disabled immediately.
/// The `disable_strategy` parameter decides if the offenders need to be disabled immediately.
///
/// The receiver might decide to not accept this offence. In this case, the call site is
/// responsible for queuing the report and re-submitting again.
Expand Down