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

Use increment not replace when calculating rewards #1703

Merged
merged 1 commit into from
May 1, 2020

Conversation

ajsutton
Copy link
Contributor

@ajsutton ajsutton commented May 1, 2020

PR Description

Fixes a consensus failure on the Schlesi testnet block 64. get_attestation_deltas was replacing the value for rewards instead of incrementing it. As a result the total reward allocated was half what it should have been.

@@ -355,9 +354,9 @@ private static UnsignedLong get_base_reward(BeaconState state, int index) {
UnsignedLong increment = EFFECTIVE_BALANCE_INCREMENT;
final UnsignedLong reward_numerator =
index_base_reward.getValue().times(attesting_balance.dividedBy(increment));
rewards.set(index, reward_numerator.dividedBy(total_balance.dividedBy(increment)));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Apparently the spec had this same bug: https://github.com/ethereum/eth2.0-specs/pull/1680/files

Copy link
Contributor

@cemozerr cemozerr left a comment

Choose a reason for hiding this comment

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

I’m confused as to how with this fix we’re still passing v0.11.1 specs

Copy link
Contributor

@cemozerr cemozerr left a comment

Choose a reason for hiding this comment

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

LGTM

@ajsutton
Copy link
Contributor Author

ajsutton commented May 1, 2020

Apparently we don't have a reference test that goes round that loop twice for the same validator.

@ajsutton ajsutton merged commit 1d774b2 into Consensys:master May 1, 2020
@ajsutton ajsutton deleted the increment-reward branch May 1, 2020 05:24
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