Merge pull request #5620 from filecoin-project/feat/disable-owner-worker-fallback
miner: Config to disable owner/worker address fallback
This commit is contained in:
commit
05274943c9
@ -238,6 +238,9 @@ type AddressConfig struct {
|
|||||||
PreCommitControl []address.Address
|
PreCommitControl []address.Address
|
||||||
CommitControl []address.Address
|
CommitControl []address.Address
|
||||||
TerminateControl []address.Address
|
TerminateControl []address.Address
|
||||||
|
|
||||||
|
DisableOwnerFallback bool
|
||||||
|
DisableWorkerFallback bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// PendingDealInfo has info about pending deals and when they are due to be
|
// PendingDealInfo has info about pending deals and when they are due to be
|
||||||
|
@ -420,6 +420,7 @@ var actorControlList = &cli.Command{
|
|||||||
|
|
||||||
commit := map[address.Address]struct{}{}
|
commit := map[address.Address]struct{}{}
|
||||||
precommit := map[address.Address]struct{}{}
|
precommit := map[address.Address]struct{}{}
|
||||||
|
terminate := map[address.Address]struct{}{}
|
||||||
post := map[address.Address]struct{}{}
|
post := map[address.Address]struct{}{}
|
||||||
|
|
||||||
for _, ca := range mi.ControlAddresses {
|
for _, ca := range mi.ControlAddresses {
|
||||||
@ -446,6 +447,16 @@ var actorControlList = &cli.Command{
|
|||||||
commit[ca] = struct{}{}
|
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) {
|
printKey := func(name string, a address.Address) {
|
||||||
b, err := api.WalletBalance(ctx, a)
|
b, err := api.WalletBalance(ctx, a)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -487,6 +498,9 @@ var actorControlList = &cli.Command{
|
|||||||
if _, ok := commit[a]; ok {
|
if _, ok := commit[a]; ok {
|
||||||
uses = append(uses, color.BlueString("commit"))
|
uses = append(uses, color.BlueString("commit"))
|
||||||
}
|
}
|
||||||
|
if _, ok := terminate[a]; ok {
|
||||||
|
uses = append(uses, color.YellowString("terminate"))
|
||||||
|
}
|
||||||
|
|
||||||
tw.Write(map[string]interface{}{
|
tw.Write(map[string]interface{}{
|
||||||
"name": name,
|
"name": name,
|
||||||
|
@ -200,7 +200,9 @@ Response:
|
|||||||
{
|
{
|
||||||
"PreCommitControl": null,
|
"PreCommitControl": null,
|
||||||
"CommitControl": null,
|
"CommitControl": null,
|
||||||
"TerminateControl": null
|
"TerminateControl": null,
|
||||||
|
"DisableOwnerFallback": true,
|
||||||
|
"DisableWorkerFallback": true
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -95,6 +95,16 @@ type MinerFeeConfig struct {
|
|||||||
type MinerAddressConfig struct {
|
type MinerAddressConfig struct {
|
||||||
PreCommitControl []string
|
PreCommitControl []string
|
||||||
CommitControl []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
|
// API contains configs for API endpoint
|
||||||
|
@ -157,6 +157,9 @@ func AddressSelector(addrConf *config.MinerAddressConfig) func() (*storage.Addre
|
|||||||
return as, nil
|
return as, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
as.DisableOwnerFallback = addrConf.DisableOwnerFallback
|
||||||
|
as.DisableWorkerFallback = addrConf.DisableWorkerFallback
|
||||||
|
|
||||||
for _, s := range addrConf.PreCommitControl {
|
for _, s := range addrConf.PreCommitControl {
|
||||||
addr, err := address.NewFromString(s)
|
addr, err := address.NewFromString(s)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -175,6 +178,15 @@ func AddressSelector(addrConf *config.MinerAddressConfig) func() (*storage.Addre
|
|||||||
as.CommitControl = append(as.CommitControl, addr)
|
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
|
return as, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,11 @@ func (as *AddressSelector) AddressFor(ctx context.Context, a addrSelectApi, mi m
|
|||||||
delete(defaultCtl, mi.Owner)
|
delete(defaultCtl, mi.Owner)
|
||||||
delete(defaultCtl, mi.Worker)
|
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 {
|
if addr.Protocol() != address.ID {
|
||||||
var err error
|
var err error
|
||||||
addr, err = a.StateLookupID(ctx, addr, types.EmptyTSK)
|
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, 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)
|
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
|
return leastBad, bestAvail, nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user