Added bad block header hash for ropsten (#49)
* Added bad block header hash for ropsten
This commit is contained in:
parent
d17ee979b8
commit
ae312bcb01
@ -29,6 +29,7 @@ use parking_lot::{Condvar, Mutex, RwLock};
|
|||||||
use std::{
|
use std::{
|
||||||
cmp,
|
cmp,
|
||||||
collections::{HashMap, HashSet, VecDeque},
|
collections::{HashMap, HashSet, VecDeque},
|
||||||
|
iter::FromIterator,
|
||||||
sync::{
|
sync::{
|
||||||
atomic::{AtomicBool, AtomicUsize, Ordering as AtomicOrdering},
|
atomic::{AtomicBool, AtomicUsize, Ordering as AtomicOrdering},
|
||||||
Arc,
|
Arc,
|
||||||
@ -85,6 +86,8 @@ pub struct VerifierSettings {
|
|||||||
pub scale_verifiers: bool,
|
pub scale_verifiers: bool,
|
||||||
/// Beginning amount of verifiers.
|
/// Beginning amount of verifiers.
|
||||||
pub num_verifiers: usize,
|
pub num_verifiers: usize,
|
||||||
|
/// list of block and header hashes that will marked as bad and not included into chain.
|
||||||
|
pub bad_hashes: Vec<H256>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for VerifierSettings {
|
impl Default for VerifierSettings {
|
||||||
@ -92,6 +95,7 @@ impl Default for VerifierSettings {
|
|||||||
VerifierSettings {
|
VerifierSettings {
|
||||||
scale_verifiers: false,
|
scale_verifiers: false,
|
||||||
num_verifiers: ::num_cpus::get(),
|
num_verifiers: ::num_cpus::get(),
|
||||||
|
bad_hashes: Vec::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -232,7 +236,7 @@ impl<K: Kind> VerificationQueue<K> {
|
|||||||
unverified: LenCachingMutex::new(VecDeque::new()),
|
unverified: LenCachingMutex::new(VecDeque::new()),
|
||||||
verifying: LenCachingMutex::new(VecDeque::new()),
|
verifying: LenCachingMutex::new(VecDeque::new()),
|
||||||
verified: LenCachingMutex::new(VecDeque::new()),
|
verified: LenCachingMutex::new(VecDeque::new()),
|
||||||
bad: Mutex::new(HashSet::new()),
|
bad: Mutex::new(HashSet::from_iter(config.verifier_settings.bad_hashes)),
|
||||||
sizes: Sizes {
|
sizes: Sizes {
|
||||||
unverified: AtomicUsize::new(0),
|
unverified: AtomicUsize::new(0),
|
||||||
verifying: AtomicUsize::new(0),
|
verifying: AtomicUsize::new(0),
|
||||||
|
@ -286,6 +286,7 @@ impl BlockDownloader {
|
|||||||
let number = BlockNumber::from(info.header.number());
|
let number = BlockNumber::from(info.header.number());
|
||||||
let hash = info.header.hash();
|
let hash = info.header.hash();
|
||||||
|
|
||||||
|
// This part checks if first header is what we expect and that all other header are chained correctly.
|
||||||
let valid_response = match last_header {
|
let valid_response = match last_header {
|
||||||
// First header must match expected hash.
|
// First header must match expected hash.
|
||||||
None => expected_hash == hash,
|
None => expected_hash == hash,
|
||||||
@ -305,6 +306,7 @@ impl BlockDownloader {
|
|||||||
return Err(BlockDownloaderImportError::Invalid);
|
return Err(BlockDownloaderImportError::Invalid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If header is already included skip and go to next one in chain.
|
||||||
last_header = Some((number, hash));
|
last_header = Some((number, hash));
|
||||||
if self.blocks.contains(&hash) {
|
if self.blocks.contains(&hash) {
|
||||||
trace_sync!(
|
trace_sync!(
|
||||||
@ -316,6 +318,7 @@ impl BlockDownloader {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if received header is present in chain. If it is in chain include header into list that will be inserted
|
||||||
match io.chain().block_status(BlockId::Hash(hash.clone())) {
|
match io.chain().block_status(BlockId::Hash(hash.clone())) {
|
||||||
BlockStatus::InChain | BlockStatus::Queued => {
|
BlockStatus::InChain | BlockStatus::Queued => {
|
||||||
match self.state {
|
match self.state {
|
||||||
@ -343,6 +346,7 @@ impl BlockDownloader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set highest block that we receive from network. This is only used as stat and nothing more.
|
||||||
if let Some((number, _)) = last_header {
|
if let Some((number, _)) = last_header {
|
||||||
if self.highest_block.as_ref().map_or(true, |n| number > *n) {
|
if self.highest_block.as_ref().map_or(true, |n| number > *n) {
|
||||||
self.highest_block = Some(number);
|
self.highest_block = Some(number);
|
||||||
|
@ -34,6 +34,7 @@ use ethcore::{
|
|||||||
};
|
};
|
||||||
use ethcore_logger::{Config as LogConfig, RotatingLogger};
|
use ethcore_logger::{Config as LogConfig, RotatingLogger};
|
||||||
use ethcore_service::ClientService;
|
use ethcore_service::ClientService;
|
||||||
|
use ethereum_types::H256;
|
||||||
use helpers::{execute_upgrades, passwords_from_files, to_client_config};
|
use helpers::{execute_upgrades, passwords_from_files, to_client_config};
|
||||||
use informant::{FullNodeInformantData, Informant};
|
use informant::{FullNodeInformantData, Informant};
|
||||||
use journaldb::Algorithm;
|
use journaldb::Algorithm;
|
||||||
@ -329,6 +330,7 @@ pub fn execute(cmd: RunCmd, logger: Arc<RotatingLogger>) -> Result<RunningClient
|
|||||||
);
|
);
|
||||||
|
|
||||||
client_config.queue.verifier_settings = cmd.verifier_settings;
|
client_config.queue.verifier_settings = cmd.verifier_settings;
|
||||||
|
client_config.queue.verifier_settings.bad_hashes = verification_bad_blocks(&cmd.spec);
|
||||||
client_config.transaction_verification_queue_size = ::std::cmp::max(2048, txpool_size / 4);
|
client_config.transaction_verification_queue_size = ::std::cmp::max(2048, txpool_size / 4);
|
||||||
client_config.snapshot = cmd.snapshot_conf.clone();
|
client_config.snapshot = cmd.snapshot_conf.clone();
|
||||||
|
|
||||||
@ -594,6 +596,16 @@ pub fn execute(cmd: RunCmd, logger: Arc<RotatingLogger>) -> Result<RunningClient
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Set bad blocks in VerificationQeueu. By omiting header we can omit particular fork of chain.
|
||||||
|
fn verification_bad_blocks(spec: &SpecType) -> Vec<H256> {
|
||||||
|
match *spec {
|
||||||
|
SpecType::Ropsten => {
|
||||||
|
vec!["1eac3d16c642411f13c287e29144c6f58fda859407c8f24c38deb168e1040714".into()]
|
||||||
|
}
|
||||||
|
_ => vec![],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Parity client currently executing in background threads.
|
/// Parity client currently executing in background threads.
|
||||||
///
|
///
|
||||||
/// Should be destroyed by calling `shutdown()`, otherwise execution will continue in the
|
/// Should be destroyed by calling `shutdown()`, otherwise execution will continue in the
|
||||||
|
Loading…
Reference in New Issue
Block a user