Skip to content

Commit 2fe2380

Browse files
authored
fix: invariants: adapt to FIP-0076 changes (#253)
1 parent a3c035f commit 2fe2380

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

builtin/v13/check.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ func CheckStateInvariants(tree *builtin.ActorTree, priorEpoch abi.ChainEpoch, ac
188188
//
189189

190190
CheckMinersAgainstPower(acc, minerSummaries, powerSummary)
191-
CheckDealStatesAgainstSectors(acc, minerSummaries, marketSummary)
191+
CheckDealStatesAgainstSectors(acc, minerSummaries, marketSummary, priorEpoch)
192192
CheckVerifregAgainstMiners(acc, verifregSummary, minerSummaries)
193193
CheckMarketAgainstVerifreg(acc, verifregSummary, marketSummary)
194194
CheckVerifregAgainstDatacap(acc, verifregSummary, datacapSummary)
@@ -251,7 +251,7 @@ func CheckMinersAgainstPower(acc *builtin.MessageAccumulator, minerSummaries map
251251
}
252252
}
253253

254-
func CheckDealStatesAgainstSectors(acc *builtin.MessageAccumulator, minerSummaries map[address.Address]*miner.StateSummary, marketSummary *market.StateSummary) {
254+
func CheckDealStatesAgainstSectors(acc *builtin.MessageAccumulator, minerSummaries map[address.Address]*miner.StateSummary, marketSummary *market.StateSummary, currEpoch abi.ChainEpoch) {
255255
// Check that all active deals are included within a non-terminated sector.
256256
// We cannot check that all deals referenced within a sector are in the market, because deals
257257
// can be terminated independently of the sector in which they are included.
@@ -291,7 +291,7 @@ func CheckDealStatesAgainstSectors(acc *builtin.MessageAccumulator, minerSummari
291291
"deal state slashed at %d after sector expiration %d for miner %v",
292292
deal.SlashEpoch, sectorDeal.SectorExpiration, deal.Provider)
293293

294-
acc.Require((deal.SectorNumber == sectorDeal.SectorNumber) || (deal.SectorNumber == 0 && deal.SlashEpoch != -1),
294+
acc.Require((deal.SectorNumber == sectorDeal.SectorNumber) || (deal.SectorNumber == 0 && deal.SlashEpoch != -1) || (deal.SectorNumber == 0 && deal.EndEpoch < currEpoch),
295295
"deal sector number %d does not match sector %d for miner %v (ds: %#v; ss %#v)",
296296
deal.SectorNumber, sectorDeal.SectorNumber, deal.Provider, deal, sectorDeal)
297297
}

builtin/v13/market/invariants.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ type DealSummary struct {
2222
SectorStartEpoch abi.ChainEpoch
2323
LastUpdatedEpoch abi.ChainEpoch
2424
SlashEpoch abi.ChainEpoch
25-
SectorNumber abi.SectorNumber
26-
PieceCid cid.Cid
25+
// Populated from market's States, not the miner state
26+
SectorNumber abi.SectorNumber
27+
PieceCid cid.Cid
2728
}
2829

2930
type StateSummary struct {
@@ -300,9 +301,10 @@ func CheckStateInvariants(st *State, store adt.Store, balance abi.TokenAmount, c
300301
// check against proposalStats
301302
for _, dealID := range dealIDsCopy {
302303
st, found := proposalStats[dealID]
303-
if !found {
304+
if !found || st.SlashEpoch != EpochUndefined || st.EndEpoch < currEpoch {
304305
continue
305306
}
307+
306308
acc.Require(st.SectorNumber == abi.SectorNumber(sectorNumber), "deal id %d sector number %d does not match sector id %d", dealID, st.SectorNumber, sectorNumber)
307309

308310
_, ok := expectedProviderSectors[dealID]
@@ -316,8 +318,6 @@ func CheckStateInvariants(st *State, store adt.Store, balance abi.TokenAmount, c
316318
}
317319

318320
acc.Require(provider == provID, "deal %d has provider %v, expected %v", dealID, provID, provider)
319-
320-
acc.Require(st.SlashEpoch == EpochUndefined, "provider sector deal %d is slashed", dealID)
321321
}
322322

323323
return nil

0 commit comments

Comments
 (0)