mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 17:01:09 +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
@@ -484,7 +484,7 @@ benchmarks_instance_pallet! {
|
||||
//
|
||||
// This is base benchmark for all other confirmations delivery benchmarks.
|
||||
receive_delivery_proof_for_single_message {
|
||||
let relayers_fund_id = crate::Pallet::<T, I>::relayer_fund_account_id();
|
||||
let relayers_fund_id = crate::relayer_fund_account_id::<T::AccountId, T::AccountIdConverter>();
|
||||
let relayer_id: T::AccountId = account("relayer", 0, SEED);
|
||||
let relayer_balance = T::account_balance(&relayer_id);
|
||||
T::endow_account(&relayers_fund_id);
|
||||
@@ -524,7 +524,7 @@ benchmarks_instance_pallet! {
|
||||
// as `weight(receive_delivery_proof_for_two_messages_by_single_relayer)
|
||||
// - weight(receive_delivery_proof_for_single_message)`.
|
||||
receive_delivery_proof_for_two_messages_by_single_relayer {
|
||||
let relayers_fund_id = crate::Pallet::<T, I>::relayer_fund_account_id();
|
||||
let relayers_fund_id = crate::relayer_fund_account_id::<T::AccountId, T::AccountIdConverter>();
|
||||
let relayer_id: T::AccountId = account("relayer", 0, SEED);
|
||||
let relayer_balance = T::account_balance(&relayer_id);
|
||||
T::endow_account(&relayers_fund_id);
|
||||
@@ -564,7 +564,7 @@ benchmarks_instance_pallet! {
|
||||
// as `weight(receive_delivery_proof_for_two_messages_by_two_relayers)
|
||||
// - weight(receive_delivery_proof_for_two_messages_by_single_relayer)`.
|
||||
receive_delivery_proof_for_two_messages_by_two_relayers {
|
||||
let relayers_fund_id = crate::Pallet::<T, I>::relayer_fund_account_id();
|
||||
let relayers_fund_id = crate::relayer_fund_account_id::<T::AccountId, T::AccountIdConverter>();
|
||||
let relayer1_id: T::AccountId = account("relayer1", 1, SEED);
|
||||
let relayer1_balance = T::account_balance(&relayer1_id);
|
||||
let relayer2_id: T::AccountId = account("relayer2", 2, SEED);
|
||||
@@ -811,7 +811,7 @@ benchmarks_instance_pallet! {
|
||||
.try_into()
|
||||
.expect("Value of MaxUnrewardedRelayerEntriesAtInboundLane is too large");
|
||||
|
||||
let relayers_fund_id = crate::Pallet::<T, I>::relayer_fund_account_id();
|
||||
let relayers_fund_id = crate::relayer_fund_account_id::<T::AccountId, T::AccountIdConverter>();
|
||||
let relayer_id: T::AccountId = account("relayer", 0, SEED);
|
||||
let relayer_balance = T::account_balance(&relayer_id);
|
||||
T::endow_account(&relayers_fund_id);
|
||||
@@ -854,7 +854,7 @@ benchmarks_instance_pallet! {
|
||||
.try_into()
|
||||
.expect("Value of MaxUnconfirmedMessagesAtInboundLane is too large ");
|
||||
|
||||
let relayers_fund_id = crate::Pallet::<T, I>::relayer_fund_account_id();
|
||||
let relayers_fund_id = crate::relayer_fund_account_id::<T::AccountId, T::AccountIdConverter>();
|
||||
let confirmation_relayer_id = account("relayer", 0, SEED);
|
||||
let relayers: BTreeMap<T::AccountId, T::OutboundMessageFee> = (1..=i)
|
||||
.map(|j| {
|
||||
|
||||
@@ -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