Skip to content

Commit a09b906

Browse files
committed
Merge branch 'master' into v0.4.4
2 parents a98cc2b + 97034fb commit a09b906

File tree

11 files changed

+92074
-75174
lines changed

11 files changed

+92074
-75174
lines changed

Cargo.lock

+9-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

chain/chain/src/chain.rs

+10-3
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ impl Chain {
688688
String::new()
689689
},
690690
);
691-
Err(ErrorKind::Orphan.into())
691+
Err(e)
692692
}
693693
ErrorKind::ChunksMissing(missing_chunks) => {
694694
let block_hash = block.hash();
@@ -702,10 +702,11 @@ impl Chain {
702702
"Process block: missing chunks. Block hash: {:?}. Missing chunks: {:?}",
703703
block_hash, missing_chunks,
704704
);
705-
Err(ErrorKind::ChunksMissing(missing_chunks).into())
705+
Err(e)
706706
}
707707
ErrorKind::EpochOutOfBounds => {
708708
// Possibly block arrived before we finished processing all of the blocks for epoch before last.
709+
// Or someone is attacking with invalid chain.
709710
debug!(target: "chain", "Received block {}/{} ignored, as epoch is unknown", block.header.inner.height, block.hash());
710711
Ok(Some(prev_head))
711712
}
@@ -719,7 +720,7 @@ impl Chain {
719720
);
720721
Err(ErrorKind::Unfit(msg.clone()).into())
721722
}
722-
e => Err(e.into()),
723+
_ => Err(e),
723724
},
724725
}
725726
}
@@ -1539,6 +1540,12 @@ impl Chain {
15391540
pub fn is_orphan(&self, hash: &CryptoHash) -> bool {
15401541
self.orphans.contains(hash)
15411542
}
1543+
1544+
/// Check if hash is for a known chunk orphan.
1545+
#[inline]
1546+
pub fn is_chunk_orphan(&self, hash: &CryptoHash) -> bool {
1547+
self.blocks_with_missing_chunks.contains(hash)
1548+
}
15421549
}
15431550

15441551
/// Chain update helper, contains information that is needed to process block

chain/client/src/client_actor.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ fn wait_until_genesis(genesis_time: &DateTime<Utc>) {
7171
let chrono_seconds = genesis_time.signed_duration_since(now).num_seconds();
7272
//check if number of seconds in chrono::Duration larger than zero
7373
if chrono_seconds > 0 {
74-
info!(target: "chain", "Waiting until genesis: {}", chrono_seconds);
74+
info!(target: "near", "Waiting until genesis: {}", chrono_seconds);
7575
let seconds = Duration::from_secs(chrono_seconds as u64);
7676
thread::sleep(seconds);
7777
}
@@ -727,18 +727,20 @@ impl ClientActor {
727727

728728
fn receive_header(&mut self, header: BlockHeader, peer_info: PeerId) -> NetworkClientResponses {
729729
let hash = header.hash();
730-
debug!(target: "client", "Received block header {} at {} from {}", hash, header.inner.height, peer_info);
730+
debug!(target: "client", "{:?} Received block header {} at {} from {}", self.client.block_producer.as_ref().map(|bp| bp.account_id.clone()), hash, header.inner.height, peer_info);
731731

732732
// Process block by chain, if it's valid header ask for the block.
733733
let result = self.client.process_block_header(&header);
734734

735735
match result {
736736
Err(ref e) if e.kind() == near_chain::ErrorKind::EpochOutOfBounds => {
737737
// Block header is either invalid or arrived too early. We ignore it.
738+
debug!(target: "client", "Epoch out of bound for header {}", e);
738739
return NetworkClientResponses::NoResponse;
739740
}
740741
Err(ref e) if e.is_bad_data() => {
741-
return NetworkClientResponses::Ban { ban_reason: ReasonForBan::BadBlockHeader }
742+
debug!(target: "client", "Error on receival of header: {}", e);
743+
return NetworkClientResponses::Ban { ban_reason: ReasonForBan::BadBlockHeader };
742744
}
743745
// Some error that worth surfacing.
744746
Err(ref e) if e.is_error() => {

chain/client/src/sync.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,9 @@ impl BlockSync {
327327

328328
let hashes_to_request = hashes
329329
.iter()
330-
.filter(|x| !chain.get_block(x).is_ok() && !chain.is_orphan(x))
330+
.filter(|x| {
331+
!chain.get_block(x).is_ok() && !chain.is_orphan(x) && !chain.is_chunk_orphan(x)
332+
})
331333
.take(block_count)
332334
.collect::<Vec<_>>();
333335
if hashes_to_request.len() > 0 {
@@ -482,6 +484,7 @@ impl StateSync {
482484
}
483485
}
484486
} else {
487+
self.last_time_block_requested = None;
485488
(false, true)
486489
};
487490
if request_block {

chain/client/src/types.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ impl ClientConfig {
167167
block_fetch_horizon: 50,
168168
state_fetch_horizon: 5,
169169
catchup_step_period: Duration::from_millis(block_prod_time / 2),
170-
chunk_request_retry_period: Duration::from_millis(100),
170+
chunk_request_retry_period: Duration::from_millis(block_prod_time / 5),
171171
block_header_fetch_horizon: 50,
172172
tracked_accounts: vec![],
173173
tracked_shards: vec![],

chain/network/src/peer.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const MAX_TRACK_SIZE: usize = 30;
3636

3737
/// Maximum number of messages per minute from single peer.
3838
// TODO: current limit is way to high due to us sending lots of messages during sync.
39-
const MAX_PEER_MSG_PER_MIN: u64 = 50000;
39+
const MAX_PEER_MSG_PER_MIN: u64 = std::u64::MAX;
4040

4141
/// Keeps track of requests and received hashes of transactions and blocks.
4242
/// Also keeps track of number of bytes sent and received from this peer to prevent abuse.

near/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "near"
3-
version = "0.4.1"
3+
version = "0.4.4"
44
authors = ["Near Inc <hello@nearprotocol.com>"]
55
edition = "2018"
66

0 commit comments

Comments
 (0)