Skip to content
This repository was archived by the owner on Nov 6, 2020. It is now read-only.

Commit b463487

Browse files
dvdplms3krit
authored andcommitted
Forward-port #11356 (#11358)
* Forward-port #11356
1 parent ba1b879 commit b463487

File tree

3 files changed

+32
-2
lines changed

3 files changed

+32
-2
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## Parity-Ethereum [v2.6.8](https://github.com/paritytech/parity-ethereum/releases/tag/v2.6.8)
2+
3+
Parity Ethereum v2.6.8-beta is a security release. Valid blocks with manipulated transactions (added/replaced) cause the client to stall.
4+
5+
The full list of included changes:
6+
* Make sure to not mark block header hash as invalid if only the body is wrong (#11356)
7+
18
## Parity-Ethereum [v2.6.7](https://github.com/paritytech/parity-ethereum/releases/tag/v2.6.7)
29

310
Parity Ethereum v2.6.7-beta is a patch release that adds Istanbul hardfork

ethcore/src/verification/queue/kind.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,12 @@ pub use self::headers::Headers;
2727

2828
/// Something which can produce a hash and a parent hash.
2929
pub trait BlockLike {
30-
/// Get the hash of this item.
30+
/// Get the hash of this item - i.e. the header hash.
3131
fn hash(&self) -> H256;
3232

33+
/// Get a raw hash of this item - i.e. the hash of the RLP representation.
34+
fn raw_hash(&self) -> H256;
35+
3336
/// Get the hash of this item's parent.
3437
fn parent_hash(&self) -> H256;
3538

@@ -151,6 +154,10 @@ pub mod blocks {
151154
self.header.hash()
152155
}
153156

157+
fn raw_hash(&self) -> H256 {
158+
keccak_hash::keccak(&self.bytes)
159+
}
160+
154161
fn parent_hash(&self) -> H256 {
155162
self.header.parent_hash().clone()
156163
}
@@ -165,6 +172,10 @@ pub mod blocks {
165172
self.header.hash()
166173
}
167174

175+
fn raw_hash(&self) -> H256 {
176+
keccak_hash::keccak(&self.bytes)
177+
}
178+
168179
fn parent_hash(&self) -> H256 {
169180
self.header.parent_hash().clone()
170181
}
@@ -188,6 +199,7 @@ pub mod headers {
188199

189200
impl BlockLike for Header {
190201
fn hash(&self) -> H256 { self.hash() }
202+
fn raw_hash(&self) -> H256 { self.hash() }
191203
fn parent_hash(&self) -> H256 { self.parent_hash().clone() }
192204
fn difficulty(&self) -> U256 { self.difficulty().clone() }
193205
}

ethcore/src/verification/queue/mod.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,13 +467,14 @@ impl<K: Kind> VerificationQueue<K> {
467467
/// Add a block to the queue.
468468
pub fn import(&self, input: K::Input) -> Result<H256, (K::Input, Error)> {
469469
let hash = input.hash();
470+
let raw_hash = input.raw_hash();
470471
{
471472
if self.processing.read().contains_key(&hash) {
472473
return Err((input, Error::Import(ImportError::AlreadyQueued).into()));
473474
}
474475

475476
let mut bad = self.verification.bad.lock();
476-
if bad.contains(&hash) {
477+
if bad.contains(&hash) || bad.contains(&raw_hash) {
477478
return Err((input, Error::Import(ImportError::KnownBad).into()));
478479
}
479480

@@ -500,6 +501,16 @@ impl<K: Kind> VerificationQueue<K> {
500501
match err {
501502
// Don't mark future blocks as bad.
502503
Error::Block(BlockError::TemporarilyInvalid(_)) => {},
504+
// If the transaction root or uncles hash is invalid, it doesn't necessarily mean
505+
// that the header is invalid. We might have just received a malformed block body,
506+
// so we shouldn't put the header hash to `bad`.
507+
//
508+
// We still put the entire `Item` hash to bad, so that we can early reject
509+
// the items that are malformed.
510+
Error::Block(BlockError::InvalidTransactionsRoot(_)) |
511+
Error::Block(BlockError::InvalidUnclesHash(_)) => {
512+
self.verification.bad.lock().insert(raw_hash);
513+
},
503514
_ => {
504515
self.verification.bad.lock().insert(hash);
505516
}

0 commit comments

Comments
 (0)