Skip to content

Commit

Permalink
just use checkPiece
Browse files Browse the repository at this point in the history
  • Loading branch information
jennijuju committed Jan 11, 2022
1 parent 37a3e61 commit 6b953a0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 20 deletions.
18 changes: 0 additions & 18 deletions extern/storage-sealing/checks.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,24 +79,6 @@ func checkPieces(ctx context.Context, maddr address.Address, si SectorInfo, api
return nil
}

func checkDealExpiration(ctx context.Context, sector SectorInfo, api SealingAPI) error {
tok, height, err := api.ChainHead(ctx)
if err != nil {
return &ErrApi{xerrors.Errorf("getting chain head: %w", err)}
}

for i, p := range sector.Pieces {
proposal, err := api.StateMarketStorageDealProposal(ctx, p.DealInfo.DealID, tok)
if err != nil {
return &ErrInvalidDeals{xerrors.Errorf("getting deal %d for piece %d: %w", p.DealInfo.DealID, i, err)}
}
if height >= proposal.StartEpoch {
return &ErrExpiredDeals{xerrors.Errorf("piece %d (of %d) of sector %d refers expired deal %d - should start at %d, head %d", i, len(sector.Pieces), sector.SectorNumber, p.DealInfo.DealID, proposal.StartEpoch, height)}
}
}
return nil
}

// checkPrecommit checks that data commitment generated in the sealing process
// matches pieces, and that the seal ticket isn't expired
func checkPrecommit(ctx context.Context, maddr address.Address, si SectorInfo, tok TipSetToken, height abi.ChainEpoch, api SealingAPI) (err error) {
Expand Down
4 changes: 2 additions & 2 deletions extern/storage-sealing/states_replica_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func (m *Sealing) handleProveReplicaUpdate(ctx statemachine.Context, sector Sect
return xerrors.Errorf("invalid sector %d with nil CommR", sector.SectorNumber)
}

if err := checkDealExpiration(ctx.Context(), sector, m.Api); err != nil { // Sanity check state
if err := checkPieces(ctx.Context(), m.maddr, sector, m.Api); err != nil { // Sanity check state
return handleErrors(ctx, err, sector)
}

Expand All @@ -58,7 +58,7 @@ func (m *Sealing) handleSubmitReplicaUpdate(ctx statemachine.Context, sector Sec
return nil
}

if err := checkDealExpiration(ctx.Context(), sector, m.Api); err != nil { // Sanity check state
if err := checkPieces(ctx.Context(), m.maddr, sector, m.Api); err != nil { // Sanity check state
return handleErrors(ctx, err, sector)
}

Expand Down

0 comments on commit 6b953a0

Please sign in to comment.