-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move future block check into validateHeader #204
base: master
Are you sure you want to change the base?
Conversation
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.
I'm still bothered by the fact that this isn't technically a consensus rule. It can't be a consensus rule, because the network does not reach consensus on the current time! The network only reaches consensus on "history" -- the list of parent blocks. (This is also why SufficientlyHeavierThan
is not a consensus rule: it depends on information other than the history.)
Splitting the checks out like this does make the consensus
package slightly harder to use correctly. But I think I'm okay with that. consensus
is a low-level package whose only "real" consumer is coreutils/chain
, so it can have some sharp edges. In theory, someone else could write their own implementation of chain.Manager
with a different ErrFutureBlock
threshold, and it would still be 100% compliant with Sia consensus.
func validateHeader(s State, parentID types.BlockID, timestamp time.Time, nonce uint64, id types.BlockID) error { | ||
if parentID != s.Index.ID { | ||
return errors.New("wrong parent ID") | ||
} else if timestamp.After(s.MaxFutureTimestamp(time.Now())) { |
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 makes the function impure -- calling it at different times gives you different results. The current time should be passed in as an argument instead.
This seems accurate, but with a big caveat. |
No description provided.