Skip to content

Commit

Permalink
Feature/fee map (paritytech#160)
Browse files Browse the repository at this point in the history
* Add xfee config

* Fuse xexecutive runtime xfee

* Format

* Fix build error
  • Loading branch information
gguoss authored Dec 19, 2018
1 parent ef3ec2c commit 08965ba
Show file tree
Hide file tree
Showing 16 changed files with 688 additions and 515 deletions.
9 changes: 9 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ members = [
"xrml/xsupport",
"xrml/xexecutive",
"xrml/xfee/manager",
"xrml/xfee/config",
]
50 changes: 33 additions & 17 deletions cli/src/chain_spec.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use chainx_runtime::GenesisConfig;
use substrate_service;
use genesis_config::{testnet_genesis, GenesisSpec};
use substrate_service;

const STAGING_TELEMETRY_URL: &str = "ws://stats.chainx.org/submit/";

Expand All @@ -9,18 +9,17 @@ pub type ChainSpec = substrate_service::ChainSpec<GenesisConfig>;

/// Staging testnet config.
pub fn staging_testnet_config() -> ChainSpec {
let boot_nodes = vec![
];
ChainSpec::from_genesis(
"Staging Testnet",
"staging_testnet",
staging_testnet_config_genesis,
boot_nodes,
Some(STAGING_TELEMETRY_URL.into()),
None,
None,
None,
)
let boot_nodes = vec![];
ChainSpec::from_genesis(
"Staging Testnet",
"staging_testnet",
staging_testnet_config_genesis,
boot_nodes,
Some(STAGING_TELEMETRY_URL.into()),
None,
None,
None,
)
}

fn staging_testnet_config_genesis() -> GenesisConfig {
Expand All @@ -33,15 +32,32 @@ fn development_config_genesis() -> GenesisConfig {

/// Development config (single validator Alice)
pub fn development_config() -> ChainSpec {
ChainSpec::from_genesis("Development", "development", development_config_genesis, vec![], None, None, None, None)
ChainSpec::from_genesis(
"Development",
"development",
development_config_genesis,
vec![],
None,
None,
None,
None,
)
}

fn local_testnet_genesis() -> GenesisConfig {
testnet_genesis(GenesisSpec::Local)
testnet_genesis(GenesisSpec::Local)
}

/// Local testnet config (multivalidator Alice + Bob)
pub fn local_testnet_config() -> ChainSpec {
ChainSpec::from_genesis("Local Testnet", "local_testnet", local_testnet_genesis, vec![], None, None, None, None)
ChainSpec::from_genesis(
"Local Testnet",
"local_testnet",
local_testnet_genesis,
vec![],
None,
None,
None,
None,
)
}

44 changes: 29 additions & 15 deletions cli/src/genesis_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ extern crate substrate_primitives;

use self::base58::FromBase58;
use chainx_runtime::GrandpaConfig;
use chainx_runtime::{GenesisConfig, ConsensusConfig, CouncilVotingConfig, DemocracyConfig,
SessionConfig, StakingConfig, TimestampConfig, BalancesConfig, TreasuryConfig,
ContractConfig, Permill, Perbill, XFeeManagerConfig, /*TokenBalancesConfig, FinancialRecordsConfig,
MultiSigConfig, BalancesConfigCopy, BridgeOfBTCConfig, Params, Token, PendingOrdersConfig, MatchOrderConfig*/};
use chainx_runtime::{
BalancesConfig, ConsensusConfig, ContractConfig, CouncilVotingConfig, DemocracyConfig,
GenesisConfig, Perbill, Permill, SessionConfig, StakingConfig, TimestampConfig, TreasuryConfig,
XFeeManagerConfig, /*TokenBalancesConfig, FinancialRecordsConfig,
MultiSigConfig, BalancesConfigCopy, BridgeOfBTCConfig, Params, Token, PendingOrdersConfig, MatchOrderConfig*/
};
use ed25519;
use ed25519::Public;

Expand All @@ -21,7 +23,7 @@ use self::btc_primitives::{compact::Compact, hash::H256};
use self::keys::DisplayLayout;

pub enum GenesisSpec {
Dev,
Dev,
Local,
Multi,
}
Expand Down Expand Up @@ -49,7 +51,7 @@ pub fn testnet_genesis(genesis_spec: GenesisSpec) -> GenesisConfig {
// const DOLLARS: u128 = 100 * CENTS;

const MILLICENTS: u128 = 1_000_000_000;
const CENTS: u128 = 1_000 * MILLICENTS; // assume this is worth about a cent.
const CENTS: u128 = 1_000 * MILLICENTS; // assume this is worth about a cent.
const DOLLARS: u128 = 100 * CENTS;

const SECS_PER_BLOCK: u64 = 1;
Expand All @@ -74,11 +76,15 @@ pub fn testnet_genesis(genesis_spec: GenesisSpec) -> GenesisConfig {
consensus: Some(ConsensusConfig {
code: include_bytes!(
"../../runtime/wasm/target/wasm32-unknown-unknown/release/chainx_runtime.compact.wasm"
).to_vec(),
)
.to_vec(),
authorities: initial_authorities.clone(),
}),
system: None,
fee_manager: Some(XFeeManagerConfig { switch: false, _genesis_phantom_data: Default::default(), }),
fee_manager: Some(XFeeManagerConfig {
switch: false,
_genesis_phantom_data: Default::default(),
}),
balances: Some(balances_config),
session: Some(SessionConfig {
validators: initial_authorities
Expand All @@ -90,7 +96,11 @@ pub fn testnet_genesis(genesis_spec: GenesisSpec) -> GenesisConfig {
}),
staking: Some(StakingConfig {
current_era: 0,
intentions: initial_authorities.iter().cloned().map(Into::into).collect(),
intentions: initial_authorities
.iter()
.cloned()
.map(Into::into)
.collect(),
offline_slash: Perbill::from_billionths(1_000_000),
session_reward: Perbill::from_billionths(2_065),
current_offline_slash: 0,
Expand All @@ -101,7 +111,7 @@ pub fn testnet_genesis(genesis_spec: GenesisSpec) -> GenesisConfig {
offline_slash_grace: 4,
minimum_validator_count: 4,
}),
/*
/*
staking: Some(StakingConfig {
current_era: 0,
bonding_duration: 3 * MINUTES, // 3 days per bond.
Expand All @@ -120,7 +130,7 @@ pub fn testnet_genesis(genesis_spec: GenesisSpec) -> GenesisConfig {
democracy: Some(DemocracyConfig {
launch_period: 5 * MINUTES, // 1 day per public referendum
voting_period: 5 * MINUTES, // 3 days to discuss & vote on an active referendum
minimum_deposit: 50 * DOLLARS, // 12000 as the minimum deposit for a referendum
minimum_deposit: 50 * DOLLARS, // 12000 as the minimum deposit for a referendum
public_delay: 0,
max_lock_periods: 6,
}),
Expand All @@ -130,7 +140,7 @@ pub fn testnet_genesis(genesis_spec: GenesisSpec) -> GenesisConfig {
enact_delay_period: 0,
}),
timestamp: Some(TimestampConfig {
period: SECS_PER_BLOCK, // 3 second block time.
period: SECS_PER_BLOCK, // 3 second block time.
}),
treasury: Some(TreasuryConfig {
proposal_bond: Permill::from_percent(5),
Expand All @@ -147,7 +157,7 @@ pub fn testnet_genesis(genesis_spec: GenesisSpec) -> GenesisConfig {
block_gas_limit: 10_000_000,
current_schedule: Default::default(),
}),
/* cxsystem: Some(CXSystemConfig {
/* cxsystem: Some(CXSystemConfig {
death_account: substrate_primitives::H256([0; 32]),
fee_buy_account: substrate_primitives::H256([1; 32]),
}),
Expand Down Expand Up @@ -209,7 +219,11 @@ pub fn testnet_genesis(genesis_spec: GenesisSpec) -> GenesisConfig {
matchorder: Some(MatchOrderConfig { match_fee: 10, _genesis_phantom_data: Default::default(),}),
*/
grandpa: Some(GrandpaConfig {
authorities: initial_authorities.clone().into_iter().map(|k| (k, 1)).collect(),
})
authorities: initial_authorities
.clone()
.into_iter()
.map(|k| (k, 1))
.collect(),
}),
}
}
Loading

0 comments on commit 08965ba

Please sign in to comment.