Unverified Commit 8121b600 authored by Gavin Wood's avatar Gavin Wood Committed by GitHub
Browse files

Companion for #6273 (Introduce stacked filtering) (#1212)

* Fix for new Substrate

* Fix

* Remove Utility constraint in NonTransfer

* Bump

* Fixes

* Allow limited utilities in proxy filters.

* Fix

* Add SudoBalances proxy restrictions
parent 473af3b1
Pipeline #95817 passed with stages
in 20 minutes and 17 seconds
This diff is collapsed.
......@@ -4,7 +4,7 @@ path = "src/main.rs"
[package]
name = "polkadot"
version = "0.8.3"
version = "0.8.4"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
......
[package]
name = "polkadot-availability-store"
description = "Persistent database for parachain data"
version = "0.8.3"
version = "0.8.4"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
......
[package]
name = "polkadot-cli"
version = "0.8.3"
version = "0.8.4"
authors = ["Parity Technologies <admin@parity.io>"]
description = "Polkadot Relay-chain Client Node"
edition = "2018"
......
[package]
name = "polkadot-collator"
version = "0.8.3"
version = "0.8.4"
authors = ["Parity Technologies <admin@parity.io>"]
description = "Collator node implementation"
edition = "2018"
......
[package]
name = "polkadot-erasure-coding"
version = "0.8.3"
version = "0.8.4"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
......
[package]
name = "polkadot-network"
version = "0.8.3"
version = "0.8.4"
authors = ["Parity Technologies <admin@parity.io>"]
description = "Polkadot-specific networking protocol"
edition = "2018"
......
[package]
name = "polkadot-network-test"
version = "0.8.3"
version = "0.8.4"
license = "GPL-3.0"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
......
[package]
name = "polkadot-parachain"
version = "0.8.3"
version = "0.8.4"
authors = ["Parity Technologies <admin@parity.io>"]
description = "Types and utilities for creating and working with parachains"
edition = "2018"
......
[package]
name = "test-parachain-adder"
version = "0.8.3"
version = "0.8.4"
authors = ["Parity Technologies <admin@parity.io>"]
description = "Test parachain which adds to a number as its state transition"
edition = "2018"
......
[package]
name = "test-parachain-halt"
version = "0.8.3"
version = "0.8.4"
authors = ["Parity Technologies <admin@parity.io>"]
description = "Test parachain which executes forever"
edition = "2018"
......
[package]
name = "polkadot-primitives"
version = "0.8.3"
version = "0.8.4"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
......
[package]
name = "polkadot-rpc"
version = "0.8.3"
version = "0.8.4"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
......
[package]
name = "polkadot-runtime-common"
version = "0.8.3"
version = "0.8.4"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
......
[package]
name = "kusama-runtime"
version = "0.8.3"
version = "0.8.4"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
build = "build.rs"
......@@ -46,6 +46,7 @@ identity = { package = "pallet-identity", git = "https://github.com/paritytech/s
im-online = { package = "pallet-im-online", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
indices = { package = "pallet-indices", 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 }
multisig = { package = "pallet-multisig", 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 }
......@@ -118,6 +119,7 @@ std = [
"im-online/std",
"indices/std",
"membership/std",
"multisig/std",
"nicks/std",
"offences/std",
"proxy/std",
......
......@@ -84,7 +84,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("kusama"),
impl_name: create_runtime_str!("parity-kusama"),
authoring_version: 2,
spec_version: 2000,
spec_version: 2004,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 1,
......@@ -100,12 +100,14 @@ pub fn native_version() -> NativeVersion {
}
/// Avoid processing transactions from slots and parachain registrar.
pub struct IsCallable;
impl Filter<Call> for IsCallable {
pub struct BaseFilter;
impl Filter<Call> for BaseFilter {
fn filter(call: &Call) -> bool {
!matches!(call, Call::Slots(_) | Call::Registrar(_))
}
}
pub struct IsCallable;
frame_support::impl_filter_stack!(IsCallable, BaseFilter, Call, is_callable);
parameter_types! {
pub const Version: RuntimeVersion = VERSION;
......@@ -688,20 +690,26 @@ impl identity::Trait for Runtime {
type ForceOrigin = collective::EnsureProportionMoreThan<_1, _2, AccountId, CouncilCollective>;
}
impl utility::Trait for Runtime {
type Event = Event;
type Call = Call;
type IsCallable = IsCallable;
}
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 DepositBase: Balance = deposit(1, 88);
// Additional storage item size of 32 bytes.
pub const MultisigDepositFactor: Balance = 5 * CENTS;
pub const DepositFactor: Balance = deposit(0, 32);
pub const MaxSignatories: u16 = 100;
}
impl utility::Trait for Runtime {
impl multisig::Trait for Runtime {
type Event = Event;
type Call = Call;
type Currency = Balances;
type MultisigDepositBase = MultisigDepositBase;
type MultisigDepositFactor = MultisigDepositFactor;
type DepositBase = DepositBase;
type DepositFactor = DepositFactor;
type MaxSignatories = MaxSignatories;
type IsCallable = IsCallable;
}
......@@ -783,16 +791,29 @@ impl InstanceFilter<Call> for ProxyType {
fn filter(&self, c: &Call) -> bool {
match self {
ProxyType::Any => true,
ProxyType::NonTransfer => !matches!(c,
Call::Balances(..) | 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(..)
| Call::Utility(utility::Call::batch(..))
| Call::Utility(utility::Call::as_limited_sub(..))
),
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(..) | Call::Utility(utility::Call::batch(..))
| Call::Utility(utility::Call::as_limited_sub(..))
),
ProxyType::Staking => matches!(c, Call::Staking(..)),
}
}
fn is_superset(&self, o: &Self) -> bool {
match (self, o) {
(x, y) if x == y => true,
(ProxyType::Any, _) => true,
(_, ProxyType::Any) => false,
(ProxyType::NonTransfer, _) => true,
_ => false,
}
}
}
......@@ -856,7 +877,7 @@ construct_runtime! {
Registrar: registrar::{Module, Call, Storage, Event, Config<T>},
// Utility module.
Utility: utility::{Module, Call, Storage, Event<T>},
Utility: utility::{Module, Call, Event},
// Less simple identity module.
Identity: identity::{Module, Call, Storage, Event<T>},
......@@ -874,7 +895,10 @@ construct_runtime! {
Scheduler: scheduler::{Module, Call, Storage, Event<T>},
// Proxy module. Late addition.
Proxy: proxy::{Module, Call, Storage, Event<T>}
Proxy: proxy::{Module, Call, Storage, Event<T>},
// Multisig module. Late addition.
Multisig: multisig::{Module, Call, Storage, Event<T>},
}
}
......
[package]
name = "polkadot-runtime"
version = "0.8.3"
version = "0.8.4"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
build = "build.rs"
......@@ -45,6 +45,7 @@ identity = { package = "pallet-identity", git = "https://github.com/paritytech/s
im-online = { package = "pallet-im-online", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
indices = { package = "pallet-indices", 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 }
multisig = { package = "pallet-multisig", 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 }
......@@ -115,6 +116,7 @@ std = [
"im-online/std",
"indices/std",
"membership/std",
"multisig/std",
"nicks/std",
"offences/std",
"proxy/std",
......
......@@ -89,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: 3,
spec_version: 4,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 0,
......@@ -104,8 +104,8 @@ pub fn native_version() -> NativeVersion {
}
}
pub struct IsCallable;
impl Filter<Call> for IsCallable {
pub struct BaseFilter;
impl Filter<Call> for BaseFilter {
fn filter(call: &Call) -> bool {
match call {
Call::Parachains(parachains::Call::set_heads(..)) => true,
......@@ -127,11 +127,13 @@ 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::Proxy(_) =>
Call::Identity(_) | Call::Proxy(_) | Call::Multisig(_) =>
true,
}
}
}
pub struct IsCallable;
frame_support::impl_filter_stack!(IsCallable, BaseFilter, Call, is_callable);
parameter_types! {
pub const Version: RuntimeVersion = VERSION;
......@@ -720,20 +722,26 @@ impl vesting::Trait for Runtime {
type MinVestedTransfer = MinVestedTransfer;
}
impl utility::Trait for Runtime {
type Event = Event;
type Call = Call;
type IsCallable = IsCallable;
}
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 DepositBase: Balance = deposit(1, 88);
// Additional storage item size of 32 bytes.
pub const MultisigDepositFactor: Balance = 5 * CENTS;
pub const DepositFactor: Balance = deposit(0, 32);
pub const MaxSignatories: u16 = 100;
}
impl utility::Trait for Runtime {
impl multisig::Trait for Runtime {
type Event = Event;
type Call = Call;
type Currency = Balances;
type MultisigDepositBase = MultisigDepositBase;
type MultisigDepositFactor = MultisigDepositFactor;
type DepositBase = DepositBase;
type DepositFactor = DepositFactor;
type MaxSignatories = MaxSignatories;
type IsCallable = IsCallable;
}
......@@ -758,6 +766,7 @@ pub enum ProxyType {
NonTransfer,
Governance,
Staking,
SudoBalances,
}
impl Default for ProxyType { fn default() -> Self { Self::Any } }
impl InstanceFilter<Call> for ProxyType {
......@@ -765,15 +774,31 @@ impl InstanceFilter<Call> for ProxyType {
match self {
ProxyType::Any => true,
ProxyType::NonTransfer => !matches!(c,
Call::Balances(..) | Call::Utility(..)
| Call::Vesting(vesting::Call::vested_transfer(..))
Call::Balances(..) | 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(..)
| Call::Utility(utility::Call::batch(..))
| Call::Utility(utility::Call::as_limited_sub(..))
),
ProxyType::Staking => matches!(c,
Call::Staking(..) | Call::Utility(utility::Call::batch(..))
| Call::Utility(utility::Call::as_limited_sub(..))
),
ProxyType::SudoBalances => matches!(c,
Call::Sudo(sudo::Call::sudo(x)) if matches!(x.as_ref(), &Call::Balances(..))
),
ProxyType::Staking => matches!(c, Call::Staking(..)),
}
}
fn is_superset(&self, o: &Self) -> bool {
match (self, o) {
(x, y) if x == y => true,
(ProxyType::Any, _) => true,
(_, ProxyType::Any) => false,
(ProxyType::NonTransfer, _) => true,
_ => false,
}
}
}
......@@ -841,7 +866,7 @@ construct_runtime! {
// Vesting. Usable initially, but removed once all vesting is finished.
Vesting: vesting::{Module, Call, Storage, Event<T>, Config<T>},
// Cunning utilities. Usable initially.
Utility: utility::{Module, Call, Storage, Event<T>},
Utility: utility::{Module, Call, Event},
// Sudo. Last module. Usable initially, but removed once governance enabled.
Sudo: sudo::{Module, Call, Storage, Config<T>, Event<T>},
......@@ -850,7 +875,10 @@ construct_runtime! {
Identity: identity::{Module, Call, Storage, Event<T>},
// Proxy module. Late addition.
Proxy: proxy::{Module, Call, Storage, Event<T>}
Proxy: proxy::{Module, Call, Storage, Event<T>},
// Multisig dispatch. Late addition.
Multisig: multisig::{Module, Call, Storage, Event<T>},
}
}
......
[package]
name = "polkadot-test-runtime"
version = "0.8.3"
version = "0.8.4"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
build = "build.rs"
......
[package]
name = "westend-runtime"
version = "0.8.3"
version = "0.8.4"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
build = "build.rs"
......@@ -46,6 +46,7 @@ identity = { package = "pallet-identity", git = "https://github.com/paritytech/s
im-online = { package = "pallet-im-online", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
indices = { package = "pallet-indices", 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 }
multisig = { package = "pallet-multisig", 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 }
......@@ -121,6 +122,7 @@ std = [
"im-online/std",
"indices/std",
"membership/std",
"multisig/std",
"nicks/std",
"offences/std",
"proxy/std",
......
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