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

Offences report system rework #13425

Merged
Merged
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
d0b6d95
Experiments with common equivocation trait
davxy Feb 13, 2023
5754be6
Improved equivocation trait
davxy Feb 15, 2023
9029a5c
Fix grandpa equivocation implementation
davxy Feb 15, 2023
0e04ca0
Remove some cruft
davxy Feb 16, 2023
d8c2598
Remove some more cruft
davxy Feb 16, 2023
1674a48
More generic naming
davxy Feb 16, 2023
6f0feff
Simplification of offences manipilation
davxy Feb 16, 2023
239bfbb
More refactory
davxy Feb 17, 2023
4ba1a01
Some prograss with the encapsulation of offence report system
davxy Feb 18, 2023
7c1c06d
Finally unit type works as a universal null report system
davxy Feb 20, 2023
1069c9d
Align substrate node code
davxy Feb 20, 2023
e096669
Further simplification
davxy Feb 20, 2023
09850ee
Fix test utils
davxy Feb 20, 2023
020e71c
Remove not required associated type
davxy Feb 20, 2023
4155c88
Fix benches
davxy Feb 20, 2023
2a3ed07
Rollback to prev field name
davxy Feb 20, 2023
5545901
Merge branch 'master' into equivocation-offence-rework
davxy Feb 20, 2023
c8a8eb6
Box big params
davxy Feb 20, 2023
9e959b7
Fix typo
davxy Feb 20, 2023
6e7e11d
Remove new tag computation
davxy Feb 20, 2023
080e82c
Remove default implementations
davxy Feb 21, 2023
3966ef7
Better docs
davxy Feb 21, 2023
5587720
Return 'Result' instead of bool
davxy Feb 23, 2023
52ee367
Change offence report system return types
davxy Feb 24, 2023
8706a6d
Some renaming and documentation
davxy Feb 24, 2023
7bebe84
Improve documentation
davxy Feb 24, 2023
f9a505b
More abstract offence report system
davxy Feb 24, 2023
aa83011
Rename 'consume_evidence' to 'process_evidence'
davxy Feb 24, 2023
0c5a536
Further docs refinements
davxy Feb 24, 2023
46b9f86
Doc for dummy offence report
davxy Feb 24, 2023
f05c4ea
Merge branch 'master' into equivocation-offence-rework
davxy Feb 24, 2023
3ff71d1
Fix rustdoc
davxy Feb 24, 2023
78f0e9f
Merge branch 'master' into equivocation-offence-rework
davxy Mar 7, 2023
d336264
Fix after master merge
davxy Mar 7, 2023
2e1c338
Apply code review suggestions
davxy Mar 7, 2023
643c745
Improve docs
davxy Mar 7, 2023
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
Prev Previous commit
Next Next commit
Improve documentation
davxy committed Feb 24, 2023
commit 7bebe8461864ade81651aff53b642c805b338b2d
26 changes: 19 additions & 7 deletions primitives/staking/src/offence.rs
Original file line number Diff line number Diff line change
@@ -240,31 +240,43 @@ pub trait OffenceReportSystem<Reporter, OffenceProof, KeyOwnerProof> {
/// to the bonding durationin blocks, not eras).
type Longevity: Get<u64>;

/// Create and submit an offence report.
/// Publish an offence evidence.
///
/// Common usage: submit the evidence on-chain via some kind of extrinsic.
fn publish_evidence(
offence_proof: OffenceProof,
key_owner_proof: KeyOwnerProof,
) -> Result<(), ()>;

/// Check an offence evidence validity.
/// Check an offence evidence.
///
/// Common usage: preliminary validity check before execution
/// (e.g. for unsigned extrinsic quick checks).
fn check_evidence(
offence_proof: &OffenceProof,
key_owner_proof: &KeyOwnerProof,
) -> Result<(), TransactionValidityError>;

/// Report an offence evidence.
///
/// Typical usage: enact some form of slashing directly or by forwarding
/// the evidence to a lower level specialized subsystem (e.g. a handler
/// implementing `ReportOffence` trait).
fn consume_evidence(
reporter: Option<Reporter>,
offence_proof: OffenceProof,
key_owner_proof: KeyOwnerProof,
) -> Result<(), DispatchError>;
}

// Dummy report system.
//
// `KeyOwnerProof` type has been coercivelly set as `sp_core::Void`, that is a
// type that can't be regularly instantiated. The idea is to prevent the report
// and submission of evidence in cause of usage of this report system.
/// Dummy offence report system.
///
/// `KeyOwnerProof` type is coercivelly set as `sp_core::Void`, i.e. a type that
/// can't be regularly instantiated. The idea is to prevent the creation of offences
/// targeting this subsystem in the first place and thus preventing any spammy behavior.
///
/// Nevertheless, because of the generic [`Reporter`] and [`OffenceProof`] this dummy
/// system can be used in any place requiring the association with an `OffenceReportSystem`.
impl<Reporter, OffenceProof> OffenceReportSystem<Reporter, OffenceProof, sp_core::Void> for () {
type Longevity = ();