-
Notifications
You must be signed in to change notification settings - Fork 803
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Relayer rewards paid to specified location account #6578
base: master
Are you sure you want to change the base?
Relayer rewards paid to specified location account #6578
Conversation
# Conflicts: # bridges/modules/relayers/src/lib.rs
@claravanstaden Nice! I’m glad you’re starting with this. I’m marking it as part of [this issue](https://github.com/orgs/paritytech/projects/145/views/8?pane=issue&itemId=84899273). I have some ideas on how to make this pallet more generic to cover all our use cases (collecting and claiming rewards regardless of where the messaging queues/pallets are deployed—whether on AH or BH). I believe a single generic I’d like to prepare a more detailed final design for this. How time-sensitive is this for you? What is your deadline? |
Thanks @bkontur, that sounds great! Would We need this functionality in |
stable-2412 has already been branched off since early Nov (see If push comes to shove and it is critical to make this release you could force it in, but then I would not change existing code to avoid introducing regressions that we don't have time to test or catch. |
@claravanstaden actually we are aiming for the |
@acatangiu @bkontur so we are targeting |
@claravanstaden I will definitely look into it deeply this week because I will also need it :) |
// Convert ERC20 token address to a location that can be understood by Assets Hub. | ||
pub fn convert_token_address(network: NetworkId, token: H160) -> Location { | ||
Location::new(2, [GlobalConsensus(network), AccountKey20 { network: None, key: token.into() }]) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is not compatible anymore with native ETH: https://github.com/paritytech/polkadot-sdk/pull/6855/files#diff-5a39b1d9ef60342361183a0aed74e5dae96dad6a973162b59c593705a31e3314R398
// Convert ERC20 token address to a location that can be understood by Assets Hub. | |
pub fn convert_token_address(network: NetworkId, token: H160) -> Location { | |
Location::new(2, [GlobalConsensus(network), AccountKey20 { network: None, key: token.into() }]) | |
} |
@@ -37,6 +45,8 @@ parameter_types! { | |||
pub const RelayerStakeReserveId: [u8; 8] = *b"brdgrlrs"; | |||
|
|||
pub storage DeliveryRewardInBalance: u64 = 1_000_000; | |||
|
|||
pub WethAddress: H160 = H160(hex_literal::hex!("fff9976782d46cc05630d1f6ebab18b2324d6b14")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@claravanstaden what is this fff9976782d46cc05630d1f6ebab18b2324d6b14
? can you please add some comment or how was it generated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bkontur this is the Weth token address on Sepolia: https://sepolia.etherscan.io/address/0xfff9976782d46cc05630d1f6ebab18b2324d6b14
Worth noting we will probably move to rewarding in native ether rather than Weth. The native ether asset location is: parents: 2, GlobalConsensus(network: Ethereum, chainId: 11155111)
.
|
||
use frame_support::pallet_prelude::DispatchResult; | ||
|
||
pub trait RewardLedger<AccountId, Balance> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please move this to the bp-relayers
/// AssetHub parachain ID | ||
type AssetHubParaId: Get<u32>; | ||
type InboundQueuePalletInstance: Get<u8>; | ||
/// Ethereum network ID including the chain ID | ||
type EthereumNetwork: Get<NetworkId>; | ||
/// Message relayers are rewarded with this asset | ||
type WethAddress: Get<H160>; | ||
/// XCM message sender | ||
type XcmSender: SendXcm; | ||
/// To withdraw and deposit an asset. | ||
type AssetTransactor: TransactAsset; | ||
type AssetHubXCMFee: Get<u128>; | ||
type Token: Mutate<Self::AccountId> + Inspect<Self::AccountId>; | ||
/// TreasuryAccount to collect fees | ||
#[pallet::constant] | ||
type TreasuryAccount: Get<Self::AccountId>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to refactor pallet-bridge-relayers
to support multiple rewards,I will prepare issue with step-by-step migration: #7272
/// AssetHub parachain ID | |
type AssetHubParaId: Get<u32>; | |
type InboundQueuePalletInstance: Get<u8>; | |
/// Ethereum network ID including the chain ID | |
type EthereumNetwork: Get<NetworkId>; | |
/// Message relayers are rewarded with this asset | |
type WethAddress: Get<H160>; | |
/// XCM message sender | |
type XcmSender: SendXcm; | |
/// To withdraw and deposit an asset. | |
type AssetTransactor: TransactAsset; | |
type AssetHubXCMFee: Get<u128>; | |
type Token: Mutate<Self::AccountId> + Inspect<Self::AccountId>; | |
/// TreasuryAccount to collect fees | |
#[pallet::constant] | |
type TreasuryAccount: Get<Self::AccountId>; |
|
||
pub trait RewardLedger<AccountId, Balance> { | ||
// Deposit reward which can later be claimed by `account` | ||
fn deposit(account: AccountId, value: Balance) -> DispatchResult; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@claravanstaden can you please point me to the place in Snowbridge pallets where you want to call this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the Inbound and Outbound v2 pallets:
Adds the required functionality for relayers to accumulate and claim rewards.
@bkontur and @acatangiu, I just lifted and shifted the code that was in the snowbridge rewards pallet into the bridge-relayers pallet. I looked at the existing code (to see if I can reuse it) and I think the main shortcoming of the existing
claim_rewards
method is the ability to claim the rewards to destination account location on AH (instead of using the extrinsic origin as destination account). And we won't userewards_account_params
, since we mint Weth on AH. Let me know your thoughts, and which option your prefer: