Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions docker/devnet/boost/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ fi
## Override config options
echo Updating config values
sed -i 's|ServiceApiInfo = ""|ServiceApiInfo = "ws://localhost:8042"|g' $BOOST_PATH/config.toml
sed -i 's|ExpectedSealDuration = "24h0m0s"|ExpectedSealDuration = "0h0m10s"|g' $BOOST_PATH/config.toml

echo Starting LID service and boost in dev mode...
trap 'kill %1' SIGINT
Expand Down
2 changes: 2 additions & 0 deletions itests/framework/framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,8 @@ func (f *TestFramework) Start() error {
cfg.Dealmaking.EnableLegacyStorageDeals = true
}

cfg.Dealmaking.ExpectedSealDuration = 10

err = lr.SetConfig(func(raw interface{}) {
rcfg := raw.(*config.Boost)
*rcfg = *cfg
Expand Down
6 changes: 3 additions & 3 deletions node/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -600,9 +600,9 @@ func ConfigBoost(cfg *config.Boost) Option {
Override(HandleSetLinkSystem, modules.SetLinkSystem),

// Boost storage deal filter
Override(new(dtypes.StorageDealFilter), modules.BasicDealFilter(cfg.Dealmaking, nil)),
Override(new(dtypes.StorageDealFilter), modules.BasicDealFilter(nil)),
If(cfg.Dealmaking.Filter != "",
Override(new(dtypes.StorageDealFilter), modules.BasicDealFilter(cfg.Dealmaking, dtypes.StorageDealFilter(dealfilter.CliStorageDealFilter(cfg.Dealmaking.Filter)))),
Override(new(dtypes.StorageDealFilter), modules.BasicDealFilter(dtypes.StorageDealFilter(dealfilter.CliStorageDealFilter(cfg.Dealmaking.Filter)))),
),

// Lotus markets storage deal filter
Expand All @@ -628,7 +628,7 @@ func ConfigBoost(cfg *config.Boost) Option {
Override(new(*storageadapter.DealPublisher), storageadapter.NewDealPublisher(&legacyFees, storageadapter.PublishMsgConfig{
Period: time.Duration(cfg.LotusDealmaking.PublishMsgPeriod),
MaxDealsPerMsg: cfg.LotusDealmaking.MaxDealsPerPublishMsg,
StartEpochSealingBuffer: cfg.LotusDealmaking.StartEpochSealingBuffer,
StartEpochSealingBuffer: cfg.Dealmaking.StartEpochSealingBuffer,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should include a comment about this change in the release announcement when this commit lands in a release.
Some SPs may be relying on this config flag.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack, I will make an announcement.

ManualDealPublish: cfg.Dealmaking.ManualDealPublish,
})),

Expand Down
4 changes: 3 additions & 1 deletion node/config/doc_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion node/config/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,9 @@ type DealmakingConfig struct {
// This includes the time the deal will need to get transferred and published
// before being assigned to a sector
ExpectedSealDuration Duration
// Maximum amount of time proposed deal StartEpoch can be in future
// Maximum amount of time proposed deal StartEpoch can be in the future.
// This is applicable only for online deals as offline deals can take long duration
// to import the data
MaxDealStartDelay Duration
// The maximum collateral that the provider will put up against a deal,
// as a multiplier of the minimum collateral bound
Expand Down
75 changes: 73 additions & 2 deletions node/modules/dealfilter.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,25 @@ package modules
import (
"context"
"fmt"
"time"

"github.com/filecoin-project/boost/node/config"
"github.com/filecoin-project/boost-gfm/retrievalmarket"
"github.com/filecoin-project/boost/node/modules/dtypes"
"github.com/filecoin-project/boost/storagemarket/dealfilter"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/lotus/api/v1api"
"github.com/filecoin-project/lotus/build"
lotus_repo "github.com/filecoin-project/lotus/node/repo"
)

func BasicDealFilter(cfg config.DealmakingConfig, userCmd dtypes.StorageDealFilter) func(onlineOk dtypes.ConsiderOnlineStorageDealsConfigFunc,
func BasicDealFilter(userCmd dtypes.StorageDealFilter) func(onlineOk dtypes.ConsiderOnlineStorageDealsConfigFunc,
offlineOk dtypes.ConsiderOfflineStorageDealsConfigFunc,
verifiedOk dtypes.ConsiderVerifiedStorageDealsConfigFunc,
unverifiedOk dtypes.ConsiderUnverifiedStorageDealsConfigFunc,
blocklistFunc dtypes.StorageDealPieceCidBlocklistConfigFunc,
expectedSealTimeFunc dtypes.GetExpectedSealDurationFunc,
startDelay dtypes.GetMaxDealStartDelayFunc,
fullNodeApi v1api.FullNode,
r lotus_repo.LockedRepo,
) dtypes.StorageDealFilter {
return func(onlineOk dtypes.ConsiderOnlineStorageDealsConfigFunc,
Expand All @@ -26,6 +31,7 @@ func BasicDealFilter(cfg config.DealmakingConfig, userCmd dtypes.StorageDealFilt
blocklistFunc dtypes.StorageDealPieceCidBlocklistConfigFunc,
expectedSealTimeFunc dtypes.GetExpectedSealDurationFunc,
startDelay dtypes.GetMaxDealStartDelayFunc,
fullNodeApi v1api.FullNode,
r lotus_repo.LockedRepo,
) dtypes.StorageDealFilter {
return func(ctx context.Context, params dealfilter.DealFilterParams) (bool, string, error) {
Expand Down Expand Up @@ -89,6 +95,38 @@ func BasicDealFilter(cfg config.DealmakingConfig, userCmd dtypes.StorageDealFilt
}
}

// Reject if start epoch is less than the minimum time to be taken to seal the deal
sealDuration, err := expectedSealTimeFunc()
if err != nil {
return false, "miner error", err
}

sealEpochs := sealDuration / (time.Duration(build.BlockDelaySecs) * time.Second)
ts, err := fullNodeApi.ChainHead(ctx)
if err != nil {
return false, "failed to get chain head", err
}
ht := ts.Height()
earliest := abi.ChainEpoch(sealEpochs) + ht
if deal.ClientDealProposal.Proposal.StartEpoch < earliest {
log.Warnw("proposed deal would start before sealing can be completed; rejecting storage deal proposal from client", "piece_cid", deal.ClientDealProposal.Proposal.PieceCID, "client", deal.ClientDealProposal.Proposal.Client.String(), "seal_duration", sealDuration, "earliest", earliest, "curepoch", ht)
return false, fmt.Sprintf("cannot seal a sector before %s", deal.ClientDealProposal.Proposal.StartEpoch), nil
}

// Reject if the start epoch is too far in the future and is online
// We probably do not want to reject offline deal based on this criteria
if !deal.IsOffline {
sd, err := startDelay()
if err != nil {
return false, "miner error", err
}

maxStartEpoch := earliest + abi.ChainEpoch(uint64(sd.Seconds())/build.BlockDelaySecs)
if deal.ClientDealProposal.Proposal.StartEpoch > maxStartEpoch {
return false, fmt.Sprintf("deal start epoch is too far in the future: %s > %s", deal.ClientDealProposal.Proposal.StartEpoch, maxStartEpoch), nil
}
}

if userCmd != nil {
return userCmd(ctx, params)
}
Expand All @@ -97,3 +135,36 @@ func BasicDealFilter(cfg config.DealmakingConfig, userCmd dtypes.StorageDealFilt
}
}
}

func RetrievalDealFilter(userFilter dtypes.RetrievalDealFilter) func(onlineOk dtypes.ConsiderOnlineRetrievalDealsConfigFunc,
offlineOk dtypes.ConsiderOfflineRetrievalDealsConfigFunc) dtypes.RetrievalDealFilter {
return func(onlineOk dtypes.ConsiderOnlineRetrievalDealsConfigFunc,
offlineOk dtypes.ConsiderOfflineRetrievalDealsConfigFunc) dtypes.RetrievalDealFilter {
return func(ctx context.Context, state retrievalmarket.ProviderDealState) (bool, string, error) {
b, err := onlineOk()
if err != nil {
return false, "miner error", err
}

if !b {
log.Warn("online retrieval deal consideration disabled; rejecting retrieval deal proposal from client")
return false, "miner is not accepting online retrieval deals", nil
}

b, err = offlineOk()
if err != nil {
return false, "miner error", err
}

if !b {
log.Info("offline retrieval has not been implemented yet")
}

if userFilter != nil {
return userFilter(ctx, state)
}

return true, "", nil
}
}
}
33 changes: 0 additions & 33 deletions node/modules/storageminer.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,39 +84,6 @@ var (
StorageCounterDSPrefix = "/storage/nextid"
)

func RetrievalDealFilter(userFilter dtypes.RetrievalDealFilter) func(onlineOk dtypes.ConsiderOnlineRetrievalDealsConfigFunc,
offlineOk dtypes.ConsiderOfflineRetrievalDealsConfigFunc) dtypes.RetrievalDealFilter {
return func(onlineOk dtypes.ConsiderOnlineRetrievalDealsConfigFunc,
offlineOk dtypes.ConsiderOfflineRetrievalDealsConfigFunc) dtypes.RetrievalDealFilter {
return func(ctx context.Context, state retrievalmarket.ProviderDealState) (bool, string, error) {
b, err := onlineOk()
if err != nil {
return false, "miner error", err
}

if !b {
log.Warn("online retrieval deal consideration disabled; rejecting retrieval deal proposal from client")
return false, "miner is not accepting online retrieval deals", nil
}

b, err = offlineOk()
if err != nil {
return false, "miner error", err
}

if !b {
log.Info("offline retrieval has not been implemented yet")
}

if userFilter != nil {
return userFilter(ctx, state)
}

return true, "", nil
}
}
}

func NewConsiderOnlineStorageDealsConfigFunc(r lotus_repo.LockedRepo) (dtypes.ConsiderOnlineStorageDealsConfigFunc, error) {
return func() (out bool, err error) {
err = readCfg(r, func(cfg *config.Boost) {
Expand Down