Skip to content

Commit

Permalink
storage: Move control address logic to storage/ctladdr
Browse files Browse the repository at this point in the history
  • Loading branch information
magik6k committed Jun 14, 2022
1 parent dff1bf2 commit 717bda6
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 26 deletions.
4 changes: 2 additions & 2 deletions itests/deals_publish_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"github.com/filecoin-project/lotus/node"
"github.com/filecoin-project/lotus/node/config"
"github.com/filecoin-project/lotus/node/modules"
"github.com/filecoin-project/lotus/storage"
"github.com/filecoin-project/lotus/storage/ctladdr"
)

func TestPublishDealsBatching(t *testing.T) {
Expand Down Expand Up @@ -51,7 +51,7 @@ func TestPublishDealsBatching(t *testing.T) {
MaxDealsPerMsg: maxDealsPerMsg,
}),
),
node.Override(new(*storage.AddressSelector), modules.AddressSelector(&config.MinerAddressConfig{
node.Override(new(*ctladdr.AddressSelector), modules.AddressSelector(&config.MinerAddressConfig{
DealPublishControl: []string{
publisherKey.Address.String(),
},
Expand Down
8 changes: 4 additions & 4 deletions itests/deals_retry_deal_no_funds_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"github.com/filecoin-project/lotus/node"
"github.com/filecoin-project/lotus/node/config"
"github.com/filecoin-project/lotus/node/modules"
"github.com/filecoin-project/lotus/storage"
"github.com/filecoin-project/lotus/storage/ctladdr"
)

var (
Expand Down Expand Up @@ -52,7 +52,7 @@ func TestDealsRetryLackOfFunds(t *testing.T) {
MaxDealsPerMsg: maxDealsPerMsg,
}),
),
node.Override(new(*storage.AddressSelector), modules.AddressSelector(&config.MinerAddressConfig{
node.Override(new(*ctladdr.AddressSelector), modules.AddressSelector(&config.MinerAddressConfig{
DealPublishControl: []string{
publishStorageDealKey.Address.String(),
},
Expand Down Expand Up @@ -128,7 +128,7 @@ func TestDealsRetryLackOfFunds_blockInPublishDeal(t *testing.T) {
MaxDealsPerMsg: maxDealsPerMsg,
}),
),
node.Override(new(*storage.AddressSelector), modules.AddressSelector(&config.MinerAddressConfig{
node.Override(new(*ctladdr.AddressSelector), modules.AddressSelector(&config.MinerAddressConfig{
DealPublishControl: []string{
publishStorageDealKey.Address.String(),
},
Expand Down Expand Up @@ -201,7 +201,7 @@ func TestDealsRetryLackOfFunds_belowLimit(t *testing.T) {
MaxDealsPerMsg: maxDealsPerMsg,
}),
),
node.Override(new(*storage.AddressSelector), modules.AddressSelector(&config.MinerAddressConfig{
node.Override(new(*ctladdr.AddressSelector), modules.AddressSelector(&config.MinerAddressConfig{
DealPublishControl: []string{
publishStorageDealKey.Address.String(),
},
Expand Down
10 changes: 5 additions & 5 deletions markets/storageadapter/dealpublisher.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/node/config"
"github.com/filecoin-project/lotus/storage"
"github.com/filecoin-project/lotus/storage/ctladdr"
)

type dealPublisherAPI interface {
Expand All @@ -48,7 +48,7 @@ type dealPublisherAPI interface {
// publish message with all deals in the queue.
type DealPublisher struct {
api dealPublisherAPI
as *storage.AddressSelector
as *ctladdr.AddressSelector

ctx context.Context
Shutdown context.CancelFunc
Expand Down Expand Up @@ -99,8 +99,8 @@ type PublishMsgConfig struct {
func NewDealPublisher(
feeConfig *config.MinerFeeConfig,
publishMsgCfg PublishMsgConfig,
) func(lc fx.Lifecycle, full api.FullNode, as *storage.AddressSelector) *DealPublisher {
return func(lc fx.Lifecycle, full api.FullNode, as *storage.AddressSelector) *DealPublisher {
) func(lc fx.Lifecycle, full api.FullNode, as *ctladdr.AddressSelector) *DealPublisher {
return func(lc fx.Lifecycle, full api.FullNode, as *ctladdr.AddressSelector) *DealPublisher {
maxFee := abi.NewTokenAmount(0)
if feeConfig != nil {
maxFee = abi.TokenAmount(feeConfig.MaxPublishDealsFee)
Expand All @@ -119,7 +119,7 @@ func NewDealPublisher(

func newDealPublisher(
dpapi dealPublisherAPI,
as *storage.AddressSelector,
as *ctladdr.AddressSelector,
publishMsgCfg PublishMsgConfig,
publishSpec *api.MessageSendSpec,
) *DealPublisher {
Expand Down
5 changes: 3 additions & 2 deletions node/builder_miner.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import (
"github.com/filecoin-project/lotus/node/modules/dtypes"
"github.com/filecoin-project/lotus/node/repo"
"github.com/filecoin-project/lotus/storage"
"github.com/filecoin-project/lotus/storage/ctladdr"
"github.com/filecoin-project/lotus/storage/sectorblocks"
"github.com/filecoin-project/lotus/storage/wdpost"
)
Expand All @@ -51,7 +52,7 @@ var MinerNode = Options(
Override(new(dtypes.NetworkName), modules.StorageNetworkName),

// Mining / proving
Override(new(*storage.AddressSelector), modules.AddressSelector(nil)),
Override(new(*ctladdr.AddressSelector), modules.AddressSelector(nil)),
)

func ConfigStorageMiner(c interface{}) Option {
Expand Down Expand Up @@ -221,7 +222,7 @@ func ConfigStorageMiner(c interface{}) Option {
),

Override(new(sectorstorage.Config), cfg.StorageManager()),
Override(new(*storage.AddressSelector), modules.AddressSelector(&cfg.Addresses)),
Override(new(*ctladdr.AddressSelector), modules.AddressSelector(&cfg.Addresses)),
)
}

Expand Down
3 changes: 2 additions & 1 deletion node/impl/storminer.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import (
"github.com/filecoin-project/lotus/miner"
"github.com/filecoin-project/lotus/node/modules/dtypes"
"github.com/filecoin-project/lotus/storage"
"github.com/filecoin-project/lotus/storage/ctladdr"
"github.com/filecoin-project/lotus/storage/sectorblocks"
"github.com/filecoin-project/lotus/storage/wdpost"
)
Expand Down Expand Up @@ -90,7 +91,7 @@ type StorageMinerAPI struct {
IStorageMgr sectorstorage.SectorManager `optional:"true"`
stores.SectorIndex
storiface.WorkerReturn `optional:"true"`
AddrSel *storage.AddressSelector
AddrSel *ctladdr.AddressSelector

WdPoSt *wdpost.WindowPoStScheduler `optional:"true"`

Expand Down
9 changes: 5 additions & 4 deletions node/modules/storageminer.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ import (
"github.com/filecoin-project/lotus/node/modules/helpers"
"github.com/filecoin-project/lotus/node/repo"
"github.com/filecoin-project/lotus/storage"
"github.com/filecoin-project/lotus/storage/ctladdr"
"github.com/filecoin-project/lotus/storage/wdpost"
)

Expand Down Expand Up @@ -151,9 +152,9 @@ func SectorIDCounter(ds dtypes.MetadataDS) sealing.SectorIDCounter {
return &sidsc{sc}
}

func AddressSelector(addrConf *config.MinerAddressConfig) func() (*storage.AddressSelector, error) {
return func() (*storage.AddressSelector, error) {
as := &storage.AddressSelector{}
func AddressSelector(addrConf *config.MinerAddressConfig) func() (*ctladdr.AddressSelector, error) {
return func() (*ctladdr.AddressSelector, error) {
as := &ctladdr.AddressSelector{}
if addrConf == nil {
return as, nil
}
Expand Down Expand Up @@ -214,7 +215,7 @@ type StorageMinerParams struct {
Prover ffiwrapper.Prover
GetSealingConfigFn dtypes.GetSealingConfigFunc
Journal journal.Journal
AddrSel *storage.AddressSelector
AddrSel *ctladdr.AddressSelector
Maddr dtypes.MinerAddress
}

Expand Down
6 changes: 5 additions & 1 deletion storage/addresses.go → storage/ctladdr/addresses.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package storage
package ctladdr

import (
"context"

logging "github.com/ipfs/go-log/v2"

"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/big"
Expand All @@ -11,6 +13,8 @@ import (
"github.com/filecoin-project/lotus/chain/types"
)

var log = logging.Logger("ctladdr")

type addrSelectApi interface {
WalletBalance(context.Context, address.Address) (types.BigInt, error)
WalletHas(context.Context, address.Address) (bool, error)
Expand Down
5 changes: 3 additions & 2 deletions storage/miner.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
"github.com/filecoin-project/lotus/journal"
"github.com/filecoin-project/lotus/node/config"
"github.com/filecoin-project/lotus/node/modules/dtypes"
"github.com/filecoin-project/lotus/storage/ctladdr"
)

var log = logging.Logger("storageminer")
Expand All @@ -54,7 +55,7 @@ type Miner struct {
sc sealing.SectorIDCounter
verif ffiwrapper.Verifier
prover ffiwrapper.Prover
addrSel *AddressSelector
addrSel *ctladdr.AddressSelector

maddr address.Address

Expand Down Expand Up @@ -139,7 +140,7 @@ func NewMiner(api fullNodeFilteredAPI,
gsd dtypes.GetSealingConfigFunc,
feeCfg config.MinerFeeConfig,
journal journal.Journal,
as *AddressSelector) (*Miner, error) {
as *ctladdr.AddressSelector) (*Miner, error) {
m := &Miner{
api: api,
feeCfg: feeCfg,
Expand Down
4 changes: 2 additions & 2 deletions storage/wdpost/wdpost_run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/extern/sector-storage/storiface"
"github.com/filecoin-project/lotus/journal"
storage2 "github.com/filecoin-project/lotus/storage"
"github.com/filecoin-project/lotus/storage/ctladdr"
)

type mockStorageMinerAPI struct {
Expand Down Expand Up @@ -237,7 +237,7 @@ func TestWDPostDoPost(t *testing.T) {
proofType: proofType,
actor: postAct,
journal: journal.NilJournal(),
addrSel: &storage2.AddressSelector{},
addrSel: &ctladdr.AddressSelector{},
}

di := &dline.Info{
Expand Down
6 changes: 3 additions & 3 deletions storage/wdpost/wdpost_sched.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"github.com/filecoin-project/lotus/extern/sector-storage/ffiwrapper"
"github.com/filecoin-project/lotus/journal"
"github.com/filecoin-project/lotus/node/config"
storage2 "github.com/filecoin-project/lotus/storage"
"github.com/filecoin-project/lotus/storage/ctladdr"
)

var log = logging.Logger("wdpost")
Expand Down Expand Up @@ -65,7 +65,7 @@ type NodeAPI interface {
type WindowPoStScheduler struct {
api NodeAPI
feeCfg config.MinerFeeConfig
addrSel *storage2.AddressSelector
addrSel *ctladdr.AddressSelector
prover storage.Prover
verifier ffiwrapper.Verifier
faultTracker sectorstorage.FaultTracker
Expand All @@ -85,7 +85,7 @@ type WindowPoStScheduler struct {
// NewWindowedPoStScheduler creates a new WindowPoStScheduler scheduler.
func NewWindowedPoStScheduler(api NodeAPI,
cfg config.MinerFeeConfig,
as *storage2.AddressSelector,
as *ctladdr.AddressSelector,
sp storage.Prover,
verif ffiwrapper.Verifier,
ft sectorstorage.FaultTracker,
Expand Down

0 comments on commit 717bda6

Please sign in to comment.