Skip to content
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

Merged
merged 5 commits into from
Sep 18, 2024

Conversation

StephenButtolph
Copy link
Contributor

@StephenButtolph StephenButtolph commented Sep 17, 2024

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

  • Updated unit tests

@StephenButtolph StephenButtolph added this to the v1.11.12 milestone Sep 17, 2024
@StephenButtolph StephenButtolph self-assigned this Sep 17, 2024
vms/platformvm/validators/fee/fee.go Outdated Show resolved Hide resolved
vms/platformvm/validators/fee/fee.go Outdated Show resolved Hide resolved
vms/platformvm/validators/fee/fee.go Show resolved Hide resolved
if err != nil || totalSeconds >= maxSeconds {
if err != nil {
// This is technically unreachable, but makes the code more
// clearly correct.
return maxSeconds
Copy link
Contributor

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

Copy link
Contributor Author

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)

Copy link
Contributor Author

@StephenButtolph StephenButtolph Sep 18, 2024

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.

vms/platformvm/validators/fee/fee.go Outdated Show resolved Hide resolved
vms/platformvm/validators/fee/fee_test.go Show resolved Hide resolved
@StephenButtolph StephenButtolph added this pull request to the merge queue Sep 18, 2024
Merged via the queue into master with commit d660979 Sep 18, 2024
20 of 21 checks passed
@StephenButtolph StephenButtolph deleted the implement-acp-77-time-until branch September 18, 2024 19:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants