Skip to content
Permalink
Browse files

Merge branch 'merge-v0.15.4-to-develop' into develop

  • Loading branch information...
doitian committed Jul 4, 2019
2 parents 36d596b + f0c08be commit a02c675c50c5969a588fa7f6356f08861d8f5f92
@@ -1,7 +1,20 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [v0.15.3](https://github.com/nervosnetwork/ckb/compare/v0.15.0...v0.15.3) (2019-07-01)
# [v0.15.4](https://github.com/nervosnetwork/ckb/compare/v0.15.3...v0.15.4) (2019-07-04)

### Features

* #1151: Allow providing extra sentry info in config (@doitian)

### Bug Fixes

* #1164: Ban peer when validate received block failed (@TheWaWaR)
* #1167: Proposal reward calculate consistency (@zhangsoledad)
* #1169: Only sync with outbound peer in IBD mode (@quake)


# [v0.15.3](https://github.com/nervosnetwork/ckb/compare/v0.15.0...v0.15.3) (2019-07-02)

### Bug Fixes

@@ -11,6 +24,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
Node should fetch download from all peers which have better chain,
no matter it's known best's ancestor or not.


# [v0.15.0](https://github.com/nervosnetwork/ckb/compare/v0.14.2...v0.15.0) (2019-06-29)

**Important:** The default secp256k1 has changed. Now its code hash is
@@ -610,7 +610,7 @@ impl<CS: ChainStore + 'static> ChainService<CS> {
}
}
Err(err) => {
error!("block {}", serde_json::to_string(b).unwrap());
error!("block {:?} verify error{:?}", b, err);
found_error =
Some(SharedError::InvalidTransaction(err.to_string()));
*verified = Some(false);
@@ -29,6 +29,9 @@ log_to_stdout = true # {{
dsn = "" # {{
# testnet => dsn = "https://48c6a88d92e246478e2d53b5917a887c@sentry.io/1422795"
# }}
# if you are willing to help us to improve,
# please leave a way to contact you when we have troubles to reproduce the errors.
# org_contact = ""

[miner.client]
rpc_url = "http://127.0.0.1:8114/" # {{
@@ -31,6 +31,9 @@ log_to_stdout = true # {{
dsn = "" # {{
# testnet => dsn = "https://48c6a88d92e246478e2d53b5917a887c@sentry.io/1422795"
# }}
# if you are willing to help us to improve,
# please leave a way to contact you when we have troubles to reproduce the errors.
# org_contact = ""

[network]
listen_addresses = ["/ip4/0.0.0.0/tcp/8115"] # {{
@@ -220,6 +220,7 @@ impl<CS: ChainStore + 'static> Relayer<CS> {
if self
.shared()
.insert_new_block(&self.chain, peer, Arc::clone(&boxed))
.is_ok()
{
debug_target!(
crate::LOG_TARGET_RELAY,
@@ -1,6 +1,6 @@
use crate::synchronizer::Synchronizer;
use crate::{synchronizer::Synchronizer, BAD_MESSAGE_BAN_TIME};
use ckb_core::block::Block;
use ckb_logger::debug;
use ckb_logger::{debug, info};
use ckb_network::{CKBProtocolContext, PeerIndex};
use ckb_protocol::Block as PBlock;
use ckb_store::ChainStore;
@@ -11,6 +11,7 @@ pub struct BlockProcess<'a, CS: ChainStore + 'a> {
message: &'a PBlock<'a>,
synchronizer: &'a Synchronizer<CS>,
peer: PeerIndex,
nc: &'a CKBProtocolContext,
}

impl<'a, CS> BlockProcess<'a, CS>
@@ -21,12 +22,13 @@ where
message: &'a PBlock,
synchronizer: &'a Synchronizer<CS>,
peer: PeerIndex,
_nc: &'a CKBProtocolContext,
nc: &'a CKBProtocolContext,
) -> Self {
BlockProcess {
message,
synchronizer,
peer,
nc,
}
}

@@ -38,9 +40,20 @@ where
block.header().hash()
);

if self.synchronizer.shared().new_block_received(&block) {
self.synchronizer.process_new_block(self.peer, block);
if self.synchronizer.shared().new_block_received(&block)
&& self
.synchronizer
.process_new_block(self.peer, block)
.is_err()
{
info!(
"Ban peer {:?} for {} seconds because send us a invalid block",
self.peer,
BAD_MESSAGE_BAN_TIME.as_secs()
);
self.nc.ban_peer(self.peer, BAD_MESSAGE_BAN_TIME);
}

Ok(())
}
}
@@ -150,16 +150,16 @@ impl<CS: ChainStore> Synchronizer<CS> {
}

//TODO: process block which we don't request
pub fn process_new_block(&self, peer: PeerIndex, block: Block) {
pub fn process_new_block(&self, peer: PeerIndex, block: Block) -> Result<(), FailureError> {
if self.shared().contains_orphan_block(block.header()) {
debug!("block {:x} already in orphan pool", block.header().hash());
return;
return Ok(());
}

match self.shared().get_block_status(&block.header().hash()) {
BlockStatus::VALID_MASK => {
self.shared()
.insert_new_block(&self.chain, peer, Arc::new(block));
.insert_new_block(&self.chain, peer, Arc::new(block))?;
}
status => {
debug!(
@@ -168,6 +168,7 @@ impl<CS: ChainStore> Synchronizer<CS> {
);
}
}
Ok(())
}

pub fn get_blocks_to_fetch(&self, peer: PeerIndex) -> Option<Vec<H256>> {
@@ -297,12 +298,13 @@ impl<CS: ChainStore> Synchronizer<CS> {

fn start_sync_headers(&self, nc: &CKBProtocolContext) {
let now = unix_time_as_millis();
let ibd = self.shared().is_initial_block_download();
let peers: Vec<PeerIndex> = self
.peers()
.state
.read()
.iter()
.filter(|(_, state)| state.can_sync(now))
.filter(|(_, state)| state.can_sync(now, ibd))
.map(|(peer_id, _)| peer_id)
.cloned()
.collect();
@@ -332,9 +334,7 @@ impl<CS: ChainStore> Synchronizer<CS> {

for peer in peers {
// Only sync with 1 peer if we're in IBD
if self.shared.is_initial_block_download()
&& self.shared().n_sync_started().load(Ordering::Acquire) != 0
{
if ibd && self.shared().n_sync_started().load(Ordering::Acquire) != 0 {
break;
}
{
@@ -866,7 +866,8 @@ mod tests {
blocks.into_iter().for_each(|block| {
synchronizer
.shared()
.insert_new_block(&synchronizer.chain, peer, Arc::new(block));
.insert_new_block(&synchronizer.chain, peer, Arc::new(block))
.expect("Insert new block failed");
});
assert_eq!(
chain1_last_block.header(),
@@ -12,7 +12,7 @@ use ckb_core::extras::EpochExt;
use ckb_core::header::{BlockNumber, Header};
use ckb_core::transaction::ProposalShortId;
use ckb_core::Cycle;
use ckb_logger::{debug, debug_target, error};
use ckb_logger::{debug, debug_target};
use ckb_network::{CKBProtocolContext, PeerIndex};
use ckb_protocol::SyncMessage;
use ckb_shared::chain_state::ChainState;
@@ -121,8 +121,10 @@ impl PeerState {
}
}

pub fn can_sync(&self, now: u64) -> bool {
!self.sync_started
pub fn can_sync(&self, now: u64, ibd: bool) -> bool {
// only sync with outbound peer in IBD
(self.is_outbound || !ibd)
&& !self.sync_started
&& self
.chain_sync
.not_sync_until
@@ -1096,7 +1098,7 @@ impl<CS: ChainStore> SyncSharedState<CS> {
chain: &ChainController,
pi: PeerIndex,
block: Arc<Block>,
) -> bool {
) -> Result<(), FailureError> {
let known_parent = |block: &Block| {
self.store()
.get_block_header(block.header().parent_hash())
@@ -1111,13 +1113,13 @@ impl<CS: ChainStore> SyncSharedState<CS> {
block.header().hash()
);
self.insert_orphan_block((*block).clone());
return false;
return Ok(());
}

// Attempt to accept the given block if its parent already exist in database
if let Err(err) = self.accept_block(chain, pi, Arc::clone(&block)) {
error!("accept block {:?} error {:?}", block, err);
return false;
debug!("accept block {:?} error {:?}", block, err);
return Err(err);
}

// The above block has been accepted. Attempt to accept its descendant blocks in orphan pool.
@@ -1146,7 +1148,7 @@ impl<CS: ChainStore> SyncSharedState<CS> {
}
}

true
Ok(())
}

fn accept_block(
@@ -4,7 +4,7 @@ use sentry::{
integrations::panic::register_panic_handler,
internals::{ClientInitGuard, Dsn},
protocol::Event,
ClientOptions,
ClientOptions, Level,
};
use serde_derive::{Deserialize, Serialize};
use std::borrow::Cow;
@@ -13,6 +13,8 @@ use std::sync::Arc;
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct SentryConfig {
pub dsn: String,
pub org_ident: Option<String>,
pub org_contact: Option<String>,
}

impl SentryConfig {
@@ -22,6 +24,12 @@ impl SentryConfig {
configure_scope(|scope| {
scope.set_tag("release.pre", version.is_pre());
scope.set_tag("release.dirty", version.is_dirty());
if let Some(org_ident) = &self.org_ident {
scope.set_tag("org_ident", org_ident);
}
if let Some(org_contact) = &self.org_contact {
scope.set_extra("org_contact", org_contact.clone().into());
}
});

register_panic_handler();
@@ -67,8 +75,10 @@ fn before_send(mut event: Event<'static>) -> Option<Event<'static>> {
// Group events via fingerprint, or ignore

if ex.starts_with("DBError failed to open the database") {
event.level = Level::Warning;
event.fingerprint = Cow::Borrowed(DB_OPEN_FINGERPRINT);
} else if ex.contains("SqliteFailure") {
event.level = Level::Warning;
event.fingerprint = Cow::Borrowed(SQLITE_FINGERPRINT);
} else if ex.starts_with("DBError the database version")
|| ex.contains("kind: AddrInUse")
@@ -182,8 +182,8 @@ impl<'a, P: ChainProvider> RewardCalculator<'a, P> {
cmp::max(index.number().saturating_sub(proposal_window.farthest()), 1);

let previous_ids = store
.get_block_hash(competing_proposal_start)
.map(|hash| self.get_proposal_ids_by_hash(&hash))
.get_ancestor(parent.hash(), competing_proposal_start)
.map(|header| self.get_proposal_ids_by_hash(header.hash()))
.expect("finalize target exist");

proposed.extend(previous_ids);

0 comments on commit a02c675

Please sign in to comment.
You can’t perform that action at this time.