Merge pull request #1526 from filecoin-project/feat/pass-deal-schedule-for-pre-commit-expiry-scheduling

provide deal scheduling info to FSM so that it can set pre-commit expiry
This commit is contained in:
Łukasz Magiera 2020-04-10 23:05:50 +02:00 committed by GitHub
commit 3426611340
9 changed files with 42 additions and 20 deletions

View File

@ -292,9 +292,17 @@ func migratePreSealMeta(ctx context.Context, api lapi.FullNode, metadata string,
SectorNumber: sector.SectorID,
Pieces: []sealing.Piece{
{
DealID: &dealID,
Size: abi.PaddedPieceSize(meta.SectorSize).Unpadded(),
CommP: sector.CommD,
Piece: abi.PieceInfo{
Size: abi.PaddedPieceSize(meta.SectorSize),
PieceCID: commD,
},
DealInfo: &sealing.DealInfo{
DealID: dealID,
DealSchedule: sealing.DealSchedule{
StartEpoch: sector.Deal.StartEpoch,
EndEpoch: sector.Deal.EndEpoch,
},
},
},
},
CommD: &commD,

2
go.mod
View File

@ -27,7 +27,7 @@ require (
github.com/filecoin-project/sector-storage v0.0.0-20200406195014-a6d093838576
github.com/filecoin-project/specs-actors v0.0.0-20200324235424-aef9b20a9fb1
github.com/filecoin-project/specs-storage v0.0.0-20200317225704-7420bc655c38
github.com/filecoin-project/storage-fsm v0.0.0-20200407163248-25993479b13f
github.com/filecoin-project/storage-fsm v0.0.0-20200408153957-1c356922353f
github.com/gbrlsnchs/jwt/v3 v3.0.0-beta.1
github.com/google/uuid v1.1.1
github.com/gorilla/mux v1.7.4

4
go.sum
View File

@ -178,8 +178,8 @@ github.com/filecoin-project/specs-actors v0.0.0-20200324235424-aef9b20a9fb1 h1:I
github.com/filecoin-project/specs-actors v0.0.0-20200324235424-aef9b20a9fb1/go.mod h1:5WngRgTN5Eo4+0SjCBqLzEr2l6Mj45DrP2606gBhqI0=
github.com/filecoin-project/specs-storage v0.0.0-20200317225704-7420bc655c38 h1:ky+rfX3bG1TjOBLn14V674q+iwZpalyKzZxGRNzA11I=
github.com/filecoin-project/specs-storage v0.0.0-20200317225704-7420bc655c38/go.mod h1:dUmzHS7izOD6HW3/JpzFrjxnptxbsHXBlO8puK2UzBk=
github.com/filecoin-project/storage-fsm v0.0.0-20200407163248-25993479b13f h1:WPA4Lj1PLBVKFe8nKs8UdJ7fj4luFKR62eRDpVNo9CU=
github.com/filecoin-project/storage-fsm v0.0.0-20200407163248-25993479b13f/go.mod h1:t3dyEJiCkdQjo0h75mir3x5a0vSPHi9woQO7UkkZpFg=
github.com/filecoin-project/storage-fsm v0.0.0-20200408153957-1c356922353f h1:ocVYJgS622P5p/LOOPzb875M+wlJHe6in2DcoGcd9J8=
github.com/filecoin-project/storage-fsm v0.0.0-20200408153957-1c356922353f/go.mod h1:9nHIzwfHk6cNXaaNnUJNWNRRytp5QYMBOA+NtcTUKJM=
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/gbrlsnchs/jwt/v3 v3.0.0-beta.1 h1:EzDjxMg43q1tA2c0MV3tNbaontnHLplHyFF6M5KiVP0=

View File

@ -102,7 +102,13 @@ func (n *ProviderNodeAdapter) PublishDeals(ctx context.Context, deal storagemark
}
func (n *ProviderNodeAdapter) OnDealComplete(ctx context.Context, deal storagemarket.MinerDeal, pieceSize abi.UnpaddedPieceSize, pieceData io.Reader) error {
_, err := n.secb.AddPiece(ctx, abi.UnpaddedPieceSize(pieceSize), pieceData, deal.DealID)
_, err := n.secb.AddPiece(ctx, pieceSize, pieceData, sealing.DealInfo{
DealID: deal.DealID,
DealSchedule: sealing.DealSchedule{
StartEpoch: deal.ClientDealProposal.Proposal.StartEpoch,
EndEpoch: deal.ClientDealProposal.Proposal.EndEpoch,
},
})
if err != nil {
return xerrors.Errorf("AddPiece failed: %s", err)
}

View File

@ -75,10 +75,10 @@ func (sm *StorageMinerAPI) SectorsStatus(ctx context.Context, sid abi.SectorNumb
deals := make([]abi.DealID, len(info.Pieces))
for i, piece := range info.Pieces {
if piece.DealID == nil {
if piece.DealInfo == nil {
continue
}
deals[i] = *piece.DealID
deals[i] = piece.DealInfo.DealID
}
log := make([]api.SectorLog, len(info.Log))

View File

@ -280,10 +280,15 @@ func SetupBlockProducer(lc fx.Lifecycle, ds dtypes.MetadataDS, api lapi.FullNode
}
func SealTicketGen(fapi lapi.FullNode) sealing.TicketFn {
return func(ctx context.Context) (abi.SealRandomness, abi.ChainEpoch, error) {
ts, err := fapi.ChainHead(ctx)
return func(ctx context.Context, tok sealing.TipSetToken) (abi.SealRandomness, abi.ChainEpoch, error) {
tsk, err := types.TipSetKeyFromBytes(tok)
if err != nil {
return nil, 0, xerrors.Errorf("getting head ts for SealTicket failed: %w", err)
return nil, 0, xerrors.Errorf("could not unmarshal TipSetToken to TipSetKey: %w", err)
}
ts, err := fapi.ChainGetTipSet(ctx, tsk)
if err != nil {
return nil, 0, xerrors.Errorf("getting TipSet for key failed: %w", err)
}
r, err := fapi.ChainGetRandomness(ctx, ts.Key(), crypto.DomainSeparationTag_SealRandomness, ts.Height()-build.SealRandomnessLookback, nil)

View File

@ -99,7 +99,9 @@ func (m *Miner) Run(ctx context.Context) error {
}
evts := events.NewEvents(ctx, m.api)
m.sealing = sealing.New(NewSealingAPIAdapter(m.api), NewEventsAdapter(evts), m.maddr, m.worker, m.ds, m.sealer, m.sc, m.verif, m.tktFn)
adaptedAPI := NewSealingAPIAdapter(m.api)
pcp := sealing.NewBasicPreCommitPolicy(adaptedAPI, 10000000)
m.sealing = sealing.New(adaptedAPI, NewEventsAdapter(evts), m.maddr, m.worker, m.ds, m.sealer, m.sc, m.verif, m.tktFn, &pcp)
go m.sealing.Run(ctx)

View File

@ -20,8 +20,8 @@ func (m *Miner) AllocatePiece(size abi.UnpaddedPieceSize) (sectorID abi.SectorNu
return m.sealing.AllocatePiece(size)
}
func (m *Miner) SealPiece(ctx context.Context, size abi.UnpaddedPieceSize, r io.Reader, sectorID abi.SectorNumber, dealID abi.DealID) error {
return m.sealing.SealPiece(ctx, size, r, sectorID, dealID)
func (m *Miner) SealPiece(ctx context.Context, size abi.UnpaddedPieceSize, r io.Reader, sectorID abi.SectorNumber, d sealing.DealInfo) error {
return m.sealing.SealPiece(ctx, size, r, sectorID, d)
}
func (m *Miner) ListSectors() ([]sealing.SectorInfo, error) {

View File

@ -8,8 +8,6 @@ import (
"io"
"sync"
"github.com/filecoin-project/go-padreader"
"github.com/filecoin-project/specs-actors/actors/abi"
"github.com/ipfs/go-datastore"
"github.com/ipfs/go-datastore/namespace"
"github.com/ipfs/go-datastore/query"
@ -17,6 +15,9 @@ import (
"golang.org/x/xerrors"
cborutil "github.com/filecoin-project/go-cbor-util"
"github.com/filecoin-project/go-padreader"
"github.com/filecoin-project/specs-actors/actors/abi"
sealing "github.com/filecoin-project/storage-fsm"
"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/node/modules/dtypes"
@ -96,18 +97,18 @@ func (st *SectorBlocks) writeRef(dealID abi.DealID, sectorID abi.SectorNumber, o
return st.keys.Put(DealIDToDsKey(dealID), newRef) // TODO: batch somehow
}
func (st *SectorBlocks) AddPiece(ctx context.Context, size abi.UnpaddedPieceSize, r io.Reader, dealID abi.DealID) (sectorID abi.SectorNumber, err error) {
func (st *SectorBlocks) AddPiece(ctx context.Context, size abi.UnpaddedPieceSize, r io.Reader, d sealing.DealInfo) (sectorID abi.SectorNumber, err error) {
sectorID, pieceOffset, err := st.Miner.AllocatePiece(padreader.PaddedSize(uint64(size)))
if err != nil {
return 0, err
}
err = st.writeRef(dealID, sectorID, pieceOffset, size)
err = st.writeRef(d.DealID, sectorID, pieceOffset, size)
if err != nil {
return 0, err
}
return sectorID, st.Miner.SealPiece(ctx, size, r, sectorID, dealID)
return sectorID, st.Miner.SealPiece(ctx, size, r, sectorID, d)
}
func (st *SectorBlocks) List() (map[uint64][]api.SealedRef, error) {