diff --git a/core/src/global.rs b/core/src/global.rs index af6a9efe6..4e1662c56 100644 --- a/core/src/global.rs +++ b/core/src/global.rs @@ -112,25 +112,34 @@ pub const TXHASHSET_ARCHIVE_INTERVAL: u64 = 12 * 60; /// MWC - all DNS hosts are updated with seed1.mwc.mw/seed2.mwc.mw and others pub const MAINNET_DNS_SEEDS: &'static [&'static str] = &[ - "mainnet.seed1.mwc.mw", // cpg - "mainnet.seed2.mwc.mw", // cpg - "greg1.mainnet.seed.mwc.mw", // Greg - "greg2.mainnet.seed.mwc.mw", // Greg - "mwcseed.ddns.net", // cpg - "uukwrgtxogz6kkpcejssb7aenb7ey7pr3h5i4llhse445dfpbp63osyd.onion", // 2o_main_410_tor - "xsjhexie5v7gxmdkvzkzb4qifywnolb6v22wzvppscs2gog6ljribuad.onion", // 2m_main_floo_master_tor - "ltjbwsexjixh5p2qxjohxd342fxhag7ljuvkjnnmkuu6wer6cg4skoad.onion", // 2mb_main_410_tor - "wmksifwk6gh22qydmbbnv7iyphnr7jfmwsazgxbo244mkwa2k2fol2yd.onion", // 2p_main_410_arch_tor - "z5ys2rogjas46tpyu343m4tamkiog6pkpznfwpu3iff55b7xypd3wcad.onion", // 2p_main_410_tor - "n4ac7b65tgtachkh5ii5zytmjkbqc3bq64rhllhz4npyrbxvz7ic5byd.onion", // 2sy_main_master_tor + "mainnet.seed2.mwc.mw", // cpg + "mwcseed.ddns.net", // cpg + "t5p26dycaa7w6vzc424mahhykncv2w2tt24isaluraszhpoc6viwcqyd.onion", + "6y2r3zcscduyaqvak4nr5muo72n46fqacz2bnfqnxmf3oksapjepkcyd.onion", + "3.132.79.177", + "18.217.245.152", + "xsjhexie5v7gxmdkvzkzb4qifywnolb6v22wzvppscs2gog6ljribuad.onion", + // mb + "p5qo2pgkv5qpjnrlxzesf4ikcxyvvtwg6aolpamp24es5lic3btshrqd.onion", + "ltjbwsexjixh5p2qxjohxd342fxhag7ljuvkjnnmkuu6wer6cg4skoad.onion", + "3.6.231.127", + "52.78.112.116", + "plnrnhuuwjcowtjejqx6ou4m2bxkvkqq2rj4ot6cwgf53chgw2keu7yd.onion", + "q3l5s4idfo7ukmbvz6mgowe3w65bt4w4skeskzs4g2ixpmw2euvxxvyd.onion", + "z5ys2rogjas46tpyu343m4tamkiog6pkpznfwpu3iff55b7xypd3wcad.onion", + "q3l5s4idfo7ukmbvz6mgowe3w65bt4w4skeskzs4g2ixpmw2euvxxvyd.onion", + "n4ac7b65tgtachkh5ii5zytmjkbqc3bq64rhllhz4npyrbxvz7ic5byd.onion", ]; /// DNS Seed for floonet pub const FLOONET_DNS_SEEDS: &'static [&'static str] = &[ "seed1.mwc.mw", "seed2.mwc.mw", - "wt635fgwmhokk25lv7y2jvrg63mokg7nfni5owrtzalz3nx22dgjytid.onion", // 2sy-floo-master-tor - "kin4i3wohlsqlzrdwdlowh2kaa7wtkxsvp6asn7vttspnrwowgquglyd.onion", // 2mb_floo_410_tor - "vstdjxrzh67udhm3fedanul2sy7fwudasjmwxy54pady6dxclty2zmqd.onion", // 2p_floo_410_arch_tor + "zwecav6dgftsoscybpzufbo77d452mk3mox2fqzjqocu7265bxgq6oad.onion", + "3.97.39.110", + "5xwjlg6fykkj2hhvlnernj4s2jmuv5en5i3i32qld3k5jznuzpbiblid.onion", + "13.209.51.140", + "oqtl7wlzukgp7r6kdp3uvyelzmc72ngknwd23lo7uw63rwornvcmg3yd.onion", + "wt635fgwmhokk25lv7y2jvrg63mokg7nfni5owrtzalz3nx22dgjytid.onion", ]; /// Types of chain a server can run with, dictates the genesis block and diff --git a/servers/src/common/adapters.rs b/servers/src/common/adapters.rs index d1cbcb378..82746d120 100644 --- a/servers/src/common/adapters.rs +++ b/servers/src/common/adapters.rs @@ -793,6 +793,7 @@ where .height .saturating_sub(global::cut_through_horizon() as u64); if b.header.height < horizon { + debug!("Got block is below horizon from peer {}", peer_info.addr); return Ok(true); } } @@ -813,6 +814,7 @@ where Ok(true) } Err(ref e) if e.is_bad_data() => { + warn!("process_block: block {} from peer {} is bad. Block is rejected, peer is banned. Error: {}", bhash, peer_info.addr, e); self.validate_chain(&bhash); self.sync_manager.recieve_block_reporting( false, @@ -823,14 +825,14 @@ where Ok(false) } Err(e) => { + self.sync_manager.recieve_block_reporting( + !e.is_bad_data(), + &peer_info.addr, + &bhash, + &self.peers(), + ); match e { chain::Error::Orphan(orph_msg) => { - self.sync_manager.recieve_block_reporting( - true, - &peer_info.addr, - &bhash, - &self.peers(), - ); if let Ok(previous) = previous { // make sure we did not miss the parent block if !self.chain().is_orphan(&previous.hash()) @@ -843,12 +845,9 @@ where Ok(true) } _ => { - debug!("process_block: block {} refused by chain: {}", bhash, e); - self.sync_manager.recieve_block_reporting( - false, - &peer_info.addr, - &bhash, - &self.peers(), + info!( + "process_block: block {} from peer {} refused by chain: {}", + bhash, peer_info.addr, e ); Ok(true) } diff --git a/servers/src/mwc/sync/body_sync.rs b/servers/src/mwc/sync/body_sync.rs index 4269d535e..4d657433c 100644 --- a/servers/src/mwc/sync/body_sync.rs +++ b/servers/src/mwc/sync/body_sync.rs @@ -262,21 +262,21 @@ impl BodySync { pub fn recieve_block_reporting( &self, - accepted: bool, // block accepted/rejected flag + valid_block: bool, // block accepted/rejected flag block_hash: &Hash, peer: &PeerAddr, peers: &Arc, sync_peers: &SyncPeers, ) { if let Some(peer_adr) = self.request_tracker.remove_request(block_hash, peer) { - if accepted { + if valid_block { if peer_adr == *peer { sync_peers.report_ok_response(peer); } } } - if !accepted { + if !valid_block { sync_peers.report_error_response( peer, format!("Get bad block {} for peer {}", block_hash, peer), diff --git a/servers/src/mwc/sync/sync_manager.rs b/servers/src/mwc/sync/sync_manager.rs index 447e079a9..034d539fa 100644 --- a/servers/src/mwc/sync/sync_manager.rs +++ b/servers/src/mwc/sync/sync_manager.rs @@ -383,13 +383,13 @@ impl SyncManager { pub fn recieve_block_reporting( &self, - accepted: bool, // block accepted/rejected flag + valid_block: bool, // block accepted/rejected flag peer: &PeerAddr, block_hash: &Hash, peers: &Arc, ) { self.body.recieve_block_reporting( - accepted, + valid_block, block_hash, peer, peers, diff --git a/servers/src/mwc/sync/sync_peers.rs b/servers/src/mwc/sync/sync_peers.rs index fac3a93ec..28207a9bb 100644 --- a/servers/src/mwc/sync/sync_peers.rs +++ b/servers/src/mwc/sync/sync_peers.rs @@ -16,6 +16,7 @@ // Normally we would put that into the base class, but rust doesn't support that. use mwc_p2p::{PeerAddr, Peers, ReasonForBan}; +use mwc_util::secp::rand::Rng; use mwc_util::RwLock; use std::collections::{HashMap, HashSet, VecDeque}; use std::sync::Arc; @@ -101,6 +102,10 @@ impl PeerPibdStatus { (res_ban, res_network_issue, comment) } + + pub fn reset(&mut self) { + self.responses.clear(); + } } pub struct SyncPeers { @@ -158,8 +163,15 @@ impl SyncPeers { let mut offline_peers: Vec = Vec::new(); for cp in check_peers.iter() { if let Some(status) = peers_status.get_mut(cp) { - let (ban, offline, comment) = status.check_for_ban(cp); + let (mut ban, offline, comment) = status.check_for_ban(cp); let peer_addr = PeerAddr::from_str(cp); + if offline { + // let's ban some offlines with a chances... + let mut rng = rand::thread_rng(); + if rng.gen_range(0, 7) == 3 { + ban = true; + } + } if ban { if let Err(e) = peers.ban_peer(&peer_addr, ReasonForBan::PibdFailure, &comment) { @@ -169,6 +181,7 @@ impl SyncPeers { } if ban || offline { offline_peers.push(peer_addr); + status.reset(); } } }