Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: panic when no claim is found #1888

Merged
merged 1 commit into from
Mar 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 24 additions & 17 deletions storagemarket/direct_deals_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,7 @@ func (ddp *DirectDealsProvider) execDeal(ctx context.Context, entry *smtypes.Dir
if derr := ddp.watchSealingUpdates(entry); derr != nil {
return derr
}
ddp.dealLogger.Infow(entry.ID, "deal sealing reached termination state")
if err := ddp.updateCheckpoint(ctx, entry, dealcheckpoints.Complete); err != nil {
return err
}
Expand Down Expand Up @@ -471,20 +472,22 @@ func (ddp *DirectDealsProvider) watchSealingUpdates(entry *smtypes.DirectDeal) *
// Check immediately if the sector has reached a final sealing state
complete := checkSealingFinalized()
if complete {
isClaimed, claimErr := ddp.confirmClaim(ddp.ctx, entry.AllocationID, entry.SectorID)
isClaimed, found, claimErr := ddp.confirmClaim(ddp.ctx, entry.AllocationID, entry.SectorID)
if claimErr != nil {
return &dealMakingError{
retry: types.DealRetryAuto,
error: claimErr,
}
}
if !isClaimed {
return &dealMakingError{
retry: types.DealRetryFatal,
error: errors.New("sector mismatch for claim"),
if found {
if !isClaimed {
return &dealMakingError{
retry: types.DealRetryFatal,
error: errors.New("sector mismatch for claim"),
}
}
return nil
}
return nil
}

// Check status every 10 seconds
Expand All @@ -501,21 +504,22 @@ func (ddp *DirectDealsProvider) watchSealingUpdates(entry *smtypes.DirectDeal) *
case <-ticker.C:
complete := checkSealingFinalized()
if complete {
isClaimed, claimErr := ddp.confirmClaim(ddp.ctx, entry.AllocationID, entry.SectorID)
isClaimed, found, claimErr := ddp.confirmClaim(ddp.ctx, entry.AllocationID, entry.SectorID)
if claimErr != nil {
return &dealMakingError{
retry: types.DealRetryAuto,
error: claimErr,
}
}
ddp.dealLogger.Infow(entry.ID, "deal sealing reached termination state")
if !isClaimed {
return &dealMakingError{
retry: types.DealRetryFatal,
error: errors.New("sector mismatch for claim"),
if found {
if !isClaimed {
return &dealMakingError{
retry: types.DealRetryFatal,
error: errors.New("sector mismatch for claim"),
}
}
return nil
}
return nil
}
}
}
Expand Down Expand Up @@ -669,13 +673,16 @@ func (ddp *DirectDealsProvider) indexAndAnnounce(ctx context.Context, entry *smt
return nil
}

func (ddp *DirectDealsProvider) confirmClaim(ctx context.Context, allocId verifreg9types.AllocationId, sectorNum abi.SectorNumber) (bool, error) {
func (ddp *DirectDealsProvider) confirmClaim(ctx context.Context, allocId verifreg9types.AllocationId, sectorNum abi.SectorNumber) (bool, bool, error) {
claim, err := ddp.fullnodeApi.StateGetClaim(ctx, ddp.Address, verifreg9types.ClaimId(allocId), ltypes.EmptyTSK)
if err != nil {
return false, fmt.Errorf("getting claim details for allocationID %d: %s", allocId, err)
return false, false, fmt.Errorf("getting claim details for allocationID %d: %s", allocId, err)
}
if claim == nil {
return false, false, nil
}
if claim.Sector != sectorNum {
return false, nil
return false, true, nil
}
return true, nil
return true, true, nil
}
Loading