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

Commit

Permalink
Reduce max block timestamp drift to 15 seconds (#7240)
Browse files Browse the repository at this point in the history
* reduce max block timestamp drift to 15 seconds

* add test for block timestamp validation within allowed drift
  • Loading branch information
andresilva authored and arkpar committed Dec 8, 2017
1 parent 77ee23b commit fcddc77
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions ethcore/src/verification/verification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() })))
}
Expand Down Expand Up @@ -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),
Expand Down

0 comments on commit fcddc77

Please sign in to comment.