diff --git a/markets/storageadapter/provider.go b/markets/storageadapter/provider.go index 9f610d76a..b1071adcd 100644 --- a/markets/storageadapter/provider.go +++ b/markets/storageadapter/provider.go @@ -25,15 +25,15 @@ import ( "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/chain/actors" - "github.com/filecoin-project/lotus/chain/events" - "github.com/filecoin-project/lotus/chain/actors/builtin/market" "github.com/filecoin-project/lotus/chain/actors/builtin/miner" + "github.com/filecoin-project/lotus/chain/events" "github.com/filecoin-project/lotus/chain/events/state" "github.com/filecoin-project/lotus/chain/types" sealing "github.com/filecoin-project/lotus/extern/storage-sealing" "github.com/filecoin-project/lotus/lib/sigs" "github.com/filecoin-project/lotus/markets/utils" + "github.com/filecoin-project/lotus/node/config" "github.com/filecoin-project/lotus/node/modules/dtypes" "github.com/filecoin-project/lotus/storage/sectorblocks" ) @@ -50,14 +50,24 @@ type ProviderNodeAdapter struct { secb *sectorblocks.SectorBlocks ev *events.Events + + publishSpec, addBalanceSpec *api.MessageSendSpec } -func NewProviderNodeAdapter(dag dtypes.StagingDAG, secb *sectorblocks.SectorBlocks, full api.FullNode) storagemarket.StorageProviderNode { - return &ProviderNodeAdapter{ - FullNode: full, - dag: dag, - secb: secb, - ev: events.NewEvents(context.TODO(), full), +func NewProviderNodeAdapter(fc *config.MinerFeeConfig) func(dag dtypes.StagingDAG, secb *sectorblocks.SectorBlocks, full api.FullNode) storagemarket.StorageProviderNode { + return func(dag dtypes.StagingDAG, secb *sectorblocks.SectorBlocks, full api.FullNode) storagemarket.StorageProviderNode { + na := &ProviderNodeAdapter{ + FullNode: full, + + dag: dag, + secb: secb, + ev: events.NewEvents(context.TODO(), full), + } + if fc != nil { + na.publishSpec = &api.MessageSendSpec{MaxFee: abi.TokenAmount(fc.MaxPublishDealsFee)} + na.addBalanceSpec = &api.MessageSendSpec{MaxFee: abi.TokenAmount(fc.MaxMarketBalanceAddFee)} + } + return na } } @@ -84,7 +94,7 @@ func (n *ProviderNodeAdapter) PublishDeals(ctx context.Context, deal storagemark Value: types.NewInt(0), Method: builtin0.MethodsMarket.PublishStorageDeals, Params: params, - }, nil) + }, n.publishSpec) if err != nil { return cid.Undef, err } @@ -183,7 +193,7 @@ func (n *ProviderNodeAdapter) AddFunds(ctx context.Context, addr address.Address From: addr, Value: amount, Method: builtin0.MethodsMarket.AddBalance, - }, nil) + }, n.addBalanceSpec) if err != nil { return cid.Undef, err } diff --git a/node/builder.go b/node/builder.go index 8512d0a0c..41fb01ef7 100644 --- a/node/builder.go +++ b/node/builder.go @@ -344,7 +344,7 @@ func Online() Option { Override(new(dtypes.DealFilter), modules.BasicDealFilter(nil)), Override(new(modules.ProviderDealFunds), modules.NewProviderDealFunds), Override(new(storagemarket.StorageProvider), modules.StorageProvider), - Override(new(storagemarket.StorageProviderNode), storageadapter.NewProviderNodeAdapter), + Override(new(storagemarket.StorageProviderNode), storageadapter.NewProviderNodeAdapter(nil)), Override(HandleRetrievalKey, modules.HandleRetrieval), Override(GetParamsKey, modules.GetParams), Override(HandleDealsKey, modules.HandleDeals), @@ -463,6 +463,8 @@ func ConfigStorageMiner(c interface{}) Option { Override(new(dtypes.DealFilter), modules.BasicDealFilter(dealfilter.CliDealFilter(cfg.Dealmaking.Filter))), ), + Override(new(storagemarket.StorageProviderNode), storageadapter.NewProviderNodeAdapter(&cfg.Fees)), + Override(new(sectorstorage.SealerConfig), cfg.Storage), Override(new(*storage.Miner), modules.StorageMiner(cfg.Fees)), ) diff --git a/node/config/def.go b/node/config/def.go index 1e216238e..b05891e47 100644 --- a/node/config/def.go +++ b/node/config/def.go @@ -61,9 +61,11 @@ type SealingConfig struct { } type MinerFeeConfig struct { - MaxPreCommitGasFee types.FIL - MaxCommitGasFee types.FIL - MaxWindowPoStGasFee types.FIL + MaxPreCommitGasFee types.FIL + MaxCommitGasFee types.FIL + MaxWindowPoStGasFee types.FIL + MaxPublishDealsFee types.FIL + MaxMarketBalanceAddFee types.FIL } // API contains configs for API endpoint @@ -173,9 +175,11 @@ func DefaultStorageMiner() *StorageMiner { }, Fees: MinerFeeConfig{ - MaxPreCommitGasFee: types.FIL(types.BigDiv(types.FromFil(1), types.NewInt(20))), // 0.05 - MaxCommitGasFee: types.FIL(types.BigDiv(types.FromFil(1), types.NewInt(20))), - MaxWindowPoStGasFee: types.FIL(types.FromFil(50)), + MaxPreCommitGasFee: types.FIL(types.BigDiv(types.FromFil(1), types.NewInt(20))), // 0.05 + MaxCommitGasFee: types.FIL(types.BigDiv(types.FromFil(1), types.NewInt(20))), + MaxWindowPoStGasFee: types.FIL(types.FromFil(50)), + MaxPublishDealsFee: types.FIL(types.BigDiv(types.FromFil(1), types.NewInt(33))), // 0.03ish + MaxMarketBalanceAddFee: types.FIL(types.BigDiv(types.FromFil(1), types.NewInt(100))), // 0.01 }, } cfg.Common.API.ListenAddress = "/ip4/127.0.0.1/tcp/2345/http"