mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 00:31:07 +00:00
Remove Offence delay (#8414)
* Removed can_report api from OnOffenceHandler * Removed DeferredOffences and create a storage migration * Removed missing comments * Mock set_deferred_offences and deferred_offences methods * OnOffenceHandler::on_offence always succeed * Fix benchmark tests * Fix runtime-benchmark cfg methods * Removed 'applied' attribute from Offence event * refactor deprecated deferred offences getter * Validate if offences are submited after on_runtime_upgrade * update changelog * Remove empty lines * Fix remove_deferred_storage weights * Remove Offence::on_runtime_upgrade benchmark * Revert CHANGELOG.md update * Deprecate DeferredOffenceOf type * Update copyright Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> * Add migration logs Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> * Fix migration log * Remove unused import * Add migration tests * rustfmt * use generate_storage_alias! macro * Refactor should_resubmit_deferred_offences test * Replace spaces by tabs * Refactor should_resubmit_deferred_offences test * Removed WeightSoftLimit * Removed WeightSoftLimit from tests and mocks * Remove unused imports * Apply suggestions from code review Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
c786fb21a0
commit
ffca28ba59
@@ -40,7 +40,6 @@ pub struct OnOffenceHandler;
|
||||
|
||||
thread_local! {
|
||||
pub static ON_OFFENCE_PERBILL: RefCell<Vec<Perbill>> = RefCell::new(Default::default());
|
||||
pub static CAN_REPORT: RefCell<bool> = RefCell::new(true);
|
||||
pub static OFFENCE_WEIGHT: RefCell<Weight> = RefCell::new(Default::default());
|
||||
}
|
||||
|
||||
@@ -51,25 +50,13 @@ impl<Reporter, Offender>
|
||||
_offenders: &[OffenceDetails<Reporter, Offender>],
|
||||
slash_fraction: &[Perbill],
|
||||
_offence_session: SessionIndex,
|
||||
) -> Result<Weight, ()> {
|
||||
if <Self as offence::OnOffenceHandler<Reporter, Offender, Weight>>::can_report() {
|
||||
ON_OFFENCE_PERBILL.with(|f| {
|
||||
*f.borrow_mut() = slash_fraction.to_vec();
|
||||
});
|
||||
) -> Weight {
|
||||
ON_OFFENCE_PERBILL.with(|f| {
|
||||
*f.borrow_mut() = slash_fraction.to_vec();
|
||||
});
|
||||
|
||||
Ok(OFFENCE_WEIGHT.with(|w| *w.borrow()))
|
||||
} else {
|
||||
Err(())
|
||||
}
|
||||
OFFENCE_WEIGHT.with(|w| *w.borrow())
|
||||
}
|
||||
|
||||
fn can_report() -> bool {
|
||||
CAN_REPORT.with(|c| *c.borrow())
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_can_report(can_report: bool) {
|
||||
CAN_REPORT.with(|c| *c.borrow_mut() = can_report);
|
||||
}
|
||||
|
||||
pub fn with_on_offence_fractions<R, F: FnOnce(&mut Vec<Perbill>) -> R>(f: F) -> R {
|
||||
@@ -78,10 +65,6 @@ pub fn with_on_offence_fractions<R, F: FnOnce(&mut Vec<Perbill>) -> R>(f: F) ->
|
||||
})
|
||||
}
|
||||
|
||||
pub fn set_offence_weight(new: Weight) {
|
||||
OFFENCE_WEIGHT.with(|w| *w.borrow_mut() = new);
|
||||
}
|
||||
|
||||
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Runtime>;
|
||||
type Block = frame_system::mocking::MockBlock<Runtime>;
|
||||
|
||||
@@ -127,16 +110,10 @@ impl frame_system::Config for Runtime {
|
||||
type OnSetCode = ();
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub OffencesWeightSoftLimit: Weight =
|
||||
Perbill::from_percent(60) * BlockWeights::get().max_block;
|
||||
}
|
||||
|
||||
impl Config for Runtime {
|
||||
type Event = Event;
|
||||
type IdentificationTuple = u64;
|
||||
type OnOffenceHandler = OnOffenceHandler;
|
||||
type WeightSoftLimit = OffencesWeightSoftLimit;
|
||||
}
|
||||
|
||||
pub fn new_test_ext() -> sp_io::TestExternalities {
|
||||
|
||||
Reference in New Issue
Block a user