From 3755474a2ff9cb0eab25241977f36ec0bbc22aa3 Mon Sep 17 00:00:00 2001 From: Oleg Kalenik Date: Wed, 12 Oct 2022 12:20:57 +0300 Subject: [PATCH 1/2] *added 'pallet-democracy' --- Cargo.lock | 17 +++++++++++ node/src/chain_spec.rs | 7 +++-- runtime/Cargo.toml | 3 ++ runtime/src/lib.rs | 68 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 92 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index faed2b9..b9615a2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3863,6 +3863,7 @@ dependencies = [ "pallet-contracts-primitives", "pallet-contracts-rpc-runtime-api", "pallet-conviction-voting", + "pallet-democracy", "pallet-election-provider-multi-phase", "pallet-grandpa", "pallet-im-online", @@ -4349,6 +4350,22 @@ dependencies = [ "sp-std", ] +[[package]] +name = "pallet-democracy" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.28#ce10b9f29353e89fc3e59d447041bb29622def3f" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "parity-scale-codec", + "scale-info", + "serde", + "sp-io", + "sp-runtime", + "sp-std", +] + [[package]] name = "pallet-election-provider-multi-phase" version = "4.0.0-dev" diff --git a/node/src/chain_spec.rs b/node/src/chain_spec.rs index 5964586..7386e59 100644 --- a/node/src/chain_spec.rs +++ b/node/src/chain_spec.rs @@ -1,8 +1,8 @@ use node_template_runtime::{ opaque::Block, wasm_binary_unwrap, AccountId, AuraConfig, AuthorityDiscoveryConfig, BabeConfig, - Balance, BalancesConfig, CouncilConfig, GenesisConfig, GrandpaConfig, ImOnlineConfig, - MaxNominations, NominationPoolsConfig, SessionConfig, SessionKeys, Signature, StakerStatus, - StakingConfig, SudoConfig, SystemConfig, TechnicalCommitteeConfig, DOLLARS, + Balance, BalancesConfig, CouncilConfig, DemocracyConfig, GenesisConfig, GrandpaConfig, + ImOnlineConfig, MaxNominations, NominationPoolsConfig, SessionConfig, SessionKeys, Signature, + StakerStatus, StakingConfig, SudoConfig, SystemConfig, TechnicalCommitteeConfig, DOLLARS, }; use pallet_im_online::sr25519::AuthorityId as ImOnlineId; use sc_chain_spec::ChainSpecExtension; @@ -257,6 +257,7 @@ pub fn testnet_genesis( phantom: Default::default(), }, assets: Default::default(), + democracy: DemocracyConfig::default(), transaction_payment: Default::default(), } } diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index 546a9ea..d05ee1f 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -57,6 +57,7 @@ pallet-contracts = { version = "4.0.0-dev", default-features = false, git = "htt pallet-contracts-primitives = { version = "6.0.0", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" } pallet-contracts-rpc-runtime-api = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" } pallet-conviction-voting = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" } +pallet-democracy = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" } pallet-election-provider-multi-phase = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" } pallet-im-online = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" } pallet-nicks = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" } @@ -113,6 +114,7 @@ std = [ "pallet-contracts-primitives/std", "pallet-contracts-rpc-runtime-api/std", "pallet-conviction-voting/std", + "pallet-democracy/std", "pallet-election-provider-multi-phase/std", "pallet-grandpa/std", "pallet-im-online/std", @@ -166,6 +168,7 @@ try-runtime = [ "pallet-assets/try-runtime", "pallet-aura/try-runtime", "pallet-balances/try-runtime", + "pallet-democracy/try-runtime", "pallet-grandpa/try-runtime", "pallet-randomness-collective-flip/try-runtime", "pallet-sudo/try-runtime", diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index c5a105a..c908993 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -995,6 +995,73 @@ impl pallet_asset_tx_payment::Config for Runtime { >; } +parameter_types! { + // One cent: $10,000 / MB + pub const PreimageByteDeposit: Balance = 1 * CENTS; +} + +parameter_types! { + pub const LaunchPeriod: BlockNumber = 28 * 24 * 60 * MINUTES; + pub const VotingPeriod: BlockNumber = 28 * 24 * 60 * MINUTES; + pub const FastTrackVotingPeriod: BlockNumber = 3 * 24 * 60 * MINUTES; + pub const MinimumDeposit: Balance = 100 * DOLLARS; + pub const EnactmentPeriod: BlockNumber = 30 * 24 * 60 * MINUTES; + pub const CooloffPeriod: BlockNumber = 28 * 24 * 60 * MINUTES; + pub const MaxProposals: u32 = 100; +} + +// TODO - Update settings +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 VoteLockingPeriod = EnactmentPeriod; // Same as EnactmentPeriod + type MinimumDeposit = MinimumDeposit; + /// A straight majority of the council can decide what their next motion is. + type ExternalOrigin = + pallet_collective::EnsureProportionAtLeast; + /// A super-majority can have the next scheduled referendum be a straight majority-carries vote. + type ExternalMajorityOrigin = + pallet_collective::EnsureProportionAtLeast; + /// A unanimous council can have the next scheduled referendum be a straight default-carries + /// (NTB) vote. + type ExternalDefaultOrigin = + pallet_collective::EnsureProportionAtLeast; + /// Two thirds of the technical committee can have an ExternalMajority/ExternalDefault vote + /// be tabled immediately and with a shorter voting/enactment period. + type FastTrackOrigin = + pallet_collective::EnsureProportionAtLeast; + type InstantOrigin = + pallet_collective::EnsureProportionAtLeast; + type InstantAllowed = frame_support::traits::ConstBool; + type FastTrackVotingPeriod = FastTrackVotingPeriod; + // To cancel a proposal which has been passed, 2/3 of the council must agree to it. + type CancellationOrigin = + pallet_collective::EnsureProportionAtLeast; + // To cancel a proposal before it has been passed, the technical committee must be unanimous or + // Root must agree. + type CancelProposalOrigin = EitherOfDiverse< + EnsureRoot, + pallet_collective::EnsureProportionAtLeast, + >; + type BlacklistOrigin = EnsureRoot; + // Any single technical committee member may veto a coming council proposal, however they can + // only do it once and it lasts only for the cool-off period. + type VetoOrigin = pallet_collective::EnsureMember; + type CooloffPeriod = CooloffPeriod; + type PreimageByteDeposit = PreimageByteDeposit; + type OperationalPreimageOrigin = pallet_collective::EnsureMember; + type Slash = Treasury; + type Scheduler = Scheduler; + type PalletsOrigin = OriginCaller; + type MaxVotes = ConstU32<100>; + type WeightInfo = pallet_democracy::weights::SubstrateWeight; + type MaxProposals = MaxProposals; +} + impl pallet_sudo::Config for Runtime { type Event = Event; type Call = Call; @@ -1062,6 +1129,7 @@ construct_runtime!( ConvictionVoting: pallet_conviction_voting, Assets: pallet_assets, AssetTxPayment: pallet_asset_tx_payment, + Democracy: pallet_democracy, } ); From 589705940df26335a5e02feff4b479864c632ae8 Mon Sep 17 00:00:00 2001 From: Oleg Kalenik Date: Wed, 12 Oct 2022 12:22:24 +0300 Subject: [PATCH 2/2] *re-arranged runtime cargo deps --- runtime/Cargo.toml | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index d05ee1f..d83e16e 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -50,7 +50,6 @@ pallet-babe = { version = "4.0.0-dev", default-features = false, git = "https:// pallet-bags-list = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" } pallet-balances = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" } pallet-bounties = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" } -pallet-grandpa = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" } pallet-child-bounties = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" } pallet-collective = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" } pallet-contracts = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" } @@ -59,11 +58,12 @@ pallet-contracts-rpc-runtime-api = { version = "4.0.0-dev", default-features = f pallet-conviction-voting = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" } pallet-democracy = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" } pallet-election-provider-multi-phase = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" } +pallet-grandpa = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" } pallet-im-online = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" } +pallet-membership = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" } pallet-nicks = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" } pallet-nomination-pools = { version = "1.0.0", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" } pallet-nomination-pools-runtime-api = { version = "1.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" } -pallet-membership = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" } pallet-offences = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" } pallet-randomness-collective-flip = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" } pallet-referenda = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" } @@ -118,21 +118,21 @@ std = [ "pallet-election-provider-multi-phase/std", "pallet-grandpa/std", "pallet-im-online/std", + "pallet-membership/std", + "pallet-nicks/std", "pallet-nomination-pools/std", "pallet-nomination-pools-runtime-api/std", - "pallet-membership/std", + "pallet-offences/std", "pallet-randomness-collective-flip/std", + "pallet-referenda/std", + "pallet-scheduler/std", + "pallet-session/std", + "pallet-staking/std", "pallet-sudo/std", "pallet-template/std", "pallet-timestamp/std", "pallet-transaction-payment-rpc-runtime-api/std", "pallet-transaction-payment/std", - "pallet-nicks/std", - "pallet-offences/std", - "pallet-referenda/std", - "pallet-scheduler/std", - "pallet-session/std", - "pallet-staking/std", "pallet-treasury/std", "scale-info/std", "sp-api/std", @@ -163,32 +163,32 @@ runtime-benchmarks = [ ] try-runtime = [ "frame-executive/try-runtime", - "frame-try-runtime", "frame-system/try-runtime", + "frame-try-runtime", "pallet-assets/try-runtime", "pallet-aura/try-runtime", - "pallet-balances/try-runtime", - "pallet-democracy/try-runtime", - "pallet-grandpa/try-runtime", - "pallet-randomness-collective-flip/try-runtime", - "pallet-sudo/try-runtime", - "pallet-template/try-runtime", - "pallet-timestamp/try-runtime", - "pallet-transaction-payment/try-runtime", "pallet-authority-discovery/try-runtime", "pallet-authorship/try-runtime", "pallet-babe/try-runtime", "pallet-bags-list/try-runtime", + "pallet-balances/try-runtime", "pallet-bounties/try-runtime", "pallet-child-bounties/try-runtime", "pallet-collective/try-runtime", "pallet-conviction-voting/try-runtime", + "pallet-democracy/try-runtime", "pallet-election-provider-multi-phase/try-runtime", + "pallet-grandpa/try-runtime", "pallet-im-online/try-runtime", "pallet-membership/try-runtime", "pallet-offences/try-runtime", + "pallet-randomness-collective-flip/try-runtime", "pallet-referenda/try-runtime", "pallet-session/try-runtime", "pallet-staking/try-runtime", + "pallet-sudo/try-runtime", + "pallet-template/try-runtime", + "pallet-timestamp/try-runtime", + "pallet-transaction-payment/try-runtime", "pallet-treasury/try-runtime", ]