From a719b91b635b1a419f78352eb50b57e34d349136 Mon Sep 17 00:00:00 2001 From: keorn Date: Fri, 11 Nov 2016 16:37:44 +0000 Subject: [PATCH 01/11] move spec constructors to spec --- ethcore/res/{ethereum => }/expanse.json | 0 ethcore/src/ethereum/ethash.rs | 38 +++++++++--------- ethcore/src/ethereum/mod.rs | 47 ++--------------------- ethcore/src/miner/mod.rs | 4 +- ethcore/src/spec/spec.rs | 51 ++++++++++++++++++++----- ethcore/src/tests/client.rs | 3 +- ethcore/src/tests/helpers.rs | 3 +- 7 files changed, 69 insertions(+), 77 deletions(-) rename ethcore/res/{ethereum => }/expanse.json (100%) diff --git a/ethcore/res/ethereum/expanse.json b/ethcore/res/expanse.json similarity index 100% rename from ethcore/res/ethereum/expanse.json rename to ethcore/res/expanse.json diff --git a/ethcore/src/ethereum/ethash.rs b/ethcore/src/ethereum/ethash.rs index 6436e353148..2c7187b09ea 100644 --- a/ethcore/src/ethereum/ethash.rs +++ b/ethcore/src/ethereum/ethash.rs @@ -423,13 +423,13 @@ mod tests { use env_info::EnvInfo; use error::{BlockError, Error}; use header::Header; - use super::super::{new_morden, new_homestead_test}; + use spec::Spec; use super::{Ethash, EthashParams}; use rlp; #[test] fn on_close_block() { - let spec = new_morden(); + let spec = Spec::new_ethereum_morden(); let engine = &*spec.engine; let genesis_header = spec.genesis_header(); let mut db_result = get_temp_state_db(); @@ -443,7 +443,7 @@ mod tests { #[test] fn on_close_block_with_uncle() { - let spec = new_morden(); + let spec = Spec::new_ethereum_morden(); let engine = &*spec.engine; let genesis_header = spec.genesis_header(); let mut db_result = get_temp_state_db(); @@ -463,14 +463,14 @@ mod tests { #[test] fn has_valid_metadata() { - let engine = new_morden().engine; + let engine = Spec::new_ethereum_morden().engine; assert!(!engine.name().is_empty()); assert!(engine.version().major >= 1); } #[test] fn can_return_schedule() { - let engine = new_morden().engine; + let engine = Spec::new_ethereum_morden().engine; let schedule = engine.schedule(&EnvInfo { number: 10000000, author: 0.into(), @@ -498,8 +498,8 @@ mod tests { #[test] fn can_do_seal_verification_fail() { - let engine = new_morden().engine; - //let engine = Ethash::new_test(new_morden()); + let engine = Spec::new_ethereum_morden().engine; + //let engine = Ethash::new_test(Spec::new_ethereum_morden()); let header: Header = Header::default(); let verify_result = engine.verify_block_basic(&header, None); @@ -513,7 +513,7 @@ mod tests { #[test] fn can_do_difficulty_verification_fail() { - let engine = new_morden().engine; + let engine = Spec::new_ethereum_morden().engine; let mut header: Header = Header::default(); header.set_seal(vec![rlp::encode(&H256::zero()).to_vec(), rlp::encode(&H64::zero()).to_vec()]); @@ -528,7 +528,7 @@ mod tests { #[test] fn can_do_proof_of_work_verification_fail() { - let engine = new_morden().engine; + let engine = Spec::new_ethereum_morden().engine; let mut header: Header = Header::default(); header.set_seal(vec![rlp::encode(&H256::zero()).to_vec(), rlp::encode(&H64::zero()).to_vec()]); header.set_difficulty(U256::from_str("ffffffffffffffffffffffffffffffffffffffffffffaaaaaaaaaaaaaaaaaaaa").unwrap()); @@ -544,7 +544,7 @@ mod tests { #[test] fn can_do_seal_unordered_verification_fail() { - let engine = new_morden().engine; + let engine = Spec::new_ethereum_morden().engine; let header: Header = Header::default(); let verify_result = engine.verify_block_unordered(&header, None); @@ -558,7 +558,7 @@ mod tests { #[test] fn can_do_seal256_verification_fail() { - let engine = new_morden().engine; + let engine = Spec::new_ethereum_morden().engine; let mut header: Header = Header::default(); header.set_seal(vec![rlp::encode(&H256::zero()).to_vec(), rlp::encode(&H64::zero()).to_vec()]); let verify_result = engine.verify_block_unordered(&header, None); @@ -572,7 +572,7 @@ mod tests { #[test] fn can_do_proof_of_work_unordered_verification_fail() { - let engine = new_morden().engine; + let engine = Spec::new_ethereum_morden().engine; let mut header: Header = Header::default(); header.set_seal(vec![rlp::encode(&H256::from("b251bd2e0283d0658f2cadfdc8ca619b5de94eca5742725e2e757dd13ed7503d")).to_vec(), rlp::encode(&H64::zero()).to_vec()]); header.set_difficulty(U256::from_str("ffffffffffffffffffffffffffffffffffffffffffffaaaaaaaaaaaaaaaaaaaa").unwrap()); @@ -588,7 +588,7 @@ mod tests { #[test] fn can_verify_block_family_genesis_fail() { - let engine = new_morden().engine; + let engine = Spec::new_ethereum_morden().engine; let header: Header = Header::default(); let parent_header: Header = Header::default(); @@ -603,7 +603,7 @@ mod tests { #[test] fn can_verify_block_family_difficulty_fail() { - let engine = new_morden().engine; + let engine = Spec::new_ethereum_morden().engine; let mut header: Header = Header::default(); header.set_number(2); let mut parent_header: Header = Header::default(); @@ -620,7 +620,7 @@ mod tests { #[test] fn can_verify_block_family_gas_fail() { - let engine = new_morden().engine; + let engine = Spec::new_ethereum_morden().engine; let mut header: Header = Header::default(); header.set_number(2); header.set_difficulty(U256::from_str("0000000000000000000000000000000000000000000000000000000000020000").unwrap()); @@ -648,7 +648,7 @@ mod tests { #[test] fn difficulty_frontier() { - let spec = new_homestead_test(); + let spec = Spec::new_ethereum_homestead_test(); let ethparams = get_default_ethash_params(); let ethash = Ethash::new(spec.params, ethparams, BTreeMap::new()); @@ -666,7 +666,7 @@ mod tests { #[test] fn difficulty_homestead() { - let spec = new_homestead_test(); + let spec = Spec::new_ethereum_homestead_test(); let ethparams = get_default_ethash_params(); let ethash = Ethash::new(spec.params, ethparams, BTreeMap::new()); @@ -684,7 +684,7 @@ mod tests { #[test] fn difficulty_classic_bomb_delay() { - let spec = new_homestead_test(); + let spec = Spec::new_ethereum_homestead_test(); let ethparams = EthashParams { ecip1010_pause_transition: 3000000, ..get_default_ethash_params() @@ -717,7 +717,7 @@ mod tests { #[test] fn test_difficulty_bomb_continue() { - let spec = new_homestead_test(); + let spec = Spec::new_ethereum_homestead_test(); let ethparams = EthashParams { ecip1010_pause_transition: 3000000, ecip1010_continue_transition: 5000000, diff --git a/ethcore/src/ethereum/mod.rs b/ethcore/src/ethereum/mod.rs index 253a123722a..3df130a8d97 100644 --- a/ethcore/src/ethereum/mod.rs +++ b/ethcore/src/ethereum/mod.rs @@ -27,56 +27,17 @@ pub mod denominations; pub use self::ethash::{Ethash}; pub use self::denominations::*; -use super::spec::*; - -fn load(b: &[u8]) -> Spec { - Spec::load(b).expect("chain spec is invalid") -} - -/// Create a new Olympic chain spec. -pub fn new_olympic() -> Spec { load(include_bytes!("../../res/ethereum/olympic.json")) } - -/// Create a new Frontier mainnet chain spec. -pub fn new_frontier() -> Spec { load(include_bytes!("../../res/ethereum/frontier.json")) } - -/// Create a new Frontier mainnet chain spec without the DAO hardfork. -pub fn new_classic() -> Spec { load(include_bytes!("../../res/ethereum/classic.json")) } - -/// Create a new Frontier mainnet chain spec without the DAO hardfork. -pub fn new_expanse() -> Spec { load(include_bytes!("../../res/ethereum/expanse.json")) } - -/// Create a new Frontier chain spec as though it never changes to Homestead. -pub fn new_frontier_test() -> Spec { load(include_bytes!("../../res/ethereum/frontier_test.json")) } - -/// Create a new Homestead chain spec as though it never changed from Frontier. -pub fn new_homestead_test() -> Spec { load(include_bytes!("../../res/ethereum/homestead_test.json")) } - -/// Create a new Homestead-EIP150 chain spec as though it never changed from Homestead/Frontier. -pub fn new_eip150_test() -> Spec { load(include_bytes!("../../res/ethereum/eip150_test.json")) } - -/// Create a new Homestead-EIP150 chain spec as though it never changed from Homestead/Frontier. -pub fn new_eip161_test() -> Spec { load(include_bytes!("../../res/ethereum/eip161_test.json")) } - -/// Create a new Frontier/Homestead/DAO chain spec with transition points at #5 and #8. -pub fn new_transition_test() -> Spec { load(include_bytes!("../../res/ethereum/transition_test.json")) } - -/// Create a new Frontier main net chain spec without genesis accounts. -pub fn new_mainnet_like() -> Spec { load(include_bytes!("../../res/ethereum/frontier_like_test.json")) } - -/// Create a new Morden chain spec. -pub fn new_morden() -> Spec { load(include_bytes!("../../res/ethereum/morden.json")) } - #[cfg(test)] mod tests { use util::*; use state::*; - use super::*; use tests::helpers::*; + use spec::Spec; use views::BlockView; #[test] fn ensure_db_good() { - let spec = new_morden(); + let spec = Spec::new_ethereum_morden(); let engine = &spec.engine; let genesis_header = spec.genesis_header(); let mut db_result = get_temp_state_db(); @@ -93,7 +54,7 @@ mod tests { #[test] fn morden() { - let morden = new_morden(); + let morden = Spec::new_ethereum_morden(); assert_eq!(morden.state_root(), "f3f4696bbf3b3b07775128eb7a3763279a394e382130f27c21e70233e04946a9".into()); let genesis = morden.genesis_block(); @@ -104,7 +65,7 @@ mod tests { #[test] fn frontier() { - let frontier = new_frontier(); + let frontier = Spec::new_ethereum_frontier(); assert_eq!(frontier.state_root(), "d7f8974fb5ac78d9ac099b9ad5018bedc2ce0a72dad1827a1709da30580f0544".into()); let genesis = frontier.genesis_block(); diff --git a/ethcore/src/miner/mod.rs b/ethcore/src/miner/mod.rs index da93dc0b7e3..a553daffcfc 100644 --- a/ethcore/src/miner/mod.rs +++ b/ethcore/src/miner/mod.rs @@ -27,12 +27,12 @@ //! extern crate ethcore_util as util; //! extern crate ethcore; //! use std::env; -//! use ethcore::ethereum; +//! use spec::Spec; //! use ethcore::client::{Client, ClientConfig}; //! use ethcore::miner::{Miner, MinerService}; //! //! fn main() { -//! let miner: Miner = Miner::with_spec(ðereum::new_frontier()); +//! let miner: Miner = Miner::with_spec(&Spec::new_ethereum_frontier()); //! // get status //! assert_eq!(miner.status().transactions_in_pending_queue, 0); //! diff --git a/ethcore/src/spec/spec.rs b/ethcore/src/spec/spec.rs index 2babfb708e6..786b264abfb 100644 --- a/ethcore/src/spec/spec.rs +++ b/ethcore/src/spec/spec.rs @@ -135,6 +135,12 @@ impl From for Spec { } } +macro_rules! load_bundled { + ($e:expr) => { + Spec::load(include_bytes!(concat!("../../res/", $e, ".json")) as &[u8]).expect("Chain spec is invalid") + }; +} + impl Spec { /// Convert engine spec into a arc'd Engine of the right underlying type. /// TODO avoid this hard-coded nastiness - use dynamic-linked plugin framework instead. @@ -267,19 +273,46 @@ impl Spec { } /// Create a new Spec which conforms to the Frontier-era Morden chain except that it's a NullEngine consensus. - pub fn new_test() -> Self { - Spec::load(include_bytes!("../../res/null_morden.json") as &[u8]).expect("null_morden.json is invalid") - } + pub fn new_test() -> Spec { load_bundled!("null_morden") } /// Create a new Spec which is a NullEngine consensus with a premine of address whose secret is sha3(''). - pub fn new_null() -> Self { - Spec::load(include_bytes!("../../res/null.json") as &[u8]).expect("null.json is invalid") - } + pub fn new_null() -> Spec { load_bundled!("null") } /// Create a new Spec with InstantSeal consensus which does internal sealing (not requiring work). - pub fn new_test_instant() -> Self { - Spec::load(include_bytes!("../../res/instant_seal.json") as &[u8]).expect("instant_seal.json is invalid") - } + pub fn new_test_instant() -> Spec { load_bundled!("instant_seal") } + + /// Create a new Olympic chain spec. + pub fn new_ethereum_olympic() -> Spec { load_bundled!("ethereum/olympic") } + + /// Create a new Frontier mainnet chain spec. + pub fn new_ethereum_frontier() -> Spec { load_bundled!("ethereum/frontier") } + + /// Create a new Frontier mainnet chain spec without the DAO hardfork. + pub fn new_ethereum_classic() -> Spec { load_bundled!("ethereum/classic") } + + /// Create a new Frontier mainnet chain spec without the DAO hardfork. + pub fn new_expanse() -> Spec { load_bundled!("expanse") } + + /// Create a new Frontier chain spec as though it never changes to Homestead. + pub fn new_ethereum_frontier_test() -> Spec { load_bundled!("ethereum/frontier_test") } + + /// Create a new Homestead chain spec as though it never changed from Frontier. + pub fn new_ethereum_homestead_test() -> Spec { load_bundled!("ethereum/homestead_test") } + + /// Create a new Homestead-EIP150 chain spec as though it never changed from Homestead/Frontier. + pub fn new_ethereum_eip150_test() -> Spec { load_bundled!("ethereum/eip150_test") } + + /// Create a new Homestead-EIP150 chain spec as though it never changed from Homestead/Frontier. + pub fn new_ethereum_eip161_test() -> Spec { load_bundled!("ethereum/eip161_test") } + + /// Create a new Frontier/Homestead/DAO chain spec with transition points at #5 and #8. + pub fn new_ethereum_transition_test() -> Spec { load_bundled!("ethereum/transition_test") } + + /// Create a new Frontier main net chain spec without genesis accounts. + pub fn new_ethereum_mainnet_like() -> Spec { load_bundled!("ethereum/frontier_like_test") } + + /// Create a new Morden chain spec. + pub fn new_ethereum_morden() -> Spec { load_bundled!("ethereum/morden") } } #[cfg(test)] diff --git a/ethcore/src/tests/client.rs b/ethcore/src/tests/client.rs index 99b251d6647..e6fba0b0afa 100644 --- a/ethcore/src/tests/client.rs +++ b/ethcore/src/tests/client.rs @@ -17,7 +17,6 @@ use io::IoChannel; use client::{BlockChainClient, MiningBlockChainClient, Client, ClientConfig, BlockID}; use state::CleanupMode; -use ethereum; use block::IsBlock; use tests::helpers::*; use types::filter::Filter; @@ -50,7 +49,7 @@ fn imports_from_empty() { #[test] fn should_return_registrar() { let dir = RandomTempPath::new(); - let spec = ethereum::new_morden(); + let spec = Spec::new_ethereum_morden(); let db_config = DatabaseConfig::with_columns(::db::NUM_COLUMNS); let client = Client::new( diff --git a/ethcore/src/tests/helpers.rs b/ethcore/src/tests/helpers.rs index 96d5f836644..a6a06608ab4 100644 --- a/ethcore/src/tests/helpers.rs +++ b/ethcore/src/tests/helpers.rs @@ -27,7 +27,6 @@ use state::*; use evm::Schedule; use engines::Engine; use env_info::EnvInfo; -use ethereum; use ethereum::ethash::EthashParams; use devtools::*; use miner::Miner; @@ -53,7 +52,7 @@ pub struct TestEngine { impl TestEngine { pub fn new(max_depth: usize) -> TestEngine { TestEngine { - engine: ethereum::new_frontier_test().engine, + engine: Spec::new_ethereum_frontier_test().engine, max_depth: max_depth, } } From beaa014543dc7f8010a45634d1ea479e4e7e1c66 Mon Sep 17 00:00:00 2001 From: keorn Date: Fri, 11 Nov 2016 16:59:22 +0000 Subject: [PATCH 02/11] tix doc test --- ethcore/src/miner/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ethcore/src/miner/mod.rs b/ethcore/src/miner/mod.rs index a553daffcfc..fc306c3de75 100644 --- a/ethcore/src/miner/mod.rs +++ b/ethcore/src/miner/mod.rs @@ -27,7 +27,7 @@ //! extern crate ethcore_util as util; //! extern crate ethcore; //! use std::env; -//! use spec::Spec; +//! use ethcore::spec::Spec; //! use ethcore::client::{Client, ClientConfig}; //! use ethcore::miner::{Miner, MinerService}; //! From 225d0b02e7d82925450dee260d720b71789582e7 Mon Sep 17 00:00:00 2001 From: keorn Date: Fri, 11 Nov 2016 17:10:47 +0000 Subject: [PATCH 03/11] update parity module --- parity/params.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/parity/params.rs b/parity/params.rs index 5a81fba7f8b..783c4564a86 100644 --- a/parity/params.rs +++ b/parity/params.rs @@ -19,7 +19,6 @@ use std::time::Duration; use util::{Address, U256, version_data}; use util::journaldb::Algorithm; use ethcore::spec::Spec; -use ethcore::ethereum; use ethcore::client::Mode; use ethcore::miner::{GasPricer, GasPriceCalibratorOptions}; use user_defaults::UserDefaults; @@ -59,11 +58,11 @@ impl str::FromStr for SpecType { impl SpecType { pub fn spec(&self) -> Result { match *self { - SpecType::Mainnet => Ok(ethereum::new_frontier()), - SpecType::Testnet => Ok(ethereum::new_morden()), - SpecType::Olympic => Ok(ethereum::new_olympic()), - SpecType::Classic => Ok(ethereum::new_classic()), - SpecType::Expanse => Ok(ethereum::new_expanse()), + SpecType::Mainnet => Ok(Spec::new_ethereum_frontier()), + SpecType::Testnet => Ok(Spec::new_ethereum_morden()), + SpecType::Olympic => Ok(Spec::new_ethereum_olympic()), + SpecType::Classic => Ok(Spec::new_ethereum_classic()), + SpecType::Expanse => Ok(Spec::new_expanse()), SpecType::Custom(ref filename) => { let file = try!(fs::File::open(filename).map_err(|_| "Could not load specification file.")); Spec::load(file) From e63b7e51fb6e02b14420c80e6a2a797d59d74ec4 Mon Sep 17 00:00:00 2001 From: keorn Date: Fri, 11 Nov 2016 17:26:41 +0000 Subject: [PATCH 04/11] update instant_seal schedule --- ethcore/src/engines/instant_seal.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ethcore/src/engines/instant_seal.rs b/ethcore/src/engines/instant_seal.rs index acead19b436..75fae4d81fe 100644 --- a/ethcore/src/engines/instant_seal.rs +++ b/ethcore/src/engines/instant_seal.rs @@ -55,7 +55,7 @@ impl Engine for InstantSeal { } fn schedule(&self, _env_info: &EnvInfo) -> Schedule { - Schedule::new_homestead() + Schedule::new_post_eip150(false, false, false) } fn is_sealer(&self, _author: &Address) -> Option { Some(true) } @@ -79,7 +79,7 @@ mod tests { let tap = AccountProvider::transient_provider(); let addr = tap.insert_account("".sha3(), "").unwrap(); - let spec = Spec::new_test_instant(); + let spec = Spec::new_instant(); let engine = &*spec.engine; let genesis_header = spec.genesis_header(); let mut db_result = get_temp_state_db(); @@ -95,7 +95,7 @@ mod tests { #[test] fn instant_cant_verify() { - let engine = Spec::new_test_instant().engine; + let engine = Spec::new_instant().engine; let mut header: Header = Header::default(); assert!(engine.verify_block_basic(&header, None).is_ok()); From 53258cca6cbeca1ef0e78b8418674b53d8953a1a Mon Sep 17 00:00:00 2001 From: keorn Date: Fri, 11 Nov 2016 17:27:20 +0000 Subject: [PATCH 05/11] add new dev spec --- ethcore/src/miner/miner.rs | 2 +- ethcore/src/spec/spec.rs | 2 +- parity/params.rs | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/ethcore/src/miner/miner.rs b/ethcore/src/miner/miner.rs index 19a2b9a10d4..af4677cf3b2 100644 --- a/ethcore/src/miner/miner.rs +++ b/ethcore/src/miner/miner.rs @@ -1251,7 +1251,7 @@ mod tests { #[test] fn internal_seals_without_work() { - let miner = Miner::with_spec(&Spec::new_test_instant()); + let miner = Miner::with_spec(&Spec::new_instant()); let c = generate_dummy_client(2); let client = c.reference().as_ref(); diff --git a/ethcore/src/spec/spec.rs b/ethcore/src/spec/spec.rs index 786b264abfb..d8b2f72fc69 100644 --- a/ethcore/src/spec/spec.rs +++ b/ethcore/src/spec/spec.rs @@ -279,7 +279,7 @@ impl Spec { pub fn new_null() -> Spec { load_bundled!("null") } /// Create a new Spec with InstantSeal consensus which does internal sealing (not requiring work). - pub fn new_test_instant() -> Spec { load_bundled!("instant_seal") } + pub fn new_instant() -> Spec { load_bundled!("instant_seal") } /// Create a new Olympic chain spec. pub fn new_ethereum_olympic() -> Spec { load_bundled!("ethereum/olympic") } diff --git a/parity/params.rs b/parity/params.rs index 783c4564a86..0a24cc7ddc7 100644 --- a/parity/params.rs +++ b/parity/params.rs @@ -30,6 +30,7 @@ pub enum SpecType { Olympic, Classic, Expanse, + Dev, Custom(String), } @@ -49,6 +50,7 @@ impl str::FromStr for SpecType { "morden" | "testnet" => SpecType::Testnet, "olympic" => SpecType::Olympic, "expanse" => SpecType::Expanse, + "dev" => SpecType::Dev, other => SpecType::Custom(other.into()), }; Ok(spec) @@ -63,6 +65,7 @@ impl SpecType { SpecType::Olympic => Ok(Spec::new_ethereum_olympic()), SpecType::Classic => Ok(Spec::new_ethereum_classic()), SpecType::Expanse => Ok(Spec::new_expanse()), + SpecType::Dev => Ok(Spec::new_instant()), SpecType::Custom(ref filename) => { let file = try!(fs::File::open(filename).map_err(|_| "Could not load specification file.")); Spec::load(file) From 4a653942696a2115e8679c1b4ec6a62df8ff29eb Mon Sep 17 00:00:00 2001 From: keorn Date: Fri, 11 Nov 2016 18:38:44 +0000 Subject: [PATCH 06/11] change instant spec, update doc --- ethcore/res/instant_seal.json | 2 +- parity/cli/usage.txt | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ethcore/res/instant_seal.json b/ethcore/res/instant_seal.json index b7c29a01fd6..eefe7431bb4 100644 --- a/ethcore/res/instant_seal.json +++ b/ethcore/res/instant_seal.json @@ -28,6 +28,6 @@ "0000000000000000000000000000000000000002": { "balance": "1", "nonce": "1048576", "builtin": { "name": "sha256", "pricing": { "linear": { "base": 60, "word": 12 } } } }, "0000000000000000000000000000000000000003": { "balance": "1", "nonce": "1048576", "builtin": { "name": "ripemd160", "pricing": { "linear": { "base": 600, "word": 120 } } } }, "0000000000000000000000000000000000000004": { "balance": "1", "nonce": "1048576", "builtin": { "name": "identity", "pricing": { "linear": { "base": 15, "word": 3 } } } }, - "102e61f5d8f9bc71d0ad4a084df4e65e05ce0e1c": { "balance": "1606938044258990275541962092341162602522202993782792835301376", "nonce": "1048576" } + "0x00a329c0648769a73afac7f9381e08fb43dbea72": { "balance": "1606938044258990275541962092341162602522202993782792835301376", "nonce": "1048576" } } } diff --git a/parity/cli/usage.txt b/parity/cli/usage.txt index ba27c49027d..89603d311e4 100644 --- a/parity/cli/usage.txt +++ b/parity/cli/usage.txt @@ -32,8 +32,8 @@ Operating Options: (default: {flag_mode_alarm}). --chain CHAIN Specify the blockchain type. CHAIN may be either a JSON chain specification file or olympic, frontier, - homestead, mainnet, morden, classic, expanse or - testnet (default: {flag_chain}). + homestead, mainnet, morden, classic, expanse, + testnet or dev (default: {flag_chain}). -d --db-path PATH Specify the database & configuration directory path (default: {flag_db_path}). --keys-path PATH Specify the path for JSON key files to be found From cc39b245990dacfa0eeded56971a52ec44bb9778 Mon Sep 17 00:00:00 2001 From: keorn Date: Fri, 11 Nov 2016 18:41:04 +0000 Subject: [PATCH 07/11] update chain name --- ethcore/res/instant_seal.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ethcore/res/instant_seal.json b/ethcore/res/instant_seal.json index eefe7431bb4..2d5b386596a 100644 --- a/ethcore/res/instant_seal.json +++ b/ethcore/res/instant_seal.json @@ -1,5 +1,5 @@ { - "name": "TestInstantSeal", + "name": "DevelopmentChain", "engine": { "InstantSeal": null }, From ea9c479fffcb904f4d2e75524f503bd5150e8b70 Mon Sep 17 00:00:00 2001 From: keorn Date: Fri, 11 Nov 2016 18:57:57 +0000 Subject: [PATCH 08/11] update json_tests --- ethcore/src/json_tests/chain.rs | 12 ++++++------ ethcore/src/json_tests/state.rs | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/ethcore/src/json_tests/chain.rs b/ethcore/src/json_tests/chain.rs index b50241199e7..1146004b358 100644 --- a/ethcore/src/json_tests/chain.rs +++ b/ethcore/src/json_tests/chain.rs @@ -17,7 +17,7 @@ use super::test_common::*; use client::{BlockChainClient, Client, ClientConfig}; use block::Block; -use ethereum; +use spec::Spec; use tests::helpers::*; use devtools::*; use spec::Genesis; @@ -46,11 +46,11 @@ pub fn json_chain_test(json_data: &[u8], era: ChainEra) -> Vec { let genesis = Genesis::from(blockchain.genesis()); let state = From::from(blockchain.pre_state.clone()); let mut spec = match era { - ChainEra::Frontier => ethereum::new_frontier_test(), - ChainEra::Homestead => ethereum::new_homestead_test(), - ChainEra::Eip150 => ethereum::new_eip150_test(), - ChainEra::Eip161 => ethereum::new_eip161_test(), - ChainEra::TransitionTest => ethereum::new_transition_test(), + ChainEra::Frontier => Spec::new_ethereum_frontier_test(), + ChainEra::Homestead => Spec::new_ethereum_homestead_test(), + ChainEra::Eip150 => Spec::new_ethereum_eip150_test(), + ChainEra::Eip161 => Spec::new_ethereum_eip161_test(), + ChainEra::TransitionTest => Spec::new_ethereum_transition_test(), }; spec.set_genesis_state(state); spec.overwrite_genesis_params(genesis); diff --git a/ethcore/src/json_tests/state.rs b/ethcore/src/json_tests/state.rs index bf84d50ee88..712b47feb08 100644 --- a/ethcore/src/json_tests/state.rs +++ b/ethcore/src/json_tests/state.rs @@ -18,7 +18,7 @@ use super::test_common::*; use tests::helpers::*; use pod_state::{self, PodState}; use log_entry::LogEntry; -use ethereum; +use spec::Spec; use ethjson; pub fn json_chain_test(json_data: &[u8], era: ChainEra) -> Vec { @@ -26,11 +26,11 @@ pub fn json_chain_test(json_data: &[u8], era: ChainEra) -> Vec { let tests = ethjson::state::Test::load(json_data).unwrap(); let mut failed = Vec::new(); let engine = match era { - ChainEra::Frontier => ethereum::new_mainnet_like().engine, - ChainEra::Homestead => ethereum::new_homestead_test().engine, - ChainEra::Eip150 => ethereum::new_eip150_test().engine, - ChainEra::Eip161 => ethereum::new_eip161_test().engine, - ChainEra::TransitionTest => ethereum::new_transition_test().engine, + ChainEra::Frontier => Spec::new_ethereum_mainnet_like().engine, + ChainEra::Homestead => Spec::new_ethereum_homestead_test().engine, + ChainEra::Eip150 => Spec::new_ethereum_eip150_test().engine, + ChainEra::Eip161 => Spec::new_ethereum_eip161_test().engine, + ChainEra::TransitionTest => Spec::new_ethereum_transition_test().engine, }; for (name, test) in tests.into_iter() { From aa296c3c0dee7323b86be3c6b56da70e1ee10e5f Mon Sep 17 00:00:00 2001 From: keorn Date: Fri, 11 Nov 2016 19:12:32 +0000 Subject: [PATCH 09/11] update rpc tests --- rpc/src/v1/tests/eth.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/rpc/src/v1/tests/eth.rs b/rpc/src/v1/tests/eth.rs index 2f5131f3262..38597343e6b 100644 --- a/rpc/src/v1/tests/eth.rs +++ b/rpc/src/v1/tests/eth.rs @@ -23,7 +23,6 @@ use ethcore::ids::BlockID; use ethcore::spec::{Genesis, Spec}; use ethcore::block::Block; use ethcore::views::BlockView; -use ethcore::ethereum; use ethcore::miner::{MinerOptions, Banning, GasPricer, MinerService, ExternalMiner, Miner, PendingSet, PrioritizationStrategy, GasLimit}; use ethcore::account_provider::AccountProvider; use devtools::RandomTempPath; @@ -79,7 +78,7 @@ fn snapshot_service() -> Arc { fn make_spec(chain: &BlockChain) -> Spec { let genesis = Genesis::from(chain.genesis()); - let mut spec = ethereum::new_frontier_test(); + let mut spec = Spec::new_ethereum_frontier_test(); let state = chain.pre_state.clone().into(); spec.set_genesis_state(state); spec.overwrite_genesis_params(genesis); From 2d4b4cf5c90706a510fad8a4c24e62754afced88 Mon Sep 17 00:00:00 2001 From: keorn Date: Mon, 14 Nov 2016 10:04:34 +0000 Subject: [PATCH 10/11] revert moves to Spec --- ethcore/res/{ => ethereum}/expanse.json | 0 ethcore/src/ethereum/ethash.rs | 38 ++++++++++---------- ethcore/src/ethereum/mod.rs | 47 ++++++++++++++++++++++--- ethcore/src/json_tests/chain.rs | 12 +++---- ethcore/src/json_tests/state.rs | 12 +++---- ethcore/src/miner/mod.rs | 4 +-- ethcore/src/spec/spec.rs | 33 ----------------- ethcore/src/tests/client.rs | 3 +- ethcore/src/tests/helpers.rs | 3 +- parity/params.rs | 11 +++--- rpc/src/v1/tests/eth.rs | 3 +- 11 files changed, 88 insertions(+), 78 deletions(-) rename ethcore/res/{ => ethereum}/expanse.json (100%) diff --git a/ethcore/res/expanse.json b/ethcore/res/ethereum/expanse.json similarity index 100% rename from ethcore/res/expanse.json rename to ethcore/res/ethereum/expanse.json diff --git a/ethcore/src/ethereum/ethash.rs b/ethcore/src/ethereum/ethash.rs index 2c7187b09ea..6436e353148 100644 --- a/ethcore/src/ethereum/ethash.rs +++ b/ethcore/src/ethereum/ethash.rs @@ -423,13 +423,13 @@ mod tests { use env_info::EnvInfo; use error::{BlockError, Error}; use header::Header; - use spec::Spec; + use super::super::{new_morden, new_homestead_test}; use super::{Ethash, EthashParams}; use rlp; #[test] fn on_close_block() { - let spec = Spec::new_ethereum_morden(); + let spec = new_morden(); let engine = &*spec.engine; let genesis_header = spec.genesis_header(); let mut db_result = get_temp_state_db(); @@ -443,7 +443,7 @@ mod tests { #[test] fn on_close_block_with_uncle() { - let spec = Spec::new_ethereum_morden(); + let spec = new_morden(); let engine = &*spec.engine; let genesis_header = spec.genesis_header(); let mut db_result = get_temp_state_db(); @@ -463,14 +463,14 @@ mod tests { #[test] fn has_valid_metadata() { - let engine = Spec::new_ethereum_morden().engine; + let engine = new_morden().engine; assert!(!engine.name().is_empty()); assert!(engine.version().major >= 1); } #[test] fn can_return_schedule() { - let engine = Spec::new_ethereum_morden().engine; + let engine = new_morden().engine; let schedule = engine.schedule(&EnvInfo { number: 10000000, author: 0.into(), @@ -498,8 +498,8 @@ mod tests { #[test] fn can_do_seal_verification_fail() { - let engine = Spec::new_ethereum_morden().engine; - //let engine = Ethash::new_test(Spec::new_ethereum_morden()); + let engine = new_morden().engine; + //let engine = Ethash::new_test(new_morden()); let header: Header = Header::default(); let verify_result = engine.verify_block_basic(&header, None); @@ -513,7 +513,7 @@ mod tests { #[test] fn can_do_difficulty_verification_fail() { - let engine = Spec::new_ethereum_morden().engine; + let engine = new_morden().engine; let mut header: Header = Header::default(); header.set_seal(vec![rlp::encode(&H256::zero()).to_vec(), rlp::encode(&H64::zero()).to_vec()]); @@ -528,7 +528,7 @@ mod tests { #[test] fn can_do_proof_of_work_verification_fail() { - let engine = Spec::new_ethereum_morden().engine; + let engine = new_morden().engine; let mut header: Header = Header::default(); header.set_seal(vec![rlp::encode(&H256::zero()).to_vec(), rlp::encode(&H64::zero()).to_vec()]); header.set_difficulty(U256::from_str("ffffffffffffffffffffffffffffffffffffffffffffaaaaaaaaaaaaaaaaaaaa").unwrap()); @@ -544,7 +544,7 @@ mod tests { #[test] fn can_do_seal_unordered_verification_fail() { - let engine = Spec::new_ethereum_morden().engine; + let engine = new_morden().engine; let header: Header = Header::default(); let verify_result = engine.verify_block_unordered(&header, None); @@ -558,7 +558,7 @@ mod tests { #[test] fn can_do_seal256_verification_fail() { - let engine = Spec::new_ethereum_morden().engine; + let engine = new_morden().engine; let mut header: Header = Header::default(); header.set_seal(vec![rlp::encode(&H256::zero()).to_vec(), rlp::encode(&H64::zero()).to_vec()]); let verify_result = engine.verify_block_unordered(&header, None); @@ -572,7 +572,7 @@ mod tests { #[test] fn can_do_proof_of_work_unordered_verification_fail() { - let engine = Spec::new_ethereum_morden().engine; + let engine = new_morden().engine; let mut header: Header = Header::default(); header.set_seal(vec![rlp::encode(&H256::from("b251bd2e0283d0658f2cadfdc8ca619b5de94eca5742725e2e757dd13ed7503d")).to_vec(), rlp::encode(&H64::zero()).to_vec()]); header.set_difficulty(U256::from_str("ffffffffffffffffffffffffffffffffffffffffffffaaaaaaaaaaaaaaaaaaaa").unwrap()); @@ -588,7 +588,7 @@ mod tests { #[test] fn can_verify_block_family_genesis_fail() { - let engine = Spec::new_ethereum_morden().engine; + let engine = new_morden().engine; let header: Header = Header::default(); let parent_header: Header = Header::default(); @@ -603,7 +603,7 @@ mod tests { #[test] fn can_verify_block_family_difficulty_fail() { - let engine = Spec::new_ethereum_morden().engine; + let engine = new_morden().engine; let mut header: Header = Header::default(); header.set_number(2); let mut parent_header: Header = Header::default(); @@ -620,7 +620,7 @@ mod tests { #[test] fn can_verify_block_family_gas_fail() { - let engine = Spec::new_ethereum_morden().engine; + let engine = new_morden().engine; let mut header: Header = Header::default(); header.set_number(2); header.set_difficulty(U256::from_str("0000000000000000000000000000000000000000000000000000000000020000").unwrap()); @@ -648,7 +648,7 @@ mod tests { #[test] fn difficulty_frontier() { - let spec = Spec::new_ethereum_homestead_test(); + let spec = new_homestead_test(); let ethparams = get_default_ethash_params(); let ethash = Ethash::new(spec.params, ethparams, BTreeMap::new()); @@ -666,7 +666,7 @@ mod tests { #[test] fn difficulty_homestead() { - let spec = Spec::new_ethereum_homestead_test(); + let spec = new_homestead_test(); let ethparams = get_default_ethash_params(); let ethash = Ethash::new(spec.params, ethparams, BTreeMap::new()); @@ -684,7 +684,7 @@ mod tests { #[test] fn difficulty_classic_bomb_delay() { - let spec = Spec::new_ethereum_homestead_test(); + let spec = new_homestead_test(); let ethparams = EthashParams { ecip1010_pause_transition: 3000000, ..get_default_ethash_params() @@ -717,7 +717,7 @@ mod tests { #[test] fn test_difficulty_bomb_continue() { - let spec = Spec::new_ethereum_homestead_test(); + let spec = new_homestead_test(); let ethparams = EthashParams { ecip1010_pause_transition: 3000000, ecip1010_continue_transition: 5000000, diff --git a/ethcore/src/ethereum/mod.rs b/ethcore/src/ethereum/mod.rs index 3df130a8d97..253a123722a 100644 --- a/ethcore/src/ethereum/mod.rs +++ b/ethcore/src/ethereum/mod.rs @@ -27,17 +27,56 @@ pub mod denominations; pub use self::ethash::{Ethash}; pub use self::denominations::*; +use super::spec::*; + +fn load(b: &[u8]) -> Spec { + Spec::load(b).expect("chain spec is invalid") +} + +/// Create a new Olympic chain spec. +pub fn new_olympic() -> Spec { load(include_bytes!("../../res/ethereum/olympic.json")) } + +/// Create a new Frontier mainnet chain spec. +pub fn new_frontier() -> Spec { load(include_bytes!("../../res/ethereum/frontier.json")) } + +/// Create a new Frontier mainnet chain spec without the DAO hardfork. +pub fn new_classic() -> Spec { load(include_bytes!("../../res/ethereum/classic.json")) } + +/// Create a new Frontier mainnet chain spec without the DAO hardfork. +pub fn new_expanse() -> Spec { load(include_bytes!("../../res/ethereum/expanse.json")) } + +/// Create a new Frontier chain spec as though it never changes to Homestead. +pub fn new_frontier_test() -> Spec { load(include_bytes!("../../res/ethereum/frontier_test.json")) } + +/// Create a new Homestead chain spec as though it never changed from Frontier. +pub fn new_homestead_test() -> Spec { load(include_bytes!("../../res/ethereum/homestead_test.json")) } + +/// Create a new Homestead-EIP150 chain spec as though it never changed from Homestead/Frontier. +pub fn new_eip150_test() -> Spec { load(include_bytes!("../../res/ethereum/eip150_test.json")) } + +/// Create a new Homestead-EIP150 chain spec as though it never changed from Homestead/Frontier. +pub fn new_eip161_test() -> Spec { load(include_bytes!("../../res/ethereum/eip161_test.json")) } + +/// Create a new Frontier/Homestead/DAO chain spec with transition points at #5 and #8. +pub fn new_transition_test() -> Spec { load(include_bytes!("../../res/ethereum/transition_test.json")) } + +/// Create a new Frontier main net chain spec without genesis accounts. +pub fn new_mainnet_like() -> Spec { load(include_bytes!("../../res/ethereum/frontier_like_test.json")) } + +/// Create a new Morden chain spec. +pub fn new_morden() -> Spec { load(include_bytes!("../../res/ethereum/morden.json")) } + #[cfg(test)] mod tests { use util::*; use state::*; + use super::*; use tests::helpers::*; - use spec::Spec; use views::BlockView; #[test] fn ensure_db_good() { - let spec = Spec::new_ethereum_morden(); + let spec = new_morden(); let engine = &spec.engine; let genesis_header = spec.genesis_header(); let mut db_result = get_temp_state_db(); @@ -54,7 +93,7 @@ mod tests { #[test] fn morden() { - let morden = Spec::new_ethereum_morden(); + let morden = new_morden(); assert_eq!(morden.state_root(), "f3f4696bbf3b3b07775128eb7a3763279a394e382130f27c21e70233e04946a9".into()); let genesis = morden.genesis_block(); @@ -65,7 +104,7 @@ mod tests { #[test] fn frontier() { - let frontier = Spec::new_ethereum_frontier(); + let frontier = new_frontier(); assert_eq!(frontier.state_root(), "d7f8974fb5ac78d9ac099b9ad5018bedc2ce0a72dad1827a1709da30580f0544".into()); let genesis = frontier.genesis_block(); diff --git a/ethcore/src/json_tests/chain.rs b/ethcore/src/json_tests/chain.rs index 1146004b358..b50241199e7 100644 --- a/ethcore/src/json_tests/chain.rs +++ b/ethcore/src/json_tests/chain.rs @@ -17,7 +17,7 @@ use super::test_common::*; use client::{BlockChainClient, Client, ClientConfig}; use block::Block; -use spec::Spec; +use ethereum; use tests::helpers::*; use devtools::*; use spec::Genesis; @@ -46,11 +46,11 @@ pub fn json_chain_test(json_data: &[u8], era: ChainEra) -> Vec { let genesis = Genesis::from(blockchain.genesis()); let state = From::from(blockchain.pre_state.clone()); let mut spec = match era { - ChainEra::Frontier => Spec::new_ethereum_frontier_test(), - ChainEra::Homestead => Spec::new_ethereum_homestead_test(), - ChainEra::Eip150 => Spec::new_ethereum_eip150_test(), - ChainEra::Eip161 => Spec::new_ethereum_eip161_test(), - ChainEra::TransitionTest => Spec::new_ethereum_transition_test(), + ChainEra::Frontier => ethereum::new_frontier_test(), + ChainEra::Homestead => ethereum::new_homestead_test(), + ChainEra::Eip150 => ethereum::new_eip150_test(), + ChainEra::Eip161 => ethereum::new_eip161_test(), + ChainEra::TransitionTest => ethereum::new_transition_test(), }; spec.set_genesis_state(state); spec.overwrite_genesis_params(genesis); diff --git a/ethcore/src/json_tests/state.rs b/ethcore/src/json_tests/state.rs index 712b47feb08..bf84d50ee88 100644 --- a/ethcore/src/json_tests/state.rs +++ b/ethcore/src/json_tests/state.rs @@ -18,7 +18,7 @@ use super::test_common::*; use tests::helpers::*; use pod_state::{self, PodState}; use log_entry::LogEntry; -use spec::Spec; +use ethereum; use ethjson; pub fn json_chain_test(json_data: &[u8], era: ChainEra) -> Vec { @@ -26,11 +26,11 @@ pub fn json_chain_test(json_data: &[u8], era: ChainEra) -> Vec { let tests = ethjson::state::Test::load(json_data).unwrap(); let mut failed = Vec::new(); let engine = match era { - ChainEra::Frontier => Spec::new_ethereum_mainnet_like().engine, - ChainEra::Homestead => Spec::new_ethereum_homestead_test().engine, - ChainEra::Eip150 => Spec::new_ethereum_eip150_test().engine, - ChainEra::Eip161 => Spec::new_ethereum_eip161_test().engine, - ChainEra::TransitionTest => Spec::new_ethereum_transition_test().engine, + ChainEra::Frontier => ethereum::new_mainnet_like().engine, + ChainEra::Homestead => ethereum::new_homestead_test().engine, + ChainEra::Eip150 => ethereum::new_eip150_test().engine, + ChainEra::Eip161 => ethereum::new_eip161_test().engine, + ChainEra::TransitionTest => ethereum::new_transition_test().engine, }; for (name, test) in tests.into_iter() { diff --git a/ethcore/src/miner/mod.rs b/ethcore/src/miner/mod.rs index fc306c3de75..da93dc0b7e3 100644 --- a/ethcore/src/miner/mod.rs +++ b/ethcore/src/miner/mod.rs @@ -27,12 +27,12 @@ //! extern crate ethcore_util as util; //! extern crate ethcore; //! use std::env; -//! use ethcore::spec::Spec; +//! use ethcore::ethereum; //! use ethcore::client::{Client, ClientConfig}; //! use ethcore::miner::{Miner, MinerService}; //! //! fn main() { -//! let miner: Miner = Miner::with_spec(&Spec::new_ethereum_frontier()); +//! let miner: Miner = Miner::with_spec(ðereum::new_frontier()); //! // get status //! assert_eq!(miner.status().transactions_in_pending_queue, 0); //! diff --git a/ethcore/src/spec/spec.rs b/ethcore/src/spec/spec.rs index d8b2f72fc69..22eb138503e 100644 --- a/ethcore/src/spec/spec.rs +++ b/ethcore/src/spec/spec.rs @@ -280,39 +280,6 @@ impl Spec { /// Create a new Spec with InstantSeal consensus which does internal sealing (not requiring work). pub fn new_instant() -> Spec { load_bundled!("instant_seal") } - - /// Create a new Olympic chain spec. - pub fn new_ethereum_olympic() -> Spec { load_bundled!("ethereum/olympic") } - - /// Create a new Frontier mainnet chain spec. - pub fn new_ethereum_frontier() -> Spec { load_bundled!("ethereum/frontier") } - - /// Create a new Frontier mainnet chain spec without the DAO hardfork. - pub fn new_ethereum_classic() -> Spec { load_bundled!("ethereum/classic") } - - /// Create a new Frontier mainnet chain spec without the DAO hardfork. - pub fn new_expanse() -> Spec { load_bundled!("expanse") } - - /// Create a new Frontier chain spec as though it never changes to Homestead. - pub fn new_ethereum_frontier_test() -> Spec { load_bundled!("ethereum/frontier_test") } - - /// Create a new Homestead chain spec as though it never changed from Frontier. - pub fn new_ethereum_homestead_test() -> Spec { load_bundled!("ethereum/homestead_test") } - - /// Create a new Homestead-EIP150 chain spec as though it never changed from Homestead/Frontier. - pub fn new_ethereum_eip150_test() -> Spec { load_bundled!("ethereum/eip150_test") } - - /// Create a new Homestead-EIP150 chain spec as though it never changed from Homestead/Frontier. - pub fn new_ethereum_eip161_test() -> Spec { load_bundled!("ethereum/eip161_test") } - - /// Create a new Frontier/Homestead/DAO chain spec with transition points at #5 and #8. - pub fn new_ethereum_transition_test() -> Spec { load_bundled!("ethereum/transition_test") } - - /// Create a new Frontier main net chain spec without genesis accounts. - pub fn new_ethereum_mainnet_like() -> Spec { load_bundled!("ethereum/frontier_like_test") } - - /// Create a new Morden chain spec. - pub fn new_ethereum_morden() -> Spec { load_bundled!("ethereum/morden") } } #[cfg(test)] diff --git a/ethcore/src/tests/client.rs b/ethcore/src/tests/client.rs index e6fba0b0afa..99b251d6647 100644 --- a/ethcore/src/tests/client.rs +++ b/ethcore/src/tests/client.rs @@ -17,6 +17,7 @@ use io::IoChannel; use client::{BlockChainClient, MiningBlockChainClient, Client, ClientConfig, BlockID}; use state::CleanupMode; +use ethereum; use block::IsBlock; use tests::helpers::*; use types::filter::Filter; @@ -49,7 +50,7 @@ fn imports_from_empty() { #[test] fn should_return_registrar() { let dir = RandomTempPath::new(); - let spec = Spec::new_ethereum_morden(); + let spec = ethereum::new_morden(); let db_config = DatabaseConfig::with_columns(::db::NUM_COLUMNS); let client = Client::new( diff --git a/ethcore/src/tests/helpers.rs b/ethcore/src/tests/helpers.rs index a6a06608ab4..96d5f836644 100644 --- a/ethcore/src/tests/helpers.rs +++ b/ethcore/src/tests/helpers.rs @@ -27,6 +27,7 @@ use state::*; use evm::Schedule; use engines::Engine; use env_info::EnvInfo; +use ethereum; use ethereum::ethash::EthashParams; use devtools::*; use miner::Miner; @@ -52,7 +53,7 @@ pub struct TestEngine { impl TestEngine { pub fn new(max_depth: usize) -> TestEngine { TestEngine { - engine: Spec::new_ethereum_frontier_test().engine, + engine: ethereum::new_frontier_test().engine, max_depth: max_depth, } } diff --git a/parity/params.rs b/parity/params.rs index 0a24cc7ddc7..54e08da3288 100644 --- a/parity/params.rs +++ b/parity/params.rs @@ -19,6 +19,7 @@ use std::time::Duration; use util::{Address, U256, version_data}; use util::journaldb::Algorithm; use ethcore::spec::Spec; +use ethcore::ethereum; use ethcore::client::Mode; use ethcore::miner::{GasPricer, GasPriceCalibratorOptions}; use user_defaults::UserDefaults; @@ -60,11 +61,11 @@ impl str::FromStr for SpecType { impl SpecType { pub fn spec(&self) -> Result { match *self { - SpecType::Mainnet => Ok(Spec::new_ethereum_frontier()), - SpecType::Testnet => Ok(Spec::new_ethereum_morden()), - SpecType::Olympic => Ok(Spec::new_ethereum_olympic()), - SpecType::Classic => Ok(Spec::new_ethereum_classic()), - SpecType::Expanse => Ok(Spec::new_expanse()), + SpecType::Mainnet => Ok(ethereum::new_frontier()), + SpecType::Testnet => Ok(ethereum::new_morden()), + SpecType::Olympic => Ok(ethereum::new_olympic()), + SpecType::Classic => Ok(ethereum::new_classic()), + SpecType::Expanse => Ok(ethereum::new_expanse()), SpecType::Dev => Ok(Spec::new_instant()), SpecType::Custom(ref filename) => { let file = try!(fs::File::open(filename).map_err(|_| "Could not load specification file.")); diff --git a/rpc/src/v1/tests/eth.rs b/rpc/src/v1/tests/eth.rs index 38597343e6b..2f5131f3262 100644 --- a/rpc/src/v1/tests/eth.rs +++ b/rpc/src/v1/tests/eth.rs @@ -23,6 +23,7 @@ use ethcore::ids::BlockID; use ethcore::spec::{Genesis, Spec}; use ethcore::block::Block; use ethcore::views::BlockView; +use ethcore::ethereum; use ethcore::miner::{MinerOptions, Banning, GasPricer, MinerService, ExternalMiner, Miner, PendingSet, PrioritizationStrategy, GasLimit}; use ethcore::account_provider::AccountProvider; use devtools::RandomTempPath; @@ -78,7 +79,7 @@ fn snapshot_service() -> Arc { fn make_spec(chain: &BlockChain) -> Spec { let genesis = Genesis::from(chain.genesis()); - let mut spec = Spec::new_ethereum_frontier_test(); + let mut spec = ethereum::new_frontier_test(); let state = chain.pre_state.clone().into(); spec.set_genesis_state(state); spec.overwrite_genesis_params(genesis); From 0b5a9a6e60b02b69ee83d056294159316dab92b6 Mon Sep 17 00:00:00 2001 From: keorn Date: Mon, 14 Nov 2016 14:29:33 +0000 Subject: [PATCH 11/11] nicer bundled spec message --- ethcore/src/spec/spec.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ethcore/src/spec/spec.rs b/ethcore/src/spec/spec.rs index 6954836111d..de1b7db42e5 100644 --- a/ethcore/src/spec/spec.rs +++ b/ethcore/src/spec/spec.rs @@ -137,7 +137,7 @@ impl From for Spec { macro_rules! load_bundled { ($e:expr) => { - Spec::load(include_bytes!(concat!("../../res/", $e, ".json")) as &[u8]).expect("Chain spec is invalid") + Spec::load(include_bytes!(concat!("../../res/", $e, ".json")) as &[u8]).expect(concat!("Chain spec ", $e, " is invalid.")) }; }