From 2ad671649c150995d98525999bb3b44547c6454e Mon Sep 17 00:00:00 2001 From: Ingar Shu Date: Wed, 7 Oct 2020 10:35:57 -0700 Subject: [PATCH 1/4] Use FIL units for `miner set-ask` --- cmd/lotus-storage-miner/market.go | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/cmd/lotus-storage-miner/market.go b/cmd/lotus-storage-miner/market.go index 6e3743143a9..67e694c7841 100644 --- a/cmd/lotus-storage-miner/market.go +++ b/cmd/lotus-storage-miner/market.go @@ -154,14 +154,14 @@ var setAskCmd = &cli.Command{ Name: "set-ask", Usage: "Configure the miner's ask", Flags: []cli.Flag{ - &cli.Uint64Flag{ + &cli.StringFlag{ Name: "price", - Usage: "Set the price of the ask for unverified deals (specified as attoFIL / GiB / Epoch) to `PRICE`", + Usage: "Set the price of the ask for unverified deals (specified as FIL / GiB / Epoch) to `PRICE`.", Required: true, }, - &cli.Uint64Flag{ + &cli.StringFlag{ Name: "verified-price", - Usage: "Set the price of the ask for verified deals (specified as attoFIL / GiB / Epoch) to `PRICE`", + Usage: "Set the price of the ask for verified deals (specified as FIL / GiB / Epoch) to `PRICE`", Required: true, }, &cli.StringFlag{ @@ -185,8 +185,15 @@ var setAskCmd = &cli.Command{ } defer closer() - pri := types.NewInt(cctx.Uint64("price")) - vpri := types.NewInt(cctx.Uint64("verified-price")) + pri, err := types.ParseFIL(cctx.String("price")) + if err != nil { + return err + } + + vpri, err := types.ParseFIL(cctx.String("verified-price")) + if err != nil { + return err + } dur, err := time.ParseDuration("720h0m0s") if err != nil { @@ -229,7 +236,7 @@ var setAskCmd = &cli.Command{ return xerrors.Errorf("max piece size (w/bit-padding) %s cannot exceed miner sector size %s", types.SizeStr(types.NewInt(uint64(max))), types.SizeStr(types.NewInt(uint64(smax)))) } - return api.MarketSetAsk(ctx, pri, vpri, abi.ChainEpoch(qty), abi.PaddedPieceSize(min), abi.PaddedPieceSize(max)) + return api.MarketSetAsk(ctx, types.BigInt(pri), types.BigInt(vpri), abi.ChainEpoch(qty), abi.PaddedPieceSize(min), abi.PaddedPieceSize(max)) }, } From 1323e07a2c4913194e45eeb9088ad4eb11840b7e Mon Sep 17 00:00:00 2001 From: Ingar Shu Date: Wed, 7 Oct 2020 10:45:59 -0700 Subject: [PATCH 2/4] Don't show failed deals by default in `client list-deals`, add option to to show failed deals. --- cli/client.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/cli/client.go b/cli/client.go index 7494815bf35..caf3ed7582a 100644 --- a/cli/client.go +++ b/cli/client.go @@ -1039,6 +1039,10 @@ var clientListDeals = &cli.Command{ Usage: "use color in display output", Value: true, }, + &cli.BoolFlag{ + Name: "show-failed", + Usage: "show failed/failing deals", + }, &cli.BoolFlag{ Name: "watch", Usage: "watch deal updates in real-time, rather than a one time list", @@ -1055,6 +1059,7 @@ var clientListDeals = &cli.Command{ verbose := cctx.Bool("verbose") color := cctx.Bool("color") watch := cctx.Bool("watch") + showFailed := cctx.Bool("show-failed") localDeals, err := api.ClientListDeals(ctx) if err != nil { @@ -1071,7 +1076,7 @@ var clientListDeals = &cli.Command{ tm.Clear() tm.MoveCursor(1, 1) - err = outputStorageDeals(ctx, tm.Screen, api, localDeals, verbose, color) + err = outputStorageDeals(ctx, tm.Screen, api, localDeals, verbose, color, showFailed) if err != nil { return err } @@ -1097,7 +1102,7 @@ var clientListDeals = &cli.Command{ } } - return outputStorageDeals(ctx, os.Stdout, api, localDeals, cctx.Bool("verbose"), cctx.Bool("color")) + return outputStorageDeals(ctx, os.Stdout, api, localDeals, cctx.Bool("verbose"), cctx.Bool("color"), showFailed) }, } @@ -1120,7 +1125,7 @@ func dealFromDealInfo(ctx context.Context, full api.FullNode, head *types.TipSet } } -func outputStorageDeals(ctx context.Context, out io.Writer, full api.FullNode, localDeals []api.DealInfo, verbose bool, color bool) error { +func outputStorageDeals(ctx context.Context, out io.Writer, full lapi.FullNode, localDeals []lapi.DealInfo, verbose bool, color bool, showFailed bool) error { sort.Slice(localDeals, func(i, j int) bool { return localDeals[i].CreationTime.Before(localDeals[j].CreationTime) }) @@ -1132,7 +1137,9 @@ func outputStorageDeals(ctx context.Context, out io.Writer, full api.FullNode, l var deals []deal for _, localDeal := range localDeals { - deals = append(deals, dealFromDealInfo(ctx, full, head, localDeal)) + if showFailed || localDeal.State != storagemarket.StorageDealError { + deals = append(deals, dealFromDealInfo(ctx, full, head, localDeal)) + } } if verbose { From f7f229ae54e7782aa12a5ed311626c50857af6f7 Mon Sep 17 00:00:00 2001 From: Ingar Shu Date: Wed, 7 Oct 2020 10:55:07 -0700 Subject: [PATCH 3/4] Show verified status in `client list-deals` --- cli/client.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cli/client.go b/cli/client.go index caf3ed7582a..5411965a708 100644 --- a/cli/client.go +++ b/cli/client.go @@ -1144,7 +1144,7 @@ func outputStorageDeals(ctx context.Context, out io.Writer, full lapi.FullNode, if verbose { w := tabwriter.NewWriter(out, 2, 4, 2, ' ', 0) - fmt.Fprintf(w, "Created\tDealCid\tDealId\tProvider\tState\tOn Chain?\tSlashed?\tPieceCID\tSize\tPrice\tDuration\tMessage\n") + fmt.Fprintf(w, "Created\tDealCid\tDealId\tProvider\tState\tOn Chain?\tSlashed?\tPieceCID\tSize\tPrice\tDuration\tVerified\tMessage\n") for _, d := range deals { onChain := "N" if d.OnChainDealState.SectorStartEpoch != -1 { @@ -1157,7 +1157,7 @@ func outputStorageDeals(ctx context.Context, out io.Writer, full lapi.FullNode, } price := types.FIL(types.BigMul(d.LocalDeal.PricePerEpoch, types.NewInt(d.LocalDeal.Duration))) - fmt.Fprintf(w, "%s\t%s\t%d\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%d\t%s\n", d.LocalDeal.CreationTime.Format(time.Stamp), d.LocalDeal.ProposalCid, d.LocalDeal.DealID, d.LocalDeal.Provider, dealStateString(color, d.LocalDeal.State), onChain, slashed, d.LocalDeal.PieceCID, types.SizeStr(types.NewInt(d.LocalDeal.Size)), price, d.LocalDeal.Duration, d.LocalDeal.Message) + fmt.Fprintf(w, "%s\t%s\t%d\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%d\t%v\t%s\n", d.LocalDeal.CreationTime.Format(time.Stamp), d.LocalDeal.ProposalCid, d.LocalDeal.DealID, d.LocalDeal.Provider, dealStateString(color, d.LocalDeal.State), onChain, slashed, d.LocalDeal.PieceCID, types.SizeStr(types.NewInt(d.LocalDeal.Size)), price, d.LocalDeal.Duration, d.LocalDeal.Verified, d.LocalDeal.Message) } return w.Flush() } @@ -1172,6 +1172,7 @@ func outputStorageDeals(ctx context.Context, out io.Writer, full lapi.FullNode, tablewriter.Col("Size"), tablewriter.Col("Price"), tablewriter.Col("Duration"), + tablewriter.Col("Verified"), tablewriter.NewLineCol("Message")) for _, d := range deals { @@ -1201,6 +1202,7 @@ func outputStorageDeals(ctx context.Context, out io.Writer, full lapi.FullNode, "PieceCID": piece, "Size": types.SizeStr(types.NewInt(d.LocalDeal.Size)), "Price": price, + "Verified": d.LocalDeal.Verified, "Duration": d.LocalDeal.Duration, "Message": d.LocalDeal.Message, }) From c3420c0ceb0023b166ed7a5386b0512ef94e1369 Mon Sep 17 00:00:00 2001 From: Ingar Shu Date: Thu, 8 Oct 2020 12:08:01 -0700 Subject: [PATCH 4/4] Display price, verified-price with units in `lotus-miner storage-deals get-ask` --- cmd/lotus-storage-miner/market.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/lotus-storage-miner/market.go b/cmd/lotus-storage-miner/market.go index 67e694c7841..bb1ebd9ec5c 100644 --- a/cmd/lotus-storage-miner/market.go +++ b/cmd/lotus-storage-miner/market.go @@ -288,7 +288,7 @@ var getAskCmd = &cli.Command{ rem = (time.Second * time.Duration(int64(dlt)*int64(build.BlockDelaySecs))).String() } - fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%d\t%s\t%d\n", ask.Price, ask.VerifiedPrice, types.SizeStr(types.NewInt(uint64(ask.MinPieceSize))), types.SizeStr(types.NewInt(uint64(ask.MaxPieceSize))), ask.Expiry, rem, ask.SeqNo) + fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%d\t%s\t%d\n", types.FIL(ask.Price), types.FIL(ask.VerifiedPrice), types.SizeStr(types.NewInt(uint64(ask.MinPieceSize))), types.SizeStr(types.NewInt(uint64(ask.MaxPieceSize))), ask.Expiry, rem, ask.SeqNo) return w.Flush() },