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

Prevent balance underflow #727

hwwhww opened this issue Mar 7, 2019 · 2 comments


Copy link

commented Mar 7, 2019


  • There are several places that we deduct the state.validator_balances[validator_index] for penalties.
  • Logically, the validator would be ejected before the balance field is under the risk of underflow.
  • But, when we read the function separately, do we need to add some protection to prevent balance underflow? For example, change
state.validator_balances[index] -= penalty


state.validator_balances[index] = max(state.validator_balances[index] - penalty, 0)

This comment has been minimized.

Copy link

commented Mar 7, 2019

One way to fix this generally would be to define decrement_balance that way in #728.


This comment has been minimized.

Copy link

commented Mar 28, 2019

decrement_balance implemented 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
3 participants
You can’t perform that action at this time.