From fefdc43534512e2d36c8cb1654deb403fa57da99 Mon Sep 17 00:00:00 2001 From: Andre Silva Date: Thu, 7 Dec 2017 17:18:42 +0100 Subject: [PATCH 1/2] reduce max block timestamp drift to 15 seconds --- ethcore/src/verification/verification.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ethcore/src/verification/verification.rs b/ethcore/src/verification/verification.rs index 2978774b0a0..a2d79acc2cc 100644 --- a/ethcore/src/verification/verification.rs +++ b/ethcore/src/verification/verification.rs @@ -273,7 +273,7 @@ pub fn verify_header_params(header: &Header, engine: &EthEngine, is_full: bool) } if is_full { - let max_time = get_time().sec as u64 + 30; + let max_time = get_time().sec as u64 + 15; if header.timestamp() > max_time { return Err(From::from(BlockError::InvalidTimestamp(OutOfBounds { max: Some(max_time), min: None, found: header.timestamp() }))) } From ce5741a314b03cc724e9f3de3581827768dbbd96 Mon Sep 17 00:00:00 2001 From: Andre Silva Date: Thu, 7 Dec 2017 17:44:21 +0100 Subject: [PATCH 2/2] add test for block timestamp validation within allowed drift --- ethcore/src/verification/verification.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ethcore/src/verification/verification.rs b/ethcore/src/verification/verification.rs index a2d79acc2cc..a418236ed1b 100644 --- a/ethcore/src/verification/verification.rs +++ b/ethcore/src/verification/verification.rs @@ -646,9 +646,15 @@ mod tests { check_fail_timestamp(basic_test(&create_test_block_with_data(&header, &good_transactions, &good_uncles), engine)); header = good.clone(); - header.set_timestamp(get_time().sec as u64 + 40); + header.set_timestamp(get_time().sec as u64 + 20); check_fail_timestamp(basic_test(&create_test_block_with_data(&header, &good_transactions, &good_uncles), engine)); + header = good.clone(); + header.set_timestamp(get_time().sec as u64 + 10); + header.set_uncles_hash(good_uncles_hash.clone()); + header.set_transactions_root(good_transactions_root.clone()); + check_ok(basic_test(&create_test_block_with_data(&header, &good_transactions, &good_uncles), engine)); + header = good.clone(); header.set_number(9); check_fail(family_test(&create_test_block_with_data(&header, &good_transactions, &good_uncles), engine, &bc),