diff --git a/bridges/bin/runtime-common/Cargo.toml b/bridges/bin/runtime-common/Cargo.toml index b33667d9be67c8d29ec7c6e9d5778eb3ccc1e443..af0c658a0516d22921431c0ba3af5cd043a9cfaf 100644 --- a/bridges/bin/runtime-common/Cargo.toml +++ b/bridges/bin/runtime-common/Cargo.toml @@ -13,7 +13,7 @@ workspace = true [dependencies] codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false, features = ["derive"] } hash-db = { version = "0.16.0", default-features = false } -log = { version = "0.4.21", default-features = false } +log = { workspace = true } scale-info = { version = "2.10.0", default-features = false, features = ["derive"] } static_assertions = { version = "1.1", optional = true } @@ -93,6 +93,7 @@ runtime-benchmarks = [ "pallet-bridge-messages/runtime-benchmarks", "pallet-bridge-parachains/runtime-benchmarks", "pallet-bridge-relayers/runtime-benchmarks", + "pallet-transaction-payment/runtime-benchmarks", "pallet-utility/runtime-benchmarks", "sp-runtime/runtime-benchmarks", "xcm-builder/runtime-benchmarks", diff --git a/bridges/bin/runtime-common/src/lib.rs b/bridges/bin/runtime-common/src/lib.rs index 2722f6f1c6d14f09ab215f8f020f2c449eda4d4b..035077408c40bd42c9e941c19af868989d66e362 100644 --- a/bridges/bin/runtime-common/src/lib.rs +++ b/bridges/bin/runtime-common/src/lib.rs @@ -105,43 +105,48 @@ macro_rules! generate_bridge_reject_obsolete_headers_and_messages { ($call:ty, $account_id:ty, $($filter_call:ty),*) => { #[derive(Clone, codec::Decode, Default, codec::Encode, Eq, PartialEq, sp_runtime::RuntimeDebug, scale_info::TypeInfo)] pub struct BridgeRejectObsoleteHeadersAndMessages; - impl sp_runtime::traits::SignedExtension for BridgeRejectObsoleteHeadersAndMessages { + impl sp_runtime::traits::TransactionExtensionBase for BridgeRejectObsoleteHeadersAndMessages { const IDENTIFIER: &'static str = "BridgeRejectObsoleteHeadersAndMessages"; - type AccountId = $account_id; - type Call = $call; - type AdditionalSigned = (); + type Implicit = (); + } + impl<Context> sp_runtime::traits::TransactionExtension<$call, Context> for BridgeRejectObsoleteHeadersAndMessages { type Pre = (); - - fn additional_signed(&self) -> sp_std::result::Result< - (), - sp_runtime::transaction_validity::TransactionValidityError, - > { - Ok(()) - } + type Val = (); fn validate( &self, - _who: &Self::AccountId, - call: &Self::Call, - _info: &sp_runtime::traits::DispatchInfoOf<Self::Call>, + origin: <$call as sp_runtime::traits::Dispatchable>::RuntimeOrigin, + call: &$call, + _info: &sp_runtime::traits::DispatchInfoOf<$call>, _len: usize, - ) -> sp_runtime::transaction_validity::TransactionValidity { - let valid = sp_runtime::transaction_validity::ValidTransaction::default(); + _context: &mut Context, + _self_implicit: Self::Implicit, + _inherited_implication: &impl codec::Encode, + ) -> Result< + ( + sp_runtime::transaction_validity::ValidTransaction, + Self::Val, + <$call as sp_runtime::traits::Dispatchable>::RuntimeOrigin, + ), sp_runtime::transaction_validity::TransactionValidityError + > { + let tx_validity = sp_runtime::transaction_validity::ValidTransaction::default(); $( - let valid = valid - .combine_with(<$filter_call as $crate::BridgeRuntimeFilterCall<$call>>::validate(call)?); + let call_filter_validity = <$filter_call as $crate::BridgeRuntimeFilterCall<$call>>::validate(call)?; + let tx_validity = tx_validity.combine_with(call_filter_validity); )* - Ok(valid) + Ok((tx_validity, (), origin)) } - fn pre_dispatch( + fn prepare( self, - who: &Self::AccountId, - call: &Self::Call, - info: &sp_runtime::traits::DispatchInfoOf<Self::Call>, - len: usize, + _val: Self::Val, + _origin: &<$call as sp_runtime::traits::Dispatchable>::RuntimeOrigin, + _call: &$call, + _info: &sp_runtime::traits::DispatchInfoOf<$call>, + _len: usize, + _context: &Context, ) -> Result<Self::Pre, sp_runtime::transaction_validity::TransactionValidityError> { - self.validate(who, call, info, len).map(drop) + Ok(()) } } }; @@ -150,12 +155,14 @@ macro_rules! generate_bridge_reject_obsolete_headers_and_messages { #[cfg(test)] mod tests { use crate::BridgeRuntimeFilterCall; - use frame_support::{assert_err, assert_ok}; + use codec::Encode; + use frame_support::assert_err; use sp_runtime::{ - traits::SignedExtension, + traits::DispatchTransaction, transaction_validity::{InvalidTransaction, TransactionValidity, ValidTransaction}, }; + #[derive(Encode)] pub struct MockCall { data: u32, } @@ -206,17 +213,20 @@ mod tests { ); assert_err!( - BridgeRejectObsoleteHeadersAndMessages.validate(&(), &MockCall { data: 1 }, &(), 0), + BridgeRejectObsoleteHeadersAndMessages.validate_only((), &MockCall { data: 1 }, &(), 0), InvalidTransaction::Custom(1) ); assert_err!( - BridgeRejectObsoleteHeadersAndMessages.validate(&(), &MockCall { data: 2 }, &(), 0), + BridgeRejectObsoleteHeadersAndMessages.validate_only((), &MockCall { data: 2 }, &(), 0), InvalidTransaction::Custom(2) ); - assert_ok!( - BridgeRejectObsoleteHeadersAndMessages.validate(&(), &MockCall { data: 3 }, &(), 0), + assert_eq!( + BridgeRejectObsoleteHeadersAndMessages + .validate_only((), &MockCall { data: 3 }, &(), 0) + .unwrap() + .0, ValidTransaction { priority: 3, ..Default::default() } ) } diff --git a/bridges/bin/runtime-common/src/mock.rs b/bridges/bin/runtime-common/src/mock.rs index 8877a4fd95ce33150824b78674f38860616cf820..f147f1404f06fb60c608d4ad049502c6e184a85f 100644 --- a/bridges/bin/runtime-common/src/mock.rs +++ b/bridges/bin/runtime-common/src/mock.rs @@ -164,6 +164,7 @@ impl pallet_balances::Config for TestRuntime { type AccountStore = System; } +#[derive_impl(pallet_transaction_payment::config_preludes::TestDefaultConfig as pallet_transaction_payment::DefaultConfig)] impl pallet_transaction_payment::Config for TestRuntime { type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, ()>; type OperationalFeeMultiplier = ConstU8<5>; @@ -176,7 +177,6 @@ impl pallet_transaction_payment::Config for TestRuntime { MinimumMultiplier, MaximumMultiplier, >; - type RuntimeEvent = RuntimeEvent; } impl pallet_bridge_grandpa::Config for TestRuntime { diff --git a/bridges/bin/runtime-common/src/priority_calculator.rs b/bridges/bin/runtime-common/src/priority_calculator.rs index a597fb9e2f49289360acfd7ee305b44eb7874a3e..0c53018330ea0ebc2fbacb32808e01a9ec88960f 100644 --- a/bridges/bin/runtime-common/src/priority_calculator.rs +++ b/bridges/bin/runtime-common/src/priority_calculator.rs @@ -169,12 +169,15 @@ mod integrity_tests { // nodes to the proof (x0.5 because we expect some nodes to be reused) let estimated_message_size = 512; // let's say all our messages have the same dispatch weight - let estimated_message_dispatch_weight = - Runtime::WeightInfo::message_dispatch_weight(estimated_message_size); + let estimated_message_dispatch_weight = <Runtime as pallet_bridge_messages::Config< + MessagesInstance, + >>::WeightInfo::message_dispatch_weight( + estimated_message_size + ); // messages proof argument size is (for every message) messages size + some additional // trie nodes. Some of them are reused by different messages, so let's take 2/3 of default // "overhead" constant - let messages_proof_size = Runtime::WeightInfo::expected_extra_storage_proof_size() + let messages_proof_size = <Runtime as pallet_bridge_messages::Config<MessagesInstance>>::WeightInfo::expected_extra_storage_proof_size() .saturating_mul(2) .saturating_div(3) .saturating_add(estimated_message_size) @@ -182,7 +185,7 @@ mod integrity_tests { // finally we are able to estimate transaction size and weight let transaction_size = base_tx_size.saturating_add(messages_proof_size); - let transaction_weight = Runtime::WeightInfo::receive_messages_proof_weight( + let transaction_weight = <Runtime as pallet_bridge_messages::Config<MessagesInstance>>::WeightInfo::receive_messages_proof_weight( &PreComputedSize(transaction_size as _), messages as _, estimated_message_dispatch_weight.saturating_mul(messages), diff --git a/bridges/bin/runtime-common/src/refund_relayer_extension.rs b/bridges/bin/runtime-common/src/refund_relayer_extension.rs index bfcb82ad166c3a2a60891c1e18f2ad22e085cb1b..b912f8445ac1b455e95110d41347ac8e55afaa7c 100644 --- a/bridges/bin/runtime-common/src/refund_relayer_extension.rs +++ b/bridges/bin/runtime-common/src/refund_relayer_extension.rs @@ -48,9 +48,12 @@ use pallet_transaction_payment::{Config as TransactionPaymentConfig, OnChargeTra use pallet_utility::{Call as UtilityCall, Config as UtilityConfig, Pallet as UtilityPallet}; use scale_info::TypeInfo; use sp_runtime::{ - traits::{DispatchInfoOf, Dispatchable, Get, PostDispatchInfoOf, SignedExtension, Zero}, + traits::{ + AsSystemOriginSigner, DispatchInfoOf, Dispatchable, Get, PostDispatchInfoOf, + TransactionExtension, TransactionExtensionBase, ValidateResult, Zero, + }, transaction_validity::{ - TransactionPriority, TransactionValidity, TransactionValidityError, ValidTransactionBuilder, + InvalidTransaction, TransactionPriority, TransactionValidityError, ValidTransactionBuilder, }, DispatchResult, FixedPointOperand, RuntimeDebug, }; @@ -239,8 +242,8 @@ pub enum RelayerAccountAction<AccountId, Reward> { Slash(AccountId, RewardsAccountParams), } -/// Everything common among our refund signed extensions. -pub trait RefundSignedExtension: +/// Everything common among our refund transaction extensions. +pub trait RefundTransactionExtension: 'static + Clone + Codec + sp_std::fmt::Debug + Default + Eq + PartialEq + Send + Sync + TypeInfo where <Self::Runtime as GrandpaConfig<Self::GrandpaInstance>>::BridgedChain: @@ -456,8 +459,8 @@ where } } -/// Adapter that allow implementing `sp_runtime::traits::SignedExtension` for any -/// `RefundSignedExtension`. +/// Adapter that allow implementing `sp_runtime::traits::TransactionExtension` for any +/// `RefundTransactionExtension`. #[derive( DefaultNoBound, CloneNoBound, @@ -468,12 +471,13 @@ where RuntimeDebugNoBound, TypeInfo, )] -pub struct RefundSignedExtensionAdapter<T: RefundSignedExtension>(T) +pub struct RefundTransactionExtensionAdapter<T: RefundTransactionExtension>(T) where <T::Runtime as GrandpaConfig<T::GrandpaInstance>>::BridgedChain: Chain<BlockNumber = RelayBlockNumber>; -impl<T: RefundSignedExtension> SignedExtension for RefundSignedExtensionAdapter<T> +impl<T: RefundTransactionExtension> TransactionExtensionBase + for RefundTransactionExtensionAdapter<T> where <T::Runtime as GrandpaConfig<T::GrandpaInstance>>::BridgedChain: Chain<BlockNumber = RelayBlockNumber>, @@ -483,22 +487,35 @@ where + MessagesCallSubType<T::Runtime, <T::Msgs as RefundableMessagesLaneId>::Instance>, { const IDENTIFIER: &'static str = T::Id::STR; - type AccountId = AccountIdOf<T::Runtime>; - type Call = CallOf<T::Runtime>; - type AdditionalSigned = (); - type Pre = Option<PreDispatchData<AccountIdOf<T::Runtime>>>; + type Implicit = (); +} - fn additional_signed(&self) -> Result<(), TransactionValidityError> { - Ok(()) - } +impl<T: RefundTransactionExtension, Context> TransactionExtension<CallOf<T::Runtime>, Context> + for RefundTransactionExtensionAdapter<T> +where + <T::Runtime as GrandpaConfig<T::GrandpaInstance>>::BridgedChain: + Chain<BlockNumber = RelayBlockNumber>, + CallOf<T::Runtime>: Dispatchable<Info = DispatchInfo, PostInfo = PostDispatchInfo> + + IsSubType<CallableCallFor<UtilityPallet<T::Runtime>, T::Runtime>> + + GrandpaCallSubType<T::Runtime, T::GrandpaInstance> + + MessagesCallSubType<T::Runtime, <T::Msgs as RefundableMessagesLaneId>::Instance>, + <CallOf<T::Runtime> as Dispatchable>::RuntimeOrigin: + AsSystemOriginSigner<AccountIdOf<T::Runtime>> + Clone, +{ + type Pre = Option<PreDispatchData<AccountIdOf<T::Runtime>>>; + type Val = Option<CallInfo>; fn validate( &self, - who: &Self::AccountId, - call: &Self::Call, - _info: &DispatchInfoOf<Self::Call>, + origin: <CallOf<T::Runtime> as Dispatchable>::RuntimeOrigin, + call: &CallOf<T::Runtime>, + _info: &DispatchInfoOf<CallOf<T::Runtime>>, _len: usize, - ) -> TransactionValidity { + _context: &mut Context, + _self_implicit: Self::Implicit, + _inherited_implication: &impl Encode, + ) -> ValidateResult<Self::Val, CallOf<T::Runtime>> { + let who = origin.as_system_origin_signer().ok_or(InvalidTransaction::BadSigner)?; // this is the only relevant line of code for the `pre_dispatch` // // we're not calling `validate` from `pre_dispatch` directly because of performance @@ -511,12 +528,12 @@ where // we only boost priority of presumably correct message delivery transactions let bundled_messages = match T::bundled_messages_for_priority_boost(parsed_call.as_ref()) { Some(bundled_messages) => bundled_messages, - None => return Ok(Default::default()), + None => return Ok((Default::default(), parsed_call, origin)), }; // we only boost priority if relayer has staked required balance if !RelayersPallet::<T::Runtime>::is_registration_active(who) { - return Ok(Default::default()) + return Ok((Default::default(), parsed_call, origin)) } // compute priority boost @@ -535,20 +552,21 @@ where priority_boost, ); - valid_transaction.build() + let validity = valid_transaction.build()?; + Ok((validity, parsed_call, origin)) } - fn pre_dispatch( + fn prepare( self, - who: &Self::AccountId, - call: &Self::Call, - _info: &DispatchInfoOf<Self::Call>, + val: Self::Val, + origin: &<CallOf<T::Runtime> as Dispatchable>::RuntimeOrigin, + _call: &CallOf<T::Runtime>, + _info: &DispatchInfoOf<CallOf<T::Runtime>>, _len: usize, + _context: &Context, ) -> Result<Self::Pre, TransactionValidityError> { - // this is a relevant piece of `validate` that we need here (in `pre_dispatch`) - let parsed_call = T::parse_and_check_for_obsolete_call(call)?; - - Ok(parsed_call.map(|call_info| { + let who = origin.as_system_origin_signer().ok_or(InvalidTransaction::BadSigner)?; + Ok(val.map(|call_info| { log::trace!( target: "runtime::bridge", "{} via {:?} parsed bridge transaction in pre-dispatch: {:?}", @@ -561,13 +579,14 @@ where } fn post_dispatch( - pre: Option<Self::Pre>, - info: &DispatchInfoOf<Self::Call>, - post_info: &PostDispatchInfoOf<Self::Call>, + pre: Self::Pre, + info: &DispatchInfoOf<CallOf<T::Runtime>>, + post_info: &PostDispatchInfoOf<CallOf<T::Runtime>>, len: usize, result: &DispatchResult, + _context: &Context, ) -> Result<(), TransactionValidityError> { - let call_result = T::analyze_call_result(pre, info, post_info, len, result); + let call_result = T::analyze_call_result(Some(pre), info, post_info, len, result); match call_result { RelayerAccountAction::None => (), @@ -595,7 +614,7 @@ where } } -/// Signed extension that refunds a relayer for new messages coming from a parachain. +/// Transaction extension that refunds a relayer for new messages coming from a parachain. /// /// Also refunds relayer for successful finality delivery if it comes in batch (`utility.batchAll`) /// with message delivery transaction. Batch may deliver either both relay chain header and @@ -636,7 +655,7 @@ pub struct RefundBridgedParachainMessages<Runtime, Para, Msgs, Refund, Priority, )>, ); -impl<Runtime, Para, Msgs, Refund, Priority, Id> RefundSignedExtension +impl<Runtime, Para, Msgs, Refund, Priority, Id> RefundTransactionExtension for RefundBridgedParachainMessages<Runtime, Para, Msgs, Refund, Priority, Id> where Self: 'static + Send + Sync, @@ -730,13 +749,13 @@ where } } -/// Signed extension that refunds a relayer for new messages coming from a standalone (GRANDPA) +/// Transaction extension that refunds a relayer for new messages coming from a standalone (GRANDPA) /// chain. /// /// Also refunds relayer for successful finality delivery if it comes in batch (`utility.batchAll`) /// with message delivery transaction. Batch may deliver either both relay chain header and -/// parachain head, or just parachain head. Corresponding headers must be used in messages -/// proof verification. +/// parachain head, or just parachain head. Corresponding headers must be used in messages proof +/// verification. /// /// Extension does not refund transaction tip due to security reasons. #[derive( @@ -771,7 +790,7 @@ pub struct RefundBridgedGrandpaMessages<Runtime, GrandpaInstance, Msgs, Refund, )>, ); -impl<Runtime, GrandpaInstance, Msgs, Refund, Priority, Id> RefundSignedExtension +impl<Runtime, GrandpaInstance, Msgs, Refund, Priority, Id> RefundTransactionExtension for RefundBridgedGrandpaMessages<Runtime, GrandpaInstance, Msgs, Refund, Priority, Id> where Self: 'static + Send + Sync, @@ -869,8 +888,8 @@ mod tests { Call as ParachainsCall, Pallet as ParachainsPallet, RelayBlockHash, }; use sp_runtime::{ - traits::{ConstU64, Header as HeaderT}, - transaction_validity::{InvalidTransaction, ValidTransaction}, + traits::{ConstU64, DispatchTransaction, Header as HeaderT}, + transaction_validity::{InvalidTransaction, TransactionValidity, ValidTransaction}, DispatchError, }; @@ -899,7 +918,7 @@ mod tests { ConstU64<1>, StrTestExtension, >; - type TestGrandpaExtension = RefundSignedExtensionAdapter<TestGrandpaExtensionProvider>; + type TestGrandpaExtension = RefundTransactionExtensionAdapter<TestGrandpaExtensionProvider>; type TestExtensionProvider = RefundBridgedParachainMessages< TestRuntime, DefaultRefundableParachainId<(), TestParachain>, @@ -908,7 +927,7 @@ mod tests { ConstU64<1>, StrTestExtension, >; - type TestExtension = RefundSignedExtensionAdapter<TestExtensionProvider>; + type TestExtension = RefundTransactionExtensionAdapter<TestExtensionProvider>; fn initial_balance_of_relayer_account_at_this_chain() -> ThisChainBalance { let test_stake: ThisChainBalance = TestStake::get(); @@ -1407,14 +1426,28 @@ mod tests { fn run_validate(call: RuntimeCall) -> TransactionValidity { let extension: TestExtension = - RefundSignedExtensionAdapter(RefundBridgedParachainMessages(PhantomData)); - extension.validate(&relayer_account_at_this_chain(), &call, &DispatchInfo::default(), 0) + RefundTransactionExtensionAdapter(RefundBridgedParachainMessages(PhantomData)); + extension + .validate_only( + Some(relayer_account_at_this_chain()).into(), + &call, + &DispatchInfo::default(), + 0, + ) + .map(|res| res.0) } fn run_grandpa_validate(call: RuntimeCall) -> TransactionValidity { let extension: TestGrandpaExtension = - RefundSignedExtensionAdapter(RefundBridgedGrandpaMessages(PhantomData)); - extension.validate(&relayer_account_at_this_chain(), &call, &DispatchInfo::default(), 0) + RefundTransactionExtensionAdapter(RefundBridgedGrandpaMessages(PhantomData)); + extension + .validate_only( + Some(relayer_account_at_this_chain()).into(), + &call, + &DispatchInfo::default(), + 0, + ) + .map(|res| res.0) } fn run_validate_ignore_priority(call: RuntimeCall) -> TransactionValidity { @@ -1428,16 +1461,30 @@ mod tests { call: RuntimeCall, ) -> Result<Option<PreDispatchData<ThisChainAccountId>>, TransactionValidityError> { let extension: TestExtension = - RefundSignedExtensionAdapter(RefundBridgedParachainMessages(PhantomData)); - extension.pre_dispatch(&relayer_account_at_this_chain(), &call, &DispatchInfo::default(), 0) + RefundTransactionExtensionAdapter(RefundBridgedParachainMessages(PhantomData)); + extension + .validate_and_prepare( + Some(relayer_account_at_this_chain()).into(), + &call, + &DispatchInfo::default(), + 0, + ) + .map(|(pre, _)| pre) } fn run_grandpa_pre_dispatch( call: RuntimeCall, ) -> Result<Option<PreDispatchData<ThisChainAccountId>>, TransactionValidityError> { let extension: TestGrandpaExtension = - RefundSignedExtensionAdapter(RefundBridgedGrandpaMessages(PhantomData)); - extension.pre_dispatch(&relayer_account_at_this_chain(), &call, &DispatchInfo::default(), 0) + RefundTransactionExtensionAdapter(RefundBridgedGrandpaMessages(PhantomData)); + extension + .validate_and_prepare( + Some(relayer_account_at_this_chain()).into(), + &call, + &DispatchInfo::default(), + 0, + ) + .map(|(pre, _)| pre) } fn dispatch_info() -> DispatchInfo { @@ -1460,11 +1507,12 @@ mod tests { dispatch_result: DispatchResult, ) { let post_dispatch_result = TestExtension::post_dispatch( - Some(pre_dispatch_data), + pre_dispatch_data, &dispatch_info(), &post_dispatch_info(), 1024, &dispatch_result, + &(), ); assert_eq!(post_dispatch_result, Ok(())); } diff --git a/bridges/modules/beefy/Cargo.toml b/bridges/modules/beefy/Cargo.toml index 3ff70eaafd231551134e8c4d79234431a864bc8f..30c91feb56da64b612dd3393262e8d587687d7cd 100644 --- a/bridges/modules/beefy/Cargo.toml +++ b/bridges/modules/beefy/Cargo.toml @@ -11,9 +11,9 @@ workspace = true [dependencies] codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false } -log = { version = "0.4.21", default-features = false } +log = { workspace = true } scale-info = { version = "2.10.0", default-features = false, features = ["derive"] } -serde = { version = "1.0", optional = true } +serde = { optional = true, workspace = true } # Bridge Dependencies diff --git a/bridges/modules/grandpa/Cargo.toml b/bridges/modules/grandpa/Cargo.toml index 33ba0f1f0fdcf5c5992d0ffc5debd263c0febdf2..1a5bfeff16e9db3a63d2acea3ec644be877891a3 100644 --- a/bridges/modules/grandpa/Cargo.toml +++ b/bridges/modules/grandpa/Cargo.toml @@ -14,7 +14,7 @@ workspace = true [dependencies] codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false } finality-grandpa = { version = "0.16.2", default-features = false } -log = { version = "0.4.21", default-features = false } +log = { workspace = true } scale-info = { version = "2.10.0", default-features = false, features = ["derive"] } # Bridge Dependencies diff --git a/bridges/modules/messages/Cargo.toml b/bridges/modules/messages/Cargo.toml index 75efb2ed5733342525bdd2128a3e8bf7bcc43c06..f6b1e71203dd1857f290b27a4058d3d28cecd272 100644 --- a/bridges/modules/messages/Cargo.toml +++ b/bridges/modules/messages/Cargo.toml @@ -11,7 +11,7 @@ workspace = true [dependencies] codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false } -log = { version = "0.4.21", default-features = false } +log = { workspace = true } num-traits = { version = "0.2", default-features = false } scale-info = { version = "2.10.0", default-features = false, features = ["derive"] } diff --git a/bridges/modules/parachains/Cargo.toml b/bridges/modules/parachains/Cargo.toml index ff58c8f43d2b99ef0739d66461af61c671293773..2011f2cbbcc5e41dae2266eb72c6760a3ce45bef 100644 --- a/bridges/modules/parachains/Cargo.toml +++ b/bridges/modules/parachains/Cargo.toml @@ -11,7 +11,7 @@ workspace = true [dependencies] codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false } -log = { version = "0.4.21", default-features = false } +log = { workspace = true } scale-info = { version = "2.10.0", default-features = false, features = ["derive"] } # Bridge Dependencies diff --git a/bridges/modules/relayers/Cargo.toml b/bridges/modules/relayers/Cargo.toml index d532db3b89f708f146cda01326876e090009e2c7..5e93e31965b39f5d2db2f624552b25376d31f135 100644 --- a/bridges/modules/relayers/Cargo.toml +++ b/bridges/modules/relayers/Cargo.toml @@ -11,7 +11,7 @@ workspace = true [dependencies] codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false } -log = { version = "0.4.21", default-features = false } +log = { workspace = true } scale-info = { version = "2.10.0", default-features = false, features = ["derive"] } # Bridge dependencies diff --git a/bridges/modules/xcm-bridge-hub-router/Cargo.toml b/bridges/modules/xcm-bridge-hub-router/Cargo.toml index 8c4b62428e75a4126823cf4dd11f71083a0c2513..280eeac942bae791a6a7ba8ac217d9b2903cb223 100644 --- a/bridges/modules/xcm-bridge-hub-router/Cargo.toml +++ b/bridges/modules/xcm-bridge-hub-router/Cargo.toml @@ -11,7 +11,7 @@ workspace = true [dependencies] codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false } -log = { version = "0.4.21", default-features = false } +log = { workspace = true } scale-info = { version = "2.10.0", default-features = false, features = ["bit-vec", "derive", "serde"] } # Bridge dependencies diff --git a/bridges/modules/xcm-bridge-hub/Cargo.toml b/bridges/modules/xcm-bridge-hub/Cargo.toml index b107461ef16f4a3cb3eefa7ff6c1bf16e9186f41..aaa11494143369fded501578930da658879e31e2 100644 --- a/bridges/modules/xcm-bridge-hub/Cargo.toml +++ b/bridges/modules/xcm-bridge-hub/Cargo.toml @@ -11,7 +11,7 @@ workspace = true [dependencies] codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false } -log = { version = "0.4.21", default-features = false } +log = { workspace = true } scale-info = { version = "2.10.0", default-features = false, features = ["derive"] } # Bridge Dependencies diff --git a/bridges/primitives/beefy/Cargo.toml b/bridges/primitives/beefy/Cargo.toml index 74e8f0492d8a33705080d86d03883faf8f960d49..4785f8297ba06b63a59f8c5d0b883990c27755f4 100644 --- a/bridges/primitives/beefy/Cargo.toml +++ b/bridges/primitives/beefy/Cargo.toml @@ -12,7 +12,7 @@ workspace = true [dependencies] codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false, features = ["derive", "bit-vec"] } scale-info = { version = "2.10.0", default-features = false, features = ["bit-vec", "derive"] } -serde = { version = "1.0", default-features = false, features = ["alloc", "derive"] } +serde = { default-features = false, features = ["alloc", "derive"], workspace = true } # Bridge Dependencies diff --git a/bridges/primitives/chain-bridge-hub-cumulus/src/lib.rs b/bridges/primitives/chain-bridge-hub-cumulus/src/lib.rs index c49aa4b856397d28746d017fd8333ae3ad10655e..f186f6427ae7d5cbac37c0dea528665ea474803e 100644 --- a/bridges/primitives/chain-bridge-hub-cumulus/src/lib.rs +++ b/bridges/primitives/chain-bridge-hub-cumulus/src/lib.rs @@ -26,7 +26,7 @@ pub use bp_polkadot_core::{ }; use bp_messages::*; -use bp_polkadot_core::SuffixedCommonSignedExtension; +use bp_polkadot_core::SuffixedCommonTransactionExtension; use bp_runtime::extensions::{ BridgeRejectObsoleteHeadersAndMessages, RefundBridgedParachainMessagesSchema, }; @@ -164,7 +164,7 @@ pub const MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX: MessageNonce = 1024; pub const MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX: MessageNonce = 4096; /// Signed extension that is used by all bridge hubs. -pub type SignedExtension = SuffixedCommonSignedExtension<( +pub type TransactionExtension = SuffixedCommonTransactionExtension<( BridgeRejectObsoleteHeadersAndMessages, RefundBridgedParachainMessagesSchema, )>; diff --git a/bridges/primitives/chain-bridge-hub-rococo/src/lib.rs b/bridges/primitives/chain-bridge-hub-rococo/src/lib.rs index c4e697fbe9526b85c7f10cf739c6893d50190fe9..992ef1bd7a10f5fd95d1a5b4ec1a1267543ce615 100644 --- a/bridges/primitives/chain-bridge-hub-rococo/src/lib.rs +++ b/bridges/primitives/chain-bridge-hub-rococo/src/lib.rs @@ -107,5 +107,5 @@ frame_support::parameter_types! { /// Transaction fee that is paid at the Rococo BridgeHub for delivering single outbound message confirmation. /// (initially was calculated by test `BridgeHubRococo::can_calculate_fee_for_complex_message_confirmation_transaction` + `33%`) - pub const BridgeHubRococoBaseConfirmationFeeInRocs: u128 = 5_380_829_647; + pub const BridgeHubRococoBaseConfirmationFeeInRocs: u128 = 5_380_904_835; } diff --git a/bridges/primitives/chain-kusama/src/lib.rs b/bridges/primitives/chain-kusama/src/lib.rs index e3b4d0520f61c858b54d78dfa4a45f57bac411fb..253a1010e83df928cceae91a18c309959c33d94e 100644 --- a/bridges/primitives/chain-kusama/src/lib.rs +++ b/bridges/primitives/chain-kusama/src/lib.rs @@ -59,8 +59,8 @@ impl ChainWithGrandpa for Kusama { const AVERAGE_HEADER_SIZE: u32 = AVERAGE_HEADER_SIZE; } -// The SignedExtension used by Kusama. -pub use bp_polkadot_core::CommonSignedExtension as SignedExtension; +// The TransactionExtension used by Kusama. +pub use bp_polkadot_core::CommonTransactionExtension as TransactionExtension; /// Name of the parachains pallet in the Kusama runtime. pub const PARAS_PALLET_NAME: &str = "Paras"; diff --git a/bridges/primitives/chain-polkadot-bulletin/src/lib.rs b/bridges/primitives/chain-polkadot-bulletin/src/lib.rs index f2eebf9312470a42e1d3a1c7d67ab8b7a38af189..73dd122bd153869b937ed65f8e7ea7f4dde79c7c 100644 --- a/bridges/primitives/chain-polkadot-bulletin/src/lib.rs +++ b/bridges/primitives/chain-polkadot-bulletin/src/lib.rs @@ -25,7 +25,7 @@ use bp_runtime::{ decl_bridge_finality_runtime_apis, decl_bridge_messages_runtime_apis, extensions::{ CheckEra, CheckGenesis, CheckNonZeroSender, CheckNonce, CheckSpecVersion, CheckTxVersion, - CheckWeight, GenericSignedExtension, GenericSignedExtensionSchema, + CheckWeight, GenericTransactionExtension, GenericTransactionExtensionSchema, }, Chain, ChainId, TransactionEra, }; @@ -37,7 +37,12 @@ use frame_support::{ }; use frame_system::limits; use scale_info::TypeInfo; -use sp_runtime::{traits::DispatchInfoOf, transaction_validity::TransactionValidityError, Perbill}; +use sp_runtime::{ + impl_tx_ext_default, + traits::{Dispatchable, TransactionExtensionBase}, + transaction_validity::TransactionValidityError, + Perbill, +}; // This chain reuses most of Polkadot primitives. pub use bp_polkadot_core::{ @@ -71,10 +76,10 @@ pub const MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX: MessageNonce = 1024; pub const MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX: MessageNonce = 4096; /// This signed extension is used to ensure that the chain transactions are signed by proper -pub type ValidateSigned = GenericSignedExtensionSchema<(), ()>; +pub type ValidateSigned = GenericTransactionExtensionSchema<(), ()>; /// Signed extension schema, used by Polkadot Bulletin. -pub type SignedExtensionSchema = GenericSignedExtension<( +pub type TransactionExtensionSchema = GenericTransactionExtension<( ( CheckNonZeroSender, CheckSpecVersion, @@ -87,34 +92,30 @@ pub type SignedExtensionSchema = GenericSignedExtension<( ValidateSigned, )>; -/// Signed extension, used by Polkadot Bulletin. +/// Transaction extension, used by Polkadot Bulletin. #[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] -pub struct SignedExtension(SignedExtensionSchema); +pub struct TransactionExtension(TransactionExtensionSchema); -impl sp_runtime::traits::SignedExtension for SignedExtension { +impl TransactionExtensionBase for TransactionExtension { const IDENTIFIER: &'static str = "Not needed."; - type AccountId = (); - type Call = (); - type AdditionalSigned = - <SignedExtensionSchema as sp_runtime::traits::SignedExtension>::AdditionalSigned; - type Pre = (); + type Implicit = <TransactionExtensionSchema as TransactionExtensionBase>::Implicit; - fn additional_signed(&self) -> Result<Self::AdditionalSigned, TransactionValidityError> { - self.0.additional_signed() + fn implicit(&self) -> Result<Self::Implicit, TransactionValidityError> { + <TransactionExtensionSchema as TransactionExtensionBase>::implicit(&self.0) } +} - fn pre_dispatch( - self, - _who: &Self::AccountId, - _call: &Self::Call, - _info: &DispatchInfoOf<Self::Call>, - _len: usize, - ) -> Result<Self::Pre, TransactionValidityError> { - Ok(()) - } +impl<C, Context> sp_runtime::traits::TransactionExtension<C, Context> for TransactionExtension +where + C: Dispatchable, +{ + type Pre = (); + type Val = (); + + impl_tx_ext_default!(C; Context; validate prepare); } -impl SignedExtension { +impl TransactionExtension { /// Create signed extension from its components. pub fn from_params( spec_version: u32, @@ -123,7 +124,7 @@ impl SignedExtension { genesis_hash: Hash, nonce: Nonce, ) -> Self { - Self(GenericSignedExtension::new( + Self(GenericTransactionExtension::new( ( ( (), // non-zero sender diff --git a/bridges/primitives/chain-polkadot/src/lib.rs b/bridges/primitives/chain-polkadot/src/lib.rs index fc5e10308a8e33463a74c041f157daaef09cc9c8..e5e2e7c3a042abddd8fb3dbd6f1decf62529cfe3 100644 --- a/bridges/primitives/chain-polkadot/src/lib.rs +++ b/bridges/primitives/chain-polkadot/src/lib.rs @@ -61,8 +61,8 @@ impl ChainWithGrandpa for Polkadot { const AVERAGE_HEADER_SIZE: u32 = AVERAGE_HEADER_SIZE; } -/// The SignedExtension used by Polkadot. -pub type SignedExtension = SuffixedCommonSignedExtension<PrevalidateAttests>; +/// The TransactionExtension used by Polkadot. +pub type TransactionExtension = SuffixedCommonTransactionExtension<PrevalidateAttests>; /// Name of the parachains pallet in the Polkadot runtime. pub const PARAS_PALLET_NAME: &str = "Paras"; diff --git a/bridges/primitives/chain-rococo/src/lib.rs b/bridges/primitives/chain-rococo/src/lib.rs index f1b256f0f090f048cc8db3a16c112ed8b938f6ce..267c6b2b1f0292b64ca8aaf969845129dae64dd8 100644 --- a/bridges/primitives/chain-rococo/src/lib.rs +++ b/bridges/primitives/chain-rococo/src/lib.rs @@ -59,8 +59,8 @@ impl ChainWithGrandpa for Rococo { const AVERAGE_HEADER_SIZE: u32 = AVERAGE_HEADER_SIZE; } -// The SignedExtension used by Rococo. -pub use bp_polkadot_core::CommonSignedExtension as SignedExtension; +// The TransactionExtension used by Rococo. +pub use bp_polkadot_core::CommonTransactionExtension as TransactionExtension; /// Name of the parachains pallet in the Rococo runtime. pub const PARAS_PALLET_NAME: &str = "Paras"; diff --git a/bridges/primitives/chain-westend/src/lib.rs b/bridges/primitives/chain-westend/src/lib.rs index f03fd2160a700eb3817a6feb629e9d366cc366aa..afa02e8ee541e5e2912b4b9a216feb633a07b617 100644 --- a/bridges/primitives/chain-westend/src/lib.rs +++ b/bridges/primitives/chain-westend/src/lib.rs @@ -59,8 +59,8 @@ impl ChainWithGrandpa for Westend { const AVERAGE_HEADER_SIZE: u32 = AVERAGE_HEADER_SIZE; } -// The SignedExtension used by Westend. -pub use bp_polkadot_core::CommonSignedExtension as SignedExtension; +// The TransactionExtension used by Westend. +pub use bp_polkadot_core::CommonTransactionExtension as TransactionExtension; /// Name of the parachains pallet in the Rococo runtime. pub const PARAS_PALLET_NAME: &str = "Paras"; diff --git a/bridges/primitives/header-chain/Cargo.toml b/bridges/primitives/header-chain/Cargo.toml index e42959164e4ca9be41b1bc2c7fa344d52a244653..7167c41046025bb7fdcae0d63cac0251d419b139 100644 --- a/bridges/primitives/header-chain/Cargo.toml +++ b/bridges/primitives/header-chain/Cargo.toml @@ -13,7 +13,7 @@ workspace = true codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false } finality-grandpa = { version = "0.16.2", default-features = false } scale-info = { version = "2.10.0", default-features = false, features = ["derive"] } -serde = { version = "1.0", default-features = false, features = ["alloc", "derive"] } +serde = { features = ["alloc", "derive"], workspace = true } # Bridge dependencies diff --git a/bridges/primitives/messages/Cargo.toml b/bridges/primitives/messages/Cargo.toml index 1092be13d899ecbe66c7b7d1874c7845800bf9de..d121b693146484003e556f6af7c4e961211b9a32 100644 --- a/bridges/primitives/messages/Cargo.toml +++ b/bridges/primitives/messages/Cargo.toml @@ -12,7 +12,7 @@ workspace = true [dependencies] codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false, features = ["bit-vec", "derive"] } scale-info = { version = "2.10.0", default-features = false, features = ["bit-vec", "derive"] } -serde = { version = "1.0", default-features = false, features = ["alloc", "derive"] } +serde = { features = ["alloc", "derive"], workspace = true } # Bridge dependencies diff --git a/bridges/primitives/polkadot-core/Cargo.toml b/bridges/primitives/polkadot-core/Cargo.toml index 5ef9920d7f196690199b0fc7777c15ddf09aafe6..c28f3f2e34e46fa1233ad2e1936cb8ffdb2e7003 100644 --- a/bridges/primitives/polkadot-core/Cargo.toml +++ b/bridges/primitives/polkadot-core/Cargo.toml @@ -13,7 +13,7 @@ workspace = true codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false, features = ["derive"] } parity-util-mem = { version = "0.12.0", optional = true } scale-info = { version = "2.10.0", default-features = false, features = ["derive"] } -serde = { version = "1.0", optional = true, features = ["derive"] } +serde = { default-features = false, features = ["derive"], optional = true, workspace = true } # Bridge Dependencies diff --git a/bridges/primitives/polkadot-core/src/lib.rs b/bridges/primitives/polkadot-core/src/lib.rs index df2836495bbe131e9cf810c43eb4af5eefaf43b7..d59b99db4b586dde7b2d645ff44c34b94f865f24 100644 --- a/bridges/primitives/polkadot-core/src/lib.rs +++ b/bridges/primitives/polkadot-core/src/lib.rs @@ -24,8 +24,8 @@ use bp_runtime::{ self, extensions::{ ChargeTransactionPayment, CheckEra, CheckGenesis, CheckNonZeroSender, CheckNonce, - CheckSpecVersion, CheckTxVersion, CheckWeight, GenericSignedExtension, - SignedExtensionSchema, + CheckSpecVersion, CheckTxVersion, CheckWeight, GenericTransactionExtension, + TransactionExtensionSchema, }, EncodedOrDecodedCall, StorageMapKeyProvider, TransactionEra, }; @@ -229,8 +229,12 @@ pub type SignedBlock = generic::SignedBlock<Block>; pub type Balance = u128; /// Unchecked Extrinsic type. -pub type UncheckedExtrinsic<Call, SignedExt> = - generic::UncheckedExtrinsic<AccountAddress, EncodedOrDecodedCall<Call>, Signature, SignedExt>; +pub type UncheckedExtrinsic<Call, TransactionExt> = generic::UncheckedExtrinsic< + AccountAddress, + EncodedOrDecodedCall<Call>, + Signature, + TransactionExt, +>; /// Account address, used by the Polkadot-like chain. pub type Address = MultiAddress<AccountId, ()>; @@ -275,7 +279,7 @@ impl AccountInfoStorageMapKeyProvider { } /// Extra signed extension data that is used by most chains. -pub type CommonSignedExtra = ( +pub type CommonTransactionExtra = ( CheckNonZeroSender, CheckSpecVersion, CheckTxVersion, @@ -286,12 +290,12 @@ pub type CommonSignedExtra = ( ChargeTransactionPayment<Balance>, ); -/// Extra signed extension data that starts with `CommonSignedExtra`. -pub type SuffixedCommonSignedExtension<Suffix> = - GenericSignedExtension<(CommonSignedExtra, Suffix)>; +/// Extra transaction extension data that starts with `CommonTransactionExtra`. +pub type SuffixedCommonTransactionExtension<Suffix> = + GenericTransactionExtension<(CommonTransactionExtra, Suffix)>; -/// Helper trait to define some extra methods on `SuffixedCommonSignedExtension`. -pub trait SuffixedCommonSignedExtensionExt<Suffix: SignedExtensionSchema> { +/// Helper trait to define some extra methods on `SuffixedCommonTransactionExtension`. +pub trait SuffixedCommonTransactionExtensionExt<Suffix: TransactionExtensionSchema> { /// Create signed extension from its components. fn from_params( spec_version: u32, @@ -300,7 +304,7 @@ pub trait SuffixedCommonSignedExtensionExt<Suffix: SignedExtensionSchema> { genesis_hash: Hash, nonce: Nonce, tip: Balance, - extra: (Suffix::Payload, Suffix::AdditionalSigned), + extra: (Suffix::Payload, Suffix::Implicit), ) -> Self; /// Return transaction nonce. @@ -310,9 +314,10 @@ pub trait SuffixedCommonSignedExtensionExt<Suffix: SignedExtensionSchema> { fn tip(&self) -> Balance; } -impl<Suffix> SuffixedCommonSignedExtensionExt<Suffix> for SuffixedCommonSignedExtension<Suffix> +impl<Suffix> SuffixedCommonTransactionExtensionExt<Suffix> + for SuffixedCommonTransactionExtension<Suffix> where - Suffix: SignedExtensionSchema, + Suffix: TransactionExtensionSchema, { fn from_params( spec_version: u32, @@ -321,9 +326,9 @@ where genesis_hash: Hash, nonce: Nonce, tip: Balance, - extra: (Suffix::Payload, Suffix::AdditionalSigned), + extra: (Suffix::Payload, Suffix::Implicit), ) -> Self { - GenericSignedExtension::new( + GenericTransactionExtension::new( ( ( (), // non-zero sender @@ -365,7 +370,7 @@ where } /// Signed extension that is used by most chains. -pub type CommonSignedExtension = SuffixedCommonSignedExtension<()>; +pub type CommonTransactionExtension = SuffixedCommonTransactionExtension<()>; #[cfg(test)] mod tests { diff --git a/bridges/primitives/runtime/Cargo.toml b/bridges/primitives/runtime/Cargo.toml index 542b696533aaea6ff0192a38d30b63931363211c..d7cef6a10320b96a632e5ac0b1f63d4a01906532 100644 --- a/bridges/primitives/runtime/Cargo.toml +++ b/bridges/primitives/runtime/Cargo.toml @@ -13,10 +13,10 @@ workspace = true codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false } hash-db = { version = "0.16.0", default-features = false } impl-trait-for-tuples = "0.2.2" -log = { version = "0.4.21", default-features = false } +log = { workspace = true } num-traits = { version = "0.2", default-features = false } scale-info = { version = "2.10.0", default-features = false, features = ["derive"] } -serde = { version = "1.0", default-features = false, features = ["alloc", "derive"] } +serde = { features = ["alloc", "derive"], workspace = true } # Substrate Dependencies diff --git a/bridges/primitives/runtime/src/chain.rs b/bridges/primitives/runtime/src/chain.rs index 9ba21a1cddf13896b21494045cea7fdd92259ce8..00bea2b3ca613e12f9c84f878b733c9c4d6e7fe9 100644 --- a/bridges/primitives/runtime/src/chain.rs +++ b/bridges/primitives/runtime/src/chain.rs @@ -98,6 +98,17 @@ impl<ChainCall: Encode> Encode for EncodedOrDecodedCall<ChainCall> { } } +// dummy implementation to satisfy `SignedPayload` requirements +impl<ChainCall> sp_runtime::traits::Dispatchable for EncodedOrDecodedCall<ChainCall> { + type RuntimeOrigin = (); + type Config = (); + type Info = (); + type PostInfo = (); + fn dispatch(self, _origin: ()) -> sp_runtime::DispatchResultWithInfo<()> { + unreachable!("never used by relayer; qed") + } +} + /// Minimal Substrate-based chain representation that may be used from no_std environment. pub trait Chain: Send + Sync + 'static { /// Chain id. diff --git a/bridges/primitives/runtime/src/extensions.rs b/bridges/primitives/runtime/src/extensions.rs index d896bc92efffc4e8fcb427ffa7057dece6f17241..a31e7b5bb47a64ec2333bbaba3e9c520aa53ef5a 100644 --- a/bridges/primitives/runtime/src/extensions.rs +++ b/bridges/primitives/runtime/src/extensions.rs @@ -20,135 +20,138 @@ use codec::{Compact, Decode, Encode}; use impl_trait_for_tuples::impl_for_tuples; use scale_info::{StaticTypeInfo, TypeInfo}; use sp_runtime::{ - traits::{DispatchInfoOf, SignedExtension}, + impl_tx_ext_default, + traits::{Dispatchable, TransactionExtension, TransactionExtensionBase}, transaction_validity::TransactionValidityError, }; use sp_std::{fmt::Debug, marker::PhantomData}; -/// Trait that describes some properties of a `SignedExtension` that are needed in order to send a -/// transaction to the chain. -pub trait SignedExtensionSchema: Encode + Decode + Debug + Eq + Clone + StaticTypeInfo { +/// Trait that describes some properties of a `TransactionExtension` that are needed in order to +/// send a transaction to the chain. +pub trait TransactionExtensionSchema: + Encode + Decode + Debug + Eq + Clone + StaticTypeInfo +{ /// A type of the data encoded as part of the transaction. type Payload: Encode + Decode + Debug + Eq + Clone + StaticTypeInfo; /// Parameters which are part of the payload used to produce transaction signature, /// but don't end up in the transaction itself (i.e. inherent part of the runtime). - type AdditionalSigned: Encode + Debug + Eq + Clone + StaticTypeInfo; + type Implicit: Encode + Decode + Debug + Eq + Clone + StaticTypeInfo; } -impl SignedExtensionSchema for () { +impl TransactionExtensionSchema for () { type Payload = (); - type AdditionalSigned = (); + type Implicit = (); } -/// An implementation of `SignedExtensionSchema` using generic params. +/// An implementation of `TransactionExtensionSchema` using generic params. #[derive(Encode, Decode, Clone, Debug, PartialEq, Eq, TypeInfo)] -pub struct GenericSignedExtensionSchema<P, S>(PhantomData<(P, S)>); +pub struct GenericTransactionExtensionSchema<P, S>(PhantomData<(P, S)>); -impl<P, S> SignedExtensionSchema for GenericSignedExtensionSchema<P, S> +impl<P, S> TransactionExtensionSchema for GenericTransactionExtensionSchema<P, S> where P: Encode + Decode + Debug + Eq + Clone + StaticTypeInfo, - S: Encode + Debug + Eq + Clone + StaticTypeInfo, + S: Encode + Decode + Debug + Eq + Clone + StaticTypeInfo, { type Payload = P; - type AdditionalSigned = S; + type Implicit = S; } -/// The `SignedExtensionSchema` for `frame_system::CheckNonZeroSender`. -pub type CheckNonZeroSender = GenericSignedExtensionSchema<(), ()>; +/// The `TransactionExtensionSchema` for `frame_system::CheckNonZeroSender`. +pub type CheckNonZeroSender = GenericTransactionExtensionSchema<(), ()>; -/// The `SignedExtensionSchema` for `frame_system::CheckSpecVersion`. -pub type CheckSpecVersion = GenericSignedExtensionSchema<(), u32>; +/// The `TransactionExtensionSchema` for `frame_system::CheckSpecVersion`. +pub type CheckSpecVersion = GenericTransactionExtensionSchema<(), u32>; -/// The `SignedExtensionSchema` for `frame_system::CheckTxVersion`. -pub type CheckTxVersion = GenericSignedExtensionSchema<(), u32>; +/// The `TransactionExtensionSchema` for `frame_system::CheckTxVersion`. +pub type CheckTxVersion = GenericTransactionExtensionSchema<(), u32>; -/// The `SignedExtensionSchema` for `frame_system::CheckGenesis`. -pub type CheckGenesis<Hash> = GenericSignedExtensionSchema<(), Hash>; +/// The `TransactionExtensionSchema` for `frame_system::CheckGenesis`. +pub type CheckGenesis<Hash> = GenericTransactionExtensionSchema<(), Hash>; -/// The `SignedExtensionSchema` for `frame_system::CheckEra`. -pub type CheckEra<Hash> = GenericSignedExtensionSchema<sp_runtime::generic::Era, Hash>; +/// The `TransactionExtensionSchema` for `frame_system::CheckEra`. +pub type CheckEra<Hash> = GenericTransactionExtensionSchema<sp_runtime::generic::Era, Hash>; -/// The `SignedExtensionSchema` for `frame_system::CheckNonce`. -pub type CheckNonce<TxNonce> = GenericSignedExtensionSchema<Compact<TxNonce>, ()>; +/// The `TransactionExtensionSchema` for `frame_system::CheckNonce`. +pub type CheckNonce<TxNonce> = GenericTransactionExtensionSchema<Compact<TxNonce>, ()>; -/// The `SignedExtensionSchema` for `frame_system::CheckWeight`. -pub type CheckWeight = GenericSignedExtensionSchema<(), ()>; +/// The `TransactionExtensionSchema` for `frame_system::CheckWeight`. +pub type CheckWeight = GenericTransactionExtensionSchema<(), ()>; -/// The `SignedExtensionSchema` for `pallet_transaction_payment::ChargeTransactionPayment`. -pub type ChargeTransactionPayment<Balance> = GenericSignedExtensionSchema<Compact<Balance>, ()>; +/// The `TransactionExtensionSchema` for `pallet_transaction_payment::ChargeTransactionPayment`. +pub type ChargeTransactionPayment<Balance> = + GenericTransactionExtensionSchema<Compact<Balance>, ()>; -/// The `SignedExtensionSchema` for `polkadot-runtime-common::PrevalidateAttests`. -pub type PrevalidateAttests = GenericSignedExtensionSchema<(), ()>; +/// The `TransactionExtensionSchema` for `polkadot-runtime-common::PrevalidateAttests`. +pub type PrevalidateAttests = GenericTransactionExtensionSchema<(), ()>; -/// The `SignedExtensionSchema` for `BridgeRejectObsoleteHeadersAndMessages`. -pub type BridgeRejectObsoleteHeadersAndMessages = GenericSignedExtensionSchema<(), ()>; +/// The `TransactionExtensionSchema` for `BridgeRejectObsoleteHeadersAndMessages`. +pub type BridgeRejectObsoleteHeadersAndMessages = GenericTransactionExtensionSchema<(), ()>; -/// The `SignedExtensionSchema` for `RefundBridgedParachainMessages`. +/// The `TransactionExtensionSchema` for `RefundBridgedParachainMessages`. /// This schema is dedicated for `RefundBridgedParachainMessages` signed extension as /// wildcard/placeholder, which relies on the scale encoding for `()` or `((), ())`, or `((), (), /// ())` is the same. So runtime can contains any kind of tuple: /// `(BridgeRefundBridgeHubRococoMessages)` /// `(BridgeRefundBridgeHubRococoMessages, BridgeRefundBridgeHubWestendMessages)` /// `(BridgeRefundParachainMessages1, ..., BridgeRefundParachainMessagesN)` -pub type RefundBridgedParachainMessagesSchema = GenericSignedExtensionSchema<(), ()>; +pub type RefundBridgedParachainMessagesSchema = GenericTransactionExtensionSchema<(), ()>; #[impl_for_tuples(1, 12)] -impl SignedExtensionSchema for Tuple { +impl TransactionExtensionSchema for Tuple { for_tuples!( type Payload = ( #( Tuple::Payload ),* ); ); - for_tuples!( type AdditionalSigned = ( #( Tuple::AdditionalSigned ),* ); ); + for_tuples!( type Implicit = ( #( Tuple::Implicit ),* ); ); } /// A simplified version of signed extensions meant for producing signed transactions /// and signed payloads in the client code. #[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] -pub struct GenericSignedExtension<S: SignedExtensionSchema> { +pub struct GenericTransactionExtension<S: TransactionExtensionSchema> { /// A payload that is included in the transaction. pub payload: S::Payload, #[codec(skip)] // It may be set to `None` if extensions are decoded. We are never reconstructing transactions - // (and it makes no sense to do that) => decoded version of `SignedExtensions` is only used to - // read fields of the `payload`. And when resigning transaction, we're reconstructing - // `SignedExtensions` from scratch. - additional_signed: Option<S::AdditionalSigned>, + // (and it makes no sense to do that) => decoded version of `TransactionExtensions` is only + // used to read fields of the `payload`. And when resigning transaction, we're reconstructing + // `TransactionExtensions` from scratch. + implicit: Option<S::Implicit>, } -impl<S: SignedExtensionSchema> GenericSignedExtension<S> { - /// Create new `GenericSignedExtension` object. - pub fn new(payload: S::Payload, additional_signed: Option<S::AdditionalSigned>) -> Self { - Self { payload, additional_signed } +impl<S: TransactionExtensionSchema> GenericTransactionExtension<S> { + /// Create new `GenericTransactionExtension` object. + pub fn new(payload: S::Payload, implicit: Option<S::Implicit>) -> Self { + Self { payload, implicit } } } -impl<S> SignedExtension for GenericSignedExtension<S> +impl<S> TransactionExtensionBase for GenericTransactionExtension<S> where - S: SignedExtensionSchema, + S: TransactionExtensionSchema, S::Payload: Send + Sync, - S::AdditionalSigned: Send + Sync, + S::Implicit: Send + Sync, { const IDENTIFIER: &'static str = "Not needed."; - type AccountId = (); - type Call = (); - type AdditionalSigned = S::AdditionalSigned; - type Pre = (); + type Implicit = S::Implicit; - fn additional_signed(&self) -> Result<Self::AdditionalSigned, TransactionValidityError> { + fn implicit(&self) -> Result<Self::Implicit, TransactionValidityError> { // we shall not ever see this error in relay, because we are never signing decoded // transactions. Instead we're constructing and signing new transactions. So the error code // is kinda random here - self.additional_signed.clone().ok_or( - frame_support::unsigned::TransactionValidityError::Unknown( + self.implicit + .clone() + .ok_or(frame_support::unsigned::TransactionValidityError::Unknown( frame_support::unsigned::UnknownTransaction::Custom(0xFF), - ), - ) + )) } +} +impl<S, C, Context> TransactionExtension<C, Context> for GenericTransactionExtension<S> +where + C: Dispatchable, + S: TransactionExtensionSchema, + S::Payload: Send + Sync, + S::Implicit: Send + Sync, +{ + type Pre = (); + type Val = (); - fn pre_dispatch( - self, - _who: &Self::AccountId, - _call: &Self::Call, - _info: &DispatchInfoOf<Self::Call>, - _len: usize, - ) -> Result<Self::Pre, TransactionValidityError> { - Ok(()) - } + impl_tx_ext_default!(C; Context; validate prepare); } diff --git a/bridges/primitives/test-utils/src/lib.rs b/bridges/primitives/test-utils/src/lib.rs index f23ddd1a10d3681900b024999aef279ea6fcb91d..1d80890779bf8310b393d585749e96f9577196a1 100644 --- a/bridges/primitives/test-utils/src/lib.rs +++ b/bridges/primitives/test-utils/src/lib.rs @@ -129,7 +129,7 @@ pub fn make_justification_for_header<H: HeaderT>( votes_ancestries.push(child.clone()); } - // The header we need to use when pre-commiting is the one at the highest height + // The header we need to use when pre-committing is the one at the highest height // on our chain. let precommit_candidate = chain.last().map(|h| (h.hash(), *h.number())).unwrap(); unsigned_precommits.push(precommit_candidate); diff --git a/bridges/relays/bin-substrate/Cargo.toml b/bridges/relays/bin-substrate/Cargo.toml index 1bcb410ddfc4ec25f8bbddc8ca3de7becd57bc9b..d5873752e22f852e8708f4802cf6336836d1f213 100644 --- a/bridges/relays/bin-substrate/Cargo.toml +++ b/bridges/relays/bin-substrate/Cargo.toml @@ -16,7 +16,7 @@ codec = { package = "parity-scale-codec", version = "3.1.5" } env_logger = "0.11" futures = "0.3.30" hex = "0.4" -log = "0.4.21" +log = { workspace = true } num-format = "0.4" num-traits = "0.2" rbtag = "0.3" diff --git a/bridges/relays/bin-substrate/src/bridges/rococo_bulletin/mod.rs b/bridges/relays/bin-substrate/src/bridges/rococo_bulletin/mod.rs index 196978c16e8c988915cc7b983bfe345368c99bd5..2d7b5aec1fd191e1ab0596c355f7a5823316d131 100644 --- a/bridges/relays/bin-substrate/src/bridges/rococo_bulletin/mod.rs +++ b/bridges/relays/bin-substrate/src/bridges/rococo_bulletin/mod.rs @@ -125,18 +125,6 @@ impl relay_substrate_client::ChainWithTransactions for RococoAsPolkadot { unsigned.switch_chain(), ) } - - fn is_signed(tx: &Self::SignedTransaction) -> bool { - relay_rococo_client::Rococo::is_signed(tx) - } - - fn is_signed_by(signer: &Self::AccountKeyPair, tx: &Self::SignedTransaction) -> bool { - relay_rococo_client::Rococo::is_signed_by(signer, tx) - } - - fn parse_transaction(tx: Self::SignedTransaction) -> Option<UnsignedTransaction<Self>> { - relay_rococo_client::Rococo::parse_transaction(tx).map(|tx| tx.switch_chain()) - } } impl CliChain for RococoAsPolkadot { @@ -232,19 +220,6 @@ impl relay_substrate_client::ChainWithTransactions for BridgeHubRococoAsBridgeHu unsigned.switch_chain(), ) } - - fn is_signed(tx: &Self::SignedTransaction) -> bool { - relay_bridge_hub_rococo_client::BridgeHubRococo::is_signed(tx) - } - - fn is_signed_by(signer: &Self::AccountKeyPair, tx: &Self::SignedTransaction) -> bool { - relay_bridge_hub_rococo_client::BridgeHubRococo::is_signed_by(signer, tx) - } - - fn parse_transaction(tx: Self::SignedTransaction) -> Option<UnsignedTransaction<Self>> { - relay_bridge_hub_rococo_client::BridgeHubRococo::parse_transaction(tx) - .map(|tx| tx.switch_chain()) - } } impl relay_substrate_client::ChainWithMessages for BridgeHubRococoAsBridgeHubPolkadot { diff --git a/bridges/relays/client-bridge-hub-kusama/src/codegen_runtime.rs b/bridges/relays/client-bridge-hub-kusama/src/codegen_runtime.rs index 78ae788b32d5755f65c04e6cb86c32cd65d9f960..2da4c3014b254920bb596476e751598c2c885ed5 100644 --- a/bridges/relays/client-bridge-hub-kusama/src/codegen_runtime.rs +++ b/bridges/relays/client-bridge-hub-kusama/src/codegen_runtime.rs @@ -392,7 +392,7 @@ pub mod api { #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] pub struct RefundBridgedParachainMessages; #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct RefundSignedExtensionAdapter<_0>(pub _0); + pub struct RefundTransactionExtensionAdapter<_0>(pub _0); } } pub mod cumulus_pallet_dmp_queue { diff --git a/bridges/relays/client-bridge-hub-kusama/src/lib.rs b/bridges/relays/client-bridge-hub-kusama/src/lib.rs index b11301b0e0f8afc4307d9818ae2cd238b437691f..4ad6d2e2fb7e06cd73600e2622ecaec57702c4a5 100644 --- a/bridges/relays/client-bridge-hub-kusama/src/lib.rs +++ b/bridges/relays/client-bridge-hub-kusama/src/lib.rs @@ -18,8 +18,8 @@ pub mod codegen_runtime; -use bp_bridge_hub_kusama::{SignedExtension, AVERAGE_BLOCK_INTERVAL}; -use bp_polkadot::SuffixedCommonSignedExtensionExt; +use bp_bridge_hub_kusama::{TransactionExtension, AVERAGE_BLOCK_INTERVAL}; +use bp_polkadot::SuffixedCommonTransactionExtensionExt; use codec::Encode; use relay_substrate_client::{ calls::UtilityCall as MockUtilityCall, Chain, ChainWithBalances, ChainWithMessages, @@ -36,7 +36,8 @@ pub type RuntimeCall = runtime_types::bridge_hub_kusama_runtime::RuntimeCall; pub type BridgeMessagesCall = runtime_types::pallet_bridge_messages::pallet::Call; pub type BridgeGrandpaCall = runtime_types::pallet_bridge_grandpa::pallet::Call; pub type BridgeParachainCall = runtime_types::pallet_bridge_parachains::pallet::Call; -type UncheckedExtrinsic = bp_bridge_hub_kusama::UncheckedExtrinsic<RuntimeCall, SignedExtension>; +type UncheckedExtrinsic = + bp_bridge_hub_kusama::UncheckedExtrinsic<RuntimeCall, TransactionExtension>; type UtilityCall = runtime_types::pallet_utility::pallet::Call; /// Kusama chain definition @@ -86,7 +87,7 @@ impl ChainWithTransactions for BridgeHubKusama { ) -> Result<Self::SignedTransaction, SubstrateError> { let raw_payload = SignedPayload::new( unsigned.call, - SignedExtension::from_params( + TransactionExtension::from_params( param.spec_version, param.transaction_version, unsigned.era, @@ -108,24 +109,6 @@ impl ChainWithTransactions for BridgeHubKusama { extra, )) } - - fn is_signed(tx: &Self::SignedTransaction) -> bool { - tx.signature.is_some() - } - - fn is_signed_by(signer: &Self::AccountKeyPair, tx: &Self::SignedTransaction) -> bool { - tx.signature - .as_ref() - .map(|(address, _, _)| { - *address == bp_bridge_hub_kusama::Address::Id(signer.public().into()) - }) - .unwrap_or(false) - } - - fn parse_transaction(tx: Self::SignedTransaction) -> Option<UnsignedTransaction<Self>> { - let extra = &tx.signature.as_ref()?.2; - Some(UnsignedTransaction::new(tx.function, extra.nonce()).tip(extra.tip())) - } } impl ChainWithMessages for BridgeHubKusama { @@ -137,34 +120,3 @@ impl ChainWithMessages for BridgeHubKusama { const FROM_CHAIN_MESSAGE_DETAILS_METHOD: &'static str = bp_bridge_hub_kusama::FROM_BRIDGE_HUB_KUSAMA_MESSAGE_DETAILS_METHOD; } - -#[cfg(test)] -mod tests { - use super::*; - use relay_substrate_client::TransactionEra; - - type SystemCall = runtime_types::frame_system::pallet::Call; - - #[test] - fn parse_transaction_works() { - let unsigned = UnsignedTransaction { - call: RuntimeCall::System(SystemCall::remark { remark: b"Hello world!".to_vec() }) - .into(), - nonce: 777, - tip: 888, - era: TransactionEra::immortal(), - }; - let signed_transaction = BridgeHubKusama::sign_transaction( - SignParam { - spec_version: 42, - transaction_version: 50000, - genesis_hash: [42u8; 32].into(), - signer: sp_core::sr25519::Pair::from_seed_slice(&[1u8; 32]).unwrap(), - }, - unsigned.clone(), - ) - .unwrap(); - let parsed_transaction = BridgeHubKusama::parse_transaction(signed_transaction).unwrap(); - assert_eq!(parsed_transaction, unsigned); - } -} diff --git a/bridges/relays/client-bridge-hub-kusama/src/runtime_wrapper.rs b/bridges/relays/client-bridge-hub-kusama/src/runtime_wrapper.rs index 96a5b4fe033c7d145e593babf8136960ce1de872..176cb173e5334d28c9c8c4163ddb1037a3faf403 100644 --- a/bridges/relays/client-bridge-hub-kusama/src/runtime_wrapper.rs +++ b/bridges/relays/client-bridge-hub-kusama/src/runtime_wrapper.rs @@ -20,14 +20,14 @@ use codec::{Decode, Encode}; use scale_info::TypeInfo; -pub use bp_bridge_hub_kusama::SignedExtension; +pub use bp_bridge_hub_kusama::TransactionExtension; pub use bp_header_chain::BridgeGrandpaCallOf; pub use bp_parachains::BridgeParachainCall; pub use bridge_runtime_common::messages::BridgeMessagesCallOf; pub use relay_substrate_client::calls::{SystemCall, UtilityCall}; /// Unchecked BridgeHubKusama extrinsic. -pub type UncheckedExtrinsic = bp_bridge_hub_kusama::UncheckedExtrinsic<Call, SignedExtension>; +pub type UncheckedExtrinsic = bp_bridge_hub_kusama::UncheckedExtrinsic<Call, TransactionExtension>; // The indirect pallet call used to sync `Polkadot` GRANDPA finality to `BHKusama`. pub type BridgePolkadotGrandpaCall = BridgeGrandpaCallOf<bp_polkadot::Polkadot>; diff --git a/bridges/relays/client-bridge-hub-polkadot/src/codegen_runtime.rs b/bridges/relays/client-bridge-hub-polkadot/src/codegen_runtime.rs index c8c063b5e19cbd634e2d36933eaaa4ecaadc15d1..1ce9d0588024a9ab231670ea4391a63dabe87fbc 100644 --- a/bridges/relays/client-bridge-hub-polkadot/src/codegen_runtime.rs +++ b/bridges/relays/client-bridge-hub-polkadot/src/codegen_runtime.rs @@ -392,7 +392,7 @@ pub mod api { #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] pub struct RefundBridgedParachainMessages; #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct RefundSignedExtensionAdapter<_0>(pub _0); + pub struct RefundTransactionExtensionAdapter<_0>(pub _0); } } pub mod cumulus_pallet_dmp_queue { diff --git a/bridges/relays/client-bridge-hub-polkadot/src/lib.rs b/bridges/relays/client-bridge-hub-polkadot/src/lib.rs index 7bcf189e109657e66232e49b45528fce26409268..8ac6569210aa8059948491c2d6bad4bcb3511cb7 100644 --- a/bridges/relays/client-bridge-hub-polkadot/src/lib.rs +++ b/bridges/relays/client-bridge-hub-polkadot/src/lib.rs @@ -18,8 +18,8 @@ pub mod codegen_runtime; -use bp_bridge_hub_polkadot::{SignedExtension, AVERAGE_BLOCK_INTERVAL}; -use bp_polkadot_core::SuffixedCommonSignedExtensionExt; +use bp_bridge_hub_polkadot::{TransactionExtension, AVERAGE_BLOCK_INTERVAL}; +use bp_polkadot_core::SuffixedCommonTransactionExtensionExt; use codec::Encode; use relay_substrate_client::{ calls::UtilityCall as MockUtilityCall, Chain, ChainWithBalances, ChainWithMessages, @@ -40,7 +40,8 @@ pub type BridgeKusamaMessagesCall = runtime_types::pallet_bridge_messages::palle pub type BridgePolkadotBulletinGrandpaCall = runtime_types::pallet_bridge_grandpa::pallet::Call; pub type BridgeKusamaGrandpaCall = runtime_types::pallet_bridge_grandpa::pallet::Call; pub type BridgeParachainCall = runtime_types::pallet_bridge_parachains::pallet::Call; -type UncheckedExtrinsic = bp_bridge_hub_polkadot::UncheckedExtrinsic<RuntimeCall, SignedExtension>; +type UncheckedExtrinsic = + bp_bridge_hub_polkadot::UncheckedExtrinsic<RuntimeCall, TransactionExtension>; type UtilityCall = runtime_types::pallet_utility::pallet::Call; /// Polkadot chain definition @@ -90,7 +91,7 @@ impl ChainWithTransactions for BridgeHubPolkadot { ) -> Result<Self::SignedTransaction, SubstrateError> { let raw_payload = SignedPayload::new( unsigned.call, - SignedExtension::from_params( + TransactionExtension::from_params( param.spec_version, param.transaction_version, unsigned.era, @@ -112,24 +113,6 @@ impl ChainWithTransactions for BridgeHubPolkadot { extra, )) } - - fn is_signed(tx: &Self::SignedTransaction) -> bool { - tx.signature.is_some() - } - - fn is_signed_by(signer: &Self::AccountKeyPair, tx: &Self::SignedTransaction) -> bool { - tx.signature - .as_ref() - .map(|(address, _, _)| { - *address == bp_bridge_hub_polkadot::Address::Id(signer.public().into()) - }) - .unwrap_or(false) - } - - fn parse_transaction(tx: Self::SignedTransaction) -> Option<UnsignedTransaction<Self>> { - let extra = &tx.signature.as_ref()?.2; - Some(UnsignedTransaction::new(tx.function, extra.nonce()).tip(extra.tip())) - } } impl ChainWithMessages for BridgeHubPolkadot { @@ -141,34 +124,3 @@ impl ChainWithMessages for BridgeHubPolkadot { const FROM_CHAIN_MESSAGE_DETAILS_METHOD: &'static str = bp_bridge_hub_polkadot::FROM_BRIDGE_HUB_POLKADOT_MESSAGE_DETAILS_METHOD; } - -#[cfg(test)] -mod tests { - use super::*; - use relay_substrate_client::TransactionEra; - - type SystemCall = runtime_types::frame_system::pallet::Call; - - #[test] - fn parse_transaction_works() { - let unsigned = UnsignedTransaction { - call: RuntimeCall::System(SystemCall::remark { remark: b"Hello world!".to_vec() }) - .into(), - nonce: 777, - tip: 888, - era: TransactionEra::immortal(), - }; - let signed_transaction = BridgeHubPolkadot::sign_transaction( - SignParam { - spec_version: 42, - transaction_version: 50000, - genesis_hash: [42u8; 32].into(), - signer: sp_core::sr25519::Pair::from_seed_slice(&[1u8; 32]).unwrap(), - }, - unsigned.clone(), - ) - .unwrap(); - let parsed_transaction = BridgeHubPolkadot::parse_transaction(signed_transaction).unwrap(); - assert_eq!(parsed_transaction, unsigned); - } -} diff --git a/bridges/relays/client-bridge-hub-polkadot/src/runtime_wrapper.rs b/bridges/relays/client-bridge-hub-polkadot/src/runtime_wrapper.rs index ded177996df9488e71d5b9b7c5f159cdeefea58a..f59b35253b1ba8b56e82fcac4bcc1a4f6ffc30ad 100644 --- a/bridges/relays/client-bridge-hub-polkadot/src/runtime_wrapper.rs +++ b/bridges/relays/client-bridge-hub-polkadot/src/runtime_wrapper.rs @@ -20,14 +20,14 @@ use codec::{Decode, Encode}; use scale_info::TypeInfo; -pub use bp_bridge_hub_polkadot::SignedExtension; +pub use bp_bridge_hub_polkadot::TransactionExtension; pub use bp_header_chain::BridgeGrandpaCallOf; pub use bp_parachains::BridgeParachainCall; pub use bridge_runtime_common::messages::BridgeMessagesCallOf; pub use relay_substrate_client::calls::{SystemCall, UtilityCall}; /// Unchecked BridgeHubPolkadot extrinsic. -pub type UncheckedExtrinsic = bp_bridge_hub_polkadot::UncheckedExtrinsic<Call, SignedExtension>; +pub type UncheckedExtrinsic = bp_bridge_hub_polkadot::UncheckedExtrinsic<Call, TransactionExtension>; /// The indirect pallet call used to sync `Kusama` GRANDPA finality to `BHPolkadot`. pub type BridgeKusamaGrandpaCall = BridgeGrandpaCallOf<bp_kusama::Kusama>; diff --git a/bridges/relays/client-bridge-hub-rococo/src/codegen_runtime.rs b/bridges/relays/client-bridge-hub-rococo/src/codegen_runtime.rs index bfb7c3e9d3d1f109834a35ebcc221ab403ef90ee..e5c7c8b3e767967dd9276dbcbc74b29bee9ad200 100644 --- a/bridges/relays/client-bridge-hub-rococo/src/codegen_runtime.rs +++ b/bridges/relays/client-bridge-hub-rococo/src/codegen_runtime.rs @@ -463,7 +463,7 @@ pub mod api { #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] pub struct RefundBridgedParachainMessages; #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct RefundSignedExtensionAdapter<_0>(pub _0); + pub struct RefundTransactionExtensionAdapter<_0>(pub _0); } } pub mod cumulus_pallet_parachain_system { diff --git a/bridges/relays/client-bridge-hub-rococo/src/lib.rs b/bridges/relays/client-bridge-hub-rococo/src/lib.rs index 80a6316a454bf722df560e60399cc73221de4a3d..7ec58453474a04b0178945dafafef749674e0700 100644 --- a/bridges/relays/client-bridge-hub-rococo/src/lib.rs +++ b/bridges/relays/client-bridge-hub-rococo/src/lib.rs @@ -18,8 +18,8 @@ pub mod codegen_runtime; -use bp_bridge_hub_rococo::{SignedExtension, AVERAGE_BLOCK_INTERVAL}; -use bp_polkadot_core::SuffixedCommonSignedExtensionExt; +use bp_bridge_hub_rococo::{TransactionExtension, AVERAGE_BLOCK_INTERVAL}; +use bp_polkadot_core::SuffixedCommonTransactionExtensionExt; use codec::Encode; use relay_substrate_client::{ calls::UtilityCall as MockUtilityCall, Chain, ChainWithBalances, ChainWithMessages, @@ -38,7 +38,8 @@ pub type BridgeBulletinMessagesCall = runtime_types::pallet_bridge_messages::pal pub type BridgeGrandpaCall = runtime_types::pallet_bridge_grandpa::pallet::Call; pub type BridgeBulletinGrandpaCall = runtime_types::pallet_bridge_grandpa::pallet::Call2; pub type BridgeParachainCall = runtime_types::pallet_bridge_parachains::pallet::Call; -type UncheckedExtrinsic = bp_bridge_hub_rococo::UncheckedExtrinsic<RuntimeCall, SignedExtension>; +type UncheckedExtrinsic = + bp_bridge_hub_rococo::UncheckedExtrinsic<RuntimeCall, TransactionExtension>; type UtilityCall = runtime_types::pallet_utility::pallet::Call; /// Rococo chain definition @@ -88,7 +89,7 @@ impl ChainWithTransactions for BridgeHubRococo { ) -> Result<Self::SignedTransaction, SubstrateError> { let raw_payload = SignedPayload::new( unsigned.call, - SignedExtension::from_params( + TransactionExtension::from_params( param.spec_version, param.transaction_version, unsigned.era, @@ -110,24 +111,6 @@ impl ChainWithTransactions for BridgeHubRococo { extra, )) } - - fn is_signed(tx: &Self::SignedTransaction) -> bool { - tx.signature.is_some() - } - - fn is_signed_by(signer: &Self::AccountKeyPair, tx: &Self::SignedTransaction) -> bool { - tx.signature - .as_ref() - .map(|(address, _, _)| { - *address == bp_bridge_hub_rococo::Address::Id(signer.public().into()) - }) - .unwrap_or(false) - } - - fn parse_transaction(tx: Self::SignedTransaction) -> Option<UnsignedTransaction<Self>> { - let extra = &tx.signature.as_ref()?.2; - Some(UnsignedTransaction::new(tx.function, extra.nonce()).tip(extra.tip())) - } } impl ChainWithMessages for BridgeHubRococo { @@ -139,34 +122,3 @@ impl ChainWithMessages for BridgeHubRococo { const FROM_CHAIN_MESSAGE_DETAILS_METHOD: &'static str = bp_bridge_hub_rococo::FROM_BRIDGE_HUB_ROCOCO_MESSAGE_DETAILS_METHOD; } - -#[cfg(test)] -mod tests { - use super::*; - use relay_substrate_client::TransactionEra; - - type SystemCall = runtime_types::frame_system::pallet::Call; - - #[test] - fn parse_transaction_works() { - let unsigned = UnsignedTransaction { - call: RuntimeCall::System(SystemCall::remark { remark: b"Hello world!".to_vec() }) - .into(), - nonce: 777, - tip: 888, - era: TransactionEra::immortal(), - }; - let signed_transaction = BridgeHubRococo::sign_transaction( - SignParam { - spec_version: 42, - transaction_version: 50000, - genesis_hash: [42u8; 32].into(), - signer: sp_core::sr25519::Pair::from_seed_slice(&[1u8; 32]).unwrap(), - }, - unsigned.clone(), - ) - .unwrap(); - let parsed_transaction = BridgeHubRococo::parse_transaction(signed_transaction).unwrap(); - assert_eq!(parsed_transaction, unsigned); - } -} diff --git a/bridges/relays/client-bridge-hub-westend/src/codegen_runtime.rs b/bridges/relays/client-bridge-hub-westend/src/codegen_runtime.rs index 3db044fcf5ec5cd072c837d56334d01505164d79..51d0b7f8c423f08e1831e4cda1285eeadd16dd5e 100644 --- a/bridges/relays/client-bridge-hub-westend/src/codegen_runtime.rs +++ b/bridges/relays/client-bridge-hub-westend/src/codegen_runtime.rs @@ -407,7 +407,7 @@ pub mod api { #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] pub struct RefundBridgedParachainMessages; #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct RefundSignedExtensionAdapter<_0>(pub _0); + pub struct RefundTransactionExtensionAdapter<_0>(pub _0); } } pub mod cumulus_pallet_parachain_system { diff --git a/bridges/relays/client-bridge-hub-westend/src/lib.rs b/bridges/relays/client-bridge-hub-westend/src/lib.rs index 5e38ef65bc34ae7317df0d16d6cab809fedb2951..c6bf1b45dd184ab7d95933e8cc785e2fe36213f7 100644 --- a/bridges/relays/client-bridge-hub-westend/src/lib.rs +++ b/bridges/relays/client-bridge-hub-westend/src/lib.rs @@ -18,8 +18,8 @@ pub mod codegen_runtime; -use bp_bridge_hub_westend::{SignedExtension, AVERAGE_BLOCK_INTERVAL}; -use bp_polkadot_core::SuffixedCommonSignedExtensionExt; +use bp_bridge_hub_westend::{TransactionExtension, AVERAGE_BLOCK_INTERVAL}; +use bp_polkadot_core::SuffixedCommonTransactionExtensionExt; use codec::Encode; use relay_substrate_client::{ calls::UtilityCall as MockUtilityCall, Chain, ChainWithBalances, ChainWithMessages, @@ -36,7 +36,8 @@ pub type RuntimeCall = runtime_types::bridge_hub_westend_runtime::RuntimeCall; pub type BridgeMessagesCall = runtime_types::pallet_bridge_messages::pallet::Call; pub type BridgeGrandpaCall = runtime_types::pallet_bridge_grandpa::pallet::Call; pub type BridgeParachainCall = runtime_types::pallet_bridge_parachains::pallet::Call; -type UncheckedExtrinsic = bp_bridge_hub_westend::UncheckedExtrinsic<RuntimeCall, SignedExtension>; +type UncheckedExtrinsic = + bp_bridge_hub_westend::UncheckedExtrinsic<RuntimeCall, TransactionExtension>; type UtilityCall = runtime_types::pallet_utility::pallet::Call; /// Westend chain definition @@ -86,7 +87,7 @@ impl ChainWithTransactions for BridgeHubWestend { ) -> Result<Self::SignedTransaction, SubstrateError> { let raw_payload = SignedPayload::new( unsigned.call, - SignedExtension::from_params( + TransactionExtension::from_params( param.spec_version, param.transaction_version, unsigned.era, @@ -108,24 +109,6 @@ impl ChainWithTransactions for BridgeHubWestend { extra, )) } - - fn is_signed(tx: &Self::SignedTransaction) -> bool { - tx.signature.is_some() - } - - fn is_signed_by(signer: &Self::AccountKeyPair, tx: &Self::SignedTransaction) -> bool { - tx.signature - .as_ref() - .map(|(address, _, _)| { - *address == bp_bridge_hub_westend::Address::Id(signer.public().into()) - }) - .unwrap_or(false) - } - - fn parse_transaction(tx: Self::SignedTransaction) -> Option<UnsignedTransaction<Self>> { - let extra = &tx.signature.as_ref()?.2; - Some(UnsignedTransaction::new(tx.function, extra.nonce()).tip(extra.tip())) - } } impl ChainWithMessages for BridgeHubWestend { @@ -137,34 +120,3 @@ impl ChainWithMessages for BridgeHubWestend { const FROM_CHAIN_MESSAGE_DETAILS_METHOD: &'static str = bp_bridge_hub_westend::FROM_BRIDGE_HUB_WESTEND_MESSAGE_DETAILS_METHOD; } - -#[cfg(test)] -mod tests { - use super::*; - use relay_substrate_client::TransactionEra; - - type SystemCall = runtime_types::frame_system::pallet::Call; - - #[test] - fn parse_transaction_works() { - let unsigned = UnsignedTransaction { - call: RuntimeCall::System(SystemCall::remark { remark: b"Hello world!".to_vec() }) - .into(), - nonce: 777, - tip: 888, - era: TransactionEra::immortal(), - }; - let signed_transaction = BridgeHubWestend::sign_transaction( - SignParam { - spec_version: 42, - transaction_version: 50000, - genesis_hash: [42u8; 32].into(), - signer: sp_core::sr25519::Pair::from_seed_slice(&[1u8; 32]).unwrap(), - }, - unsigned.clone(), - ) - .unwrap(); - let parsed_transaction = BridgeHubWestend::parse_transaction(signed_transaction).unwrap(); - assert_eq!(parsed_transaction, unsigned); - } -} diff --git a/bridges/relays/client-kusama/src/lib.rs b/bridges/relays/client-kusama/src/lib.rs index 42350ccc52f74c4a431db3e71131af833908320e..0f412284e79e45840bd437d258b9ca37a138fc00 100644 --- a/bridges/relays/client-kusama/src/lib.rs +++ b/bridges/relays/client-kusama/src/lib.rs @@ -19,7 +19,7 @@ pub mod codegen_runtime; use bp_kusama::{AccountInfoStorageMapKeyProvider, KUSAMA_SYNCED_HEADERS_GRANDPA_INFO_METHOD}; -use bp_polkadot_core::SuffixedCommonSignedExtensionExt; +use bp_polkadot_core::SuffixedCommonTransactionExtensionExt; use codec::Encode; use relay_substrate_client::{ Chain, ChainWithBalances, ChainWithGrandpa, ChainWithTransactions, Error as SubstrateError, @@ -83,7 +83,7 @@ impl RelayChain for Kusama { impl ChainWithTransactions for Kusama { type AccountKeyPair = sp_core::sr25519::Pair; type SignedTransaction = - bp_polkadot_core::UncheckedExtrinsic<Self::Call, bp_kusama::SignedExtension>; + bp_polkadot_core::UncheckedExtrinsic<Self::Call, bp_kusama::TransactionExtension>; fn sign_transaction( param: SignParam<Self>, @@ -91,7 +91,7 @@ impl ChainWithTransactions for Kusama { ) -> Result<Self::SignedTransaction, SubstrateError> { let raw_payload = SignedPayload::new( unsigned.call, - bp_kusama::SignedExtension::from_params( + bp_kusama::TransactionExtension::from_params( param.spec_version, param.transaction_version, unsigned.era, @@ -113,20 +113,4 @@ impl ChainWithTransactions for Kusama { extra, )) } - - fn is_signed(tx: &Self::SignedTransaction) -> bool { - tx.signature.is_some() - } - - fn is_signed_by(signer: &Self::AccountKeyPair, tx: &Self::SignedTransaction) -> bool { - tx.signature - .as_ref() - .map(|(address, _, _)| *address == Address::Id(signer.public().into())) - .unwrap_or(false) - } - - fn parse_transaction(tx: Self::SignedTransaction) -> Option<UnsignedTransaction<Self>> { - let extra = &tx.signature.as_ref()?.2; - Some(UnsignedTransaction::new(tx.function, extra.nonce()).tip(extra.tip())) - } } diff --git a/bridges/relays/client-polkadot-bulletin/src/lib.rs b/bridges/relays/client-polkadot-bulletin/src/lib.rs index 647df2ada32ec9e6f21d5d94a90460d720c4ae12..b5bbeda8025654aefe3bd5bc0f776b7691645e5a 100644 --- a/bridges/relays/client-polkadot-bulletin/src/lib.rs +++ b/bridges/relays/client-polkadot-bulletin/src/lib.rs @@ -99,8 +99,10 @@ impl ChainWithBalances for PolkadotBulletin { impl ChainWithTransactions for PolkadotBulletin { type AccountKeyPair = sp_core::sr25519::Pair; - type SignedTransaction = - bp_polkadot_bulletin::UncheckedExtrinsic<Self::Call, bp_polkadot_bulletin::SignedExtension>; + type SignedTransaction = bp_polkadot_bulletin::UncheckedExtrinsic< + Self::Call, + bp_polkadot_bulletin::TransactionExtension, + >; fn sign_transaction( param: SignParam<Self>, @@ -108,7 +110,7 @@ impl ChainWithTransactions for PolkadotBulletin { ) -> Result<Self::SignedTransaction, SubstrateError> { let raw_payload = SignedPayload::new( unsigned.call, - bp_polkadot_bulletin::SignedExtension::from_params( + bp_polkadot_bulletin::TransactionExtension::from_params( param.spec_version, param.transaction_version, unsigned.era, @@ -128,20 +130,4 @@ impl ChainWithTransactions for PolkadotBulletin { extra, )) } - - fn is_signed(tx: &Self::SignedTransaction) -> bool { - tx.signature.is_some() - } - - fn is_signed_by(signer: &Self::AccountKeyPair, tx: &Self::SignedTransaction) -> bool { - tx.signature - .as_ref() - .map(|(address, _, _)| *address == Address::Id(signer.public().into())) - .unwrap_or(false) - } - - fn parse_transaction(tx: Self::SignedTransaction) -> Option<UnsignedTransaction<Self>> { - let extra = &tx.signature.as_ref()?.2; - Some(UnsignedTransaction::new(tx.function, extra.nonce())) - } } diff --git a/bridges/relays/client-polkadot/src/lib.rs b/bridges/relays/client-polkadot/src/lib.rs index 8e2a2c81748b7d1e51a648c23257a71ca9cf211b..638e01d1b6ace5b5f37b29bf56983c34249bca36 100644 --- a/bridges/relays/client-polkadot/src/lib.rs +++ b/bridges/relays/client-polkadot/src/lib.rs @@ -19,7 +19,7 @@ mod codegen_runtime; use bp_polkadot::{AccountInfoStorageMapKeyProvider, POLKADOT_SYNCED_HEADERS_GRANDPA_INFO_METHOD}; -use bp_polkadot_core::SuffixedCommonSignedExtensionExt; +use bp_polkadot_core::SuffixedCommonTransactionExtensionExt; use codec::Encode; use relay_substrate_client::{ Chain, ChainWithBalances, ChainWithGrandpa, ChainWithTransactions, Error as SubstrateError, @@ -83,7 +83,7 @@ impl RelayChain for Polkadot { impl ChainWithTransactions for Polkadot { type AccountKeyPair = sp_core::sr25519::Pair; type SignedTransaction = - bp_polkadot_core::UncheckedExtrinsic<Self::Call, bp_polkadot::SignedExtension>; + bp_polkadot_core::UncheckedExtrinsic<Self::Call, bp_polkadot::TransactionExtension>; fn sign_transaction( param: SignParam<Self>, @@ -91,7 +91,7 @@ impl ChainWithTransactions for Polkadot { ) -> Result<Self::SignedTransaction, SubstrateError> { let raw_payload = SignedPayload::new( unsigned.call, - bp_polkadot::SignedExtension::from_params( + bp_polkadot::TransactionExtension::from_params( param.spec_version, param.transaction_version, unsigned.era, @@ -113,20 +113,4 @@ impl ChainWithTransactions for Polkadot { extra, )) } - - fn is_signed(tx: &Self::SignedTransaction) -> bool { - tx.signature.is_some() - } - - fn is_signed_by(signer: &Self::AccountKeyPair, tx: &Self::SignedTransaction) -> bool { - tx.signature - .as_ref() - .map(|(address, _, _)| *address == Address::Id(signer.public().into())) - .unwrap_or(false) - } - - fn parse_transaction(tx: Self::SignedTransaction) -> Option<UnsignedTransaction<Self>> { - let extra = &tx.signature.as_ref()?.2; - Some(UnsignedTransaction::new(tx.function, extra.nonce()).tip(extra.tip())) - } } diff --git a/bridges/relays/client-rococo/src/lib.rs b/bridges/relays/client-rococo/src/lib.rs index c96e421fa28d53fa52173d40ff7044acc4645d68..7843af241c1dbae501daa383b855fe198b706d4d 100644 --- a/bridges/relays/client-rococo/src/lib.rs +++ b/bridges/relays/client-rococo/src/lib.rs @@ -18,7 +18,7 @@ pub mod codegen_runtime; -use bp_polkadot_core::SuffixedCommonSignedExtensionExt; +use bp_polkadot_core::SuffixedCommonTransactionExtensionExt; use bp_rococo::ROCOCO_SYNCED_HEADERS_GRANDPA_INFO_METHOD; use codec::Encode; use relay_substrate_client::{ @@ -83,7 +83,7 @@ impl RelayChain for Rococo { impl ChainWithTransactions for Rococo { type AccountKeyPair = sp_core::sr25519::Pair; type SignedTransaction = - bp_polkadot_core::UncheckedExtrinsic<Self::Call, bp_rococo::SignedExtension>; + bp_polkadot_core::UncheckedExtrinsic<Self::Call, bp_rococo::TransactionExtension>; fn sign_transaction( param: SignParam<Self>, @@ -91,7 +91,7 @@ impl ChainWithTransactions for Rococo { ) -> Result<Self::SignedTransaction, SubstrateError> { let raw_payload = SignedPayload::new( unsigned.call, - bp_rococo::SignedExtension::from_params( + bp_rococo::TransactionExtension::from_params( param.spec_version, param.transaction_version, unsigned.era, @@ -113,20 +113,4 @@ impl ChainWithTransactions for Rococo { extra, )) } - - fn is_signed(tx: &Self::SignedTransaction) -> bool { - tx.signature.is_some() - } - - fn is_signed_by(signer: &Self::AccountKeyPair, tx: &Self::SignedTransaction) -> bool { - tx.signature - .as_ref() - .map(|(address, _, _)| *address == Address::Id(signer.public().into())) - .unwrap_or(false) - } - - fn parse_transaction(tx: Self::SignedTransaction) -> Option<UnsignedTransaction<Self>> { - let extra = &tx.signature.as_ref()?.2; - Some(UnsignedTransaction::new(tx.function, extra.nonce()).tip(extra.tip())) - } } diff --git a/bridges/relays/client-substrate/Cargo.toml b/bridges/relays/client-substrate/Cargo.toml index 56bdd150a9a83f31fb891da27e101e93d42f414c..7ff2e2f45e727c1f4e56bc7f496556bad09d4fbb 100644 --- a/bridges/relays/client-substrate/Cargo.toml +++ b/bridges/relays/client-substrate/Cargo.toml @@ -14,12 +14,12 @@ async-trait = "0.1" codec = { package = "parity-scale-codec", version = "3.1.5" } futures = "0.3.30" jsonrpsee = { version = "0.17", features = ["macros", "ws-client"] } -log = "0.4.21" +log = { workspace = true } num-traits = "0.2" rand = "0.8" scale-info = { version = "2.10.0", features = ["derive"] } tokio = { version = "1.36", features = ["rt-multi-thread"] } -thiserror = "1.0.57" +thiserror = { workspace = true } # Bridge dependencies diff --git a/bridges/relays/client-substrate/src/chain.rs b/bridges/relays/client-substrate/src/chain.rs index 9de7308c5bdd3698f7f8ea5cc8d79d69aff62218..4f9467ec59dafc2ddeb82df1380ee02d369adf9b 100644 --- a/bridges/relays/client-substrate/src/chain.rs +++ b/bridges/relays/client-substrate/src/chain.rs @@ -203,17 +203,6 @@ pub trait ChainWithTransactions: Chain { ) -> Result<Self::SignedTransaction, crate::Error> where Self: Sized; - - /// Returns true if transaction is signed. - fn is_signed(tx: &Self::SignedTransaction) -> bool; - - /// Returns true if transaction is signed by given signer. - fn is_signed_by(signer: &Self::AccountKeyPair, tx: &Self::SignedTransaction) -> bool; - - /// Parse signed transaction into its unsigned part. - /// - /// Returns `None` if signed transaction has unsupported format. - fn parse_transaction(tx: Self::SignedTransaction) -> Option<UnsignedTransaction<Self>>; } /// Sign transaction parameters diff --git a/bridges/relays/client-westend/src/lib.rs b/bridges/relays/client-westend/src/lib.rs index 789599bbb1d299eca047ec93aa16effd9627c171..8067f67a2bbd646e1f583e6bc6787838aaa581a0 100644 --- a/bridges/relays/client-westend/src/lib.rs +++ b/bridges/relays/client-westend/src/lib.rs @@ -18,7 +18,7 @@ pub mod codegen_runtime; -use bp_polkadot_core::SuffixedCommonSignedExtensionExt; +use bp_polkadot_core::SuffixedCommonTransactionExtensionExt; use bp_westend::WESTEND_SYNCED_HEADERS_GRANDPA_INFO_METHOD; use codec::Encode; use relay_substrate_client::{ @@ -83,7 +83,7 @@ impl ChainWithBalances for Westend { impl ChainWithTransactions for Westend { type AccountKeyPair = sp_core::sr25519::Pair; type SignedTransaction = - bp_polkadot_core::UncheckedExtrinsic<Self::Call, bp_westend::SignedExtension>; + bp_polkadot_core::UncheckedExtrinsic<Self::Call, bp_westend::TransactionExtension>; fn sign_transaction( param: SignParam<Self>, @@ -91,7 +91,7 @@ impl ChainWithTransactions for Westend { ) -> Result<Self::SignedTransaction, SubstrateError> { let raw_payload = SignedPayload::new( unsigned.call, - bp_westend::SignedExtension::from_params( + bp_westend::TransactionExtension::from_params( param.spec_version, param.transaction_version, unsigned.era, @@ -113,20 +113,4 @@ impl ChainWithTransactions for Westend { extra, )) } - - fn is_signed(tx: &Self::SignedTransaction) -> bool { - tx.signature.is_some() - } - - fn is_signed_by(signer: &Self::AccountKeyPair, tx: &Self::SignedTransaction) -> bool { - tx.signature - .as_ref() - .map(|(address, _, _)| *address == Address::Id(signer.public().into())) - .unwrap_or(false) - } - - fn parse_transaction(tx: Self::SignedTransaction) -> Option<UnsignedTransaction<Self>> { - let extra = &tx.signature.as_ref()?.2; - Some(UnsignedTransaction::new(tx.function, extra.nonce()).tip(extra.tip())) - } } diff --git a/bridges/relays/equivocation/Cargo.toml b/bridges/relays/equivocation/Cargo.toml index 99cf88a4045b250f91acfe469dfdc9d768d383c5..0b4a7e983a3a8bf8a9f0e6bcc1430f03da22bf63 100644 --- a/bridges/relays/equivocation/Cargo.toml +++ b/bridges/relays/equivocation/Cargo.toml @@ -16,6 +16,6 @@ bp-header-chain = { path = "../../primitives/header-chain" } finality-relay = { path = "../finality" } frame-support = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } futures = "0.3.30" -log = "0.4.21" +log = { workspace = true } num-traits = "0.2" relay-utils = { path = "../utils" } diff --git a/bridges/relays/finality/Cargo.toml b/bridges/relays/finality/Cargo.toml index 8c162294f9c769675c80a8e75e46bd53195565b8..9e8bf56f53aaac0ec4fd1b9b51ff57334570340d 100644 --- a/bridges/relays/finality/Cargo.toml +++ b/bridges/relays/finality/Cargo.toml @@ -15,7 +15,7 @@ async-trait = "0.1" backoff = "0.4" bp-header-chain = { path = "../../primitives/header-chain" } futures = "0.3.30" -log = "0.4.21" +log = { workspace = true } num-traits = "0.2" relay-utils = { path = "../utils" } diff --git a/bridges/relays/lib-substrate-relay/Cargo.toml b/bridges/relays/lib-substrate-relay/Cargo.toml index 169da263ddcafed24eabffc295f58ac8b57b350e..161548ac4d5e2ba014130d0807acce45252e867a 100644 --- a/bridges/relays/lib-substrate-relay/Cargo.toml +++ b/bridges/relays/lib-substrate-relay/Cargo.toml @@ -10,14 +10,14 @@ workspace = true [dependencies] anyhow = "1.0" -thiserror = "1.0.57" +thiserror = { workspace = true } async-std = "1.9.0" async-trait = "0.1" codec = { package = "parity-scale-codec", version = "3.1.5" } futures = "0.3.30" hex = "0.4" num-traits = "0.2" -log = "0.4.21" +log = { workspace = true } # Bridge dependencies diff --git a/bridges/relays/messages/Cargo.toml b/bridges/relays/messages/Cargo.toml index 14d3f191701a09935f1fc63dd50cfec72ddf1311..3367e4bbd443900298aae2e87bab5ed0ef50fa1a 100644 --- a/bridges/relays/messages/Cargo.toml +++ b/bridges/relays/messages/Cargo.toml @@ -14,7 +14,7 @@ async-trait = "0.1" env_logger = "0.11" futures = "0.3.30" hex = "0.4" -log = "0.4.21" +log = { workspace = true } num-traits = "0.2" parking_lot = "0.12.1" diff --git a/bridges/relays/parachains/Cargo.toml b/bridges/relays/parachains/Cargo.toml index 62c9934af332f5413b1d10fcbed8c13b54aba236..9dc35343b48c607048bd9219dc34dce3c6c80bfb 100644 --- a/bridges/relays/parachains/Cargo.toml +++ b/bridges/relays/parachains/Cargo.toml @@ -12,7 +12,7 @@ workspace = true async-std = "1.6.5" async-trait = "0.1" futures = "0.3.30" -log = "0.4.21" +log = { workspace = true } relay-utils = { path = "../utils" } # Bridge dependencies diff --git a/bridges/relays/utils/Cargo.toml b/bridges/relays/utils/Cargo.toml index ae406933288e3273da65e74f8e5dfd05941009bf..ed6093318a0dcf0bbfb76250f7bcd2d04b942387 100644 --- a/bridges/relays/utils/Cargo.toml +++ b/bridges/relays/utils/Cargo.toml @@ -18,13 +18,13 @@ isahc = "1.2" env_logger = "0.11.3" futures = "0.3.30" jsonpath_lib = "0.3" -log = "0.4.21" +log = { workspace = true } num-traits = "0.2" -serde_json = "1.0" +serde_json = { workspace = true, default-features = true } sysinfo = "0.30" time = { version = "0.3", features = ["formatting", "local-offset", "std"] } tokio = { version = "1.36", features = ["rt"] } -thiserror = "1.0.57" +thiserror = { workspace = true } # Bridge dependencies