Unverified Commit 3b0934cf authored by Gavin Wood's avatar Gavin Wood Committed by GitHub
Browse files

Generalised proxies in Polkadot (#1190)

* Introduce generalised proxies to polkadot

* Introduce proxy to westend

* Add proxy to Kusama.

* Fix
parent 0b8a8b90
Pipeline #95347 passed with stages
in 24 minutes and 56 seconds
[package] [package]
name = "polkadot-test-runtime" name = "polkadot-test-runtime"
version = "0.8.2" version = "0.8.3"
authors = ["Parity Technologies <admin@parity.io>"] authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018" edition = "2018"
build = "build.rs" build = "build.rs"
......
[package] [package]
name = "westend-runtime" name = "westend-runtime"
version = "0.8.2" version = "0.8.3"
authors = ["Parity Technologies <admin@parity.io>"] authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018" edition = "2018"
build = "build.rs" build = "build.rs"
...@@ -48,6 +48,7 @@ indices = { package = "pallet-indices", git = "https://github.com/paritytech/sub ...@@ -48,6 +48,7 @@ indices = { package = "pallet-indices", git = "https://github.com/paritytech/sub
membership = { package = "pallet-membership", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } membership = { package = "pallet-membership", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
nicks = { package = "pallet-nicks", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } nicks = { package = "pallet-nicks", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
offences = { package = "pallet-offences", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } offences = { package = "pallet-offences", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
proxy = { package = "pallet-proxy", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
randomness-collective-flip = { package = "pallet-randomness-collective-flip", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } randomness-collective-flip = { package = "pallet-randomness-collective-flip", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
recovery = { package = "pallet-recovery", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } recovery = { package = "pallet-recovery", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
scheduler = { package = "pallet-scheduler", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } scheduler = { package = "pallet-scheduler", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
...@@ -122,6 +123,7 @@ std = [ ...@@ -122,6 +123,7 @@ std = [
"membership/std", "membership/std",
"nicks/std", "nicks/std",
"offences/std", "offences/std",
"proxy/std",
"recovery/std", "recovery/std",
"sp-runtime/std", "sp-runtime/std",
"sp-staking/std", "sp-staking/std",
......
...@@ -22,6 +22,10 @@ pub mod currency { ...@@ -22,6 +22,10 @@ pub mod currency {
pub const DOLLARS: Balance = DOTS; pub const DOLLARS: Balance = DOTS;
pub const CENTS: Balance = DOLLARS / 100; pub const CENTS: Balance = DOLLARS / 100;
pub const MILLICENTS: Balance = CENTS / 1_000; pub const MILLICENTS: Balance = CENTS / 1_000;
pub const fn deposit(items: u32, bytes: u32) -> Balance {
items as Balance * 15 * CENTS + (bytes as Balance) * 6 * CENTS
}
} }
/// Time and blocks. /// Time and blocks.
......
...@@ -51,8 +51,8 @@ use version::NativeVersion; ...@@ -51,8 +51,8 @@ use version::NativeVersion;
use sp_core::OpaqueMetadata; use sp_core::OpaqueMetadata;
use sp_staking::SessionIndex; use sp_staking::SessionIndex;
use frame_support::{ use frame_support::{
parameter_types, construct_runtime, debug, parameter_types, construct_runtime, debug, RuntimeDebug,
traits::{KeyOwnerProofSystem, Randomness, Filter}, traits::{KeyOwnerProofSystem, Randomness, Filter, InstanceFilter},
weights::Weight, weights::Weight,
}; };
use im_online::sr25519::AuthorityId as ImOnlineId; use im_online::sr25519::AuthorityId as ImOnlineId;
...@@ -571,6 +571,45 @@ impl sudo::Trait for Runtime { ...@@ -571,6 +571,45 @@ impl sudo::Trait for Runtime {
type Call = Call; type Call = Call;
} }
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,
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::Indices(indices::Call::transfer(..))
),
ProxyType::Staking => matches!(c, Call::Staking(..)),
}
}
}
impl proxy::Trait for Runtime {
type Event = Event;
type Call = Call;
type Currency = Balances;
type IsCallable = IsCallable;
type ProxyType = ProxyType;
type ProxyDepositBase = ProxyDepositBase;
type ProxyDepositFactor = ProxyDepositFactor;
type MaxProxies = MaxProxies;
}
construct_runtime! { construct_runtime! {
pub enum Runtime where pub enum Runtime where
Block = Block, Block = Block,
...@@ -622,7 +661,10 @@ construct_runtime! { ...@@ -622,7 +661,10 @@ construct_runtime! {
Scheduler: scheduler::{Module, Call, Storage, Event<T>}, Scheduler: scheduler::{Module, Call, Storage, Event<T>},
// Sudo. // Sudo.
Sudo: sudo::{Module, Call, Storage, Event<T>, Config<T>} Sudo: sudo::{Module, Call, Storage, Event<T>, Config<T>},
// Proxy module. Late addition.
Proxy: proxy::{Module, Call, Storage, Event}
} }
} }
......
[package] [package]
name = "polkadot-service" name = "polkadot-service"
version = "0.8.2" version = "0.8.3"
authors = ["Parity Technologies <admin@parity.io>"] authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018" edition = "2018"
......
[package] [package]
name = "polkadot-statement-table" name = "polkadot-statement-table"
version = "0.8.2" version = "0.8.3"
authors = ["Parity Technologies <admin@parity.io>"] authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018" edition = "2018"
......
[package] [package]
name = "polkadot-validation" name = "polkadot-validation"
version = "0.8.2" version = "0.8.3"
authors = ["Parity Technologies <admin@parity.io>"] authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018" edition = "2018"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment