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
This diff is collapsed.
...@@ -4,7 +4,7 @@ path = "src/main.rs" ...@@ -4,7 +4,7 @@ path = "src/main.rs"
[package] [package]
name = "polkadot" name = "polkadot"
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-availability-store" name = "polkadot-availability-store"
description = "Persistent database for parachain data" description = "Persistent database for parachain data"
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-cli" name = "polkadot-cli"
version = "0.8.2" version = "0.8.3"
authors = ["Parity Technologies <admin@parity.io>"] authors = ["Parity Technologies <admin@parity.io>"]
description = "Polkadot Relay-chain Client Node" description = "Polkadot Relay-chain Client Node"
edition = "2018" edition = "2018"
......
[package] [package]
name = "polkadot-collator" name = "polkadot-collator"
version = "0.8.2" version = "0.8.3"
authors = ["Parity Technologies <admin@parity.io>"] authors = ["Parity Technologies <admin@parity.io>"]
description = "Collator node implementation" description = "Collator node implementation"
edition = "2018" edition = "2018"
......
[package] [package]
name = "polkadot-erasure-coding" name = "polkadot-erasure-coding"
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-network" name = "polkadot-network"
version = "0.8.2" version = "0.8.3"
authors = ["Parity Technologies <admin@parity.io>"] authors = ["Parity Technologies <admin@parity.io>"]
description = "Polkadot-specific networking protocol" description = "Polkadot-specific networking protocol"
edition = "2018" edition = "2018"
......
[package] [package]
name = "polkadot-network-test" name = "polkadot-network-test"
version = "0.8.2" version = "0.8.3"
license = "GPL-3.0" license = "GPL-3.0"
authors = ["Parity Technologies <admin@parity.io>"] authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018" edition = "2018"
......
[package] [package]
name = "polkadot-parachain" name = "polkadot-parachain"
version = "0.8.2" version = "0.8.3"
authors = ["Parity Technologies <admin@parity.io>"] authors = ["Parity Technologies <admin@parity.io>"]
description = "Types and utilities for creating and working with parachains" description = "Types and utilities for creating and working with parachains"
edition = "2018" edition = "2018"
......
[package] [package]
name = "test-parachain-adder" name = "test-parachain-adder"
version = "0.8.2" version = "0.8.3"
authors = ["Parity Technologies <admin@parity.io>"] authors = ["Parity Technologies <admin@parity.io>"]
description = "Test parachain which adds to a number as its state transition" description = "Test parachain which adds to a number as its state transition"
edition = "2018" edition = "2018"
......
[package] [package]
name = "test-parachain-halt" name = "test-parachain-halt"
version = "0.8.2" version = "0.8.3"
authors = ["Parity Technologies <admin@parity.io>"] authors = ["Parity Technologies <admin@parity.io>"]
description = "Test parachain which executes forever" description = "Test parachain which executes forever"
edition = "2018" edition = "2018"
......
[package] [package]
name = "polkadot-primitives" name = "polkadot-primitives"
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-rpc" name = "polkadot-rpc"
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-runtime-common" name = "polkadot-runtime-common"
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 = "kusama-runtime" name = "kusama-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 }
...@@ -119,6 +120,7 @@ std = [ ...@@ -119,6 +120,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.
......
...@@ -52,8 +52,8 @@ use version::NativeVersion; ...@@ -52,8 +52,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, SplitTwoWays, Randomness, LockIdentifier, Filter}, traits::{KeyOwnerProofSystem, SplitTwoWays, Randomness, LockIdentifier, Filter, InstanceFilter},
weights::Weight, weights::Weight,
}; };
use im_online::sr25519::AuthorityId as ImOnlineId; use im_online::sr25519::AuthorityId as ImOnlineId;
...@@ -762,6 +762,52 @@ impl vesting::Trait for Runtime { ...@@ -762,6 +762,52 @@ impl vesting::Trait for Runtime {
type MinVestedTransfer = MinVestedTransfer; type MinVestedTransfer = MinVestedTransfer;
} }
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::Governance => matches!(c,
Call::Democracy(..) | Call::Council(..) | Call::TechnicalCommittee(..)
| Call::ElectionsPhragmen(..) | Call::Treasury(..)
),
ProxyType::NonTransfer => !matches!(c,
Call::Balances(..) | Call::Utility(..)
| Call::Vesting(vesting::Call::vested_transfer(..))
| 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,
...@@ -826,6 +872,9 @@ construct_runtime! { ...@@ -826,6 +872,9 @@ construct_runtime! {
// System scheduler. // System scheduler.
Scheduler: scheduler::{Module, Call, Storage, Event<T>}, Scheduler: scheduler::{Module, Call, Storage, Event<T>},
// Proxy module. Late addition.
Proxy: proxy::{Module, Call, Storage, Event}
} }
} }
......
[package] [package]
name = "polkadot-runtime" name = "polkadot-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"
...@@ -47,6 +47,7 @@ indices = { package = "pallet-indices", git = "https://github.com/paritytech/sub ...@@ -47,6 +47,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 }
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 }
session = { package = "pallet-session", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } session = { package = "pallet-session", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
...@@ -116,6 +117,7 @@ std = [ ...@@ -116,6 +117,7 @@ std = [
"membership/std", "membership/std",
"nicks/std", "nicks/std",
"offences/std", "offences/std",
"proxy/std",
"sp-runtime/std", "sp-runtime/std",
"sp-staking/std", "sp-staking/std",
"scheduler/std", "scheduler/std",
......
...@@ -22,6 +22,10 @@ pub mod currency { ...@@ -22,6 +22,10 @@ pub mod currency {
pub const DOLLARS: Balance = DOTS / 100; // 10_000_000_000 pub const DOLLARS: Balance = DOTS / 100; // 10_000_000_000
pub const CENTS: Balance = DOLLARS / 100; // 100_000_000 pub const CENTS: Balance = DOLLARS / 100; // 100_000_000
pub const MILLICENTS: Balance = CENTS / 1_000; // 100_000 pub const MILLICENTS: Balance = CENTS / 1_000; // 100_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.
......
...@@ -55,7 +55,7 @@ use version::NativeVersion; ...@@ -55,7 +55,7 @@ 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, SplitTwoWays, Randomness, LockIdentifier, Filter}, traits::{KeyOwnerProofSystem, SplitTwoWays, Randomness, LockIdentifier, Filter},
weights::Weight, weights::Weight,
}; };
...@@ -77,6 +77,7 @@ pub use parachains::Call as ParachainsCall; ...@@ -77,6 +77,7 @@ pub use parachains::Call as ParachainsCall;
/// Constant values used within the runtime. /// Constant values used within the runtime.
pub mod constants; pub mod constants;
use constants::{time::*, currency::*, fee::*}; use constants::{time::*, currency::*, fee::*};
use frame_support::traits::InstanceFilter;
// Make the WASM binary available. // Make the WASM binary available.
#[cfg(feature = "std")] #[cfg(feature = "std")]
...@@ -88,7 +89,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { ...@@ -88,7 +89,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("polkadot"), spec_name: create_runtime_str!("polkadot"),
impl_name: create_runtime_str!("parity-polkadot"), impl_name: create_runtime_str!("parity-polkadot"),
authoring_version: 0, authoring_version: 0,
spec_version: 2, spec_version: 3,
impl_version: 0, impl_version: 0,
apis: RUNTIME_API_VERSIONS, apis: RUNTIME_API_VERSIONS,
transaction_version: 0, transaction_version: 0,
...@@ -126,7 +127,7 @@ impl Filter<Call> for IsCallable { ...@@ -126,7 +127,7 @@ impl Filter<Call> for IsCallable {
Call::Session(_) | Call::FinalityTracker(_) | Call::Grandpa(_) | Call::ImOnline(_) | Call::Session(_) | Call::FinalityTracker(_) | Call::Grandpa(_) | Call::ImOnline(_) |
Call::AuthorityDiscovery(_) | Call::AuthorityDiscovery(_) |
Call::Utility(_) | Call::Claims(_) | Call::Vesting(_) | Call::Sudo(_) | Call::Utility(_) | Call::Claims(_) | Call::Vesting(_) | Call::Sudo(_) |
Call::Identity(_) => Call::Identity(_) | Call::Proxy(_) =>
true, true,
} }
} }
...@@ -334,10 +335,6 @@ impl staking::Trait for Runtime { ...@@ -334,10 +335,6 @@ impl staking::Trait for Runtime {
type MinSolutionScoreBump = MinSolutionScoreBump; type MinSolutionScoreBump = MinSolutionScoreBump;
} }
const fn deposit(items: u32, bytes: u32) -> Balance {
items as Balance * 15 * CENTS + (bytes as Balance) * 6 * CENTS
}
parameter_types! { parameter_types! {
// Minimum 4 CENTS/byte // Minimum 4 CENTS/byte
pub const BasicDeposit: Balance = deposit(1, 258); pub const BasicDeposit: Balance = deposit(1, 258);
...@@ -746,6 +743,52 @@ impl sudo::Trait for Runtime { ...@@ -746,6 +743,52 @@ 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,
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(vesting::Call::vested_transfer(..))
| Call::Indices(indices::Call::transfer(..))
),
ProxyType::Governance => matches!(c,
Call::Democracy(..) | Call::Council(..) | Call::TechnicalCommittee(..)
| Call::ElectionsPhragmen(..) | Call::Treasury(..)
),
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,
...@@ -805,6 +848,9 @@ construct_runtime! { ...@@ -805,6 +848,9 @@ construct_runtime! {
// Identity. Late addition. // Identity. Late addition.
Identity: identity::{Module, Call, Storage, Event<T>}, Identity: identity::{Module, Call, Storage, Event<T>},
// Proxy module. Late addition.
Proxy: proxy::{Module, Call, Storage, Event}
} }
} }
......
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