Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
323 changes: 170 additions & 153 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
2 changes: 1 addition & 1 deletion availability-store/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"

Expand Down
2 changes: 1 addition & 1 deletion cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 1 addition & 1 deletion collator/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 1 addition & 1 deletion erasure-coding/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"

Expand Down
2 changes: 1 addition & 1 deletion network/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 1 addition & 1 deletion network/test/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 1 addition & 1 deletion parachain/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 1 addition & 1 deletion parachain/test-parachains/adder/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 1 addition & 1 deletion parachain/test-parachains/halt/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 1 addition & 1 deletion primitives/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "polkadot-primitives"
version = "0.8.2"
version = "0.8.3"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion rpc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "polkadot-rpc"
version = "0.8.2"
version = "0.8.3"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion runtime/common/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"

Expand Down
4 changes: 3 additions & 1 deletion runtime/kusama/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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 }
Expand Down Expand Up @@ -119,6 +120,7 @@ std = [
"membership/std",
"nicks/std",
"offences/std",
"proxy/std",
"recovery/std",
"sp-runtime/std",
"sp-staking/std",
Expand Down
4 changes: 4 additions & 0 deletions runtime/kusama/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
53 changes: 51 additions & 2 deletions runtime/kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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}
}
}

Expand Down
4 changes: 3 additions & 1 deletion runtime/polkadot/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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 }
Expand Down Expand Up @@ -116,6 +117,7 @@ std = [
"membership/std",
"nicks/std",
"offences/std",
"proxy/std",
"sp-runtime/std",
"sp-staking/std",
"scheduler/std",
Expand Down
4 changes: 4 additions & 0 deletions runtime/polkadot/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
60 changes: 53 additions & 7 deletions runtime/polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand All @@ -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")]
Expand All @@ -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,
Expand Down Expand Up @@ -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,
}
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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}
}
}

Expand Down
2 changes: 1 addition & 1 deletion runtime/test-runtime/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
4 changes: 3 additions & 1 deletion runtime/westend/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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 }
Expand Down Expand Up @@ -122,6 +123,7 @@ std = [
"membership/std",
"nicks/std",
"offences/std",
"proxy/std",
"recovery/std",
"sp-runtime/std",
"sp-staking/std",
Expand Down
Loading