Add miner config to always keep ensealed deal copies

This commit is contained in:
Łukasz Magiera 2021-01-26 17:50:31 +01:00
parent d5addf7173
commit d4c7b63aac
5 changed files with 23 additions and 4 deletions

View File

@ -15,4 +15,6 @@ type Config struct {
MaxSealingSectorsForDeals uint64
WaitDealsDelay time.Duration
AlwaysKeepUnsealedCopy bool
}

View File

@ -512,7 +512,12 @@ func (m *Sealing) handleCommitWait(ctx statemachine.Context, sector SectorInfo)
func (m *Sealing) handleFinalizeSector(ctx statemachine.Context, sector SectorInfo) error {
// TODO: Maybe wait for some finality
if err := m.sealer.FinalizeSector(sector.sealingCtx(ctx.Context()), m.minerSector(sector.SectorType, sector.SectorNumber), sector.keepUnsealedRanges(false)); err != nil {
cfg, err := m.getConfig()
if err != nil {
return xerrors.Errorf("getting sealing config: %w", err)
}
if err := m.sealer.FinalizeSector(sector.sealingCtx(ctx.Context()), m.minerSector(sector.SectorType, sector.SectorNumber), sector.keepUnsealedRanges(false, cfg.AlwaysKeepUnsealedCopy)); err != nil {
return ctx.Send(SectorFinalizeFailed{xerrors.Errorf("finalize sector: %w", err)})
}
@ -523,7 +528,12 @@ func (m *Sealing) handleProvingSector(ctx statemachine.Context, sector SectorInf
// TODO: track sector health / expiration
log.Infof("Proving sector %d", sector.SectorNumber)
if err := m.sealer.ReleaseUnsealed(ctx.Context(), m.minerSector(sector.SectorType, sector.SectorNumber), sector.keepUnsealedRanges(true)); err != nil {
cfg, err := m.getConfig()
if err != nil {
return xerrors.Errorf("getting sealing config: %w", err)
}
if err := m.sealer.ReleaseUnsealed(ctx.Context(), m.minerSector(sector.SectorType, sector.SectorNumber), sector.keepUnsealedRanges(true, cfg.AlwaysKeepUnsealedCopy)); err != nil {
log.Error(err)
}

View File

@ -163,7 +163,7 @@ func (t *SectorInfo) sealingCtx(ctx context.Context) context.Context {
// Returns list of offset/length tuples of sector data ranges which clients
// requested to keep unsealed
func (t *SectorInfo) keepUnsealedRanges(invert bool) []storage.Range {
func (t *SectorInfo) keepUnsealedRanges(invert, alwaysKeep bool) []storage.Range {
var out []storage.Range
var at abi.UnpaddedPieceSize
@ -174,7 +174,10 @@ func (t *SectorInfo) keepUnsealedRanges(invert bool) []storage.Range {
if piece.DealInfo == nil {
continue
}
if piece.DealInfo.KeepUnsealed == invert {
keep := piece.DealInfo.KeepUnsealed || alwaysKeep
if keep == invert {
continue
}

View File

@ -64,6 +64,8 @@ type SealingConfig struct {
MaxSealingSectorsForDeals uint64
WaitDealsDelay Duration
AlwaysKeepUnsealedCopy bool
}
type MinerFeeConfig struct {

View File

@ -810,6 +810,7 @@ func NewSetSealConfigFunc(r repo.LockedRepo) (dtypes.SetSealingConfigFunc, error
MaxSealingSectors: cfg.MaxSealingSectors,
MaxSealingSectorsForDeals: cfg.MaxSealingSectorsForDeals,
WaitDealsDelay: config.Duration(cfg.WaitDealsDelay),
AlwaysKeepUnsealedCopy: cfg.AlwaysKeepUnsealedCopy,
}
})
return
@ -824,6 +825,7 @@ func NewGetSealConfigFunc(r repo.LockedRepo) (dtypes.GetSealingConfigFunc, error
MaxSealingSectors: cfg.Sealing.MaxSealingSectors,
MaxSealingSectorsForDeals: cfg.Sealing.MaxSealingSectorsForDeals,
WaitDealsDelay: time.Duration(cfg.Sealing.WaitDealsDelay),
AlwaysKeepUnsealedCopy: cfg.Sealing.AlwaysKeepUnsealedCopy,
}
})
return