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

Fe develop #137

Merged
merged 6 commits into from
Dec 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
100 changes: 50 additions & 50 deletions node/cli/res/crayfish-fir.json

Large diffs are not rendered by default.

10 changes: 8 additions & 2 deletions node/cli/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use sr_primitives::{
traits::{IdentifyAccount, Verify},
Perbill,
};
use substrate_service;
use substrate_service::Properties;
use substrate_telemetry::TelemetryEndpoints;

type AccountPublic = <Signature as Verify>::Signer;
Expand Down Expand Up @@ -431,7 +431,13 @@ pub fn crayfish_testnet_config() -> ChainSpec {
vec![],
Some(TelemetryEndpoints::new(vec![(STAGING_TELEMETRY_URL.to_string(), 0)])),
Some("DAR"),
None,
{
let mut properties = Properties::new();
properties.insert("tokenDecimals".into(), 9.into());
properties.insert("tokenSymbol".into(), "RING".into());

Some(properties)
},
Default::default(),
)
}
11 changes: 7 additions & 4 deletions node/runtime/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ pub mod time {
///
/// <https://research.web3.foundation/en/latest/polkadot/BABE/Babe/#6-practical-results>

// Test
// pub const MILLISECS_PER_BLOCK: Moment = 1000;
// Develop
pub const MILLISECS_PER_BLOCK: Moment = 1000;
// Production
pub const MILLISECS_PER_BLOCK: Moment = 3000;
// pub const MILLISECS_PER_BLOCK: Moment = 3000;
pub const SECS_PER_BLOCK: Moment = MILLISECS_PER_BLOCK / 1000;

pub const SLOT_DURATION: Moment = MILLISECS_PER_BLOCK;
Expand All @@ -63,7 +63,10 @@ pub mod time {
pub const EPOCH_DURATION_IN_SLOTS: u64 = {
const SLOT_FILL_RATE: f64 = MILLISECS_PER_BLOCK as f64 / SLOT_DURATION as f64;

(EPOCH_DURATION_IN_BLOCKS as f64 * SLOT_FILL_RATE) as u64
// Develop
2
// Production
// (EPOCH_DURATION_IN_BLOCKS as f64 * SLOT_FILL_RATE) as u64
};

// These time units are defined in number of blocks.
Expand Down
9 changes: 2 additions & 7 deletions node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ use version::RuntimeVersion;
use constants::{currency::*, time::*};
use darwinia_support::TimeStamp;
use impls::{Author, CurrencyToVoteHandler, LinearWeightToFee, TargetedFeeAdjustment};
use staking::EraIndex;

// Make the WASM binary available.
#[cfg(feature = "std")]
Expand Down Expand Up @@ -351,12 +350,9 @@ impl kton::Trait for Runtime {
}

parameter_types! {
pub const Period: BlockNumber = 1 * MINUTES;
pub const SessionsPerEra: sr_staking_primitives::SessionIndex = 5;
pub const SessionsPerEra: sr_staking_primitives::SessionIndex = 6;
// about 14 days = 14 * 24 * 60 * 60
pub const BondingDuration: TimeStamp = 1209600;
// 365 days * 24 hours * 60 minutes / 5 minutes
pub const ErasPerEpoch: EraIndex = 105120;
pub const BondingDuration: TimeStamp = 1_209_600;
// decimal 9
pub const HardCap: Balance = 10_000_000_000 * COIN;
// date in Los Angeles*: 11/19/2019, 2:33:20 AM
Expand All @@ -380,7 +376,6 @@ impl staking::Trait for Runtime {
type BondingDuration = BondingDuration;
type Cap = HardCap;
type GenesisTime = GenesisTime;
type ErasPerEpoch = ErasPerEpoch;
type SessionInterface = Self;
}

Expand Down
12 changes: 0 additions & 12 deletions srml/staking/src/inflation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,6 @@ pub fn compute_total_payout<T: Trait>(
(payout, maximum)
}

//change when new epoch
// the total reward per era
//pub fn compute_current_era_reward<T: Trait + 'static>() -> RingBalanceOf<T> {
// let eras_per_epoch: RingBalanceOf<T> = <T::ErasPerEpoch as Get<EraIndex>>::get().into();
// let current_epoch: u32 = <Module<T>>::epoch_index();
// let total_left: u128 = (T::Cap::get() - T::Ring::total_issuance()).saturated_into::<u128>();
// let surplus = total_left
// - total_left * 99_u128.pow(current_epoch.integer_sqrt()) / 100_u128.pow(current_epoch.integer_sqrt());
// let surplus: RingBalanceOf<T> = <RingBalanceOf<T>>::saturated_from::<u128>(surplus);
// (surplus / eras_per_epoch)
//}

// consistent with the formula in smart contract in evolution land which can be found in
// https://github.com/evolutionlandorg/bank/blob/master/contracts/GringottsBank.sol#L280
pub fn compute_kton_return<T: Trait>(value: RingBalanceOf<T>, months: u32) -> KtonBalanceOf<T> {
Expand Down
2 changes: 0 additions & 2 deletions srml/staking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,6 @@ pub trait Trait: timestamp::Trait + session::Trait {
type Cap: Get<<Self::Ring as Currency<Self::AccountId>>::Balance>;
type GenesisTime: Get<MomentOf<Self>>;

type ErasPerEpoch: Get<EraIndex>;

/// Interface for interacting with a session module.
type SessionInterface: self::SessionInterface<Self::AccountId>;
}
Expand Down
3 changes: 0 additions & 3 deletions srml/staking/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ impl kton::Trait for Test {
parameter_types! {
pub const SessionsPerEra: SessionIndex = 3;
pub const BondingDuration: TimeStamp = 60;
pub const ErasPerEpoch: EraIndex = 10;
}
parameter_types! {
// decimal 9
Expand All @@ -204,7 +203,6 @@ impl Trait for Test {
type BondingDuration = BondingDuration;
type Cap = CAP;
type GenesisTime = ();
type ErasPerEpoch = ErasPerEpoch;
type SessionInterface = Self;
}

Expand Down Expand Up @@ -322,7 +320,6 @@ impl ExtBuilder {
let nominated = if self.nominate { vec![11, 21] } else { vec![] };
let _ = GenesisConfig::<Test> {
current_era: self.current_era,
// current_era_total_reward: 80_000_000 * COIN / ErasPerEpoch::get() as u64,
stakers: vec![
// (2, 1, 1 * COIN, StakerStatus::<AccountId>::Validator),
(11, 10, 100 * COIN, StakerStatus::<AccountId>::Validator),
Expand Down
6 changes: 1 addition & 5 deletions srml/staking/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,7 @@ fn expired_ring_should_capable_to_promise_again() {
});
}

// TODO
#[test]
fn inflation_should_be_correct() {
ExtBuilder::default().existential_deposit(0).build().execute_with(|| {
Expand All @@ -498,11 +499,6 @@ fn inflation_should_be_correct() {
let _ = Ring::deposit_into_existing(&11, surplus_needed);

assert_eq!(Ring::total_issuance(), initial_issuance);
// TODO
// assert_eq!(Staking::current_era_total_reward(), 80000000 * COIN / 10);
// start_era(11);
// // ErasPerEpoch = 10
// assert_eq!(Staking::current_era_total_reward(), 88000000 * COIN / 10);
});
}

Expand Down