diff --git a/markets/storageadapter/provider.go b/markets/storageadapter/provider.go index 4e361cf1c..dcfcdcbcf 100644 --- a/markets/storageadapter/provider.go +++ b/markets/storageadapter/provider.go @@ -38,6 +38,7 @@ import ( var addPieceRetryWait = 5 * time.Minute var addPieceRetryTimeout = 6 * time.Hour +var defaultMaxProviderCollateralMultiplier = uint64(2) var log = logging.Logger("storageadapter") type ProviderNodeAdapter struct { @@ -51,12 +52,13 @@ type ProviderNodeAdapter struct { dealPublisher *DealPublisher - addBalanceSpec *api.MessageSendSpec - dsMatcher *dealStateMatcher - scMgr *SectorCommittedManager + addBalanceSpec *api.MessageSendSpec + maxDealCollateralMultiplier uint64 + dsMatcher *dealStateMatcher + scMgr *SectorCommittedManager } -func NewProviderNodeAdapter(fc *config.MinerFeeConfig) func(mctx helpers.MetricsCtx, lc fx.Lifecycle, dag dtypes.StagingDAG, secb *sectorblocks.SectorBlocks, full api.FullNode, dealPublisher *DealPublisher) storagemarket.StorageProviderNode { +func NewProviderNodeAdapter(fc *config.MinerFeeConfig, dc *config.DealmakingConfig) func(mctx helpers.MetricsCtx, lc fx.Lifecycle, dag dtypes.StagingDAG, secb *sectorblocks.SectorBlocks, full api.FullNode, dealPublisher *DealPublisher) storagemarket.StorageProviderNode { return func(mctx helpers.MetricsCtx, lc fx.Lifecycle, dag dtypes.StagingDAG, secb *sectorblocks.SectorBlocks, full api.FullNode, dealPublisher *DealPublisher) storagemarket.StorageProviderNode { ctx := helpers.LifecycleCtx(mctx, lc) @@ -73,6 +75,10 @@ func NewProviderNodeAdapter(fc *config.MinerFeeConfig) func(mctx helpers.Metrics if fc != nil { na.addBalanceSpec = &api.MessageSendSpec{MaxFee: abi.TokenAmount(fc.MaxMarketBalanceAddFee)} } + na.maxDealCollateralMultiplier = defaultMaxProviderCollateralMultiplier + if dc != nil { + na.maxDealCollateralMultiplier = dc.MaxProviderCollateralMultiplier + } na.scMgr = NewSectorCommittedManager(ev, na, &apiWrapper{api: full}) return na @@ -257,7 +263,11 @@ func (n *ProviderNodeAdapter) DealProviderCollateralBounds(ctx context.Context, return abi.TokenAmount{}, abi.TokenAmount{}, err } - return bounds.Min, bounds.Max, nil + // The maximum amount of collateral that the provider will put into escrow + // for a deal is calculated as a multiple of the minimum bounded amount + max := types.BigMul(bounds.Min, types.NewInt(n.maxDealCollateralMultiplier)) + + return bounds.Min, max, nil } // TODO: Remove dealID parameter, change publishCid to be cid.Cid (instead of pointer) diff --git a/node/builder.go b/node/builder.go index 0766d934a..5e12cafbe 100644 --- a/node/builder.go +++ b/node/builder.go @@ -408,7 +408,7 @@ var MinerNode = Options( Override(new(dtypes.StorageDealFilter), modules.BasicDealFilter(nil)), Override(new(storagemarket.StorageProvider), modules.StorageProvider), Override(new(*storageadapter.DealPublisher), storageadapter.NewDealPublisher(nil, storageadapter.PublishMsgConfig{})), - Override(new(storagemarket.StorageProviderNode), storageadapter.NewProviderNodeAdapter(nil)), + Override(new(storagemarket.StorageProviderNode), storageadapter.NewProviderNodeAdapter(nil, nil)), Override(HandleMigrateProviderFundsKey, modules.HandleMigrateProviderFunds), Override(HandleDealsKey, modules.HandleDeals), @@ -567,7 +567,7 @@ func ConfigStorageMiner(c interface{}) Option { Period: time.Duration(cfg.Dealmaking.PublishMsgPeriod), MaxDealsPerMsg: cfg.Dealmaking.MaxDealsPerPublishMsg, })), - Override(new(storagemarket.StorageProviderNode), storageadapter.NewProviderNodeAdapter(&cfg.Fees)), + Override(new(storagemarket.StorageProviderNode), storageadapter.NewProviderNodeAdapter(&cfg.Fees, &cfg.Dealmaking)), Override(new(sectorstorage.SealerConfig), cfg.Storage), Override(new(*storage.AddressSelector), modules.AddressSelector(&cfg.Addresses)), diff --git a/node/config/def.go b/node/config/def.go index 3be773367..9019a3f19 100644 --- a/node/config/def.go +++ b/node/config/def.go @@ -54,6 +54,9 @@ type DealmakingConfig struct { // The maximum number of deals to include in a single PublishStorageDeals // message MaxDealsPerPublishMsg uint64 + // The maximum collateral that the provider will put up against a deal, + // as a multiplier of the minimum collateral bound + MaxProviderCollateralMultiplier uint64 Filter string RetrievalFilter string @@ -214,9 +217,10 @@ func DefaultStorageMiner() *StorageMiner { ConsiderUnverifiedStorageDeals: true, PieceCidBlocklist: []cid.Cid{}, // TODO: It'd be nice to set this based on sector size - ExpectedSealDuration: Duration(time.Hour * 24), - PublishMsgPeriod: Duration(time.Hour), - MaxDealsPerPublishMsg: 8, + ExpectedSealDuration: Duration(time.Hour * 24), + PublishMsgPeriod: Duration(time.Hour), + MaxDealsPerPublishMsg: 8, + MaxProviderCollateralMultiplier: 2, }, Fees: MinerFeeConfig{