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

feat: Add proxy pallet for Supernode staking #213

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
25 changes: 21 additions & 4 deletions Cargo.lock

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

6 changes: 3 additions & 3 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ authors = ['MXC Foundation gGmbH <https://t.me/mxcfoundation>', 'Luke Schoen <lu
build = 'build.rs'
edition = '2018'
name = 'datahighway'
version = '3.0.5'
version = '3.0.6'

[[bin]]
name = 'datahighway'
Expand All @@ -22,12 +22,12 @@ structopt = '0.3.8'
hex-literal = '0.3.1'

# local node-specific dependencies
datahighway-runtime = { version = '3.0.5', path = '../runtime' }
datahighway-runtime = { version = '3.0.6', path = '../runtime' }

# Substrate dependencies
frame-benchmarking = '3.1.0'
frame-benchmarking-cli = '3.0.0'
module-primitives = { version = '3.0.5', default-features = false, path = '../pallets/primitives' }
module-primitives = { version = '3.0.6', default-features = false, path = '../pallets/primitives' }
pallet-authority-discovery = '3.0.0'
pallet-democracy = '3.0.0'
pallet-im-online = '3.0.0'
Expand Down
4 changes: 2 additions & 2 deletions pallets/mining/eligibility/proxy/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "mining-eligibility-proxy"
version = "3.0.5"
version = "3.0.6"
authors = ["Luke Schoen"]
edition = "2018"

Expand Down Expand Up @@ -31,7 +31,7 @@ std = [
codec = { version = '2.0.0', package = 'parity-scale-codec', default-features = false, features = ['derive'] }
frame-support = { version = '3.0.0', default-features = false }
frame-system = { version = '3.0.0', default-features = false }
module-primitives = { version = '3.0.5', default-features = false, path = '../../../primitives' }
module-primitives = { version = '3.0.6', default-features = false, path = '../../../primitives' }
safe-mix = { version = '1.0.0', default-features = false }
pallet-balances = { version = '3.0.0', default-features = false }
pallet-randomness-collective-flip = { version = '3.0.0', default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion pallets/primitives/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = 'module-primitives'
version = '3.0.5'
version = '3.0.6'
authors = ['Laminar Developers <hello@laminar.one>', 'MXC Foundation GmbH <https://t.me/mxcfoundation>', 'Luke Schoen']
edition = '2018'

Expand Down
4 changes: 3 additions & 1 deletion runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
authors = ['MXC Foundation gGmbH <https://t.me/mxcfoundation>', 'Luke Schoen <luke@mxc.org>', 'Ilya Beregovskiy <ilya@mxc.org>']
edition = '2018'
name = 'datahighway-runtime'
version = '3.0.5'
version = '3.0.6'

[package.metadata.docs.rs]
targets = ['x86_64-unknown-linux-gnu']
Expand Down Expand Up @@ -30,6 +30,7 @@ pallet-membership = { version = '3.0.0', default-features = false }
pallet-multisig = { version = '3.0.0', default-features = false }
pallet-offences = { version = '3.0.0', default-features = false }
pallet-randomness-collective-flip = { version = '3.0.0', default-features = false }
pallet-proxy = { version = '3.0.0', default-features = false }
pallet-scheduler = { version = '3.0.0', default-features = false }
pallet-session = { version = '3.0.0', default-features = false }
pallet-staking = { version = '3.0.0', default-features = false }
Expand Down Expand Up @@ -115,6 +116,7 @@ std = [
'pallet-membership/std',
'pallet-multisig/std',
'pallet-offences/std',
'pallet-proxy/std',
'pallet-tips/std',
'pallet-treasury/std',
'pallet-randomness-collective-flip/std',
Expand Down
73 changes: 72 additions & 1 deletion runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,11 @@ pub use frame_support::{
construct_runtime,
parameter_types,
debug,
RuntimeDebug,
traits::{
Currency,
Imbalance,
InstanceFilter,
Contains,
ContainsLengthBound,
OnUnbalanced,
Expand Down Expand Up @@ -197,7 +199,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("datahighway"),
impl_name: create_runtime_str!("datahighway"),
authoring_version: 2,
spec_version: 8,
spec_version: 9,
impl_version: 2,
apis: RUNTIME_API_VERSIONS,
transaction_version: 2,
Expand Down Expand Up @@ -316,6 +318,74 @@ impl pallet_multisig::Config for Runtime {
type WeightInfo = pallet_multisig::weights::SubstrateWeight<Runtime>;
}

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;
pub const AnnouncementDepositBase: Balance = deposit(1, 8);
pub const AnnouncementDepositFactor: Balance = deposit(0, 66);
pub const MaxPending: 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::Vesting(pallet_vesting::Call::vested_transfer(..)) |
Call::Indices(pallet_indices::Call::transfer(..))
),
ProxyType::Governance => matches!(
c,
Call::Democracy(..) |
Call::Council(..) |
// Call::Society(..) |
Call::TechnicalCommittee(..) |
Call::Elections(..) |
Call::Treasury(..)
),
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,
}
}
}

impl pallet_proxy::Config for Runtime {
type Event = Event;
type Call = Call;
type Currency = Balances;
type ProxyType = ProxyType;
type ProxyDepositBase = ProxyDepositBase;
type ProxyDepositFactor = ProxyDepositFactor;
type MaxProxies = MaxProxies;
type WeightInfo = pallet_proxy::weights::SubstrateWeight<Runtime>;
type MaxPending = MaxPending;
type CallHasher = BlakeTwo256;
type AnnouncementDepositBase = AnnouncementDepositBase;
type AnnouncementDepositFactor = AnnouncementDepositFactor;
}

parameter_types! {
pub MaximumSchedulerWeight: Weight = Perbill::from_percent(80) *
RuntimeBlockWeights::get().max_block;
Expand Down Expand Up @@ -1113,6 +1183,7 @@ construct_runtime!(
RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Module, Call, Storage},
Identity: pallet_identity::{Module, Call, Storage, Event<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>},
Bounties: pallet_bounties::{Module, Call, Storage, Event<T>},
Tips: pallet_tips::{Module, Call, Storage, Event<T>},
Expand Down