Skip to content

Commit

Permalink
adjust genesis endud balance (paritytech#158)
Browse files Browse the repository at this point in the history
1. adjust genesis endud balance
2. add debug log for fee
3. add type in scripts
  • Loading branch information
atenjin committed Jul 27, 2020
1 parent 421f96a commit 42635a0
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 23 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

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

40 changes: 21 additions & 19 deletions cli/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::collections::BTreeMap;
use std::convert::TryFrom;

use chainx_runtime::{
h256_conv_endian_from_str, trustees, AssetInfo, AssetRestriction, AssetRestrictions,
constants, h256_conv_endian_from_str, trustees, AssetInfo, AssetRestriction, AssetRestrictions,
BtcCompact, BtcHeader, BtcNetwork, BtcParams, BtcTxVerifier, Chain, ContractsSchedule,
NetworkType, TrusteeInfoConfig,
};
Expand Down Expand Up @@ -77,16 +77,17 @@ macro_rules! endowed_gen {
}

pub fn development_config() -> ChainSpec {
let constructor = || {
let endowed_balance = 50 * constants::currency::DOLLARS;
let constructor = move || {
testnet_genesis(
vec![authority_keys_from_seed("Alice")],
get_account_id_from_seed::<sr25519::Public>("Alice"),
testnet_assets(),
endowed_gen![
("Alice", 100000),
("Bob", 100000),
("Alice//stash", 100000),
("Bob//stash", 100000),
("Alice", endowed_balance),
("Bob", endowed_balance),
("Alice//stash", endowed_balance),
("Bob//stash", endowed_balance),
],
testnet_trustees(),
true,
Expand All @@ -106,7 +107,8 @@ pub fn development_config() -> ChainSpec {
}

pub fn local_testnet_config() -> ChainSpec {
let constructor = || {
let endowed_balance = 50 * constants::currency::DOLLARS;
let constructor = move || {
testnet_genesis(
vec![
authority_keys_from_seed("Alice"),
Expand All @@ -115,18 +117,18 @@ pub fn local_testnet_config() -> ChainSpec {
get_account_id_from_seed::<sr25519::Public>("Alice"),
testnet_assets(),
endowed_gen![
("Alice", 100000),
("Bob", 100000),
("Charlie", 100000),
("Dave", 100000),
("Eve", 100000),
("Ferdie", 100000),
("Alice//stash", 100000),
("Bob//stash", 100000),
("Charlie//stash", 100000),
("Dave//stash", 100000),
("Eve//stash", 100000),
("Ferdie//stash", 100000),
("Alice", endowed_balance),
("Bob", endowed_balance),
("Charlie", endowed_balance),
("Dave", endowed_balance),
("Eve", endowed_balance),
("Ferdie", endowed_balance),
("Alice//stash", endowed_balance),
("Bob//stash", endowed_balance),
("Charlie//stash", endowed_balance),
("Dave//stash", endowed_balance),
("Eve//stash", endowed_balance),
("Ferdie//stash", endowed_balance),
],
testnet_trustees(),
true,
Expand Down
2 changes: 1 addition & 1 deletion runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ pub use xpallet_transaction_payment::{Multiplier, TargetedFeeAdjustment};

/// Constant values used within the runtime.
pub mod constants;
use constants::{currency::*, time::*};
pub use constants::{currency::*, time::*};

impl_opaque_keys! {
pub struct SessionKeys {
Expand Down
1 change: 1 addition & 0 deletions scripts/chainx_types_manual.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"Address": "AccountId",
"AssetInfoForRpc": {
"token": "String",
"token_name": "String",
Expand Down
3 changes: 3 additions & 0 deletions xpallets/transaction-payment/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ frame-system = { git = "https://github.com/paritytech/substrate.git", tag = "v2.

# ChainX pallets
xpallet-transaction-payment-rpc-runtime-api = { path = "./rpc/runtime-api", default-features = false }
xpallet-support = { path = "../support", default-features = false }
xpallet-assets = { path = "../assets", default-features = false }

[dev-dependencies]
Expand All @@ -44,6 +45,8 @@ std = [
"sp-runtime/std",
"frame-support/std",
"frame-system/std",

"xpallet-transaction-payment-rpc-runtime-api/std",
"xpallet-support/std",
"xpallet-assets/std",
]
9 changes: 6 additions & 3 deletions xpallets/transaction-payment/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ use sp_runtime::{
FixedPointNumber, FixedPointOperand, FixedU128, Perquintill,
};
use sp_std::prelude::*;
use xpallet_support::debug;
use xpallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo;

/// Fee multiplier.
pub type Multiplier = FixedU128;

Expand Down Expand Up @@ -326,11 +326,14 @@ where
let adjusted_weight_fee = multiplier.saturating_mul_int(unadjusted_weight_fee);

let base_fee = Self::weight_to_fee(T::ExtrinsicBaseWeight::get());
base_fee
let total = base_fee
.saturating_add(fixed_len_fee)
.saturating_add(adjusted_weight_fee)
.saturating_add(tip)
.saturating_add(tip);
debug!("[fee]|total:{:?}|base_fee:{:?}|fixed_len_fee:{:?}|adjusted_weight_fee:{:?}|tip:{:?}", total, base_fee, fixed_len_fee, adjusted_weight_fee, tip);
total
} else {
debug!("[fee]|just tip|tip:{:?}", tip);
tip
}
}
Expand Down

0 comments on commit 42635a0

Please sign in to comment.