From 477c08e45743a4f0f1698dc2c8de1d1af390a167 Mon Sep 17 00:00:00 2001 From: Branislav Kontur Date: Thu, 28 Nov 2024 12:41:09 +0100 Subject: [PATCH] BACKPORT-CONFLICT --- .../extensions/refund_relayer_extension.rs | 75 +++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/bridges/bin/runtime-common/src/extensions/refund_relayer_extension.rs b/bridges/bin/runtime-common/src/extensions/refund_relayer_extension.rs index 6ba3506377d0..d6dd6c65b726 100644 --- a/bridges/bin/runtime-common/src/extensions/refund_relayer_extension.rs +++ b/bridges/bin/runtime-common/src/extensions/refund_relayer_extension.rs @@ -228,9 +228,44 @@ pub enum RelayerAccountAction { Slash(AccountId, RewardsAccountParams), } +<<<<<<< HEAD:bridges/bin/runtime-common/src/extensions/refund_relayer_extension.rs /// Everything common among our refund signed extensions. pub trait RefundSignedExtension: 'static + Clone + Codec + sp_std::fmt::Debug + Default + Eq + PartialEq + Send + Sync + TypeInfo +======= +/// A signed extension, built around `pallet-bridge-relayers`. +/// +/// It may be incorporated into runtime to refund relayers for submitting correct +/// message delivery and confirmation transactions, optionally batched with required +/// finality proofs. +#[derive( + DefaultNoBound, + CloneNoBound, + Decode, + Encode, + EqNoBound, + PartialEqNoBound, + RuntimeDebugNoBound, + TypeInfo, +)] +#[scale_info(skip_type_params(Runtime, Config, LaneId))] +pub struct BridgeRelayersTransactionExtension( + PhantomData<(Runtime, Config, LaneId)>, +); + +impl BridgeRelayersTransactionExtension +where + Self: 'static + Send + Sync, + R: RelayersConfig + + BridgeMessagesConfig + + TransactionPaymentConfig, + C: ExtensionConfig, + R::RuntimeCall: Dispatchable, + ::RuntimeOrigin: AsSystemOriginSigner + Clone, + ::OnChargeTransaction: + OnChargeTransaction, + LaneId: Clone + Copy + Decode + Encode + Debug + TypeInfo, +>>>>>>> 9ec8009 (Multiple instances for pallet-bridge-relayers fix (#6684)):bridges/modules/relayers/src/extension/mod.rs { /// This chain runtime. type Runtime: MessagesConfig<::Instance> @@ -371,7 +406,11 @@ pub trait RefundSignedExtension: // let's also replace the weight of slashing relayer with the weight of rewarding relayer if call_info.is_receive_messages_proof_call() { post_info_weight = post_info_weight.saturating_sub( +<<<<<<< HEAD:bridges/bin/runtime-common/src/extensions/refund_relayer_extension.rs ::WeightInfo::extra_weight_of_successful_receive_messages_proof_call(), +======= + >::WeightInfo::extra_weight_of_successful_receive_messages_proof_call(), +>>>>>>> 9ec8009 (Multiple instances for pallet-bridge-relayers fix (#6684)):bridges/modules/relayers/src/extension/mod.rs ); } @@ -415,6 +454,7 @@ pub trait RefundSignedExtension: } } +<<<<<<< HEAD:bridges/bin/runtime-common/src/extensions/refund_relayer_extension.rs /// Adapter that allow implementing `sp_runtime::traits::SignedExtension` for any /// `RefundSignedExtension`. #[derive( @@ -428,6 +468,26 @@ pub trait RefundSignedExtension: TypeInfo, )] pub struct RefundSignedExtensionAdapter(T); +======= +impl TransactionExtension + for BridgeRelayersTransactionExtension +where + Self: 'static + Send + Sync, + R: RelayersConfig + + BridgeMessagesConfig + + TransactionPaymentConfig, + C: ExtensionConfig, + R::RuntimeCall: Dispatchable, + ::RuntimeOrigin: AsSystemOriginSigner + Clone, + ::OnChargeTransaction: + OnChargeTransaction, + LaneId: Clone + Copy + Decode + Encode + Debug + TypeInfo, +{ + const IDENTIFIER: &'static str = C::IdProvider::STR; + type Implicit = (); + type Pre = Option>; + type Val = Self::Pre; +>>>>>>> 9ec8009 (Multiple instances for pallet-bridge-relayers fix (#6684)):bridges/modules/relayers/src/extension/mod.rs impl SignedExtension for RefundSignedExtensionAdapter where @@ -467,8 +527,15 @@ where }; // we only boost priority if relayer has staked required balance +<<<<<<< HEAD:bridges/bin/runtime-common/src/extensions/refund_relayer_extension.rs if !RelayersPallet::::is_registration_active(who) { return Ok(Default::default()) +======= + if !RelayersPallet::::is_registration_active( + &data.relayer, + ) { + return Ok((Default::default(), Some(data), origin)) +>>>>>>> 9ec8009 (Multiple instances for pallet-bridge-relayers fix (#6684)):bridges/modules/relayers/src/extension/mod.rs } // compute priority boost @@ -525,7 +592,11 @@ where match call_result { RelayerAccountAction::None => (), RelayerAccountAction::Reward(relayer, reward_account, reward) => { +<<<<<<< HEAD:bridges/bin/runtime-common/src/extensions/refund_relayer_extension.rs RelayersPallet::::register_relayer_reward( +======= + RelayersPallet::::register_relayer_reward( +>>>>>>> 9ec8009 (Multiple instances for pallet-bridge-relayers fix (#6684)):bridges/modules/relayers/src/extension/mod.rs reward_account, &relayer, reward, @@ -541,7 +612,11 @@ where ); }, RelayerAccountAction::Slash(relayer, slash_account) => +<<<<<<< HEAD:bridges/bin/runtime-common/src/extensions/refund_relayer_extension.rs RelayersPallet::::slash_and_deregister( +======= + RelayersPallet::::slash_and_deregister( +>>>>>>> 9ec8009 (Multiple instances for pallet-bridge-relayers fix (#6684)):bridges/modules/relayers/src/extension/mod.rs &relayer, ExplicitOrAccountParams::Params(slash_account), ),