Skip to content

Commit

Permalink
Integrate SafeMode and TxPause updates for Shibuya runtime
Browse files Browse the repository at this point in the history
- Added `SafeModeTxPauseFilter` combining SafeMode and TxPause whitelisted calls.
- Updated `BaseCallFilter` to include the combined filter for comprehensive runtime restrictions.
- Reordered pallet indices in `construct_runtime!` for SafeMode and TxPause (SafeMode now precedes TxPause).
- Implemented `TxPauseWhitelistedCalls` to allow specific calls to bypass TxPause restrictions (e.g., Sudo, System, Timestamp).
- Updated `SafeModeWhitelistedCalls` to include `Sudo`.
- Extended `MaxNameLen` from 32 to 256 in TxPause configuration.

Addresses comments on runtime configurations and ensures correct integration of SafeMode and TxPause functionalities.
  • Loading branch information
sylvaincormier committed Nov 8, 2024
1 parent 55f56f3 commit 279b81b
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions runtime/shibuya/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ use chain_extensions::ShibuyaChainExtensions;
use frame_system::EnsureRootWithSuccess;
use pallet_safe_mode;
use pallet_tx_pause;
type SafeModeTxPauseFilter = InsideBoth<SafeModeWhitelistedCalls, TxPauseWhitelistedCalls>;
type BaseCallFilter = InsideBoth<BaseFilter, SafeModeTxPauseFilter>;
use frame_support::traits::InsideBoth;

/// Constant values used within the runtime.
pub const MICROSBY: Balance = 1_000_000_000_000;
Expand Down Expand Up @@ -1618,8 +1621,9 @@ construct_runtime!(
CollectiveProxy: pallet_collective_proxy = 109,

MultiBlockMigrations: pallet_migrations = 120,
TxPause: pallet_tx_pause = 200,
SafeMode: pallet_safe_mode = 201,
SafeMode: pallet_safe_mode = 130,
TxPause: pallet_tx_pause = 131,


#[cfg(feature = "runtime-benchmarks")]
VestingMBM: vesting_mbm = 250,
Expand Down Expand Up @@ -1685,12 +1689,26 @@ parameter_types! {
pub const ReleaseDelay: u32 = 2 * DAYS;
}

pub struct TxPauseWhitelistedCalls;
impl Contains<pallet_tx_pause::RuntimeCallNameOf<Runtime>> for TxPauseWhitelistedCalls {
fn contains(full_name: &pallet_tx_pause::RuntimeCallNameOf<Runtime>) -> bool {
matches!(
full_name.0.as_slice(),
b"Sudo" | b"System" | b"Timestamp" | b"TxPause"
)
}
}
pub struct SafeModeWhitelistedCalls;
impl Contains<RuntimeCall> for SafeModeWhitelistedCalls {
fn contains(call: &RuntimeCall) -> bool {
match call {
RuntimeCall::System(_) | RuntimeCall::SafeMode(_) | RuntimeCall::TxPause(_) => true,
_ => false,
RuntimeCall::System(_)
| RuntimeCall::SafeMode(_)
| RuntimeCall::TxPause(_)
| RuntimeCall::Sudo(_) => true,
_ => false,
}
}
}
Expand Down Expand Up @@ -1719,7 +1737,7 @@ impl pallet_tx_pause::Config for Runtime {
type PauseOrigin = EnsureRoot<AccountId>; // Authority required to pause transactions.
type UnpauseOrigin = EnsureRoot<AccountId>; // Authority required to unpause transactions.
type WhitelistedCalls = ();
type MaxNameLen = ConstU32<32>; // Maximum length of name, adjust as needed.
type MaxNameLen = ConstU32<256>; // Maximum length of name, adjust as needed.
type WeightInfo = pallet_tx_pause::weights::SubstrateWeight<Runtime>; // Weight information.
}

Expand Down

0 comments on commit 279b81b

Please sign in to comment.