Skip to content

avoid div by zero in extreme balance case#1664

Merged
djrtwo merged 2 commits into
v011xfrom
div-zero-total-balance
Mar 19, 2020
Merged

avoid div by zero in extreme balance case#1664
djrtwo merged 2 commits into
v011xfrom
div-zero-total-balance

Conversation

@djrtwo

@djrtwo djrtwo commented Mar 16, 2020

Copy link
Copy Markdown
Contributor

Address #1663

  • get_total_balance returns a minimum of EFFECTIVE_BALANCE_INCREMENT to avoid div by zero in extreme cases
  • add rewards test vector to test for this extreme case (it did in fact div by 0 before the fix was in place)
  • Add another rewards test for empty attestations (because I noticed it was needed... )

@hwwhww hwwhww left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Nice catch @MrChico!

Comment thread tests/core/pyspec/eth2spec/test/context.py Outdated
Comment thread tests/core/pyspec/eth2spec/test/context.py Outdated
Comment thread specs/phase0/beacon-chain.md
@djrtwo

djrtwo commented Mar 18, 2020

Copy link
Copy Markdown
Contributor Author

Thanks @hwwhww!
Made the suggested changes. Merging after tests run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants