Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

miner: Config to disable owner/worker address fallback #5620

Merged
merged 3 commits into from
Mar 10, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions api/api_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions cmd/lotus-storage-miner/actor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion documentation/en/api-methods-miner.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,9 @@ Response:
{
"PreCommitControl": null,
"CommitControl": null,
"TerminateControl": null
"TerminateControl": null,
"DisableOwnerFallback": true,
"DisableWorkerFallback": true
}
```

Expand Down
9 changes: 9 additions & 0 deletions node/config/def.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// 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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(found the comment confusing)

// addresses don't have enough funds available
DisableWorkerFallback bool
}

// API contains configs for API endpoint
Expand Down
12 changes: 12 additions & 0 deletions node/modules/storageminer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
}
}
Expand Down
16 changes: 13 additions & 3 deletions storage/addresses.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
}
Expand Down Expand Up @@ -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
}
Expand Down