lppiece: Implement Piece Park

This commit is contained in:
Łukasz Magiera
2024-03-14 09:36:03 +01:00
parent 0b2613ec21
commit e060cd2f37
10 changed files with 326 additions and 19 deletions
+2 -17
View File
@@ -9,12 +9,10 @@ import (
"strconv"
"time"
"github.com/filecoin-project/go-state-types/abi"
"github.com/gorilla/mux"
"github.com/ipfs/go-cid"
logging "github.com/ipfs/go-log/v2"
"golang.org/x/xerrors"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/lotus/storage/sealer/partialfile"
"github.com/filecoin-project/lotus/storage/sealer/storiface"
@@ -340,18 +338,5 @@ func (handler *FetchHandler) generatePoRepVanillaProof(w http.ResponseWriter, r
}
func FileTypeFromString(t string) (storiface.SectorFileType, error) {
switch t {
case storiface.FTUnsealed.String():
return storiface.FTUnsealed, nil
case storiface.FTSealed.String():
return storiface.FTSealed, nil
case storiface.FTCache.String():
return storiface.FTCache, nil
case storiface.FTUpdate.String():
return storiface.FTUpdate, nil
case storiface.FTUpdateCache.String():
return storiface.FTUpdateCache, nil
default:
return 0, xerrors.Errorf("unknown sector file type: '%s'", t)
}
return storiface.TypeFromString(t)
}
+3
View File
@@ -39,6 +39,9 @@ func (b *Provider) AcquireSector(ctx context.Context, id storiface.SectorRef, ex
if err := os.Mkdir(filepath.Join(b.Root, storiface.FTUpdateCache.String()), 0755); err != nil && !os.IsExist(err) { // nolint
return storiface.SectorPaths{}, nil, err
}
if err := os.Mkdir(filepath.Join(b.Root, storiface.FTPiece.String()), 0755); err != nil && !os.IsExist(err) { // nolint
return storiface.SectorPaths{}, nil, err
}
done := func() {}
+18 -1
View File
@@ -9,16 +9,22 @@ import (
)
const (
// "regular" sectors
FTUnsealed SectorFileType = 1 << iota
FTSealed
FTCache
// snap
FTUpdate
FTUpdateCache
// Piece Park
FTPiece
FileTypes = iota
)
var PathTypes = []SectorFileType{FTUnsealed, FTSealed, FTCache, FTUpdate, FTUpdateCache}
var PathTypes = []SectorFileType{FTUnsealed, FTSealed, FTCache, FTUpdate, FTUpdateCache, FTPiece}
const (
FTNone SectorFileType = 0
@@ -39,6 +45,7 @@ var FSOverheadSeal = map[SectorFileType]int{ // 10x overheads
FTUpdate: FSOverheadDen,
FTUpdateCache: FSOverheadDen*2 + 1,
FTCache: 141, // 11 layers + D(2x ssize) + C + R'
FTPiece: FSOverheadDen,
}
// sector size * disk / fs overhead. FSOverheadDen is like the unit of sector size
@@ -49,6 +56,7 @@ var FsOverheadFinalized = map[SectorFileType]int{
FTUpdate: FSOverheadDen,
FTUpdateCache: 1,
FTCache: 1,
FTPiece: FSOverheadDen,
}
type SectorFileType int
@@ -65,6 +73,8 @@ func TypeFromString(s string) (SectorFileType, error) {
return FTUpdate, nil
case "update-cache":
return FTUpdateCache, nil
case "piece":
return FTPiece, nil
default:
return 0, xerrors.Errorf("unknown sector file type '%s'", s)
}
@@ -82,6 +92,8 @@ func (t SectorFileType) String() string {
return "update"
case FTUpdateCache:
return "update-cache"
case FTPiece:
return "piece"
default:
return fmt.Sprintf("<unknown %d %v>", t, (t & ((1 << FileTypes) - 1)).Strings())
}
@@ -206,6 +218,7 @@ type SectorPaths struct {
Cache string
Update string
UpdateCache string
Piece string
}
func ParseSectorID(baseName string) (abi.SectorID, error) {
@@ -242,6 +255,8 @@ func PathByType(sps SectorPaths, fileType SectorFileType) string {
return sps.Update
case FTUpdateCache:
return sps.UpdateCache
case FTPiece:
return sps.Piece
}
panic("requested unknown path type")
@@ -259,5 +274,7 @@ func SetPathByType(sps *SectorPaths, fileType SectorFileType, p string) {
sps.Update = p
case FTUpdateCache:
sps.UpdateCache = p
case FTPiece:
sps.Piece = p
}
}
+11
View File
@@ -20,6 +20,17 @@ type SectorRef struct {
var NoSectorRef = SectorRef{}
// PieceNumber is a reference to a piece in the storage system; mapping between
// pieces in the storage system and piece CIDs is maintained by the storage index
type PieceNumber uint64
func (pn PieceNumber) Ref() SectorRef {
return SectorRef{
ID: abi.SectorID{Miner: 0, Number: abi.SectorNumber(pn)},
ProofType: abi.RegisteredSealProof_StackedDrg64GiBV1, // This only cares about TreeD which is the same for all sizes
}
}
type ProverPoSt interface {
GenerateWinningPoSt(ctx context.Context, minerID abi.ActorID, sectorInfo []proof.ExtendedSectorInfo, randomness abi.PoStRandomness) ([]proof.PoStProof, error)
GenerateWindowPoSt(ctx context.Context, minerID abi.ActorID, ppt abi.RegisteredPoStProof, sectorInfo []proof.ExtendedSectorInfo, randomness abi.PoStRandomness) (proof []proof.PoStProof, skipped []abi.SectorID, err error)