From d7bfc6f10b511ab365ac72f91376651cf0b571f1 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Wed, 27 Jan 2016 15:01:59 +0100 Subject: [PATCH 1/6] Remove misleading comment. --- src/tests/chain.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tests/chain.rs b/src/tests/chain.rs index 97dc2767f..0cf13acb4 100644 --- a/src/tests/chain.rs +++ b/src/tests/chain.rs @@ -68,7 +68,7 @@ declare_test!{BlockchainTests_bcInvalidRLPTest, "BlockchainTests/bcInvalidRLPTes declare_test!{BlockchainTests_bcMultiChainTest, "BlockchainTests/bcMultiChainTest"} declare_test!{BlockchainTests_bcRPC_API_Test, "BlockchainTests/bcRPC_API_Test"} declare_test!{BlockchainTests_bcStateTest, "BlockchainTests/bcStateTest"} -declare_test!{BlockchainTests_bcTotalDifficultyTest, "BlockchainTests/bcTotalDifficultyTest"} // FAILS: ZeroPrefixed Int. +declare_test!{BlockchainTests_bcTotalDifficultyTest, "BlockchainTests/bcTotalDifficultyTest"} declare_test!{BlockchainTests_bcUncleHeaderValiditiy, "BlockchainTests/bcUncleHeaderValiditiy"} declare_test!{BlockchainTests_bcUncleTest, "BlockchainTests/bcUncleTest"} declare_test!{BlockchainTests_bcValidBlockTest, "BlockchainTests/bcValidBlockTest"} From 7e7b2880957442adc83732ecd8eef21193b251af Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Wed, 27 Jan 2016 16:02:03 +0100 Subject: [PATCH 2/6] Fixes #221 --- src/tests/chain.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tests/chain.rs b/src/tests/chain.rs index 0cf13acb4..44e30e7ea 100644 --- a/src/tests/chain.rs +++ b/src/tests/chain.rs @@ -61,7 +61,7 @@ fn do_json_test(json_data: &[u8]) -> Vec { declare_test!{BlockchainTests_bcBlockGasLimitTest, "BlockchainTests/bcBlockGasLimitTest"} declare_test!{BlockchainTests_bcForkBlockTest, "BlockchainTests/bcForkBlockTest"} declare_test!{BlockchainTests_bcForkStressTest, "BlockchainTests/bcForkStressTest"} // STILL FAILS -declare_test!{BlockchainTests_bcForkUncle, "BlockchainTests/bcForkUncle"} // STILL FAILS +declare_test!{BlockchainTests_bcForkUncle, "BlockchainTests/bcForkUncle"} declare_test!{BlockchainTests_bcGasPricerTest, "BlockchainTests/bcGasPricerTest"} declare_test!{BlockchainTests_bcInvalidHeaderTest, "BlockchainTests/bcInvalidHeaderTest"} declare_test!{BlockchainTests_bcInvalidRLPTest, "BlockchainTests/bcInvalidRLPTest"} From d4c76eed0f55141bdfbaa0a9f074c6cb94eebc77 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Wed, 27 Jan 2016 16:05:23 +0100 Subject: [PATCH 3/6] Fixes #220. --- src/tests/chain.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/tests/chain.rs b/src/tests/chain.rs index 44e30e7ea..babd2a42f 100644 --- a/src/tests/chain.rs +++ b/src/tests/chain.rs @@ -42,9 +42,6 @@ fn do_json_test(json_data: &[u8]) -> Vec { client.flush_queue(); let imported_ok = client.import_verified_blocks(&IoChannel::disconnected()) > 0; assert_eq!(imported_ok, is_valid); - if imported_ok { - flushln!("Imported {}; best block {}", hash, client.chain_info().best_block_hash); - } } fail_unless(client.chain_info().best_block_hash == H256::from_json(&test["lastblockhash"])); } @@ -60,7 +57,7 @@ fn do_json_test(json_data: &[u8]) -> Vec { declare_test!{BlockchainTests_bcBlockGasLimitTest, "BlockchainTests/bcBlockGasLimitTest"} declare_test!{BlockchainTests_bcForkBlockTest, "BlockchainTests/bcForkBlockTest"} -declare_test!{BlockchainTests_bcForkStressTest, "BlockchainTests/bcForkStressTest"} // STILL FAILS +declare_test!{BlockchainTests_bcForkStressTest, "BlockchainTests/bcForkStressTest"} declare_test!{BlockchainTests_bcForkUncle, "BlockchainTests/bcForkUncle"} declare_test!{BlockchainTests_bcGasPricerTest, "BlockchainTests/bcGasPricerTest"} declare_test!{BlockchainTests_bcInvalidHeaderTest, "BlockchainTests/bcInvalidHeaderTest"} From 0cd2e855698ada995467b48767a2462e521dafa5 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Wed, 27 Jan 2016 16:13:21 +0100 Subject: [PATCH 4/6] Remove flushlns and tidy ready for primetime. --- src/block_queue.rs | 2 -- src/client.rs | 5 ----- src/tests/chain.rs | 5 +---- 3 files changed, 1 insertion(+), 11 deletions(-) diff --git a/src/block_queue.rs b/src/block_queue.rs index dab3a5fe3..5ce649710 100644 --- a/src/block_queue.rs +++ b/src/block_queue.rs @@ -158,7 +158,6 @@ impl BlockQueue { }, Err(err) => { let mut v = verification.lock().unwrap(); - flushln!("Stage 2 block verification failed for {}\nError: {:?}", block_hash, err); warn!(target: "client", "Stage 2 block verification failed for {}\nError: {:?}", block_hash, err); v.bad.insert(block_hash.clone()); v.verifying.retain(|e| e.hash != block_hash); @@ -224,7 +223,6 @@ impl BlockQueue { Ok(h) }, Err(err) => { - flushln!("Stage 1 block verification failed for {}\nError: {:?}", BlockView::new(&bytes).header_view().sha3(), err); warn!(target: "client", "Stage 1 block verification failed for {}\nError: {:?}", BlockView::new(&bytes).header_view().sha3(), err); self.verification.lock().unwrap().bad.insert(h.clone()); Err(From::from(err)) diff --git a/src/client.rs b/src/client.rs index 8aea437e4..33ba19147 100644 --- a/src/client.rs +++ b/src/client.rs @@ -199,7 +199,6 @@ impl Client { let _import_lock = self.import_lock.lock(); let blocks = self.block_queue.write().unwrap().drain(128); for block in blocks { -// flushln!("Importing {}...", block.header.hash()); if bad.contains(&block.header.parent_hash) { self.block_queue.write().unwrap().mark_as_bad(&block.header.hash()); bad.insert(block.header.hash()); @@ -208,7 +207,6 @@ impl Client { let header = &block.header; if let Err(e) = verify_block_family(&header, &block.bytes, self.engine.deref().deref(), self.chain.read().unwrap().deref()) { - flushln!("Stage 3 block verification failed for #{} ({})\nError: {:?}", header.number(), header.hash(), e); warn!(target: "client", "Stage 3 block verification failed for #{} ({})\nError: {:?}", header.number(), header.hash(), e); self.block_queue.write().unwrap().mark_as_bad(&header.hash()); bad.insert(block.header.hash()); @@ -217,7 +215,6 @@ impl Client { let parent = match self.chain.read().unwrap().block_header(&header.parent_hash) { Some(p) => p, None => { - flushln!("Block import failed for #{} ({}): Parent not found ({}) ", header.number(), header.hash(), header.parent_hash); warn!(target: "client", "Block import failed for #{} ({}): Parent not found ({}) ", header.number(), header.hash(), header.parent_hash); self.block_queue.write().unwrap().mark_as_bad(&header.hash()); bad.insert(block.header.hash()); @@ -241,7 +238,6 @@ impl Client { let result = match enact_verified(&block, self.engine.deref().deref(), db, &parent, &last_hashes) { Ok(b) => b, Err(e) => { - flushln!("Block import failed for #{} ({})\nError: {:?}", header.number(), header.hash(), e); warn!(target: "client", "Block import failed for #{} ({})\nError: {:?}", header.number(), header.hash(), e); bad.insert(block.header.hash()); self.block_queue.write().unwrap().mark_as_bad(&header.hash()); @@ -249,7 +245,6 @@ impl Client { } }; if let Err(e) = verify_block_final(&header, result.block().header()) { - flushln!("Stage 4 block verification failed for #{} ({})\nError: {:?}", header.number(), header.hash(), e); warn!(target: "client", "Stage 4 block verification failed for #{} ({})\nError: {:?}", header.number(), header.hash(), e); self.block_queue.write().unwrap().mark_as_bad(&header.hash()); break; diff --git a/src/tests/chain.rs b/src/tests/chain.rs index babd2a42f..42b4ee78a 100644 --- a/src/tests/chain.rs +++ b/src/tests/chain.rs @@ -33,11 +33,8 @@ fn do_json_test(json_data: &[u8]) -> Vec { { let client = Client::new(spec, &dir, IoChannel::disconnected()).unwrap(); for (b, is_valid) in blocks.into_iter() { - let mut hash = H256::new(); if Block::is_good(&b) { - if let Ok(h) = client.import_block(b.clone()) { - hash = h; - } + let _ = client.import_block(b.clone()); } client.flush_queue(); let imported_ok = client.import_verified_blocks(&IoChannel::disconnected()) > 0; From 765666faedd2932bb2a89c178b3554989ab8567b Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Wed, 27 Jan 2016 16:37:32 +0100 Subject: [PATCH 5/6] Rwmove squeeze_to_fit --- src/blockchain.rs | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/blockchain.rs b/src/blockchain.rs index da9ee04c2..fb3755ff2 100644 --- a/src/blockchain.rs +++ b/src/blockchain.rs @@ -565,15 +565,6 @@ impl BlockChain { } } - /// Tries to squeeze the cache if its too big. - pub fn squeeze_to_fit(&self, size: CacheSize) { - self.blocks.write().unwrap().squeeze(size.blocks); - self.block_details.write().unwrap().squeeze(size.block_details); - self.transaction_addresses.write().unwrap().squeeze(size.transaction_addresses); - self.block_logs.write().unwrap().squeeze(size.block_logs); - self.blocks_blooms.write().unwrap().squeeze(size.blocks_blooms); - } - /// Let the cache system know that a cacheable item has been used. fn note_used(&self, id: CacheID) { let mut cache_man = self.cache_man.write().unwrap(); From 1c67dfdaf9de4851d210833940531da6293f5c51 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Wed, 27 Jan 2016 16:41:15 +0100 Subject: [PATCH 6/6] Fix network test. --- src/sync/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sync/mod.rs b/src/sync/mod.rs index 78a5d7613..3223b69bf 100644 --- a/src/sync/mod.rs +++ b/src/sync/mod.rs @@ -9,13 +9,13 @@ /// extern crate ethcore; /// use std::env; /// use std::sync::Arc; -/// use util::network::NetworkService; +/// use util::network::{NetworkService,NetworkConfiguration}; /// use ethcore::client::Client; /// use ethcore::sync::EthSync; /// use ethcore::ethereum; /// /// fn main() { -/// let mut service = NetworkService::start().unwrap(); +/// let mut service = NetworkService::start(NetworkConfiguration::new()).unwrap(); /// let dir = env::temp_dir(); /// let client = Client::new(ethereum::new_frontier(), &dir, service.io().channel()).unwrap(); /// EthSync::register(&mut service, client);