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

Introduce stacked filtering #6273

Merged
merged 38 commits into from
Jun 8, 2020
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
13e9552
Introduce stacked filtering.
gavofyork Jun 6, 2020
d1645cc
Benchmarks
gavofyork Jun 6, 2020
7c06fdc
Remove unneeded crates
gavofyork Jun 6, 2020
ebc8c55
Fix proxy type's permissiveness checks.
gavofyork Jun 6, 2020
705cf68
Repot multisig to make utility stateless.
gavofyork Jun 6, 2020
9896ea8
Repot filter stack impl into macro
gavofyork Jun 6, 2020
39b745a
Fix wasm build
gavofyork Jun 6, 2020
1d65cc0
Tests
gavofyork Jun 6, 2020
0f3afee
Final test.
gavofyork Jun 6, 2020
16883b2
Tests for the macro
gavofyork Jun 6, 2020
55aa221
Fix test
gavofyork Jun 7, 2020
a588347
Line width
gavofyork Jun 7, 2020
09f5e9c
Merge remote-tracking branch 'origin/master' into gav-filter-stack
gavofyork Jun 7, 2020
6432f1e
Fix
gavofyork Jun 7, 2020
d8b7bc8
Update frame/multisig/src/benchmarking.rs
gavofyork Jun 7, 2020
284a2a9
Update primitives/std/with_std.rs
gavofyork Jun 7, 2020
a789ba2
Grumble
gavofyork Jun 7, 2020
e377032
Update frame/support/src/traits.rs
gavofyork Jun 7, 2020
f9cbaa1
Update frame/support/src/traits.rs
gavofyork Jun 7, 2020
c512330
Update frame/support/src/traits.rs
gavofyork Jun 7, 2020
b167261
Merge remote-tracking branch 'origin/gav-filter-stack' into gav-filte…
gavofyork Jun 7, 2020
b643318
Update frame/support/src/traits.rs
gavofyork Jun 7, 2020
23530fb
Update frame/support/src/traits.rs
gavofyork Jun 7, 2020
3e9dfbc
Update frame/multisig/src/tests.rs
gavofyork Jun 7, 2020
8928f29
Update frame/multisig/src/tests.rs
gavofyork Jun 7, 2020
a19a663
Grumble
gavofyork Jun 7, 2020
3e1f6a0
Merge remote-tracking branch 'origin/gav-filter-stack' into gav-filte…
gavofyork Jun 7, 2020
8ffd728
Migration
gavofyork Jun 8, 2020
ba9281c
Grumble
gavofyork Jun 8, 2020
2c5afd7
Comments
gavofyork Jun 8, 2020
6ca10d3
Migration
gavofyork Jun 8, 2020
936804f
Fix
gavofyork Jun 8, 2020
41b0ebe
Fix
gavofyork Jun 8, 2020
738b174
Line width
gavofyork Jun 8, 2020
a5b9aa1
Allow unused
gavofyork Jun 8, 2020
08a8149
Update frame/multisig/src/lib.rs
gavofyork Jun 8, 2020
69965e9
Fix up grumble.
gavofyork Jun 8, 2020
73e1990
Remove Utility constraint in NonTransfer
gavofyork Jun 8, 2020
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
18 changes: 18 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ members = [
"frame/indices",
"frame/membership",
"frame/metadata",
"frame/multisig",
"frame/nicks",
"frame/offences",
"frame/proxy",
Expand Down
3 changes: 3 additions & 0 deletions bin/node/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ pallet-im-online = { version = "2.0.0-rc2", default-features = false, path = "..
pallet-indices = { version = "2.0.0-rc2", default-features = false, path = "../../../frame/indices" }
pallet-identity = { version = "2.0.0-rc2", default-features = false, path = "../../../frame/identity" }
pallet-membership = { version = "2.0.0-rc2", default-features = false, path = "../../../frame/membership" }
pallet-multisig = { version = "2.0.0-rc2", default-features = false, path = "../../../frame/multisig" }
pallet-offences = { version = "2.0.0-rc2", default-features = false, path = "../../../frame/offences" }
pallet-offences-benchmarking = { version = "2.0.0-rc2", path = "../../../frame/offences/benchmarking", default-features = false, optional = true }
pallet-proxy = { version = "2.0.0-rc2", default-features = false, path = "../../../frame/proxy" }
Expand Down Expand Up @@ -108,6 +109,7 @@ std = [
"pallet-indices/std",
"sp-inherents/std",
"pallet-membership/std",
"pallet-multisig/std",
"pallet-identity/std",
"node-primitives/std",
"sp-offchain/std",
Expand Down Expand Up @@ -151,6 +153,7 @@ runtime-benchmarks = [
"pallet-elections-phragmen/runtime-benchmarks",
"pallet-identity/runtime-benchmarks",
"pallet-im-online/runtime-benchmarks",
"pallet-multisig/runtime-benchmarks",
"pallet-proxy/runtime-benchmarks",
"pallet-scheduler/runtime-benchmarks",
"pallet-society/runtime-benchmarks",
Expand Down
4 changes: 4 additions & 0 deletions bin/node/runtime/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ pub mod currency {
pub const MILLICENTS: Balance = 1_000_000_000;
pub const CENTS: Balance = 1_000 * MILLICENTS; // assume this is worth about a cent.
pub const DOLLARS: Balance = 100 * CENTS;

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

/// Time.
Expand Down
57 changes: 41 additions & 16 deletions bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#![recursion_limit="256"]

use sp_std::prelude::*;

use frame_support::{
construct_runtime, parameter_types, debug, RuntimeDebug,
weights::{
Expand All @@ -31,6 +32,7 @@ use frame_support::{
},
traits::{Currency, Imbalance, KeyOwnerProofSystem, OnUnbalanced, Randomness, LockIdentifier},
};
use frame_support::traits::{Filter, InstanceFilter};
use codec::{Encode, Decode};
use sp_core::{
crypto::KeyTypeId,
Expand Down Expand Up @@ -79,7 +81,6 @@ use impls::{CurrencyToVoteHandler, Author, TargetedFeeAdjustment};
/// Constant values used within the runtime.
pub mod constants;
use constants::{time::*, currency::*};
use frame_support::traits::InstanceFilter;

// Make the WASM binary available.
#[cfg(feature = "std")]
Expand Down Expand Up @@ -111,6 +112,15 @@ pub fn native_version() -> NativeVersion {

type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;

pub struct BaseFilter;
impl Filter<Call> for BaseFilter {
fn filter(_call: &Call) -> bool {
true
}
}
pub struct IsCallable;
frame_support::impl_filter_stack!(crate::IsCallable, crate::BaseFilter, crate::Call, is_callable);

pub struct DealWithFees;
impl OnUnbalanced<NegativeImbalance> for DealWithFees {
fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item=NegativeImbalance>) {
Expand Down Expand Up @@ -169,24 +179,28 @@ impl frame_system::Trait for Runtime {
type OnKilledAccount = ();
}

const fn deposit(items: u32, bytes: u32) -> Balance { items as Balance * 15 * CENTS + (bytes as Balance) * 6 * CENTS }
impl pallet_utility::Trait for Runtime {
type Event = Event;
type Call = Call;
type IsCallable = IsCallable;
}

parameter_types! {
// One storage item; key size is 32; value is size 4+4+16+32 bytes = 56 bytes.
pub const MultisigDepositBase: Balance = deposit(1, 88);
pub const DepositBase: Balance = deposit(1, 88);
// Additional storage item size of 32 bytes.
pub const MultisigDepositFactor: Balance = deposit(0, 32);
pub const DepositFactor: Balance = deposit(0, 32);
pub const MaxSignatories: u16 = 100;
}

impl pallet_utility::Trait for Runtime {
impl pallet_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 = ();
type IsCallable = IsCallable;
}

parameter_types! {
Expand Down Expand Up @@ -222,13 +236,22 @@ impl InstanceFilter<Call> for ProxyType {
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,
gavofyork marked this conversation as resolved.
Show resolved Hide resolved
gavofyork marked this conversation as resolved.
Show resolved Hide resolved
_ => false,
}
}
}

impl pallet_proxy::Trait for Runtime {
type Event = Event;
type Call = Call;
type Currency = Balances;
type IsCallable = ();
type IsCallable = IsCallable;
type ProxyType = ProxyType;
type ProxyDepositBase = ProxyDepositBase;
type ProxyDepositFactor = ProxyDepositFactor;
Expand Down Expand Up @@ -263,9 +286,9 @@ parameter_types! {

impl pallet_indices::Trait for Runtime {
type AccountIndex = AccountIndex;
type Event = Event;
type Currency = Balances;
type Deposit = IndexDeposit;
type Event = Event;
}

parameter_types! {
Expand Down Expand Up @@ -341,11 +364,11 @@ impl pallet_session::Trait for Runtime {
type ValidatorId = <Self as frame_system::Trait>::AccountId;
type ValidatorIdOf = pallet_staking::StashOf<Self>;
type ShouldEndSession = Babe;
type NextSessionRotation = Babe;
type SessionManager = pallet_session::historical::NoteHistoricalRoot<Self, Staking>;
type SessionHandler = <SessionKeys as OpaqueKeys>::KeyTypeIdProviders;
type Keys = SessionKeys;
type DisabledValidatorsThreshold = DisabledValidatorsThreshold;
type NextSessionRotation = Babe;
}

impl pallet_session::historical::Trait for Runtime {
Expand Down Expand Up @@ -474,8 +497,8 @@ parameter_types! {
const_assert!(DesiredMembers::get() <= pallet_collective::MAX_MEMBERS);

impl pallet_elections_phragmen::Trait for Runtime {
type ModuleId = ElectionsPhragmenModuleId;
type Event = Event;
type ModuleId = ElectionsPhragmenModuleId;
type Currency = Balances;
type ChangeMembers = Council;
// NOTE: this implies that council's genesis members cannot be set directly and must come from
Expand Down Expand Up @@ -530,6 +553,7 @@ parameter_types! {
}

impl pallet_treasury::Trait for Runtime {
type ModuleId = TreasuryModuleId;
type Currency = Balances;
type ApproveOrigin = pallet_collective::EnsureMembers<_4, AccountId, CouncilCollective>;
type RejectOrigin = pallet_collective::EnsureMembers<_2, AccountId, CouncilCollective>;
Expand All @@ -544,7 +568,6 @@ impl pallet_treasury::Trait for Runtime {
type ProposalBondMinimum = ProposalBondMinimum;
type SpendPeriod = SpendPeriod;
type Burn = Burn;
type ModuleId = TreasuryModuleId;
}

parameter_types! {
Expand Down Expand Up @@ -635,8 +658,8 @@ impl frame_system::offchain::SigningTypes for Runtime {
impl<C> frame_system::offchain::SendTransactionTypes<C> for Runtime where
Call: From<C>,
{
type OverarchingCall = Call;
type Extrinsic = UncheckedExtrinsic;
type OverarchingCall = Call;
}

impl pallet_im_online::Trait for Runtime {
Expand Down Expand Up @@ -746,6 +769,7 @@ parameter_types! {

impl pallet_society::Trait for Runtime {
type Event = Event;
type ModuleId = SocietyModuleId;
type Currency = Balances;
type Randomness = RandomnessCollectiveFlip;
type CandidateDeposit = CandidateDeposit;
Expand All @@ -758,7 +782,6 @@ impl pallet_society::Trait for Runtime {
type FounderSetOrigin = pallet_collective::EnsureProportionMoreThan<_1, _2, AccountId, CouncilCollective>;
type SuspensionJudgementOrigin = pallet_society::EnsureFounder<Runtime>;
type ChallengePeriod = ChallengePeriod;
type ModuleId = SocietyModuleId;
}

parameter_types! {
Expand All @@ -779,7 +802,7 @@ construct_runtime!(
UncheckedExtrinsic = UncheckedExtrinsic
{
System: frame_system::{Module, Call, Config, Storage, Event<T>},
Utility: pallet_utility::{Module, Call, Storage, Event<T>},
Utility: pallet_utility::{Module, Call, Event},
Babe: pallet_babe::{Module, Call, Storage, Config, Inherent(Timestamp)},
Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent},
Authorship: pallet_authorship::{Module, Call, Storage, Inherent},
Expand Down Expand Up @@ -809,6 +832,7 @@ construct_runtime!(
Vesting: pallet_vesting::{Module, Call, Storage, Event<T>, Config<T>},
Scheduler: pallet_scheduler::{Module, Call, Storage, Event<T>},
Proxy: pallet_proxy::{Module, Call, Storage, Event<T>},
Multisig: pallet_multisig::{Module, Call, Storage, Event<T>},
}
);

Expand Down Expand Up @@ -1058,6 +1082,7 @@ impl_runtime_apis! {
add_benchmark!(params, batches, b"elections", Elections);
add_benchmark!(params, batches, b"identity", Identity);
add_benchmark!(params, batches, b"im-online", ImOnline);
add_benchmark!(params, batches, b"multisig", Multisig);
add_benchmark!(params, batches, b"offences", OffencesBench::<Runtime>);
add_benchmark!(params, batches, b"proxy", Proxy);
add_benchmark!(params, batches, b"scheduler", Scheduler);
Expand Down
2 changes: 1 addition & 1 deletion frame/balances/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ impl<T: Trait<I>, I: Instance> Module<T, I> {
///
/// NOTE: LOW-LEVEL: This will not attempt to maintain total issuance. It is expected that
/// the caller will do this.
fn mutate_account<R>(
pub fn mutate_account<R>(
who: &T::AccountId,
f: impl FnOnce(&mut AccountData<T::Balance>) -> R
) -> R {
Expand Down
44 changes: 44 additions & 0 deletions frame/multisig/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
[package]
name = "pallet-multisig"
version = "2.0.0-rc2"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
license = "Apache-2.0"
homepage = "https://substrate.dev"
repository = "https://github.com/paritytech/substrate/"
description = "FRAME multi-signature dispatch pallet"

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
serde = { version = "1.0.101", optional = true }
codec = { package = "parity-scale-codec", version = "1.3.0", default-features = false }
frame-support = { version = "2.0.0-rc2", default-features = false, path = "../support" }
frame-system = { version = "2.0.0-rc2", default-features = false, path = "../system" }
sp-core = { version = "2.0.0-rc2", default-features = false, path = "../../primitives/core" }
sp-runtime = { version = "2.0.0-rc2", default-features = false, path = "../../primitives/runtime" }
sp-std = { version = "2.0.0-rc2", default-features = false, path = "../../primitives/std" }
sp-io = { version = "2.0.0-rc2", default-features = false, path = "../../primitives/io" }

frame-benchmarking = { version = "2.0.0-rc2", default-features = false, path = "../benchmarking", optional = true }

[dev-dependencies]
sp-core = { version = "2.0.0-rc2", path = "../../primitives/core" }
pallet-balances = { version = "2.0.0-rc2", path = "../balances" }

[features]
default = ["std"]
std = [
"serde",
"codec/std",
"sp-runtime/std",
"frame-support/std",
"frame-system/std",
"sp-io/std",
"sp-std/std"
]
runtime-benchmarks = [
"frame-benchmarking",
"frame-support/runtime-benchmarks",
]
Loading