paritytech / polkadot-sdk

The Parity Polkadot Blockchain SDK
https://polkadot.com/
1.92k stars 707 forks source link

Design and implement `pallet-staking-rc-client` #6166

Open gpestana opened 1 month ago

gpestana commented 1 month ago

Design and implement the relay-chain client pallet (i.e. deployed in the staking parachain) that handles i/o from the relay chain, most notably:

New pallet being worked at https://github.com/paritytech/polkadot-sdk/compare/gpestana/staking-rc-client. Opening a PR asap.

Counter-part pallet of pallet-staking-client (https://github.com/paritytech/polkadot-sdk/issues/6167).

### Tasks
- [ ] Design and open fellowship RFC for interactions between AH staking and the relay-chain
- [ ] Implement `pallet-staking-rc-client`

The relay chain and AH staking need to interact with each other over an era in different phases of an election. The communication must be done through XCM and each of functions have different requirements and time/space constraints.

Era rotation and new validator set

The relay-chain does not have the concept of "era". Staking and EPM-MB will run the elections in AH and once a new set of validators is ready, it notifies the relay-chain to change the validator set through XCM. This means that if no election happens within the expected time, the current validator set will remain active in the relay-chain.

Register/unregister validator keys

Currently, the session pallet in the relay-chain exposes Call::set_keys and Call::purge_keys for wannabe validators to set/unset their session keys. With AH staking, these extrinsics should be exposed in the pallet-staking-rc-client (or in the pallet-staking). This information should be propagated through XCM to the pallet-staking-client in the relay chain with a similar behaviour as currently (i.e. set_keys will be placed in the NextKeys storage, etc).

Block producing era points

Currently, the staking pallet implements the pallet_authorship::EventHandler to receive the era points of a block author for the current session. As similar interface must be implemented with XCM as i/o instead.

Given the potential delays in calling and propagating EventHandler::reward_by_ids between rc and AH, the reward payout may be done only after era+1 ("era" being the active era of the validator).

Offences

There are 2 types of offence reports currently, implicit and explicit. The implicit offences are generated in the relay chain and should be propagated to AH staking for slashing. The explicit (i.e. signed offences) are reported by signed origins through an extrinsic. This extrinsic should be implemented in the pallet-staking-rc-client (i.e. in AH) and relayed to the relay chain with XCM.

The relay chain should implement a thin disablement layer to ensure that the implicit offences result in a timely validator disablement in the relay-chain without having to wait for the RC -> AH -> RC XCM message passing.

gpestana commented 1 month ago

Being worked at https://github.com/paritytech/polkadot-sdk/compare/gpestana/staking-rc-client

EDIT: PR open https://github.com/paritytech/polkadot-sdk/pull/6259

Ank4n commented 2 weeks ago

I was thinking we could have only one pallet for both chains, this (AH) and RC since they need to work well together. Then both can be configured to act as Session Client (AH) or Staking Client (RC). Wdyt?