diff --git a/api/api_storage.go b/api/api_storage.go index 3f8143433..a153875f0 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 cd3881495..8c2ab95bd 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 e6a179cb0..da10a8bcd 100644 --- a/documentation/en/api-methods-miner.md +++ b/documentation/en/api-methods-miner.md @@ -200,7 +200,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 51d284e50..5a6d41549 100644 --- a/node/config/def.go +++ b/node/config/def.go @@ -95,6 +95,16 @@ 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. + // A control address that doesn't have enough funds will still be chosen + // over the worker address if this flag is set. + DisableWorkerFallback bool } // API contains configs for API endpoint diff --git a/node/modules/storageminer.go b/node/modules/storageminer.go index 818e439fa..d89474eee 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 ad0c6d683..a8e5e7101 100644 --- a/storage/addresses.go +++ b/storage/addresses.go @@ -40,7 +40,11 @@ func (as *AddressSelector) AddressFor(ctx context.Context, a addrSelectApi, mi m delete(defaultCtl, mi.Owner) delete(defaultCtl, mi.Worker) - for _, addr := range append(append([]address.Address{}, as.PreCommitControl...), as.CommitControl...) { + configCtl := append([]address.Address{}, as.PreCommitControl...) + configCtl = append(configCtl, as.CommitControl...) + configCtl = append(configCtl, as.TerminateControl...) + + for _, addr := range configCtl { if addr.Protocol() != address.ID { var err error addr, err = a.StateLookupID(ctx, addr, types.EmptyTSK) @@ -57,7 +61,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) } @@ -91,7 +101,7 @@ func pickAddress(ctx context.Context, a addrSelectApi, mi miner.MinerInfo, goodF } } - log.Warnw("No address had enough funds to for full PoSt message Fee, selecting least bad address", "address", leastBad, "balance", types.FIL(bestAvail), "optimalFunds", types.FIL(goodFunds), "minFunds", types.FIL(minFunds)) + log.Warnw("No address had enough funds to for full message Fee, selecting least bad address", "address", leastBad, "balance", types.FIL(bestAvail), "optimalFunds", types.FIL(goodFunds), "minFunds", types.FIL(minFunds)) return leastBad, bestAvail, nil }