From 2025fe9cb0a6124b4ae75a610de7a6a57fbf59a5 Mon Sep 17 00:00:00 2001 From: Juhyung Park Date: Fri, 21 Jun 2019 17:04:02 +0900 Subject: [PATCH 1/2] Make the validator to refuse the block that has the same timestamp with the parent --- core/src/verification/verification.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/verification/verification.rs b/core/src/verification/verification.rs index 5ed1fb2a38..c98d831846 100644 --- a/core/src/verification/verification.rs +++ b/core/src/verification/verification.rs @@ -230,10 +230,10 @@ fn verify_parent(header: &Header, parent: &Header) -> Result<(), Error> { found: *header.parent_hash(), }))) } - if header.timestamp() < parent.timestamp() { + if header.timestamp() <= parent.timestamp() { return Err(From::from(BlockError::InvalidTimestamp(OutOfBounds { max: None, - min: Some(parent.timestamp()), + min: Some(parent.timestamp() + 1), found: header.timestamp(), }))) } From 63aeb1b7abe0c8a0ef5508cf1398dea61113d1f7 Mon Sep 17 00:00:00 2001 From: Juhyung Park Date: Fri, 21 Jun 2019 17:04:08 +0900 Subject: [PATCH 2/2] Do not use the same timestamp with the parent block --- types/src/header.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/src/header.rs b/types/src/header.rs index d58aaccf7e..8fb730f4bf 100644 --- a/types/src/header.rs +++ b/types/src/header.rs @@ -271,7 +271,7 @@ impl Header { header.set_parent_hash(self.hash()); header.set_number(self.number() + 1); - header.set_timestamp_now(self.timestamp()); + header.set_timestamp_now(self.timestamp() + 1); header.note_dirty(); header