Skip to content

Use increment not replace when calculating rewards#1703

Merged
ajsutton merged 1 commit into
Consensys:masterfrom
ajsutton:increment-reward
May 1, 2020
Merged

Use increment not replace when calculating rewards#1703
ajsutton merged 1 commit into
Consensys:masterfrom
ajsutton:increment-reward

Conversation

@ajsutton

@ajsutton ajsutton commented May 1, 2020

Copy link
Copy Markdown
Contributor

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.

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
Copy Markdown
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

@cemozerr cemozerr 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.

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

@cemozerr cemozerr 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

@ajsutton

ajsutton commented May 1, 2020

Copy link
Copy Markdown
Contributor Author

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.

2 participants