-
Notifications
You must be signed in to change notification settings - Fork 710
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
ACP-77: Update SecondsUntil
to prevent under-charging
#3395
Conversation
if err != nil || totalSeconds >= maxSeconds { | ||
if err != nil { | ||
// This is technically unreachable, but makes the code more | ||
// clearly correct. | ||
return maxSeconds |
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.
As above re 0
instead of maxSeconds
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.
If this value were to overflow, it would mean that maxSeconds
should be retuned. 0
would not be correct to return (if this value weren't well defined, we'd need to return an error rather than an ambiguous 0
)
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.
Similar clarification to above - this function is essentially implementing:
"If you need to pay $x
every second, how long does $y
last? If the answer is more than z
then just say 1 minute
."
If $x
would last longer than MaxUint64
, returning 0
is incorrect. We should return 1 minute
.
Why this should be merged
Undercharging -> DoS
Overcharging -> Happy
Also limits fuzzing to an hour rather than a year. With race detection enabled, running for a full year can take too long.
How this works
SecondsUntil
->SecondsRemaining
The block timestamp must only be able to advance to a point that validators are fully paying for that time.
How this was tested