From 47064f987c512826f78cb2c52faae66cf235b52e Mon Sep 17 00:00:00 2001 From: Aayush Rajasekaran Date: Tue, 9 Mar 2021 23:36:30 -0500 Subject: [PATCH] Check liveness of sectors when processing termination batches --- extern/storage-sealing/terminate_batch.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/extern/storage-sealing/terminate_batch.go b/extern/storage-sealing/terminate_batch.go index 31ccef93c..0e96e8384 100644 --- a/extern/storage-sealing/terminate_batch.go +++ b/extern/storage-sealing/terminate_batch.go @@ -143,6 +143,18 @@ func (b *TerminateBatcher) processBatch(notif, after bool) (*cid.Cid, error) { continue } + ps, err := b.api.StateMinerPartitions(b.mctx, b.maddr, loc.Deadline, nil) + if err != nil { + log.Warnw("TerminateBatcher: getting miner partitions", "deadline", loc.Deadline, "partition", loc.Partition, "error", err) + continue + } + + toTerminate, err = bitfield.IntersectBitField(ps[loc.Partition].LiveSectors, toTerminate) + if err != nil { + log.Warnw("TerminateBatcher: intersecting liveSectors and toTerminate bitfields", "deadline", loc.Deadline, "partition", loc.Partition, "error", err) + continue + } + if total+n > uint64(miner.AddressedSectorsMax) { n = uint64(miner.AddressedSectorsMax) - total