Skip to content
This repository has been archived by the owner on Jun 6, 2023. It is now read-only.

Clean up vesting reward use in miner tests #1251

Merged
merged 2 commits into from
Oct 14, 2020
Merged

Conversation

anorth
Copy link
Member

@anorth anorth commented Oct 14, 2020

Miner tests almost all apply some rewards to a miner actor from which penalties will be paid, both because this is the usual, expected case and also makes the delta easy to explicitly test. However, they didn't previously support part of the penalty coming from unlocked balance (after the vesting funds are exhausted).

This PR:

  • Introduces a bigRewards number to use as a constant value for rewards that are used only as a target for penalties, replacing a bunch of ad-hoc constants
  • Adds penaltyFromUnlocked to the cron config, supporting some or all penalty being paid from unlocked funds

This is intended as a prefactor to #1249. Once rebased upon this PR, most of the delta to miner tests can disappear. Only that part related to the changed vesting schedule remains.

This PR changes tests only.

@codecov-io
Copy link

Codecov Report

Merging #1251 into master will not change coverage.
The diff coverage is n/a.

@@          Coverage Diff           @@
##           master   #1251   +/-   ##
======================================
  Coverage    70.3%   70.3%           
======================================
  Files          72      72           
  Lines        7169    7169           
======================================
  Hits         5046    5046           
  Misses       1306    1306           
  Partials      817     817           

@@ -1307,7 +1308,7 @@ func TestCCUpgrade(t *testing.T) {
oldPower := miner.QAPowerForSector(actor.sectorSize, oldSector)
expectedFee := miner.PledgePenaltyForContinuedFault(actor.epochRewardSmooth, actor.epochQAPowerSmooth, oldPower)
expectedPowerDelta := miner.NewPowerPairZero()
actor.applyRewards(rt, expectedFee, big.Zero())
actor.applyRewards(rt, bigRewards, big.Zero())
Copy link
Contributor

Choose a reason for hiding this comment

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

Non-blocking -- I think the use of applyRewards to set up test state for penalization is wrong. This PR solves the problem at hand but the brittleness from relying on the production reward function won't go away.

repaidFeeDebt abi.TokenAmount
continuedFaultsPenalty abi.TokenAmount // Expected amount burnt to pay continued fault penalties.
repaidFeeDebt abi.TokenAmount // Expected amount burnt to repay fee debt.
penaltyFromUnlocked abi.TokenAmount // Expected reduction in unlocked balance from penalties exceeding vesting funds.
Copy link
Contributor

Choose a reason for hiding this comment

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

❤️

Copy link
Contributor

@acruikshank acruikshank left a comment

Choose a reason for hiding this comment

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

Definitely an improvement.

@ZenGround0 ZenGround0 merged commit 004c444 into master Oct 14, 2020
@anorth anorth deleted the anorth/prefactor branch January 11, 2022 04:43
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants