2020-01-15 20:49:11 +00:00
|
|
|
package sealing
|
|
|
|
|
|
|
|
import (
|
2020-04-06 20:23:37 +00:00
|
|
|
"bytes"
|
|
|
|
"context"
|
|
|
|
|
2020-04-06 20:27:14 +00:00
|
|
|
"github.com/ipfs/go-cid"
|
|
|
|
|
2020-02-08 02:18:32 +00:00
|
|
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
2020-04-06 20:23:37 +00:00
|
|
|
"github.com/filecoin-project/specs-actors/actors/runtime/exitcode"
|
2020-04-03 16:54:01 +00:00
|
|
|
"github.com/filecoin-project/specs-storage/storage"
|
2020-01-15 20:49:11 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type Piece struct {
|
2020-02-23 00:47:47 +00:00
|
|
|
DealID *abi.DealID
|
2020-01-15 20:49:11 +00:00
|
|
|
|
2020-02-08 02:18:32 +00:00
|
|
|
Size abi.UnpaddedPieceSize
|
2020-02-27 00:42:39 +00:00
|
|
|
CommP cid.Cid
|
2020-01-15 20:49:11 +00:00
|
|
|
}
|
|
|
|
|
2020-01-22 02:41:39 +00:00
|
|
|
type Log struct {
|
|
|
|
Timestamp uint64
|
|
|
|
Trace string // for errors
|
|
|
|
|
|
|
|
Message string
|
|
|
|
|
|
|
|
// additional data (Event info)
|
2020-01-23 14:18:05 +00:00
|
|
|
Kind string
|
2020-01-22 02:41:39 +00:00
|
|
|
}
|
|
|
|
|
2020-01-15 20:49:11 +00:00
|
|
|
type SectorInfo struct {
|
2020-04-06 22:31:33 +00:00
|
|
|
State SectorState
|
|
|
|
SectorNumber abi.SectorNumber // TODO: this field's name should be changed to SectorNumber
|
|
|
|
Nonce uint64 // TODO: remove
|
2020-01-15 20:49:11 +00:00
|
|
|
|
2020-02-27 00:42:39 +00:00
|
|
|
SectorType abi.RegisteredProof
|
|
|
|
|
2020-01-15 20:49:11 +00:00
|
|
|
// Packing
|
|
|
|
|
|
|
|
Pieces []Piece
|
|
|
|
|
2020-04-03 16:54:01 +00:00
|
|
|
// PreCommit1
|
2020-04-06 18:07:26 +00:00
|
|
|
TicketValue abi.SealRandomness
|
|
|
|
TicketEpoch abi.ChainEpoch
|
2020-04-03 16:54:01 +00:00
|
|
|
PreCommit1Out storage.PreCommit1Out
|
|
|
|
|
|
|
|
// PreCommit2
|
|
|
|
CommD *cid.Cid
|
|
|
|
CommR *cid.Cid
|
|
|
|
Proof []byte
|
2020-01-15 20:49:11 +00:00
|
|
|
|
|
|
|
PreCommitMessage *cid.Cid
|
|
|
|
|
2020-01-20 22:04:46 +00:00
|
|
|
// WaitSeed
|
2020-04-06 18:07:26 +00:00
|
|
|
SeedValue abi.InteractiveSealRandomness
|
|
|
|
SeedEpoch abi.ChainEpoch
|
2020-01-15 20:49:11 +00:00
|
|
|
|
|
|
|
// Committing
|
|
|
|
CommitMessage *cid.Cid
|
2020-04-04 01:50:05 +00:00
|
|
|
InvalidProofs uint64 // failed proof computations (doesn't validate with proof inputs)
|
2020-01-15 20:49:11 +00:00
|
|
|
|
|
|
|
// Faults
|
|
|
|
FaultReportMsg *cid.Cid
|
|
|
|
|
|
|
|
// Debug
|
|
|
|
LastErr string
|
2020-01-16 01:25:49 +00:00
|
|
|
|
2020-01-22 02:41:39 +00:00
|
|
|
Log []Log
|
2020-01-15 20:49:11 +00:00
|
|
|
}
|
|
|
|
|
2020-02-27 00:42:39 +00:00
|
|
|
func (t *SectorInfo) pieceInfos() []abi.PieceInfo {
|
|
|
|
out := make([]abi.PieceInfo, len(t.Pieces))
|
2020-01-15 20:49:11 +00:00
|
|
|
for i, piece := range t.Pieces {
|
2020-02-27 00:42:39 +00:00
|
|
|
out[i] = abi.PieceInfo{
|
|
|
|
Size: piece.Size.Padded(),
|
|
|
|
PieceCID: piece.CommP,
|
|
|
|
}
|
2020-01-15 20:49:11 +00:00
|
|
|
}
|
|
|
|
return out
|
|
|
|
}
|
|
|
|
|
2020-02-08 02:18:32 +00:00
|
|
|
func (t *SectorInfo) deals() []abi.DealID {
|
2020-02-23 00:47:47 +00:00
|
|
|
out := make([]abi.DealID, 0, len(t.Pieces))
|
|
|
|
for _, piece := range t.Pieces {
|
|
|
|
if piece.DealID == nil {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
out = append(out, *piece.DealID)
|
2020-01-15 20:49:11 +00:00
|
|
|
}
|
|
|
|
return out
|
|
|
|
}
|
|
|
|
|
2020-02-08 02:18:32 +00:00
|
|
|
func (t *SectorInfo) existingPieces() []abi.UnpaddedPieceSize {
|
|
|
|
out := make([]abi.UnpaddedPieceSize, len(t.Pieces))
|
2020-01-15 20:49:11 +00:00
|
|
|
for i, piece := range t.Pieces {
|
|
|
|
out[i] = piece.Size
|
|
|
|
}
|
|
|
|
return out
|
|
|
|
}
|
2020-04-06 20:23:37 +00:00
|
|
|
|
2020-04-07 20:26:43 +00:00
|
|
|
type TicketFn func(ctx context.Context, tok TipSetToken) (abi.SealRandomness, abi.ChainEpoch, error)
|
2020-04-06 20:23:37 +00:00
|
|
|
|
|
|
|
type SectorIDCounter interface {
|
|
|
|
Next() (abi.SectorNumber, error)
|
|
|
|
}
|
|
|
|
|
|
|
|
type TipSetToken []byte
|
|
|
|
|
|
|
|
type MsgLookup struct {
|
|
|
|
Receipt MessageReceipt
|
|
|
|
TipSetTok TipSetToken
|
|
|
|
Height abi.ChainEpoch
|
|
|
|
}
|
|
|
|
|
|
|
|
type MessageReceipt struct {
|
|
|
|
ExitCode exitcode.ExitCode
|
|
|
|
Return []byte
|
|
|
|
GasUsed int64
|
|
|
|
}
|
|
|
|
|
|
|
|
func (mr *MessageReceipt) Equals(o *MessageReceipt) bool {
|
|
|
|
return mr.ExitCode == o.ExitCode && bytes.Equal(mr.Return, o.Return) && mr.GasUsed == o.GasUsed
|
|
|
|
}
|