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

bonding: Skip fee calculation for voting power #633

Merged
merged 4 commits into from
Oct 13, 2023
Merged

Conversation

victorges
Copy link
Member

What does this pull request do? Explain your changes. (required)
This fixes a bug observed after deploying the new BondingVotes to production.

It happens when trying to calculate voting power for a delegator whose transcoder hadn't
initialized their cumulativeFeeFactor on the corresponding round.

This causes the voting power calculation to underflow, because we don't initialize the
cumulativeFeeFactor of the endPool like BondingManager does. Even though we
don't really care about fees for voting power, the underflow causes a revert on any
transaction that needs to access the delegator votes at the uninitialized round.

Specific updates (required)

  • Break delegatorCumulativeStakeAndFees logic in 2, to allow calculating only stake or only fees
  • Call the stake-only version from BondingVotes
  • PENDING: a couple tests

How did you test each of these updates (required)
yarn test that it didnt change any existing behavior on BondingManager
New tests on BondingVotes
May do a tenderly fork test before actual deploy

Does this pull request close any open issues?
N/A

Checklist:

  • README and other documentation updated
  • All tests using yarn test pass

@coveralls
Copy link

coveralls commented Oct 13, 2023

Pull Request Test Coverage Report for Build 6513140765

  • 8 of 8 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.07%) to 99.587%

Totals Coverage Status
Change from base Build 6497587953: 0.07%
Covered Lines: 1010
Relevant Lines: 1013

💛 - Coveralls

@victorges victorges marked this pull request as ready for review October 13, 2023 19:37
Copy link
Member

@yondonfu yondonfu left a comment

Choose a reason for hiding this comment

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

A few minor nits, but generally looks good and await the updated unit tests (which should also fix converage).

src/test/BondingVotesFeeLessVotesFix.sol Outdated Show resolved Hide resolved
src/test/BondingVotesFeeLessVotesFix.sol Outdated Show resolved Hide resolved
src/test/BondingVotesFeeLessVotesFix.sol Outdated Show resolved Hide resolved
Copy link
Member

@yondonfu yondonfu left a comment

Choose a reason for hiding this comment

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

Looks like coverage is failing because EarningsPoolLIP36.delegatorCumulativeFees() lacks coverage for initial conditional statements. Those conditionals aren't triggered in tests right now because this function is only ever called by EarningsPoolLIP36.delegatorCumulativeStakeAndFees() which will always initialize _startPool.cumulativeRewardFactor and _endPool.cumulativeRewardFactor if needed before calling delegatorCumulativeFees().

A few options I see to address:

  1. Write tests for EarningsPoolLIP36.delegatorCumulativeFees()
  2. Inline the fee calculation from delegatorCumulativeFees() into delegatorCumulativeStakeAndFees() after the call to delegatorCumulativeStake()

test/integration/BondingVotes.js Outdated Show resolved Hide resolved
@victorges
Copy link
Member Author

@yondonfu added tests to the EarningsPoolLIP36 new funcs! Getting 100% coverage on those now

@victorges victorges merged commit 131a3e0 into delta Oct 13, 2023
3 checks passed
@victorges victorges deleted the vg/fix/feeless-votes branch October 13, 2023 21:36
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.

3 participants