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

Add EpochRewards smart contract to calculate epoch rewards and payments #1558

Merged
merged 172 commits into from
Nov 12, 2019

Conversation

asaj
Copy link
Contributor

@asaj asaj commented Oct 31, 2019

Description

This PR adds EpochRewards.sol, a smart contract for calculating the actual epoch reward to voters and payments to validators.

Tested

Unit and end-to-end tests.

Other changes

None

Related issues

  • Fixes #TODO

Backwards compatibility

Not backwards compatible

@asaj asaj self-assigned this Nov 8, 2019
Copy link
Contributor

@m-chrzan m-chrzan left a comment

Choose a reason for hiding this comment

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

Reviewed up to EpochRewards.sol.

Would be great to get a clear explanation of how this works in the docs, though probably out of scope of this PR if we want to get it in soon.

@@ -119,6 +125,23 @@ describe('governance tests', () => {
return blockNumber % epochSize === 0
}

const assertAlmostEqual = (
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe move this to utils.ts?

packages/celotool/src/e2e-tests/governance_tests.ts Outdated Show resolved Hide resolved
packages/contractkit/src/contract-cache.ts Show resolved Hide resolved
packages/protocol/contracts/governance/EpochRewards.sol Outdated Show resolved Hide resolved
packages/protocol/contracts/governance/EpochRewards.sol Outdated Show resolved Hide resolved
packages/protocol/contracts/governance/EpochRewards.sol Outdated Show resolved Hide resolved
packages/protocol/migrations/20_elect_validators.ts Outdated Show resolved Hide resolved
const rewardsMultiplier = {
max: toFixed(new BigNumber(2)),
adjustments: {
underspend: toFixed(new BigNumber(1 / 2)),
Copy link
Contributor

Choose a reason for hiding this comment

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

Will we always want underspend < 1 and overspend > 1? If so, should these conditions be required in the contract?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, after thinking about this more, I think this doesn't strictly need to be true, wdyt @rcroessmann?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should enforce both. Especially the condition overspend > 1 seems necessary as the protocol could end up trying to spend more than the remaining cGLD for overspend <= 1.

packages/protocol/test/governance/epochrewards.ts Outdated Show resolved Hide resolved
packages/protocol/test/governance/epochrewards.ts Outdated Show resolved Hide resolved
packages/protocol/test/governance/epochrewards.ts Outdated Show resolved Hide resolved
packages/protocol/test/governance/epochrewards.ts Outdated Show resolved Hide resolved
packages/protocol/test/governance/epochrewards.ts Outdated Show resolved Hide resolved
@m-chrzan m-chrzan removed their assignment Nov 11, 2019
Copy link
Contributor

@m-chrzan m-chrzan left a comment

Choose a reason for hiding this comment

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

LGTM pending outstanding comments.

@asaj asaj added the automerge Have PR merge automatically when checks pass label Nov 12, 2019
@celo-ci-bot-user celo-ci-bot-user merged commit 0452093 into master Nov 12, 2019
aaronmgdr added a commit that referenced this pull request Nov 14, 2019
* master: (56 commits)
  Adjust e2e transfer and governance tests to match new fee distribution and eliminate ProposerFraction (#1585)
  [Wallet] Add more local currencies (#1698)
  Switch to correct cluster when fauceting (#1687)
  [Wallet] Use the country of the phone number for determining the default local currency (#1684)
  [Wallet] Limit QR code scanner to 1 code per second (#1676)
  Update Dark backgrounds text color (#1677)
  Remove integration sync test
  Minor attestation service fixes (#1680)
  [wallet] Fixed Native phone picker Use native API instead (#1669)
  Fix token addresses for notification service (#1674)
  Add golang to setup docs
  [wallet] Hide invite education copy after invite was redeemed (#1670)
  [Wallet] Add spinner, timer, and tip text to Verification input screen (#1656)
  [Wallet] Fix app deprecation check mechanism (#1358)
  Point end-to-end governance test back to master (#1665)
  Add EpochRewards smart contract to calculate epoch rewards and payments (#1558)
  Optimized Attestation view calls and removal of the reveal TX (#1578)
  Support claim signatures and support Keybase claims (#1575)
  [Wallet] Add timestamp to top banner messages (#1657)
  Export geth metrics on VM testnet (#1351)
  ...

# Conflicts:
#	yarn.lock
@mcortesi mcortesi deleted the asaj/pos-4 branch December 4, 2019 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Have PR merge automatically when checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants