Introduces: Delegated Staking Pallet (#3904)
This is the second PR in preparation for https://github.com/paritytech/polkadot-sdk/issues/454. ## Also see - **Precursor** https://github.com/paritytech/polkadot-sdk/pull/3889. - **Follow up** https://github.com/paritytech/polkadot-sdk/pull/3905. Overall changes are documented here (lot more visual): https://hackmd.io/@ak0n/454-np-governance ## Changes ### Delegation Interface Provides delegation primitives for staking. Introduces two new roles: - Agent: These are accounts who receive delegation from other accounts (delegators) and stakes on behalf of them. The funds are held in delegator accounts. - Delegator: Accounts who delegate their funds to an agent authorising them to use it for staking. Supports - A way for delegators to add or withdraw delegation to an agent. - A way for an agent to slash a delegator during a slashing event. ### Pallet Delegated Staking - Implements `DelegationInterface`. - Lazy slashing: Any slashes to an Agent is posted in a ledger but not immediately slashed. The agent can call `DelegationInterface::delegator_slash` to slash the member and clear the corresponding slash from its ledger. - Consumes `StakingInterface` to provide `CoreStaking` features. In reality, this will be `pallet-staking`. - Ensures bookkeeping for agent and delegator are correct but leaves the management of reward and slash logic upto the consumer of this pallet. - While it does not expose any calls yet, it is written with the intent of exposing these primitives via extrinsics. ## TODO - [x] Improve unit tests in the pallet. - [x] Separate slash reward perbill for rewarding the slash reporters? - [x] Review if we should add more events. --------- Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> Co-authored-by:
Gonçalo Pestana <g6pestana@gmail.com> Co-authored-by:
georgepisaltu <52418509+georgepisaltu@users.noreply.github.com>
parent
e6d934c9
Branches
Pipeline
#474975
waiting for manual action
with stages
in
1 hour, 13 minutes, and 32 seconds
Stage:
Stage:
Stage:
Stage:
Stage:
Stage:
Showing
- Cargo.lock 22 additions, 0 deletionsCargo.lock
- Cargo.toml 1 addition, 0 deletionsCargo.toml
- prdoc/pr_3904.prdoc 19 additions, 0 deletionsprdoc/pr_3904.prdoc
- substrate/frame/delegated-staking/Cargo.toml 69 additions, 0 deletionssubstrate/frame/delegated-staking/Cargo.toml
- substrate/frame/delegated-staking/src/impls.rs 149 additions, 0 deletionssubstrate/frame/delegated-staking/src/impls.rs
- substrate/frame/delegated-staking/src/lib.rs 815 additions, 0 deletionssubstrate/frame/delegated-staking/src/lib.rs
- substrate/frame/delegated-staking/src/mock.rs 308 additions, 0 deletionssubstrate/frame/delegated-staking/src/mock.rs
- substrate/frame/delegated-staking/src/tests.rs 685 additions, 0 deletionssubstrate/frame/delegated-staking/src/tests.rs
- substrate/frame/delegated-staking/src/types.rs 292 additions, 0 deletionssubstrate/frame/delegated-staking/src/types.rs
- substrate/frame/staking/src/lib.rs 1 addition, 1 deletionsubstrate/frame/staking/src/lib.rs
- substrate/primitives/staking/src/lib.rs 119 additions, 0 deletionssubstrate/primitives/staking/src/lib.rs
Please register or sign in to comment