Skip to content

Commit

Permalink
Merge pull request #6066 from chadwick2143/extend-v1-sectors
Browse files Browse the repository at this point in the history
Fix bugs in sectors extend --v1-sectors
  • Loading branch information
arajasek authored Jul 11, 2021
2 parents 93d929a + ea9ad8c commit e983d90
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion cmd/lotus-storage-miner/sectors.go
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,12 @@ var sectorsExtendCmd = &cli.Command{
Usage: "when extending v1 sectors, don't try to extend sectors by fewer than this number of epochs",
Required: false,
},
&cli.Int64Flag{
Name: "expiration-ignore",
Value: 120,
Usage: "when extending v1 sectors, skip sectors whose current expiration is less than <ignore> epochs from now",
Required: false,
},
&cli.Int64Flag{
Name: "expiration-cutoff",
Usage: "when extending v1 sectors, skip sectors whose current expiration is more than <cutoff> epochs from now (infinity if unspecified)",
Expand Down Expand Up @@ -496,6 +502,10 @@ var sectorsExtendCmd = &cli.Command{
continue
}

if si.Expiration < (head.Height() + abi.ChainEpoch(cctx.Int64("expiration-ignore"))) {
continue
}

if cctx.IsSet("expiration-cutoff") {
if si.Expiration > (head.Height() + abi.ChainEpoch(cctx.Int64("expiration-cutoff"))) {
continue
Expand All @@ -510,6 +520,10 @@ var sectorsExtendCmd = &cli.Command{

// Set the new expiration to 48 hours less than the theoretical maximum lifetime
newExp := ml - (miner3.WPoStProvingPeriod * 2) + si.Activation
if withinTolerance(si.Expiration, newExp) || si.Expiration >= newExp {
continue
}

p, err := api.StateSectorPartition(ctx, maddr, si.SectorNumber, types.EmptyTSK)
if err != nil {
return xerrors.Errorf("getting sector location for sector %d: %w", si.SectorNumber, err)
Expand All @@ -527,7 +541,7 @@ var sectorsExtendCmd = &cli.Command{
} else {
added := false
for exp := range es {
if withinTolerance(exp, newExp) {
if withinTolerance(exp, newExp) && newExp >= exp && exp > si.Expiration {
es[exp] = append(es[exp], uint64(si.SectorNumber))
added = true
break
Expand Down

0 comments on commit e983d90

Please sign in to comment.