Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
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
Apply code review suggestions
  • Loading branch information
davxy committed Mar 7, 2023
commit 2e1c3384b857b64161bf503ae77d3d3fd83d488d
15 changes: 7 additions & 8 deletions frame/babe/src/equivocation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,18 +87,17 @@ impl<Offender: Clone> Offence<Offender> for EquivocationOffence<Offender> {
self.slot
}

// The formula is min((3k / n)^2, 1)
// with: k = offenders_number, n = validators_number
fn slash_fraction(&self, offenders_count: u32) -> Perbill {
// the formula is min((3k / n)^2, 1)
let x = Perbill::from_rational(3 * offenders_count, self.validator_set_count);
// _ ^ 2
x.square()
// Perbill type domain is [0, 1] by definition
Perbill::from_rational(3 * offenders_count, self.validator_set_count).square()
}
}

/// Generic equivocation handler. This type implements `HandleEquivocation`
/// using existing subsystems that are part of frame (type bounds described
/// below) and will dispatch to them directly, it's only purpose is to wire all
/// subsystems together.
/// Babe equivocation offence system.
///
/// This type implements `OffenceReportSystem`
pub struct EquivocationReportSystem<T, R, P, L>(sp_std::marker::PhantomData<(T, R, P, L)>);

// We use the authorship pallet to fetch the current block author and use
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 @@ -234,7 +234,7 @@ pub trait OffenceReportSystem<Reporter, Evidence> {
/// Longevity, in blocks, for the evidence report validity.
///
/// For example, when using the staking pallet this should be set equal
/// to the bonding durationin blocks, not eras).
/// to the bonding duration in blocks, not eras.
type Longevity: Get<u64>;

/// Publish an offence evidence.
Expand Down