From c2fa54ca9c5ca4f44bc48d003ce3b26ba768f13a Mon Sep 17 00:00:00 2001 From: Anton Evangelatov Date: Thu, 30 Sep 2021 12:43:02 +0200 Subject: [PATCH] check for deal start epoch on SectorAddPieceToAny --- extern/storage-sealing/input.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/extern/storage-sealing/input.go b/extern/storage-sealing/input.go index 218616aea..bdd03884a 100644 --- a/extern/storage-sealing/input.go +++ b/extern/storage-sealing/input.go @@ -274,6 +274,16 @@ func (m *Sealing) SectorAddPieceToAny(ctx context.Context, size abi.UnpaddedPiec return api.SectorOffset{}, xerrors.Errorf("getting proposal CID: %w", err) } + _, head, err := m.Api.ChainHead(ctx) + if err != nil { + return api.SectorOffset{}, xerrors.Errorf("couldnt get chain head: %w", err) + } + if head > deal.DealProposal.StartEpoch { + return api.SectorOffset{}, xerrors.Errorf( + "cannot add piece for deal with piece CID %s: current epoch %d has passed deal proposal start epoch %d", + deal.DealProposal.PieceCID, head, deal.DealProposal.StartEpoch) + } + m.inputLk.Lock() if _, exist := m.pendingPieces[proposalCID(deal)]; exist { m.inputLk.Unlock()