diff --git a/Cargo.lock b/Cargo.lock index 65210fb2..7f4e00b2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9373,6 +9373,8 @@ dependencies = [ "pallet-ismp-runtime-api", "pallet-message-queue", "pallet-regions", + "pallet-multisig", + "pallet-proxy", "pallet-session", "pallet-sudo", "pallet-timestamp", diff --git a/Cargo.toml b/Cargo.toml index 64037787..1d374540 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -51,6 +51,9 @@ pallet-transaction-payment = { version = "28.0.0", default-features = false } pallet-transaction-payment-rpc-runtime-api = { version = "28.0.0", default-features = false } pallet-utility = { version = "28.0.0", default-features = false} pallet-message-queue = { version = "31.0.0", default-features = false } +pallet-multisig = { version = "28.0.0", default-features = false } +pallet-proxy = { version = "28.0.0", default-features = false } +pallet-utility = { version = "28.0.0", default-features = false } sp-api = { version = "26.0.0", default-features = false } sp-blockchain = { version = "28.0.0", default-features = false } sp-io = { version = "30.0.0", default-features = false } diff --git a/runtime/regionx/Cargo.toml b/runtime/regionx/Cargo.toml index 71a31879..7e5a6afe 100644 --- a/runtime/regionx/Cargo.toml +++ b/runtime/regionx/Cargo.toml @@ -47,6 +47,8 @@ pallet-aura = { workspace = true } pallet-authorship = { workspace = true } pallet-balances = { workspace = true } pallet-message-queue = { workspace = true } +pallet-multisig = { workspace = true } +pallet-proxy = { workspace = true } pallet-session = { workspace = true } pallet-sudo = { workspace = true } pallet-timestamp = { workspace = true } @@ -122,8 +124,11 @@ std = [ "pallet-message-queue/std", "pallet-regions/std", "regionx-primitives/std", + "pallet-multisig/std", + "pallet-proxy/std", "pallet-session/std", "pallet-sudo/std", + "pallet-utility/std", "pallet-timestamp/std", "pallet-transaction-payment-rpc-runtime-api/std", "pallet-transaction-payment/std", @@ -170,7 +175,10 @@ runtime-benchmarks = [ "pallet-collator-selection/runtime-benchmarks", "pallet-message-queue/runtime-benchmarks", "pallet-regions/runtime-benchmarks", + "pallet-multisig/runtime-benchmarks", + "pallet-proxy/runtime-benchmarks", "pallet-sudo/runtime-benchmarks", + "pallet-utility/runtime-benchmarks", "pallet-timestamp/runtime-benchmarks", "pallet-utility/runtime-benchmarks", "pallet-xcm/runtime-benchmarks", @@ -202,8 +210,11 @@ try-runtime = [ "pallet-collator-selection/try-runtime", "pallet-message-queue/try-runtime", "pallet-regions/try-runtime", + "pallet-multisig/try-runtime", + "pallet-proxy/try-runtime", "pallet-session/try-runtime", "pallet-sudo/try-runtime", + "pallet-utility/try-runtime", "pallet-timestamp/try-runtime", "pallet-transaction-payment/try-runtime", "pallet-utility/try-runtime", diff --git a/runtime/regionx/src/impls.rs b/runtime/regionx/src/impls.rs index 55f0edca..a9ef7f6b 100644 --- a/runtime/regionx/src/impls.rs +++ b/runtime/regionx/src/impls.rs @@ -1,9 +1,10 @@ -use crate::{AssetId, Runtime}; +use crate::{AssetId, Runtime, RuntimeCall}; +use frame_support::traits::InstanceFilter; use orml_asset_registry::DefaultAssetMetadata; use orml_traits::asset_registry::AssetProcessor; use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; -use sp_runtime::DispatchError; +use sp_runtime::{DispatchError, RuntimeDebug}; #[derive( Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Debug, Encode, Decode, TypeInfo, MaxEncodedLen, @@ -28,3 +29,45 @@ impl AssetProcessor> for CustomAssetProce Ok(()) } } + +/// The type used to represent the kinds of proxying allowed. +#[derive( + Copy, + Clone, + Eq, + PartialEq, + Ord, + PartialOrd, + Encode, + Decode, + RuntimeDebug, + MaxEncodedLen, + scale_info::TypeInfo, +)] +pub enum ProxyType { + /// Fully permissioned proxy. Can execute any call on behalf of _proxied_. + Any, + /// Can execute any call that does not transfer funds or assets. + NonTransfer, + /// Proxy with the ability to reject time-delay proxy announcements. + CancelProxy, + // TODO: add more proxies in future related to coretime trading. +} + +impl Default for ProxyType { + fn default() -> Self { + Self::Any + } +} + +impl InstanceFilter for ProxyType { + fn filter(&self, c: &RuntimeCall) -> bool { + match self { + ProxyType::Any => true, + ProxyType::NonTransfer => + !matches!(c, RuntimeCall::Balances { .. } | RuntimeCall::Assets { .. }), + ProxyType::CancelProxy => + matches!(c, RuntimeCall::Proxy(pallet_proxy::Call::reject_announcement { .. })), + } + } +} diff --git a/runtime/regionx/src/lib.rs b/runtime/regionx/src/lib.rs index f0ef5053..39c45a60 100644 --- a/runtime/regionx/src/lib.rs +++ b/runtime/regionx/src/lib.rs @@ -586,6 +586,51 @@ impl pallet_regions::Config for Runtime { type Timeout = ConstU64<1000>; // TODO: FIXME } +parameter_types! { + // One storage item; key size is 32; value is size 4+4+16+32 bytes = 56 bytes. + pub const DepositBase: Balance = deposit(1, 88); + // Additional storage item size of 32 bytes. + pub const DepositFactor: Balance = deposit(0, 32); + pub const MaxSignatories: u32 = 100; +} + +impl pallet_multisig::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type RuntimeCall = RuntimeCall; + type Currency = Balances; + type DepositBase = DepositBase; + type DepositFactor = DepositFactor; + type MaxSignatories = MaxSignatories; + type WeightInfo = pallet_multisig::weights::SubstrateWeight; +} + +parameter_types! { + // One storage item; key size 32, value size 8; . + pub const ProxyDepositBase: Balance = deposit(1, 40); + // Additional storage item size of 33 bytes. + pub const ProxyDepositFactor: Balance = deposit(0, 33); + pub const MaxProxies: u16 = 32; + // One storage item; key size 32, value size 16 + pub const AnnouncementDepositBase: Balance = deposit(1, 48); + pub const AnnouncementDepositFactor: Balance = deposit(0, 66); + pub const MaxPending: u16 = 32; +} + +impl pallet_proxy::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type RuntimeCall = RuntimeCall; + type Currency = Balances; + type ProxyType = ProxyType; + type ProxyDepositBase = ProxyDepositBase; + type ProxyDepositFactor = ProxyDepositFactor; + type MaxProxies = MaxProxies; + type WeightInfo = pallet_proxy::weights::SubstrateWeight; + type MaxPending = MaxPending; + type CallHasher = BlakeTwo256; + type AnnouncementDepositBase = AnnouncementDepositBase; + type AnnouncementDepositFactor = AnnouncementDepositFactor; +} + // Create the runtime by composing the FRAME pallets that were previously configured. construct_runtime!( pub enum Runtime @@ -613,18 +658,23 @@ construct_runtime!( Aura: pallet_aura = 33, AuraExt: cumulus_pallet_aura_ext = 34, + // Handy utilities + Utility: pallet_utility = 40, + Multisig: pallet_multisig = 41, + Proxy: pallet_proxy = 42, + // XCM helpers. - XcmpQueue: cumulus_pallet_xcmp_queue = 40, - PolkadotXcm: pallet_xcm = 41, - CumulusXcm: cumulus_pallet_xcm = 42, - MessageQueue: pallet_message_queue = 43, + XcmpQueue: cumulus_pallet_xcmp_queue = 50, + PolkadotXcm: pallet_xcm = 51, + CumulusXcm: cumulus_pallet_xcm = 52, + MessageQueue: pallet_message_queue = 53, // ISMP - Ismp: pallet_ismp = 50, - IsmpParachain: ismp_parachain = 51, + Ismp: pallet_ismp = 60, + IsmpParachain: ismp_parachain = 61, // Main stage: - Regions: pallet_regions = 60, + Regions: pallet_regions = 70, } ); @@ -635,6 +685,9 @@ mod benches { [pallet_assets, Assets] [pallet_balances, Balances] [pallet_session, SessionBench::] + [pallet_multisig, Multisig] + [pallet_proxy, Proxy] + [pallet_timestamp, Utility] [pallet_timestamp, Timestamp] [pallet_utility, Utility], [pallet_sudo, Sudo]