paritytech / polkadot-sdk

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

Snowbridge V2 - Rewards Pallet #6117

Closed claravanstaden closed 3 weeks ago

claravanstaden commented 4 weeks ago

Description

Adds a rewards pallet, where rewards for relayers will be accumulated. More details in the Snowbridge v2 design: https://github.com/paritytech/polkadot-sdk/blob/master/bridges/snowbridge/docs/v2.md#relayer-rewards

Integration

Since this is a new feature, so it does not affect integration.

Review Notes

TODOs: [ ] Add deposit from Inbound and Outbound queue. [ ] Test XCM [ ] More tests, including integration.

bkontur commented 4 weeks ago

We have a similar pallet here: https://github.com/paritytech/polkadot-sdk/tree/master/bridges/modules/relayers for registering relayers (deposits, slashing) and collecting rewards for relayer accounts.

I'm just curious if we could have a single generic pallet for relayers/rewards that could cover both the P/K bridge, the Eth bridge, or any other possible bridge. That would be cool. Essentially, we need to store the same things:

Some good abstraction over the reward identifier to support both, and using xcm::Asset for the reward could potentially cover everything.

burdges commented 4 weeks ago

As an aside, we do not have grandpa or beefy rewards planned for validators, but if we ever need them then they'd need a median computation, like https://github.com/polkadot-fellows/RFCs/pull/119 does.

claravanstaden commented 3 weeks ago

@bkontur that would definitely be cool, to reuse what is already there. I could see in the future how we also would register relayers and use other functionality in the pallet. Right now we're kind of focused on meeting a tight deadline for v2 and although reusing is a great idea, it usually takes a bit longer to get right since it needs to cater to multiple party's needs. So I think we are going to do the Snowbridge specific pallet (luckily it is very simple) and revisit using your team's pallet in the future.

claravanstaden commented 3 weeks ago

Closing for now, still too WIP and depends on other PRs. Moving the PR to my personal clone: https://github.com/claravanstaden/polkadot-sdk/pull/1