Move unsealed sector from sealing to long term storage after Unseal

This commit is contained in:
Shrenuj Bansal 2022-11-23 15:22:14 -05:00
parent cc1e00b1c4
commit fa596eee5b
2 changed files with 67 additions and 0 deletions

View File

@ -2,6 +2,7 @@ package itests
import (
"context"
"fmt"
"testing"
"time"
@ -66,6 +67,53 @@ func TestUnsealPiece(t *testing.T) {
require.NoError(t, err)
require.Len(t, wpaths, 1)
// check which sectors files are present on the miner/worker storage paths
checkSectors := func(miners, workers storiface.SectorFileType) {
paths, err := miner.StorageList(ctx)
require.NoError(t, err)
require.Len(t, paths, 3) // genesis, miner, worker
// first loop for debugging
for id, decls := range paths {
pinfo, err := miner.StorageInfo(ctx, id)
require.NoError(t, err)
switch {
case id == wpaths[0].ID: // worker path
fmt.Println("Worker Decls ", len(decls), decls)
case !pinfo.CanStore && !pinfo.CanSeal: // genesis path
fmt.Println("Genesis Decls ", len(decls), decls)
default: // miner path
fmt.Println("Miner Decls ", len(decls), decls)
}
}
for id, decls := range paths {
pinfo, err := miner.StorageInfo(ctx, id)
require.NoError(t, err)
switch {
case id == wpaths[0].ID: // worker path
if workers != storiface.FTNone {
require.Len(t, decls, 1)
require.EqualValues(t, workers.Strings(), decls[0].SectorFileType.Strings())
} else {
require.Len(t, decls, 0)
}
case !pinfo.CanStore && !pinfo.CanSeal: // genesis path
require.Len(t, decls, kit.DefaultPresealsPerBootstrapMiner)
default: // miner path
if miners != storiface.FTNone {
require.Len(t, decls, 1)
require.EqualValues(t, miners.Strings(), decls[0].SectorFileType.Strings())
} else {
require.Len(t, decls, 0)
}
}
}
}
checkSectors(storiface.FTNone, storiface.FTNone)
// get a sector for upgrading
miner.PledgeSectors(ctx, 1, 0, nil)
sl, err := miner.SectorsListNonGenesis(ctx)
@ -74,6 +122,8 @@ func TestUnsealPiece(t *testing.T) {
sector := sl[0]
checkSectors(storiface.FTCache|storiface.FTSealed, storiface.FTNone)
sinfo, err := miner.SectorsStatus(ctx, sector, false)
require.NoError(t, err)
@ -87,4 +137,6 @@ func TestUnsealPiece(t *testing.T) {
err = miner.SectorsUnsealPiece(ctx, sectorRef, 0, 0, sinfo.Ticket.Value, sinfo.CommD)
require.NoError(t, err)
checkSectors(storiface.FTCache|storiface.FTSealed|storiface.FTUnsealed, storiface.FTNone)
}

View File

@ -353,6 +353,21 @@ func (m *Manager) SectorsUnsealPiece(ctx context.Context, sector storiface.Secto
return xerrors.Errorf("worker UnsealPiece call: %s", err)
}
// get a selector for moving unsealed sector into long-term storage
fetchSel := newMoveSelector(m.index, sector.ID, storiface.FTUnsealed, storiface.PathStorage, !m.disallowRemoteFinalize)
// move unsealed sector to long-term storage
// Possible TODO: Add an option to not keep the unsealed sector in long term storage?
err = m.sched.Schedule(ctx, sector, sealtasks.TTFetch, fetchSel,
m.schedFetch(sector, storiface.FTUnsealed, storiface.PathStorage, storiface.AcquireMove),
func(ctx context.Context, w Worker) error {
_, err := m.waitSimpleCall(ctx)(w.MoveStorage(ctx, sector, storiface.FTUnsealed))
return err
})
if err != nil {
return xerrors.Errorf("moving unsealed sector to long term storage: %w", err)
}
return nil
}