paritytech / polkadot-sdk

The Parity Polkadot Blockchain SDK
https://polkadot.network/
1.63k stars 570 forks source link

[Pools] Build a pool slashing monitoring bot to apply pending slashes to the affected pool members. #4630

Open Ank4n opened 1 month ago

Ank4n commented 1 month ago

Related to: https://github.com/paritytech/polkadot-sdk/issues/454 | https://github.com/paritytech/polkadot-sdk/pull/4537

Nomination Pools currently work with a Transfer and Stake strategy, i.e. members transfer their funds to a pool account, and pool stakes. With https://github.com/paritytech/polkadot-sdk/pull/4537, we are moving to a Delegate and Stake strategy where funds remain in member account, delegated to pool account, and pool account can use these delegated funds to it to stake.

Since number of pool members are unbounded, eager slashing as before becomes unfeasible. Therefore, along with this change, we are also moving to a lazy slashing mechanism. When there is a slash, it is book kept in a register of the Agent (pool) account. There is a permissionless extrinsic Pools::apply_slash() to apply pending slash to a member by calculating how much balance the member is expected to have and what they actually have, slashing the difference. The reporter also gets a cut from the slashed funds.

We need a bot that monitors slashing events for pool accounts, and when there is a slash, it applies slash to all affected members. There are runtime apis that can help with determining which members need slash.

In future, there will hopefully be multiple bots from community monitoring this (since there is an incentive to apply pending slash).

Ank4n commented 1 month ago

We could very well use tasks and OCW for this (thanks @mordamax for the suggestion).

mustermeiszer commented 1 week ago

@Ank4n We are also very interested in running Tasks+OffchainWorkers in combination. What are the plans to stabilize this feature?

bkchr commented 1 week ago

We need a bot that monitors slashing events for pool accounts, and when there is a slash, it applies slash to all affected members. There are runtime apis that can help with determining which members need slash.

Wait. What happens otherwise if the slash is not applied? Would they be able to withdraw their funds without a slash? Would they be able to continue voting with their full balance?