Skip to content

Commit

Permalink
Merge pull request #155 from AurevoirXavier/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
hackfisher authored Dec 11, 2019
2 parents 8804585 + c32bf22 commit e0fdd25
Show file tree
Hide file tree
Showing 27 changed files with 3,243 additions and 870 deletions.
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

0 comments on commit e0fdd25

Please sign in to comment.