2020-01-15 20:49:11 +00:00
|
|
|
package sealing
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2020-07-01 13:30:25 +00:00
|
|
|
"sync"
|
2021-01-18 20:59:34 +00:00
|
|
|
"time"
|
2020-01-15 20:49:11 +00:00
|
|
|
|
2022-04-12 00:45:13 +00:00
|
|
|
"github.com/ipfs/go-cid"
|
|
|
|
"github.com/ipfs/go-datastore"
|
2020-01-16 02:55:12 +00:00
|
|
|
"github.com/ipfs/go-datastore/namespace"
|
|
|
|
logging "github.com/ipfs/go-log/v2"
|
|
|
|
"golang.org/x/xerrors"
|
2020-01-15 20:49:11 +00:00
|
|
|
|
2022-06-14 15:00:51 +00:00
|
|
|
"github.com/filecoin-project/go-address"
|
2022-08-22 18:41:56 +00:00
|
|
|
"github.com/filecoin-project/go-bitfield"
|
2020-09-07 03:49:10 +00:00
|
|
|
"github.com/filecoin-project/go-state-types/abi"
|
|
|
|
"github.com/filecoin-project/go-state-types/big"
|
2022-10-10 17:31:48 +00:00
|
|
|
verifregtypes "github.com/filecoin-project/go-state-types/builtin/v9/verifreg"
|
2020-09-07 03:49:10 +00:00
|
|
|
"github.com/filecoin-project/go-state-types/crypto"
|
2021-01-13 21:19:10 +00:00
|
|
|
"github.com/filecoin-project/go-state-types/dline"
|
2020-12-02 20:47:45 +00:00
|
|
|
"github.com/filecoin-project/go-state-types/network"
|
2022-04-12 00:45:13 +00:00
|
|
|
"github.com/filecoin-project/go-statemachine"
|
2022-08-17 15:53:44 +00:00
|
|
|
"github.com/filecoin-project/go-storedcounter"
|
2020-12-02 20:47:45 +00:00
|
|
|
|
|
|
|
"github.com/filecoin-project/lotus/api"
|
2023-08-29 13:16:05 +00:00
|
|
|
"github.com/filecoin-project/lotus/chain/actors/builtin/miner"
|
2022-06-14 15:00:51 +00:00
|
|
|
lminer "github.com/filecoin-project/lotus/chain/actors/builtin/miner"
|
2022-06-16 14:05:56 +00:00
|
|
|
"github.com/filecoin-project/lotus/chain/events"
|
2021-01-25 10:28:39 +00:00
|
|
|
"github.com/filecoin-project/lotus/chain/types"
|
2022-08-09 10:57:20 +00:00
|
|
|
"github.com/filecoin-project/lotus/journal"
|
2021-06-08 13:43:43 +00:00
|
|
|
"github.com/filecoin-project/lotus/node/config"
|
2022-08-09 11:30:34 +00:00
|
|
|
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
2022-08-09 10:57:20 +00:00
|
|
|
"github.com/filecoin-project/lotus/storage/ctladdr"
|
2022-06-14 17:41:59 +00:00
|
|
|
"github.com/filecoin-project/lotus/storage/pipeline/sealiface"
|
2022-06-14 18:03:38 +00:00
|
|
|
"github.com/filecoin-project/lotus/storage/sealer"
|
2022-06-17 11:31:05 +00:00
|
|
|
"github.com/filecoin-project/lotus/storage/sealer/storiface"
|
2020-01-15 20:49:11 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
const SectorStorePrefix = "/sectors"
|
|
|
|
|
2020-09-11 11:28:09 +00:00
|
|
|
var ErrTooManySectorsSealing = xerrors.New("too many sectors sealing")
|
|
|
|
|
2020-01-15 20:49:11 +00:00
|
|
|
var log = logging.Logger("sectors")
|
|
|
|
|
2021-08-18 10:43:44 +00:00
|
|
|
//go:generate go run github.com/golang/mock/mockgen -destination=mocks/api.go -package=mocks . SealingAPI
|
|
|
|
|
2020-04-06 18:07:26 +00:00
|
|
|
type SealingAPI interface {
|
2022-06-16 10:47:19 +00:00
|
|
|
StateWaitMsg(ctx context.Context, cid cid.Cid, confidence uint64, limit abi.ChainEpoch, allowReplaced bool) (*api.MsgLookup, error)
|
|
|
|
StateSearchMsg(ctx context.Context, from types.TipSetKey, msg cid.Cid, limit abi.ChainEpoch, allowReplaced bool) (*api.MsgLookup, error)
|
2020-08-18 16:02:13 +00:00
|
|
|
|
2022-06-17 09:20:33 +00:00
|
|
|
StateSectorPreCommitInfo(ctx context.Context, maddr address.Address, sectorNumber abi.SectorNumber, tsk types.TipSetKey) (*miner.SectorPreCommitOnChainInfo, error)
|
|
|
|
StateComputeDataCID(ctx context.Context, maddr address.Address, sectorType abi.RegisteredSealProof, deals []abi.DealID, tsk types.TipSetKey) (cid.Cid, error)
|
|
|
|
StateSectorGetInfo(ctx context.Context, maddr address.Address, sectorNumber abi.SectorNumber, tsk types.TipSetKey) (*miner.SectorOnChainInfo, error)
|
|
|
|
StateSectorPartition(ctx context.Context, maddr address.Address, sectorNumber abi.SectorNumber, tsk types.TipSetKey) (*lminer.SectorLocation, error)
|
2022-06-16 09:12:33 +00:00
|
|
|
StateLookupID(context.Context, address.Address, types.TipSetKey) (address.Address, error)
|
|
|
|
StateMinerPreCommitDepositForPower(context.Context, address.Address, miner.SectorPreCommitInfo, types.TipSetKey) (big.Int, error)
|
|
|
|
StateMinerInitialPledgeCollateral(context.Context, address.Address, miner.SectorPreCommitInfo, types.TipSetKey) (big.Int, error)
|
|
|
|
StateMinerInfo(context.Context, address.Address, types.TipSetKey) (api.MinerInfo, error)
|
|
|
|
StateMinerAvailableBalance(context.Context, address.Address, types.TipSetKey) (big.Int, error)
|
|
|
|
StateMinerSectorAllocated(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (bool, error)
|
|
|
|
StateMarketStorageDeal(context.Context, abi.DealID, types.TipSetKey) (*api.MarketDeal, error)
|
2022-06-17 09:20:33 +00:00
|
|
|
StateNetworkVersion(ctx context.Context, tsk types.TipSetKey) (network.Version, error)
|
2022-06-16 09:12:33 +00:00
|
|
|
StateMinerProvingDeadline(context.Context, address.Address, types.TipSetKey) (*dline.Info, error)
|
2022-06-16 10:34:29 +00:00
|
|
|
StateMinerDeadlines(context.Context, address.Address, types.TipSetKey) ([]api.Deadline, error)
|
2022-06-17 09:20:33 +00:00
|
|
|
StateMinerPartitions(ctx context.Context, m address.Address, dlIdx uint64, tsk types.TipSetKey) ([]api.Partition, error)
|
2022-06-16 13:50:41 +00:00
|
|
|
MpoolPushMessage(context.Context, *types.Message, *api.MessageSendSpec) (*types.SignedMessage, error)
|
2023-04-10 18:52:39 +00:00
|
|
|
GasEstimateMessageGas(context.Context, *types.Message, *api.MessageSendSpec, types.TipSetKey) (*types.Message, error)
|
2022-06-16 11:15:49 +00:00
|
|
|
ChainHead(ctx context.Context) (*types.TipSet, error)
|
2021-01-25 10:28:39 +00:00
|
|
|
ChainGetMessage(ctx context.Context, mc cid.Cid) (*types.Message, error)
|
2022-06-17 09:20:33 +00:00
|
|
|
StateGetRandomnessFromBeacon(ctx context.Context, personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte, tsk types.TipSetKey) (abi.Randomness, error)
|
|
|
|
StateGetRandomnessFromTickets(ctx context.Context, personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte, tsk types.TipSetKey) (abi.Randomness, error)
|
2020-04-15 18:00:29 +00:00
|
|
|
ChainReadObj(context.Context, cid.Cid) ([]byte, error)
|
2022-08-22 18:41:56 +00:00
|
|
|
StateMinerAllocated(context.Context, address.Address, types.TipSetKey) (*bitfield.BitField, error)
|
2022-10-10 17:31:48 +00:00
|
|
|
StateGetAllocationForPendingDeal(ctx context.Context, dealId abi.DealID, tsk types.TipSetKey) (*verifregtypes.Allocation, error)
|
2022-08-09 10:57:20 +00:00
|
|
|
|
|
|
|
// Address selector
|
|
|
|
WalletBalance(context.Context, address.Address) (types.BigInt, error)
|
|
|
|
WalletHas(context.Context, address.Address) (bool, error)
|
|
|
|
StateAccountKey(context.Context, address.Address, types.TipSetKey) (address.Address, error)
|
2020-01-15 20:49:11 +00:00
|
|
|
}
|
|
|
|
|
2020-08-11 12:22:35 +00:00
|
|
|
type SectorStateNotifee func(before, after SectorInfo)
|
|
|
|
|
2022-06-16 14:05:56 +00:00
|
|
|
type Events interface {
|
|
|
|
ChainAt(ctx context.Context, hnd events.HeightHandler, rev events.RevertHandler, confidence int, h abi.ChainEpoch) error
|
|
|
|
}
|
|
|
|
|
2022-08-09 10:57:20 +00:00
|
|
|
type AddressSelector interface {
|
|
|
|
AddressFor(ctx context.Context, a ctladdr.NodeApi, mi api.MinerInfo, use api.AddrUse, goodFunds, minFunds abi.TokenAmount) (address.Address, abi.TokenAmount, error)
|
|
|
|
}
|
|
|
|
|
2020-01-15 20:49:11 +00:00
|
|
|
type Sealing struct {
|
2021-08-18 10:43:44 +00:00
|
|
|
Api SealingAPI
|
|
|
|
DealInfo *CurrentDealInfoManager
|
|
|
|
|
2022-08-17 15:53:44 +00:00
|
|
|
ds datastore.Batching
|
|
|
|
|
2021-06-08 13:43:43 +00:00
|
|
|
feeCfg config.MinerFeeConfig
|
2020-04-06 18:07:26 +00:00
|
|
|
events Events
|
2020-01-15 20:49:11 +00:00
|
|
|
|
2021-06-15 19:04:11 +00:00
|
|
|
startupWait sync.WaitGroup
|
|
|
|
|
2020-04-09 17:34:07 +00:00
|
|
|
maddr address.Address
|
2020-01-15 20:49:11 +00:00
|
|
|
|
2022-06-14 18:03:38 +00:00
|
|
|
sealer sealer.SectorManager
|
2020-01-15 20:49:11 +00:00
|
|
|
sectors *statemachine.StateGroup
|
2022-06-17 11:52:19 +00:00
|
|
|
verif storiface.Verifier
|
2021-01-18 13:26:03 +00:00
|
|
|
pcp PreCommitPolicy
|
2020-04-07 22:26:07 +00:00
|
|
|
|
2021-01-20 15:00:00 +00:00
|
|
|
inputLk sync.Mutex
|
|
|
|
openSectors map[abi.SectorID]*openSector
|
|
|
|
sectorTimers map[abi.SectorID]*time.Timer
|
|
|
|
pendingPieces map[cid.Cid]*pendingPiece
|
|
|
|
assignedPieces map[abi.SectorID][]cid.Cid
|
2022-03-16 20:29:57 +00:00
|
|
|
nextDealSector *abi.SectorNumber // used to prevent a race where we could create a new sector more than once
|
2020-07-01 13:30:25 +00:00
|
|
|
|
2022-03-16 16:33:05 +00:00
|
|
|
available map[abi.SectorID]struct{}
|
|
|
|
|
2022-08-09 10:42:35 +00:00
|
|
|
journal journal.Journal
|
|
|
|
sealingEvtType journal.EventType
|
|
|
|
notifee SectorStateNotifee
|
2022-08-09 10:57:20 +00:00
|
|
|
addrSel AddressSelector
|
2020-08-26 15:38:23 +00:00
|
|
|
|
2020-08-18 14:54:05 +00:00
|
|
|
stats SectorStats
|
|
|
|
|
2021-05-18 14:51:06 +00:00
|
|
|
terminator *TerminateBatcher
|
|
|
|
precommiter *PreCommitBatcher
|
|
|
|
commiter *CommitBatcher
|
2021-01-12 23:42:01 +00:00
|
|
|
|
2022-08-17 15:53:44 +00:00
|
|
|
sclk sync.Mutex
|
|
|
|
legacySc *storedcounter.StoredCounter
|
|
|
|
|
2022-08-09 11:30:34 +00:00
|
|
|
getConfig dtypes.GetSealingConfigFunc
|
2020-06-23 21:47:53 +00:00
|
|
|
}
|
|
|
|
|
2021-01-18 13:26:03 +00:00
|
|
|
type openSector struct {
|
2022-10-04 18:12:25 +00:00
|
|
|
used abi.UnpaddedPieceSize // change to bitfield/rle when AddPiece gains offset support to better fill sectors
|
|
|
|
lastDealEnd abi.ChainEpoch
|
|
|
|
number abi.SectorNumber
|
|
|
|
ccUpdate bool
|
2021-01-18 13:26:03 +00:00
|
|
|
|
2021-01-20 15:00:00 +00:00
|
|
|
maybeAccept func(cid.Cid) error // called with inputLk
|
2020-07-09 22:27:19 +00:00
|
|
|
}
|
|
|
|
|
2022-10-04 18:12:25 +00:00
|
|
|
func (o *openSector) checkDealAssignable(piece *pendingPiece, expF expFn) (bool, error) {
|
2022-12-09 08:54:28 +00:00
|
|
|
log := log.With(
|
|
|
|
"sector", o.number,
|
|
|
|
|
|
|
|
"deal", piece.deal.DealID,
|
|
|
|
"dealEnd", piece.deal.DealProposal.EndEpoch,
|
|
|
|
"dealStart", piece.deal.DealProposal.StartEpoch,
|
|
|
|
"dealClaimEnd", piece.claimTerms.claimTermEnd,
|
|
|
|
|
|
|
|
"lastAssignedDealEnd", o.lastDealEnd,
|
|
|
|
"update", o.ccUpdate,
|
|
|
|
)
|
|
|
|
|
2022-10-04 18:12:25 +00:00
|
|
|
// if there are deals assigned, check that no assigned deal expires after termMax
|
|
|
|
if o.lastDealEnd > piece.claimTerms.claimTermEnd {
|
2022-12-09 08:54:28 +00:00
|
|
|
log.Debugw("deal not assignable to sector", "reason", "term end beyond last assigned deal end")
|
2022-10-04 18:12:25 +00:00
|
|
|
return false, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// check that in case of upgrade sectors, sector expiration is at least deal expiration
|
2021-12-08 17:11:19 +00:00
|
|
|
if !o.ccUpdate {
|
|
|
|
return true, nil
|
|
|
|
}
|
2022-10-04 18:12:25 +00:00
|
|
|
sectorExpiration, _, err := expF(o.number)
|
2021-12-08 17:11:19 +00:00
|
|
|
if err != nil {
|
2022-12-09 08:54:28 +00:00
|
|
|
log.Debugw("deal not assignable to sector", "reason", "error getting sector expiranion", "error", err)
|
2021-12-08 17:11:19 +00:00
|
|
|
return false, err
|
|
|
|
}
|
2022-10-04 18:12:25 +00:00
|
|
|
|
2022-12-09 08:54:28 +00:00
|
|
|
log = log.With(
|
|
|
|
"sectorExpiration", sectorExpiration,
|
|
|
|
)
|
|
|
|
|
2022-10-04 18:12:25 +00:00
|
|
|
// check that in case of upgrade sector, it's expiration isn't above deals claim TermMax
|
|
|
|
if sectorExpiration > piece.claimTerms.claimTermEnd {
|
2022-12-09 08:54:28 +00:00
|
|
|
log.Debugw("deal not assignable to sector", "reason", "term end beyond sector expiration")
|
|
|
|
return false, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
if sectorExpiration < piece.deal.DealProposal.EndEpoch {
|
|
|
|
log.Debugw("deal not assignable to sector", "reason", "sector expiration less than deal expiration")
|
2022-10-04 18:12:25 +00:00
|
|
|
return false, nil
|
|
|
|
}
|
|
|
|
|
2022-12-09 08:54:28 +00:00
|
|
|
return true, nil
|
2021-12-08 17:11:19 +00:00
|
|
|
}
|
|
|
|
|
2022-02-21 07:51:25 +00:00
|
|
|
type pieceAcceptResp struct {
|
|
|
|
sn abi.SectorNumber
|
|
|
|
offset abi.UnpaddedPieceSize
|
|
|
|
err error
|
|
|
|
}
|
|
|
|
|
2022-10-04 18:12:25 +00:00
|
|
|
type pieceClaimBounds struct {
|
|
|
|
// dealStart + termMax
|
|
|
|
claimTermEnd abi.ChainEpoch
|
|
|
|
}
|
|
|
|
|
2021-01-18 13:26:03 +00:00
|
|
|
type pendingPiece struct {
|
2022-02-21 09:51:43 +00:00
|
|
|
doneCh chan struct{}
|
2022-02-21 14:27:51 +00:00
|
|
|
resp *pieceAcceptResp
|
2022-02-21 07:51:25 +00:00
|
|
|
|
2021-01-18 13:26:03 +00:00
|
|
|
size abi.UnpaddedPieceSize
|
2021-05-19 11:05:07 +00:00
|
|
|
deal api.PieceDealInfo
|
2021-01-18 13:26:03 +00:00
|
|
|
|
2022-10-04 18:12:25 +00:00
|
|
|
claimTerms pieceClaimBounds
|
|
|
|
|
2022-06-17 11:31:05 +00:00
|
|
|
data storiface.Data
|
2021-01-18 13:26:03 +00:00
|
|
|
|
|
|
|
assigned bool // assigned to a sector?
|
|
|
|
accepted func(abi.SectorNumber, abi.UnpaddedPieceSize, error)
|
2020-01-15 20:49:11 +00:00
|
|
|
}
|
|
|
|
|
2022-08-17 15:53:44 +00:00
|
|
|
func New(mctx context.Context, api SealingAPI, fc config.MinerFeeConfig, events Events, maddr address.Address, ds datastore.Batching, sealer sealer.SectorManager, verif storiface.Verifier, prov storiface.Prover, pcp PreCommitPolicy, gc dtypes.GetSealingConfigFunc, journal journal.Journal, addrSel AddressSelector) *Sealing {
|
2020-01-15 20:49:11 +00:00
|
|
|
s := &Sealing{
|
2021-08-18 10:43:44 +00:00
|
|
|
Api: api,
|
|
|
|
DealInfo: &CurrentDealInfoManager{api},
|
|
|
|
|
2022-08-17 15:53:44 +00:00
|
|
|
ds: ds,
|
|
|
|
|
2020-08-12 17:47:00 +00:00
|
|
|
feeCfg: fc,
|
2020-01-15 20:49:11 +00:00
|
|
|
events: events,
|
|
|
|
|
2020-07-09 22:27:19 +00:00
|
|
|
maddr: maddr,
|
|
|
|
sealer: sealer,
|
|
|
|
verif: verif,
|
|
|
|
pcp: pcp,
|
2020-07-01 14:33:59 +00:00
|
|
|
|
2021-01-20 15:00:00 +00:00
|
|
|
openSectors: map[abi.SectorID]*openSector{},
|
|
|
|
sectorTimers: map[abi.SectorID]*time.Timer{},
|
|
|
|
pendingPieces: map[cid.Cid]*pendingPiece{},
|
|
|
|
assignedPieces: map[abi.SectorID][]cid.Cid{},
|
2020-08-26 15:38:23 +00:00
|
|
|
|
2022-03-16 16:33:05 +00:00
|
|
|
available: map[abi.SectorID]struct{}{},
|
|
|
|
|
2022-08-09 10:42:35 +00:00
|
|
|
journal: journal,
|
|
|
|
sealingEvtType: journal.RegisterEventType("storage", "sealing_states"),
|
|
|
|
|
2022-08-09 10:57:20 +00:00
|
|
|
addrSel: addrSel,
|
2020-08-26 15:38:23 +00:00
|
|
|
|
2022-08-09 10:57:20 +00:00
|
|
|
terminator: NewTerminationBatcher(mctx, maddr, api, addrSel, fc, gc),
|
|
|
|
precommiter: NewPreCommitBatcher(mctx, maddr, api, addrSel, fc, gc),
|
|
|
|
commiter: NewCommitBatcher(mctx, maddr, api, addrSel, fc, gc, prov),
|
2021-01-12 23:42:01 +00:00
|
|
|
|
2020-08-18 14:20:31 +00:00
|
|
|
getConfig: gc,
|
2020-08-18 16:02:13 +00:00
|
|
|
|
2022-08-17 15:53:44 +00:00
|
|
|
legacySc: storedcounter.New(ds, datastore.NewKey(StorageCounterDSPrefix)),
|
|
|
|
|
2020-08-18 16:02:13 +00:00
|
|
|
stats: SectorStats{
|
2021-10-19 16:52:54 +00:00
|
|
|
bySector: map[abi.SectorID]SectorState{},
|
|
|
|
byState: map[SectorState]int64{},
|
2020-08-18 16:02:13 +00:00
|
|
|
},
|
2020-01-15 20:49:11 +00:00
|
|
|
}
|
2022-08-09 10:42:35 +00:00
|
|
|
|
|
|
|
s.notifee = func(before, after SectorInfo) {
|
|
|
|
s.journal.RecordEvent(s.sealingEvtType, func() interface{} {
|
|
|
|
return SealingStateEvt{
|
|
|
|
SectorNumber: before.SectorNumber,
|
|
|
|
SectorType: before.SectorType,
|
|
|
|
From: before.State,
|
|
|
|
After: after.State,
|
|
|
|
Error: after.LastErr,
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2021-06-15 19:04:11 +00:00
|
|
|
s.startupWait.Add(1)
|
2020-01-15 20:49:11 +00:00
|
|
|
|
|
|
|
s.sectors = statemachine.New(namespace.Wrap(ds, datastore.NewKey(SectorStorePrefix)), s, SectorInfo{})
|
|
|
|
|
|
|
|
return s
|
|
|
|
}
|
|
|
|
|
2022-08-09 11:43:08 +00:00
|
|
|
func (m *Sealing) Run(ctx context.Context) {
|
2020-01-15 20:49:11 +00:00
|
|
|
if err := m.restartSectors(ctx); err != nil {
|
2022-08-09 11:43:08 +00:00
|
|
|
log.Errorf("failed load sector states: %+v", err)
|
2020-01-15 20:49:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *Sealing) Stop(ctx context.Context) error {
|
2021-01-12 23:42:01 +00:00
|
|
|
if err := m.terminator.Stop(ctx); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := m.sectors.Stop(ctx); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
2020-01-15 20:49:11 +00:00
|
|
|
}
|
2020-11-04 20:29:08 +00:00
|
|
|
|
2022-08-09 11:30:34 +00:00
|
|
|
func (m *Sealing) RemoveSector(ctx context.Context, sid abi.SectorNumber) error {
|
2021-06-15 19:04:11 +00:00
|
|
|
m.startupWait.Wait()
|
|
|
|
|
2020-06-23 19:32:22 +00:00
|
|
|
return m.sectors.Send(uint64(sid), SectorRemove{})
|
|
|
|
}
|
|
|
|
|
2022-08-09 11:30:34 +00:00
|
|
|
func (m *Sealing) TerminateSector(ctx context.Context, sid abi.SectorNumber) error {
|
2021-06-15 19:04:11 +00:00
|
|
|
m.startupWait.Wait()
|
|
|
|
|
2021-01-12 23:42:01 +00:00
|
|
|
return m.sectors.Send(uint64(sid), SectorTerminate{})
|
|
|
|
}
|
|
|
|
|
2023-10-25 16:32:02 +00:00
|
|
|
func (m *Sealing) SectorsSummary(ctx context.Context) map[SectorState]int64 {
|
|
|
|
return m.stats.byState
|
|
|
|
}
|
|
|
|
|
2021-01-13 22:32:04 +00:00
|
|
|
func (m *Sealing) TerminateFlush(ctx context.Context) (*cid.Cid, error) {
|
|
|
|
return m.terminator.Flush(ctx)
|
|
|
|
}
|
|
|
|
|
2021-01-14 11:37:23 +00:00
|
|
|
func (m *Sealing) TerminatePending(ctx context.Context) ([]abi.SectorID, error) {
|
|
|
|
return m.terminator.Pending(ctx)
|
|
|
|
}
|
|
|
|
|
2021-06-01 12:35:30 +00:00
|
|
|
func (m *Sealing) SectorPreCommitFlush(ctx context.Context) ([]sealiface.PreCommitBatchRes, error) {
|
2021-05-18 14:51:06 +00:00
|
|
|
return m.precommiter.Flush(ctx)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *Sealing) SectorPreCommitPending(ctx context.Context) ([]abi.SectorID, error) {
|
|
|
|
return m.precommiter.Pending(ctx)
|
|
|
|
}
|
|
|
|
|
2021-06-01 09:56:19 +00:00
|
|
|
func (m *Sealing) CommitFlush(ctx context.Context) ([]sealiface.CommitBatchRes, error) {
|
2021-03-10 15:16:44 +00:00
|
|
|
return m.commiter.Flush(ctx)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *Sealing) CommitPending(ctx context.Context) ([]abi.SectorID, error) {
|
|
|
|
return m.commiter.Pending(ctx)
|
|
|
|
}
|
|
|
|
|
2020-11-04 20:29:08 +00:00
|
|
|
func (m *Sealing) currentSealProof(ctx context.Context) (abi.RegisteredSealProof, error) {
|
2022-06-16 09:12:33 +00:00
|
|
|
mi, err := m.Api.StateMinerInfo(ctx, m.maddr, types.EmptyTSK)
|
2020-11-04 20:29:08 +00:00
|
|
|
if err != nil {
|
|
|
|
return 0, err
|
|
|
|
}
|
|
|
|
|
2022-06-16 09:12:33 +00:00
|
|
|
ver, err := m.Api.StateNetworkVersion(ctx, types.EmptyTSK)
|
2021-01-20 02:06:00 +00:00
|
|
|
if err != nil {
|
|
|
|
return 0, err
|
|
|
|
}
|
|
|
|
|
2023-06-09 16:21:31 +00:00
|
|
|
c, err := m.getConfig()
|
|
|
|
if err != nil {
|
|
|
|
return 0, err
|
|
|
|
}
|
|
|
|
|
2023-07-12 11:51:50 +00:00
|
|
|
return lminer.PreferredSealProofTypeFromWindowPoStType(ver, mi.WindowPoStProofType, c.UseSyntheticPoRep)
|
2020-11-04 20:29:08 +00:00
|
|
|
}
|
|
|
|
|
2022-06-17 11:31:05 +00:00
|
|
|
func (m *Sealing) minerSector(spt abi.RegisteredSealProof, num abi.SectorNumber) storiface.SectorRef {
|
|
|
|
return storiface.SectorRef{
|
2020-11-04 20:29:08 +00:00
|
|
|
ID: m.minerSectorID(num),
|
|
|
|
ProofType: spt,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *Sealing) minerSectorID(num abi.SectorNumber) abi.SectorID {
|
2020-03-17 20:19:52 +00:00
|
|
|
mid, err := address.IDFromAddress(m.maddr)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return abi.SectorID{
|
|
|
|
Number: num,
|
2020-03-18 01:08:11 +00:00
|
|
|
Miner: abi.ActorID(mid),
|
2020-03-17 20:19:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *Sealing) Address() address.Address {
|
|
|
|
return m.maddr
|
|
|
|
}
|
2020-07-20 16:43:19 +00:00
|
|
|
|
2021-01-20 17:18:12 +00:00
|
|
|
func getDealPerSectorLimit(size abi.SectorSize) (int, error) {
|
2020-07-20 16:43:19 +00:00
|
|
|
if size < 64<<30 {
|
2021-01-20 14:20:44 +00:00
|
|
|
return 256, nil
|
2020-07-20 16:43:19 +00:00
|
|
|
}
|
2021-01-20 14:20:44 +00:00
|
|
|
return 512, nil
|
2020-07-20 16:43:19 +00:00
|
|
|
}
|