From cec5817853729677dbd770a22954ca6c83588156 Mon Sep 17 00:00:00 2001 From: Ayush Kumar Mishra Date: Fri, 8 Jan 2021 07:14:20 +0530 Subject: [PATCH 01/20] Added pallet-collective in cargo.toml --- runtime/testnet/Cargo.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/runtime/testnet/Cargo.toml b/runtime/testnet/Cargo.toml index 70e6b1932..bb7bc3740 100644 --- a/runtime/testnet/Cargo.toml +++ b/runtime/testnet/Cargo.toml @@ -35,6 +35,7 @@ frame-system-benchmarking = { git = 'https://github.com/paritytech/substrate.git frame-system-rpc-runtime-api = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } pallet-aura = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } pallet-balances = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } +pallet-collective = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } pallet-grandpa = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } pallet-randomness-collective-flip = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } pallet-sudo = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } @@ -65,6 +66,7 @@ runtime-benchmarks = [ 'frame-system-benchmarking', 'frame-system/runtime-benchmarks', 'pallet-balances/runtime-benchmarks', + 'pallet-collective/runtime-benchmarks', 'pallet-timestamp/runtime-benchmarks', 'sp-runtime/runtime-benchmarks', ] @@ -77,6 +79,7 @@ std = [ 'frame-system-rpc-runtime-api/std', 'pallet-aura/std', 'pallet-balances/std', + 'pallet-collective/std', 'pallet-grandpa/std', 'pallet-randomness-collective-flip/std', 'pallet-sudo/std', From e63714448b9253f0154895232a4f1c12c237c033 Mon Sep 17 00:00:00 2001 From: Ayush Kumar Mishra Date: Fri, 8 Jan 2021 07:26:43 +0530 Subject: [PATCH 02/20] Changed version --- .gitignore | 2 +- runtime/testnet/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 1bb6c0e41..c080f6032 100644 --- a/.gitignore +++ b/.gitignore @@ -14,5 +14,5 @@ Cargo.lock .local .idea - +.cargo/ pallets/polkadex/.idea \ No newline at end of file diff --git a/runtime/testnet/Cargo.toml b/runtime/testnet/Cargo.toml index bb7bc3740..f7313f78a 100644 --- a/runtime/testnet/Cargo.toml +++ b/runtime/testnet/Cargo.toml @@ -35,7 +35,7 @@ frame-system-benchmarking = { git = 'https://github.com/paritytech/substrate.git frame-system-rpc-runtime-api = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } pallet-aura = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } pallet-balances = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } -pallet-collective = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } +pallet-collective = { version = "2.0.0", default-features = false } pallet-grandpa = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } pallet-randomness-collective-flip = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } pallet-sudo = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } From bacc191b3ac70f9ea40263aef448811bdd0dce70 Mon Sep 17 00:00:00 2001 From: Ayush Kumar Mishra Date: Fri, 8 Jan 2021 07:39:46 +0530 Subject: [PATCH 03/20] #41 added dependency of treasury pallet --- runtime/testnet/Cargo.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/runtime/testnet/Cargo.toml b/runtime/testnet/Cargo.toml index f7313f78a..91343f8db 100644 --- a/runtime/testnet/Cargo.toml +++ b/runtime/testnet/Cargo.toml @@ -42,6 +42,7 @@ pallet-sudo = { git = 'https://github.com/paritytech/substrate.git', branch = "m pallet-timestamp = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } pallet-transaction-payment = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } pallet-transaction-payment-rpc-runtime-api = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } +pallet-treasury = { version = "2.0.0", default-features = false } sp-api = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } sp-block-builder = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } sp-consensus-aura = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = "master" } @@ -68,6 +69,7 @@ runtime-benchmarks = [ 'pallet-balances/runtime-benchmarks', 'pallet-collective/runtime-benchmarks', 'pallet-timestamp/runtime-benchmarks', + 'pallet-treasury/runtime-benchmarks', 'sp-runtime/runtime-benchmarks', ] std = [ @@ -87,6 +89,7 @@ std = [ 'pallet-timestamp/std', 'pallet-transaction-payment/std', 'pallet-transaction-payment-rpc-runtime-api/std', + 'pallet-treasury/std', 'sp-api/std', 'sp-block-builder/std', 'sp-consensus-aura/std', From cdbc79b39c4be11dfd7fa3fc7de1cb59a83b9cb3 Mon Sep 17 00:00:00 2001 From: Ayush Kumar Mishra Date: Fri, 8 Jan 2021 07:56:57 +0530 Subject: [PATCH 04/20] #41 Moved dependecy version back to master --- runtime/testnet/Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/testnet/Cargo.toml b/runtime/testnet/Cargo.toml index 91343f8db..360c119e1 100644 --- a/runtime/testnet/Cargo.toml +++ b/runtime/testnet/Cargo.toml @@ -35,14 +35,14 @@ frame-system-benchmarking = { git = 'https://github.com/paritytech/substrate.git frame-system-rpc-runtime-api = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } pallet-aura = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } pallet-balances = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } -pallet-collective = { version = "2.0.0", default-features = false } +pallet-collective = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } pallet-grandpa = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } pallet-randomness-collective-flip = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } pallet-sudo = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } pallet-timestamp = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } pallet-transaction-payment = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } pallet-transaction-payment-rpc-runtime-api = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } -pallet-treasury = { version = "2.0.0", default-features = false } +pallet-treasury = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } sp-api = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } sp-block-builder = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } sp-consensus-aura = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = "master" } From 5584f80da55f0c9a08e164b6c267d4ee7bc51d42 Mon Sep 17 00:00:00 2001 From: Ayush Kumar Mishra Date: Fri, 8 Jan 2021 07:14:20 +0530 Subject: [PATCH 05/20] Added pallet-collective in cargo.toml --- runtime/testnet/Cargo.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/runtime/testnet/Cargo.toml b/runtime/testnet/Cargo.toml index 50c20c9c7..5822d73f5 100644 --- a/runtime/testnet/Cargo.toml +++ b/runtime/testnet/Cargo.toml @@ -37,6 +37,7 @@ frame-system-benchmarking = { git = 'https://github.com/paritytech/substrate.git frame-system-rpc-runtime-api = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } pallet-aura = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } pallet-balances = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } +pallet-collective = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } pallet-grandpa = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } pallet-randomness-collective-flip = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } pallet-sudo = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } @@ -67,6 +68,7 @@ runtime-benchmarks = [ 'frame-system-benchmarking', 'frame-system/runtime-benchmarks', 'pallet-balances/runtime-benchmarks', + 'pallet-collective/runtime-benchmarks', 'pallet-timestamp/runtime-benchmarks', 'sp-runtime/runtime-benchmarks', ] @@ -79,6 +81,7 @@ std = [ 'frame-system-rpc-runtime-api/std', 'pallet-aura/std', 'pallet-balances/std', + 'pallet-collective/std', 'pallet-grandpa/std', 'pallet-randomness-collective-flip/std', 'pallet-sudo/std', From 8d8aa884eba91c0b9c6399de7bfd4451aeb9891a Mon Sep 17 00:00:00 2001 From: Ayush Kumar Mishra Date: Fri, 8 Jan 2021 07:26:43 +0530 Subject: [PATCH 06/20] Changed version --- .gitignore | 2 +- runtime/testnet/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 1bb6c0e41..c080f6032 100644 --- a/.gitignore +++ b/.gitignore @@ -14,5 +14,5 @@ Cargo.lock .local .idea - +.cargo/ pallets/polkadex/.idea \ No newline at end of file diff --git a/runtime/testnet/Cargo.toml b/runtime/testnet/Cargo.toml index 5822d73f5..3354df831 100644 --- a/runtime/testnet/Cargo.toml +++ b/runtime/testnet/Cargo.toml @@ -37,7 +37,7 @@ frame-system-benchmarking = { git = 'https://github.com/paritytech/substrate.git frame-system-rpc-runtime-api = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } pallet-aura = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } pallet-balances = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } -pallet-collective = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } +pallet-collective = { version = "2.0.0", default-features = false } pallet-grandpa = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } pallet-randomness-collective-flip = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } pallet-sudo = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } From 6e487f6845757f13d78ac43ea7bb10b55e00aaa9 Mon Sep 17 00:00:00 2001 From: Ayush Kumar Mishra Date: Fri, 8 Jan 2021 07:39:46 +0530 Subject: [PATCH 07/20] #41 added dependency of treasury pallet --- runtime/testnet/Cargo.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/runtime/testnet/Cargo.toml b/runtime/testnet/Cargo.toml index 3354df831..085c20aeb 100644 --- a/runtime/testnet/Cargo.toml +++ b/runtime/testnet/Cargo.toml @@ -44,6 +44,7 @@ pallet-sudo = { git = 'https://github.com/paritytech/substrate.git', branch = "m pallet-timestamp = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } pallet-transaction-payment = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } pallet-transaction-payment-rpc-runtime-api = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } +pallet-treasury = { version = "2.0.0", default-features = false } sp-api = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } sp-block-builder = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } sp-consensus-aura = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = "master" } @@ -70,6 +71,7 @@ runtime-benchmarks = [ 'pallet-balances/runtime-benchmarks', 'pallet-collective/runtime-benchmarks', 'pallet-timestamp/runtime-benchmarks', + 'pallet-treasury/runtime-benchmarks', 'sp-runtime/runtime-benchmarks', ] std = [ @@ -89,6 +91,7 @@ std = [ 'pallet-timestamp/std', 'pallet-transaction-payment/std', 'pallet-transaction-payment-rpc-runtime-api/std', + 'pallet-treasury/std', 'sp-api/std', 'sp-block-builder/std', 'sp-consensus-aura/std', From bbe49d02fd3fe9a02deaeac93c763ea3cb9e0f04 Mon Sep 17 00:00:00 2001 From: Ayush Kumar Mishra Date: Fri, 8 Jan 2021 07:56:57 +0530 Subject: [PATCH 08/20] #41 Moved dependecy version back to master --- runtime/testnet/Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/testnet/Cargo.toml b/runtime/testnet/Cargo.toml index 085c20aeb..0f2254eb4 100644 --- a/runtime/testnet/Cargo.toml +++ b/runtime/testnet/Cargo.toml @@ -37,14 +37,14 @@ frame-system-benchmarking = { git = 'https://github.com/paritytech/substrate.git frame-system-rpc-runtime-api = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } pallet-aura = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } pallet-balances = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } -pallet-collective = { version = "2.0.0", default-features = false } +pallet-collective = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } pallet-grandpa = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } pallet-randomness-collective-flip = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } pallet-sudo = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } pallet-timestamp = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } pallet-transaction-payment = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } pallet-transaction-payment-rpc-runtime-api = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } -pallet-treasury = { version = "2.0.0", default-features = false } +pallet-treasury = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } sp-api = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } sp-block-builder = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } sp-consensus-aura = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = "master" } From 5fc81440b43b30b4da7f69c1976aaa2bcff58700 Mon Sep 17 00:00:00 2001 From: Ayush Kumar Mishra Date: Wed, 13 Jan 2021 14:20:38 +0530 Subject: [PATCH 09/20] Integrated Treasury and Collective Pallet 1) Integrated Below Pallets in runtime/testnet * pallet_bounties * pallet_collective * pallet_treasury 2) Added pallet_collective_Instance1 and pallet_treasury in GenesisConfig of node/chain_spec --- node/testnet/src/chain_spec.rs | 4 +- runtime/testnet/Cargo.toml | 3 + runtime/testnet/src/lib.rs | 100 ++++++++++++++++++++++++++++++--- 3 files changed, 98 insertions(+), 9 deletions(-) diff --git a/node/testnet/src/chain_spec.rs b/node/testnet/src/chain_spec.rs index c053789b3..d6a08d194 100644 --- a/node/testnet/src/chain_spec.rs +++ b/node/testnet/src/chain_spec.rs @@ -1,6 +1,6 @@ use sp_core::{Pair, Public, sr25519}; use polkadex_testnet_runtime::{ - AccountId, AuraConfig, BalancesConfig, GenesisConfig, GrandpaConfig, + AccountId, AuraConfig, BalancesConfig, GenesisConfig, GrandpaConfig, CouncilConfig, SudoConfig, SystemConfig, WASM_BINARY, Signature , CustomAssetConfig }; use sp_runtime::FixedU128; @@ -160,6 +160,8 @@ fn testnet_genesis( pallet_grandpa: Some(GrandpaConfig { authorities: initial_authorities.iter().map(|x| (x.1.clone(), 1)).collect(), }), + pallet_collective_Instance1: Some(CouncilConfig::default()), + pallet_treasury: Some(Default::default()), pallet_sudo: Some(SudoConfig { // Assign network admin rights. key: root_key, diff --git a/runtime/testnet/Cargo.toml b/runtime/testnet/Cargo.toml index 0f2254eb4..afe5124f5 100644 --- a/runtime/testnet/Cargo.toml +++ b/runtime/testnet/Cargo.toml @@ -37,6 +37,7 @@ frame-system-benchmarking = { git = 'https://github.com/paritytech/substrate.git frame-system-rpc-runtime-api = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } pallet-aura = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } pallet-balances = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } +pallet-bounties = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } pallet-collective = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } pallet-grandpa = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } pallet-randomness-collective-flip = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } @@ -69,6 +70,7 @@ runtime-benchmarks = [ 'frame-system-benchmarking', 'frame-system/runtime-benchmarks', 'pallet-balances/runtime-benchmarks', + 'pallet-bounties/runtime-benchmarks', 'pallet-collective/runtime-benchmarks', 'pallet-timestamp/runtime-benchmarks', 'pallet-treasury/runtime-benchmarks', @@ -83,6 +85,7 @@ std = [ 'frame-system-rpc-runtime-api/std', 'pallet-aura/std', 'pallet-balances/std', + 'pallet-bounties/std', 'pallet-collective/std', 'pallet-grandpa/std', 'pallet-randomness-collective-flip/std', diff --git a/runtime/testnet/src/lib.rs b/runtime/testnet/src/lib.rs index afa650cb2..521f990ac 100644 --- a/runtime/testnet/src/lib.rs +++ b/runtime/testnet/src/lib.rs @@ -7,13 +7,20 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); use sp_std::prelude::*; -use sp_core::{crypto::KeyTypeId, OpaqueMetadata}; +use frame_system::{ + EnsureRoot, EnsureOneOf, +}; +use sp_core::{ + crypto::KeyTypeId, + u32_trait::{_1, _2, _3, _5}, + OpaqueMetadata, +}; use sp_runtime::{ - ApplyExtrinsicResult, generic, create_runtime_str, impl_opaque_keys, MultiSignature, - transaction_validity::{TransactionValidity, TransactionSource}, + ApplyExtrinsicResult, generic, create_runtime_str, impl_opaque_keys, ModuleId, MultiSignature, + Percent, transaction_validity::{TransactionValidity, TransactionSource}, }; use sp_runtime::traits::{ - BlakeTwo256, Block as BlockT, IdentityLookup, Verify, IdentifyAccount, NumberFor, Saturating, + BlakeTwo256, Block as BlockT, IdentityLookup, Verify, IdentifyAccount, NumberFor, }; use sp_api::impl_runtime_apis; use sp_consensus_aura::sr25519::AuthorityId as AuraId; @@ -37,7 +44,6 @@ pub use frame_support::{ constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND}, }, }; - /// Import the template pallet. pub use pallet_polkadex; use pallet_polkadex::data_structure_rpc::LinkedPriceLevelRpc; @@ -116,6 +122,11 @@ pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber); pub const HOURS: BlockNumber = MINUTES * 60; pub const DAYS: BlockNumber = HOURS * 24; +// Currencies +pub const MILLICENTS: Balance = 1_000_000_000; +pub const CENTS: Balance = 1_000 * MILLICENTS; +pub const DOLLARS: Balance = 100 * CENTS; + /// The version information used to identify this runtime when compiled natively. #[cfg(feature = "std")] pub fn native_version() -> NativeVersion { @@ -291,13 +302,80 @@ impl pallet_idenity::Config for Runtime { type MaxSubAccounts = MaxSubAccounts; type MaxRegistrars = MaxRegistrars; } +parameter_types! { + pub const CouncilMotionDuration: BlockNumber = 5 * DAYS; + pub const CouncilMaxProposals: u32 = 100; + pub const CouncilMaxMembers: u32 = 100; +} + +type CouncilCollective = pallet_collective::Instance1; +impl pallet_collective::Config for Runtime { + type Origin = Origin; + type Proposal = Call; + type Event = Event; + type MotionDuration = CouncilMotionDuration; + type MaxProposals = CouncilMaxProposals; + type MaxMembers = CouncilMaxMembers; + type DefaultVote = pallet_collective::PrimeDefaultVote; + type WeightInfo = pallet_collective::weights::SubstrateWeight; +} +parameter_types! { + pub const ProposalBond: Permill = Permill::from_percent(5); + pub const ProposalBondMinimum: Balance = 1 * DOLLARS; + pub const SpendPeriod: BlockNumber = 1 * DAYS; + pub const Burn: Permill = Permill::from_percent(50); + pub const TipCountdown: BlockNumber = 1 * DAYS; + pub const TipFindersFee: Percent = Percent::from_percent(20); + pub const TipReportDepositBase: Balance = 1 * DOLLARS; + pub const DataDepositPerByte: Balance = 1 * CENTS; + pub const BountyDepositBase: Balance = 1 * DOLLARS; + pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS; + pub const TreasuryModuleId: ModuleId = ModuleId(*b"py/trsry"); + pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS; + pub const MaximumReasonLength: u32 = 16384; + pub const BountyCuratorDeposit: Permill = Permill::from_percent(50); + pub const BountyValueMinimum: Balance = 5 * DOLLARS; +} + +impl pallet_treasury::Config for Runtime { + type ModuleId = TreasuryModuleId; + type Currency = Balances; + type ApproveOrigin = EnsureOneOf< + AccountId, + EnsureRoot, + pallet_collective::EnsureProportionAtLeast<_3, _5, AccountId, CouncilCollective> + >; + type RejectOrigin = EnsureOneOf< + AccountId, + EnsureRoot, + pallet_collective::EnsureProportionMoreThan<_1, _2, AccountId, CouncilCollective> + >; + type Event = Event; + type OnSlash = (); + type ProposalBond = ProposalBond; + type ProposalBondMinimum = ProposalBondMinimum; + type SpendPeriod = SpendPeriod; + type Burn = Burn; + type BurnDestination = (); + type SpendFunds = Bounties; + type WeightInfo = pallet_treasury::weights::SubstrateWeight; +} + +impl pallet_bounties::Config for Runtime { + type Event = Event; + type BountyDepositBase = BountyDepositBase; + type BountyDepositPayoutDelay = BountyDepositPayoutDelay; + type BountyUpdatePeriod = BountyUpdatePeriod; + type BountyCuratorDeposit = BountyCuratorDeposit; + type BountyValueMinimum = BountyValueMinimum; + type DataDepositPerByte = DataDepositPerByte; + type MaximumReasonLength = MaximumReasonLength; + type WeightInfo = pallet_bounties::weights::SubstrateWeight; +} use polkadex_custom_assets::NativeAssetCurrency; -//use pallet_generic_asset::{SpendingAssetCurrency, StakingAssetCurrency}; -use frame_system::limits::{BlockLength, BlockWeights}; use pallet_transaction_payment::CurrencyAdapter; -use frame_system::Config; // Create the runtime by composing the FRAME pallets that were previously configured. construct_runtime!( @@ -319,6 +397,9 @@ construct_runtime!( PolkadexIdentity: pallet_idenity::{Module, Call, Storage, Event}, // Include the custom logic from the template pallet in the runtime. Polkadex: pallet_polkadex::{Module, Call, Storage, Event}, + Council: pallet_collective::::{Module, Call, Storage, Origin, Event, Config}, + Treasury: pallet_treasury::{Module, Call, Storage, Config, Event}, + Bounties: pallet_bounties::{Module, Call, Storage, Event}, } ); @@ -540,7 +621,10 @@ impl_runtime_apis! { add_benchmark!(params, batches, frame_system, SystemBench::); add_benchmark!(params, batches, pallet_balances, Balances); + add_benchmark!(params, batches, pallet_bounties, Bounties); + add_benchmark!(params, batches, pallet_collective, Council); add_benchmark!(params, batches, pallet_timestamp, Timestamp); + add_benchmark!(params, batches, pallet_treasury, Treasury); if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) } Ok(batches) From d38fc77ca2acf2249969c96e9f8e35f75077790a Mon Sep 17 00:00:00 2001 From: ksr30 Date: Wed, 13 Jan 2021 16:16:38 +0530 Subject: [PATCH 10/20] mainnet runtime updated --- node/mainnet/Cargo.toml | 4 +-- node/mainnet/src/chain_spec.rs | 14 ++++----- node/mainnet/src/rpc.rs | 6 ++-- runtime/mainnet/Cargo.toml | 14 ++++++--- runtime/mainnet/src/lib.rs | 52 +++++++++++++++++++++++++--------- 5 files changed, 60 insertions(+), 30 deletions(-) diff --git a/node/mainnet/Cargo.toml b/node/mainnet/Cargo.toml index 84ba7e9a9..2acdde05c 100644 --- a/node/mainnet/Cargo.toml +++ b/node/mainnet/Cargo.toml @@ -18,8 +18,8 @@ name = 'polkadex-mainnet' [dependencies] jsonrpc-core = '15.0.0' structopt = '0.3.8' -rpc = { path = "../../pallets/polkadex/rpc", version = "0.1.0" } -runtime-api = { path = "../../pallets/polkadex/runtime-api", version = "0.1.0" } +engine-rpc = { path = "../../pallets/polkadex-engine/rpc" } +engine-runtime-api = { default-features = false, path = "../../pallets/polkadex-engine/runtime-api" } polkadex-mainnet-runtime = { path = "../../runtime/mainnet", version = "2.0.0" } pallet-transaction-payment-rpc = { git = 'https://github.com/paritytech/substrate.git', branch = "master" } sc-basic-authorship = { git = 'https://github.com/paritytech/substrate.git', branch = "master" } diff --git a/node/mainnet/src/chain_spec.rs b/node/mainnet/src/chain_spec.rs index ea77fc283..98cd6426c 100644 --- a/node/mainnet/src/chain_spec.rs +++ b/node/mainnet/src/chain_spec.rs @@ -2,7 +2,7 @@ use sp_core::{Pair, Public, sr25519}; use polkadex_mainnet_runtime::{ AccountId, BabeConfig,BalancesConfig, GenesisConfig, GrandpaConfig, SudoConfig, SystemConfig, WASM_BINARY, Signature, SessionConfig, StakingConfig, StakerStatus, - opaque::SessionKeys, Balance, GenericAssetConfig + opaque::SessionKeys, Balance, CustomAssetConfig }; // use sp_consensus_aura::sr25519::AuthorityId as AuraId; use sp_consensus_babe::{AuthorityId as BabeId}; @@ -10,6 +10,8 @@ use sp_finality_grandpa::AuthorityId as GrandpaId; use sp_runtime::traits::{Verify, IdentifyAccount}; use sc_service::ChainType; use sp_runtime::{Perbill}; +use sp_runtime::FixedU128; +use sp_runtime::testing::H256; // The URL for the telemetry server. // const STAGING_TELEMETRY_URL: &str = "wss://telemetry.polkadot.io/submit/"; @@ -188,14 +190,12 @@ fn testnet_genesis( slash_reward_fraction: Perbill::from_percent(10), .. Default::default() }), - pallet_generic_asset: Some(GenericAssetConfig{ - assets: vec![0], - initial_balance: 3*UNIT, + polkadex_custom_assets: Some(CustomAssetConfig{ + assets: vec![H256::random()], + initial_balance: FixedU128::from(UNIT*UNIT), // TODO Change values accordingly endowed_accounts: endowed_accounts .clone().into_iter().map(Into::into).collect(), - next_asset_id: 1, - staking_asset_id: 0, - spending_asset_id: 0 + native_asset: H256::random() }) } } diff --git a/node/mainnet/src/rpc.rs b/node/mainnet/src/rpc.rs index d7e74c5d3..82fab31d8 100644 --- a/node/mainnet/src/rpc.rs +++ b/node/mainnet/src/rpc.rs @@ -35,7 +35,7 @@ pub fn create_full( C::Api: substrate_frame_rpc_system::AccountNonceApi, C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi, C::Api: BlockBuilder, - C::Api: runtime_api::DexStorageApi, + C::Api: engine_runtime_api::DexStorageApi, P: TransactionPool + 'static, { use substrate_frame_rpc_system::{FullSystem, SystemApi}; @@ -49,8 +49,8 @@ pub fn create_full( } = deps; - io.extend_with(rpc::DexStorageApi::to_delegate( - rpc::DexStorage::new(client.clone()), + io.extend_with(engine_rpc::DexStorageApi::to_delegate( + engine_rpc::DexStorage::new(client.clone()), )); io.extend_with( diff --git a/runtime/mainnet/Cargo.toml b/runtime/mainnet/Cargo.toml index ba059edf4..69159c0ff 100644 --- a/runtime/mainnet/Cargo.toml +++ b/runtime/mainnet/Cargo.toml @@ -12,8 +12,6 @@ version = '2.0.0' targets = ['x86_64-unknown-linux-gnu'] [dependencies] -runtime-api = { default-features = false, path = "../../pallets/polkadex/runtime-api" } -polkadex = { default-features = false, package = 'pallet-polkadex', path = '../../pallets/polkadex', version = '2.0.0' } frame-executive = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } sp-arithmetic = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } frame-support = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } @@ -42,9 +40,15 @@ pallet-staking = { git = 'https://github.com/paritytech/substrate.git', branch = pallet-staking-reward-curve = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } pallet-session = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false, features = ['historical'] } sp-staking = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } -pallet-generic-asset = { path = "../../pallets/generic_asset" , default-features = false } serde = { features = ['derive'], optional = true, version = '1.0.101' } +# Local Dependecies +runtime-api = { package = 'engine-runtime-api',default-features = false, path = "../../pallets/polkadex-engine/runtime-api" } +polkadex = { package = 'polkadex-engine' , path = '../../pallets/polkadex-engine', default-features = false } +polkadex-custom-assets = { path = '../../pallets/polkadex-custom-assets', default-features = false } +polkadex-swap-engine = { path = '../../pallets/polkadex-uniswap', default-features = false } +pallet-idenity = { path = '../../pallets/polkadex-identity-pallet', default-features = false } + [dependencies.codec] default-features = false features = ['derive'] @@ -66,7 +70,6 @@ std = [ 'pallet-sudo/std', 'pallet-timestamp/std', 'pallet-transaction-payment/std', - 'pallet-generic-asset/std', 'pallet-transaction-payment-rpc-runtime-api/std', 'serde', 'sp-api/std', @@ -84,6 +87,9 @@ std = [ 'sp-transaction-pool/std', 'sp-version/std', 'polkadex/std', + 'polkadex-custom-assets/std', + 'polkadex-swap-engine/std', + 'pallet-idenity/std' ] [build-dependencies] diff --git a/runtime/mainnet/src/lib.rs b/runtime/mainnet/src/lib.rs index 58c58b7f0..0412b124e 100644 --- a/runtime/mainnet/src/lib.rs +++ b/runtime/mainnet/src/lib.rs @@ -295,7 +295,7 @@ parameter_types! { // } impl pallet_transaction_payment::Config for Runtime { - type OnChargeTransaction = CurrencyAdapter, ()>; + type OnChargeTransaction = CurrencyAdapter, ()>; type TransactionByteFee = TransactionByteFee; type WeightToFee = IdentityFee; type FeeMultiplierUpdate = (); @@ -308,7 +308,7 @@ impl pallet_sudo::Config for Runtime { /// Struct that handles the conversion of Balance -> `u64`. This is used for staking's election /// calculation. -use pallet_generic_asset::{SpendingAssetCurrency, StakingAssetCurrency}; +use polkadex_custom_assets::NativeAssetCurrency; use pallet_transaction_payment::CurrencyAdapter; use frame_system::limits::{BlockLength, BlockWeights}; @@ -358,7 +358,7 @@ parameter_types! { } impl pallet_staking::Config for Runtime { - type Currency = StakingAssetCurrency; + type Currency = NativeAssetCurrency; type UnixTime = Timestamp; type CurrencyToVote = U128CurrencyToVote; type RewardRemainder = (); // Treasury @@ -388,6 +388,28 @@ impl pallet_staking::Config for Runtime { type WeightInfo = (); } +parameter_types! { + pub const TradingPathLimit: usize = 10; +} + +impl polkadex_swap_engine::Config for Runtime { + type Event = Event; + type TradingPathLimit = TradingPathLimit; +} + +parameter_types! { + pub const MaxSubAccounts: u32 = 10; + pub const MaxRegistrars: u32 = 10; +} + +impl pallet_idenity::Config for Runtime { + type Event = Event; + type MaxSubAccounts = MaxSubAccounts; + type MaxRegistrars = MaxRegistrars; +} + + + parameter_types! { // pub const SessionDuration: BlockNumber = EPOCH_DURATION_IN_SLOTS as _; // pub const ImOnlineUnsignedPriority: TransactionPriority = TransactionPriority::max_value(); @@ -402,11 +424,11 @@ impl frame_system::offchain::SendTransactionTypes for Runtime where type OverarchingCall = Call; } -impl pallet_generic_asset::Config for Runtime { - type Balance = Balance; - type AssetId = u32; +impl polkadex_custom_assets::Config for Runtime { type Event = Event; + type Balance = Balance; type MaxLocks = MaxLocks; + type ExistentialDeposit = ExistentialDeposit; } parameter_types! { @@ -435,12 +457,14 @@ construct_runtime!( Balances: pallet_balances::{Module, Call, Storage, Config, Event}, TransactionPayment: pallet_transaction_payment::{Module, Storage}, Sudo: pallet_sudo::{Module, Call, Config, Storage, Event}, - GenericAsset: pallet_generic_asset::{Module, Call, Storage, Config, Event}, + CustomAsset: polkadex_custom_assets::{Module, Call, Storage, Config, Event}, Staking: pallet_staking::{Module, Call, Config, Storage, Event, ValidateUnsigned}, Session: pallet_session::{Module, Call, Storage, Event, Config}, Historical: pallet_session_historical::{Module}, // Include the custom logic from the polkadex pallet in the runtime. Polkadex: polkadex::{Module, Call, Storage, Event}, + PolkadexUniswap: polkadex_swap_engine::{Module, Call, Storage, Event}, + PolkadexIdentity: pallet_idenity::{Module, Call, Storage, Event}, } ); @@ -647,20 +671,20 @@ impl_runtime_apis! { impl runtime_api::DexStorageApi for Runtime{ - fn get_ask_level(trading_pair: Hash) -> Result,ErrorRpc> { + fn get_ask_level(trading_pair: (Hash,Hash)) -> Result,ErrorRpc> { Polkadex::get_ask_level(trading_pair) } - fn get_bid_level(trading_pair: Hash) -> Result,ErrorRpc> { + fn get_bid_level(trading_pair: (Hash,Hash)) -> Result,ErrorRpc> { Polkadex::get_bid_level(trading_pair) } - fn get_price_level(trading_pair: Hash) -> Result,ErrorRpc> { + fn get_price_level(trading_pair: (Hash,Hash)) -> Result,ErrorRpc> { Polkadex::get_price_level(trading_pair) } - fn get_orderbook(trading_pair: Hash) -> Result { + fn get_orderbook(trading_pair: (Hash,Hash)) -> Result { Polkadex::get_orderbook(trading_pair) } @@ -668,11 +692,11 @@ impl_runtime_apis! { Polkadex::get_all_orderbook() } - fn get_market_info(trading_pair: Hash,blocknum: u32) -> Result { - Polkadex::get_market_info(trading_pair,blocknum) + fn get_market_info(trading_pair: (Hash,Hash)) -> Result { + Polkadex::get_market_info(trading_pair) } - fn get_orderbook_updates(trading_pair: Hash)-> Result{ + fn get_orderbook_updates(trading_pair: (Hash,Hash))-> Result{ Polkadex::get_orderbook_updates(trading_pair) } From 5f35687c93de227cc80c8e9d766918550c10fc2d Mon Sep 17 00:00:00 2001 From: Ayush Mishra Date: Thu, 14 Jan 2021 10:09:12 +0530 Subject: [PATCH 11/20] Update runtime/testnet/src/lib.rs Co-authored-by: Gautham --- runtime/testnet/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/testnet/src/lib.rs b/runtime/testnet/src/lib.rs index 521f990ac..83a93e8e5 100644 --- a/runtime/testnet/src/lib.rs +++ b/runtime/testnet/src/lib.rs @@ -340,7 +340,7 @@ parameter_types! { impl pallet_treasury::Config for Runtime { type ModuleId = TreasuryModuleId; - type Currency = Balances; + type Currency = NativeAssetCurrency; type ApproveOrigin = EnsureOneOf< AccountId, EnsureRoot, From 0372f9f8d00bec230f9a4fe54f95dfc538e536f8 Mon Sep 17 00:00:00 2001 From: Ayush Kumar Mishra Date: Fri, 8 Jan 2021 07:14:20 +0530 Subject: [PATCH 12/20] Added pallet-collective in cargo.toml --- runtime/testnet/Cargo.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/runtime/testnet/Cargo.toml b/runtime/testnet/Cargo.toml index 50c20c9c7..5822d73f5 100644 --- a/runtime/testnet/Cargo.toml +++ b/runtime/testnet/Cargo.toml @@ -37,6 +37,7 @@ frame-system-benchmarking = { git = 'https://github.com/paritytech/substrate.git frame-system-rpc-runtime-api = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } pallet-aura = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } pallet-balances = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } +pallet-collective = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } pallet-grandpa = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } pallet-randomness-collective-flip = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } pallet-sudo = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } @@ -67,6 +68,7 @@ runtime-benchmarks = [ 'frame-system-benchmarking', 'frame-system/runtime-benchmarks', 'pallet-balances/runtime-benchmarks', + 'pallet-collective/runtime-benchmarks', 'pallet-timestamp/runtime-benchmarks', 'sp-runtime/runtime-benchmarks', ] @@ -79,6 +81,7 @@ std = [ 'frame-system-rpc-runtime-api/std', 'pallet-aura/std', 'pallet-balances/std', + 'pallet-collective/std', 'pallet-grandpa/std', 'pallet-randomness-collective-flip/std', 'pallet-sudo/std', From db6e1ff6d292841fa82a501c1afc969a62c29796 Mon Sep 17 00:00:00 2001 From: Ayush Kumar Mishra Date: Fri, 8 Jan 2021 07:26:43 +0530 Subject: [PATCH 13/20] Changed version --- .gitignore | 2 +- runtime/testnet/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 1bb6c0e41..c080f6032 100644 --- a/.gitignore +++ b/.gitignore @@ -14,5 +14,5 @@ Cargo.lock .local .idea - +.cargo/ pallets/polkadex/.idea \ No newline at end of file diff --git a/runtime/testnet/Cargo.toml b/runtime/testnet/Cargo.toml index 5822d73f5..3354df831 100644 --- a/runtime/testnet/Cargo.toml +++ b/runtime/testnet/Cargo.toml @@ -37,7 +37,7 @@ frame-system-benchmarking = { git = 'https://github.com/paritytech/substrate.git frame-system-rpc-runtime-api = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } pallet-aura = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } pallet-balances = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } -pallet-collective = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } +pallet-collective = { version = "2.0.0", default-features = false } pallet-grandpa = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } pallet-randomness-collective-flip = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } pallet-sudo = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } From 16e431777f691fedd69c2deb76109b44c204559e Mon Sep 17 00:00:00 2001 From: Ayush Kumar Mishra Date: Fri, 8 Jan 2021 07:39:46 +0530 Subject: [PATCH 14/20] #41 added dependency of treasury pallet --- runtime/testnet/Cargo.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/runtime/testnet/Cargo.toml b/runtime/testnet/Cargo.toml index 3354df831..085c20aeb 100644 --- a/runtime/testnet/Cargo.toml +++ b/runtime/testnet/Cargo.toml @@ -44,6 +44,7 @@ pallet-sudo = { git = 'https://github.com/paritytech/substrate.git', branch = "m pallet-timestamp = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } pallet-transaction-payment = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } pallet-transaction-payment-rpc-runtime-api = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } +pallet-treasury = { version = "2.0.0", default-features = false } sp-api = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } sp-block-builder = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } sp-consensus-aura = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = "master" } @@ -70,6 +71,7 @@ runtime-benchmarks = [ 'pallet-balances/runtime-benchmarks', 'pallet-collective/runtime-benchmarks', 'pallet-timestamp/runtime-benchmarks', + 'pallet-treasury/runtime-benchmarks', 'sp-runtime/runtime-benchmarks', ] std = [ @@ -89,6 +91,7 @@ std = [ 'pallet-timestamp/std', 'pallet-transaction-payment/std', 'pallet-transaction-payment-rpc-runtime-api/std', + 'pallet-treasury/std', 'sp-api/std', 'sp-block-builder/std', 'sp-consensus-aura/std', From d5b4415dc86b1aa7938d6c812a9c5a5a12a555ed Mon Sep 17 00:00:00 2001 From: Ayush Kumar Mishra Date: Fri, 8 Jan 2021 07:56:57 +0530 Subject: [PATCH 15/20] #41 Moved dependecy version back to master --- runtime/testnet/Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/testnet/Cargo.toml b/runtime/testnet/Cargo.toml index 085c20aeb..0f2254eb4 100644 --- a/runtime/testnet/Cargo.toml +++ b/runtime/testnet/Cargo.toml @@ -37,14 +37,14 @@ frame-system-benchmarking = { git = 'https://github.com/paritytech/substrate.git frame-system-rpc-runtime-api = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } pallet-aura = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } pallet-balances = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } -pallet-collective = { version = "2.0.0", default-features = false } +pallet-collective = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } pallet-grandpa = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } pallet-randomness-collective-flip = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } pallet-sudo = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } pallet-timestamp = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } pallet-transaction-payment = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } pallet-transaction-payment-rpc-runtime-api = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } -pallet-treasury = { version = "2.0.0", default-features = false } +pallet-treasury = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } sp-api = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } sp-block-builder = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } sp-consensus-aura = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = "master" } From 8c0d5052e2a43fc6f3b033c2987333ff8caaa9b6 Mon Sep 17 00:00:00 2001 From: Ayush Kumar Mishra Date: Fri, 8 Jan 2021 07:26:43 +0530 Subject: [PATCH 16/20] Changed version --- runtime/testnet/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/testnet/Cargo.toml b/runtime/testnet/Cargo.toml index 0f2254eb4..8def74b49 100644 --- a/runtime/testnet/Cargo.toml +++ b/runtime/testnet/Cargo.toml @@ -37,7 +37,7 @@ frame-system-benchmarking = { git = 'https://github.com/paritytech/substrate.git frame-system-rpc-runtime-api = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } pallet-aura = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } pallet-balances = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } -pallet-collective = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } +pallet-collective = { version = "2.0.0", default-features = false } pallet-grandpa = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } pallet-randomness-collective-flip = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } pallet-sudo = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } From 8f3dc1a636aa861e5aa2feb4c380af67cd329882 Mon Sep 17 00:00:00 2001 From: Ayush Kumar Mishra Date: Fri, 8 Jan 2021 07:56:57 +0530 Subject: [PATCH 17/20] #41 Moved dependecy version back to master --- runtime/testnet/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/testnet/Cargo.toml b/runtime/testnet/Cargo.toml index 8def74b49..0f2254eb4 100644 --- a/runtime/testnet/Cargo.toml +++ b/runtime/testnet/Cargo.toml @@ -37,7 +37,7 @@ frame-system-benchmarking = { git = 'https://github.com/paritytech/substrate.git frame-system-rpc-runtime-api = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } pallet-aura = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } pallet-balances = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } -pallet-collective = { version = "2.0.0", default-features = false } +pallet-collective = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } pallet-grandpa = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } pallet-randomness-collective-flip = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } pallet-sudo = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } From 85918640c51c1fb910c642cb83be1cdfbf013235 Mon Sep 17 00:00:00 2001 From: Ayush Kumar Mishra Date: Wed, 13 Jan 2021 14:20:38 +0530 Subject: [PATCH 18/20] Integrated Treasury and Collective Pallet 1) Integrated Below Pallets in runtime/testnet * pallet_bounties * pallet_collective * pallet_treasury 2) Added pallet_collective_Instance1 and pallet_treasury in GenesisConfig of node/chain_spec --- node/testnet/src/chain_spec.rs | 4 +- runtime/testnet/Cargo.toml | 3 + runtime/testnet/src/lib.rs | 100 ++++++++++++++++++++++++++++++--- 3 files changed, 98 insertions(+), 9 deletions(-) diff --git a/node/testnet/src/chain_spec.rs b/node/testnet/src/chain_spec.rs index c053789b3..d6a08d194 100644 --- a/node/testnet/src/chain_spec.rs +++ b/node/testnet/src/chain_spec.rs @@ -1,6 +1,6 @@ use sp_core::{Pair, Public, sr25519}; use polkadex_testnet_runtime::{ - AccountId, AuraConfig, BalancesConfig, GenesisConfig, GrandpaConfig, + AccountId, AuraConfig, BalancesConfig, GenesisConfig, GrandpaConfig, CouncilConfig, SudoConfig, SystemConfig, WASM_BINARY, Signature , CustomAssetConfig }; use sp_runtime::FixedU128; @@ -160,6 +160,8 @@ fn testnet_genesis( pallet_grandpa: Some(GrandpaConfig { authorities: initial_authorities.iter().map(|x| (x.1.clone(), 1)).collect(), }), + pallet_collective_Instance1: Some(CouncilConfig::default()), + pallet_treasury: Some(Default::default()), pallet_sudo: Some(SudoConfig { // Assign network admin rights. key: root_key, diff --git a/runtime/testnet/Cargo.toml b/runtime/testnet/Cargo.toml index 0f2254eb4..afe5124f5 100644 --- a/runtime/testnet/Cargo.toml +++ b/runtime/testnet/Cargo.toml @@ -37,6 +37,7 @@ frame-system-benchmarking = { git = 'https://github.com/paritytech/substrate.git frame-system-rpc-runtime-api = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } pallet-aura = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } pallet-balances = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } +pallet-bounties = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } pallet-collective = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } pallet-grandpa = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } pallet-randomness-collective-flip = { git = 'https://github.com/paritytech/substrate.git', branch = "master", default-features = false } @@ -69,6 +70,7 @@ runtime-benchmarks = [ 'frame-system-benchmarking', 'frame-system/runtime-benchmarks', 'pallet-balances/runtime-benchmarks', + 'pallet-bounties/runtime-benchmarks', 'pallet-collective/runtime-benchmarks', 'pallet-timestamp/runtime-benchmarks', 'pallet-treasury/runtime-benchmarks', @@ -83,6 +85,7 @@ std = [ 'frame-system-rpc-runtime-api/std', 'pallet-aura/std', 'pallet-balances/std', + 'pallet-bounties/std', 'pallet-collective/std', 'pallet-grandpa/std', 'pallet-randomness-collective-flip/std', diff --git a/runtime/testnet/src/lib.rs b/runtime/testnet/src/lib.rs index afa650cb2..521f990ac 100644 --- a/runtime/testnet/src/lib.rs +++ b/runtime/testnet/src/lib.rs @@ -7,13 +7,20 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); use sp_std::prelude::*; -use sp_core::{crypto::KeyTypeId, OpaqueMetadata}; +use frame_system::{ + EnsureRoot, EnsureOneOf, +}; +use sp_core::{ + crypto::KeyTypeId, + u32_trait::{_1, _2, _3, _5}, + OpaqueMetadata, +}; use sp_runtime::{ - ApplyExtrinsicResult, generic, create_runtime_str, impl_opaque_keys, MultiSignature, - transaction_validity::{TransactionValidity, TransactionSource}, + ApplyExtrinsicResult, generic, create_runtime_str, impl_opaque_keys, ModuleId, MultiSignature, + Percent, transaction_validity::{TransactionValidity, TransactionSource}, }; use sp_runtime::traits::{ - BlakeTwo256, Block as BlockT, IdentityLookup, Verify, IdentifyAccount, NumberFor, Saturating, + BlakeTwo256, Block as BlockT, IdentityLookup, Verify, IdentifyAccount, NumberFor, }; use sp_api::impl_runtime_apis; use sp_consensus_aura::sr25519::AuthorityId as AuraId; @@ -37,7 +44,6 @@ pub use frame_support::{ constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND}, }, }; - /// Import the template pallet. pub use pallet_polkadex; use pallet_polkadex::data_structure_rpc::LinkedPriceLevelRpc; @@ -116,6 +122,11 @@ pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber); pub const HOURS: BlockNumber = MINUTES * 60; pub const DAYS: BlockNumber = HOURS * 24; +// Currencies +pub const MILLICENTS: Balance = 1_000_000_000; +pub const CENTS: Balance = 1_000 * MILLICENTS; +pub const DOLLARS: Balance = 100 * CENTS; + /// The version information used to identify this runtime when compiled natively. #[cfg(feature = "std")] pub fn native_version() -> NativeVersion { @@ -291,13 +302,80 @@ impl pallet_idenity::Config for Runtime { type MaxSubAccounts = MaxSubAccounts; type MaxRegistrars = MaxRegistrars; } +parameter_types! { + pub const CouncilMotionDuration: BlockNumber = 5 * DAYS; + pub const CouncilMaxProposals: u32 = 100; + pub const CouncilMaxMembers: u32 = 100; +} + +type CouncilCollective = pallet_collective::Instance1; +impl pallet_collective::Config for Runtime { + type Origin = Origin; + type Proposal = Call; + type Event = Event; + type MotionDuration = CouncilMotionDuration; + type MaxProposals = CouncilMaxProposals; + type MaxMembers = CouncilMaxMembers; + type DefaultVote = pallet_collective::PrimeDefaultVote; + type WeightInfo = pallet_collective::weights::SubstrateWeight; +} +parameter_types! { + pub const ProposalBond: Permill = Permill::from_percent(5); + pub const ProposalBondMinimum: Balance = 1 * DOLLARS; + pub const SpendPeriod: BlockNumber = 1 * DAYS; + pub const Burn: Permill = Permill::from_percent(50); + pub const TipCountdown: BlockNumber = 1 * DAYS; + pub const TipFindersFee: Percent = Percent::from_percent(20); + pub const TipReportDepositBase: Balance = 1 * DOLLARS; + pub const DataDepositPerByte: Balance = 1 * CENTS; + pub const BountyDepositBase: Balance = 1 * DOLLARS; + pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS; + pub const TreasuryModuleId: ModuleId = ModuleId(*b"py/trsry"); + pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS; + pub const MaximumReasonLength: u32 = 16384; + pub const BountyCuratorDeposit: Permill = Permill::from_percent(50); + pub const BountyValueMinimum: Balance = 5 * DOLLARS; +} + +impl pallet_treasury::Config for Runtime { + type ModuleId = TreasuryModuleId; + type Currency = Balances; + type ApproveOrigin = EnsureOneOf< + AccountId, + EnsureRoot, + pallet_collective::EnsureProportionAtLeast<_3, _5, AccountId, CouncilCollective> + >; + type RejectOrigin = EnsureOneOf< + AccountId, + EnsureRoot, + pallet_collective::EnsureProportionMoreThan<_1, _2, AccountId, CouncilCollective> + >; + type Event = Event; + type OnSlash = (); + type ProposalBond = ProposalBond; + type ProposalBondMinimum = ProposalBondMinimum; + type SpendPeriod = SpendPeriod; + type Burn = Burn; + type BurnDestination = (); + type SpendFunds = Bounties; + type WeightInfo = pallet_treasury::weights::SubstrateWeight; +} + +impl pallet_bounties::Config for Runtime { + type Event = Event; + type BountyDepositBase = BountyDepositBase; + type BountyDepositPayoutDelay = BountyDepositPayoutDelay; + type BountyUpdatePeriod = BountyUpdatePeriod; + type BountyCuratorDeposit = BountyCuratorDeposit; + type BountyValueMinimum = BountyValueMinimum; + type DataDepositPerByte = DataDepositPerByte; + type MaximumReasonLength = MaximumReasonLength; + type WeightInfo = pallet_bounties::weights::SubstrateWeight; +} use polkadex_custom_assets::NativeAssetCurrency; -//use pallet_generic_asset::{SpendingAssetCurrency, StakingAssetCurrency}; -use frame_system::limits::{BlockLength, BlockWeights}; use pallet_transaction_payment::CurrencyAdapter; -use frame_system::Config; // Create the runtime by composing the FRAME pallets that were previously configured. construct_runtime!( @@ -319,6 +397,9 @@ construct_runtime!( PolkadexIdentity: pallet_idenity::{Module, Call, Storage, Event}, // Include the custom logic from the template pallet in the runtime. Polkadex: pallet_polkadex::{Module, Call, Storage, Event}, + Council: pallet_collective::::{Module, Call, Storage, Origin, Event, Config}, + Treasury: pallet_treasury::{Module, Call, Storage, Config, Event}, + Bounties: pallet_bounties::{Module, Call, Storage, Event}, } ); @@ -540,7 +621,10 @@ impl_runtime_apis! { add_benchmark!(params, batches, frame_system, SystemBench::); add_benchmark!(params, batches, pallet_balances, Balances); + add_benchmark!(params, batches, pallet_bounties, Bounties); + add_benchmark!(params, batches, pallet_collective, Council); add_benchmark!(params, batches, pallet_timestamp, Timestamp); + add_benchmark!(params, batches, pallet_treasury, Treasury); if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) } Ok(batches) From 578714aa04a717dd88ba5bbee293a7eb02ec2d64 Mon Sep 17 00:00:00 2001 From: Ayush Mishra Date: Thu, 14 Jan 2021 10:09:12 +0530 Subject: [PATCH 19/20] Update runtime/testnet/src/lib.rs Co-authored-by: Gautham --- runtime/testnet/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/testnet/src/lib.rs b/runtime/testnet/src/lib.rs index 521f990ac..83a93e8e5 100644 --- a/runtime/testnet/src/lib.rs +++ b/runtime/testnet/src/lib.rs @@ -340,7 +340,7 @@ parameter_types! { impl pallet_treasury::Config for Runtime { type ModuleId = TreasuryModuleId; - type Currency = Balances; + type Currency = NativeAssetCurrency; type ApproveOrigin = EnsureOneOf< AccountId, EnsureRoot, From bc4af56c0f645496fc6c939652b20a777c80b416 Mon Sep 17 00:00:00 2001 From: ksr30 Date: Thu, 14 Jan 2021 13:07:43 +0530 Subject: [PATCH 20/20] resolved error --- node/mainnet/src/cli.rs | 4 +++- node/mainnet/src/command.rs | 28 +++++----------------------- node/testnet/src/command.rs | 23 +++-------------------- 3 files changed, 11 insertions(+), 44 deletions(-) diff --git a/node/mainnet/src/cli.rs b/node/mainnet/src/cli.rs index 874a7965b..d9f43c793 100644 --- a/node/mainnet/src/cli.rs +++ b/node/mainnet/src/cli.rs @@ -1,5 +1,5 @@ -use sc_cli::RunCmd; use structopt::StructOpt; +use sc_cli::RunCmd; #[derive(Debug, StructOpt)] pub struct Cli { @@ -12,6 +12,8 @@ pub struct Cli { #[derive(Debug, StructOpt)] pub enum Subcommand { + /// Key management cli utilities + Key(sc_cli::KeySubcommand), /// Build a chain specification. BuildSpec(sc_cli::BuildSpecCmd), diff --git a/node/mainnet/src/command.rs b/node/mainnet/src/command.rs index 0fe326b5a..d86b3321f 100644 --- a/node/mainnet/src/command.rs +++ b/node/mainnet/src/command.rs @@ -1,27 +1,9 @@ -// This file is part of Substrate. - -// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - use crate::{chain_spec, service}; use crate::cli::{Cli, Subcommand}; use sc_cli::{SubstrateCli, RuntimeVersion, Role, ChainSpec}; use sc_service::PartialComponents; use polkadex_mainnet_runtime::Block; - impl SubstrateCli for Cli { fn impl_name() -> String { "Substrate Node".into() @@ -67,6 +49,7 @@ pub fn run() -> sc_cli::Result<()> { let cli = Cli::from_args(); match &cli.subcommand { + Some(Subcommand::Key(cmd)) => cmd.run(&cli), Some(Subcommand::BuildSpec(cmd)) => { let runner = cli.create_runner(cmd)?; runner.sync_run(|config| cmd.run(config.chain_spec, config.network)) @@ -128,11 +111,10 @@ pub fn run() -> sc_cli::Result<()> { None => { let runner = cli.create_runner(&cli.run)?; runner.run_node_until_exit(|config| async move { - let role = config.role.clone(); - match role { - Role::Light => service::new_light(config), - _ => service::new_full(config), - } + match config.role { + Role::Light => service::new_light(config), + _ => service::new_full(config), + }.map_err(sc_cli::Error::Service) }) } } diff --git a/node/testnet/src/command.rs b/node/testnet/src/command.rs index a10e6fc80..adb775825 100644 --- a/node/testnet/src/command.rs +++ b/node/testnet/src/command.rs @@ -1,20 +1,3 @@ -// This file is part of Substrate. - -// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - use crate::{chain_spec, service}; use crate::cli::{Cli, Subcommand}; use sc_cli::{SubstrateCli, RuntimeVersion, Role, ChainSpec}; @@ -23,7 +6,7 @@ use polkadex_testnet_runtime::Block; impl SubstrateCli for Cli { fn impl_name() -> String { - "Polkadex Testnet Node".into() + "Substrate Node".into() } fn impl_version() -> String { @@ -131,8 +114,8 @@ pub fn run() -> sc_cli::Result<()> { match config.role { Role::Light => service::new_light(config), _ => service::new_full(config), - } + }.map_err(sc_cli::Error::Service) }) } } -} \ No newline at end of file +}