Skip to content

Commit

Permalink
sealing pipeline: Fix panic on padding pieces in WaitDeals
Browse files Browse the repository at this point in the history
  • Loading branch information
magik6k committed Mar 12, 2024
1 parent e5ccf19 commit 801e20c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
6 changes: 5 additions & 1 deletion storage/pipeline/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,16 @@ func (m *Sealing) handleWaitDeals(ctx statemachine.Context, sector SectorInfo) e
for _, piece := range sector.Pieces {
used += piece.Piece().Size.Unpadded()

if !piece.HasDealInfo() {
continue
}

endEpoch, err := piece.EndEpoch()
if err != nil {
return xerrors.Errorf("piece.EndEpoch: %w", err)
}

if piece.HasDealInfo() && endEpoch > lastDealEnd {
if endEpoch > lastDealEnd {
lastDealEnd = endEpoch
}
}
Expand Down
28 changes: 28 additions & 0 deletions storage/pipeline/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,10 +289,18 @@ func (sp *SafeSectorPiece) handleDealInfo(params handleDealInfoParams) error {
// SectorPiece Proxy

func (sp *SafeSectorPiece) Impl() piece.PieceDealInfo {
if !sp.HasDealInfo() {
return piece.PieceDealInfo{}
}

return sp.real.DealInfo.Impl()
}

func (sp *SafeSectorPiece) String() string {
if !sp.HasDealInfo() {
return "<no deal info>"
}

return sp.real.DealInfo.String()
}

Expand All @@ -305,21 +313,41 @@ func (sp *SafeSectorPiece) Valid(nv network.Version) error {
}

func (sp *SafeSectorPiece) StartEpoch() (abi.ChainEpoch, error) {
if !sp.HasDealInfo() {
return 0, xerrors.Errorf("no deal info")
}

return sp.real.DealInfo.StartEpoch()
}

func (sp *SafeSectorPiece) EndEpoch() (abi.ChainEpoch, error) {
if !sp.HasDealInfo() {
return 0, xerrors.Errorf("no deal info")
}

return sp.real.DealInfo.EndEpoch()
}

func (sp *SafeSectorPiece) PieceCID() cid.Cid {
if !sp.HasDealInfo() {
return sp.real.Piece.PieceCID
}

return sp.real.DealInfo.PieceCID()
}

func (sp *SafeSectorPiece) KeepUnsealedRequested() bool {
if !sp.HasDealInfo() {
return false
}

return sp.real.DealInfo.KeepUnsealedRequested()
}

func (sp *SafeSectorPiece) GetAllocation(ctx context.Context, aapi piece.AllocationAPI, tsk types.TipSetKey) (*verifreg.Allocation, error) {
if !sp.HasDealInfo() {
return nil, xerrors.Errorf("no deal info")
}

return sp.real.DealInfo.GetAllocation(ctx, aapi, tsk)
}

0 comments on commit 801e20c

Please sign in to comment.