Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generalised proxies in Polkadot #1190

Merged
merged 5 commits into from Jun 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view

Large diffs are not rendered by default.

@@ -4,7 +4,7 @@ path = "src/main.rs"

[package]
name = "polkadot"
version = "0.8.2"
version = "0.8.3"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"

@@ -1,7 +1,7 @@
[package]
name = "polkadot-availability-store"
description = "Persistent database for parachain data"
version = "0.8.2"
version = "0.8.3"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"

@@ -1,6 +1,6 @@
[package]
name = "polkadot-cli"
version = "0.8.2"
version = "0.8.3"
authors = ["Parity Technologies <admin@parity.io>"]
description = "Polkadot Relay-chain Client Node"
edition = "2018"
@@ -1,6 +1,6 @@
[package]
name = "polkadot-collator"
version = "0.8.2"
version = "0.8.3"
authors = ["Parity Technologies <admin@parity.io>"]
description = "Collator node implementation"
edition = "2018"
@@ -1,6 +1,6 @@
[package]
name = "polkadot-erasure-coding"
version = "0.8.2"
version = "0.8.3"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"

@@ -1,6 +1,6 @@
[package]
name = "polkadot-network"
version = "0.8.2"
version = "0.8.3"
authors = ["Parity Technologies <admin@parity.io>"]
description = "Polkadot-specific networking protocol"
edition = "2018"
@@ -1,6 +1,6 @@
[package]
name = "polkadot-network-test"
version = "0.8.2"
version = "0.8.3"
license = "GPL-3.0"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
@@ -1,6 +1,6 @@
[package]
name = "polkadot-parachain"
version = "0.8.2"
version = "0.8.3"
authors = ["Parity Technologies <admin@parity.io>"]
description = "Types and utilities for creating and working with parachains"
edition = "2018"
@@ -1,6 +1,6 @@
[package]
name = "test-parachain-adder"
version = "0.8.2"
version = "0.8.3"
authors = ["Parity Technologies <admin@parity.io>"]
description = "Test parachain which adds to a number as its state transition"
edition = "2018"
@@ -1,6 +1,6 @@
[package]
name = "test-parachain-halt"
version = "0.8.2"
version = "0.8.3"
authors = ["Parity Technologies <admin@parity.io>"]
description = "Test parachain which executes forever"
edition = "2018"
@@ -1,6 +1,6 @@
[package]
name = "polkadot-primitives"
version = "0.8.2"
version = "0.8.3"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"

@@ -1,6 +1,6 @@
[package]
name = "polkadot-rpc"
version = "0.8.2"
version = "0.8.3"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"

@@ -1,6 +1,6 @@
[package]
name = "polkadot-runtime-common"
version = "0.8.2"
version = "0.8.3"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"

@@ -1,6 +1,6 @@
[package]
name = "kusama-runtime"
version = "0.8.2"
version = "0.8.3"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
build = "build.rs"
@@ -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 }
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 }
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 }
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 }
@@ -119,6 +120,7 @@ std = [
"membership/std",
"nicks/std",
"offences/std",
"proxy/std",
"recovery/std",
"sp-runtime/std",
"sp-staking/std",
@@ -22,6 +22,10 @@ pub mod currency {
pub const DOLLARS: Balance = DOTS;
pub const CENTS: Balance = DOLLARS / 100;
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.
@@ -52,8 +52,8 @@ use version::NativeVersion;
use sp_core::OpaqueMetadata;
use sp_staking::SessionIndex;
use frame_support::{
parameter_types, construct_runtime, debug,
traits::{KeyOwnerProofSystem, SplitTwoWays, Randomness, LockIdentifier, Filter},
parameter_types, construct_runtime, debug, RuntimeDebug,
traits::{KeyOwnerProofSystem, SplitTwoWays, Randomness, LockIdentifier, Filter, InstanceFilter},
weights::Weight,
};
use im_online::sr25519::AuthorityId as ImOnlineId;
@@ -762,6 +762,52 @@ impl vesting::Trait for Runtime {
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! {
pub enum Runtime where
Block = Block,
@@ -826,6 +872,9 @@ construct_runtime! {

// System scheduler.
Scheduler: scheduler::{Module, Call, Storage, Event<T>},

// Proxy module. Late addition.
Proxy: proxy::{Module, Call, Storage, Event}
}
}

@@ -1,6 +1,6 @@
[package]
name = "polkadot-runtime"
version = "0.8.2"
version = "0.8.3"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
build = "build.rs"
@@ -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 }
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 }
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 }
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 }
@@ -116,6 +117,7 @@ std = [
"membership/std",
"nicks/std",
"offences/std",
"proxy/std",
"sp-runtime/std",
"sp-staking/std",
"scheduler/std",
@@ -22,6 +22,10 @@ pub mod currency {
pub const DOLLARS: Balance = DOTS / 100; // 10_000_000_000
pub const CENTS: Balance = DOLLARS / 100; // 100_000_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.
@@ -55,7 +55,7 @@ use version::NativeVersion;
use sp_core::OpaqueMetadata;
use sp_staking::SessionIndex;
use frame_support::{
parameter_types, construct_runtime, debug,
parameter_types, construct_runtime, debug, RuntimeDebug,
traits::{KeyOwnerProofSystem, SplitTwoWays, Randomness, LockIdentifier, Filter},
weights::Weight,
};
@@ -77,6 +77,7 @@ pub use parachains::Call as ParachainsCall;
/// Constant values used within the runtime.
pub mod constants;
use constants::{time::*, currency::*, fee::*};
use frame_support::traits::InstanceFilter;

// Make the WASM binary available.
#[cfg(feature = "std")]
@@ -88,7 +89,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("polkadot"),
impl_name: create_runtime_str!("parity-polkadot"),
authoring_version: 0,
spec_version: 2,
spec_version: 3,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 0,
@@ -126,7 +127,7 @@ impl Filter<Call> for IsCallable {
Call::Session(_) | Call::FinalityTracker(_) | Call::Grandpa(_) | Call::ImOnline(_) |
Call::AuthorityDiscovery(_) |
Call::Utility(_) | Call::Claims(_) | Call::Vesting(_) | Call::Sudo(_) |
Call::Identity(_) =>
Call::Identity(_) | Call::Proxy(_) =>
true,
}
}
@@ -334,10 +335,6 @@ impl staking::Trait for Runtime {
type MinSolutionScoreBump = MinSolutionScoreBump;
}

const fn deposit(items: u32, bytes: u32) -> Balance {
items as Balance * 15 * CENTS + (bytes as Balance) * 6 * CENTS
}

parameter_types! {
// Minimum 4 CENTS/byte
pub const BasicDeposit: Balance = deposit(1, 258);
@@ -746,6 +743,52 @@ impl sudo::Trait for Runtime {
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! {
pub enum Runtime where
Block = Block,
@@ -805,6 +848,9 @@ construct_runtime! {

// Identity. Late addition.
Identity: identity::{Module, Call, Storage, Event<T>},

// Proxy module. Late addition.
Proxy: proxy::{Module, Call, Storage, Event}
}
}

@@ -1,6 +1,6 @@
[package]
name = "polkadot-test-runtime"
version = "0.8.2"
version = "0.8.3"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
build = "build.rs"
@@ -1,6 +1,6 @@
[package]
name = "westend-runtime"
version = "0.8.2"
version = "0.8.3"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
build = "build.rs"
@@ -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 }
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 }
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 }
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 }
@@ -122,6 +123,7 @@ std = [
"membership/std",
"nicks/std",
"offences/std",
"proxy/std",
"recovery/std",
"sp-runtime/std",
"sp-staking/std",