diff --git a/runtime/common/src/test.rs b/runtime/common/src/test.rs index f1daf255e..f885cedd7 100644 --- a/runtime/common/src/test.rs +++ b/runtime/common/src/test.rs @@ -173,7 +173,7 @@ macro_rules! impl_account_migration_tests { #[test] fn validate_evm_account_already_exist() { let (from, _) = alice(); - let to = H160::from_low_u64_be(33).into(); + let to = H160::from_low_u64_be(0).into(); ExtBuilder::default().with_balances(vec![(to, RING_AMOUNT)]).build().execute_with( || { @@ -188,7 +188,7 @@ macro_rules! impl_account_migration_tests { #[test] fn validate_invalid_sig() { let (from, from_pk) = alice(); - let to = H160::from_low_u64_be(33).into(); + let to = H160::from_low_u64_be(0).into(); let message = darwinia_account_migration::signable_message(b"?", &to); let sig = from.sign(&message); @@ -861,7 +861,7 @@ macro_rules! impl_maintenance_tests { use sp_core::H160; use sp_runtime::{traits::Dispatchable, DispatchError}; - pub fn full_name(pallet_name: &[u8], call_name: &[u8]) -> RuntimeCallNameOf { + fn full_name(pallet_name: &[u8], call_name: &[u8]) -> RuntimeCallNameOf { >::from(( pallet_name.to_vec().try_into().unwrap(), call_name.to_vec().try_into().unwrap(), @@ -869,13 +869,12 @@ macro_rules! impl_maintenance_tests { } #[test] - fn tx_pause_origins_work_correctly() { + fn tx_pause_origins_should_work() { ExtBuilder::default().build().execute_with(|| { assert_ok!(TxPause::pause( RuntimeOrigin::root(), full_name(b"Balances", b"transfer") )); - assert_err!( TxPause::pause( RuntimeOrigin::signed(H160::default().into()), @@ -883,62 +882,66 @@ macro_rules! impl_maintenance_tests { ), DispatchError::BadOrigin ); - }) + }); } #[test] - fn tx_pause_pause_and_unpause_work_correctly() { - let from = H160::from_low_u64_be(555).into(); - let to = H160::from_low_u64_be(333).into(); - ExtBuilder::default() - .with_balances(vec![(from, 100), (to, 50)]) - .build() - .execute_with(|| { - assert_ok!(TxPause::pause( - RuntimeOrigin::root(), - full_name(b"System", b"remark") - )); - assert_err!( - RuntimeCall::System(frame_system::Call::remark { - remark: b"hello world".to_vec() - }) - .dispatch(RuntimeOrigin::signed(from)), - frame_system::Error::::CallFiltered - ); + fn tx_pause_pause_and_unpause_should_work() { + let from = H160::from_low_u64_be(0).into(); + let to = H160::from_low_u64_be(1).into(); - assert_ok!(TxPause::unpause( - RuntimeOrigin::root(), - full_name(b"System", b"remark") - )); - assert_ok!(RuntimeCall::System(frame_system::Call::remark { - remark: b"hello world".to_vec(), - }) - .dispatch(RuntimeOrigin::signed(from))); - }) - } - - #[test] - fn tx_pause_pause_calls_except_on_whitelist() { - let from = H160::from_low_u64_be(555).into(); ExtBuilder::default().with_balances(vec![(from, 100)]).build().execute_with(|| { - assert_ok!(RuntimeCall::System(frame_system::Call::remark_with_event { - remark: b"hello world".to_vec(), - }) - .dispatch(RuntimeOrigin::signed(from))); - + assert_ok!(TxPause::pause( + RuntimeOrigin::root(), + full_name(b"Balances", b"transfer") + )); assert_err!( - TxPause::pause( - RuntimeOrigin::root(), - full_name(b"System", b"remark_with_event") - ), - pallet_tx_pause::Error::::Unpausable + RuntimeCall::Balances(pallet_balances::Call::transfer { + dest: to, + value: 1, + }) + .dispatch(RuntimeOrigin::signed(from)), + >::CallFiltered ); - assert_ok!(RuntimeCall::System(frame_system::Call::remark_with_event { - remark: b"hello world".to_vec(), + assert_ok!(TxPause::unpause( + RuntimeOrigin::root(), + full_name(b"Balances", b"transfer") + )); + assert_ok!(RuntimeCall::Balances(pallet_balances::Call::transfer { + dest: to, + value: 1, }) .dispatch(RuntimeOrigin::signed(from))); - }) + }); + } + + #[test] + fn tx_pause_whitelist_should_work() { + ExtBuilder::default().build().execute_with(|| { + let whitelist: &[(&[u8], &[&[u8]])] = &[ + (b"System", &[b"*"]), + (b"ParachainSystem", &[b"*"]), + (b"Timestamp", &[b"*"]), + (b"Session", &[b"*"]), + (b"Scheduler", &[b"*"]), + (b"Preimage", &[b"*"]), + (b"TxPause", &[b"*"]), + (b"TechnicalCommittee", &[b"*"]), + (b"ConvictionVoting", &[b"*"]), + (b"Referenda", &[b"*"]), + (b"Whitelist", &[b"*"]), + ]; + + whitelist.iter().for_each(|(p, cs)| { + cs.iter().for_each(|c| { + assert_err!( + TxPause::pause(RuntimeOrigin::root(), full_name(p, c)), + >::Unpausable + ); + }); + }); + }); } } }; diff --git a/runtime/crab/src/migration.rs b/runtime/crab/src/migration.rs index 9e6cfb561..bdd33d52c 100644 --- a/runtime/crab/src/migration.rs +++ b/runtime/crab/src/migration.rs @@ -41,6 +41,20 @@ impl frame_support::traits::OnRuntimeUpgrade for CustomOnRuntimeUpgrade { } fn migrate() -> frame_support::weights::Weight { + let _ = + migration::clear_storage_prefix(b"MessageGadget", b"CommitmentContract", &[], None, None); + let _ = migration::clear_storage_prefix(b"EcdsaAuthority", b"Authorities", &[], None, None); + let _ = migration::clear_storage_prefix(b"EcdsaAuthority", b"NextAuthorities", &[], None, None); + let _ = migration::clear_storage_prefix(b"EcdsaAuthority", b"Nonce", &[], None, None); + let _ = migration::clear_storage_prefix( + b"EcdsaAuthority", + b"AuthoritiesChangeToSign", + &[], + None, + None, + ); + let _ = + migration::clear_storage_prefix(b"EcdsaAuthority", b"MessageRootToSign", &[], None, None); let _ = migration::clear_storage_prefix(b"Council", b"Proposals", &[], None, None); let _ = migration::clear_storage_prefix(b"Council", b"ProposalOf", &[], None, None); let _ = migration::clear_storage_prefix(b"Council", b"Voting", &[], None, None); diff --git a/runtime/crab/src/pallets/tx_pause.rs b/runtime/crab/src/pallets/tx_pause.rs index 2b6bf92fe..01659e268 100644 --- a/runtime/crab/src/pallets/tx_pause.rs +++ b/runtime/crab/src/pallets/tx_pause.rs @@ -19,15 +19,27 @@ // 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") + let pallet = full_name.0.as_slice(); + + // Pallets that can be paused by the tx-pause pallet. + !matches!( + pallet, + b"Balances" + | b"Assets" | b"Vesting" + | b"Deposit" | b"AccountMigration" + | b"DarwiniaStaking" + | b"Ethereum" | b"EVM" + | b"MessageTransact" + | b"BridgePolkadotGrandpa" + | b"BridgePolkadotParachain" + | b"BridgeDarwiniaMessages" + | b"BridgeDarwiniaDispatch" + | b"DarwiniaFeeMarket" ) } } diff --git a/runtime/darwinia/src/pallets/governance.rs b/runtime/darwinia/src/pallets/governance.rs index 1e91ac5b6..97423043e 100644 --- a/runtime/darwinia/src/pallets/governance.rs +++ b/runtime/darwinia/src/pallets/governance.rs @@ -93,7 +93,7 @@ impl pallet_referenda::Config for Runtime { type SubmitOrigin = frame_system::EnsureSigned; type Tally = pallet_conviction_voting::TallyOf; type Tracks = TracksInfo; - type UndecidingTimeout = ConstU32<{ 14 * DAYS }>; + type UndecidingTimeout = ConstU32<{ 28 * DAYS }>; type Votes = pallet_conviction_voting::VotesOf; // type WeightInfo = weights::pallet_referenda::WeightInfo; type WeightInfo = (); diff --git a/runtime/darwinia/src/pallets/tx_pause.rs b/runtime/darwinia/src/pallets/tx_pause.rs index 2b6bf92fe..01659e268 100644 --- a/runtime/darwinia/src/pallets/tx_pause.rs +++ b/runtime/darwinia/src/pallets/tx_pause.rs @@ -19,15 +19,27 @@ // 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") + let pallet = full_name.0.as_slice(); + + // Pallets that can be paused by the tx-pause pallet. + !matches!( + pallet, + b"Balances" + | b"Assets" | b"Vesting" + | b"Deposit" | b"AccountMigration" + | b"DarwiniaStaking" + | b"Ethereum" | b"EVM" + | b"MessageTransact" + | b"BridgePolkadotGrandpa" + | b"BridgePolkadotParachain" + | b"BridgeDarwiniaMessages" + | b"BridgeDarwiniaDispatch" + | b"DarwiniaFeeMarket" ) } } diff --git a/runtime/pangolin/src/pallets/tx_pause.rs b/runtime/pangolin/src/pallets/tx_pause.rs index 2b6bf92fe..01659e268 100644 --- a/runtime/pangolin/src/pallets/tx_pause.rs +++ b/runtime/pangolin/src/pallets/tx_pause.rs @@ -19,15 +19,27 @@ // 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") + let pallet = full_name.0.as_slice(); + + // Pallets that can be paused by the tx-pause pallet. + !matches!( + pallet, + b"Balances" + | b"Assets" | b"Vesting" + | b"Deposit" | b"AccountMigration" + | b"DarwiniaStaking" + | b"Ethereum" | b"EVM" + | b"MessageTransact" + | b"BridgePolkadotGrandpa" + | b"BridgePolkadotParachain" + | b"BridgeDarwiniaMessages" + | b"BridgeDarwiniaDispatch" + | b"DarwiniaFeeMarket" ) } } diff --git a/runtime/pangoro/src/pallets/tx_pause.rs b/runtime/pangoro/src/pallets/tx_pause.rs index 2b6bf92fe..01659e268 100644 --- a/runtime/pangoro/src/pallets/tx_pause.rs +++ b/runtime/pangoro/src/pallets/tx_pause.rs @@ -19,15 +19,27 @@ // 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") + let pallet = full_name.0.as_slice(); + + // Pallets that can be paused by the tx-pause pallet. + !matches!( + pallet, + b"Balances" + | b"Assets" | b"Vesting" + | b"Deposit" | b"AccountMigration" + | b"DarwiniaStaking" + | b"Ethereum" | b"EVM" + | b"MessageTransact" + | b"BridgePolkadotGrandpa" + | b"BridgePolkadotParachain" + | b"BridgeDarwiniaMessages" + | b"BridgeDarwiniaDispatch" + | b"DarwiniaFeeMarket" ) } }