mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-01 06:37:56 +00:00
Generalised proxies (#6156)
* Initial work * It should work * Fix node * Fix tests * Initial test * Tests * Expunge proxy functionality from democracy and elections * Allow different proxy types * Repotted * Build * Build * Making a start on weights * Undo breaking change * Line widths. * Fix * fix tests * finish benchmarks? * Storage name! * Utility -> Proxy * proxy weight * add proxy weight * remove weights * Update transfer constraint * Again, fix constraints * Fix negation * Update frame/proxy/Cargo.toml Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> * Remove unneeded event. * Grumbles * Apply suggestions from code review Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com> Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
This commit is contained in:
@@ -24,13 +24,14 @@
|
||||
|
||||
use sp_std::prelude::*;
|
||||
use frame_support::{
|
||||
construct_runtime, parameter_types, debug,
|
||||
construct_runtime, parameter_types, debug, RuntimeDebug,
|
||||
weights::{
|
||||
Weight, IdentityFee,
|
||||
constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},
|
||||
},
|
||||
traits::{Currency, Imbalance, KeyOwnerProofSystem, OnUnbalanced, Randomness, LockIdentifier},
|
||||
};
|
||||
use codec::{Encode, Decode};
|
||||
use sp_core::{
|
||||
crypto::KeyTypeId,
|
||||
u32_trait::{_1, _2, _3, _4},
|
||||
@@ -60,7 +61,6 @@ use pallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo;
|
||||
use pallet_contracts_rpc_runtime_api::ContractExecResult;
|
||||
use pallet_session::{historical as pallet_session_historical};
|
||||
use sp_inherents::{InherentData, CheckInherentsResult};
|
||||
use codec::Encode;
|
||||
use static_assertions::const_assert;
|
||||
|
||||
#[cfg(any(feature = "std", test))]
|
||||
@@ -79,6 +79,7 @@ use impls::{CurrencyToVoteHandler, Author, TargetedFeeAdjustment};
|
||||
/// Constant values used within the runtime.
|
||||
pub mod constants;
|
||||
use constants::{time::*, currency::*};
|
||||
use frame_support::traits::InstanceFilter;
|
||||
|
||||
// Make the WASM binary available.
|
||||
#[cfg(feature = "std")]
|
||||
@@ -168,11 +169,13 @@ impl frame_system::Trait for Runtime {
|
||||
type OnKilledAccount = ();
|
||||
}
|
||||
|
||||
const fn deposit(items: u32, bytes: u32) -> Balance { items as Balance * 15 * CENTS + (bytes as Balance) * 6 * CENTS }
|
||||
|
||||
parameter_types! {
|
||||
// One storage item; value is size 4+4+16+32 bytes = 56 bytes.
|
||||
pub const MultisigDepositBase: Balance = 30 * CENTS;
|
||||
// One storage item; key size is 32; value is size 4+4+16+32 bytes = 56 bytes.
|
||||
pub const MultisigDepositBase: Balance = deposit(1, 88);
|
||||
// Additional storage item size of 32 bytes.
|
||||
pub const MultisigDepositFactor: Balance = 5 * CENTS;
|
||||
pub const MultisigDepositFactor: Balance = deposit(0, 32);
|
||||
pub const MaxSignatories: u16 = 100;
|
||||
}
|
||||
|
||||
@@ -186,6 +189,52 @@ impl pallet_utility::Trait for Runtime {
|
||||
type IsCallable = ();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/// The type used to represent the kinds of proxying allowed.
|
||||
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, RuntimeDebug)]
|
||||
pub enum ProxyType {
|
||||
Any,
|
||||
NonTransfer,
|
||||
Governance,
|
||||
Staking,
|
||||
}
|
||||
impl Default for ProxyType { fn default() -> Self { Self::Any } }
|
||||
impl InstanceFilter<Call> for ProxyType {
|
||||
fn filter(&self, c: &Call) -> bool {
|
||||
match self {
|
||||
ProxyType::Any => true,
|
||||
ProxyType::NonTransfer => !matches!(c,
|
||||
Call::Balances(..) | Call::Utility(..)
|
||||
| Call::Vesting(pallet_vesting::Call::vested_transfer(..))
|
||||
| Call::Indices(pallet_indices::Call::transfer(..))
|
||||
),
|
||||
ProxyType::Governance => matches!(c,
|
||||
Call::Democracy(..) | Call::Council(..) | Call::Society(..)
|
||||
| Call::TechnicalCommittee(..) | Call::Elections(..) | Call::Treasury(..)
|
||||
),
|
||||
ProxyType::Staking => matches!(c, Call::Staking(..)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl pallet_proxy::Trait for Runtime {
|
||||
type Event = Event;
|
||||
type Call = Call;
|
||||
type Currency = Balances;
|
||||
type IsCallable = ();
|
||||
type ProxyType = ProxyType;
|
||||
type ProxyDepositBase = ProxyDepositBase;
|
||||
type ProxyDepositFactor = ProxyDepositFactor;
|
||||
type MaxProxies = MaxProxies;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub MaximumSchedulerWeight: Weight = Perbill::from_percent(80) * MaximumBlockWeight::get();
|
||||
}
|
||||
@@ -759,6 +808,7 @@ construct_runtime!(
|
||||
Recovery: pallet_recovery::{Module, Call, Storage, Event<T>},
|
||||
Vesting: pallet_vesting::{Module, Call, Storage, Event<T>, Config<T>},
|
||||
Scheduler: pallet_scheduler::{Module, Call, Storage, Event<T>},
|
||||
Proxy: pallet_proxy::{Module, Call, Storage, Event},
|
||||
}
|
||||
);
|
||||
|
||||
@@ -1009,6 +1059,7 @@ impl_runtime_apis! {
|
||||
add_benchmark!(params, batches, b"identity", Identity);
|
||||
add_benchmark!(params, batches, b"im-online", ImOnline);
|
||||
add_benchmark!(params, batches, b"offences", OffencesBench::<Runtime>);
|
||||
add_benchmark!(params, batches, b"proxy", Proxy);
|
||||
add_benchmark!(params, batches, b"scheduler", Scheduler);
|
||||
add_benchmark!(params, batches, b"session", SessionBench::<Runtime>);
|
||||
add_benchmark!(params, batches, b"staking", Staking);
|
||||
|
||||
Reference in New Issue
Block a user