Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tx-pause to all runtimes #1381

Merged
merged 3 commits into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions node/src/chain_spec/crab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() },

Expand Down Expand Up @@ -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),
Expand Down
6 changes: 6 additions & 0 deletions node/src/chain_spec/darwinia.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() },

Expand Down Expand Up @@ -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),
Expand Down
2 changes: 2 additions & 0 deletions node/src/chain_spec/pangoro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 4 additions & 0 deletions runtime/crab/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
6 changes: 4 additions & 2 deletions runtime/crab/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -197,11 +198,12 @@ frame_benchmarking::define_benchmarks! {
[pallet_proxy, Proxy]
[pallet_referenda, Referenda]
[pallet_scheduler, Scheduler]
[pallet_session, SessionBench::<Runtime>]
[pallet_timestamp, Timestamp]
[pallet_treasury, Treasury]
[pallet_tx_pause, TxPause]
[pallet_utility, Utility]
[pallet_vesting, Vesting]
[pallet_session, SessionBench::<Runtime>]
[pallet_timestamp, Timestamp]
[pallet_whitelist, Whitelist]
}

Expand Down
2 changes: 2 additions & 0 deletions runtime/crab/src/pallets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ mod preimage;

mod proxy;

mod tx_pause;

// XCM stuff.
mod xcmp_queue;

Expand Down
2 changes: 1 addition & 1 deletion runtime/crab/src/pallets/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>;
Expand Down
44 changes: 44 additions & 0 deletions runtime/crab/src/pallets/tx_pause.rs
Original file line number Diff line number Diff line change
@@ -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 <https://www.gnu.org/licenses/>.

// darwinia
use crate::*;

/// Calls that cannot be paused by the tx-pause pallet.
pub struct TxPauseWhitelistedCalls;
impl frame_support::traits::Contains<pallet_tx_pause::RuntimeCallNameOf<Runtime>>
for TxPauseWhitelistedCalls
{
fn contains(full_name: &pallet_tx_pause::RuntimeCallNameOf<Runtime>) -> 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<TechnicalCollective>;
type RuntimeCall = RuntimeCall;
type RuntimeEvent = RuntimeEvent;
type UnpauseOrigin = RootOrAtLeastTwoThird<TechnicalCollective>;
// TODO: Update the benchmark weight info
type WeightInfo = ();
type WhitelistedCalls = TxPauseWhitelistedCalls;
}
1 change: 1 addition & 0 deletions runtime/crab/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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! {}
8 changes: 6 additions & 2 deletions runtime/darwinia/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand Down Expand Up @@ -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 }
Expand Down Expand Up @@ -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",

Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
12 changes: 7 additions & 5 deletions runtime/darwinia/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -195,18 +196,19 @@ frame_benchmarking::define_benchmarks! {
[frame_system, SystemBench::<Runtime>]
[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::<Runtime>]
[pallet_timestamp, Timestamp]
[pallet_treasury, Treasury]
[pallet_tx_pause, TxPause]
[pallet_utility, Utility]
[pallet_whitelist, Whitelist]
}

impl_self_contained_call!();
Expand Down
2 changes: 2 additions & 0 deletions runtime/darwinia/src/pallets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ mod preimage;

mod proxy;

mod tx_pause;

// XCM stuff.
mod xcmp_queue;

Expand Down
2 changes: 1 addition & 1 deletion runtime/darwinia/src/pallets/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>;
Expand Down
44 changes: 44 additions & 0 deletions runtime/darwinia/src/pallets/tx_pause.rs
Original file line number Diff line number Diff line change
@@ -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 <https://www.gnu.org/licenses/>.

// darwinia
use crate::*;

/// Calls that cannot be paused by the tx-pause pallet.
pub struct TxPauseWhitelistedCalls;
impl frame_support::traits::Contains<pallet_tx_pause::RuntimeCallNameOf<Runtime>>
for TxPauseWhitelistedCalls
{
fn contains(full_name: &pallet_tx_pause::RuntimeCallNameOf<Runtime>) -> 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<TechnicalCollective>;
type RuntimeCall = RuntimeCall;
type RuntimeEvent = RuntimeEvent;
type UnpauseOrigin = RootOrAtLeastTwoThird<TechnicalCollective>;
// TODO: Update the benchmark weight info
type WeightInfo = ();
type WhitelistedCalls = TxPauseWhitelistedCalls;
}
1 change: 1 addition & 0 deletions runtime/darwinia/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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! {}
6 changes: 3 additions & 3 deletions runtime/pangolin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<Runtime>]
[pallet_timestamp, Timestamp]
[pallet_whitelist, Whitelist]
[pallet_treasury, Treasury]
[pallet_tx_pause, TxPause]
[pallet_utility, Utility]
[pallet_whitelist, Whitelist]
}

impl_self_contained_call!();
Expand Down
Loading