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

Feature/41 install governance pallet #78

Merged
merged 23 commits into from
Jan 14, 2021
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
cec5817
Added pallet-collective in cargo.toml
ayushmishra2005 Jan 8, 2021
e637144
Changed version
ayushmishra2005 Jan 8, 2021
bacc191
#41 added dependency of treasury pallet
ayushmishra2005 Jan 8, 2021
cdbc79b
#41 Moved dependecy version back to master
ayushmishra2005 Jan 8, 2021
5584f80
Added pallet-collective in cargo.toml
ayushmishra2005 Jan 8, 2021
8d8aa88
Changed version
ayushmishra2005 Jan 8, 2021
6e487f6
#41 added dependency of treasury pallet
ayushmishra2005 Jan 8, 2021
bbe49d0
#41 Moved dependecy version back to master
ayushmishra2005 Jan 8, 2021
60c4dac
Merge branch 'feature/41-install-governance-pallet' of https://github…
ayushmishra2005 Jan 13, 2021
5fc8144
Integrated Treasury and Collective Pallet
ayushmishra2005 Jan 13, 2021
d38fc77
mainnet runtime updated
jaxter03 Jan 13, 2021
c056193
Merge pull request #77 from Polkadex-Substrate/feature/18-impl-cust-a…
jaxter03 Jan 14, 2021
5f35687
Update runtime/testnet/src/lib.rs
ayushmishra2005 Jan 14, 2021
0372f9f
Added pallet-collective in cargo.toml
ayushmishra2005 Jan 8, 2021
db6e1ff
Changed version
ayushmishra2005 Jan 8, 2021
16e4317
#41 added dependency of treasury pallet
ayushmishra2005 Jan 8, 2021
d5b4415
#41 Moved dependecy version back to master
ayushmishra2005 Jan 8, 2021
8c0d505
Changed version
ayushmishra2005 Jan 8, 2021
8f3dc1a
#41 Moved dependecy version back to master
ayushmishra2005 Jan 8, 2021
8591864
Integrated Treasury and Collective Pallet
ayushmishra2005 Jan 13, 2021
578714a
Update runtime/testnet/src/lib.rs
ayushmishra2005 Jan 14, 2021
118eb85
Merge branch 'feature/41-install-governance-pallet' of https://github…
ayushmishra2005 Jan 14, 2021
bc4af56
resolved error
jaxter03 Jan 14, 2021
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: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ Cargo.lock
.local

.idea

.cargo/
pallets/polkadex/.idea
4 changes: 3 additions & 1 deletion node/testnet/src/chain_spec.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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,
Expand Down
9 changes: 9 additions & 0 deletions runtime/testnet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,15 @@ 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 }
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 = { 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" }
Expand All @@ -67,7 +70,10 @@ 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',
'sp-runtime/runtime-benchmarks',
]
std = [
Expand All @@ -79,13 +85,16 @@ 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',
'pallet-sudo/std',
'pallet-polkadex/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',
Expand Down
100 changes: 92 additions & 8 deletions runtime/testnet/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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<CouncilCollective> 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<Runtime>;
}

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;
ayushmishra2005 marked this conversation as resolved.
Show resolved Hide resolved
type ApproveOrigin = EnsureOneOf<
AccountId,
EnsureRoot<AccountId>,
pallet_collective::EnsureProportionAtLeast<_3, _5, AccountId, CouncilCollective>
>;
type RejectOrigin = EnsureOneOf<
AccountId,
EnsureRoot<AccountId>,
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<Runtime>;
}

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<Runtime>;
}

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!(
Expand All @@ -319,6 +397,9 @@ construct_runtime!(
PolkadexIdentity: pallet_idenity::{Module, Call, Storage, Event<T>},
// Include the custom logic from the template pallet in the runtime.
Polkadex: pallet_polkadex::{Module, Call, Storage, Event<T>},
Council: pallet_collective::<Instance1>::{Module, Call, Storage, Origin<T>, Event<T>, Config<T>},
Treasury: pallet_treasury::{Module, Call, Storage, Config, Event<T>},
Bounties: pallet_bounties::{Module, Call, Storage, Event<T>},
}
);

Expand Down Expand Up @@ -540,7 +621,10 @@ impl_runtime_apis! {

add_benchmark!(params, batches, frame_system, SystemBench::<Runtime>);
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)
Expand Down