diff --git a/api/api_storage.go b/api/api_storage.go index eb4584e103a..7dc72874608 100644 --- a/api/api_storage.go +++ b/api/api_storage.go @@ -238,6 +238,9 @@ type AddressConfig struct { PreCommitControl []address.Address CommitControl []address.Address TerminateControl []address.Address + + DisableOwnerFallback bool + DisableWorkerFallback bool } // PendingDealInfo has info about pending deals and when they are due to be diff --git a/cmd/lotus-storage-miner/actor.go b/cmd/lotus-storage-miner/actor.go index bcd29ea60b2..84729ca8123 100644 --- a/cmd/lotus-storage-miner/actor.go +++ b/cmd/lotus-storage-miner/actor.go @@ -420,6 +420,7 @@ var actorControlList = &cli.Command{ commit := map[address.Address]struct{}{} precommit := map[address.Address]struct{}{} + terminate := map[address.Address]struct{}{} post := map[address.Address]struct{}{} for _, ca := range mi.ControlAddresses { @@ -446,6 +447,16 @@ var actorControlList = &cli.Command{ commit[ca] = struct{}{} } + for _, ca := range ac.TerminateControl { + ca, err := api.StateLookupID(ctx, ca, types.EmptyTSK) + if err != nil { + return err + } + + delete(post, ca) + terminate[ca] = struct{}{} + } + printKey := func(name string, a address.Address) { b, err := api.WalletBalance(ctx, a) if err != nil { @@ -487,6 +498,9 @@ var actorControlList = &cli.Command{ if _, ok := commit[a]; ok { uses = append(uses, color.BlueString("commit")) } + if _, ok := terminate[a]; ok { + uses = append(uses, color.YellowString("terminate")) + } tw.Write(map[string]interface{}{ "name": name, diff --git a/documentation/en/api-methods-miner.md b/documentation/en/api-methods-miner.md index aa84ebdf255..7ff87383d20 100644 --- a/documentation/en/api-methods-miner.md +++ b/documentation/en/api-methods-miner.md @@ -199,7 +199,9 @@ Response: { "PreCommitControl": null, "CommitControl": null, - "TerminateControl": null + "TerminateControl": null, + "DisableOwnerFallback": true, + "DisableWorkerFallback": true } ``` diff --git a/node/config/def.go b/node/config/def.go index 3be7733679b..a553cbebfd1 100644 --- a/node/config/def.go +++ b/node/config/def.go @@ -86,6 +86,15 @@ type MinerFeeConfig struct { type MinerAddressConfig struct { PreCommitControl []string CommitControl []string + TerminateControl []string + + // DisableOwnerFallback disables usage of the owner address for messages + // sent automatically + DisableOwnerFallback bool + // DisableWorkerFallback disables usage of the worker address for messages + // sent automatically if control addresses are configured, even if those + // addresses don't have enough funds available + DisableWorkerFallback bool } // API contains configs for API endpoint diff --git a/node/modules/storageminer.go b/node/modules/storageminer.go index ba38d501bdc..3195d8c71e0 100644 --- a/node/modules/storageminer.go +++ b/node/modules/storageminer.go @@ -157,6 +157,9 @@ func AddressSelector(addrConf *config.MinerAddressConfig) func() (*storage.Addre return as, nil } + as.DisableOwnerFallback = addrConf.DisableOwnerFallback + as.DisableWorkerFallback = addrConf.DisableWorkerFallback + for _, s := range addrConf.PreCommitControl { addr, err := address.NewFromString(s) if err != nil { @@ -175,6 +178,15 @@ func AddressSelector(addrConf *config.MinerAddressConfig) func() (*storage.Addre as.CommitControl = append(as.CommitControl, addr) } + for _, s := range addrConf.TerminateControl { + addr, err := address.NewFromString(s) + if err != nil { + return nil, xerrors.Errorf("parsing terminate control address: %w", err) + } + + as.TerminateControl = append(as.TerminateControl, addr) + } + return as, nil } } diff --git a/storage/addresses.go b/storage/addresses.go index ad0c6d68369..ff8fcbd993e 100644 --- a/storage/addresses.go +++ b/storage/addresses.go @@ -57,7 +57,13 @@ func (as *AddressSelector) AddressFor(ctx context.Context, a addrSelectApi, mi m addrs = append(addrs, a) } } - addrs = append(addrs, mi.Owner, mi.Worker) + + if len(addrs) == 0 || !as.DisableWorkerFallback { + addrs = append(addrs, mi.Worker) + } + if !as.DisableOwnerFallback { + addrs = append(addrs, mi.Owner) + } return pickAddress(ctx, a, mi, goodFunds, minFunds, addrs) }