diff --git a/Cargo.lock b/Cargo.lock index 19c76b720..b4e69a8bc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1872,6 +1872,7 @@ dependencies = [ "pallet-transaction-payment", "pallet-transaction-payment-rpc-runtime-api", "pallet-treasury", + "pallet-tx-pause", "pallet-utility", "pallet-vesting", "pallet-whitelist", @@ -3253,6 +3254,7 @@ dependencies = [ "pallet-transaction-payment", "pallet-transaction-payment-rpc-runtime-api", "pallet-treasury", + "pallet-tx-pause", "pallet-utility", "pallet-vesting", "pallet-whitelist", @@ -9472,6 +9474,7 @@ dependencies = [ "pallet-transaction-payment", "pallet-transaction-payment-rpc-runtime-api", "pallet-treasury", + "pallet-tx-pause", "pallet-utility", "pallet-whitelist", "pallet-xcm", diff --git a/node/src/chain_spec/crab.rs b/node/src/chain_spec/crab.rs index 9391fa132..c7ba55757 100644 --- a/node/src/chain_spec/crab.rs +++ b/node/src/chain_spec/crab.rs @@ -225,6 +225,9 @@ pub fn genesis_config() -> ChainSpec { technical_committee: Default::default(), treasury: Default::default(), + // Utility stuff. + tx_pause: Default::default(), + // XCM stuff. polkadot_xcm: PolkadotXcmConfig { safe_xcm_version: Some(SAFE_XCM_VERSION), ..Default::default() }, @@ -328,6 +331,9 @@ fn testnet_genesis( technical_committee: Default::default(), treasury: Default::default(), + // Utility stuff. + tx_pause: Default::default(), + // XCM stuff. polkadot_xcm: PolkadotXcmConfig { safe_xcm_version: Some(SAFE_XCM_VERSION), diff --git a/node/src/chain_spec/darwinia.rs b/node/src/chain_spec/darwinia.rs index bd80c43c5..1c7527bb4 100644 --- a/node/src/chain_spec/darwinia.rs +++ b/node/src/chain_spec/darwinia.rs @@ -225,6 +225,9 @@ pub fn genesis_config() -> ChainSpec { technical_committee: Default::default(), treasury: Default::default(), + // Utility stuff. + tx_pause: Default::default(), + // XCM stuff. polkadot_xcm: PolkadotXcmConfig { safe_xcm_version: Some(SAFE_XCM_VERSION), ..Default::default() }, @@ -332,6 +335,9 @@ fn testnet_genesis( technical_committee: Default::default(), treasury: Default::default(), + // Utility stuff. + tx_pause: Default::default(), + // XCM stuff. polkadot_xcm: PolkadotXcmConfig { safe_xcm_version: Some(SAFE_XCM_VERSION), diff --git a/node/src/chain_spec/pangoro.rs b/node/src/chain_spec/pangoro.rs index 8540095ff..f75fc3404 100644 --- a/node/src/chain_spec/pangoro.rs +++ b/node/src/chain_spec/pangoro.rs @@ -218,6 +218,7 @@ pub fn genesis_config() -> ChainSpec { // Utility stuff. sudo: SudoConfig { key: Some(array_bytes::hex_n_into_unchecked::<_, _, 20>(SUDO)) }, + tx_pause: Default::default(), // XCM stuff. polkadot_xcm: PolkadotXcmConfig { @@ -330,6 +331,7 @@ fn testnet_genesis( // Utility stuff. sudo: SudoConfig { key: Some(array_bytes::hex_n_into_unchecked::<_, _, 20>(ALITH)) }, + tx_pause: Default::default(), // XCM stuff. polkadot_xcm: PolkadotXcmConfig { diff --git a/runtime/crab/Cargo.toml b/runtime/crab/Cargo.toml index 937ae4eda..18112da41 100644 --- a/runtime/crab/Cargo.toml +++ b/runtime/crab/Cargo.toml @@ -107,6 +107,7 @@ pallet-timestamp = { workspace = true } pallet-transaction-payment = { workspace = true } pallet-transaction-payment-rpc-runtime-api = { workspace = true } pallet-treasury = { workspace = true } +pallet-tx-pause = { workspace = true } pallet-utility = { workspace = true } pallet-vesting = { workspace = true } pallet-whitelist = { workspace = true } @@ -233,6 +234,7 @@ std = [ "pallet-transaction-payment-rpc-runtime-api/std", "pallet-transaction-payment/std", "pallet-treasury/std", + "pallet-tx-pause/std", "pallet-utility/std", "pallet-vesting/std", "pallet-whitelist/std", @@ -325,6 +327,7 @@ runtime-benchmarks = [ "pallet-scheduler/runtime-benchmarks", "pallet-timestamp/runtime-benchmarks", "pallet-treasury/runtime-benchmarks", + "pallet-tx-pause/runtime-benchmarks", "pallet-utility/runtime-benchmarks", "pallet-vesting/runtime-benchmarks", "pallet-whitelist/runtime-benchmarks", @@ -386,6 +389,7 @@ try-runtime = [ "pallet-timestamp/try-runtime", "pallet-transaction-payment/try-runtime", "pallet-treasury/try-runtime", + "pallet-tx-pause/try-runtime", "pallet-utility/try-runtime", "pallet-vesting/try-runtime", "pallet-whitelist/try-runtime", diff --git a/runtime/crab/src/lib.rs b/runtime/crab/src/lib.rs index 4be25dc0b..ac3a0f9d3 100644 --- a/runtime/crab/src/lib.rs +++ b/runtime/crab/src/lib.rs @@ -152,6 +152,7 @@ frame_support::construct_runtime! { Scheduler: pallet_scheduler = 28, Preimage: pallet_preimage = 29, Proxy: pallet_proxy = 30, + TxPause: pallet_tx_pause = 48, // XCM stuff. XcmpQueue: cumulus_pallet_xcmp_queue = 32, @@ -197,11 +198,12 @@ frame_benchmarking::define_benchmarks! { [pallet_proxy, Proxy] [pallet_referenda, Referenda] [pallet_scheduler, Scheduler] + [pallet_session, SessionBench::] + [pallet_timestamp, Timestamp] [pallet_treasury, Treasury] + [pallet_tx_pause, TxPause] [pallet_utility, Utility] [pallet_vesting, Vesting] - [pallet_session, SessionBench::] - [pallet_timestamp, Timestamp] [pallet_whitelist, Whitelist] } diff --git a/runtime/crab/src/pallets.rs b/runtime/crab/src/pallets.rs index 33deaac27..b08cd2f3f 100644 --- a/runtime/crab/src/pallets.rs +++ b/runtime/crab/src/pallets.rs @@ -77,6 +77,8 @@ mod preimage; mod proxy; +mod tx_pause; + // XCM stuff. mod xcmp_queue; diff --git a/runtime/crab/src/pallets/system.rs b/runtime/crab/src/pallets/system.rs index 6ddc141fc..10304a02c 100644 --- a/runtime/crab/src/pallets/system.rs +++ b/runtime/crab/src/pallets/system.rs @@ -65,7 +65,7 @@ impl frame_system::Config for Runtime { /// The identifier used to distinguish between accounts. type AccountId = AccountId; /// The basic call filter to use in dispatchable. - type BaseCallFilter = frame_support::traits::Everything; + type BaseCallFilter = TxPause; type Block = Block; /// Maximum number of block number to block hash mappings to keep (oldest pruned first). type BlockHashCount = ConstU32<256>; diff --git a/runtime/crab/src/pallets/tx_pause.rs b/runtime/crab/src/pallets/tx_pause.rs new file mode 100644 index 000000000..2b6bf92fe --- /dev/null +++ b/runtime/crab/src/pallets/tx_pause.rs @@ -0,0 +1,44 @@ +// This file is part of Darwinia. +// +// Copyright (C) 2018-2023 Darwinia Network +// SPDX-License-Identifier: GPL-3.0 +// +// Darwinia is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Darwinia is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Darwinia. If not, see . + +// darwinia +use crate::*; + +/// Calls that cannot be paused by the tx-pause pallet. +pub struct TxPauseWhitelistedCalls; +impl frame_support::traits::Contains> + for TxPauseWhitelistedCalls +{ + fn contains(full_name: &pallet_tx_pause::RuntimeCallNameOf) -> bool { + matches!( + (full_name.0.as_slice(), full_name.1.as_slice()), + (b"System", b"remark_with_event") + ) + } +} + +impl pallet_tx_pause::Config for Runtime { + type MaxNameLen = ConstU32<256>; + type PauseOrigin = RootOrAtLeastTwoThird; + type RuntimeCall = RuntimeCall; + type RuntimeEvent = RuntimeEvent; + type UnpauseOrigin = RootOrAtLeastTwoThird; + // TODO: Update the benchmark weight info + type WeightInfo = (); + type WhitelistedCalls = TxPauseWhitelistedCalls; +} diff --git a/runtime/crab/tests/tests.rs b/runtime/crab/tests/tests.rs index b220641fb..24610373e 100644 --- a/runtime/crab/tests/tests.rs +++ b/runtime/crab/tests/tests.rs @@ -23,3 +23,4 @@ darwinia_common_runtime::impl_fee_tests! {} darwinia_common_runtime::impl_evm_tests! {} darwinia_common_runtime::impl_account_migration_tests! {} darwinia_common_runtime::impl_messages_bridge_tests! {} +darwinia_common_runtime::impl_maintenance_tests! {} diff --git a/runtime/darwinia/Cargo.toml b/runtime/darwinia/Cargo.toml index 6d05ad7e2..040c2c7d6 100644 --- a/runtime/darwinia/Cargo.toml +++ b/runtime/darwinia/Cargo.toml @@ -77,8 +77,8 @@ pallet-evm-precompile-simple = { workspace = true } moonbeam-evm-tracer = { workspace = true, optional = true } moonbeam-rpc-primitives-debug = { workspace = true } pallet-asset-manager = { workspace = true } -pallet-evm-precompile-conviction-voting = { workspace = true } pallet-ethereum-xcm = { workspace = true } +pallet-evm-precompile-conviction-voting = { workspace = true } precompile-utils = { workspace = true } xcm-primitives = { workspace = true } @@ -116,6 +116,7 @@ pallet-timestamp = { workspace = true } pallet-transaction-payment = { workspace = true } pallet-transaction-payment-rpc-runtime-api = { workspace = true } pallet-treasury = { workspace = true } +pallet-tx-pause = { workspace = true } pallet-utility = { workspace = true } pallet-vesting = { workspace = true } pallet-whitelist = { workspace = true } @@ -213,8 +214,8 @@ std = [ "moonbeam-evm-tracer/std", "moonbeam-rpc-primitives-debug/std", "pallet-asset-manager/std", - "pallet-evm-precompile-conviction-voting/std", "pallet-ethereum-xcm/std", + "pallet-evm-precompile-conviction-voting/std", "precompile-utils/std", "xcm-primitives/std", @@ -252,6 +253,7 @@ std = [ "pallet-transaction-payment-rpc-runtime-api/std", "pallet-transaction-payment/std", "pallet-treasury/std", + "pallet-tx-pause/std", "pallet-utility/std", "pallet-vesting/std", "pallet-whitelist/std", @@ -350,6 +352,7 @@ runtime-benchmarks = [ "pallet-scheduler/runtime-benchmarks", "pallet-timestamp/runtime-benchmarks", "pallet-treasury/runtime-benchmarks", + "pallet-tx-pause/runtime-benchmarks", "pallet-utility/runtime-benchmarks", "pallet-vesting/runtime-benchmarks", "pallet-whitelist/runtime-benchmarks", @@ -421,6 +424,7 @@ try-runtime = [ "pallet-timestamp/try-runtime", "pallet-transaction-payment/try-runtime", "pallet-treasury/try-runtime", + "pallet-tx-pause/try-runtime", "pallet-utility/try-runtime", "pallet-vesting/try-runtime", "pallet-whitelist/try-runtime", diff --git a/runtime/darwinia/src/lib.rs b/runtime/darwinia/src/lib.rs index 30a74a777..1da184dc2 100644 --- a/runtime/darwinia/src/lib.rs +++ b/runtime/darwinia/src/lib.rs @@ -152,6 +152,7 @@ frame_support::construct_runtime! { Scheduler: pallet_scheduler = 28, Preimage: pallet_preimage = 29, Proxy: pallet_proxy = 30, + TxPause: pallet_tx_pause = 52, // XCM stuff. XcmpQueue: cumulus_pallet_xcmp_queue = 32, @@ -195,18 +196,19 @@ frame_benchmarking::define_benchmarks! { [frame_system, SystemBench::] [pallet_assets, Assets] [pallet_balances, Balances] - [pallet_collective, Council] [pallet_collective, TechnicalCommittee] - [pallet_democracy, Democracy] + [pallet_conviction_voting, ConvictionVoting] [pallet_identity, Identity] [pallet_preimage, Preimage] [pallet_proxy, Proxy] + [pallet_referenda, Referenda] [pallet_scheduler, Scheduler] - [pallet_treasury, Treasury] - [pallet_utility, Utility] - [pallet_vesting, Vesting] [pallet_session, SessionBench::] [pallet_timestamp, Timestamp] + [pallet_treasury, Treasury] + [pallet_tx_pause, TxPause] + [pallet_utility, Utility] + [pallet_whitelist, Whitelist] } impl_self_contained_call!(); diff --git a/runtime/darwinia/src/pallets.rs b/runtime/darwinia/src/pallets.rs index 90679456c..f5da4979b 100644 --- a/runtime/darwinia/src/pallets.rs +++ b/runtime/darwinia/src/pallets.rs @@ -81,6 +81,8 @@ mod preimage; mod proxy; +mod tx_pause; + // XCM stuff. mod xcmp_queue; diff --git a/runtime/darwinia/src/pallets/system.rs b/runtime/darwinia/src/pallets/system.rs index 5532835da..12c7ee996 100644 --- a/runtime/darwinia/src/pallets/system.rs +++ b/runtime/darwinia/src/pallets/system.rs @@ -65,7 +65,7 @@ impl frame_system::Config for Runtime { /// The identifier used to distinguish between accounts. type AccountId = AccountId; /// The basic call filter to use in dispatchable. - type BaseCallFilter = frame_support::traits::Everything; + type BaseCallFilter = TxPause; type Block = Block; /// Maximum number of block number to block hash mappings to keep (oldest pruned first). type BlockHashCount = ConstU32<256>; diff --git a/runtime/darwinia/src/pallets/tx_pause.rs b/runtime/darwinia/src/pallets/tx_pause.rs new file mode 100644 index 000000000..2b6bf92fe --- /dev/null +++ b/runtime/darwinia/src/pallets/tx_pause.rs @@ -0,0 +1,44 @@ +// This file is part of Darwinia. +// +// Copyright (C) 2018-2023 Darwinia Network +// SPDX-License-Identifier: GPL-3.0 +// +// Darwinia is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Darwinia is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Darwinia. If not, see . + +// darwinia +use crate::*; + +/// Calls that cannot be paused by the tx-pause pallet. +pub struct TxPauseWhitelistedCalls; +impl frame_support::traits::Contains> + for TxPauseWhitelistedCalls +{ + fn contains(full_name: &pallet_tx_pause::RuntimeCallNameOf) -> bool { + matches!( + (full_name.0.as_slice(), full_name.1.as_slice()), + (b"System", b"remark_with_event") + ) + } +} + +impl pallet_tx_pause::Config for Runtime { + type MaxNameLen = ConstU32<256>; + type PauseOrigin = RootOrAtLeastTwoThird; + type RuntimeCall = RuntimeCall; + type RuntimeEvent = RuntimeEvent; + type UnpauseOrigin = RootOrAtLeastTwoThird; + // TODO: Update the benchmark weight info + type WeightInfo = (); + type WhitelistedCalls = TxPauseWhitelistedCalls; +} diff --git a/runtime/darwinia/tests/tests.rs b/runtime/darwinia/tests/tests.rs index b220641fb..24610373e 100644 --- a/runtime/darwinia/tests/tests.rs +++ b/runtime/darwinia/tests/tests.rs @@ -23,3 +23,4 @@ darwinia_common_runtime::impl_fee_tests! {} darwinia_common_runtime::impl_evm_tests! {} darwinia_common_runtime::impl_account_migration_tests! {} darwinia_common_runtime::impl_messages_bridge_tests! {} +darwinia_common_runtime::impl_maintenance_tests! {} diff --git a/runtime/pangolin/src/lib.rs b/runtime/pangolin/src/lib.rs index 9dfbdb182..b8c12eba4 100644 --- a/runtime/pangolin/src/lib.rs +++ b/runtime/pangolin/src/lib.rs @@ -204,12 +204,12 @@ frame_benchmarking::define_benchmarks! { [pallet_proxy, Proxy] [pallet_referenda, Referenda] [pallet_scheduler, Scheduler] - [pallet_treasury, Treasury] - [pallet_utility, Utility] [pallet_session, SessionBench::] [pallet_timestamp, Timestamp] - [pallet_whitelist, Whitelist] + [pallet_treasury, Treasury] [pallet_tx_pause, TxPause] + [pallet_utility, Utility] + [pallet_whitelist, Whitelist] } impl_self_contained_call!(); diff --git a/runtime/pangoro/Cargo.toml b/runtime/pangoro/Cargo.toml index 677ca940e..8e8091430 100644 --- a/runtime/pangoro/Cargo.toml +++ b/runtime/pangoro/Cargo.toml @@ -110,6 +110,7 @@ pallet-timestamp = { workspace = true } pallet-transaction-payment = { workspace = true } pallet-transaction-payment-rpc-runtime-api = { workspace = true } pallet-treasury = { workspace = true } +pallet-tx-pause = { workspace = true } pallet-utility = { workspace = true } pallet-whitelist = { workspace = true } sp-api = { workspace = true } @@ -239,6 +240,7 @@ std = [ "pallet-transaction-payment-rpc-runtime-api/std", "pallet-transaction-payment/std", "pallet-treasury/std", + "pallet-tx-pause/std", "pallet-utility/std", "pallet-whitelist/std", "sp-api/std", @@ -331,6 +333,7 @@ runtime-benchmarks = [ "pallet-sudo/runtime-benchmarks", "pallet-timestamp/runtime-benchmarks", "pallet-treasury/runtime-benchmarks", + "pallet-tx-pause/runtime-benchmarks", "pallet-utility/runtime-benchmarks", "pallet-whitelist/runtime-benchmarks", "sp-runtime/runtime-benchmarks", @@ -397,6 +400,7 @@ try-runtime = [ "pallet-timestamp/try-runtime", "pallet-transaction-payment/try-runtime", "pallet-treasury/try-runtime", + "pallet-tx-pause/try-runtime", "pallet-utility/try-runtime", "pallet-whitelist/try-runtime", "sp-runtime/try-runtime", diff --git a/runtime/pangoro/src/lib.rs b/runtime/pangoro/src/lib.rs index 83b7c7974..0557d1a6c 100644 --- a/runtime/pangoro/src/lib.rs +++ b/runtime/pangoro/src/lib.rs @@ -152,6 +152,7 @@ frame_support::construct_runtime! { Scheduler: pallet_scheduler = 28, Preimage: pallet_preimage = 29, Proxy: pallet_proxy = 30, + TxPause: pallet_tx_pause = 49, // XCM stuff. XcmpQueue: cumulus_pallet_xcmp_queue = 32, @@ -192,17 +193,19 @@ frame_benchmarking::define_benchmarks! { [frame_system, SystemBench::] [pallet_assets, Assets] [pallet_balances, Balances] - [pallet_collective, Council] [pallet_collective, TechnicalCommittee] - [pallet_democracy, Democracy] + [pallet_conviction_voting, ConvictionVoting] [pallet_identity, Identity] [pallet_preimage, Preimage] [pallet_proxy, Proxy] + [pallet_referenda, Referenda] [pallet_scheduler, Scheduler] - [pallet_treasury, Treasury] - [pallet_utility, Utility] [pallet_session, SessionBench::] [pallet_timestamp, Timestamp] + [pallet_treasury, Treasury] + [pallet_tx_pause, TxPause] + [pallet_utility, Utility] + [pallet_whitelist, Whitelist] } impl_self_contained_call!(); diff --git a/runtime/pangoro/src/pallets.rs b/runtime/pangoro/src/pallets.rs index d4b32a965..895e2223c 100644 --- a/runtime/pangoro/src/pallets.rs +++ b/runtime/pangoro/src/pallets.rs @@ -81,6 +81,8 @@ mod preimage; mod proxy; +mod tx_pause; + // XCM stuff. mod xcmp_queue; diff --git a/runtime/pangoro/src/pallets/system.rs b/runtime/pangoro/src/pallets/system.rs index 5532835da..12c7ee996 100644 --- a/runtime/pangoro/src/pallets/system.rs +++ b/runtime/pangoro/src/pallets/system.rs @@ -65,7 +65,7 @@ impl frame_system::Config for Runtime { /// The identifier used to distinguish between accounts. type AccountId = AccountId; /// The basic call filter to use in dispatchable. - type BaseCallFilter = frame_support::traits::Everything; + type BaseCallFilter = TxPause; type Block = Block; /// Maximum number of block number to block hash mappings to keep (oldest pruned first). type BlockHashCount = ConstU32<256>; diff --git a/runtime/pangoro/src/pallets/tx_pause.rs b/runtime/pangoro/src/pallets/tx_pause.rs new file mode 100644 index 000000000..2b6bf92fe --- /dev/null +++ b/runtime/pangoro/src/pallets/tx_pause.rs @@ -0,0 +1,44 @@ +// This file is part of Darwinia. +// +// Copyright (C) 2018-2023 Darwinia Network +// SPDX-License-Identifier: GPL-3.0 +// +// Darwinia is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Darwinia is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Darwinia. If not, see . + +// darwinia +use crate::*; + +/// Calls that cannot be paused by the tx-pause pallet. +pub struct TxPauseWhitelistedCalls; +impl frame_support::traits::Contains> + for TxPauseWhitelistedCalls +{ + fn contains(full_name: &pallet_tx_pause::RuntimeCallNameOf) -> bool { + matches!( + (full_name.0.as_slice(), full_name.1.as_slice()), + (b"System", b"remark_with_event") + ) + } +} + +impl pallet_tx_pause::Config for Runtime { + type MaxNameLen = ConstU32<256>; + type PauseOrigin = RootOrAtLeastTwoThird; + type RuntimeCall = RuntimeCall; + type RuntimeEvent = RuntimeEvent; + type UnpauseOrigin = RootOrAtLeastTwoThird; + // TODO: Update the benchmark weight info + type WeightInfo = (); + type WhitelistedCalls = TxPauseWhitelistedCalls; +} diff --git a/runtime/pangoro/tests/tests.rs b/runtime/pangoro/tests/tests.rs index b220641fb..24610373e 100644 --- a/runtime/pangoro/tests/tests.rs +++ b/runtime/pangoro/tests/tests.rs @@ -23,3 +23,4 @@ darwinia_common_runtime::impl_fee_tests! {} darwinia_common_runtime::impl_evm_tests! {} darwinia_common_runtime::impl_account_migration_tests! {} darwinia_common_runtime::impl_messages_bridge_tests! {} +darwinia_common_runtime::impl_maintenance_tests! {}