Remove InvalidParentHash in favor of assert! (#8300)
* Remove InvalidParentHash in favor of assert! * Typo: assert test true case
This commit is contained in:
parent
9d3771458d
commit
e4168c2985
@ -86,9 +86,6 @@ pub enum BlockError {
|
|||||||
TemporarilyInvalid(OutOfBounds<u64>),
|
TemporarilyInvalid(OutOfBounds<u64>),
|
||||||
/// Log bloom header field is invalid.
|
/// Log bloom header field is invalid.
|
||||||
InvalidLogBloom(Mismatch<Bloom>),
|
InvalidLogBloom(Mismatch<Bloom>),
|
||||||
/// 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<H256>),
|
|
||||||
/// Number field of header is invalid.
|
/// Number field of header is invalid.
|
||||||
InvalidNumber(Mismatch<BlockNumber>),
|
InvalidNumber(Mismatch<BlockNumber>),
|
||||||
/// Block number isn't sensible.
|
/// Block number isn't sensible.
|
||||||
@ -131,7 +128,6 @@ impl fmt::Display for BlockError {
|
|||||||
InvalidTimestamp(ref oob) => format!("Invalid timestamp in header: {}", oob),
|
InvalidTimestamp(ref oob) => format!("Invalid timestamp in header: {}", oob),
|
||||||
TemporarilyInvalid(ref oob) => format!("Future timestamp in header: {}", oob),
|
TemporarilyInvalid(ref oob) => format!("Future timestamp in header: {}", oob),
|
||||||
InvalidLogBloom(ref oob) => format!("Invalid log bloom 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),
|
InvalidNumber(ref mis) => format!("Invalid number in header: {}", mis),
|
||||||
RidiculousNumber(ref oob) => format!("Implausible block number. {}", oob),
|
RidiculousNumber(ref oob) => format!("Implausible block number. {}", oob),
|
||||||
UnknownParent(ref hash) => format!("Unknown parent: {}", hash),
|
UnknownParent(ref hash) => format!("Unknown parent: {}", hash),
|
||||||
|
@ -304,11 +304,11 @@ pub fn verify_header_params(header: &Header, engine: &EthEngine, is_full: bool)
|
|||||||
|
|
||||||
/// Check header parameters agains parent header.
|
/// Check header parameters agains parent header.
|
||||||
fn verify_parent(header: &Header, parent: &Header, engine: &EthEngine) -> Result<(), Error> {
|
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;
|
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()) {
|
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() })))
|
return Err(From::from(BlockError::InvalidTimestamp(OutOfBounds { max: None, min: Some(parent.timestamp() + 1), found: header.timestamp() })))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user