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

New slashing mechanism #554

Merged
merged 11 commits into from
Aug 15, 2018
Merged

New slashing mechanism #554

merged 11 commits into from
Aug 15, 2018

Conversation

gavofyork
Copy link
Member

@gavofyork gavofyork commented Aug 12, 2018

Redesigns the slashing subsystem to make incremental slashing more sensible, offers a way out for validators that want a fail-safe and provides more scope for fail-overs (especially when done in combination with a weighted leader-selection algorithm).

  • validators can set preferences;
  • force-unstake when balance too low;
  • auto-unstake after N slashes according to validator's preferences;
  • exponential (base 2) slashing;
  • don't early-terminate session/era unless validator becomes unstaked;
  • offline grace period before punishment;
  • introduced support for the new inherent extrinsic into the block-authoring subsystem.

Still to do:

  • A few runtime tests;
  • fix validator_offline test.

- unstake when balance too low
- unstake after N slashes according to val prefs
- don't early-terminate session/era unless unstaked
- offline grace period before punishment
@gavofyork gavofyork changed the title New slashing mechanism New slashing mechanism [WiP] Aug 12, 2018
@gavofyork gavofyork added the A3-in_progress Pull request is in progress. No review needed at this stage. label Aug 12, 2018
@gavofyork gavofyork changed the title New slashing mechanism [WiP] New slashing mechanism Aug 12, 2018
fn note_round_end(&mut self, was_online: bool) {
let now = Instant::now();

fn note_round_end(&mut self, now: Instant, was_online: Option<bool>) {
Copy link
Member Author

Choose a reason for hiding this comment

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

we provide now in order to ensure that all rounds in the same block are considered contemporaneous, which lets us group which validators were offline for the previous block specifically.

.or_insert_with(Observed::new)
.note_round_end(was_online);
self.observed.entry(validator).or_insert_with(Observed::new);
for (val, obs) in self.observed.iter_mut() {
Copy link
Member Author

Choose a reason for hiding this comment

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

all validators are updated with the current time so that we can see which of them were inactive in specifially the previous block.

@gavofyork gavofyork added A0-please_review Pull request needs code review. and removed A3-in_progress Pull request is in progress. No review needed at this stage. labels Aug 14, 2018
@rphmeier rphmeier added A5-grumble and removed A0-please_review Pull request needs code review. labels Aug 14, 2018
@rphmeier
Copy link
Contributor

(Waiting for tests)

@0xthreebody
Copy link

0xthreebody commented Aug 14, 2018

  • auto-unstake after N slashes according to validator's preferences;

I think, the auto-unnominate after N slashes according to nominator's preferences, is also necessary.

@gavofyork
Copy link
Member Author

@jiangfuyao yeah, but that'll be another PR

@gavofyork gavofyork added A0-please_review Pull request needs code review. and removed A5-grumble labels Aug 15, 2018
@gavofyork gavofyork mentioned this pull request Aug 15, 2018
@gavofyork gavofyork merged commit 6ce9337 into v0.2 Aug 15, 2018
@gavofyork gavofyork deleted the gav-missed-proposal branch August 15, 2018 16:08
gavofyork added a commit that referenced this pull request Aug 15, 2018
* Slashing improvements

- unstake when balance too low
- unstake after N slashes according to val prefs
- don't early-terminate session/era unless unstaked
- offline grace period before punishment

* Fix warning

* Cleanups and ensure slash_count decays

* Bump authoring version and introduce needed authoring stub

* Rename

* Fix offline tracker

* Fix offline tracker

* Renames

* Add test

* Tests

* Tests.
gavofyork added a commit that referenced this pull request Aug 27, 2018
* New slashing mechanism (#554)

* Slashing improvements

- unstake when balance too low
- unstake after N slashes according to val prefs
- don't early-terminate session/era unless unstaked
- offline grace period before punishment

* Fix warning

* Cleanups and ensure slash_count decays

* Bump authoring version and introduce needed authoring stub

* Rename

* Fix offline tracker

* Fix offline tracker

* Renames

* Add test

* Tests

* Tests.

* Remove accidental merge files.

* Version bump, fixes (#572)

* Bump version, don't propose invalid blocks

* Fix build.

* Fixes.

* More fixes.

* Fix tests.

* Fix more tests

* More tests fixed

* Fix merge

* Fix accidental merge bug

* Fixes.

* Staking failsafes

- Don't slash/unstake/change session when too few staking participants
- Introduce set_balance PrivCall

* Make minimum validator count dynamic.

* test fixes

* Fix tests.

* Fix tests

* Fix tests, update readme.

* Test with release.

* Use safe math when dealing with total stake

* Fix test again.

* Fix grumbles.
gavofyork added a commit that referenced this pull request Aug 27, 2018
New slashing mechanism (#554)  …
* Slashing improvements

- unstake when balance too low
- unstake after N slashes according to val prefs
- don't early-terminate session/era unless unstaked
- offline grace period before punishment
* Fix warning
* Cleanups and ensure slash_count decays
* Bump authoring version and introduce needed authoring stub
* Rename
* Fix offline tracker
* Fix offline tracker
* Renames
* Add test
* Tests
* Tests.
Remove accidental merge files.
Merge remote-tracking branch 'origin/master' into gav-new-pos
Version bump, fixes (#572)  …
* Bump version, don't propose invalid blocks
* Fix build.
* Fixes.
* More fixes.
* Fix tests.
* Fix more tests
* More tests fixed
Fix merge
Fix accidental merge bug
Fixes.
Staking failsafes  …
- Don't slash/unstake/change session when too few staking participants
- Introduce set_balance PrivCall
Make minimum validator count dynamic.
test fixes
Fix tests.
Fix tests
Fix tests, update readme.
Merge remote-tracking branch 'origin/master' into gav-new-pos
Test with release.
Use safe math when dealing with total stake
Fix test again.
Introduce events into runtime.
Fix tests
Add events for account new/reap
Integration-style tests for events.
gavofyork added a commit that referenced this pull request Aug 28, 2018
* Squashed commit.

New slashing mechanism (#554)  …
* Slashing improvements

- unstake when balance too low
- unstake after N slashes according to val prefs
- don't early-terminate session/era unless unstaked
- offline grace period before punishment
* Fix warning
* Cleanups and ensure slash_count decays
* Bump authoring version and introduce needed authoring stub
* Rename
* Fix offline tracker
* Fix offline tracker
* Renames
* Add test
* Tests
* Tests.
Remove accidental merge files.
Merge remote-tracking branch 'origin/master' into gav-new-pos
Version bump, fixes (#572)  …
* Bump version, don't propose invalid blocks
* Fix build.
* Fixes.
* More fixes.
* Fix tests.
* Fix more tests
* More tests fixed
Fix merge
Fix accidental merge bug
Fixes.
Staking failsafes  …
- Don't slash/unstake/change session when too few staking participants
- Introduce set_balance PrivCall
Make minimum validator count dynamic.
test fixes
Fix tests.
Fix tests
Fix tests, update readme.
Merge remote-tracking branch 'origin/master' into gav-new-pos
Test with release.
Use safe math when dealing with total stake
Fix test again.
Introduce events into runtime.
Fix tests
Add events for account new/reap
Integration-style tests for events.

* Remove old code
liuchengxu pushed a commit to chainx-org/substrate that referenced this pull request Aug 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants