From 1b0bad33dde71bb7874fda52b9afe581fc21f38c Mon Sep 17 00:00:00 2001 From: LexLuthr Date: Thu, 2 May 2024 13:05:09 +0530 Subject: [PATCH] reject deals longer than sector --- storagemarket/direct_deals_provider.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/storagemarket/direct_deals_provider.go b/storagemarket/direct_deals_provider.go index b3b7e936e..75d3d449a 100644 --- a/storagemarket/direct_deals_provider.go +++ b/storagemarket/direct_deals_provider.go @@ -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" @@ -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)