diff --git a/Cargo.lock b/Cargo.lock index d2db65ae8e..77e485aa08 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -201,6 +201,7 @@ dependencies = [ "pallet-collective", "pallet-democracy", "pallet-elections-phragmen", + "pallet-identity", "pallet-indices", "pallet-membership", "pallet-multisig", @@ -860,9 +861,11 @@ dependencies = [ "pallet-collective", "pallet-democracy", "pallet-elections-phragmen", + "pallet-identity", "pallet-indices", "pallet-membership", "pallet-multisig", + "pallet-proxy", "pallet-randomness-collective-flip", "pallet-scheduler", "pallet-session", diff --git a/runtime/asgard/Cargo.toml b/runtime/asgard/Cargo.toml index 43a878c2cd..56abb9a7f9 100644 --- a/runtime/asgard/Cargo.toml +++ b/runtime/asgard/Cargo.toml @@ -45,6 +45,7 @@ pallet-bounties = { git = "https://github.com/paritytech/substrate", branch = "p pallet-collective = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.11", default-features = false } pallet-democracy = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.11", default-features = false } pallet-elections-phragmen = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.11", default-features = false } +pallet-identity = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.11", default-features = false } pallet-indices = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.11", default-features = false } pallet-membership = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.11", default-features = false } pallet-multisig = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.11", default-features = false } @@ -137,6 +138,7 @@ std = [ "pallet-collective/std", "pallet-democracy/std", "pallet-elections-phragmen/std", + "pallet-identity/std", "pallet-indices/std", "pallet-membership/std", "pallet-multisig/std", diff --git a/runtime/asgard/src/lib.rs b/runtime/asgard/src/lib.rs index 0b0b25d70f..6871751b91 100644 --- a/runtime/asgard/src/lib.rs +++ b/runtime/asgard/src/lib.rs @@ -274,24 +274,6 @@ impl pallet_utility::Config for Runtime { type WeightInfo = pallet_utility::weights::SubstrateWeight; } -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: u16 = 100; -} - -impl pallet_multisig::Config for Runtime { - type Call = Call; - type Currency = Balances; - type DepositBase = DepositBase; - type DepositFactor = DepositFactor; - type Event = Event; - 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, 8); @@ -322,6 +304,7 @@ pub enum ProxyType { NonTransfer = 1, Governance = 2, CancelProxy = 3, + IdentityJudgement = 4, } impl Default for ProxyType { @@ -371,6 +354,10 @@ impl InstanceFilter for ProxyType { ProxyType::CancelProxy => { matches!(c, Call::Proxy(pallet_proxy::Call::reject_announcement { .. })) }, + ProxyType::IdentityJudgement => matches!( + c, + Call::Identity(pallet_identity::Call::provide_judgement { .. }) | Call::Utility(..) + ), } } @@ -417,6 +404,49 @@ impl pallet_scheduler::Config for Runtime { type WeightInfo = pallet_scheduler::weights::SubstrateWeight; } +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: u16 = 100; +} + +impl pallet_multisig::Config for Runtime { + type Call = Call; + type Currency = Balances; + type DepositBase = DepositBase; + type DepositFactor = DepositFactor; + type Event = Event; + type MaxSignatories = MaxSignatories; + type WeightInfo = pallet_multisig::weights::SubstrateWeight; +} + +parameter_types! { + // Minimum 4 CENTS/byte + pub const BasicDeposit: Balance = deposit(1, 258); + pub const FieldDeposit: Balance = deposit(0, 66); + pub const SubAccountDeposit: Balance = deposit(1, 53); + pub const MaxSubAccounts: u32 = 100; + pub const MaxAdditionalFields: u32 = 100; + pub const MaxRegistrars: u32 = 20; +} + +impl pallet_identity::Config for Runtime { + type Event = Event; + type Currency = Balances; + type BasicDeposit = BasicDeposit; + type FieldDeposit = FieldDeposit; + type SubAccountDeposit = SubAccountDeposit; + type MaxSubAccounts = MaxSubAccounts; + type MaxAdditionalFields = MaxAdditionalFields; + type MaxRegistrars = MaxRegistrars; + type Slashed = Treasury; + type ForceOrigin = MoreThanHalfCouncil; + type RegistrarOrigin = MoreThanHalfCouncil; + type WeightInfo = pallet_identity::weights::SubstrateWeight; +} + parameter_types! { pub const IndexDeposit: Balance = 1 * DOLLARS; } @@ -1485,6 +1515,7 @@ construct_runtime! { Scheduler: pallet_scheduler::{Pallet, Call, Storage, Event} = 51, Proxy: pallet_proxy::{Pallet, Call, Storage, Event} = 52, Multisig: pallet_multisig::{Pallet, Call, Storage, Event} = 53, + Identity: pallet_identity::{Pallet, Call, Storage, Event} = 54, // Vesting. Usable initially, but removed once all vesting is finished. Vesting: pallet_vesting::{Pallet, Call, Storage, Event, Config} = 60, diff --git a/runtime/bifrost/Cargo.toml b/runtime/bifrost/Cargo.toml index 67abb047a3..e0be9157db 100644 --- a/runtime/bifrost/Cargo.toml +++ b/runtime/bifrost/Cargo.toml @@ -46,9 +46,11 @@ pallet-bounties = { git = "https://github.com/paritytech/substrate", branch = "p pallet-collective = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.11", default-features = false } pallet-democracy = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.11", default-features = false } pallet-elections-phragmen = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.11", default-features = false } +pallet-identity = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.11", default-features = false } pallet-indices = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.11", default-features = false } pallet-membership = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.11", default-features = false } pallet-multisig = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.11", default-features = false } +pallet-proxy = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.11", default-features = false } pallet-randomness-collective-flip = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.11", default-features = false } pallet-scheduler = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.11", default-features = false } pallet-session = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.11", default-features = false } @@ -125,8 +127,10 @@ std = [ "pallet-bounties/std", "pallet-collective/std", "pallet-democracy/std", + "pallet-identity/std", "pallet-indices/std", "pallet-multisig/std", + "pallet-proxy/std", "pallet-randomness-collective-flip/std", "pallet-timestamp/std", "pallet-transaction-payment-rpc-runtime-api/std", diff --git a/runtime/bifrost/src/lib.rs b/runtime/bifrost/src/lib.rs index 1ab4e5bada..cd4a1b88e1 100644 --- a/runtime/bifrost/src/lib.rs +++ b/runtime/bifrost/src/lib.rs @@ -31,12 +31,12 @@ use core::convert::TryInto; // A few exports that help ease life for downstream crates. pub use frame_support::{ construct_runtime, match_type, parameter_types, - traits::{Contains, Everything, IsInVec, Nothing, Randomness}, + traits::{Contains, Everything, InstanceFilter, IsInVec, Nothing, Randomness}, weights::{ constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND}, DispatchClass, IdentityFee, Weight, }, - PalletId, StorageValue, + PalletId, RuntimeDebug, StorageValue, }; use frame_system::limits::{BlockLength, BlockWeights}; pub use pallet_balances::Call as BalancesCall; @@ -77,7 +77,7 @@ use bifrost_runtime_common::{ CouncilCollective, EnsureRootOrAllTechnicalCommittee, MoreThanHalfCouncil, SlowAdjustingFeeUpdate, TechnicalCollective, }; -use codec::Encode; +use codec::{Decode, Encode, MaxEncodedLen}; use constants::{currency::*, time::*}; use cumulus_primitives_core::ParaId as CumulusParaId; use frame_support::{ @@ -297,21 +297,116 @@ impl pallet_utility::Config for Runtime { } 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: u16 = 100; + // 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 AnnouncementDepositBase: Balance = deposit(1, 8); + pub const AnnouncementDepositFactor: Balance = deposit(0, 66); + pub const MaxPending: u16 = 32; +} + +/// 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 { + Any = 0, + NonTransfer = 1, + Governance = 2, + CancelProxy = 3, + IdentityJudgement = 4, +} + +impl Default for ProxyType { + fn default() -> Self { + Self::Any + } } +impl InstanceFilter for ProxyType { + fn filter(&self, c: &Call) -> bool { + match self { + ProxyType::Any => true, + ProxyType::NonTransfer => matches!( + c, + Call::System(..) | + Call::Scheduler(..) | + Call::Timestamp(..) | + Call::Indices(pallet_indices::Call::claim{..}) | + Call::Indices(pallet_indices::Call::free{..}) | + Call::Indices(pallet_indices::Call::freeze{..}) | + // Specifically omitting Indices `transfer`, `force_transfer` + // Specifically omitting the entire Balances pallet + Call::Authorship(..) | + Call::Session(..) | + Call::Democracy(..) | + Call::Council(..) | + Call::TechnicalCommittee(..) | + Call::PhragmenElection(..) | + Call::TechnicalMembership(..) | + Call::Treasury(..) | + Call::Bounties(..) | + Call::Tips(..) | + Call::Vesting(pallet_vesting::Call::vest{..}) | + Call::Vesting(pallet_vesting::Call::vest_other{..}) | + // Specifically omitting Vesting `vested_transfer`, and `force_vested_transfer` + Call::Utility(..) | + Call::Proxy(..) | + Call::Multisig(..) + ), + ProxyType::Governance => matches!( + c, + Call::Democracy(..) | + Call::Council(..) | Call::TechnicalCommittee(..) | + Call::PhragmenElection(..) | + Call::Treasury(..) | Call::Bounties(..) | + Call::Tips(..) | Call::Utility(..) + ), + ProxyType::CancelProxy => { + matches!(c, Call::Proxy(pallet_proxy::Call::reject_announcement { .. })) + }, + ProxyType::IdentityJudgement => matches!( + c, + Call::Identity(pallet_identity::Call::provide_judgement { .. }) | Call::Utility(..) + ), + } + } -impl pallet_multisig::Config for Runtime { + fn is_superset(&self, o: &Self) -> bool { + match (self, o) { + (x, y) if x == y => true, + (ProxyType::Any, _) => true, + (_, ProxyType::Any) => false, + (ProxyType::NonTransfer, _) => true, + _ => false, + } + } +} + +impl pallet_proxy::Config for Runtime { + type AnnouncementDepositBase = AnnouncementDepositBase; + type AnnouncementDepositFactor = AnnouncementDepositFactor; type Call = Call; + type CallHasher = BlakeTwo256; type Currency = Balances; - type DepositBase = DepositBase; - type DepositFactor = DepositFactor; type Event = Event; - type MaxSignatories = MaxSignatories; - type WeightInfo = pallet_multisig::weights::SubstrateWeight; + type MaxPending = MaxPending; + type MaxProxies = MaxProxies; + type ProxyDepositBase = ProxyDepositBase; + type ProxyDepositFactor = ProxyDepositFactor; + type ProxyType = ProxyType; + type WeightInfo = pallet_proxy::weights::SubstrateWeight; } parameter_types! { @@ -331,6 +426,49 @@ impl pallet_scheduler::Config for Runtime { type WeightInfo = weights::pallet_scheduler::WeightInfo; } +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: u16 = 100; +} + +impl pallet_multisig::Config for Runtime { + type Call = Call; + type Currency = Balances; + type DepositBase = DepositBase; + type DepositFactor = DepositFactor; + type Event = Event; + type MaxSignatories = MaxSignatories; + type WeightInfo = pallet_multisig::weights::SubstrateWeight; +} + +parameter_types! { + // Minimum 4 CENTS/byte + pub const BasicDeposit: Balance = deposit(1, 258); + pub const FieldDeposit: Balance = deposit(0, 66); + pub const SubAccountDeposit: Balance = deposit(1, 53); + pub const MaxSubAccounts: u32 = 100; + pub const MaxAdditionalFields: u32 = 100; + pub const MaxRegistrars: u32 = 20; +} + +impl pallet_identity::Config for Runtime { + type Event = Event; + type Currency = Balances; + type BasicDeposit = BasicDeposit; + type FieldDeposit = FieldDeposit; + type SubAccountDeposit = SubAccountDeposit; + type MaxSubAccounts = MaxSubAccounts; + type MaxAdditionalFields = MaxAdditionalFields; + type MaxRegistrars = MaxRegistrars; + type Slashed = Treasury; + type ForceOrigin = MoreThanHalfCouncil; + type RegistrarOrigin = MoreThanHalfCouncil; + type WeightInfo = pallet_identity::weights::SubstrateWeight; +} + parameter_types! { pub const IndexDeposit: Balance = 1 * DOLLARS; } @@ -1331,7 +1469,9 @@ construct_runtime! { // utilities Utility: pallet_utility::{Pallet, Call, Event} = 50, Scheduler: pallet_scheduler::{Pallet, Call, Storage, Event} = 51, + Proxy: pallet_proxy::{Pallet, Call, Storage, Event} = 52, Multisig: pallet_multisig::{Pallet, Call, Storage, Event} = 53, + Identity: pallet_identity::{Pallet, Call, Storage, Event} = 54, // Vesting. Usable initially, but removed once all vesting is finished. Vesting: pallet_vesting::{Pallet, Call, Storage, Event, Config} = 60,