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

Democracy MVP #206

Merged
merged 19 commits into from
Feb 8, 2021
Merged
Show file tree
Hide file tree
Changes from 17 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
2 changes: 2 additions & 0 deletions Cargo.lock

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

11 changes: 7 additions & 4 deletions node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@

use cumulus_primitives::ParaId;
use moonbeam_runtime::{
AccountId, BalancesConfig, EVMConfig, EthereumChainIdConfig, EthereumConfig, GenesisConfig,
ParachainInfoConfig, StakeConfig, SudoConfig, SystemConfig, GLMR, WASM_BINARY,
AccountId, BalancesConfig, DemocracyConfig, EVMConfig, EthereumChainIdConfig, EthereumConfig,
GenesisConfig, ParachainInfoConfig, SchedulerConfig, StakeConfig, SudoConfig, SystemConfig,
GLMR, WASM_BINARY,
};
use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup};
use sc_service::ChainType;
use serde::{Deserialize, Serialize};
use std::collections::BTreeMap;
use std::str::FromStr;
use std::{collections::BTreeMap, str::FromStr};

/// Specialized `ChainSpec`. This is a specialization of the general Substrate ChainSpec type.
pub type ChainSpec = sc_service::GenericChainSpec<GenesisConfig, Extensions>;
Expand Down Expand Up @@ -125,12 +125,15 @@ fn testnet_genesis(
accounts: BTreeMap::new(),
}),
pallet_ethereum: Some(EthereumConfig {}),

stake: Some(StakeConfig {
stakers: endowed_accounts
.iter()
.cloned()
.map(|k| (k, None, 100_000 * GLMR))
.collect(),
}),
pallet_democracy: Some(DemocracyConfig {}),
pallet_scheduler: Some(SchedulerConfig {}),
}
}
5 changes: 5 additions & 0 deletions runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ pallet-grandpa = { default-features = false, git = "https://github.com/paritytec
pallet-ethereum = { default-features = false, git = "https://github.com/purestake/frontier", branch = "v0.5-hotfixes" }
fp-rpc = { default-features = false, git = "https://github.com/purestake/frontier", branch = "v0.5-hotfixes" }

pallet-democracy = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
pallet-scheduler = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }

moonbeam-rpc-primitives-txpool = { path = "../primitives/rpc/txpool", default-features = false }

# Cumulus dependencies
Expand Down Expand Up @@ -101,6 +104,8 @@ std = [
"frame-system-rpc-runtime-api/std",
"pallet-transaction-payment-rpc-runtime-api/std",
"pallet-ethereum-chain-id/std",
"pallet-democracy/std",
"pallet-scheduler/std",
"author-inherent/std",
"parachain-info/std",
"cumulus-runtime/std",
Expand Down
64 changes: 64 additions & 0 deletions runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ pub use frame_support::{
weights::{constants::WEIGHT_PER_SECOND, IdentityFee, Weight},
ConsensusEngineId, StorageValue,
};
use frame_system::{EnsureNever, EnsureRoot, EnsureSigned};
use pallet_ethereum::Call::transact;
use pallet_evm::{
Account as EVMAccount, EnsureAddressNever, EnsureAddressSame, FeeCalculator,
Expand Down Expand Up @@ -260,6 +261,67 @@ impl pallet_evm::Config for Runtime {
type ChainId = EthereumChainId;
}

JoshOrndorff marked this conversation as resolved.
Show resolved Hide resolved
parameter_types! {
pub MaximumSchedulerWeight: Weight = Perbill::from_percent(80) * BlockWeights::get().max_block;
}

impl pallet_scheduler::Config for Runtime {
type Event = Event;
type Origin = Origin;
type PalletsOrigin = OriginCaller;
type Call = Call;
type MaximumWeight = MaximumSchedulerWeight;
type ScheduleOrigin = EnsureRoot<AccountId>;
type MaxScheduledPerBlock = ();
type WeightInfo = ();
}

pub const BLOCKS_PER_DAY: BlockNumber = 24 * 60 * 10;

parameter_types! {
pub const LaunchPeriod: BlockNumber = BLOCKS_PER_DAY;
pub const VotingPeriod: BlockNumber = 5 * BLOCKS_PER_DAY;
pub const FastTrackVotingPeriod: BlockNumber = BLOCKS_PER_DAY;
pub const EnactmentPeriod: BlockNumber = BLOCKS_PER_DAY;
pub const CooloffPeriod: BlockNumber = 7 * BLOCKS_PER_DAY;
pub const MinimumDeposit: Balance = 4 * GLMR;
pub const MaxVotes: u32 = 100;
pub const MaxProposals: u32 = 100;
pub const PreimageByteDeposit: Balance = GLMR / 1_000;
pub const InstantAllowed: bool = false;
}

// todo : ensure better origins
impl pallet_democracy::Config for Runtime {
type Proposal = Call;
type Event = Event;
type Currency = Balances;
type EnactmentPeriod = EnactmentPeriod;
type LaunchPeriod = LaunchPeriod;
type VotingPeriod = VotingPeriod;
type FastTrackVotingPeriod = FastTrackVotingPeriod;
type MinimumDeposit = MinimumDeposit;
type ExternalOrigin = EnsureRoot<AccountId>;
type ExternalMajorityOrigin = EnsureRoot<AccountId>;
type ExternalDefaultOrigin = EnsureRoot<AccountId>;
type FastTrackOrigin = EnsureRoot<AccountId>;
type CancellationOrigin = EnsureRoot<AccountId>;
type BlacklistOrigin = EnsureRoot<AccountId>;
type CancelProposalOrigin = EnsureRoot<AccountId>;
type VetoOrigin = EnsureNever<AccountId>; // (root not possible)
type CooloffPeriod = CooloffPeriod;
type PreimageByteDeposit = PreimageByteDeposit;
type Slash = ();
type InstantOrigin = EnsureRoot<AccountId>;
type InstantAllowed = InstantAllowed;
type Scheduler = Scheduler;
type MaxVotes = MaxVotes;
type OperationalPreimageOrigin = EnsureSigned<AccountId>;
type PalletsOrigin = OriginCaller;
type WeightInfo = ();
type MaxProposals = MaxProposals;
}

pub struct TransactionConverter;

impl fp_rpc::ConvertTransaction<UncheckedExtrinsic> for TransactionConverter {
Expand Down Expand Up @@ -355,6 +417,8 @@ construct_runtime! {
Ethereum: pallet_ethereum::{Module, Call, Storage, Event, Config, ValidateUnsigned},
Stake: stake::{Module, Call, Storage, Event<T>, Config<T>},
AuthorInherent: author_inherent::{Module, Call, Storage, Inherent},
Scheduler: pallet_scheduler::{Module, Storage, Config, Event<T>, Call},
Democracy: pallet_democracy::{Module, Storage, Config, Event<T>, Call},
}
}

Expand Down