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 all 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: 2 additions & 2 deletions node/mainnet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
14 changes: 7 additions & 7 deletions node/mainnet/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@ 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};
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/";
Expand Down Expand Up @@ -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()
})
}
}
Expand Down
4 changes: 3 additions & 1 deletion node/mainnet/src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use sc_cli::RunCmd;
use structopt::StructOpt;
use sc_cli::RunCmd;

#[derive(Debug, StructOpt)]
pub struct Cli {
Expand All @@ -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),

Expand Down
28 changes: 5 additions & 23 deletions node/mainnet/src/command.rs
Original file line number Diff line number Diff line change
@@ -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()
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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)
})
}
}
Expand Down
6 changes: 3 additions & 3 deletions node/mainnet/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub fn create_full<C, P>(
C::Api: substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Index>,
C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance>,
C::Api: BlockBuilder<Block>,
C::Api: runtime_api::DexStorageApi<Block>,
C::Api: engine_runtime_api::DexStorageApi<Block>,
P: TransactionPool + 'static,
{
use substrate_frame_rpc_system::{FullSystem, SystemApi};
Expand All @@ -49,8 +49,8 @@ pub fn create_full<C, P>(
} = 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(
Expand Down
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
23 changes: 3 additions & 20 deletions node/testnet/src/command.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand All @@ -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 {
Expand Down Expand Up @@ -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)
})
}
}
}
}
14 changes: 10 additions & 4 deletions runtime/mainnet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down Expand Up @@ -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']
Expand All @@ -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',
Expand All @@ -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]
Expand Down
52 changes: 38 additions & 14 deletions runtime/mainnet/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ parameter_types! {
// }

impl pallet_transaction_payment::Config for Runtime {
type OnChargeTransaction = CurrencyAdapter<SpendingAssetCurrency<Self>, ()>;
type OnChargeTransaction = CurrencyAdapter<NativeAssetCurrency<Self>, ()>;
type TransactionByteFee = TransactionByteFee;
type WeightToFee = IdentityFee<Balance>;
type FeeMultiplierUpdate = ();
Expand All @@ -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};

Expand Down Expand Up @@ -358,7 +358,7 @@ parameter_types! {
}

impl pallet_staking::Config for Runtime {
type Currency = StakingAssetCurrency<Self>;
type Currency = NativeAssetCurrency<Self>;
type UnixTime = Timestamp;
type CurrencyToVote = U128CurrencyToVote;
type RewardRemainder = (); // Treasury
Expand Down Expand Up @@ -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();
Expand All @@ -402,11 +424,11 @@ impl<C> frame_system::offchain::SendTransactionTypes<C> 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! {
Expand Down Expand Up @@ -435,12 +457,14 @@ construct_runtime!(
Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>},
TransactionPayment: pallet_transaction_payment::{Module, Storage},
Sudo: pallet_sudo::{Module, Call, Config<T>, Storage, Event<T>},
GenericAsset: pallet_generic_asset::{Module, Call, Storage, Config<T>, Event<T>},
CustomAsset: polkadex_custom_assets::{Module, Call, Storage, Config<T>, Event<T>},
Staking: pallet_staking::{Module, Call, Config<T>, Storage, Event<T>, ValidateUnsigned},
Session: pallet_session::{Module, Call, Storage, Event, Config<T>},
Historical: pallet_session_historical::{Module},
// Include the custom logic from the polkadex pallet in the runtime.
Polkadex: polkadex::{Module, Call, Storage, Event<T>},
PolkadexUniswap: polkadex_swap_engine::{Module, Call, Storage, Event<T>},
PolkadexIdentity: pallet_idenity::{Module, Call, Storage, Event<T>},
}
);

Expand Down Expand Up @@ -647,32 +671,32 @@ impl_runtime_apis! {

impl runtime_api::DexStorageApi<Block> for Runtime{

fn get_ask_level(trading_pair: Hash) -> Result<Vec<FixedU128>,ErrorRpc> {
fn get_ask_level(trading_pair: (Hash,Hash)) -> Result<Vec<FixedU128>,ErrorRpc> {

Polkadex::get_ask_level(trading_pair)
}

fn get_bid_level(trading_pair: Hash) -> Result<Vec<FixedU128>,ErrorRpc> {
fn get_bid_level(trading_pair: (Hash,Hash)) -> Result<Vec<FixedU128>,ErrorRpc> {

Polkadex::get_bid_level(trading_pair)
}

fn get_price_level(trading_pair: Hash) -> Result<Vec<LinkedPriceLevelRpc>,ErrorRpc> {
fn get_price_level(trading_pair: (Hash,Hash)) -> Result<Vec<LinkedPriceLevelRpc>,ErrorRpc> {
Polkadex::get_price_level(trading_pair)
}
fn get_orderbook(trading_pair: Hash) -> Result<OrderbookRpc, ErrorRpc> {
fn get_orderbook(trading_pair: (Hash,Hash)) -> Result<OrderbookRpc, ErrorRpc> {
Polkadex::get_orderbook(trading_pair)
}

fn get_all_orderbook() -> Result<Vec<OrderbookRpc>, ErrorRpc> {
Polkadex::get_all_orderbook()
}

fn get_market_info(trading_pair: Hash,blocknum: u32) -> Result<MarketDataRpc, ErrorRpc> {
Polkadex::get_market_info(trading_pair,blocknum)
fn get_market_info(trading_pair: (Hash,Hash)) -> Result<MarketDataRpc, ErrorRpc> {
Polkadex::get_market_info(trading_pair)
}

fn get_orderbook_updates(trading_pair: Hash)-> Result<OrderbookUpdates, ErrorRpc>{
fn get_orderbook_updates(trading_pair: (Hash,Hash))-> Result<OrderbookUpdates, ErrorRpc>{
Polkadex::get_orderbook_updates(trading_pair)
}

Expand Down
Loading