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

Develop #155

Merged
merged 63 commits into from
Dec 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
9cbfb52
update: staking module
AurevoirXavier Dec 9, 2019
8b8fac3
update: types
AurevoirXavier Dec 9, 2019
d7b2d8e
update: StakingLock
AurevoirXavier Dec 9, 2019
2aebb58
patch: try fix #151
AurevoirXavier Dec 9, 2019
7751d50
Merge remote-tracking branch 'upstream/develop' into develop
AurevoirXavier Dec 9, 2019
588664f
fix: support wasm
AurevoirXavier Dec 9, 2019
627c231
update: format
AurevoirXavier Dec 9, 2019
9f0c651
Merge remote-tracking branch 'upstream/develop' into develop
AurevoirXavier Dec 10, 2019
0ab0118
update: format
AurevoirXavier Dec 10, 2019
22b5761
fix: #136
AurevoirXavier Dec 10, 2019
7adcf2f
update: format
AurevoirXavier Dec 10, 2019
99c80d0
update: develop configuration
AurevoirXavier Dec 10, 2019
a00e0d5
update: tests
AurevoirXavier Dec 10, 2019
f65a261
fix: `basic_setup_works`
AurevoirXavier Dec 10, 2019
a9a3013
add: `rewards_should_work`
AurevoirXavier Dec 10, 2019
ddf8b79
add: TODO
AurevoirXavier Dec 10, 2019
a57b2a6
update: default `node_name`
AurevoirXavier Dec 10, 2019
b105fbe
add: `multi_era_reward_should_work`
AurevoirXavier Dec 10, 2019
b3370f8
add: `staking_should_work`
AurevoirXavier Dec 10, 2019
96caa26
add: `less_than_needed_candidates_works`
AurevoirXavier Dec 10, 2019
36fbf63
add: `no_candidate_emergency_condition`
AurevoirXavier Dec 10, 2019
b41b008
add: `nominating_and_rewards_should_work`, `nominators_also_get_slashed`
AurevoirXavier Dec 10, 2019
772c48f
add: `double_staking_should_fail`
AurevoirXavier Dec 10, 2019
574b45d
add: `double_controlling_should_fail`
AurevoirXavier Dec 10, 2019
61b48ee
add: `session_and_eras_work`
AurevoirXavier Dec 10, 2019
3eb3601
add: `forcing_new_era_works`
AurevoirXavier Dec 10, 2019
4f41e7c
add: `cannot_transfer_staked_balance`
AurevoirXavier Dec 10, 2019
2be06dc
add: `cannot_transfer_staked_balance_2`
AurevoirXavier Dec 10, 2019
588d29a
add: `cannot_reserve_staked_balance`
AurevoirXavier Dec 10, 2019
8fff52f
add: `reward_destination_works`
AurevoirXavier Dec 10, 2019
a1b6d6c
add: `validator_payment_prefs_work`
AurevoirXavier Dec 10, 2019
5b3fde3
add: `bond_extra_works`
AurevoirXavier Dec 10, 2019
bca2930
add: `bond_extra_and_withdraw_unbonded_automatically_works`
AurevoirXavier Dec 10, 2019
b7a073b
add: `too_many_unbond_calls_should_not_work`
AurevoirXavier Dec 10, 2019
d252ecb
add: `slot_stake_is_least_staked_validator_and_exposure_defines_maxim…
AurevoirXavier Dec 10, 2019
48ba9e9
add: `on_free_balance_zero_stash_removes_validator`
AurevoirXavier Dec 10, 2019
3b2e9ae
add: `on_free_balance_zero_stash_removes_nominator`
AurevoirXavier Dec 10, 2019
09f2842
add: `switching_roles`
AurevoirXavier Dec 10, 2019
54a054b
add: `wrong_vote_is_null`
AurevoirXavier Dec 10, 2019
6c40446
add: `bond_with_no_staked_value`
AurevoirXavier Dec 10, 2019
f91592e
add: `bond_with_little_staked_value_bounded_by_slot_stake`
AurevoirXavier Dec 10, 2019
4312353
add: `phragmen_linear_worse_case_equalize`
AurevoirXavier Dec 10, 2019
eadba9f
add: `new_era_elects_correct_number_of_validators`
AurevoirXavier Dec 10, 2019
c2dd357
add: `reward_from_authorship_event_handler_works`
AurevoirXavier Dec 10, 2019
57342de
add: `add_reward_points_fns_works`
AurevoirXavier Dec 10, 2019
1687d98
add: `unbonded_balance_is_not_slashable`
AurevoirXavier Dec 10, 2019
bcd6b55
update: format
AurevoirXavier Dec 10, 2019
b50b6de
update: format
AurevoirXavier Dec 10, 2019
29e1247
fix: all timestamp to milliseconds format
AurevoirXavier Dec 10, 2019
3e4690b
update: types
AurevoirXavier Dec 10, 2019
fc82bcc
add: `era_is_always_same_length`
AurevoirXavier Dec 10, 2019
89a4c9e
add: `offence_forces_new_era`
AurevoirXavier Dec 10, 2019
1588efc
add: `offence_ensures_new_era_without_clobbering`
AurevoirXavier Dec 10, 2019
c2840e8
add: `offence_deselects_validator_when_slash_is_zero`
AurevoirXavier Dec 10, 2019
06c7a31
add: `slashing_performed_according_exposure`
AurevoirXavier Dec 10, 2019
5792d83
add: `reporters_receive_their_slice`
AurevoirXavier Dec 10, 2019
36b7b2d
add: `invulnerables_are_not_slashed`
AurevoirXavier Dec 10, 2019
a777098
add: `dont_slash_if_fraction_is_zero`
AurevoirXavier Dec 10, 2019
fbda43a
fix: typo
AurevoirXavier Dec 11, 2019
0bec1bf
patch: try stable develop env when epoch change
AurevoirXavier Dec 11, 2019
2a554ae
fix: old tests
AurevoirXavier Dec 11, 2019
4ae0fa4
update: eliminate warnings
AurevoirXavier Dec 11, 2019
c32bf22
fix: slash 0 Kton when `deposit_ring` smaller than 0.00002 Ring
AurevoirXavier Dec 11, 2019
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
5 changes: 0 additions & 5 deletions Cargo.lock

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

6 changes: 3 additions & 3 deletions core/cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1022,7 +1022,7 @@ mod tests {
#[test]
fn test_node_key_config_input() {
fn secret_input(net_config_dir: Option<String>) -> error::Result<()> {
NodeKeyType::variants().into_iter().try_for_each(|t| {
NodeKeyType::variants().iter().try_for_each(|t| {
let node_key_type = NodeKeyType::from_str(t).unwrap();
let sk = match node_key_type {
NodeKeyType::Ed25519 => ed25519::SecretKey::generate().as_ref().to_vec(),
Expand Down Expand Up @@ -1050,7 +1050,7 @@ mod tests {
#[test]
fn test_node_key_config_file() {
fn secret_file(net_config_dir: Option<String>) -> error::Result<()> {
NodeKeyType::variants().into_iter().try_for_each(|t| {
NodeKeyType::variants().iter().try_for_each(|t| {
let node_key_type = NodeKeyType::from_str(t).unwrap();
let tmp = TempDir::new("alice")?;
let file = tmp.path().join(format!("{}_mysecret", t)).to_path_buf();
Expand Down Expand Up @@ -1080,7 +1080,7 @@ mod tests {
where
F: Fn(NodeKeyParams) -> error::Result<()>,
{
NodeKeyType::variants().into_iter().try_for_each(|t| {
NodeKeyType::variants().iter().try_for_each(|t| {
let node_key_type = NodeKeyType::from_str(t).unwrap();
f(NodeKeyParams {
node_key_type,
Expand Down
7 changes: 3 additions & 4 deletions core/merkle-patricia-trie/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,9 @@ where
{
let memdb = Rc::new(MemoryDB::new());
let mut trie = MerklePatriciaTrie::new(memdb.clone());
data.into_iter().for_each(|(key, value)| {
// TODO the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `core::ops::Try`)
trie.insert(key.as_ref().to_vec(), value.as_ref().to_vec());
});
for (k, v) in data {
trie.insert(k.as_ref().to_vec(), v.as_ref().to_vec())?;
}
trie.root()?;
Ok(trie)
}
Expand Down
5 changes: 3 additions & 2 deletions core/merkle-patricia-trie/src/tests.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
#[cfg(test)]
mod trie_tests {
use std::rc::Rc;

use hex::FromHex;
use rand::Rng;
use std::rc::Rc;
use rlp::{self};

use crate::db::MemoryDB;
use crate::proof::Proof;
use crate::trie::*;
use rlp::{self, Rlp};

fn assert_root(data: Vec<(&[u8], &[u8])>, hash: &str) {
let memdb = Rc::new(MemoryDB::new());
Expand Down
9 changes: 4 additions & 5 deletions core/merkle-patricia-trie/src/trie.rs
Original file line number Diff line number Diff line change
Expand Up @@ -765,17 +765,16 @@ impl<'a> Iterator for TrieIterator<'a> {

#[cfg(test)]
mod tests {
use rand::distributions::Alphanumeric;
use rand::seq::SliceRandom;
use rand::{thread_rng, Rng};
use std::collections::{HashMap, HashSet};
use std::rc::Rc;

use ethereum_types;
use rand::distributions::Alphanumeric;
use rand::seq::SliceRandom;
use rand::{thread_rng, Rng};

use super::*;
use crate::db::MemoryDB;
use core::borrow::Borrow;

#[test]
fn test_trie_insert() {
Expand Down Expand Up @@ -996,7 +995,7 @@ mod tests {
#[test]
fn iterator_trie() {
let memdb = Rc::new(MemoryDB::new());
let mut root1;
let root1;
let mut kv = HashMap::new();
kv.insert(b"test".to_vec(), b"test".to_vec());
kv.insert(b"test1".to_vec(), b"test1".to_vec());
Expand Down
4 changes: 2 additions & 2 deletions core/sr-eth-primitives/src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ mod tests {
fn can_calculate_difficulty_ropsten() {
let (header1, header2) = ropsten_sequential_header();
let expected = U256::from_str("f3c49f25").unwrap();
let mut ethash_params = EthashPartial::ropsten_testnet();
let ethash_params = EthashPartial::ropsten_testnet();
// ethash_params.set_difficulty_bomb_delays(0xc3500, 5000000);
assert_eq!(ethash_params.calculate_difficulty(&header2, &header1), expected);
}
Expand All @@ -493,7 +493,7 @@ mod tests {
fn can_calculate_difficulty_production() {
let (header1, header2) = sequential_header();
let expected = U256::from_str("92c07e50de0b9").unwrap();
let mut ethash_params = EthashPartial::production();
let ethash_params = EthashPartial::production();
assert_eq!(ethash_params.calculate_difficulty(&header2, &header1), expected);
}

Expand Down
21 changes: 9 additions & 12 deletions core/sr-eth-primitives/src/receipt.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
use super::*;
use codec::{Decode, Encode};
use ethbloom::{Bloom, Input as BloomInput};
use primitive_types::{H256, U256};
use rlp::*;
use rstd::prelude::*;
//use substrate_primitives::RuntimeDebug;

use codec::{Decode, Encode};
use primitive_types::{H256, U256};

use sr_primitives::RuntimeDebug;

use super::*;

#[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug)]
pub enum TransactionOutcome {
/// Status and state root are unknown under EIP-98 rules.
Expand Down Expand Up @@ -118,14 +116,13 @@ impl Decodable for Receipt {

#[cfg(test)]
mod tests {
use super::{Address, LogEntry, Receipt, TransactionOutcome, H256, U128, U256};
use ethbloom::Bloom;
use hex_literal::*;
use rustc_hex::FromHex;
use std::str::FromStr;

use hex_literal::*;
use keccak_hasher::KeccakHasher;
use triehash::ordered_trie_root;
use rustc_hex::FromHex;

use super::*;

#[inline]
fn construct_receipts(
Expand Down Expand Up @@ -159,7 +156,7 @@ mod tests {
data: vec![],
}];

let r = construct_receipts(None, U256::from(U128::from(21000)), Some(1), log_entries);
let _r = construct_receipts(None, U256::from(U128::from(21000)), Some(1), log_entries);
// let rs = &rlp::encode(&r)[..];
// TODO: fix logbloom not match here!
// assert_eq!(r.log_bloom, Bloom::from_str(
Expand Down
2 changes: 0 additions & 2 deletions node/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ version = { package = "sr-version", git = "https://github.com/darwinia-network/s

# darwinia
balances = { package = "darwinia-balances", path = '../../srml/balances', default-features = false }
darwinia-support = { path = "../../srml/support", default-features = false }
eth-relay = { package = "darwinia-eth-relay", path = "../../srml/eth-relay", default-features = false }
kton = { package = "darwinia-kton", path = '../../srml/kton', default-features = false }
node-primitives = { path = "../primitives", default-features = false }
Expand Down Expand Up @@ -108,7 +107,6 @@ std = [

# darwinia
"balances/std",
"darwinia-support/std",
"eth-relay/std",
"kton/std",
"node-primitives/std",
Expand Down
4 changes: 2 additions & 2 deletions node/runtime/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ pub mod time {

pub const EPOCH_DURATION_IN_BLOCKS: BlockNumber = 10 * MINUTES;
pub const EPOCH_DURATION_IN_SLOTS: u64 = {
// const SLOT_FILL_RATE: f64 = MILLISECS_PER_BLOCK as f64 / SLOT_DURATION as f64;
const SLOT_FILL_RATE: f64 = MILLISECS_PER_BLOCK as f64 / SLOT_DURATION as f64;

// Develop
5
60
// Production
// (EPOCH_DURATION_IN_BLOCKS as f64 * SLOT_FILL_RATE) as u64
};
Expand Down
10 changes: 6 additions & 4 deletions node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ use version::NativeVersion;
use version::RuntimeVersion;

use constants::{currency::*, time::*};
use darwinia_support::TimeStamp;
use impls::{Author, CurrencyToVoteHandler, LinearWeightToFee, TargetedFeeAdjustment};

// Make the WASM binary available.
Expand Down Expand Up @@ -350,9 +349,12 @@ impl kton::Trait for Runtime {
}

parameter_types! {
pub const SessionsPerEra: sr_staking_primitives::SessionIndex = 6;
// about 14 days = 14 * 24 * 60 * 60
pub const BondingDuration: TimeStamp = 1_209_600;
// Develop
pub const SessionsPerEra: sr_staking_primitives::SessionIndex = 1;
// Production
// pub const SessionsPerEra: sr_staking_primitives::SessionIndex = 6;
// about 14 days = 14 * 24 * 60 * 60 * 1000
pub const BondingDuration: Moment = 1_209_600_000;
// decimal 9
pub const HardCap: Balance = 10_000_000_000 * COIN;
// date in Los Angeles*: 11/19/2019, 2:33:20 AM
Expand Down
Loading