This repository has been archived by the owner on Nov 6, 2020. It is now read-only.
Decouple timestamp open-block-assignment/verification to Engine #8305
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #7694
The bug happens because when Parity constructs a new open block, the timestamp will be set at least one second ahead of parent timestamp. For most of the time, this works fine, and most Engine rules also require this. However, because dev chain seals a block for every transaction, it becomes a problem if one tries to send more than one transaction per second.
This PR adds two new predefined functions in Engine trait,
open_block_header_timestamp
andis_timestamp_valid
. All other engines are unchanged exceptInstantSeal
, whereopen_block_header_timestamp
would not do "plus one", andis_timestamp_valid
would accept it if parent timestamp equals to current one. Those replaces hard coded rules inverification
mod andHeader::set_timestamp_now
.This also makes the function
set_timestamp_now
unused. And I read a comment saying this function "kind of sucks"... So I removed it.