mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-17 20:41:02 +00:00
remove account derivation functions (#1498)
This commit is contained in:
committed by
Bastian Köcher
parent
d327b25724
commit
ceefd1b05d
@@ -461,8 +461,6 @@ impl pallet_bridge_messages::Config<WithRialtoMessagesInstance> for Runtime {
|
|||||||
type InboundMessageFee = bp_rialto::Balance;
|
type InboundMessageFee = bp_rialto::Balance;
|
||||||
type InboundRelayer = bp_rialto::AccountId;
|
type InboundRelayer = bp_rialto::AccountId;
|
||||||
|
|
||||||
type AccountIdConverter = bp_millau::AccountIdConverter;
|
|
||||||
|
|
||||||
type TargetHeaderChain = crate::rialto_messages::Rialto;
|
type TargetHeaderChain = crate::rialto_messages::Rialto;
|
||||||
type LaneMessageVerifier = crate::rialto_messages::ToRialtoMessageVerifier;
|
type LaneMessageVerifier = crate::rialto_messages::ToRialtoMessageVerifier;
|
||||||
type MessageDeliveryAndDispatchPayment = ();
|
type MessageDeliveryAndDispatchPayment = ();
|
||||||
@@ -494,8 +492,6 @@ impl pallet_bridge_messages::Config<WithRialtoParachainMessagesInstance> for Run
|
|||||||
type InboundMessageFee = bp_rialto_parachain::Balance;
|
type InboundMessageFee = bp_rialto_parachain::Balance;
|
||||||
type InboundRelayer = bp_rialto_parachain::AccountId;
|
type InboundRelayer = bp_rialto_parachain::AccountId;
|
||||||
|
|
||||||
type AccountIdConverter = bp_millau::AccountIdConverter;
|
|
||||||
|
|
||||||
type TargetHeaderChain = crate::rialto_parachain_messages::RialtoParachain;
|
type TargetHeaderChain = crate::rialto_parachain_messages::RialtoParachain;
|
||||||
type LaneMessageVerifier = crate::rialto_parachain_messages::ToRialtoParachainMessageVerifier;
|
type LaneMessageVerifier = crate::rialto_parachain_messages::ToRialtoParachainMessageVerifier;
|
||||||
type MessageDeliveryAndDispatchPayment = ();
|
type MessageDeliveryAndDispatchPayment = ();
|
||||||
|
|||||||
@@ -371,7 +371,6 @@ mod tests {
|
|||||||
bridge: WithRialtoMessageBridge,
|
bridge: WithRialtoMessageBridge,
|
||||||
this_chain: bp_millau::Millau,
|
this_chain: bp_millau::Millau,
|
||||||
bridged_chain: bp_rialto::Rialto,
|
bridged_chain: bp_rialto::Rialto,
|
||||||
this_chain_account_id_converter: bp_millau::AccountIdConverter
|
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_complete_bridge_constants::<
|
assert_complete_bridge_constants::<
|
||||||
|
|||||||
@@ -528,8 +528,6 @@ impl pallet_bridge_messages::Config<WithMillauMessagesInstance> for Runtime {
|
|||||||
type InboundMessageFee = bp_millau::Balance;
|
type InboundMessageFee = bp_millau::Balance;
|
||||||
type InboundRelayer = bp_millau::AccountId;
|
type InboundRelayer = bp_millau::AccountId;
|
||||||
|
|
||||||
type AccountIdConverter = bp_rialto_parachain::AccountIdConverter;
|
|
||||||
|
|
||||||
type TargetHeaderChain = crate::millau_messages::Millau;
|
type TargetHeaderChain = crate::millau_messages::Millau;
|
||||||
type LaneMessageVerifier = crate::millau_messages::ToMillauMessageVerifier;
|
type LaneMessageVerifier = crate::millau_messages::ToMillauMessageVerifier;
|
||||||
type MessageDeliveryAndDispatchPayment = ();
|
type MessageDeliveryAndDispatchPayment = ();
|
||||||
|
|||||||
@@ -445,8 +445,6 @@ impl pallet_bridge_messages::Config<WithMillauMessagesInstance> for Runtime {
|
|||||||
type InboundMessageFee = bp_millau::Balance;
|
type InboundMessageFee = bp_millau::Balance;
|
||||||
type InboundRelayer = bp_millau::AccountId;
|
type InboundRelayer = bp_millau::AccountId;
|
||||||
|
|
||||||
type AccountIdConverter = bp_rialto::AccountIdConverter;
|
|
||||||
|
|
||||||
type TargetHeaderChain = crate::millau_messages::Millau;
|
type TargetHeaderChain = crate::millau_messages::Millau;
|
||||||
type LaneMessageVerifier = crate::millau_messages::ToMillauMessageVerifier;
|
type LaneMessageVerifier = crate::millau_messages::ToMillauMessageVerifier;
|
||||||
type MessageDeliveryAndDispatchPayment = ();
|
type MessageDeliveryAndDispatchPayment = ();
|
||||||
|
|||||||
@@ -368,7 +368,6 @@ mod tests {
|
|||||||
bridge: WithMillauMessageBridge,
|
bridge: WithMillauMessageBridge,
|
||||||
this_chain: bp_rialto::Rialto,
|
this_chain: bp_rialto::Rialto,
|
||||||
bridged_chain: bp_millau::Millau,
|
bridged_chain: bp_millau::Millau,
|
||||||
this_chain_account_id_converter: bp_rialto::AccountIdConverter
|
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_complete_bridge_constants::<
|
assert_complete_bridge_constants::<
|
||||||
|
|||||||
@@ -105,8 +105,7 @@ macro_rules! assert_bridge_messages_pallet_types(
|
|||||||
(
|
(
|
||||||
runtime: $r:path,
|
runtime: $r:path,
|
||||||
with_bridged_chain_messages_instance: $i:path,
|
with_bridged_chain_messages_instance: $i:path,
|
||||||
bridge: $bridge:path,
|
bridge: $bridge:path
|
||||||
this_chain_account_id_converter: $this_converter:path
|
|
||||||
) => {
|
) => {
|
||||||
{
|
{
|
||||||
// if one of asserts fail, then either bridge isn't configured properly (or alternatively - non-standard
|
// if one of asserts fail, then either bridge isn't configured properly (or alternatively - non-standard
|
||||||
@@ -127,8 +126,6 @@ macro_rules! assert_bridge_messages_pallet_types(
|
|||||||
assert_type_eq_all!(<$r as MessagesConfig<$i>>::InboundMessageFee, BalanceOf<BridgedChain<$bridge>>);
|
assert_type_eq_all!(<$r as MessagesConfig<$i>>::InboundMessageFee, BalanceOf<BridgedChain<$bridge>>);
|
||||||
assert_type_eq_all!(<$r as MessagesConfig<$i>>::InboundRelayer, AccountIdOf<BridgedChain<$bridge>>);
|
assert_type_eq_all!(<$r as MessagesConfig<$i>>::InboundRelayer, AccountIdOf<BridgedChain<$bridge>>);
|
||||||
|
|
||||||
assert_type_eq_all!(<$r as MessagesConfig<$i>>::AccountIdConverter, $this_converter);
|
|
||||||
|
|
||||||
assert_type_eq_all!(<$r as MessagesConfig<$i>>::TargetHeaderChain, BridgedChain<$bridge>);
|
assert_type_eq_all!(<$r as MessagesConfig<$i>>::TargetHeaderChain, BridgedChain<$bridge>);
|
||||||
assert_type_eq_all!(<$r as MessagesConfig<$i>>::SourceHeaderChain, BridgedChain<$bridge>);
|
assert_type_eq_all!(<$r as MessagesConfig<$i>>::SourceHeaderChain, BridgedChain<$bridge>);
|
||||||
}
|
}
|
||||||
@@ -148,7 +145,6 @@ macro_rules! assert_complete_bridge_types(
|
|||||||
bridge: $bridge:path,
|
bridge: $bridge:path,
|
||||||
this_chain: $this:path,
|
this_chain: $this:path,
|
||||||
bridged_chain: $bridged:path,
|
bridged_chain: $bridged:path,
|
||||||
this_chain_account_id_converter: $this_converter:path
|
|
||||||
) => {
|
) => {
|
||||||
$crate::assert_chain_types!(runtime: $r, this_chain: $this);
|
$crate::assert_chain_types!(runtime: $r, this_chain: $this);
|
||||||
$crate::assert_bridge_types!(bridge: $bridge, this_chain: $this, bridged_chain: $bridged);
|
$crate::assert_bridge_types!(bridge: $bridge, this_chain: $this, bridged_chain: $bridged);
|
||||||
@@ -160,8 +156,7 @@ macro_rules! assert_complete_bridge_types(
|
|||||||
$crate::assert_bridge_messages_pallet_types!(
|
$crate::assert_bridge_messages_pallet_types!(
|
||||||
runtime: $r,
|
runtime: $r,
|
||||||
with_bridged_chain_messages_instance: $mi,
|
with_bridged_chain_messages_instance: $mi,
|
||||||
bridge: $bridge,
|
bridge: $bridge
|
||||||
this_chain_account_id_converter: $this_converter
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -126,10 +126,8 @@ benchmarks_instance_pallet! {
|
|||||||
// added.
|
// added.
|
||||||
send_minimal_message_worst_case {
|
send_minimal_message_worst_case {
|
||||||
let lane_id = T::bench_lane_id();
|
let lane_id = T::bench_lane_id();
|
||||||
let relayers_fund_id = crate::relayer_fund_account_id::<T::AccountId, T::AccountIdConverter>();
|
|
||||||
let sender = account("sender", 0, SEED);
|
let sender = account("sender", 0, SEED);
|
||||||
T::endow_account(&sender);
|
T::endow_account(&sender);
|
||||||
T::endow_account(&relayers_fund_id);
|
|
||||||
|
|
||||||
// 'send' messages that are to be pruned when our message is sent
|
// 'send' messages that are to be pruned when our message is sent
|
||||||
for _nonce in 1..=T::MaxMessagesToPruneAtOnce::get() {
|
for _nonce in 1..=T::MaxMessagesToPruneAtOnce::get() {
|
||||||
@@ -159,10 +157,8 @@ benchmarks_instance_pallet! {
|
|||||||
// `(send_16_kb_message_worst_case - send_1_kb_message_worst_case) / 15`.
|
// `(send_16_kb_message_worst_case - send_1_kb_message_worst_case) / 15`.
|
||||||
send_1_kb_message_worst_case {
|
send_1_kb_message_worst_case {
|
||||||
let lane_id = T::bench_lane_id();
|
let lane_id = T::bench_lane_id();
|
||||||
let relayers_fund_id = crate::relayer_fund_account_id::<T::AccountId, T::AccountIdConverter>();
|
|
||||||
let sender = account("sender", 0, SEED);
|
let sender = account("sender", 0, SEED);
|
||||||
T::endow_account(&sender);
|
T::endow_account(&sender);
|
||||||
T::endow_account(&relayers_fund_id);
|
|
||||||
|
|
||||||
// 'send' messages that are to be pruned when our message is sent
|
// 'send' messages that are to be pruned when our message is sent
|
||||||
for _nonce in 1..=T::MaxMessagesToPruneAtOnce::get() {
|
for _nonce in 1..=T::MaxMessagesToPruneAtOnce::get() {
|
||||||
@@ -198,10 +194,8 @@ benchmarks_instance_pallet! {
|
|||||||
// `(send_16_kb_message_worst_case - send_1_kb_message_worst_case) / 15`.
|
// `(send_16_kb_message_worst_case - send_1_kb_message_worst_case) / 15`.
|
||||||
send_16_kb_message_worst_case {
|
send_16_kb_message_worst_case {
|
||||||
let lane_id = T::bench_lane_id();
|
let lane_id = T::bench_lane_id();
|
||||||
let relayers_fund_id = crate::relayer_fund_account_id::<T::AccountId, T::AccountIdConverter>();
|
|
||||||
let sender = account("sender", 0, SEED);
|
let sender = account("sender", 0, SEED);
|
||||||
T::endow_account(&sender);
|
T::endow_account(&sender);
|
||||||
T::endow_account(&relayers_fund_id);
|
|
||||||
|
|
||||||
// 'send' messages that are to be pruned when our message is sent
|
// 'send' messages that are to be pruned when our message is sent
|
||||||
for _nonce in 1..=T::MaxMessagesToPruneAtOnce::get() {
|
for _nonce in 1..=T::MaxMessagesToPruneAtOnce::get() {
|
||||||
@@ -233,10 +227,8 @@ benchmarks_instance_pallet! {
|
|||||||
//
|
//
|
||||||
// Result of this benchmark is directly used by weight formula of the call.
|
// Result of this benchmark is directly used by weight formula of the call.
|
||||||
maximal_increase_message_fee {
|
maximal_increase_message_fee {
|
||||||
let relayers_fund_id = crate::relayer_fund_account_id::<T::AccountId, T::AccountIdConverter>();
|
|
||||||
let sender = account("sender", 42, SEED);
|
let sender = account("sender", 42, SEED);
|
||||||
T::endow_account(&sender);
|
T::endow_account(&sender);
|
||||||
T::endow_account(&relayers_fund_id);
|
|
||||||
|
|
||||||
let additional_fee = T::account_balance(&sender);
|
let additional_fee = T::account_balance(&sender);
|
||||||
let lane_id = T::bench_lane_id();
|
let lane_id = T::bench_lane_id();
|
||||||
@@ -257,10 +249,8 @@ benchmarks_instance_pallet! {
|
|||||||
increase_message_fee {
|
increase_message_fee {
|
||||||
let i in 0..T::maximal_message_size().try_into().unwrap_or_default();
|
let i in 0..T::maximal_message_size().try_into().unwrap_or_default();
|
||||||
|
|
||||||
let relayers_fund_id = crate::relayer_fund_account_id::<T::AccountId, T::AccountIdConverter>();
|
|
||||||
let sender = account("sender", 42, SEED);
|
let sender = account("sender", 42, SEED);
|
||||||
T::endow_account(&sender);
|
T::endow_account(&sender);
|
||||||
T::endow_account(&relayers_fund_id);
|
|
||||||
|
|
||||||
let additional_fee = T::account_balance(&sender);
|
let additional_fee = T::account_balance(&sender);
|
||||||
let lane_id = T::bench_lane_id();
|
let lane_id = T::bench_lane_id();
|
||||||
@@ -488,10 +478,8 @@ benchmarks_instance_pallet! {
|
|||||||
//
|
//
|
||||||
// This is base benchmark for all other confirmations delivery benchmarks.
|
// This is base benchmark for all other confirmations delivery benchmarks.
|
||||||
receive_delivery_proof_for_single_message {
|
receive_delivery_proof_for_single_message {
|
||||||
let relayers_fund_id = crate::relayer_fund_account_id::<T::AccountId, T::AccountIdConverter>();
|
|
||||||
let relayer_id: T::AccountId = account("relayer", 0, SEED);
|
let relayer_id: T::AccountId = account("relayer", 0, SEED);
|
||||||
let relayer_balance = T::account_balance(&relayer_id);
|
let relayer_balance = T::account_balance(&relayer_id);
|
||||||
T::endow_account(&relayers_fund_id);
|
|
||||||
|
|
||||||
// send message that we're going to confirm
|
// send message that we're going to confirm
|
||||||
send_regular_message::<T, I>();
|
send_regular_message::<T, I>();
|
||||||
@@ -526,10 +514,8 @@ benchmarks_instance_pallet! {
|
|||||||
// as `weight(receive_delivery_proof_for_two_messages_by_single_relayer)
|
// as `weight(receive_delivery_proof_for_two_messages_by_single_relayer)
|
||||||
// - weight(receive_delivery_proof_for_single_message)`.
|
// - weight(receive_delivery_proof_for_single_message)`.
|
||||||
receive_delivery_proof_for_two_messages_by_single_relayer {
|
receive_delivery_proof_for_two_messages_by_single_relayer {
|
||||||
let relayers_fund_id = crate::relayer_fund_account_id::<T::AccountId, T::AccountIdConverter>();
|
|
||||||
let relayer_id: T::AccountId = account("relayer", 0, SEED);
|
let relayer_id: T::AccountId = account("relayer", 0, SEED);
|
||||||
let relayer_balance = T::account_balance(&relayer_id);
|
let relayer_balance = T::account_balance(&relayer_id);
|
||||||
T::endow_account(&relayers_fund_id);
|
|
||||||
|
|
||||||
// send message that we're going to confirm
|
// send message that we're going to confirm
|
||||||
send_regular_message::<T, I>();
|
send_regular_message::<T, I>();
|
||||||
@@ -567,12 +553,10 @@ benchmarks_instance_pallet! {
|
|||||||
// as `weight(receive_delivery_proof_for_two_messages_by_two_relayers)
|
// as `weight(receive_delivery_proof_for_two_messages_by_two_relayers)
|
||||||
// - weight(receive_delivery_proof_for_two_messages_by_single_relayer)`.
|
// - weight(receive_delivery_proof_for_two_messages_by_single_relayer)`.
|
||||||
receive_delivery_proof_for_two_messages_by_two_relayers {
|
receive_delivery_proof_for_two_messages_by_two_relayers {
|
||||||
let relayers_fund_id = crate::relayer_fund_account_id::<T::AccountId, T::AccountIdConverter>();
|
|
||||||
let relayer1_id: T::AccountId = account("relayer1", 1, SEED);
|
let relayer1_id: T::AccountId = account("relayer1", 1, SEED);
|
||||||
let relayer1_balance = T::account_balance(&relayer1_id);
|
let relayer1_balance = T::account_balance(&relayer1_id);
|
||||||
let relayer2_id: T::AccountId = account("relayer2", 2, SEED);
|
let relayer2_id: T::AccountId = account("relayer2", 2, SEED);
|
||||||
let relayer2_balance = T::account_balance(&relayer2_id);
|
let relayer2_balance = T::account_balance(&relayer2_id);
|
||||||
T::endow_account(&relayers_fund_id);
|
|
||||||
|
|
||||||
// send message that we're going to confirm
|
// send message that we're going to confirm
|
||||||
send_regular_message::<T, I>();
|
send_regular_message::<T, I>();
|
||||||
|
|||||||
@@ -71,8 +71,6 @@ use frame_support::{
|
|||||||
weights::{Pays, PostDispatchInfo},
|
weights::{Pays, PostDispatchInfo},
|
||||||
};
|
};
|
||||||
use num_traits::{SaturatingAdd, Zero};
|
use num_traits::{SaturatingAdd, Zero};
|
||||||
use sp_core::H256;
|
|
||||||
use sp_runtime::traits::Convert;
|
|
||||||
use sp_std::{
|
use sp_std::{
|
||||||
cell::RefCell, cmp::PartialOrd, collections::vec_deque::VecDeque, marker::PhantomData,
|
cell::RefCell, cmp::PartialOrd, collections::vec_deque::VecDeque, marker::PhantomData,
|
||||||
ops::RangeInclusive, prelude::*,
|
ops::RangeInclusive, prelude::*,
|
||||||
@@ -170,11 +168,6 @@ pub mod pallet {
|
|||||||
/// bridged chain.
|
/// bridged chain.
|
||||||
type InboundRelayer: Parameter + MaxEncodedLen;
|
type InboundRelayer: Parameter + MaxEncodedLen;
|
||||||
|
|
||||||
/// A type which can be turned into an AccountId from a 256-bit hash.
|
|
||||||
///
|
|
||||||
/// Used when deriving the shared relayer fund account.
|
|
||||||
type AccountIdConverter: sp_runtime::traits::Convert<sp_core::hash::H256, Self::AccountId>;
|
|
||||||
|
|
||||||
// Types that are used by outbound_lane (on source chain).
|
// Types that are used by outbound_lane (on source chain).
|
||||||
|
|
||||||
/// Target header chain.
|
/// Target header chain.
|
||||||
@@ -313,16 +306,14 @@ pub mod pallet {
|
|||||||
T::MessageDeliveryAndDispatchPayment::pay_delivery_and_dispatch_fee(
|
T::MessageDeliveryAndDispatchPayment::pay_delivery_and_dispatch_fee(
|
||||||
&origin,
|
&origin,
|
||||||
&additional_fee,
|
&additional_fee,
|
||||||
&relayer_fund_account_id::<T::AccountId, T::AccountIdConverter>(),
|
|
||||||
)
|
)
|
||||||
.map_err(|err| {
|
.map_err(|err| {
|
||||||
log::trace!(
|
log::trace!(
|
||||||
target: LOG_TARGET,
|
target: LOG_TARGET,
|
||||||
"Submitter can't pay additional fee {:?} for the message {:?}/{:?} to {:?}: {:?}",
|
"Submitter can't pay additional fee {:?} for the message {:?}/{:?}: {:?}",
|
||||||
additional_fee,
|
additional_fee,
|
||||||
lane_id,
|
lane_id,
|
||||||
nonce,
|
nonce,
|
||||||
relayer_fund_account_id::<T::AccountId, T::AccountIdConverter>(),
|
|
||||||
err,
|
err,
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -629,14 +620,11 @@ pub mod pallet {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// if some new messages have been confirmed, reward relayers
|
// if some new messages have been confirmed, reward relayers
|
||||||
let relayer_fund_account =
|
|
||||||
relayer_fund_account_id::<T::AccountId, T::AccountIdConverter>();
|
|
||||||
<T as Config<I>>::MessageDeliveryAndDispatchPayment::pay_relayers_rewards(
|
<T as Config<I>>::MessageDeliveryAndDispatchPayment::pay_relayers_rewards(
|
||||||
lane_id,
|
lane_id,
|
||||||
lane_data.relayers,
|
lane_data.relayers,
|
||||||
&confirmation_relayer,
|
&confirmation_relayer,
|
||||||
&received_range,
|
&received_range,
|
||||||
&relayer_fund_account,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -787,16 +775,6 @@ pub mod pallet {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 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.
|
|
||||||
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>
|
impl<T, I>
|
||||||
bp_messages::source_chain::MessagesBridge<
|
bp_messages::source_chain::MessagesBridge<
|
||||||
T::Origin,
|
T::Origin,
|
||||||
@@ -877,7 +855,6 @@ fn send_message<T: Config<I>, I: 'static>(
|
|||||||
T::MessageDeliveryAndDispatchPayment::pay_delivery_and_dispatch_fee(
|
T::MessageDeliveryAndDispatchPayment::pay_delivery_and_dispatch_fee(
|
||||||
&submitter,
|
&submitter,
|
||||||
&delivery_and_dispatch_fee,
|
&delivery_and_dispatch_fee,
|
||||||
&relayer_fund_account_id::<T::AccountId, T::AccountIdConverter>(),
|
|
||||||
)
|
)
|
||||||
.map_err(|err| {
|
.map_err(|err| {
|
||||||
log::trace!(
|
log::trace!(
|
||||||
|
|||||||
@@ -68,14 +68,6 @@ pub struct TestPayload {
|
|||||||
pub type TestMessageFee = u64;
|
pub type TestMessageFee = u64;
|
||||||
pub type TestRelayer = u64;
|
pub type TestRelayer = u64;
|
||||||
|
|
||||||
pub struct AccountIdConverter;
|
|
||||||
|
|
||||||
impl sp_runtime::traits::Convert<H256, AccountId> for AccountIdConverter {
|
|
||||||
fn convert(hash: H256) -> AccountId {
|
|
||||||
hash.to_low_u64_ne()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
type Block = frame_system::mocking::MockBlock<TestRuntime>;
|
type Block = frame_system::mocking::MockBlock<TestRuntime>;
|
||||||
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<TestRuntime>;
|
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<TestRuntime>;
|
||||||
|
|
||||||
@@ -182,8 +174,6 @@ impl Config for TestRuntime {
|
|||||||
type InboundMessageFee = TestMessageFee;
|
type InboundMessageFee = TestMessageFee;
|
||||||
type InboundRelayer = TestRelayer;
|
type InboundRelayer = TestRelayer;
|
||||||
|
|
||||||
type AccountIdConverter = AccountIdConverter;
|
|
||||||
|
|
||||||
type TargetHeaderChain = TestTargetHeaderChain;
|
type TargetHeaderChain = TestTargetHeaderChain;
|
||||||
type LaneMessageVerifier = TestLaneMessageVerifier;
|
type LaneMessageVerifier = TestLaneMessageVerifier;
|
||||||
type MessageDeliveryAndDispatchPayment = TestMessageDeliveryAndDispatchPayment;
|
type MessageDeliveryAndDispatchPayment = TestMessageDeliveryAndDispatchPayment;
|
||||||
@@ -360,7 +350,6 @@ impl MessageDeliveryAndDispatchPayment<Origin, AccountId, TestMessageFee>
|
|||||||
fn pay_delivery_and_dispatch_fee(
|
fn pay_delivery_and_dispatch_fee(
|
||||||
submitter: &Origin,
|
submitter: &Origin,
|
||||||
fee: &TestMessageFee,
|
fee: &TestMessageFee,
|
||||||
_relayer_fund_account: &AccountId,
|
|
||||||
) -> Result<(), Self::Error> {
|
) -> Result<(), Self::Error> {
|
||||||
if frame_support::storage::unhashed::get(b":reject-message-fee:") == Some(true) {
|
if frame_support::storage::unhashed::get(b":reject-message-fee:") == Some(true) {
|
||||||
return Err(TEST_ERROR)
|
return Err(TEST_ERROR)
|
||||||
@@ -376,7 +365,6 @@ impl MessageDeliveryAndDispatchPayment<Origin, AccountId, TestMessageFee>
|
|||||||
message_relayers: VecDeque<UnrewardedRelayer<AccountId>>,
|
message_relayers: VecDeque<UnrewardedRelayer<AccountId>>,
|
||||||
_confirmation_relayer: &AccountId,
|
_confirmation_relayer: &AccountId,
|
||||||
received_range: &RangeInclusive<MessageNonce>,
|
received_range: &RangeInclusive<MessageNonce>,
|
||||||
_relayer_fund_account: &AccountId,
|
|
||||||
) {
|
) {
|
||||||
let relayers_rewards =
|
let relayers_rewards =
|
||||||
calc_relayers_rewards::<TestRuntime, ()>(lane_id, message_relayers, received_range);
|
calc_relayers_rewards::<TestRuntime, ()>(lane_id, message_relayers, received_range);
|
||||||
|
|||||||
@@ -63,13 +63,6 @@ impl WeightToFeePolynomial for WeightToFee {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// We use this to get the account on Kusama (target) which is derived from Polkadot's (source)
|
|
||||||
// account.
|
|
||||||
pub fn derive_account_from_polkadot_id(id: bp_runtime::SourceAccount<AccountId>) -> AccountId {
|
|
||||||
let encoded_id = bp_runtime::derive_account_id(bp_runtime::POLKADOT_CHAIN_ID, id);
|
|
||||||
AccountIdConverter::convert(encoded_id)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Per-byte fee for Kusama transactions.
|
/// Per-byte fee for Kusama transactions.
|
||||||
pub const TRANSACTION_BYTE_FEE: Balance = 10 * 1_000_000_000_000 / 30_000 / 1_000;
|
pub const TRANSACTION_BYTE_FEE: Balance = 10 * 1_000_000_000_000 / 30_000 / 1_000;
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ use frame_system::limits;
|
|||||||
use scale_info::TypeInfo;
|
use scale_info::TypeInfo;
|
||||||
use sp_core::{storage::StateVersion, Hasher as HasherT};
|
use sp_core::{storage::StateVersion, Hasher as HasherT};
|
||||||
use sp_runtime::{
|
use sp_runtime::{
|
||||||
traits::{Convert, IdentifyAccount, Verify},
|
traits::{IdentifyAccount, Verify},
|
||||||
FixedU128, MultiSignature, MultiSigner, Perbill,
|
FixedU128, MultiSignature, MultiSigner, Perbill,
|
||||||
};
|
};
|
||||||
use sp_std::prelude::*;
|
use sp_std::prelude::*;
|
||||||
@@ -218,43 +218,6 @@ impl sp_runtime::traits::Hash for BlakeTwoAndKeccak256 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Convert a 256-bit hash into an AccountId.
|
|
||||||
pub struct AccountIdConverter;
|
|
||||||
|
|
||||||
impl sp_runtime::traits::Convert<sp_core::H256, AccountId> for AccountIdConverter {
|
|
||||||
fn convert(hash: sp_core::H256) -> AccountId {
|
|
||||||
hash.to_fixed_bytes().into()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// We use this to get the account on Millau (target) which is derived from Rialto's (source)
|
|
||||||
/// account. We do this so we can fund the derived account on Millau at Genesis to it can pay
|
|
||||||
/// transaction fees.
|
|
||||||
///
|
|
||||||
/// The reason we can use the same `AccountId` type for both chains is because they share the same
|
|
||||||
/// development seed phrase.
|
|
||||||
///
|
|
||||||
/// Note that this should only be used for testing.
|
|
||||||
pub fn derive_account_from_rialto_id(id: bp_runtime::SourceAccount<AccountId>) -> AccountId {
|
|
||||||
let encoded_id = bp_runtime::derive_account_id(bp_runtime::RIALTO_CHAIN_ID, id);
|
|
||||||
AccountIdConverter::convert(encoded_id)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// We use this to get the account on Millau (target) which is derived from RialtoParachain's
|
|
||||||
/// (source) account. We do this so we can fund the derived account on Millau at Genesis to it can
|
|
||||||
/// pay transaction fees.
|
|
||||||
///
|
|
||||||
/// The reason we can use the same `AccountId` type for both chains is because they share the same
|
|
||||||
/// development seed phrase.
|
|
||||||
///
|
|
||||||
/// Note that this should only be used for testing.
|
|
||||||
pub fn derive_account_from_rialto_parachain_id(
|
|
||||||
id: bp_runtime::SourceAccount<AccountId>,
|
|
||||||
) -> AccountId {
|
|
||||||
let encoded_id = bp_runtime::derive_account_id(bp_runtime::RIALTO_PARACHAIN_CHAIN_ID, id);
|
|
||||||
AccountIdConverter::convert(encoded_id)
|
|
||||||
}
|
|
||||||
|
|
||||||
frame_support::parameter_types! {
|
frame_support::parameter_types! {
|
||||||
pub BlockLength: limits::BlockLength =
|
pub BlockLength: limits::BlockLength =
|
||||||
limits::BlockLength::max_with_normal_ratio(2 * 1024 * 1024, NORMAL_DISPATCH_RATIO);
|
limits::BlockLength::max_with_normal_ratio(2 * 1024 * 1024, NORMAL_DISPATCH_RATIO);
|
||||||
|
|||||||
@@ -63,13 +63,6 @@ impl WeightToFeePolynomial for WeightToFee {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// We use this to get the account on Polkadot (target) which is derived from Kusama's (source)
|
|
||||||
// account.
|
|
||||||
pub fn derive_account_from_kusama_id(id: bp_runtime::SourceAccount<AccountId>) -> AccountId {
|
|
||||||
let encoded_id = bp_runtime::derive_account_id(bp_runtime::KUSAMA_CHAIN_ID, id);
|
|
||||||
AccountIdConverter::convert(encoded_id)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Per-byte fee for Polkadot transactions.
|
/// Per-byte fee for Polkadot transactions.
|
||||||
pub const TRANSACTION_BYTE_FEE: Balance = 10 * 10_000_000_000 / 100 / 1_000;
|
pub const TRANSACTION_BYTE_FEE: Balance = 10 * 10_000_000_000 / 100 / 1_000;
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ use frame_support::{
|
|||||||
use frame_system::limits;
|
use frame_system::limits;
|
||||||
use sp_core::Hasher as HasherT;
|
use sp_core::Hasher as HasherT;
|
||||||
use sp_runtime::{
|
use sp_runtime::{
|
||||||
traits::{BlakeTwo256, Convert, IdentifyAccount, Verify},
|
traits::{BlakeTwo256, IdentifyAccount, Verify},
|
||||||
FixedU128, MultiSignature, MultiSigner, Perbill,
|
FixedU128, MultiSignature, MultiSigner, Perbill,
|
||||||
};
|
};
|
||||||
use sp_std::vec::Vec;
|
use sp_std::vec::Vec;
|
||||||
@@ -161,15 +161,6 @@ impl Chain for RialtoParachain {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Convert a 256-bit hash into an AccountId.
|
|
||||||
pub struct AccountIdConverter;
|
|
||||||
|
|
||||||
impl Convert<sp_core::H256, AccountId> for AccountIdConverter {
|
|
||||||
fn convert(hash: sp_core::H256) -> AccountId {
|
|
||||||
hash.to_fixed_bytes().into()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
frame_support::parameter_types! {
|
frame_support::parameter_types! {
|
||||||
pub BlockLength: limits::BlockLength =
|
pub BlockLength: limits::BlockLength =
|
||||||
limits::BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);
|
limits::BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);
|
||||||
@@ -218,19 +209,6 @@ pub const TO_RIALTO_PARACHAIN_MESSAGE_DETAILS_METHOD: &str =
|
|||||||
pub const FROM_RIALTO_PARACHAIN_MESSAGE_DETAILS_METHOD: &str =
|
pub const FROM_RIALTO_PARACHAIN_MESSAGE_DETAILS_METHOD: &str =
|
||||||
"FromRialtoParachainInboundLaneApi_message_details";
|
"FromRialtoParachainInboundLaneApi_message_details";
|
||||||
|
|
||||||
// We use this to get the account on RialtoParachain (target) which is derived from Millau's
|
|
||||||
// (source) account. We do this so we can fund the derived account on RialtoParachain at Genesis to
|
|
||||||
// it can pay transaction fees.
|
|
||||||
//
|
|
||||||
// The reason we can use the same `AccountId` type for both chains is because they share the same
|
|
||||||
// development seed phrase.
|
|
||||||
//
|
|
||||||
// Note that this should only be used for testing.
|
|
||||||
pub fn derive_account_from_millau_id(id: bp_runtime::SourceAccount<AccountId>) -> AccountId {
|
|
||||||
let encoded_id = bp_runtime::derive_account_id(bp_runtime::MILLAU_CHAIN_ID, id);
|
|
||||||
AccountIdConverter::convert(encoded_id)
|
|
||||||
}
|
|
||||||
|
|
||||||
sp_api::decl_runtime_apis! {
|
sp_api::decl_runtime_apis! {
|
||||||
/// API for querying information about the finalized RialtoParachain headers.
|
/// API for querying information about the finalized RialtoParachain headers.
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ use frame_support::{
|
|||||||
use frame_system::limits;
|
use frame_system::limits;
|
||||||
use sp_core::Hasher as HasherT;
|
use sp_core::Hasher as HasherT;
|
||||||
use sp_runtime::{
|
use sp_runtime::{
|
||||||
traits::{BlakeTwo256, Convert, IdentifyAccount, Verify},
|
traits::{BlakeTwo256, IdentifyAccount, Verify},
|
||||||
FixedU128, MultiSignature, MultiSigner, Perbill,
|
FixedU128, MultiSignature, MultiSigner, Perbill,
|
||||||
};
|
};
|
||||||
use sp_std::prelude::*;
|
use sp_std::prelude::*;
|
||||||
@@ -181,28 +181,6 @@ impl Chain for Rialto {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Convert a 256-bit hash into an AccountId.
|
|
||||||
pub struct AccountIdConverter;
|
|
||||||
|
|
||||||
impl Convert<sp_core::H256, AccountId> for AccountIdConverter {
|
|
||||||
fn convert(hash: sp_core::H256) -> AccountId {
|
|
||||||
hash.to_fixed_bytes().into()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// We use this to get the account on Rialto (target) which is derived from Millau's (source)
|
|
||||||
// account. We do this so we can fund the derived account on Rialto at Genesis to it can pay
|
|
||||||
// transaction fees.
|
|
||||||
//
|
|
||||||
// The reason we can use the same `AccountId` type for both chains is because they share the same
|
|
||||||
// development seed phrase.
|
|
||||||
//
|
|
||||||
// Note that this should only be used for testing.
|
|
||||||
pub fn derive_account_from_millau_id(id: bp_runtime::SourceAccount<AccountId>) -> AccountId {
|
|
||||||
let encoded_id = bp_runtime::derive_account_id(bp_runtime::MILLAU_CHAIN_ID, id);
|
|
||||||
AccountIdConverter::convert(encoded_id)
|
|
||||||
}
|
|
||||||
|
|
||||||
frame_support::parameter_types! {
|
frame_support::parameter_types! {
|
||||||
pub BlockLength: limits::BlockLength =
|
pub BlockLength: limits::BlockLength =
|
||||||
limits::BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);
|
limits::BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);
|
||||||
|
|||||||
@@ -69,13 +69,6 @@ impl WeightToFeePolynomial for WeightToFee {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// We use this to get the account on Rococo (target) which is derived from Wococo's (source)
|
|
||||||
// account.
|
|
||||||
pub fn derive_account_from_wococo_id(id: bp_runtime::SourceAccount<AccountId>) -> AccountId {
|
|
||||||
let encoded_id = bp_runtime::derive_account_id(bp_runtime::WOCOCO_CHAIN_ID, id);
|
|
||||||
AccountIdConverter::convert(encoded_id)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Name of the With-Rococo GRANDPA pallet instance that is deployed at bridged chains.
|
/// Name of the With-Rococo GRANDPA pallet instance that is deployed at bridged chains.
|
||||||
pub const WITH_ROCOCO_GRANDPA_PALLET_NAME: &str = "BridgeRococoGrandpa";
|
pub const WITH_ROCOCO_GRANDPA_PALLET_NAME: &str = "BridgeRococoGrandpa";
|
||||||
/// Name of the With-Rococo messages pallet instance that is deployed at bridged chains.
|
/// Name of the With-Rococo messages pallet instance that is deployed at bridged chains.
|
||||||
|
|||||||
@@ -79,13 +79,6 @@ impl sp_runtime::traits::Dispatchable for Call {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// We use this to get the account on Westend (target) which is derived from Rococo's (source)
|
|
||||||
// account.
|
|
||||||
pub fn derive_account_from_rococo_id(id: bp_runtime::SourceAccount<AccountId>) -> AccountId {
|
|
||||||
let encoded_id = bp_runtime::derive_account_id(bp_runtime::ROCOCO_CHAIN_ID, id);
|
|
||||||
AccountIdConverter::convert(encoded_id)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Name of the parachains pallet at the Westend runtime.
|
/// Name of the parachains pallet at the Westend runtime.
|
||||||
pub const PARAS_PALLET_NAME: &str = "Paras";
|
pub const PARAS_PALLET_NAME: &str = "Paras";
|
||||||
|
|
||||||
|
|||||||
@@ -38,13 +38,6 @@ pub type Wococo = PolkadotLike;
|
|||||||
/// conditions.
|
/// conditions.
|
||||||
pub const SESSION_LENGTH: BlockNumber = time_units::MINUTES;
|
pub const SESSION_LENGTH: BlockNumber = time_units::MINUTES;
|
||||||
|
|
||||||
// We use this to get the account on Wococo (target) which is derived from Rococo's (source)
|
|
||||||
// account.
|
|
||||||
pub fn derive_account_from_rococo_id(id: bp_runtime::SourceAccount<AccountId>) -> AccountId {
|
|
||||||
let encoded_id = bp_runtime::derive_account_id(bp_runtime::ROCOCO_CHAIN_ID, id);
|
|
||||||
AccountIdConverter::convert(encoded_id)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Name of the With-Wococo GRANDPA pallet instance that is deployed at bridged chains.
|
/// Name of the With-Wococo GRANDPA pallet instance that is deployed at bridged chains.
|
||||||
pub const WITH_WOCOCO_GRANDPA_PALLET_NAME: &str = "BridgeWococoGrandpa";
|
pub const WITH_WOCOCO_GRANDPA_PALLET_NAME: &str = "BridgeWococoGrandpa";
|
||||||
/// Name of the With-Wococo messages pallet instance that is deployed at bridged chains.
|
/// Name of the With-Wococo messages pallet instance that is deployed at bridged chains.
|
||||||
|
|||||||
@@ -133,7 +133,6 @@ pub trait MessageDeliveryAndDispatchPayment<SenderOrigin, AccountId, Balance> {
|
|||||||
fn pay_delivery_and_dispatch_fee(
|
fn pay_delivery_and_dispatch_fee(
|
||||||
submitter: &SenderOrigin,
|
submitter: &SenderOrigin,
|
||||||
fee: &Balance,
|
fee: &Balance,
|
||||||
relayer_fund_account: &AccountId,
|
|
||||||
) -> Result<(), Self::Error>;
|
) -> Result<(), Self::Error>;
|
||||||
|
|
||||||
/// Pay rewards for delivering messages to the given relayers.
|
/// Pay rewards for delivering messages to the given relayers.
|
||||||
@@ -145,7 +144,6 @@ pub trait MessageDeliveryAndDispatchPayment<SenderOrigin, AccountId, Balance> {
|
|||||||
messages_relayers: VecDeque<UnrewardedRelayer<AccountId>>,
|
messages_relayers: VecDeque<UnrewardedRelayer<AccountId>>,
|
||||||
confirmation_relayer: &AccountId,
|
confirmation_relayer: &AccountId,
|
||||||
received_range: &RangeInclusive<MessageNonce>,
|
received_range: &RangeInclusive<MessageNonce>,
|
||||||
relayer_fund_account: &AccountId,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,7 +155,6 @@ impl<SenderOrigin, AccountId, Balance>
|
|||||||
fn pay_delivery_and_dispatch_fee(
|
fn pay_delivery_and_dispatch_fee(
|
||||||
_submitter: &SenderOrigin,
|
_submitter: &SenderOrigin,
|
||||||
_fee: &Balance,
|
_fee: &Balance,
|
||||||
_relayer_fund_account: &AccountId,
|
|
||||||
) -> Result<(), Self::Error> {
|
) -> Result<(), Self::Error> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -167,7 +164,6 @@ impl<SenderOrigin, AccountId, Balance>
|
|||||||
_messages_relayers: VecDeque<UnrewardedRelayer<AccountId>>,
|
_messages_relayers: VecDeque<UnrewardedRelayer<AccountId>>,
|
||||||
_confirmation_relayer: &AccountId,
|
_confirmation_relayer: &AccountId,
|
||||||
_received_range: &RangeInclusive<MessageNonce>,
|
_received_range: &RangeInclusive<MessageNonce>,
|
||||||
_relayer_fund_account: &AccountId,
|
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -306,7 +302,6 @@ impl<SenderOrigin, AccountId, Balance>
|
|||||||
fn pay_delivery_and_dispatch_fee(
|
fn pay_delivery_and_dispatch_fee(
|
||||||
_submitter: &SenderOrigin,
|
_submitter: &SenderOrigin,
|
||||||
_fee: &Balance,
|
_fee: &Balance,
|
||||||
_relayer_fund_account: &AccountId,
|
|
||||||
) -> Result<(), Self::Error> {
|
) -> Result<(), Self::Error> {
|
||||||
Err(ALL_OUTBOUND_MESSAGES_REJECTED)
|
Err(ALL_OUTBOUND_MESSAGES_REJECTED)
|
||||||
}
|
}
|
||||||
@@ -316,7 +311,6 @@ impl<SenderOrigin, AccountId, Balance>
|
|||||||
_messages_relayers: VecDeque<UnrewardedRelayer<AccountId>>,
|
_messages_relayers: VecDeque<UnrewardedRelayer<AccountId>>,
|
||||||
_confirmation_relayer: &AccountId,
|
_confirmation_relayer: &AccountId,
|
||||||
_received_range: &RangeInclusive<MessageNonce>,
|
_received_range: &RangeInclusive<MessageNonce>,
|
||||||
_relayer_fund_account: &AccountId,
|
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -390,15 +390,6 @@ impl Chain for PolkadotLike {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Convert a 256-bit hash into an AccountId.
|
|
||||||
pub struct AccountIdConverter;
|
|
||||||
|
|
||||||
impl Convert<sp_core::H256, AccountId> for AccountIdConverter {
|
|
||||||
fn convert(hash: sp_core::H256) -> AccountId {
|
|
||||||
hash.to_fixed_bytes().into()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Return a storage key for account data.
|
/// Return a storage key for account data.
|
||||||
///
|
///
|
||||||
/// This is based on FRAME storage-generation code from Substrate:
|
/// This is based on FRAME storage-generation code from Substrate:
|
||||||
|
|||||||
@@ -127,16 +127,6 @@ where
|
|||||||
.into()
|
.into()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Derive the account ID of the shared relayer fund account.
|
|
||||||
///
|
|
||||||
/// This account is used to collect fees for relayers that are passing messages across the bridge.
|
|
||||||
///
|
|
||||||
/// The account ID can be the same across different instances of `pallet-bridge-messages` if the
|
|
||||||
/// same `bridge_id` is used.
|
|
||||||
pub fn derive_relayer_fund_account_id(bridge_id: ChainId) -> H256 {
|
|
||||||
("relayer-fund-account", bridge_id).using_encoded(blake2_256).into()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Anything that has size.
|
/// Anything that has size.
|
||||||
pub trait Size {
|
pub trait Size {
|
||||||
/// Return size of this object (in bytes).
|
/// Return size of this object (in bytes).
|
||||||
|
|||||||
@@ -15,7 +15,6 @@
|
|||||||
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
|
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
use crate::cli::CliChain;
|
use crate::cli::CliChain;
|
||||||
use bp_runtime::{AccountIdOf, SourceAccount};
|
|
||||||
use relay_substrate_client::{AccountKeyPairOf, Chain, TransactionSignScheme};
|
use relay_substrate_client::{AccountKeyPairOf, Chain, TransactionSignScheme};
|
||||||
use strum::{EnumString, EnumVariantNames};
|
use strum::{EnumString, EnumVariantNames};
|
||||||
use substrate_relay_helper::{
|
use substrate_relay_helper::{
|
||||||
@@ -82,11 +81,6 @@ pub trait MessagesCliBridge: CliBridgeBase {
|
|||||||
SourceTransactionSignScheme = Self::Source,
|
SourceTransactionSignScheme = Self::Source,
|
||||||
TargetTransactionSignScheme = Self::Target,
|
TargetTransactionSignScheme = Self::Target,
|
||||||
>;
|
>;
|
||||||
|
|
||||||
/// We use this to get the account on the target which is derived from the source account.
|
|
||||||
fn derive_account_from_id(
|
|
||||||
id: SourceAccount<AccountIdOf<Self::Source>>,
|
|
||||||
) -> AccountIdOf<Self::Target>;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//// `Millau` to `Rialto` bridge definition.
|
//// `Millau` to `Rialto` bridge definition.
|
||||||
@@ -105,12 +99,6 @@ impl MessagesCliBridge for MillauToRialtoCliBridge {
|
|||||||
const ESTIMATE_MESSAGE_FEE_METHOD: &'static str =
|
const ESTIMATE_MESSAGE_FEE_METHOD: &'static str =
|
||||||
bp_rialto::TO_RIALTO_ESTIMATE_MESSAGE_FEE_METHOD;
|
bp_rialto::TO_RIALTO_ESTIMATE_MESSAGE_FEE_METHOD;
|
||||||
type MessagesLane = crate::chains::millau_messages_to_rialto::MillauMessagesToRialto;
|
type MessagesLane = crate::chains::millau_messages_to_rialto::MillauMessagesToRialto;
|
||||||
|
|
||||||
fn derive_account_from_id(
|
|
||||||
id: SourceAccount<AccountIdOf<Self::Source>>,
|
|
||||||
) -> AccountIdOf<Self::Target> {
|
|
||||||
bp_rialto::derive_account_from_millau_id(id)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//// `Rialto` to `Millau` bridge definition.
|
//// `Rialto` to `Millau` bridge definition.
|
||||||
@@ -129,14 +117,6 @@ impl MessagesCliBridge for RialtoToMillauCliBridge {
|
|||||||
const ESTIMATE_MESSAGE_FEE_METHOD: &'static str =
|
const ESTIMATE_MESSAGE_FEE_METHOD: &'static str =
|
||||||
bp_millau::TO_MILLAU_ESTIMATE_MESSAGE_FEE_METHOD;
|
bp_millau::TO_MILLAU_ESTIMATE_MESSAGE_FEE_METHOD;
|
||||||
type MessagesLane = crate::chains::rialto_messages_to_millau::RialtoMessagesToMillau;
|
type MessagesLane = crate::chains::rialto_messages_to_millau::RialtoMessagesToMillau;
|
||||||
|
|
||||||
/// We use this to get the account on the target chain which is derived from
|
|
||||||
/// the source chain account.
|
|
||||||
fn derive_account_from_id(
|
|
||||||
id: SourceAccount<AccountIdOf<Self::Source>>,
|
|
||||||
) -> AccountIdOf<Self::Target> {
|
|
||||||
bp_millau::derive_account_from_rialto_id(id)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//// `Westend` to `Millau` bridge definition.
|
//// `Westend` to `Millau` bridge definition.
|
||||||
@@ -169,12 +149,6 @@ impl MessagesCliBridge for MillauToRialtoParachainCliBridge {
|
|||||||
bp_rialto_parachain::TO_RIALTO_PARACHAIN_ESTIMATE_MESSAGE_FEE_METHOD;
|
bp_rialto_parachain::TO_RIALTO_PARACHAIN_ESTIMATE_MESSAGE_FEE_METHOD;
|
||||||
type MessagesLane =
|
type MessagesLane =
|
||||||
crate::chains::millau_messages_to_rialto_parachain::MillauMessagesToRialtoParachain;
|
crate::chains::millau_messages_to_rialto_parachain::MillauMessagesToRialtoParachain;
|
||||||
|
|
||||||
fn derive_account_from_id(
|
|
||||||
id: SourceAccount<AccountIdOf<Self::Source>>,
|
|
||||||
) -> AccountIdOf<Self::Target> {
|
|
||||||
bp_rialto_parachain::derive_account_from_millau_id(id)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//// `RialtoParachain` to `Millau` bridge definition.
|
//// `RialtoParachain` to `Millau` bridge definition.
|
||||||
@@ -190,12 +164,6 @@ impl MessagesCliBridge for RialtoParachainToMillauCliBridge {
|
|||||||
bp_millau::TO_MILLAU_ESTIMATE_MESSAGE_FEE_METHOD;
|
bp_millau::TO_MILLAU_ESTIMATE_MESSAGE_FEE_METHOD;
|
||||||
type MessagesLane =
|
type MessagesLane =
|
||||||
crate::chains::rialto_parachain_messages_to_millau::RialtoParachainMessagesToMillau;
|
crate::chains::rialto_parachain_messages_to_millau::RialtoParachainMessagesToMillau;
|
||||||
|
|
||||||
fn derive_account_from_id(
|
|
||||||
id: SourceAccount<AccountIdOf<Self::Source>>,
|
|
||||||
) -> AccountIdOf<Self::Target> {
|
|
||||||
bp_millau::derive_account_from_rialto_parachain_id(id)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//// `WestendParachain` to `Millau` bridge definition.
|
//// `WestendParachain` to `Millau` bridge definition.
|
||||||
|
|||||||
@@ -77,9 +77,6 @@ pub struct HeadersAndMessagesSharedParams {
|
|||||||
lane: Vec<HexLaneId>,
|
lane: Vec<HexLaneId>,
|
||||||
#[structopt(long, possible_values = RelayerMode::VARIANTS, case_insensitive = true, default_value = "rational")]
|
#[structopt(long, possible_values = RelayerMode::VARIANTS, case_insensitive = true, default_value = "rational")]
|
||||||
relayer_mode: RelayerMode,
|
relayer_mode: RelayerMode,
|
||||||
/// Create relayers fund accounts on both chains, if it does not exists yet.
|
|
||||||
#[structopt(long)]
|
|
||||||
create_relayers_fund_accounts: bool,
|
|
||||||
/// If passed, only mandatory headers (headers that are changing the GRANDPA authorities set)
|
/// If passed, only mandatory headers (headers that are changing the GRANDPA authorities set)
|
||||||
/// are relayed.
|
/// are relayed.
|
||||||
#[structopt(long)]
|
#[structopt(long)]
|
||||||
@@ -185,9 +182,6 @@ macro_rules! select_bridge {
|
|||||||
type Left = relay_millau_client::Millau;
|
type Left = relay_millau_client::Millau;
|
||||||
type Right = relay_rialto_client::Rialto;
|
type Right = relay_rialto_client::Rialto;
|
||||||
|
|
||||||
type LeftAccountIdConverter = bp_millau::AccountIdConverter;
|
|
||||||
type RightAccountIdConverter = bp_rialto::AccountIdConverter;
|
|
||||||
|
|
||||||
use crate::chains::{
|
use crate::chains::{
|
||||||
millau_messages_to_rialto::MillauMessagesToRialto as LeftToRightMessageLane,
|
millau_messages_to_rialto::MillauMessagesToRialto as LeftToRightMessageLane,
|
||||||
rialto_messages_to_millau::RialtoMessagesToMillau as RightToLeftMessageLane,
|
rialto_messages_to_millau::RialtoMessagesToMillau as RightToLeftMessageLane,
|
||||||
@@ -222,22 +216,6 @@ macro_rules! select_bridge {
|
|||||||
).await
|
).await
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn left_create_account(
|
|
||||||
_left_client: Client<Left>,
|
|
||||||
_left_sign: <Left as TransactionSignScheme>::AccountKeyPair,
|
|
||||||
_account_id: AccountIdOf<Left>,
|
|
||||||
) -> anyhow::Result<()> {
|
|
||||||
Err(anyhow::format_err!("Account creation is not supported by this bridge"))
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn right_create_account(
|
|
||||||
_right_client: Client<Right>,
|
|
||||||
_right_sign: <Right as TransactionSignScheme>::AccountKeyPair,
|
|
||||||
_account_id: AccountIdOf<Right>,
|
|
||||||
) -> anyhow::Result<()> {
|
|
||||||
Err(anyhow::format_err!("Account creation is not supported by this bridge"))
|
|
||||||
}
|
|
||||||
|
|
||||||
$generic
|
$generic
|
||||||
},
|
},
|
||||||
RelayHeadersAndMessages::MillauRialtoParachain(_) => {
|
RelayHeadersAndMessages::MillauRialtoParachain(_) => {
|
||||||
@@ -246,9 +224,6 @@ macro_rules! select_bridge {
|
|||||||
type Left = relay_millau_client::Millau;
|
type Left = relay_millau_client::Millau;
|
||||||
type Right = relay_rialto_parachain_client::RialtoParachain;
|
type Right = relay_rialto_parachain_client::RialtoParachain;
|
||||||
|
|
||||||
type LeftAccountIdConverter = bp_millau::AccountIdConverter;
|
|
||||||
type RightAccountIdConverter = bp_rialto_parachain::AccountIdConverter;
|
|
||||||
|
|
||||||
use crate::chains::{
|
use crate::chains::{
|
||||||
millau_messages_to_rialto_parachain::MillauMessagesToRialtoParachain as LeftToRightMessageLane,
|
millau_messages_to_rialto_parachain::MillauMessagesToRialtoParachain as LeftToRightMessageLane,
|
||||||
rialto_parachain_messages_to_millau::RialtoParachainMessagesToMillau as RightToLeftMessageLane,
|
rialto_parachain_messages_to_millau::RialtoParachainMessagesToMillau as RightToLeftMessageLane,
|
||||||
@@ -290,22 +265,6 @@ macro_rules! select_bridge {
|
|||||||
).await
|
).await
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn left_create_account(
|
|
||||||
_left_client: Client<Left>,
|
|
||||||
_left_sign: <Left as TransactionSignScheme>::AccountKeyPair,
|
|
||||||
_account_id: AccountIdOf<Left>,
|
|
||||||
) -> anyhow::Result<()> {
|
|
||||||
Err(anyhow::format_err!("Account creation is not supported by this bridge"))
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn right_create_account(
|
|
||||||
_right_client: Client<Right>,
|
|
||||||
_right_sign: <Right as TransactionSignScheme>::AccountKeyPair,
|
|
||||||
_account_id: AccountIdOf<Right>,
|
|
||||||
) -> anyhow::Result<()> {
|
|
||||||
Err(anyhow::format_err!("Account creation is not supported by this bridge"))
|
|
||||||
}
|
|
||||||
|
|
||||||
$generic
|
$generic
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -445,45 +404,6 @@ impl RelayHeadersAndMessages {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// optionally, create relayers fund account
|
|
||||||
if params.shared.create_relayers_fund_accounts {
|
|
||||||
let relayer_fund_acount_id = pallet_bridge_messages::relayer_fund_account_id::<
|
|
||||||
AccountIdOf<Left>,
|
|
||||||
LeftAccountIdConverter,
|
|
||||||
>();
|
|
||||||
let relayers_fund_account_balance =
|
|
||||||
left_client.free_native_balance(relayer_fund_acount_id.clone()).await;
|
|
||||||
if let Err(relay_substrate_client::Error::AccountDoesNotExist) =
|
|
||||||
relayers_fund_account_balance
|
|
||||||
{
|
|
||||||
log::info!(target: "bridge", "Going to create relayers fund account at {}.", Left::NAME);
|
|
||||||
left_create_account(
|
|
||||||
left_client.clone(),
|
|
||||||
left_sign.clone(),
|
|
||||||
relayer_fund_acount_id,
|
|
||||||
)
|
|
||||||
.await?;
|
|
||||||
}
|
|
||||||
|
|
||||||
let relayer_fund_acount_id = pallet_bridge_messages::relayer_fund_account_id::<
|
|
||||||
AccountIdOf<Right>,
|
|
||||||
RightAccountIdConverter,
|
|
||||||
>();
|
|
||||||
let relayers_fund_account_balance =
|
|
||||||
right_client.free_native_balance(relayer_fund_acount_id.clone()).await;
|
|
||||||
if let Err(relay_substrate_client::Error::AccountDoesNotExist) =
|
|
||||||
relayers_fund_account_balance
|
|
||||||
{
|
|
||||||
log::info!(target: "bridge", "Going to create relayers fund account at {}.", Right::NAME);
|
|
||||||
right_create_account(
|
|
||||||
right_client.clone(),
|
|
||||||
right_sign.clone(),
|
|
||||||
relayer_fund_acount_id,
|
|
||||||
)
|
|
||||||
.await?;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// start on-demand header relays
|
// start on-demand header relays
|
||||||
let (left_to_right_on_demand_headers, right_to_left_on_demand_headers) =
|
let (left_to_right_on_demand_headers, right_to_left_on_demand_headers) =
|
||||||
start_on_demand_relays(
|
start_on_demand_relays(
|
||||||
@@ -785,7 +705,6 @@ mod tests {
|
|||||||
HexLaneId([0x73, 0x77, 0x61, 0x70])
|
HexLaneId([0x73, 0x77, 0x61, 0x70])
|
||||||
],
|
],
|
||||||
relayer_mode: RelayerMode::Rational,
|
relayer_mode: RelayerMode::Rational,
|
||||||
create_relayers_fund_accounts: false,
|
|
||||||
only_mandatory_headers: false,
|
only_mandatory_headers: false,
|
||||||
prometheus_params: PrometheusParams {
|
prometheus_params: PrometheusParams {
|
||||||
no_prometheus: false,
|
no_prometheus: false,
|
||||||
@@ -899,7 +818,6 @@ mod tests {
|
|||||||
shared: HeadersAndMessagesSharedParams {
|
shared: HeadersAndMessagesSharedParams {
|
||||||
lane: vec![HexLaneId([0x00, 0x00, 0x00, 0x00])],
|
lane: vec![HexLaneId([0x00, 0x00, 0x00, 0x00])],
|
||||||
relayer_mode: RelayerMode::Rational,
|
relayer_mode: RelayerMode::Rational,
|
||||||
create_relayers_fund_accounts: false,
|
|
||||||
only_mandatory_headers: false,
|
only_mandatory_headers: false,
|
||||||
prometheus_params: PrometheusParams {
|
prometheus_params: PrometheusParams {
|
||||||
no_prometheus: false,
|
no_prometheus: false,
|
||||||
|
|||||||
Reference in New Issue
Block a user