From 132b582ce3eb24e3ed19c2f8e475cb23e851f2b9 Mon Sep 17 00:00:00 2001 From: b-yap <2826165+b-yap@users.noreply.github.com> Date: Wed, 18 Oct 2023 15:30:57 +0800 Subject: [PATCH 1/4] first iteration --- Cargo.lock | 3 + runtime/amplitude/Cargo.toml | 2 + runtime/amplitude/src/lib.rs | 49 +++++++++++++++- runtime/common/src/lib.rs | 2 + runtime/common/src/proxy_type.rs | 37 ++++++++++++ runtime/foucoco/Cargo.toml | 2 + runtime/foucoco/src/lib.rs | 98 +++++++++++++++++++++++++++++++- runtime/pendulum/Cargo.toml | 2 + runtime/pendulum/src/lib.rs | 50 +++++++++++++++- 9 files changed, 237 insertions(+), 8 deletions(-) create mode 100644 runtime/common/src/proxy_type.rs diff --git a/Cargo.lock b/Cargo.lock index bed0047c3..a51b243a0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -240,6 +240,7 @@ dependencies = [ "pallet-insecure-randomness-collective-flip", "pallet-multisig", "pallet-preimage", + "pallet-proxy", "pallet-scheduler", "pallet-session", "pallet-timestamp", @@ -3050,6 +3051,7 @@ dependencies = [ "pallet-insecure-randomness-collective-flip", "pallet-multisig", "pallet-preimage", + "pallet-proxy", "pallet-scheduler", "pallet-session", "pallet-sudo", @@ -7718,6 +7720,7 @@ dependencies = [ "pallet-insecure-randomness-collective-flip", "pallet-multisig", "pallet-preimage", + "pallet-proxy", "pallet-scheduler", "pallet-session", "pallet-timestamp", diff --git a/runtime/amplitude/Cargo.toml b/runtime/amplitude/Cargo.toml index 29c8d6e56..b5a7e7a92 100644 --- a/runtime/amplitude/Cargo.toml +++ b/runtime/amplitude/Cargo.toml @@ -66,6 +66,7 @@ pallet-democracy = { git = "https://github.com/paritytech/substrate", default-fe pallet-identity = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } pallet-multisig = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } pallet-preimage = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } +pallet-proxy = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } pallet-insecure-randomness-collective-flip = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } pallet-scheduler = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } pallet-session = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } @@ -172,6 +173,7 @@ std = [ "pallet-identity/std", "pallet-multisig/std", "pallet-preimage/std", + "pallet-proxy/std", "pallet-insecure-randomness-collective-flip/std", "pallet-scheduler/std", "pallet-session/std", diff --git a/runtime/amplitude/src/lib.rs b/runtime/amplitude/src/lib.rs index 5f59b69ff..bd8c4ca8e 100644 --- a/runtime/amplitude/src/lib.rs +++ b/runtime/amplitude/src/lib.rs @@ -45,7 +45,7 @@ use frame_support::{ parameter_types, traits::{ ConstBool, ConstU32, Contains, Currency as FrameCurrency, EitherOfDiverse, - EqualPrivilegeOnly, Imbalance, OnUnbalanced, WithdrawReasons, + EqualPrivilegeOnly, Imbalance, InstanceFilter, OnUnbalanced, WithdrawReasons, }, weights::{ constants::WEIGHT_REF_TIME_PER_SECOND, ConstantMultiplier, Weight, WeightToFeeCoefficient, @@ -61,7 +61,7 @@ pub use sp_runtime::{MultiAddress, Perbill, Permill, Perquintill}; use runtime_common::{ asset_registry, opaque, AccountId, Amount, AuraId, Balance, BlockNumber, Hash, Index, PoolId, - ReserveIdentifier, Signature, EXISTENTIAL_DEPOSIT, MILLIUNIT, NANOUNIT, UNIT, + ProxyType, ReserveIdentifier, Signature, EXISTENTIAL_DEPOSIT, MILLIUNIT, NANOUNIT, UNIT, }; use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases; @@ -360,7 +360,8 @@ impl Contains for BaseFilter { RuntimeCall::VaultRegistry(_) | RuntimeCall::VaultRewards(_) | RuntimeCall::Farming(_) | - RuntimeCall::AssetRegistry(_) => true, + RuntimeCall::AssetRegistry(_) | + RuntimeCall::Proxy(_) => true, // All pallets are allowed, but exhaustive match is defensive // in the case of adding new pallets. } @@ -1218,6 +1219,47 @@ impl farming::Config for Runtime { type RewardIssuer = FarmingRewardIssuerPalletId; } +impl InstanceFilter for ProxyType { + fn filter(&self, c: &RuntimeCall) -> bool { + match self { + // Always allowed RuntimeCall::Utility no matter type. + // Only transactions allowed by Proxy.filter can be executed + _ if matches!(c, RuntimeCall::Utility(..)) => true, + ProxyType::Any => true, + } + } + + // Determines whether self matches at least everything that o does. + fn is_superset(&self, _o: &Self) -> bool { + true + } +} + +parameter_types! { + // One storage item; key size 32, value size 8; . + pub const ProxyDepositBase: Balance = deposit(1, 8); + // Additional storage item size of 33 bytes. + pub const ProxyDepositFactor: Balance = deposit(0, 33); + pub const MaxProxies: u16 = 32; + pub const MaxPending: u16 = 32; + pub const AnnouncementDepositBase: Balance = deposit(1, 8); + pub const AnnouncementDepositFactor: Balance = deposit(0, 66); +} + +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 where @@ -1244,6 +1286,7 @@ construct_runtime!( Scheduler: pallet_scheduler::{Pallet, Call, Storage, Event} = 16, Preimage: pallet_preimage::{Pallet, Call, Storage, Event} = 17, Multisig: pallet_multisig::{Pallet, Call, Storage, Event} = 18, + Proxy: pallet_proxy::{Pallet, Call, Storage, Event} = 92, Treasury: pallet_treasury::{Pallet, Call, Storage, Event} = 19, Bounties: pallet_bounties::{Pallet, Call, Storage, Event} = 20, ChildBounties: pallet_child_bounties::{Pallet, Call, Storage, Event} = 21, diff --git a/runtime/common/src/lib.rs b/runtime/common/src/lib.rs index 5ab947c1c..1f166a17e 100644 --- a/runtime/common/src/lib.rs +++ b/runtime/common/src/lib.rs @@ -7,6 +7,7 @@ use sp_runtime::{ pub mod asset_registry; pub mod chain_ext; +mod proxy_type; pub mod stellar; pub mod zenlink; @@ -23,6 +24,7 @@ pub type AccountId = <::Signer as IdentifyAccount>::Account /// Type for IDs of farming pools pub type PoolId = u32; +pub use proxy_type::*; pub use sp_consensus_aura::sr25519::AuthorityId as AuraId; /// Balance of an account. diff --git a/runtime/common/src/proxy_type.rs b/runtime/common/src/proxy_type.rs new file mode 100644 index 000000000..ae4d8607f --- /dev/null +++ b/runtime/common/src/proxy_type.rs @@ -0,0 +1,37 @@ +use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; +use sp_runtime::RuntimeDebug; +/// 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 { + /// Allows all runtime calls for proxy account + Any, + // /// Allows only NonTransfer runtime calls for proxy account + // /// To know exact calls check InstanceFilter inmplementation for ProxyTypes + // NonTransfer, + // /// All Runtime calls from Pallet Balances allowed for proxy account + // Balances, + // /// Only provide_judgement call from pallet identity allowed for proxy account + // IdentityJudgement, + // /// Only reject_announcement call from pallet proxy allowed for proxy account + // CancelProxy, + // /// Only claim_reward call from pallet staking is allowed for proxy account + // StakerRewardClaim, +} + +impl Default for ProxyType { + fn default() -> Self { + Self::Any + } +} diff --git a/runtime/foucoco/Cargo.toml b/runtime/foucoco/Cargo.toml index 50b796bfd..717cfa95d 100644 --- a/runtime/foucoco/Cargo.toml +++ b/runtime/foucoco/Cargo.toml @@ -67,6 +67,7 @@ pallet-democracy = { git = "https://github.com/paritytech/substrate", default-fe pallet-identity = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } pallet-multisig = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } pallet-preimage = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } +pallet-proxy = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } pallet-insecure-randomness-collective-flip = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } pallet-scheduler = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } pallet-session = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } @@ -174,6 +175,7 @@ std = [ "pallet-identity/std", "pallet-multisig/std", "pallet-preimage/std", + "pallet-proxy/std", "pallet-insecure-randomness-collective-flip/std", "pallet-scheduler/std", "pallet-session/std", diff --git a/runtime/foucoco/src/lib.rs b/runtime/foucoco/src/lib.rs index 375668f3d..3af23e7c9 100644 --- a/runtime/foucoco/src/lib.rs +++ b/runtime/foucoco/src/lib.rs @@ -106,6 +106,7 @@ use orml_currencies_allowance_extension::{ use frame_support::{ log::{error, warn}, pallet_prelude::*, + traits::InstanceFilter, }; use sp_std::vec::Vec; @@ -371,7 +372,8 @@ impl Contains for BaseFilter { RuntimeCall::VaultRewards(_) | RuntimeCall::Farming(_) | RuntimeCall::TokenAllowance(_) | - RuntimeCall::AssetRegistry(_) => true, + RuntimeCall::AssetRegistry(_) | + RuntimeCall::Proxy(_) => true, // All pallets are allowed, but exhaustive match is defensive // in the case of adding new pallets. } @@ -953,7 +955,8 @@ parameter_types! { #[derive(Default)] pub struct Psp22Extension; -use runtime_common::chain_ext::*; +use runtime_common::{chain_ext::*, ProxyType}; + pub(crate) type BalanceOfForChainExt = <::MultiCurrency as orml_traits::MultiCurrency< ::AccountId, @@ -1510,6 +1513,96 @@ impl clients_info::Config for Runtime { type MaxUriLength = ConstU32<255>; } +impl InstanceFilter for ProxyType { + fn filter(&self, c: &RuntimeCall) -> bool { + match self { + // Always allowed RuntimeCall::Utility no matter type. + // Only transactions allowed by Proxy.filter can be executed + _ if matches!(c, RuntimeCall::Utility(..)) => true, + ProxyType::Any => true, + // ProxyType::NonTransfer => { + // matches!( + // c, + // RuntimeCall::System(..) + // | RuntimeCall::Identity(..) + // | RuntimeCall::Timestamp(..) + // | RuntimeCall::Multisig(..) + // | RuntimeCall::Proxy(..) + // | RuntimeCall::ParachainSystem(..) + // | RuntimeCall::ParachainInfo(..) + // // Skip entire Balances pallet + // | RuntimeCall::Vesting(pallet_vesting::Call::vest{..}) + // | RuntimeCall::Vesting(pallet_vesting::Call::vest_other{..}) + // // Specifically omitting Vesting `vested_transfer`, and `force_vested_transfer` + // | RuntimeCall::Session(..) + // | RuntimeCall::XcmpQueue(..) + // | RuntimeCall::PolkadotXcm(..) + // | RuntimeCall::DmpQueue(..) + // ) + // } + // ProxyType::Balances => { + // matches!(c, RuntimeCall::Balances(..)) + // } + // ProxyType::IdentityJudgement => { + // matches!( + // c, + // RuntimeCall::Identity(pallet_identity::Call::provide_judgement { .. }) + // ) + // } + // ProxyType::CancelProxy => { + // matches!( + // c, + // RuntimeCall::Proxy(pallet_proxy::Call::reject_announcement { .. }) + // ) + // } + // ProxyType::StakerRewardClaim => { + // matches!( + // c, + // RuntimeCall::DappsStaking(parachain_staking::Call::claim_rewards { .. }) + // ) + // } + } + } + + // Determines whether self matches at least everything that o does. + fn is_superset(&self, _o: &Self) -> bool { + true + // match (self, o) { + // (x, y) if x == y => true, + // (ProxyType::Any, _) => true, + // (_, ProxyType::Any) => false, + // (_, ProxyType::StakerRewardClaim) => true, + // _ => false, + // } + } +} + +parameter_types! { + // One storage item; key size 32, value size 8; . + pub const ProxyDepositBase: Balance = deposit(1, 8); + // Additional storage item size of 33 bytes. + pub const ProxyDepositFactor: Balance = deposit(0, 33); + pub const MaxProxies: u16 = 32; + pub const MaxPending: u16 = 32; + pub const AnnouncementDepositBase: Balance = deposit(1, 8); + pub const AnnouncementDepositFactor: Balance = deposit(0, 66); +} + +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; +} + impl frame_system::offchain::SendTransactionTypes for Runtime where RuntimeCall: From, @@ -1545,6 +1638,7 @@ construct_runtime!( Scheduler: pallet_scheduler::{Pallet, Call, Storage, Event} = 16, Preimage: pallet_preimage::{Pallet, Call, Storage, Event} = 17, Multisig: pallet_multisig::{Pallet, Call, Storage, Event} = 18, + Proxy: pallet_proxy::{Pallet, Call, Storage, Event} = 92, Treasury: pallet_treasury::{Pallet, Call, Storage, Event} = 19, Bounties: pallet_bounties::{Pallet, Call, Storage, Event} = 20, ChildBounties: pallet_child_bounties::{Pallet, Call, Storage, Event} = 21, diff --git a/runtime/pendulum/Cargo.toml b/runtime/pendulum/Cargo.toml index 7b73ee77e..5a58e19f0 100644 --- a/runtime/pendulum/Cargo.toml +++ b/runtime/pendulum/Cargo.toml @@ -48,6 +48,7 @@ pallet-democracy = {git = "https://github.com/paritytech/substrate", default-fea pallet-identity = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40"} pallet-multisig = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40"} pallet-preimage = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40"} +pallet-proxy = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40"} pallet-insecure-randomness-collective-flip = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40"} pallet-scheduler = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40"} pallet-session = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40"} @@ -152,6 +153,7 @@ std = [ "pallet-identity/std", "pallet-multisig/std", "pallet-preimage/std", + "pallet-proxy/std", "pallet-insecure-randomness-collective-flip/std", "pallet-scheduler/std", "pallet-session/std", diff --git a/runtime/pendulum/src/lib.rs b/runtime/pendulum/src/lib.rs index 6e9ade8f9..fd68555ea 100644 --- a/runtime/pendulum/src/lib.rs +++ b/runtime/pendulum/src/lib.rs @@ -40,7 +40,7 @@ use frame_support::{ parameter_types, traits::{ ConstBool, ConstU32, Contains, Currency, EitherOfDiverse, EqualPrivilegeOnly, Imbalance, - OnUnbalanced, WithdrawReasons, + InstanceFilter, OnUnbalanced, WithdrawReasons, }, weights::{ constants::WEIGHT_REF_TIME_PER_SECOND, ConstantMultiplier, Weight, WeightToFeeCoefficient, @@ -56,7 +56,7 @@ pub use sp_runtime::{traits::AccountIdConversion, MultiAddress, Perbill, Permill use runtime_common::{ asset_registry, opaque, AccountId, Amount, AuraId, Balance, BlockNumber, Hash, Index, - ReserveIdentifier, Signature, EXISTENTIAL_DEPOSIT, MILLIUNIT, NANOUNIT, UNIT, + ProxyType, ReserveIdentifier, Signature, EXISTENTIAL_DEPOSIT, MILLIUNIT, NANOUNIT, UNIT, }; use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases; @@ -269,7 +269,8 @@ impl Contains for BaseFilter { RuntimeCall::ZenlinkProtocol(_) | RuntimeCall::DiaOracleModule(_) | RuntimeCall::VestingManager(_) | - RuntimeCall::AssetRegistry(_) => true, + RuntimeCall::AssetRegistry(_) | + RuntimeCall::Proxy(_) => true, // All pallets are allowed, but exhaustive match is defensive // in the case of adding new pallets. } @@ -953,6 +954,48 @@ where } } +impl InstanceFilter for ProxyType { + fn filter(&self, c: &RuntimeCall) -> bool { + match self { + // Always allowed RuntimeCall::Utility no matter type. + // Only transactions allowed by Proxy.filter can be executed + _ if matches!(c, RuntimeCall::Utility(..)) => true, + ProxyType::Any => true, + } + } + + // Determines whether self matches at least everything that o does. + fn is_superset(&self, _o: &Self) -> bool { + true + } +} + +parameter_types! { + // One storage item; key size 32, value size 8; . + pub const ProxyDepositBase: Balance = deposit(1, 8); + // Additional storage item size of 33 bytes. + pub const ProxyDepositFactor: Balance = deposit(0, 33); + pub const MaxProxies: u16 = 32; + pub const MaxPending: u16 = 32; + pub const AnnouncementDepositBase: Balance = deposit(1, 8); + pub const AnnouncementDepositFactor: Balance = deposit(0, 66); +} + +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 where @@ -979,6 +1022,7 @@ construct_runtime!( Scheduler: pallet_scheduler::{Pallet, Call, Storage, Event} = 16, Preimage: pallet_preimage::{Pallet, Call, Storage, Event} = 17, Multisig: pallet_multisig::{Pallet, Call, Storage, Event} = 18, + Proxy: pallet_proxy::{Pallet, Call, Storage, Event} = 92, Treasury: pallet_treasury::{Pallet, Call, Storage, Event} = 19, Bounties: pallet_bounties::{Pallet, Call, Storage, Event} = 20, ChildBounties: pallet_child_bounties::{Pallet, Call, Storage, Event} = 21, From 2acb3abae31d93a8dc92525f39140219ef5e7d70 Mon Sep 17 00:00:00 2001 From: b-yap <2826165+b-yap@users.noreply.github.com> Date: Mon, 6 Nov 2023 22:30:01 +0800 Subject: [PATCH 2/4] https://github.com/pendulum-chain/pendulum/pull/325#discussion_r1374834036, https://github.com/pendulum-chain/pendulum/pull/325#discussion_r1374835562, --- runtime/amplitude/src/lib.rs | 9 +++-- runtime/common/src/proxy_type.rs | 11 ------ runtime/foucoco/src/lib.rs | 59 +++++--------------------------- runtime/pendulum/src/lib.rs | 9 +++-- 4 files changed, 22 insertions(+), 66 deletions(-) diff --git a/runtime/amplitude/src/lib.rs b/runtime/amplitude/src/lib.rs index bd8c4ca8e..157ddfa37 100644 --- a/runtime/amplitude/src/lib.rs +++ b/runtime/amplitude/src/lib.rs @@ -1230,8 +1230,13 @@ impl InstanceFilter for ProxyType { } // Determines whether self matches at least everything that o does. - fn is_superset(&self, _o: &Self) -> bool { - true + fn is_superset(&self, o: &Self) -> bool { + match (self, o) { + (x, y) if x == y => true, + (ProxyType::Any, _) => true, + (_, ProxyType::Any) => false, + _ => false, + } } } diff --git a/runtime/common/src/proxy_type.rs b/runtime/common/src/proxy_type.rs index ae4d8607f..f7beeea23 100644 --- a/runtime/common/src/proxy_type.rs +++ b/runtime/common/src/proxy_type.rs @@ -17,17 +17,6 @@ use sp_runtime::RuntimeDebug; pub enum ProxyType { /// Allows all runtime calls for proxy account Any, - // /// Allows only NonTransfer runtime calls for proxy account - // /// To know exact calls check InstanceFilter inmplementation for ProxyTypes - // NonTransfer, - // /// All Runtime calls from Pallet Balances allowed for proxy account - // Balances, - // /// Only provide_judgement call from pallet identity allowed for proxy account - // IdentityJudgement, - // /// Only reject_announcement call from pallet proxy allowed for proxy account - // CancelProxy, - // /// Only claim_reward call from pallet staking is allowed for proxy account - // StakerRewardClaim, } impl Default for ProxyType { diff --git a/runtime/foucoco/src/lib.rs b/runtime/foucoco/src/lib.rs index 3af23e7c9..c128a7582 100644 --- a/runtime/foucoco/src/lib.rs +++ b/runtime/foucoco/src/lib.rs @@ -1519,61 +1519,18 @@ impl InstanceFilter for ProxyType { // Always allowed RuntimeCall::Utility no matter type. // Only transactions allowed by Proxy.filter can be executed _ if matches!(c, RuntimeCall::Utility(..)) => true, - ProxyType::Any => true, - // ProxyType::NonTransfer => { - // matches!( - // c, - // RuntimeCall::System(..) - // | RuntimeCall::Identity(..) - // | RuntimeCall::Timestamp(..) - // | RuntimeCall::Multisig(..) - // | RuntimeCall::Proxy(..) - // | RuntimeCall::ParachainSystem(..) - // | RuntimeCall::ParachainInfo(..) - // // Skip entire Balances pallet - // | RuntimeCall::Vesting(pallet_vesting::Call::vest{..}) - // | RuntimeCall::Vesting(pallet_vesting::Call::vest_other{..}) - // // Specifically omitting Vesting `vested_transfer`, and `force_vested_transfer` - // | RuntimeCall::Session(..) - // | RuntimeCall::XcmpQueue(..) - // | RuntimeCall::PolkadotXcm(..) - // | RuntimeCall::DmpQueue(..) - // ) - // } - // ProxyType::Balances => { - // matches!(c, RuntimeCall::Balances(..)) - // } - // ProxyType::IdentityJudgement => { - // matches!( - // c, - // RuntimeCall::Identity(pallet_identity::Call::provide_judgement { .. }) - // ) - // } - // ProxyType::CancelProxy => { - // matches!( - // c, - // RuntimeCall::Proxy(pallet_proxy::Call::reject_announcement { .. }) - // ) - // } - // ProxyType::StakerRewardClaim => { - // matches!( - // c, - // RuntimeCall::DappsStaking(parachain_staking::Call::claim_rewards { .. }) - // ) - // } + ProxyType::Any => true } } // Determines whether self matches at least everything that o does. - fn is_superset(&self, _o: &Self) -> bool { - true - // match (self, o) { - // (x, y) if x == y => true, - // (ProxyType::Any, _) => true, - // (_, ProxyType::Any) => false, - // (_, ProxyType::StakerRewardClaim) => true, - // _ => false, - // } + fn is_superset(&self, o: &Self) -> bool { + match (self, o) { + (x, y) if x == y => true, + (ProxyType::Any, _) => true, + (_, ProxyType::Any) => false, + _ => false, + } } } diff --git a/runtime/pendulum/src/lib.rs b/runtime/pendulum/src/lib.rs index fd68555ea..d8db73a48 100644 --- a/runtime/pendulum/src/lib.rs +++ b/runtime/pendulum/src/lib.rs @@ -965,8 +965,13 @@ impl InstanceFilter for ProxyType { } // Determines whether self matches at least everything that o does. - fn is_superset(&self, _o: &Self) -> bool { - true + fn is_superset(&self, o: &Self) -> bool { + match (self, o) { + (x, y) if x == y => true, + (ProxyType::Any, _) => true, + (_, ProxyType::Any) => false, + _ => false, + } } } From f449c090a4e79807dc48008bf61fe6b2c34da055 Mon Sep 17 00:00:00 2001 From: b-yap <2826165+b-yap@users.noreply.github.com> Date: Wed, 8 Nov 2023 17:03:25 +0800 Subject: [PATCH 3/4] https://github.com/pendulum-chain/pendulum/pull/325#discussion_r1383334089 --- runtime/amplitude/src/lib.rs | 2 +- runtime/foucoco/src/lib.rs | 2 +- runtime/pendulum/src/lib.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/runtime/amplitude/src/lib.rs b/runtime/amplitude/src/lib.rs index 157ddfa37..5b1c8f293 100644 --- a/runtime/amplitude/src/lib.rs +++ b/runtime/amplitude/src/lib.rs @@ -1291,10 +1291,10 @@ construct_runtime!( Scheduler: pallet_scheduler::{Pallet, Call, Storage, Event} = 16, Preimage: pallet_preimage::{Pallet, Call, Storage, Event} = 17, Multisig: pallet_multisig::{Pallet, Call, Storage, Event} = 18, - Proxy: pallet_proxy::{Pallet, Call, Storage, Event} = 92, Treasury: pallet_treasury::{Pallet, Call, Storage, Event} = 19, Bounties: pallet_bounties::{Pallet, Call, Storage, Event} = 20, ChildBounties: pallet_child_bounties::{Pallet, Call, Storage, Event} = 21, + Proxy: pallet_proxy::{Pallet, Call, Storage, Event} = 81, // Consensus support. // The following order MUST NOT be changed: Aura -> Session -> Staking -> Authorship -> AuraExt diff --git a/runtime/foucoco/src/lib.rs b/runtime/foucoco/src/lib.rs index c128a7582..791df5814 100644 --- a/runtime/foucoco/src/lib.rs +++ b/runtime/foucoco/src/lib.rs @@ -1595,10 +1595,10 @@ construct_runtime!( Scheduler: pallet_scheduler::{Pallet, Call, Storage, Event} = 16, Preimage: pallet_preimage::{Pallet, Call, Storage, Event} = 17, Multisig: pallet_multisig::{Pallet, Call, Storage, Event} = 18, - Proxy: pallet_proxy::{Pallet, Call, Storage, Event} = 92, Treasury: pallet_treasury::{Pallet, Call, Storage, Event} = 19, Bounties: pallet_bounties::{Pallet, Call, Storage, Event} = 20, ChildBounties: pallet_child_bounties::{Pallet, Call, Storage, Event} = 21, + Proxy: pallet_proxy::{Pallet, Call, Storage, Event} = 81, // Consensus support. // The following order MUST NOT be changed: Aura -> Session -> Staking -> Authorship -> AuraExt diff --git a/runtime/pendulum/src/lib.rs b/runtime/pendulum/src/lib.rs index d8db73a48..0c4483569 100644 --- a/runtime/pendulum/src/lib.rs +++ b/runtime/pendulum/src/lib.rs @@ -1027,10 +1027,10 @@ construct_runtime!( Scheduler: pallet_scheduler::{Pallet, Call, Storage, Event} = 16, Preimage: pallet_preimage::{Pallet, Call, Storage, Event} = 17, Multisig: pallet_multisig::{Pallet, Call, Storage, Event} = 18, - Proxy: pallet_proxy::{Pallet, Call, Storage, Event} = 92, Treasury: pallet_treasury::{Pallet, Call, Storage, Event} = 19, Bounties: pallet_bounties::{Pallet, Call, Storage, Event} = 20, ChildBounties: pallet_child_bounties::{Pallet, Call, Storage, Event} = 21, + Proxy: pallet_proxy::{Pallet, Call, Storage, Event} = 81, // Consensus support. // The following order MUST NOT be changed: Aura -> Session -> Staking -> Authorship -> AuraExt From 04bca97b29bb3ccc4f84273725253ce55d6a3886 Mon Sep 17 00:00:00 2001 From: b-yap <2826165+b-yap@users.noreply.github.com> Date: Fri, 10 Nov 2023 14:16:38 +0800 Subject: [PATCH 4/4] https://github.com/pendulum-chain/pendulum/pull/325#discussion_r1388178575 --- runtime/amplitude/src/lib.rs | 2 +- runtime/foucoco/src/lib.rs | 2 +- runtime/pendulum/src/lib.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/runtime/amplitude/src/lib.rs b/runtime/amplitude/src/lib.rs index 5b1c8f293..ae1f7c2f3 100644 --- a/runtime/amplitude/src/lib.rs +++ b/runtime/amplitude/src/lib.rs @@ -1294,7 +1294,7 @@ construct_runtime!( Treasury: pallet_treasury::{Pallet, Call, Storage, Event} = 19, Bounties: pallet_bounties::{Pallet, Call, Storage, Event} = 20, ChildBounties: pallet_child_bounties::{Pallet, Call, Storage, Event} = 21, - Proxy: pallet_proxy::{Pallet, Call, Storage, Event} = 81, + Proxy: pallet_proxy::{Pallet, Call, Storage, Event} = 22, // Consensus support. // The following order MUST NOT be changed: Aura -> Session -> Staking -> Authorship -> AuraExt diff --git a/runtime/foucoco/src/lib.rs b/runtime/foucoco/src/lib.rs index 791df5814..46b7c3211 100644 --- a/runtime/foucoco/src/lib.rs +++ b/runtime/foucoco/src/lib.rs @@ -1598,7 +1598,7 @@ construct_runtime!( Treasury: pallet_treasury::{Pallet, Call, Storage, Event} = 19, Bounties: pallet_bounties::{Pallet, Call, Storage, Event} = 20, ChildBounties: pallet_child_bounties::{Pallet, Call, Storage, Event} = 21, - Proxy: pallet_proxy::{Pallet, Call, Storage, Event} = 81, + Proxy: pallet_proxy::{Pallet, Call, Storage, Event} = 22, // Consensus support. // The following order MUST NOT be changed: Aura -> Session -> Staking -> Authorship -> AuraExt diff --git a/runtime/pendulum/src/lib.rs b/runtime/pendulum/src/lib.rs index 0c4483569..2b86a70f1 100644 --- a/runtime/pendulum/src/lib.rs +++ b/runtime/pendulum/src/lib.rs @@ -1030,7 +1030,7 @@ construct_runtime!( Treasury: pallet_treasury::{Pallet, Call, Storage, Event} = 19, Bounties: pallet_bounties::{Pallet, Call, Storage, Event} = 20, ChildBounties: pallet_child_bounties::{Pallet, Call, Storage, Event} = 21, - Proxy: pallet_proxy::{Pallet, Call, Storage, Event} = 81, + Proxy: pallet_proxy::{Pallet, Call, Storage, Event} = 22, // Consensus support. // The following order MUST NOT be changed: Aura -> Session -> Staking -> Authorship -> AuraExt