diff --git a/ethcore/src/error.rs b/ethcore/src/error.rs index dd4cf4986..aae224116 100644 --- a/ethcore/src/error.rs +++ b/ethcore/src/error.rs @@ -86,9 +86,6 @@ pub enum BlockError { TemporarilyInvalid(OutOfBounds), /// Log bloom header field is invalid. InvalidLogBloom(Mismatch), - /// Parent hash field of header is invalid; this is an invalid error indicating a logic flaw in the codebase. - /// TODO: remove and favour an assert!/panic!. - InvalidParentHash(Mismatch), /// Number field of header is invalid. InvalidNumber(Mismatch), /// Block number isn't sensible. @@ -131,7 +128,6 @@ impl fmt::Display for BlockError { InvalidTimestamp(ref oob) => format!("Invalid timestamp in header: {}", oob), TemporarilyInvalid(ref oob) => format!("Future timestamp in header: {}", oob), InvalidLogBloom(ref oob) => format!("Invalid log bloom in header: {}", oob), - InvalidParentHash(ref mis) => format!("Invalid parent hash: {}", mis), InvalidNumber(ref mis) => format!("Invalid number in header: {}", mis), RidiculousNumber(ref oob) => format!("Implausible block number. {}", oob), UnknownParent(ref hash) => format!("Unknown parent: {}", hash), diff --git a/ethcore/src/verification/verification.rs b/ethcore/src/verification/verification.rs index b670851f0..e6289c2b0 100644 --- a/ethcore/src/verification/verification.rs +++ b/ethcore/src/verification/verification.rs @@ -304,11 +304,11 @@ pub fn verify_header_params(header: &Header, engine: &EthEngine, is_full: bool) /// Check header parameters agains parent header. fn verify_parent(header: &Header, parent: &Header, engine: &EthEngine) -> Result<(), Error> { + assert!(header.parent_hash().is_zero() || &parent.hash() == header.parent_hash(), + "Parent hash should already have been verified; qed"); + let gas_limit_divisor = engine.params().gas_limit_bound_divisor; - if !header.parent_hash().is_zero() && &parent.hash() != header.parent_hash() { - return Err(From::from(BlockError::InvalidParentHash(Mismatch { expected: parent.hash(), found: header.parent_hash().clone() }))) - } if !engine.is_timestamp_valid(header.timestamp(), parent.timestamp()) { return Err(From::from(BlockError::InvalidTimestamp(OutOfBounds { max: None, min: Some(parent.timestamp() + 1), found: header.timestamp() }))) }