sealing: Check piece CIDs after AddPiece
This commit is contained in:
parent
c664f9e30c
commit
b42171dc04
13
extern/storage-sealing/input.go
vendored
13
extern/storage-sealing/input.go
vendored
@ -9,6 +9,7 @@ import (
|
|||||||
|
|
||||||
"github.com/ipfs/go-cid"
|
"github.com/ipfs/go-cid"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/go-commp-utils/zerocomm"
|
||||||
"github.com/filecoin-project/go-padreader"
|
"github.com/filecoin-project/go-padreader"
|
||||||
"github.com/filecoin-project/go-state-types/abi"
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
"github.com/filecoin-project/go-statemachine"
|
"github.com/filecoin-project/go-statemachine"
|
||||||
@ -187,6 +188,8 @@ func (m *Sealing) handleAddPiece(ctx statemachine.Context, sector SectorInfo) er
|
|||||||
offset += padLength.Unpadded()
|
offset += padLength.Unpadded()
|
||||||
|
|
||||||
for _, p := range pads {
|
for _, p := range pads {
|
||||||
|
expectCid := zerocomm.ZeroPieceCommitment(p.Unpadded())
|
||||||
|
|
||||||
ppi, err := m.sealer.AddPiece(sectorstorage.WithPriority(ctx.Context(), DealSectorPriority),
|
ppi, err := m.sealer.AddPiece(sectorstorage.WithPriority(ctx.Context(), DealSectorPriority),
|
||||||
m.minerSector(sector.SectorType, sector.SectorNumber),
|
m.minerSector(sector.SectorType, sector.SectorNumber),
|
||||||
pieceSizes,
|
pieceSizes,
|
||||||
@ -197,6 +200,11 @@ func (m *Sealing) handleAddPiece(ctx statemachine.Context, sector SectorInfo) er
|
|||||||
deal.accepted(sector.SectorNumber, offset, err)
|
deal.accepted(sector.SectorNumber, offset, err)
|
||||||
return ctx.Send(SectorAddPieceFailed{err})
|
return ctx.Send(SectorAddPieceFailed{err})
|
||||||
}
|
}
|
||||||
|
if !ppi.PieceCID.Equals(expectCid) {
|
||||||
|
err = xerrors.Errorf("got unexpected padding piece CID: expected:%s, got:%s", expectCid, ppi.PieceCID)
|
||||||
|
deal.accepted(sector.SectorNumber, offset, err)
|
||||||
|
return ctx.Send(SectorAddPieceFailed{err})
|
||||||
|
}
|
||||||
|
|
||||||
pieceSizes = append(pieceSizes, p.Unpadded())
|
pieceSizes = append(pieceSizes, p.Unpadded())
|
||||||
res.NewPieces = append(res.NewPieces, Piece{
|
res.NewPieces = append(res.NewPieces, Piece{
|
||||||
@ -214,6 +222,11 @@ func (m *Sealing) handleAddPiece(ctx statemachine.Context, sector SectorInfo) er
|
|||||||
deal.accepted(sector.SectorNumber, offset, err)
|
deal.accepted(sector.SectorNumber, offset, err)
|
||||||
return ctx.Send(SectorAddPieceFailed{err})
|
return ctx.Send(SectorAddPieceFailed{err})
|
||||||
}
|
}
|
||||||
|
if !ppi.PieceCID.Equals(deal.deal.DealProposal.PieceCID) {
|
||||||
|
err = xerrors.Errorf("got unexpected piece CID: expected:%s, got:%s", deal.deal.DealProposal.PieceCID, ppi.PieceCID)
|
||||||
|
deal.accepted(sector.SectorNumber, offset, err)
|
||||||
|
return ctx.Send(SectorAddPieceFailed{err})
|
||||||
|
}
|
||||||
|
|
||||||
log.Infow("deal added to a sector", "deal", deal.deal.DealID, "sector", sector.SectorNumber, "piece", ppi.PieceCID)
|
log.Infow("deal added to a sector", "deal", deal.deal.DealID, "sector", sector.SectorNumber, "piece", ppi.PieceCID)
|
||||||
|
|
||||||
|
6
extern/storage-sealing/states_sealing.go
vendored
6
extern/storage-sealing/states_sealing.go
vendored
@ -7,6 +7,7 @@ import (
|
|||||||
"github.com/ipfs/go-cid"
|
"github.com/ipfs/go-cid"
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/go-commp-utils/zerocomm"
|
||||||
"github.com/filecoin-project/go-state-types/abi"
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
"github.com/filecoin-project/go-state-types/big"
|
"github.com/filecoin-project/go-state-types/big"
|
||||||
"github.com/filecoin-project/go-state-types/crypto"
|
"github.com/filecoin-project/go-state-types/crypto"
|
||||||
@ -88,10 +89,15 @@ func (m *Sealing) padSector(ctx context.Context, sectorID storage.SectorRef, exi
|
|||||||
|
|
||||||
out := make([]abi.PieceInfo, len(sizes))
|
out := make([]abi.PieceInfo, len(sizes))
|
||||||
for i, size := range sizes {
|
for i, size := range sizes {
|
||||||
|
expectCid := zerocomm.ZeroPieceCommitment(size)
|
||||||
|
|
||||||
ppi, err := m.sealer.AddPiece(ctx, sectorID, existingPieceSizes, size, NewNullReader(size))
|
ppi, err := m.sealer.AddPiece(ctx, sectorID, existingPieceSizes, size, NewNullReader(size))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, xerrors.Errorf("add piece: %w", err)
|
return nil, xerrors.Errorf("add piece: %w", err)
|
||||||
}
|
}
|
||||||
|
if !expectCid.Equals(expectCid) {
|
||||||
|
return nil, xerrors.Errorf("got unexpected padding piece CID: expected:%s, got:%s", expectCid, ppi.PieceCID)
|
||||||
|
}
|
||||||
|
|
||||||
existingPieceSizes = append(existingPieceSizes, size)
|
existingPieceSizes = append(existingPieceSizes, size)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user