Skip to content

Commit

Permalink
Merge pull request #7236 from filecoin-project/fix/expired-precomm
Browse files Browse the repository at this point in the history
sectors expired: Handle precomitted and unproven sectors correctly
  • Loading branch information
magik6k authored Aug 31, 2021
2 parents 4c607d9 + daaa725 commit 7a38cd9
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 0 deletions.
6 changes: 6 additions & 0 deletions chain/actors/builtin/miner/actor.go.template
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,12 @@ type Partition interface {

// Active sectors are those that are neither terminated nor faulty nor unproven, i.e. actively contributing power.
ActiveSectors() (bitfield.BitField, error)

// Unproven sectors in this partition. This bitfield will be cleared on
// a successful window post (or at the end of the partition's next
// deadline). At that time, any still unproven sectors will be added to
// the faulty sector bitfield.
UnprovenSectors() (bitfield.BitField, error)
}

type SectorOnChainInfo struct {
Expand Down
6 changes: 6 additions & 0 deletions chain/actors/builtin/miner/miner.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,12 @@ type Partition interface {

// Active sectors are those that are neither terminated nor faulty nor unproven, i.e. actively contributing power.
ActiveSectors() (bitfield.BitField, error)

// Unproven sectors in this partition. This bitfield will be cleared on
// a successful window post (or at the end of the partition's next
// deadline). At that time, any still unproven sectors will be added to
// the faulty sector bitfield.
UnprovenSectors() (bitfield.BitField, error)
}

type SectorOnChainInfo struct {
Expand Down
4 changes: 4 additions & 0 deletions chain/actors/builtin/miner/state.go.template
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,10 @@ func (p *partition{{.v}}) RecoveringSectors() (bitfield.BitField, error) {
return p.Partition.Recoveries, nil
}

func (p *partition{{.v}}) UnprovenSectors() (bitfield.BitField, error) {
return {{if (ge .v 2)}}p.Partition.Unproven{{else}}bitfield.New(){{end}}, nil
}

func fromV{{.v}}SectorOnChainInfo(v{{.v}} miner{{.v}}.SectorOnChainInfo) SectorOnChainInfo {
{{if (ge .v 2)}}
return SectorOnChainInfo{
Expand Down
4 changes: 4 additions & 0 deletions chain/actors/builtin/miner/v0.go
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,10 @@ func (p *partition0) RecoveringSectors() (bitfield.BitField, error) {
return p.Partition.Recoveries, nil
}

func (p *partition0) UnprovenSectors() (bitfield.BitField, error) {
return bitfield.New(), nil
}

func fromV0SectorOnChainInfo(v0 miner0.SectorOnChainInfo) SectorOnChainInfo {

return (SectorOnChainInfo)(v0)
Expand Down
4 changes: 4 additions & 0 deletions chain/actors/builtin/miner/v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,10 @@ func (p *partition2) RecoveringSectors() (bitfield.BitField, error) {
return p.Partition.Recoveries, nil
}

func (p *partition2) UnprovenSectors() (bitfield.BitField, error) {
return p.Partition.Unproven, nil
}

func fromV2SectorOnChainInfo(v2 miner2.SectorOnChainInfo) SectorOnChainInfo {

return SectorOnChainInfo{
Expand Down
4 changes: 4 additions & 0 deletions chain/actors/builtin/miner/v3.go
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,10 @@ func (p *partition3) RecoveringSectors() (bitfield.BitField, error) {
return p.Partition.Recoveries, nil
}

func (p *partition3) UnprovenSectors() (bitfield.BitField, error) {
return p.Partition.Unproven, nil
}

func fromV3SectorOnChainInfo(v3 miner3.SectorOnChainInfo) SectorOnChainInfo {

return SectorOnChainInfo{
Expand Down
4 changes: 4 additions & 0 deletions chain/actors/builtin/miner/v4.go
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,10 @@ func (p *partition4) RecoveringSectors() (bitfield.BitField, error) {
return p.Partition.Recoveries, nil
}

func (p *partition4) UnprovenSectors() (bitfield.BitField, error) {
return p.Partition.Unproven, nil
}

func fromV4SectorOnChainInfo(v4 miner4.SectorOnChainInfo) SectorOnChainInfo {

return SectorOnChainInfo{
Expand Down
4 changes: 4 additions & 0 deletions chain/actors/builtin/miner/v5.go
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,10 @@ func (p *partition5) RecoveringSectors() (bitfield.BitField, error) {
return p.Partition.Recoveries, nil
}

func (p *partition5) UnprovenSectors() (bitfield.BitField, error) {
return p.Partition.Unproven, nil
}

func fromV5SectorOnChainInfo(v5 miner5.SectorOnChainInfo) SectorOnChainInfo {

return SectorOnChainInfo{
Expand Down
19 changes: 19 additions & 0 deletions cmd/lotus-miner/sectors.go
Original file line number Diff line number Diff line change
Expand Up @@ -1628,12 +1628,31 @@ var sectorsExpiredCmd = &cli.Command{
}

toCheck, err = bitfield.SubtractBitField(toCheck, live)
if err != nil {
return err
}

unproven, err := part.UnprovenSectors()
if err != nil {
return err
}

toCheck, err = bitfield.SubtractBitField(toCheck, unproven)

return err
})
}); err != nil {
return err
}

err = mas.ForEachPrecommittedSector(func(pci miner.SectorPreCommitOnChainInfo) error {
toCheck.Unset(uint64(pci.Info.SectorNumber))
return nil
})
if err != nil {
return err
}

if cctx.Bool("remove-expired") {
color.Red("Removing sectors:\n")
}
Expand Down

0 comments on commit 7a38cd9

Please sign in to comment.