sealing

package module
v1.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 27, 2020 License: Apache-2.0, MIT Imports: 29 Imported by: 0

README

storage-fsm

CircleCI standard-readme compliant

A finite state machine used for sector storage

License

The Filecoin Project is dual-licensed under Apache 2.0 and MIT terms:

Documentation

Index

Constants

View Source
const Finality = 500

Epochs

View Source
const InteractivePoRepConfidence = 6

Epochs

View Source
const SealRandomnessLookback = Finality

Epochs

View Source
const SealRandomnessLookbackLimit = SealRandomnessLookback + 30000

Epochs

View Source
const SectorStorePrefix = "/sectors"

Variables

This section is empty.

Functions

This section is empty.

Types

type BasicPreCommitPolicy

type BasicPreCommitPolicy struct {
	// contains filtered or unexported fields
}

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.

func NewBasicPreCommitPolicy

func NewBasicPreCommitPolicy(api Chain, duration abi.ChainEpoch, provingBoundary abi.ChainEpoch) BasicPreCommitPolicy

NewBasicPreCommitPolicy produces a BasicPreCommitPolicy

func (*BasicPreCommitPolicy) Expiration

func (p *BasicPreCommitPolicy) Expiration(ctx context.Context, ps ...Piece) (abi.ChainEpoch, error)

Expiration produces the pre-commit sector expiration epoch for an encoded replica containing the provided enumeration of pieces and deals.

type Chain

type Chain interface {
	ChainHead(ctx context.Context) (TipSetToken, abi.ChainEpoch, error)
}

type DealInfo

type DealInfo struct {
	DealID       abi.DealID
	DealSchedule DealSchedule
}

DealInfo is a tuple of deal identity and its schedule

func (*DealInfo) MarshalCBOR

func (t *DealInfo) MarshalCBOR(w io.Writer) error

func (*DealInfo) UnmarshalCBOR

func (t *DealInfo) UnmarshalCBOR(r io.Reader) error

type DealSchedule

type DealSchedule struct {
	StartEpoch abi.ChainEpoch
	EndEpoch   abi.ChainEpoch
}

DealSchedule communicates the time interval of a storage deal. The deal must appear in a sealed (proven) sector no later than StartEpoch, otherwise it is invalid.

func (*DealSchedule) MarshalCBOR

func (t *DealSchedule) MarshalCBOR(w io.Writer) error

func (*DealSchedule) UnmarshalCBOR

func (t *DealSchedule) UnmarshalCBOR(r io.Reader) error

type ErrApi

type ErrApi struct {
	// contains filtered or unexported fields
}

TODO: For now we handle this by halting state execution, when we get jsonrpc reconnecting

We should implement some wait-for-api logic

type ErrBadCommD

type ErrBadCommD struct {
	// contains filtered or unexported fields
}

type ErrBadSeed

type ErrBadSeed struct {
	// contains filtered or unexported fields
}

type ErrExpiredDeals

type ErrExpiredDeals struct {
	// contains filtered or unexported fields
}

type ErrExpiredTicket

type ErrExpiredTicket struct {
	// contains filtered or unexported fields
}

type ErrInvalidDeals

type ErrInvalidDeals struct {
	// contains filtered or unexported fields
}

type ErrInvalidPiece

type ErrInvalidPiece struct {
	// contains filtered or unexported fields
}

type ErrInvalidProof

type ErrInvalidProof struct {
	// contains filtered or unexported fields
}

type Events

type Events interface {
	ChainAt(hnd HeightHandler, rev RevertHandler, confidence int, h abi.ChainEpoch) error
}

type HeightHandler

type HeightHandler func(ctx context.Context, tok TipSetToken, curH abi.ChainEpoch) error

`curH`-`ts.Height` = `confidence`

type Log

type Log struct {
	Timestamp uint64
	Trace     string // for errors

	Message string

	// additional data (Event info)
	Kind string
}

func (*Log) MarshalCBOR

func (t *Log) MarshalCBOR(w io.Writer) error

func (*Log) UnmarshalCBOR

func (t *Log) UnmarshalCBOR(r io.Reader) error

type MessageReceipt

type MessageReceipt struct {
	ExitCode exitcode.ExitCode
	Return   []byte
	GasUsed  int64
}

func (*MessageReceipt) Equals

func (mr *MessageReceipt) Equals(o *MessageReceipt) bool

type MsgLookup

type MsgLookup struct {
	Receipt   MessageReceipt
	TipSetTok TipSetToken
	Height    abi.ChainEpoch
}

type Piece

type Piece struct {
	Piece    abi.PieceInfo
	DealInfo *DealInfo // nil for pieces which do not appear in deals (e.g. filler pieces)
}

Piece is a tuple of piece info and optional deal

func (*Piece) MarshalCBOR

func (t *Piece) MarshalCBOR(w io.Writer) error

func (*Piece) UnmarshalCBOR

func (t *Piece) UnmarshalCBOR(r io.Reader) error

type PieceWithDealInfo

type PieceWithDealInfo struct {
	Piece    abi.PieceInfo
	DealInfo DealInfo
}

Piece is a tuple of piece and deal info

type PreCommitPolicy

type PreCommitPolicy interface {
	Expiration(ctx context.Context, ps ...Piece) (abi.ChainEpoch, error)
}

type RevertHandler

type RevertHandler func(ctx context.Context, tok TipSetToken) error

type Sealing

type Sealing struct {
	// contains filtered or unexported fields
}

func New

func New(api SealingAPI, events Events, maddr address.Address, ds datastore.Batching, sealer sectorstorage.SectorManager, sc SectorIDCounter, verif ffiwrapper.Verifier, pcp PreCommitPolicy) *Sealing

func (*Sealing) Address

func (m *Sealing) Address() address.Address

func (*Sealing) AllocatePiece

func (m *Sealing) AllocatePiece(size abi.UnpaddedPieceSize) (sectorID abi.SectorNumber, offset uint64, err error)

func (*Sealing) ForceSectorState

func (m *Sealing) ForceSectorState(ctx context.Context, id abi.SectorNumber, state SectorState) error

func (*Sealing) GetSectorInfo

func (m *Sealing) GetSectorInfo(sid abi.SectorNumber) (SectorInfo, error)

func (*Sealing) ListSectors

func (m *Sealing) ListSectors() ([]SectorInfo, error)

func (*Sealing) Plan

func (m *Sealing) Plan(events []statemachine.Event, user interface{}) (interface{}, uint64, error)

func (*Sealing) PledgeSector

func (m *Sealing) PledgeSector() error

func (*Sealing) Run

func (m *Sealing) Run(ctx context.Context) error

func (*Sealing) SealPiece

func (m *Sealing) SealPiece(ctx context.Context, size abi.UnpaddedPieceSize, r io.Reader, sectorID abi.SectorNumber, d DealInfo) error

func (*Sealing) Stop

func (m *Sealing) Stop(ctx context.Context) error

type SealingAPI

type SealingAPI interface {
	StateWaitMsg(context.Context, cid.Cid) (MsgLookup, error)
	StateComputeDataCommitment(ctx context.Context, maddr address.Address, sectorType abi.RegisteredProof, deals []abi.DealID, tok TipSetToken) (cid.Cid, error)
	StateSectorPreCommitInfo(ctx context.Context, maddr address.Address, sectorNumber abi.SectorNumber, tok TipSetToken) (*miner.SectorPreCommitOnChainInfo, error)
	StateMinerSectorSize(context.Context, address.Address, TipSetToken) (abi.SectorSize, error)
	StateMinerWorkerAddress(ctx context.Context, maddr address.Address, tok TipSetToken) (address.Address, error)
	StateMinerDeadlines(ctx context.Context, maddr address.Address, tok TipSetToken) (*miner.Deadlines, error)
	StateMinerInitialPledgeCollateral(context.Context, address.Address, abi.SectorNumber, TipSetToken) (big.Int, error)
	StateMarketStorageDeal(context.Context, abi.DealID, TipSetToken) (market.DealProposal, error)
	SendMsg(ctx context.Context, from, to address.Address, method abi.MethodNum, value, gasPrice big.Int, gasLimit int64, params []byte) (cid.Cid, error)
	ChainHead(ctx context.Context) (TipSetToken, abi.ChainEpoch, error)
	ChainGetRandomness(ctx context.Context, tok TipSetToken, personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte) (abi.Randomness, error)
	ChainReadObj(context.Context, cid.Cid) ([]byte, error)
}

type SectorChainPreCommitFailed

type SectorChainPreCommitFailed struct {
	// contains filtered or unexported fields
}

func (SectorChainPreCommitFailed) FormatError

func (evt SectorChainPreCommitFailed) FormatError(xerrors.Printer) (next error)

type SectorCommitFailed

type SectorCommitFailed struct {
	// contains filtered or unexported fields
}

func (SectorCommitFailed) FormatError

func (evt SectorCommitFailed) FormatError(xerrors.Printer) (next error)

type SectorCommitted

type SectorCommitted struct {
	Message cid.Cid
	Proof   []byte
}

type SectorComputeProofFailed

type SectorComputeProofFailed struct {
	// contains filtered or unexported fields
}

func (SectorComputeProofFailed) FormatError

func (evt SectorComputeProofFailed) FormatError(xerrors.Printer) (next error)

type SectorFatalError

type SectorFatalError struct {
	// contains filtered or unexported fields
}

func (SectorFatalError) FormatError

func (evt SectorFatalError) FormatError(xerrors.Printer) (next error)

type SectorFaultReported

type SectorFaultReported struct {
	// contains filtered or unexported fields
}

type SectorFaultedFinal

type SectorFaultedFinal struct{}

type SectorFaulty

type SectorFaulty struct{}

type SectorFinalizeFailed

type SectorFinalizeFailed struct {
	// contains filtered or unexported fields
}

func (SectorFinalizeFailed) FormatError

func (evt SectorFinalizeFailed) FormatError(xerrors.Printer) (next error)

type SectorFinalized

type SectorFinalized struct{}

type SectorForceState

type SectorForceState struct {
	State SectorState
}

type SectorIDCounter

type SectorIDCounter interface {
	Next() (abi.SectorNumber, error)
}

type SectorInfo

type SectorInfo struct {
	State        SectorState
	SectorNumber abi.SectorNumber // TODO: this field's name should be changed to SectorNumber
	Nonce        uint64           // TODO: remove

	SectorType abi.RegisteredProof

	// Packing
	Pieces []Piece

	// PreCommit1
	TicketValue   abi.SealRandomness
	TicketEpoch   abi.ChainEpoch
	PreCommit1Out storage.PreCommit1Out

	// PreCommit2
	CommD *cid.Cid
	CommR *cid.Cid
	Proof []byte

	PreCommitMessage *cid.Cid

	// WaitSeed
	SeedValue abi.InteractiveSealRandomness
	SeedEpoch abi.ChainEpoch

	// Committing
	CommitMessage *cid.Cid
	InvalidProofs uint64 // failed proof computations (doesn't validate with proof inputs)

	// Faults
	FaultReportMsg *cid.Cid

	// Debug
	LastErr string

	Log []Log
}

func (*SectorInfo) MarshalCBOR

func (t *SectorInfo) MarshalCBOR(w io.Writer) error

func (*SectorInfo) UnmarshalCBOR

func (t *SectorInfo) UnmarshalCBOR(r io.Reader) error

type SectorPacked

type SectorPacked struct{ FillerPieces []abi.PieceInfo }

type SectorPackingFailed

type SectorPackingFailed struct {
	// contains filtered or unexported fields
}

type SectorPreCommit1

type SectorPreCommit1 struct {
	PreCommit1Out storage.PreCommit1Out
	TicketValue   abi.SealRandomness
	TicketEpoch   abi.ChainEpoch
}

type SectorPreCommit2

type SectorPreCommit2 struct {
	Sealed   cid.Cid
	Unsealed cid.Cid
}

type SectorPreCommitted

type SectorPreCommitted struct {
	Message cid.Cid
}

type SectorProving

type SectorProving struct{}

type SectorRestart

type SectorRestart struct{}

type SectorRetryComputeProof

type SectorRetryComputeProof struct{}

type SectorRetryInvalidProof

type SectorRetryInvalidProof struct{}

type SectorRetryPreCommit

type SectorRetryPreCommit struct{}

type SectorRetrySeal

type SectorRetrySeal struct{}

type SectorRetryWaitSeed

type SectorRetryWaitSeed struct{}

type SectorSealPreCommitFailed

type SectorSealPreCommitFailed struct {
	// contains filtered or unexported fields
}

func (SectorSealPreCommitFailed) FormatError

func (evt SectorSealPreCommitFailed) FormatError(xerrors.Printer) (next error)

type SectorSeedReady

type SectorSeedReady struct {
	SeedValue abi.InteractiveSealRandomness
	SeedEpoch abi.ChainEpoch
}

type SectorStart

type SectorStart struct {
	ID         abi.SectorNumber
	SectorType abi.RegisteredProof
	Pieces     []Piece
}

type SectorState

type SectorState string
const (
	UndefinedSectorState SectorState = ""

	// happy path
	Empty          SectorState = "Empty"
	Packing        SectorState = "Packing"       // sector not in sealStore, and not on chain
	PreCommit1     SectorState = "PreCommit1"    // do PreCommit1
	PreCommit2     SectorState = "PreCommit2"    // do PreCommit1
	PreCommitting  SectorState = "PreCommitting" // on chain pre-commit
	WaitSeed       SectorState = "WaitSeed"      // waiting for seed
	Committing     SectorState = "Committing"
	CommitWait     SectorState = "CommitWait" // waiting for message to land on chain
	FinalizeSector SectorState = "FinalizeSector"
	Proving        SectorState = "Proving"
	// error modes
	FailedUnrecoverable SectorState = "FailedUnrecoverable"
	SealFailed          SectorState = "SealFailed"
	PreCommitFailed     SectorState = "PreCommitFailed"
	ComputeProofFailed  SectorState = "ComputeProofFailed"
	CommitFailed        SectorState = "CommitFailed"
	PackingFailed       SectorState = "PackingFailed"
	Faulty              SectorState = "Faulty"        // sector is corrupted or gone for some reason
	FaultReported       SectorState = "FaultReported" // sector has been declared as a fault on chain
	FaultedFinal        SectorState = "FaultedFinal"  // fault declared on chain
)

type TipSetToken

type TipSetToken []byte

Directories

Path Synopsis
lib

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL