feat(config): support configurable CC sector expiration

This commit is contained in:
Mike Greenberg 2021-07-20 17:19:28 -04:00
parent 2d40089b7e
commit 9e34cce1f2
3 changed files with 22 additions and 4 deletions

View File

@ -20,6 +20,8 @@ type Config struct {
WaitDealsDelay time.Duration WaitDealsDelay time.Duration
CommittedCapacityDefaultLifetime time.Duration
AlwaysKeepUnsealedCopy bool AlwaysKeepUnsealedCopy bool
FinalizeEarly bool FinalizeEarly bool

View File

@ -131,6 +131,12 @@ type SealingConfig struct {
WaitDealsDelay Duration 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 AlwaysKeepUnsealedCopy bool
// Run sector finalization before submitting sector proof to the chain // Run sector finalization before submitting sector proof to the chain

View File

@ -178,8 +178,11 @@ func (m *Miner) Run(ctx context.Context) error {
// provides extra methods. // provides extra methods.
adaptedAPI = NewSealingAPIAdapter(m.api) adaptedAPI = NewSealingAPIAdapter(m.api)
// sealing configuration.
cfg = sealing.GetSealingConfigFunc(m.getSealConfig)
// Instantiate a precommit policy. // Instantiate a precommit policy.
defaultDuration = policy.GetMaxSectorExpirationExtension() - (md.WPoStProvingPeriod * 2) defaultDuration = getDefaultSectorExpirationExtension(cfg) - (md.WPoStProvingPeriod * 2)
provingBoundary = md.PeriodStart % md.WPoStProvingPeriod provingBoundary = md.PeriodStart % md.WPoStProvingPeriod
// TODO: Maybe we update this policy after actor upgrades? // 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) { 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) return m.addrSel.AddressFor(ctx, m.api, mi, use, goodFunds, minFunds)
} }
// sealing configuration.
cfg = sealing.GetSealingConfigFunc(m.getSealConfig)
) )
// Instantiate the sealing FSM. // Instantiate the sealing FSM.
@ -203,6 +203,16 @@ func (m *Miner) Run(ctx context.Context) error {
return nil 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()
}
return abi.ChainEpoch(c.CommittedCapacityDefaultLifetime.Truncate(builtin.EpochDurationSeconds))
}
func (m *Miner) handleSealingNotifications(before, after sealing.SectorInfo) { func (m *Miner) handleSealingNotifications(before, after sealing.SectorInfo) {
m.journal.RecordEvent(m.sealingEvtType, func() interface{} { m.journal.RecordEvent(m.sealingEvtType, func() interface{} {
return SealingStateEvt{ return SealingStateEvt{