safe multi-era slashing for NPoS (#3846)
* define slashing spans * tests and pruning for slashing-spans record * validators get slashed before nominators * apply slash to nominators as well * chill and end slashing spans * actually perform slashes * integration (tests failing) * prune metadata * fix compilation * some tests for slashing and metadata garbage collection * correctly pass session index to slash handler * test span-max property for nominators and validators * test that slashes are summed correctly * reward value computation * implement rewarding * add comment about rewards * do not adjust slash fraction in offences module * fix offences tests * remove unused new_offenders field * update runtime version * fix up some docs * fix some CI failures * remove no-std incompatible vec! invocation * try to fix span-max rounding error * Update srml/staking/src/slashing.rs Fix type: winow -> window Co-Authored-By:Tomasz Drwięga <tomusdrw@users.noreply.github.com> * slashes from prior spans don't kick validator again * more information for nominators, suppression * ensure ledger is consistent with itself post-slash * implement slash out of unlocking funds also * slashing: create records to be applied after-the-fact * queue slashes for a few eras later * method for canceling deferred slashes * attempt to fix test in CI * storage migration for `Nominators` * update node-runtime to use SlashDeferDuration * adjust migration entry-points somewhat * fix migration compilation * add manual Vec import to migration * enable migrations feature in node-runtime * bump runtime version * update to latest master crate renames * update to use ensure-origin * Apply suggestions from code review use `ensure!` Co-Authored-By:
Gavin Wood <gavin@parity.io> * fix multi-slash removal * initialize storage version to current in genesis * add test for version initialization
Showing
- substrate/bin/node/runtime/Cargo.toml 1 addition, 1 deletionsubstrate/bin/node/runtime/Cargo.toml
- substrate/bin/node/runtime/src/lib.rs 4 additions, 0 deletionssubstrate/bin/node/runtime/src/lib.rs
- substrate/frame/balances/src/lib.rs 1 addition, 0 deletionssubstrate/frame/balances/src/lib.rs
- substrate/frame/offences/src/lib.rs 17 additions, 51 deletionssubstrate/frame/offences/src/lib.rs
- substrate/frame/offences/src/mock.rs 2 additions, 3 deletionssubstrate/frame/offences/src/mock.rs
- substrate/frame/offences/src/tests.rs 1 addition, 32 deletionssubstrate/frame/offences/src/tests.rs
- substrate/frame/staking/Cargo.toml 1 addition, 0 deletionssubstrate/frame/staking/Cargo.toml
- substrate/frame/staking/src/lib.rs 303 additions, 141 deletionssubstrate/frame/staking/src/lib.rs
- substrate/frame/staking/src/migration.rs 88 additions, 0 deletionssubstrate/frame/staking/src/migration.rs
- substrate/frame/staking/src/mock.rs 57 additions, 2 deletionssubstrate/frame/staking/src/mock.rs
- substrate/frame/staking/src/slashing.rs 824 additions, 0 deletionssubstrate/frame/staking/src/slashing.rs
- substrate/frame/staking/src/tests.rs 619 additions, 20 deletionssubstrate/frame/staking/src/tests.rs
- substrate/primitives/sr-staking-primitives/src/offence.rs 4 additions, 0 deletionssubstrate/primitives/sr-staking-primitives/src/offence.rs
Please register or sign in to comment