diff --git a/chain/src/chain.rs b/chain/src/chain.rs index d29474e22..786609bac 100644 --- a/chain/src/chain.rs +++ b/chain/src/chain.rs @@ -33,8 +33,6 @@ use sumtree; use types::*; use util::LOGGER; -use core::global; - const MAX_ORPHANS: usize = 20; /// Facade to the blockchain block processing pipeline and storage. Provides @@ -154,6 +152,15 @@ impl Chain { orphans.push_front((opts, b)); orphans.truncate(MAX_ORPHANS); }, + Err(Error::Unfit(ref msg)) => { + debug!( + LOGGER, + "Block {} at {} is unfit at this time: {}", + b.hash(), + b.header.height, + msg + ); + } Err(ref e) => { info!( LOGGER, @@ -184,12 +191,6 @@ impl Chain { } fn ctx_from_head(&self, head: Tip, opts: Options) -> pipe::BlockContext { - let opts = if global::is_production_mode() { - opts - } else { - opts | EASY_POW - }; - pipe::BlockContext { opts: opts, store: self.store.clone(), diff --git a/chain/src/lib.rs b/chain/src/lib.rs index b0ef92860..b3faf228a 100644 --- a/chain/src/lib.rs +++ b/chain/src/lib.rs @@ -43,4 +43,4 @@ pub mod types; // Re-export the base interface pub use chain::Chain; -pub use types::{ChainAdapter, ChainStore, Error, Options, Tip, EASY_POW, NONE, SKIP_POW, SYNC}; +pub use types::{ChainAdapter, ChainStore, Error, Options, Tip, NONE, SKIP_POW, SYNC}; diff --git a/chain/src/pipe.rs b/chain/src/pipe.rs index d2cc9f772..3e6e07303 100644 --- a/chain/src/pipe.rs +++ b/chain/src/pipe.rs @@ -155,11 +155,8 @@ fn validate_header(header: &BlockHeader, ctx: &mut BlockContext) -> Result<(), E } if !ctx.opts.intersects(SKIP_POW) { - let cycle_size = if ctx.opts.intersects(EASY_POW) { - global::sizeshift() - } else { - consensus::DEFAULT_SIZESHIFT - }; + let cycle_size = global::sizeshift(); + debug!(LOGGER, "Validating block with cuckoo size {}", cycle_size); if !(ctx.pow_verifier)(header, cycle_size as u32) { return Err(Error::InvalidPow); diff --git a/chain/src/types.rs b/chain/src/types.rs index 00ec3c650..b9c9dae26 100644 --- a/chain/src/types.rs +++ b/chain/src/types.rs @@ -32,8 +32,6 @@ bitflags! { const NONE = 0b00000001, /// Runs without checking the Proof of Work, mostly to make testing easier. const SKIP_POW = 0b00000010, - /// Runs PoW verification with a lower cycle size. - const EASY_POW = 0b00000100, /// Adds block while in syncing mode. const SYNC = 0b00001000, } diff --git a/chain/tests/mine_simple_chain.rs b/chain/tests/mine_simple_chain.rs index 41b7994b3..d9fb0a65a 100644 --- a/chain/tests/mine_simple_chain.rs +++ b/chain/tests/mine_simple_chain.rs @@ -92,7 +92,7 @@ fn mine_empty_chain() { ).unwrap(); let bhash = b.hash(); - chain.process_block(b, chain::EASY_POW).unwrap(); + chain.process_block(b, chain::NONE).unwrap(); // checking our new head let head = chain.head().unwrap(); diff --git a/chain/tests/test_coinbase_maturity.rs b/chain/tests/test_coinbase_maturity.rs index d2928fc0a..5ec4f8922 100644 --- a/chain/tests/test_coinbase_maturity.rs +++ b/chain/tests/test_coinbase_maturity.rs @@ -97,7 +97,7 @@ fn test_coinbase_maturity() { .contains(transaction::COINBASE_OUTPUT,) ); - chain.process_block(block, chain::EASY_POW).unwrap(); + chain.process_block(block, chain::NONE).unwrap(); let prev = chain.head_header().unwrap(); @@ -126,7 +126,7 @@ fn test_coinbase_maturity() { global::sizeshift() as u32, ).unwrap(); - let result = chain.process_block(block, chain::EASY_POW); + let result = chain.process_block(block, chain::NONE); match result { Err(Error::ImmatureCoinbase) => (), _ => panic!("expected ImmatureCoinbase error here"), @@ -154,7 +154,7 @@ fn test_coinbase_maturity() { global::sizeshift() as u32, ).unwrap(); - chain.process_block(block, chain::EASY_POW).unwrap(); + chain.process_block(block, chain::NONE).unwrap(); } let prev = chain.head_header().unwrap(); @@ -175,7 +175,7 @@ fn test_coinbase_maturity() { global::sizeshift() as u32, ).unwrap(); - let result = chain.process_block(block, chain::EASY_POW); + let result = chain.process_block(block, chain::NONE); match result { Ok(_) => (), Err(Error::ImmatureCoinbase) => panic!("we should not get an ImmatureCoinbase here"), diff --git a/core/src/genesis.rs b/core/src/genesis.rs index 4a7bf5ea6..7a836a030 100644 --- a/core/src/genesis.rs +++ b/core/src/genesis.rs @@ -53,12 +53,19 @@ pub fn genesis_testnet1() -> core::Block { previous: core::hash::Hash([0xff; 32]), timestamp: time::Tm { tm_year: 2017 - 1900, - tm_mon: 12, - tm_mday: 25, + tm_mon: 10, + tm_mday: 16, + tm_hour: 20, ..time::empty_tm() }, - nonce: 1, - pow: core::Proof::zero(consensus::PROOFSIZE), + nonce: 28205, + pow: core::Proof::new(vec![0x21e, 0x7a2, 0xeae, 0x144e, 0x1b1c, 0x1fbd, + 0x203a, 0x214b, 0x293b, 0x2b74, 0x2bfa, 0x2c26, + 0x32bb, 0x346a, 0x34c7, 0x37c5, 0x4164, 0x42cc, + 0x4cc3, 0x55af, 0x5a70, 0x5b14, 0x5e1c, 0x5f76, + 0x6061, 0x60f9, 0x61d7, 0x6318, 0x63a1, 0x63fb, + 0x649b, 0x64e5, 0x65a1, 0x6b69, 0x70f8, 0x71c7, + 0x71cd, 0x7492, 0x7b11, 0x7db8, 0x7f29, 0x7ff8]), ..Default::default() }, inputs: vec![], diff --git a/core/src/global.rs b/core/src/global.rs index 50dd5112d..1a3d9000a 100644 --- a/core/src/global.rs +++ b/core/src/global.rs @@ -88,7 +88,7 @@ pub fn sizeshift() -> u8 { match *param_ref { ChainTypes::AutomatedTesting => AUTOMATED_TESTING_SIZESHIFT, ChainTypes::UserTesting => USER_TESTING_SIZESHIFT, - ChainTypes::Testnet1 => DEFAULT_SIZESHIFT, + ChainTypes::Testnet1 => USER_TESTING_SIZESHIFT, ChainTypes::Mainnet => DEFAULT_SIZESHIFT, } } @@ -134,7 +134,6 @@ pub fn is_production_mode() -> bool { ChainTypes::Mainnet == *param_ref } - /// Helper function to get a nonce known to create a valid POW on /// the genesis block, to prevent it taking ages. Should be fine for now /// as the genesis block POW solution turns out to be the same for every new diff --git a/grin.toml b/grin.toml index e9fe75154..0f0016beb 100644 --- a/grin.toml +++ b/grin.toml @@ -26,10 +26,11 @@ api_http_addr = "127.0.0.1:13413" db_root = ".grin" #How to seed this server, can be None, List or WebStatic +# +#seeding_type = "None" -seeding_type = "None" - -#if seeding_type = List, the list of peers to connect to. +#If seeding_type = List, the list of peers to connect to. +# #seeds = ["192.168.0.1:8080","192.168.0.2:8080"] #The chain type, which defines the genesis block and the set of cuckoo @@ -37,8 +38,8 @@ seeding_type = "None" #AutomatedTesting - For CI builds and instant blockchain creation #UserTesting - For regular user testing (cuckoo 16) #Testnet1 - Full production cuckoo parameter (cuckoo 30) - -chain_type = "UserTesting" +# +#chain_type = "UserTesting" #7 = Bit flags for FULL_NODE, this structure needs to be changed #internally to make it more configurable diff --git a/grin/src/adapters.rs b/grin/src/adapters.rs index d025aa2c3..b665dac92 100644 --- a/grin/src/adapters.rs +++ b/grin/src/adapters.rs @@ -21,7 +21,6 @@ use core::core::{self, Output}; use core::core::block::BlockHeader; use core::core::hash::{Hash, Hashed}; use core::core::target::Difficulty; -use core::global; use p2p::{self, NetAdapter, PeerData, PeerStore, Server, State}; use pool; use util::secp::pedersen::Commitment; @@ -286,11 +285,6 @@ impl NetToChainAdapter { } else { chain::NONE }; - let opts = if global::is_production_mode() { - opts - } else { - opts | chain::EASY_POW - }; opts } } diff --git a/grin/src/miner.rs b/grin/src/miner.rs index d5e790baa..357c91470 100644 --- a/grin/src/miner.rs +++ b/grin/src/miner.rs @@ -507,12 +507,7 @@ impl Miner { b.hash() ); b.header.pow = proof; - let opts = if cuckoo_size < consensus::DEFAULT_SIZESHIFT as u32 { - chain::EASY_POW - } else { - chain::NONE - }; - let res = self.chain.process_block(b, opts); + let res = self.chain.process_block(b, chain::NONE); if let Err(e) = res { error!( LOGGER, diff --git a/grin/src/seed.rs b/grin/src/seed.rs index 6be5f4dc7..f89da2f65 100644 --- a/grin/src/seed.rs +++ b/grin/src/seed.rs @@ -35,7 +35,7 @@ use util::LOGGER; const PEER_MAX_COUNT: u32 = 25; const PEER_PREFERRED_COUNT: u32 = 8; -const SEEDS_URL: &'static str = "http://www.mimwim.org/seeds.txt"; +const SEEDS_URL: &'static str = "http://grin-tech.org/seeds.txt"; pub struct Seeder { peer_store: Arc<p2p::PeerStore>, @@ -158,7 +158,7 @@ impl Seeder { }) .and_then(|mut peers| { // if so, get their addresses, otherwise use our seeds - if peers.len() > 0 { + if peers.len() > 3 { thread_rng().shuffle(&mut peers[..]); Box::new(future::ok(peers.iter().map(|p| p.addr).collect::<Vec<_>>())) } else { @@ -218,6 +218,7 @@ pub fn web_seeds(h: reactor::Handle) -> Box<Future<Item = Vec<SocketAddr>, Error let url = hyper::Uri::from_str(&SEEDS_URL).unwrap(); let seeds = future::ok(()).and_then(move |_| { let client = hyper::Client::new(&h); + debug!(LOGGER, "Retrieving seed nodes from {}", &SEEDS_URL); // http get, filtering out non 200 results client @@ -241,6 +242,7 @@ pub fn web_seeds(h: reactor::Handle) -> Box<Future<Item = Vec<SocketAddr>, Error let addrs = res.split_whitespace() .map(|s| s.parse().unwrap()) .collect::<Vec<_>>(); + debug!(LOGGER, "Retrieved seed addresses: {:?}", addrs); Ok(addrs) }) }) diff --git a/grin/src/types.rs b/grin/src/types.rs index 3a6f67999..ed2de313a 100644 --- a/grin/src/types.rs +++ b/grin/src/types.rs @@ -81,6 +81,12 @@ pub enum Seeding { Programmatic, } +impl Default for Seeding { + fn default() -> Seeding { + Seeding::None + } +} + /// Full server configuration, aggregating configurations required for the /// different components. #[derive(Debug, Clone, Serialize, Deserialize)] @@ -96,6 +102,7 @@ pub struct ServerConfig { pub chain_type: ChainTypes, /// Method used to get the list of seed nodes for initial bootstrap. + #[serde(default)] pub seeding_type: Seeding, /// The list of seed nodes, if using Seeding as a seed type @@ -122,7 +129,7 @@ impl Default for ServerConfig { db_root: ".grin".to_string(), api_http_addr: "0.0.0.0:13413".to_string(), capabilities: p2p::FULL_NODE, - seeding_type: Seeding::None, + seeding_type: Seeding::default(), seeds: None, p2p_config: Some(p2p::P2PConfig::default()), mining_config: Some(pow::types::MinerConfig::default()),