9e03fcab83
* Initial work supporting DDO pieces in lotus-miner * sealing: Update pipeline input to operate on UniversalPiece * sealing: Update pipeline checks/sealing states to operate on UniversalPiece * sealing: Make pipeline build with UniversalPiece * move PieceDealInfo out of api * make gen * make sealing pipeline unit tests pass * fix itest ensemble build * don't panic in SectorsStatus with deals * stop linter from complaining about checkPieces * fix sector import tests * mod tidy * sealing: Add logic for (pre)committing DDO sectors * sealing: state-types with method defs * DDO non-snap pipeline works(?), DDO Itests * DDO support in snapdeals pipeline * make gen * update actor bundles * update the gst market fix * fix: chain: use PreCommitSectorsBatch2 when setting up genesis * some bug fixes * integration working changes * update actor bundles * Make TestOnboardRawPieceSnap pass * Appease the linter * Make deadlines test pass with v12 actors * Update go-state-types, abstract market DealState * make gen * mod tidy, lint fixes * Fix some more tests * Bump version in master Bump version in master * Make gen Make gen * fix sender * fix: lotus-provider: Fix winning PoSt * fix: sql Scan cannot write to an object * Actually show miner-addrs in info-log Actually show miner-addrs in lotus-provider info-log * [WIP] feat: Add nv22 skeleton Addition of Network Version 22 skeleton * update FFI * ddo is now nv22 * make gen * temp actor bundle with ddo * use working go-state-types * gst with v13 market migration * update bundle, builtin.MethodsMiner.ProveCommitSectors2 -> 3 * actually working v13 migration, v13 migration itest * Address review * sealing: Correct DDO snap pledge math * itests: Mixed ddo itest * pipeline: Fix sectorWeight * sealing: convert market deals into PAMs in mixed sectors * sealing: make market to ddo conversion work * fix lint * update gst * Update actors and GST to lastest integ branch * commit batcher: Update ProveCommitSectors3Params builder logic * make gen * use builtin-actors master * ddo: address review * itests: Add commd assertions to ddo tests * make gen * gst with fixed types * config knobs for RequireActivationSuccess * storage: Drop obsolete flaky tasts --------- Co-authored-by: Jennifer Wang <jiayingw703@gmail.com> Co-authored-by: Aayush <arajasek94@gmail.com> Co-authored-by: Shrenuj Bansal <shrenuj.bansal@protocol.ai> Co-authored-by: Phi <orjan.roren@gmail.com> Co-authored-by: Andrew Jackson (Ajax) <snadrus@gmail.com> Co-authored-by: TippyFlits <james.bluett@protocol.ai>
145 lines
4.5 KiB
Go
145 lines
4.5 KiB
Go
package sealing
|
|
|
|
import (
|
|
"context"
|
|
|
|
"golang.org/x/xerrors"
|
|
|
|
"github.com/filecoin-project/go-state-types/abi"
|
|
"github.com/filecoin-project/go-state-types/builtin/v8/miner"
|
|
"github.com/filecoin-project/go-state-types/network"
|
|
|
|
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
|
"github.com/filecoin-project/lotus/chain/actors/policy"
|
|
"github.com/filecoin-project/lotus/chain/types"
|
|
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
|
)
|
|
|
|
type PreCommitPolicy interface {
|
|
Expiration(ctx context.Context, ps ...SafeSectorPiece) (abi.ChainEpoch, error)
|
|
}
|
|
|
|
type Chain interface {
|
|
ChainHead(context.Context) (*types.TipSet, error)
|
|
StateNetworkVersion(ctx context.Context, tsk types.TipSetKey) (network.Version, error)
|
|
}
|
|
|
|
// BasicPreCommitPolicy satisfies PreCommitPolicy. It has two modes:
|
|
//
|
|
// Mode 1: The sector contains a non-zero quantity of pieces with deal info
|
|
// Mode 2: The sector contains no pieces with deal info
|
|
//
|
|
// The BasicPreCommitPolicy#Expiration method is given a slice of the pieces
|
|
// which the miner has encoded into the sector, and from that slice picks either
|
|
// the first or second mode.
|
|
//
|
|
// If we're in Mode 1: The pre-commit expiration epoch will be the maximum
|
|
// deal end epoch of a piece in the sector.
|
|
//
|
|
// If we're in Mode 2: The pre-commit expiration epoch will be set to the
|
|
// current epoch + the provided default duration.
|
|
type BasicPreCommitPolicy struct {
|
|
api Chain
|
|
getSealingConfig dtypes.GetSealingConfigFunc
|
|
|
|
provingBuffer abi.ChainEpoch
|
|
}
|
|
|
|
// NewBasicPreCommitPolicy produces a BasicPreCommitPolicy.
|
|
//
|
|
// The provided duration is used as the default sector expiry when the sector
|
|
// contains no deals. The proving boundary is used to adjust/align the sector's expiration.
|
|
func NewBasicPreCommitPolicy(api Chain, cfgGetter dtypes.GetSealingConfigFunc, provingBuffer abi.ChainEpoch) BasicPreCommitPolicy {
|
|
return BasicPreCommitPolicy{
|
|
api: api,
|
|
getSealingConfig: cfgGetter,
|
|
provingBuffer: provingBuffer,
|
|
}
|
|
}
|
|
|
|
// Expiration produces the pre-commit sector expiration epoch for an encoded
|
|
// replica containing the provided enumeration of pieces and deals.
|
|
func (p *BasicPreCommitPolicy) Expiration(ctx context.Context, ps ...SafeSectorPiece) (abi.ChainEpoch, error) {
|
|
ts, err := p.api.ChainHead(ctx)
|
|
if err != nil {
|
|
return 0, err
|
|
}
|
|
|
|
var end *abi.ChainEpoch
|
|
|
|
for _, p := range ps {
|
|
if !p.HasDealInfo() {
|
|
continue
|
|
}
|
|
|
|
endEpoch, err := p.EndEpoch()
|
|
if err != nil {
|
|
return 0, xerrors.Errorf("failed to get end epoch: %w", err)
|
|
}
|
|
|
|
if endEpoch < ts.Height() {
|
|
log.Warnf("piece schedule %+v ended before current epoch %d", p, ts.Height())
|
|
continue
|
|
}
|
|
|
|
if end == nil || *end < endEpoch {
|
|
tmp := endEpoch
|
|
end = &tmp
|
|
}
|
|
}
|
|
|
|
if end == nil {
|
|
nv, err := p.api.StateNetworkVersion(ctx, types.EmptyTSK)
|
|
if err != nil {
|
|
return 0, xerrors.Errorf("failed to get network version: %w", err)
|
|
}
|
|
|
|
// no deal pieces, get expiration for committed capacity sector
|
|
expirationDuration, err := p.getCCSectorLifetime(nv)
|
|
if err != nil {
|
|
return 0, xerrors.Errorf("failed to get cc sector lifetime: %w", err)
|
|
}
|
|
|
|
tmp := ts.Height() + expirationDuration
|
|
end = &tmp
|
|
}
|
|
|
|
// Ensure there is at least one day for the PC message to land without falling below min sector lifetime
|
|
// TODO: The "one day" should probably be a config, though it doesn't matter too much
|
|
minExp := ts.Height() + policy.GetMinSectorExpiration() + miner.WPoStProvingPeriod
|
|
if *end < minExp {
|
|
end = &minExp
|
|
}
|
|
|
|
return *end, nil
|
|
}
|
|
|
|
func (p *BasicPreCommitPolicy) getCCSectorLifetime(nv network.Version) (abi.ChainEpoch, error) {
|
|
c, err := p.getSealingConfig()
|
|
if err != nil {
|
|
return 0, xerrors.Errorf("sealing config load error: %w", err)
|
|
}
|
|
|
|
maxCommitment, err := policy.GetMaxSectorExpirationExtension(nv)
|
|
if err != nil {
|
|
return 0, xerrors.Errorf("failed to get max extension: %w", err)
|
|
}
|
|
|
|
var ccLifetimeEpochs = abi.ChainEpoch(uint64(c.CommittedCapacitySectorLifetime.Seconds()) / builtin.EpochDurationSeconds)
|
|
// if zero value in config, assume default sector extension
|
|
if ccLifetimeEpochs == 0 {
|
|
ccLifetimeEpochs = maxCommitment
|
|
}
|
|
|
|
if minExpiration := abi.ChainEpoch(miner.MinSectorExpiration); ccLifetimeEpochs < minExpiration {
|
|
log.Warnf("value for CommittedCapacitySectorLiftime is too short, using default minimum (%d epochs)", minExpiration)
|
|
return minExpiration, nil
|
|
}
|
|
if ccLifetimeEpochs > maxCommitment {
|
|
log.Warnf("value for CommittedCapacitySectorLiftime is too long, using default maximum (%d epochs)", maxCommitment)
|
|
return maxCommitment, nil
|
|
}
|
|
|
|
return ccLifetimeEpochs - p.provingBuffer, nil
|
|
}
|