Skip to content
This repository has been archived by the owner on Dec 19, 2022. It is now read-only.

Repair the pieces info of the cc data modified in the verification deal #146

Merged
merged 1 commit into from
Dec 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions sector-storage/ffiwrapper/sealer_cgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,7 @@ func (sb *Sealer) SealPreCommit1(ctx context.Context, sector storage.SectorRef,
log.Infof("pre commit1 paths: %v", paths)
if bExist, _ := storiface.FileExists(tUnsealedFile); bExist {
if bExist, _ := storiface.FileExists(paths.Unsealed); !bExist {
log.Infof("copy default unsealed file for sector %v", sector.ID.Number)
err = storiface.CopyFile(tUnsealedFile, paths.Unsealed)
if err != nil {
return nil, err
Expand Down
44 changes: 29 additions & 15 deletions storage-sealing/states_sealing.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,27 @@ func (m *Sealing) handlePacking(ctx statemachine.Context, sector types.SectorInf
log.Warnf("Creating %d filler pieces for sector %d", len(fillerSizes), sector.SectorNumber)
}

fillerPieces, err := m.padSector(sector.SealingCtx(ctx.Context()), m.minerSector(sector.SectorType, sector.SectorNumber), sector.ExistingPieceSizes(), fillerSizes...)
// Check if the sector is deal
var deals int = 0
for _, piece := range sector.Pieces {
if piece.DealInfo == nil {
continue
}

if piece.DealInfo.DealID > 0 {
deals++
}
}

fillerPieces, err := m.padSector(sector.SealingCtx(ctx.Context()), m.minerSector(sector.SectorType, sector.SectorNumber), deals>0, sector.ExistingPieceSizes(), fillerSizes...)
if err != nil {
return xerrors.Errorf("filling up the sector (%v): %w", fillerSizes, err)
}

return ctx.Send(SectorPacked{FillerPieces: fillerPieces})
}

func (m *Sealing) padSector(ctx context.Context, sectorID storage.SectorRef, existingPieceSizes []abi.UnpaddedPieceSize, sizes ...abi.UnpaddedPieceSize) ([]abi.PieceInfo, error) {
func (m *Sealing) padSector(ctx context.Context, sectorID storage.SectorRef, bDeal bool, existingPieceSizes []abi.UnpaddedPieceSize, sizes ...abi.UnpaddedPieceSize) ([]abi.PieceInfo, error) {
if len(sizes) == 0 {
return nil, nil
}
Expand All @@ -98,9 +110,9 @@ func (m *Sealing) padSector(ctx context.Context, sectorID storage.SectorRef, exi
}

pisFile := storiface.DefaultPieceInfosFile(ssize)
if len(existingPieceSizes) == 0 {
if len(existingPieceSizes) == 0 && !bDeal {
//hack for cc sector
log.Infof("pisFile: %s", pisFile)
log.Infof("use default pisFile for sector %v: %s", sectorID.ID.Number, pisFile)
if bExist, _ := storiface.FileExists(pisFile); bExist {
bufs, err := ioutil.ReadFile(pisFile)
if err != nil {
Expand Down Expand Up @@ -129,18 +141,20 @@ func (m *Sealing) padSector(ctx context.Context, sectorID storage.SectorRef, exi
out[i] = ppi
}

psFile := storiface.DefaultUnsealedFile(ssize)
if bExist, _ := storiface.FileExists(psFile); bExist {
//hack for cc sector
// save piece info to /var/tmp/s-piece-infos-<SectorSize>
buf, err := json.Marshal(out)
if err != nil {
return nil, err
}
if !bDeal {
psFile := storiface.DefaultUnsealedFile(ssize)
if bExist, _ := storiface.FileExists(psFile); bExist {
//hack for cc sector
// save piece info to /var/tmp/s-piece-infos-<SectorSize>
buf, err := json.Marshal(out)
if err != nil {
return nil, err
}

log.Infof("default pieceInfo file: %s, buf: %s", pisFile, buf)
if err := ioutil.WriteFile(pisFile, buf, 0644); err != nil {
return nil, xerrors.Errorf("persisting (%s): %w", pisFile, err)
log.Infof("default pieceInfo file: %s, buf: %s", pisFile, buf)
if err := ioutil.WriteFile(pisFile, buf, 0644); err != nil {
return nil, xerrors.Errorf("persisting (%s): %w", pisFile, err)
}
}
}

Expand Down