Skip to content

Commit

Permalink
feat(config): support configurable CC sector expiration
Browse files Browse the repository at this point in the history
  • Loading branch information
placer14 committed Jul 20, 2021
1 parent 1c30d07 commit e7d9b33
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
2 changes: 2 additions & 0 deletions extern/storage-sealing/sealiface/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ type Config struct {

WaitDealsDelay time.Duration

CommittedCapacityDefaultLifetime time.Duration

AlwaysKeepUnsealedCopy bool

FinalizeEarly bool
Expand Down
6 changes: 6 additions & 0 deletions node/config/def.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 16 additions & 4 deletions storage/miner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand All @@ -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.
Expand All @@ -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{
Expand Down

0 comments on commit e7d9b33

Please sign in to comment.