resolve conflicts

This commit is contained in:
Anton Evangelatov 2021-07-12 11:34:37 +02:00
commit d89ddb9315
40 changed files with 449 additions and 94 deletions

View File

@ -286,6 +286,7 @@ type AddrUse int
const ( const (
PreCommitAddr AddrUse = iota PreCommitAddr AddrUse = iota
CommitAddr CommitAddr
DealPublishAddr
PoStAddr PoStAddr
TerminateSectorsAddr TerminateSectorsAddr
@ -295,6 +296,7 @@ type AddressConfig struct {
PreCommitControl []address.Address PreCommitControl []address.Address
CommitControl []address.Address CommitControl []address.Address
TerminateControl []address.Address TerminateControl []address.Address
DealPublishControl []address.Address
DisableOwnerFallback bool DisableOwnerFallback bool
DisableWorkerFallback bool DisableWorkerFallback bool

View File

@ -1,2 +1,2 @@
/dns4/bootstrap-0.interop.fildev.network/tcp/1347/p2p/12D3KooWN86wA54r3v9M8bBYbc1vK9W1ehHDxVGPRaoeUYuXF8R7 /dns4/bootstrap-0.interop.fildev.network/tcp/1347/p2p/12D3KooWLGPq9JL1xwL6gHok7HSNxtK1Q5kyfg4Hk69ifRPghn4i
/dns4/bootstrap-1.interop.fildev.network/tcp/1347/p2p/12D3KooWNZ41kev8mtBZgWe43qam1VX9pJyf87jnaisQP2urZZ2M /dns4/bootstrap-1.interop.fildev.network/tcp/1347/p2p/12D3KooWFYS1f31zafv8mqqYu8U3hEqYvaZ6avWzYU3BmZdpyH3h

Binary file not shown.

Binary file not shown.

View File

@ -196,6 +196,33 @@ func GetMaxProveCommitDuration(ver actors.Version, t abi.RegisteredSealProof) ab
} }
} }
// SetProviderCollateralSupplyTarget sets the percentage of normalized circulating
// supply that must be covered by provider collateral in a deal. This should
// only be used for testing.
func SetProviderCollateralSupplyTarget(num, denom big.Int) {
market2.ProviderCollateralSupplyTarget = builtin2.BigFrac{
Numerator: num,
Denominator: denom,
}
market3.ProviderCollateralSupplyTarget = builtin3.BigFrac{
Numerator: num,
Denominator: denom,
}
market4.ProviderCollateralSupplyTarget = builtin4.BigFrac{
Numerator: num,
Denominator: denom,
}
market5.ProviderCollateralSupplyTarget = builtin5.BigFrac{
Numerator: num,
Denominator: denom,
}
}
func DealProviderCollateralBounds( func DealProviderCollateralBounds(
size abi.PaddedPieceSize, verified bool, size abi.PaddedPieceSize, verified bool,
rawBytePower, qaPower, baselinePower abi.StoragePower, rawBytePower, qaPower, baselinePower abi.StoragePower,

View File

@ -132,6 +132,20 @@ func GetMaxProveCommitDuration(ver actors.Version, t abi.RegisteredSealProof) ab
} }
} }
// SetProviderCollateralSupplyTarget sets the percentage of normalized circulating
// supply that must be covered by provider collateral in a deal. This should
// only be used for testing.
func SetProviderCollateralSupplyTarget(num, denom big.Int) {
{{range .versions}}
{{if (ge . 2)}}
market{{.}}.ProviderCollateralSupplyTarget = builtin{{.}}.BigFrac{
Numerator: num,
Denominator: denom,
}
{{end}}
{{end}}
}
func DealProviderCollateralBounds( func DealProviderCollateralBounds(
size abi.PaddedPieceSize, verified bool, size abi.PaddedPieceSize, verified bool,
rawBytePower, qaPower, baselinePower abi.StoragePower, rawBytePower, qaPower, baselinePower abi.StoragePower,

View File

@ -45,6 +45,7 @@ import (
"github.com/filecoin-project/lotus/chain/actors/builtin" "github.com/filecoin-project/lotus/chain/actors/builtin"
"github.com/filecoin-project/lotus/chain/actors/builtin/market" "github.com/filecoin-project/lotus/chain/actors/builtin/market"
"github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/chain/types"
cliutil "github.com/filecoin-project/lotus/cli/util"
"github.com/filecoin-project/lotus/lib/tablewriter" "github.com/filecoin-project/lotus/lib/tablewriter"
) )
@ -1233,7 +1234,8 @@ var clientListRetrievalsCmd = &cli.Command{
&cli.BoolFlag{ &cli.BoolFlag{
Name: "color", Name: "color",
Usage: "use color in display output", Usage: "use color in display output",
Value: true, Value: cliutil.DefaultColorUse,
DefaultText: "depends on output being a TTY",
}, },
&cli.BoolFlag{ &cli.BoolFlag{
Name: "show-failed", Name: "show-failed",
@ -1806,7 +1808,8 @@ var clientListDeals = &cli.Command{
&cli.BoolFlag{ &cli.BoolFlag{
Name: "color", Name: "color",
Usage: "use color in display output", Usage: "use color in display output",
Value: true, Value: cliutil.DefaultColorUse,
DefaultText: "depends on output being a TTY",
}, },
&cli.BoolFlag{ &cli.BoolFlag{
Name: "show-failed", Name: "show-failed",
@ -2336,7 +2339,8 @@ var clientListTransfers = &cli.Command{
&cli.BoolFlag{ &cli.BoolFlag{
Name: "color", Name: "color",
Usage: "use color in display output", Usage: "use color in display output",
Value: true, Value: cliutil.DefaultColorUse,
DefaultText: "depends on output being a TTY",
}, },
&cli.BoolFlag{ &cli.BoolFlag{
Name: "completed", Name: "completed",

View File

@ -695,7 +695,7 @@ var StateListActorsCmd = &cli.Command{
var StateGetActorCmd = &cli.Command{ var StateGetActorCmd = &cli.Command{
Name: "get-actor", Name: "get-actor",
Usage: "Print actor information", Usage: "Print actor information",
ArgsUsage: "[actorrAddress]", ArgsUsage: "[actorAddress]",
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
api, closer, err := GetFullNodeAPI(cctx) api, closer, err := GetFullNodeAPI(cctx)
if err != nil { if err != nil {

14
cli/util/color.go Normal file
View File

@ -0,0 +1,14 @@
package cliutil
import (
"os"
"github.com/mattn/go-isatty"
)
// DefaultColorUse is the globally referenced variable for all Lotus CLI tools
// It sets to `true` if STDOUT is a TTY or if the variable GOLOG_LOG_FMT is set
// to color (as recognizd by github.com/ipfs/go-log/v2)
var DefaultColorUse = os.Getenv("GOLOG_LOG_FMT") == "color" ||
isatty.IsTerminal(os.Stdout.Fd()) ||
isatty.IsCygwinTerminal(os.Stdout.Fd())

View File

@ -572,7 +572,7 @@ var genesisCarCmd = &cli.Command{
} }
ofile := c.String("out") ofile := c.String("out")
jrnl := journal.NilJournal() jrnl := journal.NilJournal()
bstor := blockstore.NewMemorySync() bstor := blockstore.WrapIDStore(blockstore.NewMemorySync())
sbldr := vm.Syscalls(ffiwrapper.ProofVerifier) sbldr := vm.Syscalls(ffiwrapper.ProofVerifier)
_, err := testing.MakeGenesis(ofile, c.Args().First())(bstor, sbldr, jrnl)() _, err := testing.MakeGenesis(ofile, c.Args().First())(bstor, sbldr, jrnl)()
return err return err

View File

@ -20,6 +20,7 @@ import (
"github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/actors/builtin/miner"
"github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/chain/types"
lcli "github.com/filecoin-project/lotus/cli" lcli "github.com/filecoin-project/lotus/cli"
cliutil "github.com/filecoin-project/lotus/cli/util"
"github.com/filecoin-project/lotus/lib/tablewriter" "github.com/filecoin-project/lotus/lib/tablewriter"
) )
@ -266,7 +267,8 @@ var actorControlList = &cli.Command{
}, },
&cli.BoolFlag{ &cli.BoolFlag{
Name: "color", Name: "color",
Value: true, Value: cliutil.DefaultColorUse,
DefaultText: "depends on output being a TTY",
}, },
}, },
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {

View File

@ -1,10 +1,16 @@
package main package main
import ( import (
"context"
"encoding/binary" "encoding/binary"
"fmt" "fmt"
"math/rand" "math/rand"
"github.com/filecoin-project/lotus/api/v0api"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/lotus/chain/gen"
"github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/chain/types"
lcli "github.com/filecoin-project/lotus/cli" lcli "github.com/filecoin-project/lotus/cli"
builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin" builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
@ -18,6 +24,7 @@ var electionCmd = &cli.Command{
Subcommands: []*cli.Command{ Subcommands: []*cli.Command{
electionRunDummy, electionRunDummy,
electionEstimate, electionEstimate,
electionBacktest,
}, },
} }
@ -124,3 +131,97 @@ var electionEstimate = &cli.Command{
return nil return nil
}, },
} }
var electionBacktest = &cli.Command{
Name: "backtest",
Usage: "Backtest elections with given miner",
ArgsUsage: "[minerAddress]",
Flags: []cli.Flag{
&cli.Uint64Flag{
Name: "height",
Usage: "blockchain head height",
},
&cli.IntFlag{
Name: "count",
Usage: "number of won elections to look for",
Value: 120,
},
},
Action: func(cctx *cli.Context) error {
api, closer, err := lcli.GetFullNodeAPI(cctx)
if err != nil {
return xerrors.Errorf("GetFullNodeAPI: %w", err)
}
defer closer()
ctx := lcli.ReqContext(cctx)
var head *types.TipSet
if cctx.IsSet("height") {
head, err = api.ChainGetTipSetByHeight(ctx, abi.ChainEpoch(cctx.Uint64("height")), types.EmptyTSK)
if err != nil {
return xerrors.Errorf("ChainGetTipSetByHeight: %w", err)
}
} else {
head, err = api.ChainHead(ctx)
if err != nil {
return xerrors.Errorf("ChainHead: %w", err)
}
}
miner, err := address.NewFromString(cctx.Args().First())
if err != nil {
return xerrors.Errorf("miner address: %w", err)
}
count := cctx.Int("count")
if count < 1 {
return xerrors.Errorf("count: %d", count)
}
fmt.Println("height, winCount")
roundEnd := head.Height() + abi.ChainEpoch(1)
for i := 0; i < count; {
for round := head.Height() + abi.ChainEpoch(1); round <= roundEnd; round++ {
i++
win, err := backTestWinner(ctx, miner, round, head, api)
if err == nil && win != nil {
fmt.Printf("%d, %d\n", round, win.WinCount)
}
}
roundEnd = head.Height()
head, err = api.ChainGetTipSet(ctx, head.Parents())
if err != nil {
break
}
}
return nil
},
}
func backTestWinner(ctx context.Context, miner address.Address, round abi.ChainEpoch, ts *types.TipSet, api v0api.FullNode) (*types.ElectionProof, error) {
mbi, err := api.MinerGetBaseInfo(ctx, miner, round, ts.Key())
if err != nil {
return nil, xerrors.Errorf("failed to get mining base info: %w", err)
}
if mbi == nil {
return nil, nil
}
if !mbi.EligibleForMining {
return nil, nil
}
brand := mbi.PrevBeaconEntry
bvals := mbi.BeaconEntries
if len(bvals) > 0 {
brand = bvals[len(bvals)-1]
}
winner, err := gen.IsRoundWinner(ctx, ts, round, miner, brand, mbi, api)
if err != nil {
return nil, xerrors.Errorf("failed to check if we win next round: %w", err)
}
return winner, nil
}

View File

@ -26,6 +26,7 @@ import (
"github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/actors/builtin/miner"
"github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/chain/types"
lcli "github.com/filecoin-project/lotus/cli" lcli "github.com/filecoin-project/lotus/cli"
cliutil "github.com/filecoin-project/lotus/cli/util"
"github.com/filecoin-project/lotus/lib/tablewriter" "github.com/filecoin-project/lotus/lib/tablewriter"
) )
@ -389,7 +390,8 @@ var actorControlList = &cli.Command{
}, },
&cli.BoolFlag{ &cli.BoolFlag{
Name: "color", Name: "color",
Value: true, Value: cliutil.DefaultColorUse,
DefaultText: "depends on output being a TTY",
}, },
}, },
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
@ -435,6 +437,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{}{} terminate := map[address.Address]struct{}{}
dealPublish := map[address.Address]struct{}{}
post := map[address.Address]struct{}{} post := map[address.Address]struct{}{}
for _, ca := range mi.ControlAddresses { for _, ca := range mi.ControlAddresses {
@ -471,6 +474,16 @@ var actorControlList = &cli.Command{
terminate[ca] = struct{}{} terminate[ca] = struct{}{}
} }
for _, ca := range ac.DealPublishControl {
ca, err := api.StateLookupID(ctx, ca, types.EmptyTSK)
if err != nil {
return err
}
delete(post, ca)
dealPublish[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 {
@ -515,6 +528,9 @@ var actorControlList = &cli.Command{
if _, ok := terminate[a]; ok { if _, ok := terminate[a]; ok {
uses = append(uses, color.YellowString("terminate")) uses = append(uses, color.YellowString("terminate"))
} }
if _, ok := dealPublish[a]; ok {
uses = append(uses, color.MagentaString("deals"))
}
tw.Write(map[string]interface{}{ tw.Write(map[string]interface{}{
"name": name, "name": name,

View File

@ -13,6 +13,7 @@ import (
"github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/build"
lcli "github.com/filecoin-project/lotus/cli" lcli "github.com/filecoin-project/lotus/cli"
cliutil "github.com/filecoin-project/lotus/cli/util"
"github.com/filecoin-project/lotus/lib/lotuslog" "github.com/filecoin-project/lotus/lib/lotuslog"
"github.com/filecoin-project/lotus/lib/tracing" "github.com/filecoin-project/lotus/lib/tracing"
"github.com/filecoin-project/lotus/node/repo" "github.com/filecoin-project/lotus/node/repo"
@ -82,6 +83,8 @@ func main() {
}, },
&cli.BoolFlag{ &cli.BoolFlag{
Name: "color", Name: "color",
Value: cliutil.DefaultColorUse,
DefaultText: "depends on output being a TTY",
}, },
&cli.StringFlag{ &cli.StringFlag{
Name: "repo", Name: "repo",

View File

@ -30,6 +30,7 @@ import (
"github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/chain/types"
lcli "github.com/filecoin-project/lotus/cli" lcli "github.com/filecoin-project/lotus/cli"
cliutil "github.com/filecoin-project/lotus/cli/util"
) )
var CidBaseFlag = cli.StringFlag{ var CidBaseFlag = cli.StringFlag{
@ -754,7 +755,8 @@ var transfersListCmd = &cli.Command{
&cli.BoolFlag{ &cli.BoolFlag{
Name: "color", Name: "color",
Usage: "use color in display output", Usage: "use color in display output",
Value: true, Value: cliutil.DefaultColorUse,
DefaultText: "depends on output being a TTY",
}, },
&cli.BoolFlag{ &cli.BoolFlag{
Name: "completed", Name: "completed",

View File

@ -19,6 +19,7 @@ import (
"github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/chain/types"
lcli "github.com/filecoin-project/lotus/cli" lcli "github.com/filecoin-project/lotus/cli"
cliutil "github.com/filecoin-project/lotus/cli/util"
) )
var sealingCmd = &cli.Command{ var sealingCmd = &cli.Command{
@ -36,7 +37,11 @@ var sealingWorkersCmd = &cli.Command{
Name: "workers", Name: "workers",
Usage: "list workers", Usage: "list workers",
Flags: []cli.Flag{ Flags: []cli.Flag{
&cli.BoolFlag{Name: "color"}, &cli.BoolFlag{
Name: "color",
Value: cliutil.DefaultColorUse,
DefaultText: "depends on output being a TTY",
},
}, },
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
color.NoColor = !cctx.Bool("color") color.NoColor = !cctx.Bool("color")
@ -127,7 +132,11 @@ var sealingJobsCmd = &cli.Command{
Name: "jobs", Name: "jobs",
Usage: "list running jobs", Usage: "list running jobs",
Flags: []cli.Flag{ Flags: []cli.Flag{
&cli.BoolFlag{Name: "color"}, &cli.BoolFlag{
Name: "color",
Value: cliutil.DefaultColorUse,
DefaultText: "depends on output being a TTY",
},
&cli.BoolFlag{ &cli.BoolFlag{
Name: "show-ret-done", Name: "show-ret-done",
Usage: "show returned but not consumed calls", Usage: "show returned but not consumed calls",

View File

@ -26,6 +26,7 @@ import (
"github.com/filecoin-project/lotus/lib/tablewriter" "github.com/filecoin-project/lotus/lib/tablewriter"
lcli "github.com/filecoin-project/lotus/cli" lcli "github.com/filecoin-project/lotus/cli"
cliutil "github.com/filecoin-project/lotus/cli/util"
sealing "github.com/filecoin-project/lotus/extern/storage-sealing" sealing "github.com/filecoin-project/lotus/extern/storage-sealing"
) )
@ -163,7 +164,8 @@ var sectorsListCmd = &cli.Command{
&cli.BoolFlag{ &cli.BoolFlag{
Name: "color", Name: "color",
Aliases: []string{"c"}, Aliases: []string{"c"},
Value: true, Value: cliutil.DefaultColorUse,
DefaultText: "depends on output being a TTY",
}, },
&cli.BoolFlag{ &cli.BoolFlag{
Name: "fast", Name: "fast",
@ -436,6 +438,12 @@ var sectorsExtendCmd = &cli.Command{
Usage: "when extending v1 sectors, don't try to extend sectors by fewer than this number of epochs", Usage: "when extending v1 sectors, don't try to extend sectors by fewer than this number of epochs",
Required: false, Required: false,
}, },
&cli.Int64Flag{
Name: "expiration-ignore",
Value: 120,
Usage: "when extending v1 sectors, skip sectors whose current expiration is less than <ignore> epochs from now",
Required: false,
},
&cli.Int64Flag{ &cli.Int64Flag{
Name: "expiration-cutoff", Name: "expiration-cutoff",
Usage: "when extending v1 sectors, skip sectors whose current expiration is more than <cutoff> epochs from now (infinity if unspecified)", Usage: "when extending v1 sectors, skip sectors whose current expiration is more than <cutoff> epochs from now (infinity if unspecified)",
@ -494,6 +502,10 @@ var sectorsExtendCmd = &cli.Command{
continue continue
} }
if si.Expiration < (head.Height() + abi.ChainEpoch(cctx.Int64("expiration-ignore"))) {
continue
}
if cctx.IsSet("expiration-cutoff") { if cctx.IsSet("expiration-cutoff") {
if si.Expiration > (head.Height() + abi.ChainEpoch(cctx.Int64("expiration-cutoff"))) { if si.Expiration > (head.Height() + abi.ChainEpoch(cctx.Int64("expiration-cutoff"))) {
continue continue
@ -508,6 +520,10 @@ var sectorsExtendCmd = &cli.Command{
// Set the new expiration to 48 hours less than the theoretical maximum lifetime // Set the new expiration to 48 hours less than the theoretical maximum lifetime
newExp := ml - (miner3.WPoStProvingPeriod * 2) + si.Activation newExp := ml - (miner3.WPoStProvingPeriod * 2) + si.Activation
if withinTolerance(si.Expiration, newExp) || si.Expiration >= newExp {
continue
}
p, err := api.StateSectorPartition(ctx, maddr, si.SectorNumber, types.EmptyTSK) p, err := api.StateSectorPartition(ctx, maddr, si.SectorNumber, types.EmptyTSK)
if err != nil { if err != nil {
return xerrors.Errorf("getting sector location for sector %d: %w", si.SectorNumber, err) return xerrors.Errorf("getting sector location for sector %d: %w", si.SectorNumber, err)
@ -525,7 +541,7 @@ var sectorsExtendCmd = &cli.Command{
} else { } else {
added := false added := false
for exp := range es { for exp := range es {
if withinTolerance(exp, newExp) { if withinTolerance(exp, newExp) && newExp >= exp && exp > si.Expiration {
es[exp] = append(es[exp], uint64(si.SectorNumber)) es[exp] = append(es[exp], uint64(si.SectorNumber))
added = true added = true
break break

View File

@ -27,6 +27,7 @@ import (
"github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/chain/types"
lcli "github.com/filecoin-project/lotus/cli" lcli "github.com/filecoin-project/lotus/cli"
cliutil "github.com/filecoin-project/lotus/cli/util"
"github.com/filecoin-project/lotus/extern/sector-storage/fsutil" "github.com/filecoin-project/lotus/extern/sector-storage/fsutil"
"github.com/filecoin-project/lotus/extern/sector-storage/stores" "github.com/filecoin-project/lotus/extern/sector-storage/stores"
"github.com/filecoin-project/lotus/extern/sector-storage/storiface" "github.com/filecoin-project/lotus/extern/sector-storage/storiface"
@ -166,7 +167,11 @@ var storageListCmd = &cli.Command{
Name: "list", Name: "list",
Usage: "list local storage paths", Usage: "list local storage paths",
Flags: []cli.Flag{ Flags: []cli.Flag{
&cli.BoolFlag{Name: "color"}, &cli.BoolFlag{
Name: "color",
Value: cliutil.DefaultColorUse,
DefaultText: "depends on output being a TTY",
},
}, },
Subcommands: []*cli.Command{ Subcommands: []*cli.Command{
storageListSectorsCmd, storageListSectorsCmd,
@ -479,7 +484,8 @@ var storageListSectorsCmd = &cli.Command{
Flags: []cli.Flag{ Flags: []cli.Flag{
&cli.BoolFlag{ &cli.BoolFlag{
Name: "color", Name: "color",
Value: true, Value: cliutil.DefaultColorUse,
DefaultText: "depends on output being a TTY",
}, },
}, },
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {

View File

@ -229,6 +229,7 @@ Response:
"PreCommitControl": null, "PreCommitControl": null,
"CommitControl": null, "CommitControl": null,
"TerminateControl": null, "TerminateControl": null,
"DealPublishControl": null,
"DisableOwnerFallback": true, "DisableOwnerFallback": true,
"DisableWorkerFallback": true "DisableWorkerFallback": true
} }

View File

@ -41,7 +41,7 @@ COMMANDS:
GLOBAL OPTIONS: GLOBAL OPTIONS:
--actor value, -a value specify other actor to check state for (read only) --actor value, -a value specify other actor to check state for (read only)
--color (default: false) --color (default: depends on output being a TTY)
--miner-repo value, --storagerepo value Specify miner repo path. flag(storagerepo) and env(LOTUS_STORAGE_PATH) are DEPRECATION, will REMOVE SOON (default: "~/.lotusminer") [$LOTUS_MINER_PATH, $LOTUS_STORAGE_PATH] --miner-repo value, --storagerepo value Specify miner repo path. flag(storagerepo) and env(LOTUS_STORAGE_PATH) are DEPRECATION, will REMOVE SOON (default: "~/.lotusminer") [$LOTUS_MINER_PATH, $LOTUS_STORAGE_PATH]
--help, -h show help (default: false) --help, -h show help (default: false)
--version, -v print the version (default: false) --version, -v print the version (default: false)
@ -315,7 +315,7 @@ USAGE:
OPTIONS: OPTIONS:
--verbose (default: false) --verbose (default: false)
--color (default: true) --color (default: depends on output being a TTY)
--help, -h show help (default: false) --help, -h show help (default: false)
``` ```
@ -908,7 +908,7 @@ USAGE:
OPTIONS: OPTIONS:
--verbose, -v print verbose transfer details (default: false) --verbose, -v print verbose transfer details (default: false)
--color use color in display output (default: true) --color use color in display output (default: depends on output being a TTY)
--completed show completed data transfers (default: false) --completed show completed data transfers (default: false)
--watch watch deal updates in real-time, rather than a one time list (default: false) --watch watch deal updates in real-time, rather than a one time list (default: false)
--show-failed show failed/cancelled transfers (default: false) --show-failed show failed/cancelled transfers (default: false)
@ -1364,7 +1364,7 @@ USAGE:
OPTIONS: OPTIONS:
--show-removed show removed sectors (default: false) --show-removed show removed sectors (default: false)
--color, -c (default: true) --color, -c (default: depends on output being a TTY)
--fast don't show on-chain info for better performance (default: false) --fast don't show on-chain info for better performance (default: false)
--events display number of events the sector has received (default: false) --events display number of events the sector has received (default: false)
--seal-time display how long it took for the sector to be sealed (default: false) --seal-time display how long it took for the sector to be sealed (default: false)
@ -1425,6 +1425,7 @@ OPTIONS:
--new-expiration value new expiration epoch (default: 0) --new-expiration value new expiration epoch (default: 0)
--v1-sectors renews all v1 sectors up to the maximum possible lifetime (default: false) --v1-sectors renews all v1 sectors up to the maximum possible lifetime (default: false)
--tolerance value when extending v1 sectors, don't try to extend sectors by fewer than this number of epochs (default: 20160) --tolerance value when extending v1 sectors, don't try to extend sectors by fewer than this number of epochs (default: 20160)
--expiration-ignore value when extending v1 sectors, skip sectors whose current expiration is less than <ignore> epochs from now (default: 120)
--expiration-cutoff value when extending v1 sectors, skip sectors whose current expiration is more than <cutoff> epochs from now (infinity if unspecified) (default: 0) --expiration-cutoff value when extending v1 sectors, skip sectors whose current expiration is more than <cutoff> epochs from now (infinity if unspecified) (default: 0)
--help, -h show help (default: false) --help, -h show help (default: false)
@ -1759,7 +1760,7 @@ COMMANDS:
help, h Shows a list of commands or help for one command help, h Shows a list of commands or help for one command
OPTIONS: OPTIONS:
--color (default: false) --color (default: depends on output being a TTY)
--help, -h show help (default: false) --help, -h show help (default: false)
--version, -v print the version (default: false) --version, -v print the version (default: false)
@ -1774,7 +1775,7 @@ USAGE:
lotus-miner storage list sectors [command options] [arguments...] lotus-miner storage list sectors [command options] [arguments...]
OPTIONS: OPTIONS:
--color (default: true) --color (default: depends on output being a TTY)
--help, -h show help (default: false) --help, -h show help (default: false)
``` ```
@ -1836,7 +1837,7 @@ USAGE:
lotus-miner sealing jobs [command options] [arguments...] lotus-miner sealing jobs [command options] [arguments...]
OPTIONS: OPTIONS:
--color (default: false) --color (default: depends on output being a TTY)
--show-ret-done show returned but not consumed calls (default: false) --show-ret-done show returned but not consumed calls (default: false)
--help, -h show help (default: false) --help, -h show help (default: false)
@ -1851,7 +1852,7 @@ USAGE:
lotus-miner sealing workers [command options] [arguments...] lotus-miner sealing workers [command options] [arguments...]
OPTIONS: OPTIONS:
--color (default: false) --color (default: depends on output being a TTY)
--help, -h show help (default: false) --help, -h show help (default: false)
``` ```

View File

@ -535,7 +535,7 @@ CATEGORY:
OPTIONS: OPTIONS:
--verbose, -v print verbose deal details (default: false) --verbose, -v print verbose deal details (default: false)
--color use color in display output (default: true) --color use color in display output (default: depends on output being a TTY)
--show-failed show failed/failing deals (default: true) --show-failed show failed/failing deals (default: true)
--completed show completed retrievals (default: false) --completed show completed retrievals (default: false)
--watch watch deal updates in real-time, rather than a one time list (default: false) --watch watch deal updates in real-time, rather than a one time list (default: false)
@ -609,7 +609,7 @@ CATEGORY:
OPTIONS: OPTIONS:
--verbose, -v print verbose deal details (default: false) --verbose, -v print verbose deal details (default: false)
--color use color in display output (default: true) --color use color in display output (default: depends on output being a TTY)
--show-failed show failed/failing deals (default: false) --show-failed show failed/failing deals (default: false)
--watch watch deal updates in real-time, rather than a one time list (default: false) --watch watch deal updates in real-time, rather than a one time list (default: false)
--help, -h show help (default: false) --help, -h show help (default: false)
@ -747,7 +747,7 @@ CATEGORY:
OPTIONS: OPTIONS:
--verbose, -v print verbose transfer details (default: false) --verbose, -v print verbose transfer details (default: false)
--color use color in display output (default: true) --color use color in display output (default: depends on output being a TTY)
--completed show completed data transfers (default: false) --completed show completed data transfers (default: false)
--watch watch deal updates in real-time, rather than a one time list (default: false) --watch watch deal updates in real-time, rather than a one time list (default: false)
--show-failed show failed/cancelled transfers (default: false) --show-failed show failed/cancelled transfers (default: false)
@ -1673,7 +1673,7 @@ NAME:
lotus state get-actor - Print actor information lotus state get-actor - Print actor information
USAGE: USAGE:
lotus state get-actor [command options] [actorrAddress] lotus state get-actor [command options] [actorAddress]
OPTIONS: OPTIONS:
--help, -h show help (default: false) --help, -h show help (default: false)

View File

@ -43,13 +43,8 @@ Testing an RC:
- [ ] **Stage 1 - Internal Testing** - [ ] **Stage 1 - Internal Testing**
- Binaries - Binaries
- [ ] Ensure the RC release has downloadable binaries - [ ] Ensure the RC release has downloadable binaries
- [ ] Validate the binary is able to run on at least one platform
- Upgrade our testnet infra - Upgrade our testnet infra
- [ ] 1 bootstrap node
- [ ] 1 miner
- [ ] Scratch nodes
- [ ] Wait 24 hours, confirm nodes stay in sync - [ ] Wait 24 hours, confirm nodes stay in sync
- [ ] Remaining testnet infra
- Upgrade our mainnet infra - Upgrade our mainnet infra
- [ ] Subset of development full archival nodes - [ ] Subset of development full archival nodes
- [ ] Subset of bootstrappers (1 per region) - [ ] Subset of bootstrappers (1 per region)

4
go.mod
View File

@ -89,7 +89,7 @@ require (
github.com/ipfs/go-ipfs-util v0.0.2 github.com/ipfs/go-ipfs-util v0.0.2
github.com/ipfs/go-ipld-cbor v0.0.5 github.com/ipfs/go-ipld-cbor v0.0.5
github.com/ipfs/go-ipld-format v0.2.0 github.com/ipfs/go-ipld-format v0.2.0
github.com/ipfs/go-log/v2 v2.1.3 github.com/ipfs/go-log/v2 v2.3.0
github.com/ipfs/go-merkledag v0.3.2 github.com/ipfs/go-merkledag v0.3.2
github.com/ipfs/go-metrics-interface v0.0.1 github.com/ipfs/go-metrics-interface v0.0.1
github.com/ipfs/go-metrics-prometheus v0.0.2 github.com/ipfs/go-metrics-prometheus v0.0.2
@ -119,7 +119,7 @@ require (
github.com/libp2p/go-libp2p-yamux v0.5.4 github.com/libp2p/go-libp2p-yamux v0.5.4
github.com/libp2p/go-maddr-filter v0.1.0 github.com/libp2p/go-maddr-filter v0.1.0
github.com/mattn/go-colorable v0.1.6 // indirect github.com/mattn/go-colorable v0.1.6 // indirect
github.com/mattn/go-isatty v0.0.12 github.com/mattn/go-isatty v0.0.13
github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1 github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1
github.com/mitchellh/go-homedir v1.1.0 github.com/mitchellh/go-homedir v1.1.0
github.com/multiformats/go-base32 v0.0.3 github.com/multiformats/go-base32 v0.0.3

7
go.sum
View File

@ -703,10 +703,10 @@ github.com/ipfs/go-log/v2 v2.0.8/go.mod h1:eZs4Xt4ZUJQFM3DlanGhy7TkwwawCZcSByscw
github.com/ipfs/go-log/v2 v2.1.1/go.mod h1:2v2nsGfZsvvAJz13SyFzf9ObaqwHiHxsPLEHntrv9KM= github.com/ipfs/go-log/v2 v2.1.1/go.mod h1:2v2nsGfZsvvAJz13SyFzf9ObaqwHiHxsPLEHntrv9KM=
github.com/ipfs/go-log/v2 v2.1.2-0.20200626104915-0016c0b4b3e4/go.mod h1:2v2nsGfZsvvAJz13SyFzf9ObaqwHiHxsPLEHntrv9KM= github.com/ipfs/go-log/v2 v2.1.2-0.20200626104915-0016c0b4b3e4/go.mod h1:2v2nsGfZsvvAJz13SyFzf9ObaqwHiHxsPLEHntrv9KM=
github.com/ipfs/go-log/v2 v2.1.2/go.mod h1:2v2nsGfZsvvAJz13SyFzf9ObaqwHiHxsPLEHntrv9KM= github.com/ipfs/go-log/v2 v2.1.2/go.mod h1:2v2nsGfZsvvAJz13SyFzf9ObaqwHiHxsPLEHntrv9KM=
github.com/ipfs/go-log/v2 v2.1.3 h1:1iS3IU7aXRlbgUpN8yTTpJ53NXYjAe37vcI5+5nYrzk=
github.com/ipfs/go-log/v2 v2.1.3 h1:1iS3IU7aXRlbgUpN8yTTpJ53NXYjAe37vcI5+5nYrzk=
github.com/ipfs/go-log/v2 v2.1.3/go.mod h1:/8d0SH3Su5Ooc31QlL1WysJhvyOTDCjcCZ9Axpmri6g= github.com/ipfs/go-log/v2 v2.1.3/go.mod h1:/8d0SH3Su5Ooc31QlL1WysJhvyOTDCjcCZ9Axpmri6g=
github.com/ipfs/go-log/v2 v2.1.3/go.mod h1:/8d0SH3Su5Ooc31QlL1WysJhvyOTDCjcCZ9Axpmri6g= github.com/ipfs/go-log/v2 v2.1.3/go.mod h1:/8d0SH3Su5Ooc31QlL1WysJhvyOTDCjcCZ9Axpmri6g=
github.com/ipfs/go-log/v2 v2.3.0 h1:31Re/cPqFHpsRHgyVwjWADPoF0otB1WrjTy8ZFYwEZU=
github.com/ipfs/go-log/v2 v2.3.0/go.mod h1:QqGoj30OTpnKaG/LKTGTxoP2mmQtjVMEnK72gynbe/g=
github.com/ipfs/go-merkledag v0.0.3/go.mod h1:Oc5kIXLHokkE1hWGMBHw+oxehkAaTOqtEb7Zbh6BhLA= github.com/ipfs/go-merkledag v0.0.3/go.mod h1:Oc5kIXLHokkE1hWGMBHw+oxehkAaTOqtEb7Zbh6BhLA=
github.com/ipfs/go-merkledag v0.0.6/go.mod h1:QYPdnlvkOg7GnQRofu9XZimC5ZW5Wi3bKys/4GQQfto= github.com/ipfs/go-merkledag v0.0.6/go.mod h1:QYPdnlvkOg7GnQRofu9XZimC5ZW5Wi3bKys/4GQQfto=
github.com/ipfs/go-merkledag v0.2.3/go.mod h1:SQiXrtSts3KGNmgOzMICy5c0POOpUNQLvB3ClKnBAlk= github.com/ipfs/go-merkledag v0.2.3/go.mod h1:SQiXrtSts3KGNmgOzMICy5c0POOpUNQLvB3ClKnBAlk=
@ -1182,8 +1182,9 @@ github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNx
github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE= github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE=
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-isatty v0.0.13 h1:qdl+GuBjcsKKDco5BsxPJlId98mSWNKqYA+Co0SC1yA=
github.com/mattn/go-isatty v0.0.13/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
github.com/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/mattn/go-runewidth v0.0.10 h1:CoZ3S2P7pvtP45xOtBw+/mDL2z0RKI576gSkzRRpdGg= github.com/mattn/go-runewidth v0.0.10 h1:CoZ3S2P7pvtP45xOtBw+/mDL2z0RKI576gSkzRRpdGg=

View File

@ -73,10 +73,14 @@ func runTestCCUpgrade(t *testing.T, upgradeHeight abi.ChainEpoch) {
{ {
exp, err := client.StateSectorExpiration(ctx, maddr, CC, types.EmptyTSK) exp, err := client.StateSectorExpiration(ctx, maddr, CC, types.EmptyTSK)
if err != nil {
require.Contains(t, err.Error(), "failed to find sector 3") // already cleaned up
} else {
require.NoError(t, err) require.NoError(t, err)
require.NotNil(t, exp) require.NotNil(t, exp)
require.Greater(t, 50000, int(exp.OnTime)) require.Greater(t, 50000, int(exp.OnTime))
} }
}
{ {
exp, err := client.StateSectorExpiration(ctx, maddr, Upgraded, types.EmptyTSK) exp, err := client.StateSectorExpiration(ctx, maddr, Upgraded, types.EmptyTSK)
require.NoError(t, err) require.NoError(t, err)

View File

@ -11,9 +11,13 @@ import (
"github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/chain/actors/builtin/market" "github.com/filecoin-project/lotus/chain/actors/builtin/market"
"github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/chain/wallet"
"github.com/filecoin-project/lotus/itests/kit" "github.com/filecoin-project/lotus/itests/kit"
"github.com/filecoin-project/lotus/markets/storageadapter" "github.com/filecoin-project/lotus/markets/storageadapter"
"github.com/filecoin-project/lotus/node" "github.com/filecoin-project/lotus/node"
"github.com/filecoin-project/lotus/node/config"
"github.com/filecoin-project/lotus/node/modules"
"github.com/filecoin-project/lotus/storage"
market2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/market" market2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/market"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )
@ -28,16 +32,34 @@ func TestPublishDealsBatching(t *testing.T) {
kit.QuietMiningLogs() kit.QuietMiningLogs()
opts := node.Override(new(*storageadapter.DealPublisher), publisherKey, err := wallet.GenerateKey(types.KTSecp256k1)
require.NoError(t, err)
opts := node.Options(
node.Override(new(*storageadapter.DealPublisher),
storageadapter.NewDealPublisher(nil, storageadapter.PublishMsgConfig{ storageadapter.NewDealPublisher(nil, storageadapter.PublishMsgConfig{
Period: publishPeriod, Period: publishPeriod,
MaxDealsPerMsg: maxDealsPerMsg, MaxDealsPerMsg: maxDealsPerMsg,
}), }),
),
node.Override(new(*storage.AddressSelector), modules.AddressSelector(&config.MinerAddressConfig{
DealPublishControl: []string{
publisherKey.Address.String(),
},
DisableOwnerFallback: true,
DisableWorkerFallback: true,
})),
kit.LatestActorsAt(-1),
) )
client, miner, ens := kit.EnsembleMinimal(t, kit.MockProofs(), kit.ConstructorOpts(opts)) client, miner, ens := kit.EnsembleMinimal(t, kit.Account(publisherKey, types.FromFil(10)), kit.MockProofs(), kit.ConstructorOpts(opts))
ens.InterconnectAll().BeginMining(10 * time.Millisecond) ens.InterconnectAll().BeginMining(10 * time.Millisecond)
_, err = client.WalletImport(ctx, &publisherKey.KeyInfo)
require.NoError(t, err)
miner.SetControlAddresses(publisherKey.Address)
dh := kit.NewDealHarness(t, client, miner, miner) dh := kit.NewDealHarness(t, client, miner, miner)
// Starts a deal and waits until it's published // Starts a deal and waits until it's published
@ -92,6 +114,7 @@ func TestPublishDealsBatching(t *testing.T) {
err = pubDealsParams.UnmarshalCBOR(bytes.NewReader(msg.Params)) err = pubDealsParams.UnmarshalCBOR(bytes.NewReader(msg.Params))
require.NoError(t, err) require.NoError(t, err)
require.Len(t, pubDealsParams.Deals, int(maxDealsPerMsg)) require.Len(t, pubDealsParams.Deals, int(maxDealsPerMsg))
require.Equal(t, publisherKey.Address.String(), msg.From.String())
} }
} }
require.Equal(t, 1, count) require.Equal(t, 1, count)

42
itests/kit/control.go Normal file
View File

@ -0,0 +1,42 @@
package kit
import (
"context"
"github.com/stretchr/testify/require"
addr "github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/big"
miner2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/miner"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/actors/builtin/miner"
"github.com/filecoin-project/lotus/chain/types"
)
func (tm *TestMiner) SetControlAddresses(addrs ...addr.Address) {
ctx := context.TODO()
mi, err := tm.FullNode.StateMinerInfo(ctx, tm.ActorAddr, types.EmptyTSK)
require.NoError(tm.t, err)
cwp := &miner2.ChangeWorkerAddressParams{
NewWorker: mi.Worker,
NewControlAddrs: addrs,
}
sp, err := actors.SerializeParams(cwp)
require.NoError(tm.t, err)
smsg, err := tm.FullNode.MpoolPushMessage(ctx, &types.Message{
From: mi.Owner,
To: tm.ActorAddr,
Method: miner.Methods.ChangeWorkerAddress,
Value: big.Zero(),
Params: sp,
}, nil)
require.NoError(tm.t, err)
tm.FullNode.WaitMsg(ctx, smsg.Cid())
}

View File

@ -4,9 +4,11 @@ import (
"context" "context"
"testing" "testing"
"github.com/filecoin-project/go-state-types/abi"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/filecoin-project/go-state-types/abi"
"github.com/ipfs/go-cid"
"github.com/filecoin-project/go-address" "github.com/filecoin-project/go-address"
"github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/chain/types"
@ -27,8 +29,12 @@ func SendFunds(ctx context.Context, t *testing.T, sender *TestFullNode, recipien
sm, err := sender.MpoolPushMessage(ctx, msg, nil) sm, err := sender.MpoolPushMessage(ctx, msg, nil)
require.NoError(t, err) require.NoError(t, err)
res, err := sender.StateWaitMsg(ctx, sm.Cid(), 3, api.LookbackNoLimit, true) sender.WaitMsg(ctx, sm.Cid())
require.NoError(t, err) }
require.EqualValues(t, 0, res.Receipt.ExitCode, "did not successfully send funds") func (f *TestFullNode) WaitMsg(ctx context.Context, msg cid.Cid) {
res, err := f.StateWaitMsg(ctx, msg, 3, api.LookbackNoLimit, true)
require.NoError(f.t, err)
require.EqualValues(f.t, 0, res.Receipt.ExitCode, "message did not successfully execute")
} }

View File

@ -5,6 +5,7 @@ import (
"os" "os"
"github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/big"
"github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/actors/policy" "github.com/filecoin-project/lotus/chain/actors/policy"
logging "github.com/ipfs/go-log/v2" logging "github.com/ipfs/go-log/v2"
@ -13,6 +14,8 @@ import (
func init() { func init() {
_ = logging.SetLogLevel("*", "INFO") _ = logging.SetLogLevel("*", "INFO")
policy.SetProviderCollateralSupplyTarget(big.Zero(), big.NewInt(1))
policy.SetConsensusMinerMinPower(abi.NewStoragePower(2048)) policy.SetConsensusMinerMinPower(abi.NewStoragePower(2048))
policy.SetSupportedProofTypes(abi.RegisteredSealProof_StackedDrg2KiBV1) policy.SetSupportedProofTypes(abi.RegisteredSealProof_StackedDrg2KiBV1)
policy.SetMinVerifiedDealSize(abi.NewStoragePower(256)) policy.SetMinVerifiedDealSize(abi.NewStoragePower(256))

View File

@ -160,8 +160,16 @@ func (c *ClientNodeAdapter) ValidatePublishedDeal(ctx context.Context, deal stor
return 0, xerrors.Errorf("failed to resolve from msg ID addr: %w", err) return 0, xerrors.Errorf("failed to resolve from msg ID addr: %w", err)
} }
if fromid != mi.Worker { var pubOk bool
return 0, xerrors.Errorf("deal wasn't published by storage provider: from=%s, provider=%s", pubmsg.From, deal.Proposal.Provider) pubAddrs := append([]address.Address{mi.Worker, mi.Owner}, mi.ControlAddresses...)
for _, a := range pubAddrs {
if fromid == a {
pubOk = true
break
}
}
if !pubOk {
return 0, xerrors.Errorf("deal wasn't published by storage provider: from=%s, provider=%s,%+v", pubmsg.From, deal.Proposal.Provider, pubAddrs)
} }
if pubmsg.To != miner2.StorageMarketActorAddr { if pubmsg.To != miner2.StorageMarketActorAddr {

View File

@ -7,27 +7,33 @@ import (
"sync" "sync"
"time" "time"
"github.com/ipfs/go-cid"
"go.uber.org/fx" "go.uber.org/fx"
"golang.org/x/xerrors"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/lotus/node/config"
"github.com/filecoin-project/go-address" "github.com/filecoin-project/go-address"
"github.com/filecoin-project/lotus/api" "github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/big"
market2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/market"
"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/actors/builtin/market" "github.com/filecoin-project/lotus/chain/actors/builtin/market"
"github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/actors/builtin/miner"
"github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/chain/types"
market2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/market" "github.com/filecoin-project/lotus/node/config"
"github.com/ipfs/go-cid" "github.com/filecoin-project/lotus/storage"
"golang.org/x/xerrors"
) )
type dealPublisherAPI interface { type dealPublisherAPI interface {
ChainHead(context.Context) (*types.TipSet, error) ChainHead(context.Context) (*types.TipSet, error)
MpoolPushMessage(ctx context.Context, msg *types.Message, spec *api.MessageSendSpec) (*types.SignedMessage, error) MpoolPushMessage(ctx context.Context, msg *types.Message, spec *api.MessageSendSpec) (*types.SignedMessage, error)
StateMinerInfo(context.Context, address.Address, types.TipSetKey) (miner.MinerInfo, error) StateMinerInfo(context.Context, address.Address, types.TipSetKey) (miner.MinerInfo, error)
WalletBalance(context.Context, address.Address) (types.BigInt, error)
WalletHas(context.Context, address.Address) (bool, error)
StateAccountKey(context.Context, address.Address, types.TipSetKey) (address.Address, error)
StateLookupID(context.Context, address.Address, types.TipSetKey) (address.Address, error)
} }
// DealPublisher batches deal publishing so that many deals can be included in // DealPublisher batches deal publishing so that many deals can be included in
@ -40,6 +46,7 @@ type dealPublisherAPI interface {
// publish message with all deals in the queue. // publish message with all deals in the queue.
type DealPublisher struct { type DealPublisher struct {
api dealPublisherAPI api dealPublisherAPI
as *storage.AddressSelector
ctx context.Context ctx context.Context
Shutdown context.CancelFunc Shutdown context.CancelFunc
@ -87,14 +94,14 @@ type PublishMsgConfig struct {
func NewDealPublisher( func NewDealPublisher(
feeConfig *config.MinerFeeConfig, feeConfig *config.MinerFeeConfig,
publishMsgCfg PublishMsgConfig, publishMsgCfg PublishMsgConfig,
) func(lc fx.Lifecycle, full api.FullNode) *DealPublisher { ) func(lc fx.Lifecycle, full api.FullNode, as *storage.AddressSelector) *DealPublisher {
return func(lc fx.Lifecycle, full api.FullNode) *DealPublisher { return func(lc fx.Lifecycle, full api.FullNode, as *storage.AddressSelector) *DealPublisher {
maxFee := abi.NewTokenAmount(0) maxFee := abi.NewTokenAmount(0)
if feeConfig != nil { if feeConfig != nil {
maxFee = abi.TokenAmount(feeConfig.MaxPublishDealsFee) maxFee = abi.TokenAmount(feeConfig.MaxPublishDealsFee)
} }
publishSpec := &api.MessageSendSpec{MaxFee: maxFee} publishSpec := &api.MessageSendSpec{MaxFee: maxFee}
dp := newDealPublisher(full, publishMsgCfg, publishSpec) dp := newDealPublisher(full, as, publishMsgCfg, publishSpec)
lc.Append(fx.Hook{ lc.Append(fx.Hook{
OnStop: func(ctx context.Context) error { OnStop: func(ctx context.Context) error {
dp.Shutdown() dp.Shutdown()
@ -107,12 +114,14 @@ func NewDealPublisher(
func newDealPublisher( func newDealPublisher(
dpapi dealPublisherAPI, dpapi dealPublisherAPI,
as *storage.AddressSelector,
publishMsgCfg PublishMsgConfig, publishMsgCfg PublishMsgConfig,
publishSpec *api.MessageSendSpec, publishSpec *api.MessageSendSpec,
) *DealPublisher { ) *DealPublisher {
ctx, cancel := context.WithCancel(context.Background()) ctx, cancel := context.WithCancel(context.Background())
return &DealPublisher{ return &DealPublisher{
api: dpapi, api: dpapi,
as: as,
ctx: ctx, ctx: ctx,
Shutdown: cancel, Shutdown: cancel,
maxDealsPerPublishMsg: publishMsgCfg.MaxDealsPerMsg, maxDealsPerPublishMsg: publishMsgCfg.MaxDealsPerMsg,
@ -345,9 +354,14 @@ func (p *DealPublisher) publishDealProposals(deals []market2.ClientDealProposal)
return cid.Undef, xerrors.Errorf("serializing PublishStorageDeals params failed: %w", err) return cid.Undef, xerrors.Errorf("serializing PublishStorageDeals params failed: %w", err)
} }
addr, _, err := p.as.AddressFor(p.ctx, p.api, mi, api.DealPublishAddr, big.Zero(), big.Zero())
if err != nil {
return cid.Undef, xerrors.Errorf("selecting address for publishing deals: %w", err)
}
smsg, err := p.api.MpoolPushMessage(p.ctx, &types.Message{ smsg, err := p.api.MpoolPushMessage(p.ctx, &types.Message{
To: market.Address, To: market.Address,
From: mi.Worker, From: addr,
Value: types.NewInt(0), Value: types.NewInt(0),
Method: market.Methods.PublishStorageDeals, Method: market.Methods.PublishStorageDeals,
Params: params, Params: params,

View File

@ -94,7 +94,7 @@ func TestDealPublisher(t *testing.T) {
dpapi := newDPAPI(t) dpapi := newDPAPI(t)
// Create a deal publisher // Create a deal publisher
dp := newDealPublisher(dpapi, PublishMsgConfig{ dp := newDealPublisher(dpapi, nil, PublishMsgConfig{
Period: tc.publishPeriod, Period: tc.publishPeriod,
MaxDealsPerMsg: tc.maxDealsPerMsg, MaxDealsPerMsg: tc.maxDealsPerMsg,
}, &api.MessageSendSpec{MaxFee: abi.NewTokenAmount(1)}) }, &api.MessageSendSpec{MaxFee: abi.NewTokenAmount(1)})
@ -134,7 +134,7 @@ func TestForcePublish(t *testing.T) {
// Create a deal publisher // Create a deal publisher
start := time.Now() start := time.Now()
publishPeriod := time.Hour publishPeriod := time.Hour
dp := newDealPublisher(dpapi, PublishMsgConfig{ dp := newDealPublisher(dpapi, nil, PublishMsgConfig{
Period: publishPeriod, Period: publishPeriod,
MaxDealsPerMsg: 10, MaxDealsPerMsg: 10,
}, &api.MessageSendSpec{MaxFee: abi.NewTokenAmount(1)}) }, &api.MessageSendSpec{MaxFee: abi.NewTokenAmount(1)})
@ -320,6 +320,22 @@ func (d *dpAPI) MpoolPushMessage(ctx context.Context, msg *types.Message, spec *
return &types.SignedMessage{Message: *msg}, nil return &types.SignedMessage{Message: *msg}, nil
} }
func (d *dpAPI) WalletBalance(ctx context.Context, a address.Address) (types.BigInt, error) {
panic("don't call me")
}
func (d *dpAPI) WalletHas(ctx context.Context, a address.Address) (bool, error) {
panic("don't call me")
}
func (d *dpAPI) StateAccountKey(ctx context.Context, a address.Address, key types.TipSetKey) (address.Address, error) {
panic("don't call me")
}
func (d *dpAPI) StateLookupID(ctx context.Context, a address.Address, key types.TipSetKey) (address.Address, error) {
panic("don't call me")
}
func getClientActor(t *testing.T) address.Address { func getClientActor(t *testing.T) address.Address {
return tutils.NewActorAddr(t, "client") return tutils.NewActorAddr(t, "client")
} }

View File

@ -6,6 +6,7 @@ import (
"crypto/rand" "crypto/rand"
"encoding/binary" "encoding/binary"
"fmt" "fmt"
"os"
"sync" "sync"
"time" "time"
@ -325,8 +326,10 @@ minerLoop:
if err := m.sf.MinedBlock(b.Header, base.TipSet.Height()+base.NullRounds); err != nil { if err := m.sf.MinedBlock(b.Header, base.TipSet.Height()+base.NullRounds); err != nil {
log.Errorf("<!!> SLASH FILTER ERROR: %s", err) log.Errorf("<!!> SLASH FILTER ERROR: %s", err)
if os.Getenv("LOTUS_MINER_NO_SLASHFILTER") != "_yes_i_know_i_can_and_probably_will_lose_all_my_fil_and_power_" {
continue continue
} }
}
blkKey := fmt.Sprintf("%d", b.Header.Height) blkKey := fmt.Sprintf("%d", b.Header.Height)
if _, ok := m.minedBlockHeights.Get(blkKey); ok { if _, ok := m.minedBlockHeights.Get(blkKey); ok {

View File

@ -196,6 +196,7 @@ type MinerAddressConfig struct {
PreCommitControl []string PreCommitControl []string
CommitControl []string CommitControl []string
TerminateControl []string TerminateControl []string
DealPublishControl []string
// DisableOwnerFallback disables usage of the owner address for messages // DisableOwnerFallback disables usage of the owner address for messages
// sent automatically // sent automatically
@ -424,6 +425,8 @@ func DefaultStorageMiner() *StorageMiner {
Addresses: MinerAddressConfig{ Addresses: MinerAddressConfig{
PreCommitControl: []string{}, PreCommitControl: []string{},
CommitControl: []string{}, CommitControl: []string{},
TerminateControl: []string{},
DealPublishControl: []string{},
}, },
} }
cfg.Common.API.ListenAddress = "/ip4/127.0.0.1/tcp/2345/http" cfg.Common.API.ListenAddress = "/ip4/127.0.0.1/tcp/2345/http"

View File

@ -188,6 +188,15 @@ func AddressSelector(addrConf *config.MinerAddressConfig) func() (*storage.Addre
as.TerminateControl = append(as.TerminateControl, addr) as.TerminateControl = append(as.TerminateControl, addr)
} }
for _, s := range addrConf.DealPublishControl {
addr, err := address.NewFromString(s)
if err != nil {
return nil, xerrors.Errorf("parsing deal publishing control address: %w", err)
}
as.DealPublishControl = append(as.DealPublishControl, addr)
}
return as, nil return as, nil
} }
} }

View File

@ -5,6 +5,7 @@ import (
"github.com/filecoin-project/go-address" "github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/big"
"github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/actors/builtin/miner"
@ -24,6 +25,12 @@ type AddressSelector struct {
} }
func (as *AddressSelector) AddressFor(ctx context.Context, a addrSelectApi, mi miner.MinerInfo, use api.AddrUse, goodFunds, minFunds abi.TokenAmount) (address.Address, abi.TokenAmount, error) { func (as *AddressSelector) AddressFor(ctx context.Context, a addrSelectApi, mi miner.MinerInfo, use api.AddrUse, goodFunds, minFunds abi.TokenAmount) (address.Address, abi.TokenAmount, error) {
if as == nil {
// should only happen in some tests
log.Warnw("smart address selection disabled, using worker address")
return mi.Worker, big.Zero(), nil
}
var addrs []address.Address var addrs []address.Address
switch use { switch use {
case api.PreCommitAddr: case api.PreCommitAddr:
@ -32,6 +39,8 @@ func (as *AddressSelector) AddressFor(ctx context.Context, a addrSelectApi, mi m
addrs = append(addrs, as.CommitControl...) addrs = append(addrs, as.CommitControl...)
case api.TerminateSectorsAddr: case api.TerminateSectorsAddr:
addrs = append(addrs, as.TerminateControl...) addrs = append(addrs, as.TerminateControl...)
case api.DealPublishAddr:
addrs = append(addrs, as.DealPublishControl...)
default: default:
defaultCtl := map[address.Address]struct{}{} defaultCtl := map[address.Address]struct{}{}
for _, a := range mi.ControlAddresses { for _, a := range mi.ControlAddresses {
@ -43,6 +52,7 @@ func (as *AddressSelector) AddressFor(ctx context.Context, a addrSelectApi, mi m
configCtl := append([]address.Address{}, as.PreCommitControl...) configCtl := append([]address.Address{}, as.PreCommitControl...)
configCtl = append(configCtl, as.CommitControl...) configCtl = append(configCtl, as.CommitControl...)
configCtl = append(configCtl, as.TerminateControl...) configCtl = append(configCtl, as.TerminateControl...)
configCtl = append(configCtl, as.DealPublishControl...)
for _, addr := range configCtl { for _, addr := range configCtl {
if addr.Protocol() != address.ID { if addr.Protocol() != address.ID {

View File

@ -6,7 +6,7 @@
GATE="$LOTUS_PATH"/date_initialized GATE="$LOTUS_PATH"/date_initialized
# Don't init if already initialized. # Don't init if already initialized.
if [ -f "GATE" ]; then if [ -f "$GATE" ]; then
echo lotus already initialized. echo lotus already initialized.
exit 0 exit 0
fi fi

View File

@ -6,7 +6,7 @@
GATE="$LOTUS_PATH"/date_initialized GATE="$LOTUS_PATH"/date_initialized
# Don't init if already initialized. # Don't init if already initialized.
if [ -f "GATE" ]; then if [ -f "$GATE" ]; then
echo lotus already initialized. echo lotus already initialized.
exit 0 exit 0
fi fi

View File

@ -6,7 +6,7 @@
GATE="$LOTUS_PATH"/date_initialized GATE="$LOTUS_PATH"/date_initialized
# Don't init if already initialized. # Don't init if already initialized.
if [ -f "GATE" ]; then if [ -f "$GATE" ]; then
echo lotus already initialized. echo lotus already initialized.
exit 0 exit 0
fi fi

View File

@ -6,7 +6,7 @@
GATE="$LOTUS_PATH"/date_initialized GATE="$LOTUS_PATH"/date_initialized
# Don't init if already initialized. # Don't init if already initialized.
if [ -f "GATE" ]; then if [ -f "$GATE" ]; then
echo lotus already initialized. echo lotus already initialized.
exit 0 exit 0
fi fi