-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Invalidate blocks from future #3652
Invalidate blocks from future #3652
Conversation
InvalidTimestamp(OutOfBounds { max: Some(get_time().sec as u64 + 30), min: None, found: header.timestamp() })); | ||
|
||
header = good.clone(); | ||
header.set_timestamp(get_time().sec as u64 + 31); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will make the test fail spuriously if the blocks check happens to hit the next second interval. Please set to something like + 40
instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe 32 is enough?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
32 should be enough unless the test takes longer than a second to execute for some reason. I'd put 40 just to be safe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hm, ok. I considered 2 seconds for such test as a failure already
@@ -516,6 +522,16 @@ mod tests { | |||
InvalidTimestamp(OutOfBounds { max: None, min: Some(parent.timestamp() + 1), found: header.timestamp() })); | |||
|
|||
header = good.clone(); | |||
header.set_timestamp(2450000000); | |||
check_fail(basic_test(&create_test_block_with_data(&header, &good_transactions, &good_uncles), engine), | |||
InvalidTimestamp(OutOfBounds { max: Some(get_time().sec as u64 + 30), min: None, found: header.timestamp() })); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will make the test fail spuriously if the blocks check happens to hit the next second interval. Test should just check if this is an InvalidTimestamp
error.
header = good.clone(); | ||
header.set_timestamp(get_time().sec as u64 + 31); | ||
check_fail(basic_test(&create_test_block_with_data(&header, &good_transactions, &good_uncles), engine), | ||
InvalidTimestamp(OutOfBounds { max: Some(get_time().sec as u64 + 30), min: None, found: header.timestamp() })); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above
@arkpar fixed |
@jesuscript / @General-Beck the gitlab CI isn't firing? |
I think it's because Gitlab only builds branches in the main repo (not PRs) |
Decline blocks which have a timestamp from future (more than 30 seconds from current time). Otherwise malicious miner can use block with invalid timestamp to attack the network.