From e7d9b33db5483bc434b8527000d277b41aa341d9 Mon Sep 17 00:00:00 2001 From: Mike Greenberg Date: Tue, 20 Jul 2021 17:19:28 -0400 Subject: [PATCH] feat(config): support configurable CC sector expiration --- extern/storage-sealing/sealiface/config.go | 2 ++ node/config/def.go | 6 ++++++ storage/miner.go | 20 ++++++++++++++++---- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/extern/storage-sealing/sealiface/config.go b/extern/storage-sealing/sealiface/config.go index e33b3626319..59c3d8c4fd7 100644 --- a/extern/storage-sealing/sealiface/config.go +++ b/extern/storage-sealing/sealiface/config.go @@ -20,6 +20,8 @@ type Config struct { WaitDealsDelay time.Duration + CommittedCapacityDefaultLifetime time.Duration + AlwaysKeepUnsealedCopy bool FinalizeEarly bool diff --git a/node/config/def.go b/node/config/def.go index 2ba70d89248..a19a058f0a0 100644 --- a/node/config/def.go +++ b/node/config/def.go @@ -131,6 +131,12 @@ type SealingConfig struct { WaitDealsDelay Duration + // CommittedCapacityDefaultLifetime is the default duration a Committed Capacity (CC) + // sector will live before it must be extended or converted into sector containing deals + // before it is terminated. + // Value must be between 180-540 days inclusive. + CommittedCapacityDefaultLifetime Duration + AlwaysKeepUnsealedCopy bool // Run sector finalization before submitting sector proof to the chain diff --git a/storage/miner.go b/storage/miner.go index cdacc273492..f668d543407 100644 --- a/storage/miner.go +++ b/storage/miner.go @@ -178,8 +178,11 @@ func (m *Miner) Run(ctx context.Context) error { // provides extra methods. adaptedAPI = NewSealingAPIAdapter(m.api) + // sealing configuration. + cfg = sealing.GetSealingConfigFunc(m.getSealConfig) + // Instantiate a precommit policy. - defaultDuration = policy.GetMaxSectorExpirationExtension() - (md.WPoStProvingPeriod * 2) + defaultDuration = getDefaultSectorExpirationExtension(cfg) - (md.WPoStProvingPeriod * 2) provingBoundary = md.PeriodStart % md.WPoStProvingPeriod // TODO: Maybe we update this policy after actor upgrades? @@ -189,9 +192,6 @@ func (m *Miner) Run(ctx context.Context) error { as = func(ctx context.Context, mi miner.MinerInfo, use api.AddrUse, goodFunds, minFunds abi.TokenAmount) (address.Address, abi.TokenAmount, error) { return m.addrSel.AddressFor(ctx, m.api, mi, use, goodFunds, minFunds) } - - // sealing configuration. - cfg = sealing.GetSealingConfigFunc(m.getSealConfig) ) // Instantiate the sealing FSM. @@ -203,6 +203,18 @@ func (m *Miner) Run(ctx context.Context) error { return nil } +func getDefaultSectorExpirationExtension(cfg sealing.GetSealingConfigFunc) abi.ChainEpoch { + c, err := cfg() + if err != nil { + log.Warnf("failed to load sealing config, using default sector extension expiration") + log.Errorf("sealing config load error: %s", err.Error()) + return policy.GetMaxSectorExpirationExtension() + } + // TODO: remove magic number + secondsPerEpoch := 30 * time.Second + return abi.ChainEpoch(c.CommittedCapacityDefaultLifetime.Truncate(secondsPerEpoch)) +} + func (m *Miner) handleSealingNotifications(before, after sealing.SectorInfo) { m.journal.RecordEvent(m.sealingEvtType, func() interface{} { return SealingStateEvt{