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

Offences reporting and slashing #3322

Merged
merged 119 commits into from
Aug 16, 2019
Merged

Offences reporting and slashing #3322

merged 119 commits into from
Aug 16, 2019

Conversation

tomusdrw
Copy link
Contributor

@tomusdrw tomusdrw commented Aug 7, 2019

The spec is available here.

This PR introduces infrastructure for tracking offences and enacting them, i.e. slashing. Actual reporting is implemented only for unresponsivness; detection, validation and filing the reports is out of scope for this PR and should be implemented in #3314. There are some differences from the spec, namely:

  1. Only reports for BABE equivocation, GRANDPA equivocation and unresponsivness are in place.
  2. This doesn't have any notion of severity levels, and we always start a new era on if any of validators is slashed and we always disable a validator on an offence.
  3. The reward ratio is a global scalar whereas in the spec it could depend on the actual misbehavior (e.g. for BABE equivocation the reporter is rewarded not from the total slashed amount but rather from an amount that would have been slashed with the offender count equals to 1).

tomusdrw and others added 30 commits August 6, 2019 16:28
srml/im-online/src/lib.rs Outdated Show resolved Hide resolved
Co-Authored-By: Logan Saether <x@logansaether.com>
// because:
// Y = X * (1 - prev)
// Z = Y * (1 - x)
// Z = X * (1 - new)
Copy link
Contributor

@rphmeier rphmeier Aug 15, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our main concern was whether PerBill can handle it.
To keep the decimal representation from going out of control, we could always round the slash_fraction to the nearest 1000th or 10,000th.

We will then incur some rounding error but are at much lower risk of overflow.

rphmeier and others added 2 commits August 16, 2019 14:02
* only slash in current era

* prune journal for last era

* comment own_slash

* emit an event when old slashing events are discarded
srml/grandpa/src/lib.rs Outdated Show resolved Hide resolved
srml/babe/src/lib.rs Outdated Show resolved Hide resolved
srml/im-online/src/lib.rs Outdated Show resolved Hide resolved
srml/offences/src/lib.rs Outdated Show resolved Hide resolved
srml/offences/src/lib.rs Outdated Show resolved Hide resolved
srml/offences/src/lib.rs Outdated Show resolved Hide resolved
srml/offences/src/mock.rs Outdated Show resolved Hide resolved
srml/offences/src/lib.rs Outdated Show resolved Hide resolved
srml/offences/src/lib.rs Show resolved Hide resolved
srml/offences/src/lib.rs Outdated Show resolved Hide resolved
# Conflicts:
#	node/cli/src/chain_spec.rs
#	node/runtime/src/lib.rs
#	srml/aura/Cargo.toml
#	srml/babe/Cargo.toml
#	srml/babe/src/lib.rs
#	srml/session/src/lib.rs
# Conflicts:
#	node/runtime/src/lib.rs
#	srml/babe/src/lib.rs
Copy link
Member

@gavofyork gavofyork left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A0-please_review Pull request needs code review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants