Skip to content

Commit

Permalink
Prepare IceFrog (#194)
Browse files Browse the repository at this point in the history
Prepare IceFrog
  • Loading branch information
AurevoirXavier authored Dec 26, 2019
2 parents 368a8d3 + 70f9d02 commit e697348
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 10 deletions.
32 changes: 24 additions & 8 deletions node/cli/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,9 @@ pub fn darwinia_genesis(
get_account_id_from_seed::<sr25519::Public>("Bob"),
];

const ENDOWMENT: Balance = 1_000_000 * COIN;
const STASH: Balance = 100 * COIN;
const RING_ENDOWMENT: Balance = 20_000_000 * COIN;
const KTON_ENDOWMENT: Balance = 10 * COIN;
const STASH: Balance = 1000 * COIN;

GenesisConfig {
babe: Some(Default::default()),
Expand Down Expand Up @@ -242,7 +243,7 @@ pub fn darwinia_genesis(
balances: endowed_accounts
.iter()
.cloned()
.map(|k| (k, ENDOWMENT))
.map(|k| (k, RING_ENDOWMENT))
.chain(initial_authorities.iter().map(|x| (x.0.clone(), STASH)))
.collect(),
vesting: vec![],
Expand All @@ -251,7 +252,7 @@ pub fn darwinia_genesis(
balances: endowed_accounts
.iter()
.cloned()
.map(|k| (k, ENDOWMENT))
.map(|k| (k, KTON_ENDOWMENT))
.chain(initial_authorities.iter().map(|x| (x.0.clone(), STASH)))
.collect(),
vesting: vec![],
Expand All @@ -266,9 +267,10 @@ pub fn darwinia_genesis(
.collect(),
invulnerables: initial_authorities.iter().map(|x| x.0.clone()).collect(),
slash_reward_fraction: Perbill::from_percent(10),
payout_fraction: Perbill::from_percent(50),
..Default::default()
}),
eth_relay: Some(EthRelayConfig {
eth_relay: Some(EthRelayConfig {
authorities: eth_relay_authorities,
..Default::default()
}),
Expand Down Expand Up @@ -336,9 +338,23 @@ pub fn local_testnet_config() -> ChainSpec {
pub fn icefrog_testnet_config() -> ChainSpec {
fn icefrog_config_genesis() -> GenesisConfig {
darwinia_genesis(
vec![get_authority_keys_from_seed("Alice")],
get_account_id_from_seed::<sr25519::Public>("Alice"),
None,
vec![
get_authority_keys_from_seed("Alice"),
get_authority_keys_from_seed("Bob"),
],
hex!["a60837b2782f7ffd23e95cd26d1aa8d493b8badc6636234ccd44db03c41fcc6c"].into(), // 5FpQFHfKd1xQ9HLZLQoG1JAQSCJoUEVBELnKsKNcuRLZejJR
Some(vec![
hex!["a60837b2782f7ffd23e95cd26d1aa8d493b8badc6636234ccd44db03c41fcc6c"].into(),
hex!["f29311a581558ded67b8bfd097e614ce8135f777e29777d07ec501adb0ddab08"].into(),
hex!["1098e3bf7b351d6210c61b05edefb3a2b88c9611db26fbed2c7136b6d8f9c90f"].into(),
hex!["f252bc67e45acc9b3852a0ef84ddfce6c9cef25193617ef1421c460ecc2c746f"].into(),
hex!["90ce56f84328b180fc55146709aa7038c18efd58f1f247410be0b1ddc612df27"].into(),
hex!["4ca516c4b95488d0e6e9810a429a010b5716168d777c6b1399d3ed61cce1715c"].into(),
hex!["e28573bb4d9233c799defe8f85fa80a66b43d47f4c1aef64bb8fffde1ecf8606"].into(),
hex!["20e2455350cbe36631e82ce9b12152f98a3738cb763e46e65d1a253806a26d1a"].into(),
hex!["9eccaca8a35f0659aed4df45455a855bcb3e7bff7bfc9d672b676bbb78988f0d"].into(),
hex!["98dba2d3252825f4cd1141ca4f41ea201a22b4e129a6c7253cea546dbb20e442"].into(),
]),
true,
)
}
Expand Down
2 changes: 1 addition & 1 deletion node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ parameter_types! {
pub const BondingDuration: Moment = 1_209_600_000;
pub const BondingDurationInEra: staking::EraIndex = 4032;
// decimal 9
pub const HardCap: Balance = 10_000_000_000 * COIN;
pub const HardCap: Balance = 1_000_000_000 * COIN;
// date in Los Angeles*: 11/19/2019, 2:33:20 AM
// date in Berlin* :11/19/2019, 5:33:20 PM
// date in Beijing*: 11/19/2019, 4:33:20 PM
Expand Down
3 changes: 2 additions & 1 deletion srml/staking/src/inflation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ pub fn compute_total_payout<T: Trait>(
era_duration: Moment,
living_time: Moment,
total_left: u128,
payout_fraction: Perbill,
) -> (Ring<T>, Ring<T>) {
// Milliseconds per year for the Julian year (365.25 days).
const MILLISECONDS_PER_YEAR: Moment = ((36525 * 24 * 60 * 60) / 100) * 1000;
Expand All @@ -25,7 +26,7 @@ pub fn compute_total_payout<T: Trait>(

let maximum = maximum - maximum * 99_u128.pow(year.integer_sqrt()) / 100_u128.pow(year.integer_sqrt());

let payout = maximum * 1; // TODO: add treasury ratio: Perbill::from_rational_approximation(npos_token_staked, total_tokens);
let payout = payout_fraction * maximum;

let payout: Ring<T> = <Ring<T>>::saturated_from::<u128>(payout);

Expand Down
6 changes: 6 additions & 0 deletions srml/staking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,11 @@ decl_storage! {
/// The rest of the slashed value is handled by the `Slash`.
pub SlashRewardFraction get(fn slash_reward_fraction) config(): Perbill;

/// The percentage of the total payout that is distributed to validators and nominators
///
/// The reset might go to Treasury or something else.
pub PayoutFraction get(fn payout_fraction) config(): Perbill;

/// Total *Ring* in pool.
pub RingPool get(fn ring_pool): Ring<T>;
/// Total *Kton* in pool.
Expand Down Expand Up @@ -1547,6 +1552,7 @@ impl<T: Trait> Module<T> {
era_duration.saturated_into::<Moment>(),
(T::Time::now() - T::GenesisTime::get()).saturated_into::<Moment>(),
(T::Cap::get() - T::Ring::total_issuance()).saturated_into::<Balance>(),
PayoutFraction::get(),
);

let mut total_imbalance = <PositiveImbalanceRing<T>>::zero();
Expand Down
1 change: 1 addition & 0 deletions srml/staking/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ impl ExtBuilder {
minimum_validator_count: self.minimum_validator_count,
invulnerables: self.invulnerables,
slash_reward_fraction: Perbill::from_percent(10),
payout_fraction: Perbill::from_percent(50),
..Default::default()
}
.assimilate_storage(&mut storage);
Expand Down

0 comments on commit e697348

Please sign in to comment.