Offences report system rework (#13425)

* Experiments with common equivocation trait

* Improved equivocation trait

* Fix grandpa equivocation implementation

* Remove some cruft

* Remove some more cruft

* More generic naming

* Simplification of offences manipilation

* More refactory

* Some prograss with the encapsulation of offence report system

* Finally unit type works as a universal null report system

* Align substrate node code

* Further simplification

* Fix test utils

* Remove not required associated type

* Fix benches

* Rollback to prev field name

* Box big params

* Fix typo

* Remove new tag computation

* Remove default implementations

* Better docs

* Return 'Result' instead of bool

* Change offence report system return types

* Some renaming and documentation

* Improve documentation

* More abstract offence report system

* Rename 'consume_evidence' to 'process_evidence'

* Further docs refinements

* Doc for dummy offence report

* Fix rustdoc

* Fix after master merge

* Apply code review suggestions

* Improve docs
This commit is contained in:
Davide Galassi
2023-03-07 21:25:55 +01:00
committed by GitHub
parent e16f15119f
commit 9dd10d131d
18 changed files with 499 additions and 741 deletions
+5 -5
View File
@@ -134,17 +134,17 @@ pub fn offence_reports(kind: Kind, time_slot: u128) -> Vec<OffenceDetails<u64, u
}
#[derive(Clone)]
pub struct Offence<T> {
pub struct Offence {
pub validator_set_count: u32,
pub offenders: Vec<T>,
pub offenders: Vec<u64>,
pub time_slot: u128,
}
impl<T: Clone> offence::Offence<T> for Offence<T> {
impl offence::Offence<u64> for Offence {
const ID: offence::Kind = KIND;
type TimeSlot = u128;
fn offenders(&self) -> Vec<T> {
fn offenders(&self) -> Vec<u64> {
self.offenders.clone()
}
@@ -167,5 +167,5 @@ impl<T: Clone> offence::Offence<T> for Offence<T> {
/// Create the report id for the given `offender` and `time_slot` combination.
pub fn report_id(time_slot: u128, offender: u64) -> H256 {
Offences::report_id::<Offence<u64>>(&time_slot, &offender)
Offences::report_id::<Offence>(&time_slot, &offender)
}