mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 02:51:08 +00:00
Polkadot <> Kusama relayers (#1122)
* relay headers between Kusama and Polkadot * relay messages between Kusama and Polkadot * complex Kusama <> Polkadot relayer * expose relayer_fund_account_id from messages pallet * create relayers fund accounts on Kusama/Polkadot + some more fixes * fmt * fix compilation * compilation + clippy * compilation * MAXIMAL_BALANCE_DECREASE_PER_DAY for K<>P header relays * fmt * deduplicate tests * Update modules/messages/src/lib.rs Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com> * extract storage_parameter_key function * other grumbles * fix * fmt Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com>
This commit is contained in:
committed by
Bastian Köcher
parent
417903f9e7
commit
2db84b74cc
@@ -64,7 +64,8 @@ use frame_support::{
|
||||
};
|
||||
use frame_system::RawOrigin;
|
||||
use num_traits::{SaturatingAdd, Zero};
|
||||
use sp_runtime::traits::BadOrigin;
|
||||
use sp_core::H256;
|
||||
use sp_runtime::traits::{BadOrigin, Convert};
|
||||
use sp_std::{cell::RefCell, cmp::PartialOrd, marker::PhantomData, prelude::*};
|
||||
|
||||
mod inbound_lane;
|
||||
@@ -286,16 +287,17 @@ pub mod pallet {
|
||||
T::MessageDeliveryAndDispatchPayment::pay_delivery_and_dispatch_fee(
|
||||
&submitter,
|
||||
&additional_fee,
|
||||
&Self::relayer_fund_account_id(),
|
||||
&relayer_fund_account_id::<T::AccountId, T::AccountIdConverter>(),
|
||||
)
|
||||
.map_err(|err| {
|
||||
log::trace!(
|
||||
target: "runtime::bridge-messages",
|
||||
"Submitter {:?} can't pay additional fee {:?} for the message {:?}/{:?}: {:?}",
|
||||
"Submitter {:?} can't pay additional fee {:?} for the message {:?}/{:?} to {:?}: {:?}",
|
||||
submitter,
|
||||
additional_fee,
|
||||
lane_id,
|
||||
nonce,
|
||||
relayer_fund_account_id::<T::AccountId, T::AccountIdConverter>(),
|
||||
err,
|
||||
);
|
||||
|
||||
@@ -604,7 +606,7 @@ pub mod pallet {
|
||||
|
||||
// if some new messages have been confirmed, reward relayers
|
||||
if !relayers_rewards.is_empty() {
|
||||
let relayer_fund_account = Self::relayer_fund_account_id();
|
||||
let relayer_fund_account = relayer_fund_account_id::<T::AccountId, T::AccountIdConverter>();
|
||||
<T as Config<I>>::MessageDeliveryAndDispatchPayment::pay_relayers_rewards(
|
||||
&confirmation_relayer,
|
||||
relayers_rewards,
|
||||
@@ -768,17 +770,6 @@ pub mod pallet {
|
||||
total_messages: total_unrewarded_messages(&relayers).unwrap_or(MessageNonce::MAX),
|
||||
}
|
||||
}
|
||||
|
||||
/// AccountId of the shared relayer fund account.
|
||||
///
|
||||
/// This account is passed to `MessageDeliveryAndDispatchPayment` trait, and depending
|
||||
/// on the implementation it can be used to store relayers rewards.
|
||||
/// See [InstantCurrencyPayments] for a concrete implementation.
|
||||
pub fn relayer_fund_account_id() -> T::AccountId {
|
||||
use sp_runtime::traits::Convert;
|
||||
let encoded_id = bp_runtime::derive_relayer_fund_account_id(bp_runtime::NO_INSTANCE_ID);
|
||||
T::AccountIdConverter::convert(encoded_id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -825,6 +816,16 @@ pub mod storage_keys {
|
||||
}
|
||||
}
|
||||
|
||||
/// AccountId of the shared relayer fund account.
|
||||
///
|
||||
/// This account is passed to `MessageDeliveryAndDispatchPayment` trait, and depending
|
||||
/// on the implementation it can be used to store relayers rewards.
|
||||
/// See [`InstantCurrencyPayments`] for a concrete implementation.
|
||||
pub fn relayer_fund_account_id<AccountId, AccountIdConverter: Convert<H256, AccountId>>() -> AccountId {
|
||||
let encoded_id = bp_runtime::derive_relayer_fund_account_id(bp_runtime::NO_INSTANCE_ID);
|
||||
AccountIdConverter::convert(encoded_id)
|
||||
}
|
||||
|
||||
impl<T, I> bp_messages::source_chain::MessagesBridge<T::AccountId, T::OutboundMessageFee, T::OutboundPayload>
|
||||
for Pallet<T, I>
|
||||
where
|
||||
@@ -894,7 +895,7 @@ fn send_message<T: Config<I>, I: 'static>(
|
||||
T::MessageDeliveryAndDispatchPayment::pay_delivery_and_dispatch_fee(
|
||||
&submitter,
|
||||
&delivery_and_dispatch_fee,
|
||||
&Pallet::<T, I>::relayer_fund_account_id(),
|
||||
&relayer_fund_account_id::<T::AccountId, T::AccountIdConverter>(),
|
||||
)
|
||||
.map_err(|err| {
|
||||
log::trace!(
|
||||
|
||||
Reference in New Issue
Block a user