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

Commit

Permalink
Fix failure to detect faults of exactly-full top partition (#350)
Browse files Browse the repository at this point in the history
  • Loading branch information
anorth authored May 6, 2020
1 parent 2307586 commit ee40198
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions actors/builtin/miner/miner_actor.go
Original file line number Diff line number Diff line change
Expand Up @@ -1093,25 +1093,22 @@ func computeFaultsFromMissingPoSts(st *State, deadlines *Deadlines, beforeDeadli
deadlineFirstPartition := uint64(0)
var fGroups, rGroups []*abi.BitField
for dlIdx := uint64(0); dlIdx < beforeDeadline; dlIdx++ {
partitionCount, dlSectorCount, err := DeadlineCount(deadlines, partitionSize, dlIdx)
dlPartCount, dlSectorCount, err := DeadlineCount(deadlines, partitionSize, dlIdx)
if err != nil {
return nil, nil, fmt.Errorf("failed to count deadline %d partitions: %w", dlIdx, err)
}
deadlineSectors := deadlines.Due[dlIdx]

for i := uint64(0); i < partitionCount; i++ {
if !submissions[deadlineFirstPartition+i] {
for dlPartIdx := uint64(0); dlPartIdx < dlPartCount; dlPartIdx++ {
if !submissions[deadlineFirstPartition+dlPartIdx] {
// No PoSt received in prior period.
firstSector := i * partitionSize
sectorCount := partitionSize
if i == partitionCount-1 {
sectorCount = dlSectorCount % partitionSize
}
partFirstSectorIdx := dlPartIdx * partitionSize
partSectorCount := min64(partitionSize, dlSectorCount-partFirstSectorIdx)

partitionSectors, err := deadlineSectors.Slice(firstSector, sectorCount)
partitionSectors, err := deadlineSectors.Slice(partFirstSectorIdx, partSectorCount)
if err != nil {
return nil, nil, fmt.Errorf("failed to slice deadline %d partition %d sectors %d..%d: %w",
dlIdx, i, firstSector, firstSector+partitionCount, err)
dlIdx, dlPartIdx, partFirstSectorIdx, partFirstSectorIdx+dlPartCount, err)
}

// Record newly-faulty sectors.
Expand All @@ -1125,7 +1122,7 @@ func computeFaultsFromMissingPoSts(st *State, deadlines *Deadlines, beforeDeadli
}
}

deadlineFirstPartition += partitionCount
deadlineFirstPartition += dlPartCount
}
detectedFaults, err = abi.BitFieldUnion(fGroups...)
if err != nil {
Expand Down

0 comments on commit ee40198

Please sign in to comment.