fix expiration config handling in calcTargetExpiration
This commit is contained in:
parent
bf3daea124
commit
501d21aa28
@ -521,7 +521,7 @@ func (m *Sealing) updateInput(ctx context.Context, sp abi.RegisteredSealProof) e
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Sealing) calcTargetExpiration(ctx context.Context, ssize abi.SectorSize, cfg sealiface.Config) (minExp, target abi.ChainEpoch, err error) {
|
func (m *Sealing) calcTargetExpiration(ctx context.Context, ssize abi.SectorSize, cfg sealiface.Config) (minExpEpoch, targetEpoch abi.ChainEpoch, err error) {
|
||||||
var candidates []*pendingPiece
|
var candidates []*pendingPiece
|
||||||
|
|
||||||
for _, piece := range m.pendingPieces {
|
for _, piece := range m.pendingPieces {
|
||||||
@ -542,7 +542,7 @@ func (m *Sealing) calcTargetExpiration(ctx context.Context, ssize abi.SectorSize
|
|||||||
// Find the expiration of the last deal which can fit into the sector, use that as the initial target
|
// Find the expiration of the last deal which can fit into the sector, use that as the initial target
|
||||||
for _, candidate := range candidates {
|
for _, candidate := range candidates {
|
||||||
totalBytes += uint64(candidate.size)
|
totalBytes += uint64(candidate.size)
|
||||||
target = candidate.deal.DealProposal.EndEpoch
|
targetEpoch = candidate.deal.DealProposal.EndEpoch
|
||||||
|
|
||||||
if totalBytes >= uint64(abi.PaddedPieceSize(ssize).Unpadded()) {
|
if totalBytes >= uint64(abi.PaddedPieceSize(ssize).Unpadded()) {
|
||||||
full = true
|
full = true
|
||||||
@ -550,33 +550,33 @@ func (m *Sealing) calcTargetExpiration(ctx context.Context, ssize abi.SectorSize
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if the sector isn't full, use max deal duration as the target
|
|
||||||
if !full {
|
|
||||||
ts, err := m.Api.ChainHead(ctx)
|
ts, err := m.Api.ChainHead(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, 0, xerrors.Errorf("getting current epoch: %w", err)
|
return 0, 0, xerrors.Errorf("getting current epoch: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if the sector isn't full, use max deal duration as the target
|
||||||
|
if !full {
|
||||||
minDur, maxDur := policy.DealDurationBounds(0)
|
minDur, maxDur := policy.DealDurationBounds(0)
|
||||||
minExp = ts.Height() + minDur
|
|
||||||
|
|
||||||
target = maxDur
|
minExpEpoch = ts.Height() + minDur
|
||||||
|
targetEpoch = ts.Height() + maxDur
|
||||||
}
|
}
|
||||||
|
|
||||||
// make sure that at least one deal in the queue is within the expiration
|
// make sure that at least one deal in the queue is within the expiration
|
||||||
if len(candidates) > 0 && candidates[0].deal.DealProposal.EndEpoch > minExp {
|
if len(candidates) > 0 && candidates[0].deal.DealProposal.EndEpoch > minExpEpoch {
|
||||||
minExp = candidates[0].deal.DealProposal.EndEpoch
|
minExpEpoch = candidates[0].deal.DealProposal.EndEpoch
|
||||||
}
|
}
|
||||||
|
|
||||||
// apply user minimums
|
// apply user minimums
|
||||||
if abi.ChainEpoch(cfg.MinUpgradeSectorExpiration) > minExp {
|
if abi.ChainEpoch(cfg.MinUpgradeSectorExpiration)+ts.Height() > minExpEpoch {
|
||||||
minExp = abi.ChainEpoch(cfg.MinUpgradeSectorExpiration)
|
minExpEpoch = abi.ChainEpoch(cfg.MinUpgradeSectorExpiration) + ts.Height()
|
||||||
}
|
}
|
||||||
if abi.ChainEpoch(cfg.MinTargetUpgradeSectorExpiration) > target {
|
if abi.ChainEpoch(cfg.MinTargetUpgradeSectorExpiration)+ts.Height() > targetEpoch {
|
||||||
target = abi.ChainEpoch(cfg.MinTargetUpgradeSectorExpiration)
|
targetEpoch = abi.ChainEpoch(cfg.MinTargetUpgradeSectorExpiration) + ts.Height()
|
||||||
}
|
}
|
||||||
|
|
||||||
return minExp, target, nil
|
return minExpEpoch, targetEpoch, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Sealing) maybeUpgradeSector(ctx context.Context, sp abi.RegisteredSealProof, cfg sealiface.Config, ef expFn) (bool, error) {
|
func (m *Sealing) maybeUpgradeSector(ctx context.Context, sp abi.RegisteredSealProof, cfg sealiface.Config, ef expFn) (bool, error) {
|
||||||
@ -588,7 +588,7 @@ func (m *Sealing) maybeUpgradeSector(ctx context.Context, sp abi.RegisteredSealP
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return false, xerrors.Errorf("getting sector size: %w", err)
|
return false, xerrors.Errorf("getting sector size: %w", err)
|
||||||
}
|
}
|
||||||
minExpiration, targetExpiration, err := m.calcTargetExpiration(ctx, ssize, cfg)
|
minExpirationEpoch, targetExpirationEpoch, err := m.calcTargetExpiration(ctx, ssize, cfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, xerrors.Errorf("calculating min target expiration: %w", err)
|
return false, xerrors.Errorf("calculating min target expiration: %w", err)
|
||||||
}
|
}
|
||||||
@ -598,7 +598,7 @@ func (m *Sealing) maybeUpgradeSector(ctx context.Context, sp abi.RegisteredSealP
|
|||||||
bestPledge := types.TotalFilecoinInt
|
bestPledge := types.TotalFilecoinInt
|
||||||
|
|
||||||
for s := range m.available {
|
for s := range m.available {
|
||||||
expiration, pledge, err := ef(s.Number)
|
expirationEpoch, pledge, err := ef(s.Number)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorw("checking sector expiration", "error", err)
|
log.Errorw("checking sector expiration", "error", err)
|
||||||
continue
|
continue
|
||||||
@ -620,24 +620,24 @@ func (m *Sealing) maybeUpgradeSector(ctx context.Context, sp abi.RegisteredSealP
|
|||||||
// if best is below target, we want larger expirations
|
// if best is below target, we want larger expirations
|
||||||
// if best is above target, we want lower pledge, but only if still above target
|
// if best is above target, we want lower pledge, but only if still above target
|
||||||
|
|
||||||
if bestExpiration < targetExpiration {
|
if bestExpiration < targetExpirationEpoch {
|
||||||
if expiration > bestExpiration && slowChecks(s.Number) {
|
if expirationEpoch > bestExpiration && slowChecks(s.Number) {
|
||||||
bestExpiration = expiration
|
bestExpiration = expirationEpoch
|
||||||
bestPledge = pledge
|
bestPledge = pledge
|
||||||
candidate = s
|
candidate = s
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if expiration >= targetExpiration && pledge.LessThan(bestPledge) && slowChecks(s.Number) {
|
if expirationEpoch >= targetExpirationEpoch && pledge.LessThan(bestPledge) && slowChecks(s.Number) {
|
||||||
bestExpiration = expiration
|
bestExpiration = expirationEpoch
|
||||||
bestPledge = pledge
|
bestPledge = pledge
|
||||||
candidate = s
|
candidate = s
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if bestExpiration < minExpiration {
|
if bestExpiration < minExpirationEpoch {
|
||||||
log.Infow("Not upgrading any sectors", "available", len(m.available), "pieces", len(m.pendingPieces), "bestExp", bestExpiration, "target", targetExpiration, "min", minExpiration, "candidate", candidate)
|
log.Infow("Not upgrading any sectors", "available", len(m.available), "pieces", len(m.pendingPieces), "bestExp", bestExpiration, "target", targetExpirationEpoch, "min", minExpirationEpoch, "candidate", candidate)
|
||||||
// didn't find a good sector / no sectors were available
|
// didn't find a good sector / no sectors were available
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user