2020-01-15 20:49:11 +00:00
|
|
|
package storage
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2021-01-13 22:32:04 +00:00
|
|
|
"github.com/ipfs/go-cid"
|
2021-05-19 11:05:07 +00:00
|
|
|
"golang.org/x/xerrors"
|
2021-01-13 22:32:04 +00:00
|
|
|
|
2020-04-06 20:23:37 +00:00
|
|
|
"github.com/filecoin-project/go-address"
|
2020-09-07 03:49:10 +00:00
|
|
|
"github.com/filecoin-project/go-state-types/abi"
|
2021-05-19 11:05:07 +00:00
|
|
|
"github.com/filecoin-project/go-state-types/big"
|
2021-02-16 16:41:29 +00:00
|
|
|
"github.com/filecoin-project/specs-storage/storage"
|
2020-02-08 02:18:32 +00:00
|
|
|
|
2021-05-19 11:05:07 +00:00
|
|
|
"github.com/filecoin-project/lotus/api"
|
2020-08-17 13:39:33 +00:00
|
|
|
sealing "github.com/filecoin-project/lotus/extern/storage-sealing"
|
2021-06-01 09:56:19 +00:00
|
|
|
"github.com/filecoin-project/lotus/extern/storage-sealing/sealiface"
|
2021-05-19 11:22:00 +00:00
|
|
|
"github.com/filecoin-project/lotus/storage/sectorblocks"
|
2020-01-15 20:49:11 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// TODO: refactor this to be direct somehow
|
|
|
|
|
2020-03-17 20:19:52 +00:00
|
|
|
func (m *Miner) Address() address.Address {
|
|
|
|
return m.sealing.Address()
|
|
|
|
}
|
|
|
|
|
2020-06-26 15:28:05 +00:00
|
|
|
func (m *Miner) StartPackingSector(sectorNum abi.SectorNumber) error {
|
|
|
|
return m.sealing.StartPacking(sectorNum)
|
|
|
|
}
|
|
|
|
|
2020-01-15 20:49:11 +00:00
|
|
|
func (m *Miner) ListSectors() ([]sealing.SectorInfo, error) {
|
|
|
|
return m.sealing.ListSectors()
|
|
|
|
}
|
|
|
|
|
2021-02-16 16:41:29 +00:00
|
|
|
func (m *Miner) PledgeSector(ctx context.Context) (storage.SectorRef, error) {
|
2021-02-16 16:14:59 +00:00
|
|
|
return m.sealing.PledgeSector(ctx)
|
2020-01-15 20:49:11 +00:00
|
|
|
}
|
|
|
|
|
2020-04-06 20:23:37 +00:00
|
|
|
func (m *Miner) ForceSectorState(ctx context.Context, id abi.SectorNumber, state sealing.SectorState) error {
|
2020-01-15 20:49:11 +00:00
|
|
|
return m.sealing.ForceSectorState(ctx, id, state)
|
|
|
|
}
|
2020-06-22 17:35:14 +00:00
|
|
|
|
|
|
|
func (m *Miner) RemoveSector(ctx context.Context, id abi.SectorNumber) error {
|
|
|
|
return m.sealing.Remove(ctx, id)
|
|
|
|
}
|
2020-07-01 14:49:17 +00:00
|
|
|
|
2021-01-12 23:42:01 +00:00
|
|
|
func (m *Miner) TerminateSector(ctx context.Context, id abi.SectorNumber) error {
|
|
|
|
return m.sealing.Terminate(ctx, id)
|
|
|
|
}
|
|
|
|
|
2021-01-13 22:32:04 +00:00
|
|
|
func (m *Miner) TerminateFlush(ctx context.Context) (*cid.Cid, error) {
|
|
|
|
return m.sealing.TerminateFlush(ctx)
|
|
|
|
}
|
|
|
|
|
2021-01-14 11:37:23 +00:00
|
|
|
func (m *Miner) TerminatePending(ctx context.Context) ([]abi.SectorID, error) {
|
|
|
|
return m.sealing.TerminatePending(ctx)
|
|
|
|
}
|
|
|
|
|
2021-06-01 12:35:30 +00:00
|
|
|
func (m *Miner) SectorPreCommitFlush(ctx context.Context) ([]sealiface.PreCommitBatchRes, error) {
|
2021-05-18 14:51:06 +00:00
|
|
|
return m.sealing.SectorPreCommitFlush(ctx)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *Miner) SectorPreCommitPending(ctx context.Context) ([]abi.SectorID, error) {
|
|
|
|
return m.sealing.SectorPreCommitPending(ctx)
|
|
|
|
}
|
|
|
|
|
2021-06-01 09:56:19 +00:00
|
|
|
func (m *Miner) CommitFlush(ctx context.Context) ([]sealiface.CommitBatchRes, error) {
|
2021-03-10 15:16:44 +00:00
|
|
|
return m.sealing.CommitFlush(ctx)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *Miner) CommitPending(ctx context.Context) ([]abi.SectorID, error) {
|
|
|
|
return m.sealing.CommitPending(ctx)
|
|
|
|
}
|
|
|
|
|
2021-12-08 17:11:19 +00:00
|
|
|
func (m *Miner) SectorMatchPendingPiecesToOpenSectors(ctx context.Context) error {
|
|
|
|
return m.sealing.MatchPendingPiecesToOpenSectors(ctx)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *Miner) MarkForUpgrade(ctx context.Context, id abi.SectorNumber, snap bool) error {
|
|
|
|
if snap {
|
|
|
|
return m.sealing.MarkForSnapUpgrade(ctx, id)
|
|
|
|
}
|
2022-03-01 18:27:03 +00:00
|
|
|
return xerrors.Errorf("Old CC upgrade deprecated, use snap deals CC upgrade")
|
2020-08-21 19:43:30 +00:00
|
|
|
}
|
2021-05-19 11:05:07 +00:00
|
|
|
|
2022-01-21 17:39:18 +00:00
|
|
|
func (m *Miner) SectorAbortUpgrade(sectorNum abi.SectorNumber) error {
|
|
|
|
return m.sealing.AbortUpgrade(sectorNum)
|
|
|
|
}
|
|
|
|
|
2021-05-19 11:05:07 +00:00
|
|
|
func (m *Miner) SectorAddPieceToAny(ctx context.Context, size abi.UnpaddedPieceSize, r storage.Data, d api.PieceDealInfo) (api.SectorOffset, error) {
|
|
|
|
return m.sealing.SectorAddPieceToAny(ctx, size, r, d)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *Miner) SectorsStatus(ctx context.Context, sid abi.SectorNumber, showOnChainInfo bool) (api.SectorInfo, error) {
|
|
|
|
if showOnChainInfo {
|
|
|
|
return api.SectorInfo{}, xerrors.Errorf("on-chain info not supported")
|
|
|
|
}
|
|
|
|
|
|
|
|
info, err := m.sealing.GetSectorInfo(sid)
|
|
|
|
if err != nil {
|
|
|
|
return api.SectorInfo{}, err
|
|
|
|
}
|
|
|
|
|
|
|
|
deals := make([]abi.DealID, len(info.Pieces))
|
2021-09-02 19:44:26 +00:00
|
|
|
pieces := make([]api.SectorPiece, len(info.Pieces))
|
2021-05-19 11:05:07 +00:00
|
|
|
for i, piece := range info.Pieces {
|
2021-09-02 19:44:26 +00:00
|
|
|
pieces[i].Piece = piece.Piece
|
2021-05-19 11:05:07 +00:00
|
|
|
if piece.DealInfo == nil {
|
|
|
|
continue
|
|
|
|
}
|
2021-09-02 19:44:26 +00:00
|
|
|
|
|
|
|
pdi := *piece.DealInfo // copy
|
|
|
|
pieces[i].DealInfo = &pdi
|
|
|
|
|
2021-05-19 11:05:07 +00:00
|
|
|
deals[i] = piece.DealInfo.DealID
|
|
|
|
}
|
|
|
|
|
|
|
|
log := make([]api.SectorLog, len(info.Log))
|
|
|
|
for i, l := range info.Log {
|
|
|
|
log[i] = api.SectorLog{
|
|
|
|
Kind: l.Kind,
|
|
|
|
Timestamp: l.Timestamp,
|
|
|
|
Trace: l.Trace,
|
|
|
|
Message: l.Message,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sInfo := api.SectorInfo{
|
|
|
|
SectorID: sid,
|
|
|
|
State: api.SectorState(info.State),
|
|
|
|
CommD: info.CommD,
|
|
|
|
CommR: info.CommR,
|
|
|
|
Proof: info.Proof,
|
|
|
|
Deals: deals,
|
2021-09-02 19:44:26 +00:00
|
|
|
Pieces: pieces,
|
2021-05-19 11:05:07 +00:00
|
|
|
Ticket: api.SealTicket{
|
|
|
|
Value: info.TicketValue,
|
|
|
|
Epoch: info.TicketEpoch,
|
|
|
|
},
|
|
|
|
Seed: api.SealSeed{
|
|
|
|
Value: info.SeedValue,
|
|
|
|
Epoch: info.SeedEpoch,
|
|
|
|
},
|
|
|
|
PreCommitMsg: info.PreCommitMessage,
|
|
|
|
CommitMsg: info.CommitMessage,
|
|
|
|
Retries: info.InvalidProofs,
|
2022-03-01 18:27:03 +00:00
|
|
|
ToUpgrade: false,
|
2021-05-19 11:05:07 +00:00
|
|
|
|
|
|
|
LastErr: info.LastErr,
|
|
|
|
Log: log,
|
|
|
|
// on chain info
|
2021-07-21 13:49:45 +00:00
|
|
|
SealProof: info.SectorType,
|
2021-05-19 11:05:07 +00:00
|
|
|
Activation: 0,
|
|
|
|
Expiration: 0,
|
|
|
|
DealWeight: big.Zero(),
|
|
|
|
VerifiedDealWeight: big.Zero(),
|
|
|
|
InitialPledge: big.Zero(),
|
|
|
|
OnTime: 0,
|
|
|
|
Early: 0,
|
|
|
|
}
|
|
|
|
|
|
|
|
return sInfo, nil
|
|
|
|
}
|
2021-05-19 11:22:00 +00:00
|
|
|
|
|
|
|
var _ sectorblocks.SectorBuilder = &Miner{}
|