2019-11-01 12:01:16 +00:00
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
2020-03-03 22:19:22 +00:00
|
|
|
"bytes"
|
2019-11-01 12:01:16 +00:00
|
|
|
"context"
|
2020-07-08 18:35:55 +00:00
|
|
|
"time"
|
|
|
|
|
2020-10-22 20:40:26 +00:00
|
|
|
datatransfer "github.com/filecoin-project/go-data-transfer"
|
2020-10-18 10:35:44 +00:00
|
|
|
"github.com/google/uuid"
|
2020-07-08 18:35:55 +00:00
|
|
|
"github.com/ipfs/go-cid"
|
2020-10-22 20:40:26 +00:00
|
|
|
"github.com/libp2p/go-libp2p-core/peer"
|
2020-07-08 18:35:55 +00:00
|
|
|
|
2019-12-19 20:13:17 +00:00
|
|
|
"github.com/filecoin-project/go-address"
|
2020-07-27 17:59:30 +00:00
|
|
|
"github.com/filecoin-project/go-fil-markets/piecestore"
|
2020-07-28 21:35:23 +00:00
|
|
|
"github.com/filecoin-project/go-fil-markets/retrievalmarket"
|
2020-03-13 11:59:19 +00:00
|
|
|
"github.com/filecoin-project/go-fil-markets/storagemarket"
|
2020-09-07 03:49:10 +00:00
|
|
|
"github.com/filecoin-project/go-state-types/abi"
|
2020-06-01 12:59:51 +00:00
|
|
|
"github.com/filecoin-project/lotus/chain/types"
|
2020-08-17 13:26:18 +00:00
|
|
|
"github.com/filecoin-project/lotus/extern/sector-storage/fsutil"
|
|
|
|
"github.com/filecoin-project/lotus/extern/sector-storage/stores"
|
|
|
|
"github.com/filecoin-project/lotus/extern/sector-storage/storiface"
|
2020-11-26 07:02:43 +00:00
|
|
|
"github.com/filecoin-project/specs-storage/storage"
|
2019-11-01 12:01:16 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// StorageMiner is a low-level interface to the Filecoin network storage miner node
|
|
|
|
type StorageMiner interface {
|
|
|
|
Common
|
|
|
|
|
|
|
|
ActorAddress(context.Context) (address.Address, error)
|
|
|
|
|
2020-02-09 06:06:32 +00:00
|
|
|
ActorSectorSize(context.Context, address.Address) (abi.SectorSize, error)
|
2019-11-21 14:10:51 +00:00
|
|
|
|
2020-04-23 21:12:42 +00:00
|
|
|
MiningBase(context.Context) (*types.TipSet, error)
|
|
|
|
|
2019-11-01 12:01:16 +00:00
|
|
|
// Temp api for testing
|
2019-12-08 21:48:20 +00:00
|
|
|
PledgeSector(context.Context) error
|
2019-11-01 12:01:16 +00:00
|
|
|
|
|
|
|
// Get the status of a given sector by ID
|
2020-07-24 08:04:04 +00:00
|
|
|
SectorsStatus(ctx context.Context, sid abi.SectorNumber, showOnChainInfo bool) (SectorInfo, error)
|
2019-11-01 12:01:16 +00:00
|
|
|
|
|
|
|
// List all staged sectors
|
2020-02-09 06:06:32 +00:00
|
|
|
SectorsList(context.Context) ([]abi.SectorNumber, error)
|
2019-11-01 12:01:16 +00:00
|
|
|
|
|
|
|
SectorsRefs(context.Context) (map[string][]SealedRef, error)
|
2019-11-08 18:15:13 +00:00
|
|
|
|
2020-07-06 18:39:26 +00:00
|
|
|
// SectorStartSealing can be called on sectors in Empty or WaitDeals states
|
2020-06-26 15:28:05 +00:00
|
|
|
// to trigger sealing early
|
|
|
|
SectorStartSealing(context.Context, abi.SectorNumber) error
|
2020-07-06 18:39:26 +00:00
|
|
|
// SectorSetSealDelay sets the time that a newly-created sector
|
|
|
|
// waits for more deals before it starts sealing
|
|
|
|
SectorSetSealDelay(context.Context, time.Duration) error
|
|
|
|
// SectorGetSealDelay gets the time that a newly-created sector
|
|
|
|
// waits for more deals before it starts sealing
|
|
|
|
SectorGetSealDelay(context.Context) (time.Duration, error)
|
2020-07-12 17:54:53 +00:00
|
|
|
// SectorSetExpectedSealDuration sets the expected time for a sector to seal
|
|
|
|
SectorSetExpectedSealDuration(context.Context, time.Duration) error
|
|
|
|
// SectorGetExpectedSealDuration gets the expected time for a sector to seal
|
|
|
|
SectorGetExpectedSealDuration(context.Context) (time.Duration, error)
|
2020-04-23 22:33:59 +00:00
|
|
|
SectorsUpdate(context.Context, abi.SectorNumber, SectorState) error
|
2020-06-22 17:35:14 +00:00
|
|
|
SectorRemove(context.Context, abi.SectorNumber) error
|
2020-07-01 14:49:17 +00:00
|
|
|
SectorMarkForUpgrade(ctx context.Context, id abi.SectorNumber) error
|
2019-12-05 04:43:54 +00:00
|
|
|
|
2020-03-16 17:50:07 +00:00
|
|
|
StorageList(ctx context.Context) (map[stores.ID][]stores.Decl, error)
|
2020-03-19 19:51:33 +00:00
|
|
|
StorageLocal(ctx context.Context) (map[stores.ID]string, error)
|
2020-07-08 15:23:27 +00:00
|
|
|
StorageStat(ctx context.Context, id stores.ID) (fsutil.FsStat, error)
|
2020-03-16 17:50:07 +00:00
|
|
|
|
2020-03-11 01:57:52 +00:00
|
|
|
// WorkerConnect tells the node to connect to workers RPC
|
|
|
|
WorkerConnect(context.Context, string) error
|
2020-10-18 10:35:44 +00:00
|
|
|
WorkerStats(context.Context) (map[uuid.UUID]storiface.WorkerStats, error)
|
|
|
|
WorkerJobs(context.Context) (map[uuid.UUID][]storiface.WorkerJob, error)
|
2020-09-06 16:47:16 +00:00
|
|
|
storiface.WorkerReturn
|
2020-03-23 14:56:22 +00:00
|
|
|
|
2020-07-27 11:23:43 +00:00
|
|
|
// SealingSchedDiag dumps internal sealing scheduler state
|
2020-10-30 10:07:35 +00:00
|
|
|
SealingSchedDiag(ctx context.Context, doSched bool) (interface{}, error)
|
2020-11-11 16:39:12 +00:00
|
|
|
SealingAbort(ctx context.Context, call storiface.CallID) error
|
2020-07-27 11:23:43 +00:00
|
|
|
|
2020-03-13 11:59:19 +00:00
|
|
|
stores.SectorIndex
|
2019-11-21 00:52:59 +00:00
|
|
|
|
2020-02-08 00:18:14 +00:00
|
|
|
MarketImportDealData(ctx context.Context, propcid cid.Cid, path string) error
|
2020-09-17 07:32:10 +00:00
|
|
|
MarketListDeals(ctx context.Context) ([]MarketDeal, error)
|
2020-08-04 23:40:29 +00:00
|
|
|
MarketListRetrievalDeals(ctx context.Context) ([]retrievalmarket.ProviderDealState, error)
|
2020-09-02 17:58:44 +00:00
|
|
|
MarketGetDealUpdates(ctx context.Context) (<-chan storagemarket.MinerDeal, error)
|
2020-02-08 00:18:14 +00:00
|
|
|
MarketListIncompleteDeals(ctx context.Context) ([]storagemarket.MinerDeal, error)
|
2020-07-31 19:14:48 +00:00
|
|
|
MarketSetAsk(ctx context.Context, price types.BigInt, verifiedPrice types.BigInt, duration abi.ChainEpoch, minPieceSize abi.PaddedPieceSize, maxPieceSize abi.PaddedPieceSize) error
|
2020-06-17 00:18:54 +00:00
|
|
|
MarketGetAsk(ctx context.Context) (*storagemarket.SignedStorageAsk, error)
|
2020-07-28 21:35:23 +00:00
|
|
|
MarketSetRetrievalAsk(ctx context.Context, rask *retrievalmarket.Ask) error
|
|
|
|
MarketGetRetrievalAsk(ctx context.Context) (*retrievalmarket.Ask, error)
|
2020-08-20 08:18:05 +00:00
|
|
|
MarketListDataTransfers(ctx context.Context) ([]DataTransferChannel, error)
|
|
|
|
MarketDataTransferUpdates(ctx context.Context) (<-chan DataTransferChannel, error)
|
2020-10-22 20:40:26 +00:00
|
|
|
// MinerRestartDataTransfer attempts to restart a data transfer with the given transfer ID and other peer
|
|
|
|
MarketRestartDataTransfer(ctx context.Context, transferID datatransfer.TransferID, otherPeer peer.ID, isInitiator bool) error
|
|
|
|
// ClientCancelDataTransfer cancels a data transfer with the given transfer ID and other peer
|
|
|
|
MarketCancelDataTransfer(ctx context.Context, transferID datatransfer.TransferID, otherPeer peer.ID, isInitiator bool) error
|
2020-03-04 02:49:00 +00:00
|
|
|
|
|
|
|
DealsImportData(ctx context.Context, dealPropCid cid.Cid, file string) error
|
2020-09-17 07:32:10 +00:00
|
|
|
DealsList(ctx context.Context) ([]MarketDeal, error)
|
2020-06-26 17:50:54 +00:00
|
|
|
DealsConsiderOnlineStorageDeals(context.Context) (bool, error)
|
|
|
|
DealsSetConsiderOnlineStorageDeals(context.Context, bool) error
|
|
|
|
DealsConsiderOnlineRetrievalDeals(context.Context) (bool, error)
|
|
|
|
DealsSetConsiderOnlineRetrievalDeals(context.Context, bool) error
|
2020-06-18 22:42:24 +00:00
|
|
|
DealsPieceCidBlocklist(context.Context) ([]cid.Cid, error)
|
|
|
|
DealsSetPieceCidBlocklist(context.Context, []cid.Cid) error
|
2020-06-26 19:27:41 +00:00
|
|
|
DealsConsiderOfflineStorageDeals(context.Context) (bool, error)
|
|
|
|
DealsSetConsiderOfflineStorageDeals(context.Context, bool) error
|
|
|
|
DealsConsiderOfflineRetrievalDeals(context.Context) (bool, error)
|
|
|
|
DealsSetConsiderOfflineRetrievalDeals(context.Context, bool) error
|
2020-03-05 22:02:01 +00:00
|
|
|
|
|
|
|
StorageAddLocal(ctx context.Context, path string) error
|
2020-07-27 17:59:30 +00:00
|
|
|
|
|
|
|
PiecesListPieces(ctx context.Context) ([]cid.Cid, error)
|
|
|
|
PiecesListCidInfos(ctx context.Context) ([]cid.Cid, error)
|
|
|
|
PiecesGetPieceInfo(ctx context.Context, pieceCid cid.Cid) (*piecestore.PieceInfo, error)
|
|
|
|
PiecesGetCIDInfo(ctx context.Context, payloadCid cid.Cid) (*piecestore.CIDInfo, error)
|
2020-10-01 11:58:26 +00:00
|
|
|
|
|
|
|
// CreateBackup creates node backup onder the specified file name. The
|
|
|
|
// method requires that the lotus-miner is running with the
|
|
|
|
// LOTUS_BACKUP_BASE_PATH environment variable set to some path, and that
|
|
|
|
// the path specified when calling CreateBackup is within the base path
|
|
|
|
CreateBackup(ctx context.Context, fpath string) error
|
2020-11-26 07:02:43 +00:00
|
|
|
|
2020-12-01 23:32:01 +00:00
|
|
|
CheckProvable(ctx context.Context, pp abi.RegisteredPoStProof, sectors []storage.SectorRef, expensive bool) (map[abi.SectorNumber]string, error)
|
2020-02-28 18:06:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type SealRes struct {
|
|
|
|
Err string
|
|
|
|
GoErr error `json:"-"`
|
2019-11-21 00:52:59 +00:00
|
|
|
|
2020-02-28 18:06:59 +00:00
|
|
|
Proof []byte
|
2019-11-08 18:15:13 +00:00
|
|
|
}
|
|
|
|
|
2020-01-23 14:18:05 +00:00
|
|
|
type SectorLog struct {
|
|
|
|
Kind string
|
|
|
|
Timestamp uint64
|
|
|
|
|
|
|
|
Trace string
|
|
|
|
|
|
|
|
Message string
|
|
|
|
}
|
|
|
|
|
2019-11-08 18:15:13 +00:00
|
|
|
type SectorInfo struct {
|
2020-08-27 10:41:24 +00:00
|
|
|
SectorID abi.SectorNumber
|
|
|
|
State SectorState
|
|
|
|
CommD *cid.Cid
|
|
|
|
CommR *cid.Cid
|
|
|
|
Proof []byte
|
|
|
|
Deals []abi.DealID
|
|
|
|
Ticket SealTicket
|
|
|
|
Seed SealSeed
|
2020-08-27 10:40:19 +00:00
|
|
|
PreCommitMsg *cid.Cid
|
2020-08-27 10:41:24 +00:00
|
|
|
CommitMsg *cid.Cid
|
|
|
|
Retries uint64
|
|
|
|
ToUpgrade bool
|
2019-12-08 16:10:11 +00:00
|
|
|
|
2019-12-09 16:40:15 +00:00
|
|
|
LastErr string
|
2020-01-23 14:18:05 +00:00
|
|
|
|
|
|
|
Log []SectorLog
|
2020-07-24 08:04:04 +00:00
|
|
|
|
|
|
|
// On Chain Info
|
|
|
|
SealProof abi.RegisteredSealProof // The seal proof type implies the PoSt proof/s
|
2020-07-27 23:22:41 +00:00
|
|
|
Activation abi.ChainEpoch // Epoch during which the sector proof was accepted
|
|
|
|
Expiration abi.ChainEpoch // Epoch during which the sector expires
|
|
|
|
DealWeight abi.DealWeight // Integral of active deals over sector lifetime
|
|
|
|
VerifiedDealWeight abi.DealWeight // Integral of active verified deals over sector lifetime
|
|
|
|
InitialPledge abi.TokenAmount // Pledge collected to commit this sector
|
2020-07-24 08:04:04 +00:00
|
|
|
// Expiration Info
|
|
|
|
OnTime abi.ChainEpoch
|
|
|
|
// non-zero if sector is faulty, epoch at which it will be permanently
|
|
|
|
// removed if it doesn't recover
|
|
|
|
Early abi.ChainEpoch
|
2019-11-01 12:01:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type SealedRef struct {
|
2020-02-08 02:18:32 +00:00
|
|
|
SectorID abi.SectorNumber
|
2020-07-27 23:22:20 +00:00
|
|
|
Offset abi.PaddedPieceSize
|
2020-02-08 02:18:32 +00:00
|
|
|
Size abi.UnpaddedPieceSize
|
2019-11-06 12:22:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type SealedRefs struct {
|
|
|
|
Refs []SealedRef
|
2019-11-01 12:01:16 +00:00
|
|
|
}
|
2020-03-03 22:19:22 +00:00
|
|
|
|
|
|
|
type SealTicket struct {
|
|
|
|
Value abi.SealRandomness
|
|
|
|
Epoch abi.ChainEpoch
|
|
|
|
}
|
|
|
|
|
|
|
|
type SealSeed struct {
|
|
|
|
Value abi.InteractiveSealRandomness
|
|
|
|
Epoch abi.ChainEpoch
|
|
|
|
}
|
|
|
|
|
|
|
|
func (st *SealTicket) Equals(ost *SealTicket) bool {
|
|
|
|
return bytes.Equal(st.Value, ost.Value) && st.Epoch == ost.Epoch
|
|
|
|
}
|
|
|
|
|
|
|
|
func (st *SealSeed) Equals(ost *SealSeed) bool {
|
|
|
|
return bytes.Equal(st.Value, ost.Value) && st.Epoch == ost.Epoch
|
2020-03-05 19:21:06 +00:00
|
|
|
}
|
2020-04-23 22:33:59 +00:00
|
|
|
|
2020-06-01 12:59:51 +00:00
|
|
|
type SectorState string
|