v1.27.0-a #10

Closed
jonathanface wants to merge 473 commits from v1.27.0-a into master
7 changed files with 14 additions and 12 deletions
Showing only changes of commit a0867a2a60 - Show all commits

View File

@ -291,7 +291,6 @@ type ExportRef struct {
} }
type MinerInfo struct { type MinerInfo struct {
MinerID address.Address
Owner address.Address // Must be an ID-address. Owner address.Address // Must be an ID-address.
Worker address.Address // Must be an ID-address. Worker address.Address // Must be an ID-address.
NewWorker address.Address // Must be an ID-address. NewWorker address.Address // Must be an ID-address.

View File

@ -9,7 +9,6 @@ import (
"path" "path"
"strings" "strings"
"github.com/BurntSushi/toml"
"github.com/urfave/cli/v2" "github.com/urfave/cli/v2"
"golang.org/x/xerrors" "golang.org/x/xerrors"
@ -103,7 +102,7 @@ var configSetCmd = &cli.Command{
} }
lp := config.DefaultLotusProvider() // ensure it's toml lp := config.DefaultLotusProvider() // ensure it's toml
_, err = toml.Decode(string(bytes), lp) _, err = deps.LoadConfigWithUpgrades(string(bytes), lp)
if err != nil { if err != nil {
return fmt.Errorf("cannot decode file: %w", err) return fmt.Errorf("cannot decode file: %w", err)
} }

View File

@ -253,6 +253,12 @@ Get it with: jq .PrivateKey ~/.lotus-miner/keystore/MF2XI2BNNJ3XILLQOJUXMYLUMU`,
var oldAddresses = regexp.MustCompile("(?i)^[addresses]$") var oldAddresses = regexp.MustCompile("(?i)^[addresses]$")
func LoadConfigWithUpgrades(text string, lp *config.LotusProviderConfig) (toml.MetaData, error) {
// allow migration from old config format that was limited to 1 wallet setup.
newText := oldAddresses.ReplaceAllString(text, "[[addresses]]")
meta, err := toml.Decode(newText, &lp)
return meta, err
}
func GetConfig(cctx *cli.Context, db *harmonydb.DB) (*config.LotusProviderConfig, error) { func GetConfig(cctx *cli.Context, db *harmonydb.DB) (*config.LotusProviderConfig, error) {
lp := config.DefaultLotusProvider() lp := config.DefaultLotusProvider()
have := []string{} have := []string{}
@ -271,11 +277,9 @@ func GetConfig(cctx *cli.Context, db *harmonydb.DB) (*config.LotusProviderConfig
return nil, fmt.Errorf("could not read layer '%s': %w", layer, err) return nil, fmt.Errorf("could not read layer '%s': %w", layer, err)
} }
// allow migration from old config format that was limited to 1 wallet setup. meta, err := LoadConfigWithUpgrades(text, lp)
newText := oldAddresses.ReplaceAllString(text, "[[addresses]]")
meta, err := toml.Decode(newText, &lp)
if err != nil { if err != nil {
return nil, fmt.Errorf("could not read layer, bad toml %s: %w", layer, err) return lp, fmt.Errorf("could not read layer, bad toml %s: %w", layer, err)
} }
for _, k := range meta.Keys() { for _, k := range meta.Keys() {
have = append(have, strings.Join(k, " ")) have = append(have, strings.Join(k, " "))

View File

@ -20,6 +20,7 @@ import (
"github.com/filecoin-project/go-address" "github.com/filecoin-project/go-address"
cliutil "github.com/filecoin-project/lotus/cli/util" cliutil "github.com/filecoin-project/lotus/cli/util"
"github.com/filecoin-project/lotus/cmd/lotus-provider/deps"
"github.com/filecoin-project/lotus/lib/harmony/harmonydb" "github.com/filecoin-project/lotus/lib/harmony/harmonydb"
"github.com/filecoin-project/lotus/node/config" "github.com/filecoin-project/lotus/node/config"
"github.com/filecoin-project/lotus/node/modules" "github.com/filecoin-project/lotus/node/modules"
@ -124,7 +125,7 @@ func fromMiner(cctx *cli.Context) (err error) {
return fmt.Errorf("could not read config.toml: %w", err) return fmt.Errorf("could not read config.toml: %w", err)
} }
var lpCfg config.LotusProviderConfig var lpCfg config.LotusProviderConfig
_, err = toml.Decode(string(buf), &lpCfg) _, err = deps.LoadConfigWithUpgrades(string(buf), &lpCfg)
if err != nil { if err != nil {
return fmt.Errorf("could not decode toml: %w", err) return fmt.Errorf("could not decode toml: %w", err)
} }

View File

@ -169,7 +169,6 @@ func (m *StateModule) StateMinerInfo(ctx context.Context, actor address.Address,
} }
ret := api.MinerInfo{ ret := api.MinerInfo{
MinerID: actor,
Owner: info.Owner, Owner: info.Owner,
Worker: info.Worker, Worker: info.Worker,
ControlAddresses: info.ControlAddresses, ControlAddresses: info.ControlAddresses,

View File

@ -292,7 +292,7 @@ func preparePoStMessage(w MsgPrepAPI, as *ctladdr.MultiAddressSelector, maddr ad
goodFunds := big.Add(minGasFeeMsg.RequiredFunds(), minGasFeeMsg.Value) goodFunds := big.Add(minGasFeeMsg.RequiredFunds(), minGasFeeMsg.Value)
minFunds := big.Min(big.Add(minGasFeeMsg.RequiredFunds(), minGasFeeMsg.Value), goodFunds) minFunds := big.Min(big.Add(minGasFeeMsg.RequiredFunds(), minGasFeeMsg.Value), goodFunds)
from, _, err := as.AddressFor(context.Background(), w, mi, api.PoStAddr, goodFunds, minFunds) from, _, err := as.AddressFor(context.Background(), w, maddr, mi, api.PoStAddr, goodFunds, minFunds)
if err != nil { if err != nil {
return nil, nil, xerrors.Errorf("error getting address: %w", err) return nil, nil, xerrors.Errorf("error getting address: %w", err)
} }

View File

@ -15,14 +15,14 @@ type MultiAddressSelector struct {
MinerMap map[address.Address]api.AddressConfig MinerMap map[address.Address]api.AddressConfig
} }
func (as *MultiAddressSelector) AddressFor(ctx context.Context, a NodeApi, mi api.MinerInfo, use api.AddrUse, goodFunds, minFunds abi.TokenAmount) (address.Address, abi.TokenAmount, error) { func (as *MultiAddressSelector) AddressFor(ctx context.Context, a NodeApi, minerID address.Address, mi api.MinerInfo, use api.AddrUse, goodFunds, minFunds abi.TokenAmount) (address.Address, abi.TokenAmount, error) {
if as == nil { if as == nil {
// should only happen in some tests // should only happen in some tests
log.Warnw("smart address selection disabled, using worker address") log.Warnw("smart address selection disabled, using worker address")
return mi.Worker, big.Zero(), nil return mi.Worker, big.Zero(), nil
} }
tmp := as.MinerMap[mi.MinerID] tmp := as.MinerMap[minerID]
var addrs []address.Address var addrs []address.Address
switch use { switch use {