diff --git a/bridges/bin/millau/runtime/src/lib.rs b/bridges/bin/millau/runtime/src/lib.rs index 8b2988d421..4041cfe171 100644 --- a/bridges/bin/millau/runtime/src/lib.rs +++ b/bridges/bin/millau/runtime/src/lib.rs @@ -461,8 +461,6 @@ impl pallet_bridge_messages::Config for Runtime { type InboundMessageFee = bp_rialto::Balance; type InboundRelayer = bp_rialto::AccountId; - type AccountIdConverter = bp_millau::AccountIdConverter; - type TargetHeaderChain = crate::rialto_messages::Rialto; type LaneMessageVerifier = crate::rialto_messages::ToRialtoMessageVerifier; type MessageDeliveryAndDispatchPayment = (); @@ -494,8 +492,6 @@ impl pallet_bridge_messages::Config for Run type InboundMessageFee = bp_rialto_parachain::Balance; type InboundRelayer = bp_rialto_parachain::AccountId; - type AccountIdConverter = bp_millau::AccountIdConverter; - type TargetHeaderChain = crate::rialto_parachain_messages::RialtoParachain; type LaneMessageVerifier = crate::rialto_parachain_messages::ToRialtoParachainMessageVerifier; type MessageDeliveryAndDispatchPayment = (); diff --git a/bridges/bin/millau/runtime/src/rialto_messages.rs b/bridges/bin/millau/runtime/src/rialto_messages.rs index bbcc6144f8..5d192bd56a 100644 --- a/bridges/bin/millau/runtime/src/rialto_messages.rs +++ b/bridges/bin/millau/runtime/src/rialto_messages.rs @@ -371,7 +371,6 @@ mod tests { bridge: WithRialtoMessageBridge, this_chain: bp_millau::Millau, bridged_chain: bp_rialto::Rialto, - this_chain_account_id_converter: bp_millau::AccountIdConverter ); assert_complete_bridge_constants::< diff --git a/bridges/bin/rialto-parachain/runtime/src/lib.rs b/bridges/bin/rialto-parachain/runtime/src/lib.rs index 37930c3555..f2463b5e06 100644 --- a/bridges/bin/rialto-parachain/runtime/src/lib.rs +++ b/bridges/bin/rialto-parachain/runtime/src/lib.rs @@ -528,8 +528,6 @@ impl pallet_bridge_messages::Config for Runtime { type InboundMessageFee = bp_millau::Balance; type InboundRelayer = bp_millau::AccountId; - type AccountIdConverter = bp_rialto_parachain::AccountIdConverter; - type TargetHeaderChain = crate::millau_messages::Millau; type LaneMessageVerifier = crate::millau_messages::ToMillauMessageVerifier; type MessageDeliveryAndDispatchPayment = (); diff --git a/bridges/bin/rialto/runtime/src/lib.rs b/bridges/bin/rialto/runtime/src/lib.rs index 3d468a5b4e..e06fdffe88 100644 --- a/bridges/bin/rialto/runtime/src/lib.rs +++ b/bridges/bin/rialto/runtime/src/lib.rs @@ -445,8 +445,6 @@ impl pallet_bridge_messages::Config for Runtime { type InboundMessageFee = bp_millau::Balance; type InboundRelayer = bp_millau::AccountId; - type AccountIdConverter = bp_rialto::AccountIdConverter; - type TargetHeaderChain = crate::millau_messages::Millau; type LaneMessageVerifier = crate::millau_messages::ToMillauMessageVerifier; type MessageDeliveryAndDispatchPayment = (); diff --git a/bridges/bin/rialto/runtime/src/millau_messages.rs b/bridges/bin/rialto/runtime/src/millau_messages.rs index d547dde538..e5e95e3d4a 100644 --- a/bridges/bin/rialto/runtime/src/millau_messages.rs +++ b/bridges/bin/rialto/runtime/src/millau_messages.rs @@ -368,7 +368,6 @@ mod tests { bridge: WithMillauMessageBridge, this_chain: bp_rialto::Rialto, bridged_chain: bp_millau::Millau, - this_chain_account_id_converter: bp_rialto::AccountIdConverter ); assert_complete_bridge_constants::< diff --git a/bridges/bin/runtime-common/src/integrity.rs b/bridges/bin/runtime-common/src/integrity.rs index a145d81e9b..850c71181e 100644 --- a/bridges/bin/runtime-common/src/integrity.rs +++ b/bridges/bin/runtime-common/src/integrity.rs @@ -105,8 +105,7 @@ macro_rules! assert_bridge_messages_pallet_types( ( runtime: $r:path, with_bridged_chain_messages_instance: $i:path, - bridge: $bridge:path, - this_chain_account_id_converter: $this_converter:path + bridge: $bridge:path ) => { { // 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>); assert_type_eq_all!(<$r as MessagesConfig<$i>>::InboundRelayer, AccountIdOf>); - 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>>::SourceHeaderChain, BridgedChain<$bridge>); } @@ -148,7 +145,6 @@ macro_rules! assert_complete_bridge_types( bridge: $bridge:path, this_chain: $this:path, bridged_chain: $bridged:path, - this_chain_account_id_converter: $this_converter:path ) => { $crate::assert_chain_types!(runtime: $r, this_chain: $this); $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!( runtime: $r, with_bridged_chain_messages_instance: $mi, - bridge: $bridge, - this_chain_account_id_converter: $this_converter + bridge: $bridge ); } ); diff --git a/bridges/modules/messages/src/benchmarking.rs b/bridges/modules/messages/src/benchmarking.rs index 78a04d2286..9c74265e2d 100644 --- a/bridges/modules/messages/src/benchmarking.rs +++ b/bridges/modules/messages/src/benchmarking.rs @@ -126,10 +126,8 @@ benchmarks_instance_pallet! { // added. send_minimal_message_worst_case { let lane_id = T::bench_lane_id(); - let relayers_fund_id = crate::relayer_fund_account_id::(); let sender = account("sender", 0, SEED); T::endow_account(&sender); - T::endow_account(&relayers_fund_id); // 'send' messages that are to be pruned when our message is sent 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_1_kb_message_worst_case { let lane_id = T::bench_lane_id(); - let relayers_fund_id = crate::relayer_fund_account_id::(); let sender = account("sender", 0, SEED); T::endow_account(&sender); - T::endow_account(&relayers_fund_id); // 'send' messages that are to be pruned when our message is sent 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 { let lane_id = T::bench_lane_id(); - let relayers_fund_id = crate::relayer_fund_account_id::(); let sender = account("sender", 0, SEED); T::endow_account(&sender); - T::endow_account(&relayers_fund_id); // 'send' messages that are to be pruned when our message is sent 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. maximal_increase_message_fee { - let relayers_fund_id = crate::relayer_fund_account_id::(); let sender = account("sender", 42, SEED); T::endow_account(&sender); - T::endow_account(&relayers_fund_id); let additional_fee = T::account_balance(&sender); let lane_id = T::bench_lane_id(); @@ -257,10 +249,8 @@ benchmarks_instance_pallet! { increase_message_fee { let i in 0..T::maximal_message_size().try_into().unwrap_or_default(); - let relayers_fund_id = crate::relayer_fund_account_id::(); let sender = account("sender", 42, SEED); T::endow_account(&sender); - T::endow_account(&relayers_fund_id); let additional_fee = T::account_balance(&sender); let lane_id = T::bench_lane_id(); @@ -488,10 +478,8 @@ benchmarks_instance_pallet! { // // This is base benchmark for all other confirmations delivery benchmarks. receive_delivery_proof_for_single_message { - let relayers_fund_id = crate::relayer_fund_account_id::(); let relayer_id: T::AccountId = account("relayer", 0, SEED); let relayer_balance = T::account_balance(&relayer_id); - T::endow_account(&relayers_fund_id); // send message that we're going to confirm send_regular_message::(); @@ -526,10 +514,8 @@ 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::relayer_fund_account_id::(); let relayer_id: T::AccountId = account("relayer", 0, SEED); let relayer_balance = T::account_balance(&relayer_id); - T::endow_account(&relayers_fund_id); // send message that we're going to confirm send_regular_message::(); @@ -567,12 +553,10 @@ 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::relayer_fund_account_id::(); 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); let relayer2_balance = T::account_balance(&relayer2_id); - T::endow_account(&relayers_fund_id); // send message that we're going to confirm send_regular_message::(); diff --git a/bridges/modules/messages/src/lib.rs b/bridges/modules/messages/src/lib.rs index 26e62a07d7..ca4b7044b2 100644 --- a/bridges/modules/messages/src/lib.rs +++ b/bridges/modules/messages/src/lib.rs @@ -71,8 +71,6 @@ use frame_support::{ weights::{Pays, PostDispatchInfo}, }; use num_traits::{SaturatingAdd, Zero}; -use sp_core::H256; -use sp_runtime::traits::Convert; use sp_std::{ cell::RefCell, cmp::PartialOrd, collections::vec_deque::VecDeque, marker::PhantomData, ops::RangeInclusive, prelude::*, @@ -170,11 +168,6 @@ pub mod pallet { /// bridged chain. 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; - // Types that are used by outbound_lane (on source chain). /// Target header chain. @@ -313,16 +306,14 @@ pub mod pallet { T::MessageDeliveryAndDispatchPayment::pay_delivery_and_dispatch_fee( &origin, &additional_fee, - &relayer_fund_account_id::(), ) .map_err(|err| { log::trace!( target: LOG_TARGET, - "Submitter can't pay additional fee {:?} for the message {:?}/{:?} to {:?}: {:?}", + "Submitter can't pay additional fee {:?} for the message {:?}/{:?}: {:?}", additional_fee, lane_id, nonce, - relayer_fund_account_id::(), err, ); @@ -629,14 +620,11 @@ pub mod pallet { }); // if some new messages have been confirmed, reward relayers - let relayer_fund_account = - relayer_fund_account_id::(); >::MessageDeliveryAndDispatchPayment::pay_relayers_rewards( lane_id, lane_data.relayers, &confirmation_relayer, &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 { - let encoded_id = bp_runtime::derive_relayer_fund_account_id(bp_runtime::NO_INSTANCE_ID); - AccountIdConverter::convert(encoded_id) -} - impl bp_messages::source_chain::MessagesBridge< T::Origin, @@ -877,7 +855,6 @@ fn send_message, I: 'static>( T::MessageDeliveryAndDispatchPayment::pay_delivery_and_dispatch_fee( &submitter, &delivery_and_dispatch_fee, - &relayer_fund_account_id::(), ) .map_err(|err| { log::trace!( diff --git a/bridges/modules/messages/src/mock.rs b/bridges/modules/messages/src/mock.rs index b836517e41..9584d17b83 100644 --- a/bridges/modules/messages/src/mock.rs +++ b/bridges/modules/messages/src/mock.rs @@ -68,14 +68,6 @@ pub struct TestPayload { pub type TestMessageFee = u64; pub type TestRelayer = u64; -pub struct AccountIdConverter; - -impl sp_runtime::traits::Convert for AccountIdConverter { - fn convert(hash: H256) -> AccountId { - hash.to_low_u64_ne() - } -} - type Block = frame_system::mocking::MockBlock; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; @@ -182,8 +174,6 @@ impl Config for TestRuntime { type InboundMessageFee = TestMessageFee; type InboundRelayer = TestRelayer; - type AccountIdConverter = AccountIdConverter; - type TargetHeaderChain = TestTargetHeaderChain; type LaneMessageVerifier = TestLaneMessageVerifier; type MessageDeliveryAndDispatchPayment = TestMessageDeliveryAndDispatchPayment; @@ -360,7 +350,6 @@ impl MessageDeliveryAndDispatchPayment fn pay_delivery_and_dispatch_fee( submitter: &Origin, fee: &TestMessageFee, - _relayer_fund_account: &AccountId, ) -> Result<(), Self::Error> { if frame_support::storage::unhashed::get(b":reject-message-fee:") == Some(true) { return Err(TEST_ERROR) @@ -376,7 +365,6 @@ impl MessageDeliveryAndDispatchPayment message_relayers: VecDeque>, _confirmation_relayer: &AccountId, received_range: &RangeInclusive, - _relayer_fund_account: &AccountId, ) { let relayers_rewards = calc_relayers_rewards::(lane_id, message_relayers, received_range); diff --git a/bridges/primitives/chain-kusama/src/lib.rs b/bridges/primitives/chain-kusama/src/lib.rs index 637f6b9da0..f3450a77dc 100644 --- a/bridges/primitives/chain-kusama/src/lib.rs +++ b/bridges/primitives/chain-kusama/src/lib.rs @@ -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 { - let encoded_id = bp_runtime::derive_account_id(bp_runtime::POLKADOT_CHAIN_ID, id); - AccountIdConverter::convert(encoded_id) -} - /// Per-byte fee for Kusama transactions. pub const TRANSACTION_BYTE_FEE: Balance = 10 * 1_000_000_000_000 / 30_000 / 1_000; diff --git a/bridges/primitives/chain-millau/src/lib.rs b/bridges/primitives/chain-millau/src/lib.rs index 48c80e7017..6bdd9c53ee 100644 --- a/bridges/primitives/chain-millau/src/lib.rs +++ b/bridges/primitives/chain-millau/src/lib.rs @@ -32,7 +32,7 @@ use frame_system::limits; use scale_info::TypeInfo; use sp_core::{storage::StateVersion, Hasher as HasherT}; use sp_runtime::{ - traits::{Convert, IdentifyAccount, Verify}, + traits::{IdentifyAccount, Verify}, FixedU128, MultiSignature, MultiSigner, Perbill, }; 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 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 { - 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 { - let encoded_id = bp_runtime::derive_account_id(bp_runtime::RIALTO_PARACHAIN_CHAIN_ID, id); - AccountIdConverter::convert(encoded_id) -} - frame_support::parameter_types! { pub BlockLength: limits::BlockLength = limits::BlockLength::max_with_normal_ratio(2 * 1024 * 1024, NORMAL_DISPATCH_RATIO); diff --git a/bridges/primitives/chain-polkadot/src/lib.rs b/bridges/primitives/chain-polkadot/src/lib.rs index f06bb917ed..af195e511c 100644 --- a/bridges/primitives/chain-polkadot/src/lib.rs +++ b/bridges/primitives/chain-polkadot/src/lib.rs @@ -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 { - let encoded_id = bp_runtime::derive_account_id(bp_runtime::KUSAMA_CHAIN_ID, id); - AccountIdConverter::convert(encoded_id) -} - /// Per-byte fee for Polkadot transactions. pub const TRANSACTION_BYTE_FEE: Balance = 10 * 10_000_000_000 / 100 / 1_000; diff --git a/bridges/primitives/chain-rialto-parachain/src/lib.rs b/bridges/primitives/chain-rialto-parachain/src/lib.rs index 9e54744f2d..00402ae49d 100644 --- a/bridges/primitives/chain-rialto-parachain/src/lib.rs +++ b/bridges/primitives/chain-rialto-parachain/src/lib.rs @@ -29,7 +29,7 @@ use frame_support::{ use frame_system::limits; use sp_core::Hasher as HasherT; use sp_runtime::{ - traits::{BlakeTwo256, Convert, IdentifyAccount, Verify}, + traits::{BlakeTwo256, IdentifyAccount, Verify}, FixedU128, MultiSignature, MultiSigner, Perbill, }; 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 for AccountIdConverter { - fn convert(hash: sp_core::H256) -> AccountId { - hash.to_fixed_bytes().into() - } -} - frame_support::parameter_types! { pub BlockLength: limits::BlockLength = 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 = "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 { - let encoded_id = bp_runtime::derive_account_id(bp_runtime::MILLAU_CHAIN_ID, id); - AccountIdConverter::convert(encoded_id) -} - sp_api::decl_runtime_apis! { /// API for querying information about the finalized RialtoParachain headers. /// diff --git a/bridges/primitives/chain-rialto/src/lib.rs b/bridges/primitives/chain-rialto/src/lib.rs index 9acc9f9f9a..e5d1abbc7e 100644 --- a/bridges/primitives/chain-rialto/src/lib.rs +++ b/bridges/primitives/chain-rialto/src/lib.rs @@ -29,7 +29,7 @@ use frame_support::{ use frame_system::limits; use sp_core::Hasher as HasherT; use sp_runtime::{ - traits::{BlakeTwo256, Convert, IdentifyAccount, Verify}, + traits::{BlakeTwo256, IdentifyAccount, Verify}, FixedU128, MultiSignature, MultiSigner, Perbill, }; 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 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 { - let encoded_id = bp_runtime::derive_account_id(bp_runtime::MILLAU_CHAIN_ID, id); - AccountIdConverter::convert(encoded_id) -} - frame_support::parameter_types! { pub BlockLength: limits::BlockLength = limits::BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO); diff --git a/bridges/primitives/chain-rococo/src/lib.rs b/bridges/primitives/chain-rococo/src/lib.rs index 1c2bfb42d0..ad3190a122 100644 --- a/bridges/primitives/chain-rococo/src/lib.rs +++ b/bridges/primitives/chain-rococo/src/lib.rs @@ -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 { - 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. pub const WITH_ROCOCO_GRANDPA_PALLET_NAME: &str = "BridgeRococoGrandpa"; /// Name of the With-Rococo messages pallet instance that is deployed at bridged chains. diff --git a/bridges/primitives/chain-westend/src/lib.rs b/bridges/primitives/chain-westend/src/lib.rs index 0dc4ccc65a..16c0252ea7 100644 --- a/bridges/primitives/chain-westend/src/lib.rs +++ b/bridges/primitives/chain-westend/src/lib.rs @@ -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 { - 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. pub const PARAS_PALLET_NAME: &str = "Paras"; diff --git a/bridges/primitives/chain-wococo/src/lib.rs b/bridges/primitives/chain-wococo/src/lib.rs index 6e0bad1227..83d913db7f 100644 --- a/bridges/primitives/chain-wococo/src/lib.rs +++ b/bridges/primitives/chain-wococo/src/lib.rs @@ -38,13 +38,6 @@ pub type Wococo = PolkadotLike; /// conditions. 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 { - 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. pub const WITH_WOCOCO_GRANDPA_PALLET_NAME: &str = "BridgeWococoGrandpa"; /// Name of the With-Wococo messages pallet instance that is deployed at bridged chains. diff --git a/bridges/primitives/messages/src/source_chain.rs b/bridges/primitives/messages/src/source_chain.rs index 8451941a40..be56ffe87f 100644 --- a/bridges/primitives/messages/src/source_chain.rs +++ b/bridges/primitives/messages/src/source_chain.rs @@ -133,7 +133,6 @@ pub trait MessageDeliveryAndDispatchPayment { fn pay_delivery_and_dispatch_fee( submitter: &SenderOrigin, fee: &Balance, - relayer_fund_account: &AccountId, ) -> Result<(), Self::Error>; /// Pay rewards for delivering messages to the given relayers. @@ -145,7 +144,6 @@ pub trait MessageDeliveryAndDispatchPayment { messages_relayers: VecDeque>, confirmation_relayer: &AccountId, received_range: &RangeInclusive, - relayer_fund_account: &AccountId, ); } @@ -157,7 +155,6 @@ impl fn pay_delivery_and_dispatch_fee( _submitter: &SenderOrigin, _fee: &Balance, - _relayer_fund_account: &AccountId, ) -> Result<(), Self::Error> { Ok(()) } @@ -167,7 +164,6 @@ impl _messages_relayers: VecDeque>, _confirmation_relayer: &AccountId, _received_range: &RangeInclusive, - _relayer_fund_account: &AccountId, ) { } } @@ -306,7 +302,6 @@ impl fn pay_delivery_and_dispatch_fee( _submitter: &SenderOrigin, _fee: &Balance, - _relayer_fund_account: &AccountId, ) -> Result<(), Self::Error> { Err(ALL_OUTBOUND_MESSAGES_REJECTED) } @@ -316,7 +311,6 @@ impl _messages_relayers: VecDeque>, _confirmation_relayer: &AccountId, _received_range: &RangeInclusive, - _relayer_fund_account: &AccountId, ) { } } diff --git a/bridges/primitives/polkadot-core/src/lib.rs b/bridges/primitives/polkadot-core/src/lib.rs index 4b0ef430ad..6245c2b169 100644 --- a/bridges/primitives/polkadot-core/src/lib.rs +++ b/bridges/primitives/polkadot-core/src/lib.rs @@ -390,15 +390,6 @@ impl Chain for PolkadotLike { } } -/// Convert a 256-bit hash into an AccountId. -pub struct AccountIdConverter; - -impl Convert for AccountIdConverter { - fn convert(hash: sp_core::H256) -> AccountId { - hash.to_fixed_bytes().into() - } -} - /// Return a storage key for account data. /// /// This is based on FRAME storage-generation code from Substrate: diff --git a/bridges/primitives/runtime/src/lib.rs b/bridges/primitives/runtime/src/lib.rs index 2849e346da..ca8a22ee16 100644 --- a/bridges/primitives/runtime/src/lib.rs +++ b/bridges/primitives/runtime/src/lib.rs @@ -127,16 +127,6 @@ where .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. pub trait Size { /// Return size of this object (in bytes). diff --git a/bridges/relays/bin-substrate/src/cli/bridge.rs b/bridges/relays/bin-substrate/src/cli/bridge.rs index 103c9cb391..3ef324265c 100644 --- a/bridges/relays/bin-substrate/src/cli/bridge.rs +++ b/bridges/relays/bin-substrate/src/cli/bridge.rs @@ -15,7 +15,6 @@ // along with Parity Bridges Common. If not, see . use crate::cli::CliChain; -use bp_runtime::{AccountIdOf, SourceAccount}; use relay_substrate_client::{AccountKeyPairOf, Chain, TransactionSignScheme}; use strum::{EnumString, EnumVariantNames}; use substrate_relay_helper::{ @@ -82,11 +81,6 @@ pub trait MessagesCliBridge: CliBridgeBase { SourceTransactionSignScheme = Self::Source, 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; } //// `Millau` to `Rialto` bridge definition. @@ -105,12 +99,6 @@ impl MessagesCliBridge for MillauToRialtoCliBridge { const ESTIMATE_MESSAGE_FEE_METHOD: &'static str = bp_rialto::TO_RIALTO_ESTIMATE_MESSAGE_FEE_METHOD; type MessagesLane = crate::chains::millau_messages_to_rialto::MillauMessagesToRialto; - - fn derive_account_from_id( - id: SourceAccount>, - ) -> AccountIdOf { - bp_rialto::derive_account_from_millau_id(id) - } } //// `Rialto` to `Millau` bridge definition. @@ -129,14 +117,6 @@ impl MessagesCliBridge for RialtoToMillauCliBridge { const ESTIMATE_MESSAGE_FEE_METHOD: &'static str = bp_millau::TO_MILLAU_ESTIMATE_MESSAGE_FEE_METHOD; 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 { - bp_millau::derive_account_from_rialto_id(id) - } } //// `Westend` to `Millau` bridge definition. @@ -169,12 +149,6 @@ impl MessagesCliBridge for MillauToRialtoParachainCliBridge { bp_rialto_parachain::TO_RIALTO_PARACHAIN_ESTIMATE_MESSAGE_FEE_METHOD; type MessagesLane = crate::chains::millau_messages_to_rialto_parachain::MillauMessagesToRialtoParachain; - - fn derive_account_from_id( - id: SourceAccount>, - ) -> AccountIdOf { - bp_rialto_parachain::derive_account_from_millau_id(id) - } } //// `RialtoParachain` to `Millau` bridge definition. @@ -190,12 +164,6 @@ impl MessagesCliBridge for RialtoParachainToMillauCliBridge { bp_millau::TO_MILLAU_ESTIMATE_MESSAGE_FEE_METHOD; type MessagesLane = crate::chains::rialto_parachain_messages_to_millau::RialtoParachainMessagesToMillau; - - fn derive_account_from_id( - id: SourceAccount>, - ) -> AccountIdOf { - bp_millau::derive_account_from_rialto_parachain_id(id) - } } //// `WestendParachain` to `Millau` bridge definition. diff --git a/bridges/relays/bin-substrate/src/cli/relay_headers_and_messages.rs b/bridges/relays/bin-substrate/src/cli/relay_headers_and_messages.rs index c1e0acaea3..4d6456cc61 100644 --- a/bridges/relays/bin-substrate/src/cli/relay_headers_and_messages.rs +++ b/bridges/relays/bin-substrate/src/cli/relay_headers_and_messages.rs @@ -77,9 +77,6 @@ pub struct HeadersAndMessagesSharedParams { lane: Vec, #[structopt(long, possible_values = RelayerMode::VARIANTS, case_insensitive = true, default_value = "rational")] 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) /// are relayed. #[structopt(long)] @@ -185,9 +182,6 @@ macro_rules! select_bridge { type Left = relay_millau_client::Millau; type Right = relay_rialto_client::Rialto; - type LeftAccountIdConverter = bp_millau::AccountIdConverter; - type RightAccountIdConverter = bp_rialto::AccountIdConverter; - use crate::chains::{ millau_messages_to_rialto::MillauMessagesToRialto as LeftToRightMessageLane, rialto_messages_to_millau::RialtoMessagesToMillau as RightToLeftMessageLane, @@ -222,22 +216,6 @@ macro_rules! select_bridge { ).await } - async fn left_create_account( - _left_client: Client, - _left_sign: ::AccountKeyPair, - _account_id: AccountIdOf, - ) -> anyhow::Result<()> { - Err(anyhow::format_err!("Account creation is not supported by this bridge")) - } - - async fn right_create_account( - _right_client: Client, - _right_sign: ::AccountKeyPair, - _account_id: AccountIdOf, - ) -> anyhow::Result<()> { - Err(anyhow::format_err!("Account creation is not supported by this bridge")) - } - $generic }, RelayHeadersAndMessages::MillauRialtoParachain(_) => { @@ -246,9 +224,6 @@ macro_rules! select_bridge { type Left = relay_millau_client::Millau; type Right = relay_rialto_parachain_client::RialtoParachain; - type LeftAccountIdConverter = bp_millau::AccountIdConverter; - type RightAccountIdConverter = bp_rialto_parachain::AccountIdConverter; - use crate::chains::{ millau_messages_to_rialto_parachain::MillauMessagesToRialtoParachain as LeftToRightMessageLane, rialto_parachain_messages_to_millau::RialtoParachainMessagesToMillau as RightToLeftMessageLane, @@ -290,22 +265,6 @@ macro_rules! select_bridge { ).await } - async fn left_create_account( - _left_client: Client, - _left_sign: ::AccountKeyPair, - _account_id: AccountIdOf, - ) -> anyhow::Result<()> { - Err(anyhow::format_err!("Account creation is not supported by this bridge")) - } - - async fn right_create_account( - _right_client: Client, - _right_sign: ::AccountKeyPair, - _account_id: AccountIdOf, - ) -> anyhow::Result<()> { - Err(anyhow::format_err!("Account creation is not supported by this bridge")) - } - $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, - 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, - 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 let (left_to_right_on_demand_headers, right_to_left_on_demand_headers) = start_on_demand_relays( @@ -785,7 +705,6 @@ mod tests { HexLaneId([0x73, 0x77, 0x61, 0x70]) ], relayer_mode: RelayerMode::Rational, - create_relayers_fund_accounts: false, only_mandatory_headers: false, prometheus_params: PrometheusParams { no_prometheus: false, @@ -899,7 +818,6 @@ mod tests { shared: HeadersAndMessagesSharedParams { lane: vec![HexLaneId([0x00, 0x00, 0x00, 0x00])], relayer_mode: RelayerMode::Rational, - create_relayers_fund_accounts: false, only_mandatory_headers: false, prometheus_params: PrometheusParams { no_prometheus: false,