-
Notifications
You must be signed in to change notification settings - Fork 102
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1009 +/- ##
========================================
- Coverage 74.0% 73.8% -0.2%
========================================
Files 57 57
Lines 6549 6589 +40
========================================
+ Hits 4848 4865 +17
- Misses 1091 1105 +14
- Partials 610 619 +9 |
cc50a71
to
7ebee1a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to revert most of the AdvanceDeadline
refactor. There may be small pure manipulations that could be pushed down, but it shouldn't take parameters like the reward estimate or return values like penalty amounts.
Most of the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After investigating and writing up most of these comments I think I get what's going on, and it's probably right. But I left them all there because it's confusing and I think worth changing so as not to be.
actors/builtin/miner/miner_state.go
Outdated
type AdvanceDeadlineResult struct { | ||
PledgeDelta abi.TokenAmount | ||
PowerDelta PowerPair | ||
UndeclaredFaultyPower, DeclaredFaultyPower PowerPair |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It took me quite a while to figure out how (I think) these are being used. I think:
- UndeclaredFaultyPower is the faults triggered by missing posts
- DeclaredFaultyPower was not just declared here, but is the ongoing faulty power to be penalised
I.e. one is an "edge" and one is a "gauge", just reading a value from state. "Declared" is misleading here, since nothing is being declared and also it includes power from faults that were both previously, and in this call, undeclared.
Maybe names could help, but it definitely needs explanation. Maybe
DetectedFaultyPower
sum of power of sectors from partitions which were not proven this deadlineOngoingFaultyPower
sum of power of sectors that are (or were) faulty
Does the latter include the former? Maybe PreviouslyFaultyPower
or AlreadyFaultyPower
then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently, "undeclared" is the amount of faulty power we discovered while processing the deadline. "declared" is the amount of faulty power we expected from declarations (and from previous discoveries). I'm using them to match up with the penalty function names.
I swapped out ongoing because it's a bit confusing to me. Before, ongoing actually included newly detected faulty power.
I'm going to change these to "detected" and "total". I think that'll resolve any confusion.
actors/builtin/miner/miner_state.go
Outdated
if err != nil { | ||
return nil, xerrors.Errorf("failed to process end of deadline %d: %w", dlInfo.Index, err) | ||
} | ||
declaredFaultyPower = deadline.FaultyPower.Sub(undeclaredFaultyPower) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand this, or at least it's appearance here. No "declared faults" can happen while processing missed PoSts. In combination with my confusion above, this line would make a bit more sense at the bottom of this method. But if it's just trying to count the faulty power before the new faults were added .... just read deadline.FaultyPower
before processing the new faults?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would have counted failed recoveries as "declared" faulty power. But yeah, this is confusing. I've switched this over to just returning the total faulty power.
actors/builtin/miner/miner_test.go
Outdated
@@ -1207,7 +1207,7 @@ func TestWindowPost(t *testing.T) { | |||
actor.submitWindowPoSt(rt, dlinfo, partitions, infos, cfg) | |||
|
|||
// expect declared fee to be charged during cron | |||
dlinfo = advanceDeadline(rt, actor, &cronConfig{ongoingFaultsPenalty: declaredFee}) | |||
dlinfo = advanceDeadline(rt, actor, &cronConfig{declaredFaultsPenalty: declaredFee}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see some of my earlier confusion now. Here, the original is better IMO. Nothing is being declared, and some of the power may have been an undeclared fault.
actors/builtin/miner/miner_test.go
Outdated
ongoingPwr := miner.PowerForSectors(actor.sectorSize, allSectors) | ||
ongoingPenalty := miner.PledgePenaltyForDeclaredFault(actor.epochRewardSmooth, actor.epochQAPowerSmooth, ongoingPwr.QA) | ||
declaredPwr := miner.PowerForSectors(actor.sectorSize, allSectors[:1]) | ||
declaredPenalty := miner.PledgePenaltyForDeclaredFault(actor.epochRewardSmooth, actor.epochQAPowerSmooth, declaredPwr.QA) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto, this rename confuses me.
011a9f3
to
eb8dfa4
Compare
I've reverted the fee names in the tests but they're still confusing. The "ongoing" power is actually "ongoing minus failed recoveries", that's why I've been avoiding it. |
st.ProvingPeriodStart = st.ProvingPeriodStart + WPoStProvingPeriod | ||
penaltyTarget := big.Add(declaredPenalty, undeclaredPenalty) | ||
if !penaltyTarget.IsZero() { | ||
unlockedBalance := st.GetUnlockedBalance(rt.CurrentBalance()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this was already wrong, but I this calculation is incorrect. Earlier on in this method, the pre-commit deposit amount was reduced and the associated amount to be burnt remembered in penaltyTotal
. rt.CurrentBalance()
still includes that amount that is to be burnt, and so this will calculate a greater unlocked balance than it should, if it's to be used as a bound on how much more is available to burn now. I think this could result in an attempt to burn more funds than the actor has (rather than accumulating fee debt in PenalizeFundsInPriorityOrder
).
Since this was already wrong and @ZenGround0 is working on related changes in #1004 (in part to reduce the ease of errors like this) I'm ok with us landing this still broken, to be repaired in 1004.
A test case to show this needs to incur a penalty in the same epoch as expiring an overdue pre-commit (for a follow-up PR).
* Moves most logic into helper functions. * Avoids loading deadlines, vesting table, etc. unnecessarily. * Loads the vesting table at most twice.
eb8dfa4
to
80c3e0d
Compare
fixes #983