lotus/storage/pipeline/upgrade_queue.go

81 lines
2.3 KiB
Go
Raw Normal View History

2020-07-01 13:30:25 +00:00
package sealing
import (
2020-07-15 14:51:02 +00:00
"context"
2020-09-17 02:34:13 +00:00
2020-07-01 13:30:25 +00:00
"golang.org/x/xerrors"
2020-09-07 03:49:10 +00:00
"github.com/filecoin-project/go-state-types/abi"
2022-03-16 19:28:15 +00:00
market7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/market"
"github.com/filecoin-project/lotus/chain/types"
2020-07-01 13:30:25 +00:00
)
func (m *Sealing) MarkForUpgrade(ctx context.Context, id abi.SectorNumber) error {
2020-07-01 13:30:25 +00:00
si, err := m.GetSectorInfo(id)
if err != nil {
return xerrors.Errorf("getting sector info: %w", err)
}
if si.State != Proving {
return xerrors.Errorf("unable to snap-up sectors not in the 'Proving' state")
2020-07-01 13:30:25 +00:00
}
feat: sealing: Support nv22 DDO features in the sealing pipeline (#11226) * 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>
2024-01-25 14:15:55 +00:00
if si.hasData() {
2020-07-01 13:30:25 +00:00
return xerrors.Errorf("not a committed-capacity sector, has deals")
}
ts, err := m.Api.ChainHead(ctx)
if err != nil {
return xerrors.Errorf("couldnt get chain head: %w", err)
}
onChainInfo, err := m.Api.StateSectorGetInfo(ctx, m.maddr, id, ts.Key())
if err != nil {
return xerrors.Errorf("failed to read sector on chain info: %w", err)
}
if onChainInfo == nil {
return xerrors.Errorf("sector not found %d", id)
}
2020-07-01 13:30:25 +00:00
active, err := m.sectorActive(ctx, ts.Key(), id)
if err != nil {
return xerrors.Errorf("failed to check if sector is active")
}
if !active {
return xerrors.Errorf("cannot mark inactive sector for upgrade")
}
2020-07-01 13:30:25 +00:00
if onChainInfo.Expiration-ts.Height() < market7.DealMinDuration {
return xerrors.Errorf("pointless to upgrade sector %d, expiration %d is less than a min deal duration away from current epoch."+
"Upgrade expiration before marking for upgrade", id, onChainInfo.Expiration)
}
2022-03-16 16:33:05 +00:00
return m.sectors.Send(uint64(id), SectorMarkForUpdate{})
2020-07-01 13:30:25 +00:00
}
func (m *Sealing) sectorActive(ctx context.Context, tsk types.TipSetKey, sector abi.SectorNumber) (bool, error) {
dls, err := m.Api.StateMinerDeadlines(ctx, m.maddr, tsk)
if err != nil {
return false, xerrors.Errorf("getting proving deadlines: %w", err)
}
2022-02-01 06:09:42 +00:00
for dl := range dls {
parts, err := m.Api.StateMinerPartitions(ctx, m.maddr, uint64(dl), tsk)
if err != nil {
return false, xerrors.Errorf("getting partitions for deadline %d: %w", dl, err)
}
for p, part := range parts {
set, err := part.ActiveSectors.IsSet(uint64(sector))
if err != nil {
return false, xerrors.Errorf("checking if sector %d is in deadline %d partition %d: %w", sector, dl, p, err)
}
if set {
return true, nil
}
}
}
return false, nil
}