Skip to content

Commit 54ec502

Browse files
authored
fix(shed): account for new sectors that haven't been proven yet (#13042)
original code assumed a static state, but that's just not how mainnet works; we need to account for constantly onboarding sectors and ensure we're not counting fees for sectors that we don't expect to have been paid yet because they won't have been proven
1 parent a565780 commit 54ec502

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

cmd/lotus-shed/miner-fees.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,16 @@ var minerFeesCmd = &cli.Command{
9898
_, _ = fmt.Fprintf(cctx.App.Writer, "Deadline %d:\n", dlIdx)
9999

100100
totalSectorsFee := big.NewInt(0)
101+
totalProvenSectorsFee := big.NewInt(0)
101102
totalFeeDeduction := big.NewInt(0)
102103

104+
// Epoch at which sectors that are within this deadline would have last been proven, so we
105+
// can look for new sectors that have (probably) not been proven yet
106+
dlLastProvenEpoch := dlinfo.PeriodStart + abi.ChainEpoch(dlIdx+1)*dlinfo.WPoStChallengeWindow
107+
if dlLastProvenEpoch > dlinfo.CurrentEpoch {
108+
dlLastProvenEpoch -= dlinfo.WPoStProvingPeriod
109+
}
110+
103111
/** Iterate over partitions **/
104112

105113
partitions, err := dl.PartitionsArray(adtStore)
@@ -135,6 +143,9 @@ var minerFeesCmd = &cli.Command{
135143
_, _ = fmt.Fprintf(cctx.App.Writer, "%s\n", soci16.DailyFee)
136144
}
137145
totalSectorsFee = big.Add(totalSectorsFee, soci16.DailyFee)
146+
if soci16.Activation < dlLastProvenEpoch {
147+
totalProvenSectorsFee = big.Add(totalProvenSectorsFee, soci16.DailyFee)
148+
} // else the sector is too new, hasn't been proven and won't have paid a fee yet
138149
} else {
139150
_, _ = fmt.Fprintf(cctx.App.Writer, "<legacy, not migrated>\n")
140151
}
@@ -170,7 +181,7 @@ var minerFeesCmd = &cli.Command{
170181
correct = "✗"
171182
discrepancies = true
172183
}
173-
_, _ = fmt.Fprintf(cctx.App.Writer, "\t%s Deadline daily fee: %s, power: %s (sector fee sum: %s, expiration fee deduction sum: %s)\n", correct, dl.DailyFee, dl.LivePower.QA, totalSectorsFee, totalFeeDeduction)
184+
_, _ = fmt.Fprintf(cctx.App.Writer, "\t%s Deadline daily fee: %s, power: %s (proven sector fee sum: %s, total sector fee sum: %s, expiration fee deduction sum: %s)\n", correct, dl.DailyFee, dl.LivePower.QA, totalProvenSectorsFee, totalSectorsFee, totalFeeDeduction)
174185

175186
if !dl.DailyFee.IsZero() {
176187

@@ -261,7 +272,7 @@ var minerFeesCmd = &cli.Command{
261272
}
262273
}
263274

264-
expectedFee := dl.DailyFee
275+
expectedFee := totalProvenSectorsFee
265276

266277
rewardPercent := "<cron call not found>"
267278
feeCapDesc := "fee not capped"

0 commit comments

Comments
 (0)