diff --git a/Cargo.lock b/Cargo.lock index 8d5ad8e500..bd52f01b3e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5820,12 +5820,14 @@ name = "module-transaction-pause" version = "2.1.3" dependencies = [ "acala-primitives", + "cumulus-primitives-core", "frame-support", "frame-system", "orml-tokens", "orml-traits", "pallet-balances", "parity-scale-codec", + "polkadot-core-primitives", "scale-info", "smallvec", "sp-core", @@ -9879,6 +9881,7 @@ dependencies = [ "module-relaychain", "module-session-manager", "module-support", + "module-transaction-pause", "module-transaction-payment", "orml-auction", "orml-authority", @@ -13783,7 +13786,7 @@ dependencies = [ [[package]] name = "xcm-emulator" version = "0.1.0" -source = "git+https://github.com/shaunxw/xcm-simulator?rev=4d3bb9dd4fa2cd554a9970ffff816d9346269eaa#4d3bb9dd4fa2cd554a9970ffff816d9346269eaa" +source = "git+https://github.com/shaunxw/xcm-simulator?rev=87af52d07fc742cc9220bab6acb9afa061d09fd3#87af52d07fc742cc9220bab6acb9afa061d09fd3" dependencies = [ "cumulus-pallet-dmp-queue", "cumulus-pallet-parachain-system", diff --git a/modules/transaction-pause/Cargo.toml b/modules/transaction-pause/Cargo.toml index 1aa4ef281e..ceaa3eadc3 100644 --- a/modules/transaction-pause/Cargo.toml +++ b/modules/transaction-pause/Cargo.toml @@ -12,13 +12,16 @@ frame-support = { git = "https://github.com/paritytech/substrate", branch = "pol frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.13", default-features = false } sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.13", default-features = false } +primitives = { package = "acala-primitives", path = "../../primitives", default-features = false} +polkadot-core-primitives = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.13", default-features = false } +cumulus-primitives-core = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.13", default-features = false } + [dev-dependencies] sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.13" } sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.13" } pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.13" } orml-tokens = { path = "../../orml/tokens" } orml-traits = { path = "../../orml/traits" } -primitives = { package = "acala-primitives", path = "../../primitives" } smallvec = "1.4.1" [features] @@ -29,5 +32,8 @@ std = [ "frame-support/std", "frame-system/std", "sp-std/std", + "primitives/std", + "polkadot-core-primitives/std", + "cumulus-primitives-core/std", ] try-runtime = ["frame-support/try-runtime"] diff --git a/modules/transaction-pause/src/lib.rs b/modules/transaction-pause/src/lib.rs index 83a5c8ef3f..0f5f53b941 100644 --- a/modules/transaction-pause/src/lib.rs +++ b/modules/transaction-pause/src/lib.rs @@ -26,9 +26,15 @@ use frame_support::{ transactional, }; use frame_system::pallet_prelude::*; +use primitives::BlockNumber; use sp_runtime::DispatchResult; use sp_std::{prelude::*, vec::Vec}; +use cumulus_primitives_core::relay_chain::v1::Id; +use cumulus_primitives_core::{DmpMessageHandler, XcmpMessageHandler}; +/// Block number type used by the relay chain. +pub use polkadot_core_primitives::BlockNumber as RelayChainBlockNumber; + mod mock; mod tests; pub mod weights; @@ -72,6 +78,10 @@ pub mod module { pallet_name_bytes: Vec, function_name_bytes: Vec, }, + /// Paused Xcm message + XcmPaused, + /// Resumed Xcm message + XcmResumed, } /// The paused transaction map @@ -81,6 +91,10 @@ pub mod module { #[pallet::getter(fn paused_transactions)] pub type PausedTransactions = StorageMap<_, Twox64Concat, (Vec, Vec), (), OptionQuery>; + #[pallet::storage] + #[pallet::getter(fn xcm_paused)] + pub type XcmPaused = StorageValue<_, bool, ValueQuery>; + #[pallet::pallet] pub struct Pallet(_); @@ -129,6 +143,26 @@ pub mod module { }; Ok(()) } + + #[pallet::weight(T::WeightInfo::pause_xcm())] + pub fn pause_xcm(origin: OriginFor) -> DispatchResult { + T::UpdateOrigin::ensure_origin(origin)?; + if !XcmPaused::::get() { + XcmPaused::::set(true); + Self::deposit_event(Event::XcmPaused); + } + Ok(()) + } + + #[pallet::weight(T::WeightInfo::resume_xcm())] + pub fn resume_xcm(origin: OriginFor) -> DispatchResult { + T::UpdateOrigin::ensure_origin(origin)?; + if XcmPaused::::get() { + XcmPaused::::set(false); + Self::deposit_event(Event::XcmResumed); + } + Ok(()) + } } } @@ -145,3 +179,46 @@ where PausedTransactions::::contains_key((pallet_name.as_bytes(), function_name.as_bytes())) } } + +/// Dmp and Xcmp message handler +pub struct XcmMessageHandler(PhantomData<(T, H)>); + +/// XcmMessageHandler implements `DmpMessageHandler`. if xcm paused, the `max_weight` is set to `0`. +/// +/// Parameters type: +/// - `H`: `DmpMessageHandler` +impl DmpMessageHandler for XcmMessageHandler +where + H: DmpMessageHandler, +{ + fn handle_dmp_messages(iter: impl Iterator)>, max_weight: Weight) -> Weight { + let xcm_paused: bool = Pallet::::xcm_paused(); + if !xcm_paused { + H::handle_dmp_messages(iter, max_weight) + } else { + H::handle_dmp_messages(iter, 0) + } + } +} + +/// XcmMessageHandler implements `XcmpMessageHandler`. if xcm paused, the `max_weight` is set to +/// `0`. +/// +/// Parameters type: +/// - `H`: `XcmpMessageHandler` +impl XcmpMessageHandler for XcmMessageHandler +where + H: XcmpMessageHandler, +{ + fn handle_xcmp_messages<'a, I: Iterator>( + iter: I, + max_weight: Weight, + ) -> Weight { + let xcm_paused: bool = Pallet::::xcm_paused(); + if !xcm_paused { + H::handle_xcmp_messages(iter, max_weight) + } else { + H::handle_xcmp_messages(iter, 0) + } + } +} diff --git a/modules/transaction-pause/src/weights.rs b/modules/transaction-pause/src/weights.rs index 376a3e953e..fa22ec8438 100644 --- a/modules/transaction-pause/src/weights.rs +++ b/modules/transaction-pause/src/weights.rs @@ -49,6 +49,8 @@ use sp_std::marker::PhantomData; pub trait WeightInfo { fn pause_transaction() -> Weight; fn unpause_transaction() -> Weight; + fn pause_xcm() -> Weight; + fn resume_xcm() -> Weight; } /// Weights for module_transaction_pause using the Acala node and recommended hardware. @@ -64,6 +66,16 @@ impl WeightInfo for AcalaWeight { .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } + fn pause_xcm() -> Weight { + (25_798_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + fn resume_xcm() -> Weight { + (25_355_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } } // For backwards compatibility and tests @@ -78,4 +90,14 @@ impl WeightInfo for () { .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } + fn pause_xcm() -> Weight { + (25_798_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(1 as Weight)) + .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + } + fn resume_xcm() -> Weight { + (25_355_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(1 as Weight)) + .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + } } diff --git a/runtime/acala/src/lib.rs b/runtime/acala/src/lib.rs index ac642c964b..79edeeb288 100644 --- a/runtime/acala/src/lib.rs +++ b/runtime/acala/src/lib.rs @@ -56,6 +56,7 @@ use module_evm::{CallInfo, CreateInfo, EvmTask, Runner}; use module_evm_accounts::EvmAddressMapping; use module_relaychain::RelayChainCallBuilder; use module_support::{AssetIdMapping, DispatchableTask}; +use module_transaction_pause::XcmMessageHandler; use module_transaction_payment::{Multiplier, TargetedFeeAdjustment, TransactionFeePoolTrader}; use orml_traits::{ create_median_value_data_provider, parameter_type_with_key, DataFeeder, DataProviderExtended, MultiCurrency, @@ -1366,10 +1367,10 @@ impl cumulus_pallet_parachain_system::Config for Runtime { type Event = Event; type OnValidationData = (); type SelfParaId = ParachainInfo; - type DmpMessageHandler = DmpQueue; + type DmpMessageHandler = XcmMessageHandler; type ReservedDmpWeight = ReservedDmpWeight; type OutboundXcmpMessageSource = XcmpQueue; - type XcmpMessageHandler = XcmpQueue; + type XcmpMessageHandler = XcmMessageHandler; type ReservedXcmpWeight = ReservedXcmpWeight; } diff --git a/runtime/acala/src/weights/module_transaction_pause.rs b/runtime/acala/src/weights/module_transaction_pause.rs index b3615b7a75..5d190f6ba2 100644 --- a/runtime/acala/src/weights/module_transaction_pause.rs +++ b/runtime/acala/src/weights/module_transaction_pause.rs @@ -19,7 +19,7 @@ //! Autogenerated weights for module_transaction_pause //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2021-10-30, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2022-01-05, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("acala-latest"), DB CACHE: 128 // Executed Command: @@ -28,7 +28,7 @@ // --chain=acala-latest // --steps=50 // --repeat=20 -// --pallet=* +// --pallet=module_transaction_pause // --extrinsic=* // --execution=wasm // --wasm-execution=compiled @@ -36,7 +36,6 @@ // --template=./templates/runtime-weight-template.hbs // --output=./runtime/acala/src/weights/ - #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] @@ -48,13 +47,22 @@ use sp_std::marker::PhantomData; pub struct WeightInfo(PhantomData); impl module_transaction_pause::WeightInfo for WeightInfo { fn pause_transaction() -> Weight { - (23_319_000 as Weight) + (23_381_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } fn unpause_transaction() -> Weight { - (23_899_000 as Weight) + (23_853_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + fn pause_xcm() -> Weight { + (20_265_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } + fn resume_xcm() -> Weight { + (4_521_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + } } diff --git a/runtime/integration-tests/Cargo.toml b/runtime/integration-tests/Cargo.toml index 6bdb6d0127..0e01375bff 100644 --- a/runtime/integration-tests/Cargo.toml +++ b/runtime/integration-tests/Cargo.toml @@ -86,6 +86,7 @@ orml-unknown-tokens = { path = "../../orml/unknown-tokens" } orml-xcm = { path = "../../orml/xcm" } module-transaction-payment = { path = "../../modules/transaction-payment" } +module-transaction-pause = { path = "../../modules/transaction-pause" } module-asset-registry = { path = "../../modules/asset-registry" } module-auction-manager = { path = "../../modules/auction-manager" } module-cdp-engine = { path = "../../modules/cdp-engine" } @@ -133,7 +134,7 @@ polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch = polkadot-runtime-parachains = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.13" } kusama-runtime = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.13" } -xcm-emulator = { git = "https://github.com/shaunxw/xcm-simulator", rev = "4d3bb9dd4fa2cd554a9970ffff816d9346269eaa" } +xcm-emulator = { git = "https://github.com/shaunxw/xcm-simulator", rev = "87af52d07fc742cc9220bab6acb9afa061d09fd3" } acala-service = { path = "../../node/service", features = ["with-all-runtime"] } diff --git a/runtime/integration-tests/src/relaychain/kusama_cross_chain_transfer.rs b/runtime/integration-tests/src/relaychain/kusama_cross_chain_transfer.rs index 4110f80912..0d5670488f 100644 --- a/runtime/integration-tests/src/relaychain/kusama_cross_chain_transfer.rs +++ b/runtime/integration-tests/src/relaychain/kusama_cross_chain_transfer.rs @@ -83,15 +83,14 @@ fn transfer_to_relay_chain() { }); } +fn karura_reserve_account() -> AccountId { + polkadot_parachain::primitives::Sibling::from(2000).into_account() +} + #[test] fn transfer_to_sibling() { TestNet::reset(); - fn karura_reserve_account() -> AccountId { - use sp_runtime::traits::AccountIdConversion; - polkadot_parachain::primitives::Sibling::from(2000).into_account() - } - Karura::execute_with(|| { assert_ok!(Tokens::deposit(BNC, &AccountId::from(ALICE), 100_000_000_000_000)); }); @@ -325,11 +324,6 @@ fn subscribe_version_notify_works() { fn test_asset_registry_module() { TestNet::reset(); - fn karura_reserve_account() -> AccountId { - use sp_runtime::traits::AccountIdConversion; - polkadot_parachain::primitives::Sibling::from(2000).into_account() - } - Karura::execute_with(|| { // register foreign asset assert_ok!(AssetRegistry::register_foreign_asset( @@ -711,7 +705,6 @@ fn sibling_trap_assets_works() { let (bnc_asset_amount, kar_asset_amount) = (cent(BNC) / 10, cent(KAR)); fn sibling_account() -> AccountId { - use sp_runtime::traits::AccountIdConversion; polkadot_parachain::primitives::Sibling::from(2001).into_account() } @@ -768,3 +761,113 @@ fn sibling_trap_assets_works() { ); }); } + +#[test] +fn dmp_queue_pause_resume_works() { + use polkadot_primitives::v1::runtime_decl_for_ParachainHost::ParachainHost; + + Karura::execute_with(|| { + assert_ok!(module_transaction_pause::Pallet::::pause_xcm(Origin::root())); + assert!(module_transaction_pause::Pallet::::xcm_paused()); + }); + + let fee: u128 = 128_000_000; + + KusamaNet::execute_with(|| { + assert_ok!(kusama_runtime::XcmPallet::reserve_transfer_assets( + kusama_runtime::Origin::signed(ALICE.into()), + Box::new(Parachain(2000).into().into()), + Box::new( + Junction::AccountId32 { + id: BOB, + network: NetworkId::Any + } + .into() + .into() + ), + Box::new((Here, dollar(KSM)).into()), + 0 + )); + + assert_eq!(::dmq_contents(2000.into()).len(), 1); + }); + + Karura::execute_with(|| { + // the first message is not processed but remain in dmq-queue + assert!(module_transaction_pause::Pallet::::xcm_paused()); + // Bob balance is 0 as the xcm message not executed + assert_eq!(Tokens::free_balance(KSM, &AccountId::from(BOB)), 0); + + // resume the dmp-queue working + assert_ok!(module_transaction_pause::Pallet::::resume_xcm(Origin::root())); + assert!(!module_transaction_pause::Pallet::::xcm_paused()); + }); + + // the empty body implementation here is used to trigger send downward message to parachain + KusamaNet::execute_with(|| { + assert_eq!(::dmq_contents(2000.into()).len(), 1); + }); + + Karura::execute_with(|| { + assert!(!module_transaction_pause::Pallet::::xcm_paused()); + assert_eq!( + Tokens::free_balance(KSM, &AccountId::from(BOB)), + 2 * (dollar(KSM) - fee) + ); + }); +} + +#[test] +fn xcmp_queue_pause_resume_works() { + Karura::execute_with(|| { + assert_ok!(Tokens::deposit(BNC, &AccountId::from(ALICE), 100 * dollar(BNC))); + }); + + Sibling::execute_with(|| { + assert_ok!(Tokens::deposit(BNC, &karura_reserve_account(), 100 * dollar(BNC))); + assert_ok!(module_transaction_pause::Pallet::::pause_xcm(Origin::root())); + assert!(module_transaction_pause::Pallet::::xcm_paused()); + }); + + Karura::execute_with(|| { + assert_ok!(XTokens::transfer( + Origin::signed(ALICE.into()), + BNC, + 10 * dollar(BNC), + Box::new( + MultiLocation::new( + 1, + X2( + Parachain(2001), + Junction::AccountId32 { + network: NetworkId::Any, + id: BOB.into(), + } + ) + ) + .into() + ), + 1_000_000_000, + )); + + assert_eq!(Tokens::free_balance(BNC, &AccountId::from(ALICE)), 90 * dollar(BNC)); + }); + + Sibling::execute_with(|| { + assert_eq!(Tokens::free_balance(BNC, &karura_reserve_account()), 100 * dollar(BNC)); + assert_eq!(Tokens::free_balance(BNC, &AccountId::from(BOB)), 0); + + // resume the xcmp-queue working + assert_ok!(module_transaction_pause::Pallet::::resume_xcm(Origin::root())); + assert!(!module_transaction_pause::Pallet::::xcm_paused()); + + // in the same block, balance not changed + assert_eq!(Tokens::free_balance(BNC, &karura_reserve_account()), 100 * dollar(BNC)); + assert_eq!(Tokens::free_balance(BNC, &AccountId::from(BOB)), 0); + }); + + Sibling::execute_with(|| { + assert_eq!(Tokens::free_balance(BNC, &karura_reserve_account()), 90 * dollar(BNC)); + assert_eq!(Tokens::free_balance(BNC, &AccountId::from(BOB)), 9_989_760_000_000); + }); +} diff --git a/runtime/integration-tests/src/relaychain/kusama_test_net.rs b/runtime/integration-tests/src/relaychain/kusama_test_net.rs index 3ff38e63c9..7b68912a20 100644 --- a/runtime/integration-tests/src/relaychain/kusama_test_net.rs +++ b/runtime/integration-tests/src/relaychain/kusama_test_net.rs @@ -22,6 +22,7 @@ use crate::setup::*; use cumulus_primitives_core::ParaId; use frame_support::traits::GenesisBuild; +use module_transaction_pause::XcmMessageHandler; use polkadot_primitives::v1::{BlockNumber, MAX_CODE_SIZE, MAX_POV_SIZE}; use polkadot_runtime_parachains::configuration::HostConfiguration; use sp_runtime::traits::AccountIdConversion; @@ -40,6 +41,8 @@ decl_test_parachain! { pub struct Karura { Runtime = Runtime, Origin = Origin, + XcmpMessageHandler = XcmMessageHandler, + DmpMessageHandler = XcmMessageHandler, new_ext = para_ext(2000), } } @@ -48,6 +51,8 @@ decl_test_parachain! { pub struct Sibling { Runtime = Runtime, Origin = Origin, + XcmpMessageHandler = XcmMessageHandler, + DmpMessageHandler = XcmMessageHandler, new_ext = para_ext(2001), } } diff --git a/runtime/integration-tests/src/setup.rs b/runtime/integration-tests/src/setup.rs index 9a9923a7f3..ec2926737c 100644 --- a/runtime/integration-tests/src/setup.rs +++ b/runtime/integration-tests/src/setup.rs @@ -78,14 +78,14 @@ mod karura_imports { constants::parachains, create_x2_parachain_multilocation, get_all_module_accounts, AcalaOracle, AccountId, AssetRegistry, AuctionManager, Authority, AuthoritysOriginId, Balance, Balances, BlockNumber, Call, CdpEngine, CdpTreasury, CreateClassDeposit, CreateTokenDeposit, Currencies, CurrencyId, CurrencyIdConvert, - DataDepositPerByte, DefaultExchangeRate, Dex, EmergencyShutdown, Event, EvmAccounts, ExistentialDeposits, - FeePoolSize, FinancialCouncil, Get, GetNativeCurrencyId, Homa, HomaXcm, Honzon, IdleScheduler, KarPerSecond, - KaruraFoundationAccounts, KsmPerSecond, KusamaBondingDuration, KusdPerSecond, Loans, MaxTipsOfPriority, - MinimumDebitValue, MultiLocation, NativeTokenExistentialDeposit, NetworkId, NftPalletId, OneDay, Origin, - OriginCaller, ParachainAccount, ParachainInfo, ParachainSystem, PolkadotXcm, Proxy, ProxyType, Ratio, - RelayChainBlockNumberProvider, Runtime, Scheduler, Session, SessionManager, SevenDays, SwapBalanceThreshold, - System, Timestamp, TipPerWeightStep, TokenSymbol, Tokens, TreasuryPalletId, Utility, Vesting, XTokens, - XcmConfig, XcmExecutor, EVM, NFT, + DataDepositPerByte, DefaultExchangeRate, Dex, DmpQueue, EmergencyShutdown, Event, EvmAccounts, + ExistentialDeposits, FeePoolSize, FinancialCouncil, Get, GetNativeCurrencyId, Homa, HomaXcm, Honzon, + IdleScheduler, KarPerSecond, KaruraFoundationAccounts, KsmPerSecond, KusamaBondingDuration, KusdPerSecond, + Loans, MaxTipsOfPriority, MinimumDebitValue, MultiLocation, NativeTokenExistentialDeposit, NetworkId, + NftPalletId, OneDay, Origin, OriginCaller, ParachainAccount, ParachainInfo, ParachainSystem, PolkadotXcm, + Proxy, ProxyType, Ratio, RelayChainBlockNumberProvider, Runtime, Scheduler, Session, SessionManager, SevenDays, + SwapBalanceThreshold, System, Timestamp, TipPerWeightStep, TokenSymbol, Tokens, TreasuryPalletId, Utility, + Vesting, XTokens, XcmConfig, XcmExecutor, XcmpQueue, EVM, NFT, }; pub use primitives::TradingPair; pub use runtime_common::{calculate_asset_ratio, cent, dollar, millicent, KAR, KSM, KUSD, LKSM}; diff --git a/runtime/karura/src/lib.rs b/runtime/karura/src/lib.rs index a67b817525..00875fee08 100644 --- a/runtime/karura/src/lib.rs +++ b/runtime/karura/src/lib.rs @@ -56,6 +56,7 @@ use module_evm::{CallInfo, CreateInfo, EvmTask, Runner}; use module_evm_accounts::EvmAddressMapping; use module_relaychain::RelayChainCallBuilder; use module_support::{AssetIdMapping, DispatchableTask}; +use module_transaction_pause::XcmMessageHandler; use module_transaction_payment::{Multiplier, TargetedFeeAdjustment, TransactionFeePoolTrader}; use orml_traits::{ @@ -1383,10 +1384,10 @@ impl cumulus_pallet_parachain_system::Config for Runtime { type Event = Event; type OnValidationData = (); type SelfParaId = ParachainInfo; - type DmpMessageHandler = DmpQueue; + type DmpMessageHandler = XcmMessageHandler; type ReservedDmpWeight = ReservedDmpWeight; type OutboundXcmpMessageSource = XcmpQueue; - type XcmpMessageHandler = XcmpQueue; + type XcmpMessageHandler = XcmMessageHandler; type ReservedXcmpWeight = ReservedXcmpWeight; } diff --git a/runtime/karura/src/weights/module_transaction_pause.rs b/runtime/karura/src/weights/module_transaction_pause.rs index c7c82dab17..4a674a4a3f 100644 --- a/runtime/karura/src/weights/module_transaction_pause.rs +++ b/runtime/karura/src/weights/module_transaction_pause.rs @@ -19,7 +19,7 @@ //! Autogenerated weights for module_transaction_pause //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2021-10-30, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2022-01-05, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("karura-dev"), DB CACHE: 128 // Executed Command: @@ -28,7 +28,7 @@ // --chain=karura-dev // --steps=50 // --repeat=20 -// --pallet=* +// --pallet=module_transaction_pause // --extrinsic=* // --execution=wasm // --wasm-execution=compiled @@ -36,7 +36,6 @@ // --template=./templates/runtime-weight-template.hbs // --output=./runtime/karura/src/weights/ - #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] @@ -48,13 +47,22 @@ use sp_std::marker::PhantomData; pub struct WeightInfo(PhantomData); impl module_transaction_pause::WeightInfo for WeightInfo { fn pause_transaction() -> Weight { - (22_667_000 as Weight) + (22_432_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } fn unpause_transaction() -> Weight { - (22_608_000 as Weight) + (22_658_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + fn pause_xcm() -> Weight { + (19_438_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } + fn resume_xcm() -> Weight { + (4_208_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + } } diff --git a/runtime/mandala/src/benchmarking/transaction_pause.rs b/runtime/mandala/src/benchmarking/transaction_pause.rs index 54bdfd2ebe..9d19cac36d 100644 --- a/runtime/mandala/src/benchmarking/transaction_pause.rs +++ b/runtime/mandala/src/benchmarking/transaction_pause.rs @@ -30,6 +30,12 @@ runtime_benchmarks! { unpause_transaction { TransactionPause::pause_transaction(Origin::root(), b"Balances".to_vec(), b"transfer".to_vec())?; }: _(RawOrigin::Root, b"Balances".to_vec(), b"transfer".to_vec()) + + pause_xcm { + }: _(RawOrigin::Root) + + resume_xcm { + }: _(RawOrigin::Root) } #[cfg(test)] diff --git a/runtime/mandala/src/lib.rs b/runtime/mandala/src/lib.rs index a37eea1b87..caf683219d 100644 --- a/runtime/mandala/src/lib.rs +++ b/runtime/mandala/src/lib.rs @@ -53,6 +53,7 @@ use module_evm::{CallInfo, CreateInfo, EvmTask, Runner}; use module_evm_accounts::EvmAddressMapping; use module_relaychain::RelayChainCallBuilder; use module_support::{AssetIdMapping, DispatchableTask, ExchangeRateProvider}; +use module_transaction_pause::XcmMessageHandler; use module_transaction_payment::{Multiplier, TargetedFeeAdjustment, TransactionFeePoolTrader}; use scale_info::TypeInfo; @@ -1535,10 +1536,10 @@ impl cumulus_pallet_parachain_system::Config for Runtime { type Event = Event; type OnValidationData = (); type SelfParaId = ParachainInfo; - type DmpMessageHandler = DmpQueue; + type DmpMessageHandler = XcmMessageHandler; type ReservedDmpWeight = ReservedDmpWeight; type OutboundXcmpMessageSource = XcmpQueue; - type XcmpMessageHandler = XcmpQueue; + type XcmpMessageHandler = XcmMessageHandler; type ReservedXcmpWeight = ReservedXcmpWeight; } diff --git a/runtime/mandala/src/weights/module_transaction_pause.rs b/runtime/mandala/src/weights/module_transaction_pause.rs index a8be8ce093..e998f4b32a 100644 --- a/runtime/mandala/src/weights/module_transaction_pause.rs +++ b/runtime/mandala/src/weights/module_transaction_pause.rs @@ -18,17 +18,17 @@ //! Autogenerated weights for module_transaction_pause //! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0 -//! DATE: 2021-08-15, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("mandala-latest"), DB CACHE: 128 +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2022-01-05, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 128 // Executed Command: // target/release/acala // benchmark -// --chain=mandala-latest +// --chain=dev // --steps=50 // --repeat=20 -// --pallet=* +// --pallet=module_transaction_pause // --extrinsic=* // --execution=wasm // --wasm-execution=compiled @@ -36,7 +36,6 @@ // --template=./templates/runtime-weight-template.hbs // --output=./runtime/mandala/src/weights/ - #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] @@ -48,13 +47,22 @@ use sp_std::marker::PhantomData; pub struct WeightInfo(PhantomData); impl module_transaction_pause::WeightInfo for WeightInfo { fn pause_transaction() -> Weight { - (24_000_000 as Weight) + (22_402_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } fn unpause_transaction() -> Weight { - (25_000_000 as Weight) + (22_972_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + fn pause_xcm() -> Weight { + (19_395_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } + fn resume_xcm() -> Weight { + (4_190_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + } }