diff --git a/res/ethereum/frontier.json b/res/ethereum/frontier.json index 9cb456ce8..43be680d2 100644 --- a/res/ethereum/frontier.json +++ b/res/ethereum/frontier.json @@ -3,7 +3,7 @@ "engineName": "Ethash", "params": { "accountStartNonce": "0x00", - "frontierCompatibilityModeLimit": "0xDBBA0", + "frontierCompatibilityModeLimit": "0xdbba0", "maximumExtraDataSize": "0x20", "tieBreakingGas": false, "minGasLimit": "0x1388", diff --git a/res/ethereum/homestead_test.json b/res/ethereum/homestead_test.json index b11ef9740..1fb5dff80 100644 --- a/res/ethereum/homestead_test.json +++ b/res/ethereum/homestead_test.json @@ -3,7 +3,7 @@ "engineName": "Ethash", "params": { "accountStartNonce": "0x00", - "frontierCompatibilityModeLimit": "0", + "frontierCompatibilityModeLimit": 0, "maximumExtraDataSize": "0x20", "minGasLimit": "0x1388", "tieBreakingGas": false, diff --git a/res/ethereum/morden.json b/res/ethereum/morden.json index 32fed0cab..cdcf8c7dc 100644 --- a/res/ethereum/morden.json +++ b/res/ethereum/morden.json @@ -3,7 +3,7 @@ "engineName": "Ethash", "params": { "accountStartNonce": "0x0100000", - "frontierCompatibilityModeLimit": "0xDBBA0", + "frontierCompatibilityModeLimit": "0xdbba0", "maximumExtraDataSize": "0x20", "tieBreakingGas": false, "minGasLimit": "0x1388", diff --git a/src/ethereum/ethash.rs b/src/ethereum/ethash.rs index 019d764df..4736beb92 100644 --- a/src/ethereum/ethash.rs +++ b/src/ethereum/ethash.rs @@ -59,9 +59,14 @@ impl Engine for Ethash { } fn schedule(&self, env_info: &EnvInfo) -> Schedule { + trace!(target: "client", "Creating schedule. param={:?}, fCML={}", self.spec().engine_params.get("frontierCompatibilityModeLimit"), self.u64_param("frontierCompatibilityModeLimit")); match env_info.number < self.u64_param("frontierCompatibilityModeLimit") { - true => Schedule::new_frontier(), - _ => Schedule::new_homestead(), + true => { + Schedule::new_frontier() + }, + _ => { + Schedule::new_homestead() + }, } } @@ -178,12 +183,13 @@ impl Ethash { } } else { + trace!(target: "ethash", "Calculating difficulty parent.difficulty={}, header.timestamp={}, parent.timestamp={}", parent.difficulty, header.timestamp, parent.timestamp); + //block_diff = parent_diff + parent_diff // 2048 * max(1 - (block_timestamp - parent_timestamp) // 10, -99) let diff_inc = (header.timestamp - parent.timestamp) / 10; if diff_inc <= 1 { parent.difficulty + parent.difficulty / From::from(2048) * From::from(1 - diff_inc) - } - else { - parent.difficulty - parent.difficulty / From::from(2048) * From::from(max(diff_inc - 1, 99)) + } else { + parent.difficulty - parent.difficulty / From::from(2048) * From::from(min(diff_inc - 1, 99)) } }; target = max(min_difficulty, target); diff --git a/src/spec.rs b/src/spec.rs index f4166eab2..77073eedd 100644 --- a/src/spec.rs +++ b/src/spec.rs @@ -16,7 +16,7 @@ pub fn gzip64res_to_json(source: &[u8]) -> Json { Json::from_str(&s).expect("Json is invalid") } -/// Convert JSON value to equivlaent RLP representation. +/// Convert JSON value to equivalent RLP representation. // TODO: handle container types. fn json_to_rlp(json: &Json) -> Bytes { match *json { diff --git a/src/tests/chain.rs b/src/tests/chain.rs index 84ca35058..48b176508 100644 --- a/src/tests/chain.rs +++ b/src/tests/chain.rs @@ -1,3 +1,6 @@ +use std::env; +use log::{LogLevelFilter}; +use env_logger::LogBuilder; use super::test_common::*; use client::{BlockChainClient,Client}; use pod_state::*; @@ -10,7 +13,19 @@ pub enum ChainEra { Homestead, } +fn setup_log() { + let mut builder = LogBuilder::new(); + builder.filter(None, LogLevelFilter::Info); + + if env::var("RUST_LOG").is_ok() { + builder.parse(&env::var("RUST_LOG").unwrap()); + } + + builder.init().unwrap(); +} + pub fn json_chain_test(json_data: &[u8], era: ChainEra) -> Vec { + setup_log(); let json = Json::from_str(::std::str::from_utf8(json_data).unwrap()).expect("Json is invalid"); let mut failed = Vec::new();