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: reject deals longer than sector lifetime #1916

Merged
merged 1 commit into from
May 7, 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
10 changes: 10 additions & 0 deletions storagemarket/direct_deals_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
lapi "github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/api/v1api"
minertypes "github.com/filecoin-project/lotus/chain/actors/builtin/miner"
"github.com/filecoin-project/lotus/chain/actors/policy"
ltypes "github.com/filecoin-project/lotus/chain/types"
lotuspiece "github.com/filecoin-project/lotus/storage/pipeline/piece"
"github.com/google/uuid"
Expand Down Expand Up @@ -136,6 +137,15 @@ func (ddp *DirectDealsProvider) Accept(ctx context.Context, entry *types.DirectD

log.Infow("found allocation for client", "allocation", spew.Sdump(allocation))

// If the TermMin is longer than initial sector duration, the deal will be dropped from the sector
if allocation.TermMin > miner13types.MaxSectorExpirationExtension-policy.SealRandomnessLookback {
return &api.ProviderDealRejectionInfo{
Accepted: false,
Reason: fmt.Sprintf("allocation term min %d is longer than the sector lifetime %d", allocation.TermMin, miner13types.MaxSectorExpirationExtension-policy.SealRandomnessLookback),
}, nil

}

allActive, err := ddp.directDealsDB.ListActive(ctx)
if err != nil {
return nil, fmt.Errorf("failed to get active deals: %w", err)
Expand Down
Loading