Implementation of the new validator disabling strategy (#2226)
Closes https://github.com/paritytech/polkadot-sdk/issues/1966, https://github.com/paritytech/polkadot-sdk/issues/1963 and https://github.com/paritytech/polkadot-sdk/issues/1962. Disabling strategy specification [here](https://github.com/paritytech/polkadot-sdk/pull/2955). (Updated 13/02/2024) Implements: * validator disabling for a whole era instead of just a session * no more than 1/3 of the validators in the active set are disabled Removes: * `DisableStrategy` enum - now each validator committing an offence is disabled. * New era is not forced if too many validators are disabled. Before this PR not all offenders were disabled. A decision was made based on [`enum DisableStrategy`](https://github.com/paritytech/polkadot-sdk/blob/bbb66316/substrate/primitives/staking/src/offence.rs#L54). Some offenders were disabled for a whole era, some just for a session, some were not disabled at all. This PR changes the disabling behaviour. Now a validator committing an offense is disabled immediately till the end of the current era. Some implementation notes: * `OffendingValidators` in pallet session keeps all offenders (this is not changed). However its type is changed from `Vec<(u32, bool)>` to `Vec<u32>`. The reason is simple - each offender is getting disabled so the bool doesn't make sense anymore. * When a validator is disabled it is first added to `OffendingValidators` and then to `DisabledValidators`. This is done in [`add_offending_validator`](https://github.com/paritytech/polkadot-sdk/blob/bbb66316/substrate/frame/staking/src/slashing.rs#L325) from staking pallet. * In [`rotate_session`](https://github.com/paritytech/polkadot-sdk/blob/bdbe9829/substrate/frame/session/src/lib.rs#L623) the `end_session` also calls [`end_era`](https://github.com/paritytech/polkadot-sdk/blob/bbb66316/substrate/frame/staking/src/pallet/impls.rs#L490) when an era ends. In this case `OffendingValidators` are cleared **(1)**. * Then in [`rotate_session`](https://github.com/paritytech/polkadot-sdk/blob/bdbe9829/substrate/frame/session/src/lib.rs#L623) `DisabledValidators` are cleared **(2)** * And finally (still in `rotate_session`) a call to [`start_session`](https://github.com/paritytech/polkadot-sdk/blob/bbb66316 /substrate/frame/staking/src/pallet/impls.rs#L430) repopulates the disabled validators **(3)**. * The reason for this complication is that session pallet knows nothing abut eras. To overcome this on each new session the disabled list is repopulated (points 2 and 3). Staking pallet knows when a new era starts so with point 1 it ensures that the offenders list is cleared. --------- Co-authored-by:ordian <noreply@reusable.software> Co-authored-by:
ordian <write@reusable.software> Co-authored-by:
Maciej <maciej.zyszkiewicz@parity.io> Co-authored-by:
Gonçalo Pestana <g6pestana@gmail.com> Co-authored-by:
Kian Paimani <5588131+kianenigma@users.noreply.github.com> Co-authored-by: command-bot <> Co-authored-by:
Ankan <10196091+Ank4n@users.noreply.github.com>
Showing
- polkadot/runtime/parachains/src/disputes/slashing.rs 1 addition, 10 deletionspolkadot/runtime/parachains/src/disputes/slashing.rs
- polkadot/runtime/test-runtime/src/lib.rs 1 addition, 2 deletionspolkadot/runtime/test-runtime/src/lib.rs
- polkadot/runtime/westend/src/lib.rs 2 additions, 3 deletionspolkadot/runtime/westend/src/lib.rs
- polkadot/zombienet_tests/functional/0010-validator-disabling.toml 1 addition, 1 deletion.../zombienet_tests/functional/0010-validator-disabling.toml
- prdoc/pr_2226.prdoc 28 additions, 0 deletionsprdoc/pr_2226.prdoc
- substrate/bin/node/runtime/src/lib.rs 1 addition, 2 deletionssubstrate/bin/node/runtime/src/lib.rs
- substrate/frame/babe/src/mock.rs 1 addition, 2 deletionssubstrate/frame/babe/src/mock.rs
- substrate/frame/beefy/src/mock.rs 1 addition, 2 deletionssubstrate/frame/beefy/src/mock.rs
- substrate/frame/election-provider-multi-phase/test-staking-e2e/src/lib.rs 32 additions, 130 deletions...election-provider-multi-phase/test-staking-e2e/src/lib.rs
- substrate/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs 12 additions, 15 deletions...lection-provider-multi-phase/test-staking-e2e/src/mock.rs
- substrate/frame/fast-unstake/src/mock.rs 1 addition, 1 deletionsubstrate/frame/fast-unstake/src/mock.rs
- substrate/frame/grandpa/src/mock.rs 1 addition, 2 deletionssubstrate/frame/grandpa/src/mock.rs
- substrate/frame/im-online/src/lib.rs 1 addition, 5 deletionssubstrate/frame/im-online/src/lib.rs
- substrate/frame/im-online/src/tests.rs 0 additions, 3 deletionssubstrate/frame/im-online/src/tests.rs
- substrate/frame/nomination-pools/benchmarking/src/mock.rs 1 addition, 1 deletionsubstrate/frame/nomination-pools/benchmarking/src/mock.rs
- substrate/frame/nomination-pools/test-staking/src/mock.rs 1 addition, 1 deletionsubstrate/frame/nomination-pools/test-staking/src/mock.rs
- substrate/frame/offences/benchmarking/src/mock.rs 1 addition, 1 deletionsubstrate/frame/offences/benchmarking/src/mock.rs
- substrate/frame/offences/src/lib.rs 0 additions, 1 deletionsubstrate/frame/offences/src/lib.rs
- substrate/frame/offences/src/migration.rs 2 additions, 7 deletionssubstrate/frame/offences/src/migration.rs
- substrate/frame/offences/src/mock.rs 1 addition, 2 deletionssubstrate/frame/offences/src/mock.rs
Please register or sign in to comment