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

avoid div by zero in extreme balance case #1664

Merged
merged 2 commits into from Mar 19, 2020
Merged

Conversation

djrtwo
Copy link
Contributor

@djrtwo djrtwo commented Mar 16, 2020

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... )

@djrtwo djrtwo requested a review from protolambda Mar 16, 2020
@djrtwo djrtwo changed the base branch from dev to v011x Mar 16, 2020
@djrtwo djrtwo requested a review from hwwhww Mar 17, 2020
hwwhww
hwwhww approved these changes Mar 18, 2020
Copy link
Contributor

@hwwhww hwwhww left a comment

LGTM

Nice catch @MrChico!

tests/core/pyspec/eth2spec/test/context.py Outdated Show resolved Hide resolved
tests/core/pyspec/eth2spec/test/context.py Outdated Show resolved Hide resolved
specs/phase0/beacon-chain.md Show resolved Hide resolved
@djrtwo
Copy link
Contributor Author

djrtwo commented Mar 18, 2020

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

@djrtwo djrtwo merged commit 2b8c32a into v011x Mar 19, 2020
10 checks passed
@djrtwo djrtwo deleted the div-zero-total-balance branch Mar 19, 2020
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.

None yet

2 participants