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

feat: add list storage/retrieval asks cli #272

Merged
merged 1 commit into from
Feb 3, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions api/clients/mix_msgclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func (msgClient *MixMsgClient) WaitMsg(ctx context.Context, mCid cid.Cid, confid
case msgTypes.UnKnown:
continue
//OnChain
case msgTypes.ReplacedMsg:
case msgTypes.NonceConflictMsg:
fallthrough
case msgTypes.OnChainMsg:
if msg.Confidence > int64(confidence) {
Expand Down Expand Up @@ -198,7 +198,7 @@ func (msgClient *MixMsgClient) SearchMsg(ctx context.Context, from types.TipSetK
case msgTypes.UnKnown:
return nil, nil
//OnChain
case msgTypes.ReplacedMsg:
case msgTypes.NonceConflictMsg:
fallthrough
case msgTypes.OnChainMsg:
return &types.MsgLookup{
Expand Down
108 changes: 1 addition & 107 deletions api/impl/venus_market.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ package impl

import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
"os"
"sort"
"time"
Expand Down Expand Up @@ -234,7 +232,7 @@ func (m *MarketNodeImpl) MarketSetAsk(ctx context.Context, mAddr address.Address
return m.StorageAsk.SetAsk(ctx, mAddr, price, verifiedPrice, duration, options...)
}

func (m *MarketNodeImpl) MarketListAsk(ctx context.Context) ([]*types.SignedStorageAsk, error) {
func (m *MarketNodeImpl) MarketListStorageAsk(ctx context.Context) ([]*types.SignedStorageAsk, error) {
return m.StorageAsk.ListAsk(ctx)
}

Expand Down Expand Up @@ -899,110 +897,6 @@ func (m *MarketNodeImpl) PaychVoucherList(ctx context.Context, pch address.Addre
return m.PaychAPI.PaychVoucherList(ctx, pch)
}

// ImportV1Data deprecated api
func (m *MarketNodeImpl) ImportV1Data(ctx context.Context, src string) error {
type minerDealsIncludeStatus struct {
MinerDeal storagemarket.MinerDeal
DealInfo piecestore.DealInfo
Status types.PieceStatus
}

type exportData struct {
Miner address.Address
MinerDeals []minerDealsIncludeStatus
SignedVoucher map[string]*types.ChannelInfo
StorageAsk *storagemarket.SignedStorageAsk
RetrievalAsk *retrievalmarket.Ask
RetrievalDeals []retrievalmarket.ProviderDealState
}

srcBytes, err := ioutil.ReadFile(src)
if err != nil {
return err
}

data := exportData{}
err = json.Unmarshal(srcBytes, &data)
if err != nil {
return err
}

err = m.Repo.StorageAskRepo().SetAsk(ctx, types.FromChainAsk(data.StorageAsk))
if err != nil {
return err
}

err = m.Repo.RetrievalAskRepo().SetAsk(ctx, &types.RetrievalAsk{
Miner: data.Miner,
PricePerByte: data.RetrievalAsk.PricePerByte,
UnsealPrice: data.RetrievalAsk.UnsealPrice,
PaymentInterval: data.RetrievalAsk.PaymentInterval,
PaymentIntervalIncrease: data.RetrievalAsk.PaymentIntervalIncrease,
})
if err != nil {
return err
}

for _, channelInfo := range data.SignedVoucher {
err = m.Repo.PaychChannelInfoRepo().SaveChannel(ctx, channelInfo)
if err != nil {
return fmt.Errorf("save channel fail %w", err)
}
}

for _, minerDeal := range data.MinerDeals {
err = m.Repo.StorageDealRepo().SaveDeal(ctx, &types.MinerDeal{
ClientDealProposal: minerDeal.MinerDeal.ClientDealProposal,
ProposalCid: minerDeal.MinerDeal.ProposalCid,
AddFundsCid: minerDeal.MinerDeal.AddFundsCid,
PublishCid: minerDeal.MinerDeal.PublishCid,
Miner: minerDeal.MinerDeal.Miner,
Client: minerDeal.MinerDeal.Client,
State: minerDeal.MinerDeal.State,
PiecePath: minerDeal.MinerDeal.PiecePath,
// PayloadSize: ,//
MetadataPath: minerDeal.MinerDeal.MetadataPath,
SlashEpoch: minerDeal.MinerDeal.SlashEpoch,
FastRetrieval: minerDeal.MinerDeal.FastRetrieval,
Message: minerDeal.MinerDeal.Message,
FundsReserved: minerDeal.MinerDeal.FundsReserved,
Ref: minerDeal.MinerDeal.Ref,
AvailableForRetrieval: minerDeal.MinerDeal.AvailableForRetrieval,
DealID: minerDeal.MinerDeal.DealID,
CreationTime: minerDeal.MinerDeal.CreationTime,
TransferChannelID: minerDeal.MinerDeal.TransferChannelId,
SectorNumber: minerDeal.MinerDeal.SectorNumber,
Offset: minerDeal.DealInfo.Offset,
PieceStatus: minerDeal.Status,
InboundCAR: minerDeal.MinerDeal.InboundCAR,
})
if err != nil {
return fmt.Errorf("save storage deal fail %w", err)
}
}

for _, retrievalDeal := range data.RetrievalDeals {
err = m.Repo.RetrievalDealRepo().SaveDeal(ctx, &types.ProviderDealState{
DealProposal: retrievalDeal.DealProposal,
StoreID: retrievalDeal.StoreID,
// SelStorageProposalCid: retrievalDeal,
ChannelID: retrievalDeal.ChannelID,
Status: retrievalDeal.Status,
Receiver: retrievalDeal.Receiver,
TotalSent: retrievalDeal.TotalSent,
FundsReceived: retrievalDeal.FundsReceived,
Message: retrievalDeal.Message,
CurrentInterval: retrievalDeal.CurrentInterval,
LegacyProtocol: retrievalDeal.LegacyProtocol,
})
if err != nil {
return fmt.Errorf("retrieval storage deal fail %w", err)
}
}

return nil
}

func (m *MarketNodeImpl) AddFsPieceStorage(ctx context.Context, name string, path string, readonly bool) error {
ifs := &config.FsPieceStorage{ReadOnly: readonly, Path: path, Name: name}
fsps, err := piecestorage.NewFsPieceStorage(ifs)
Expand Down
31 changes: 0 additions & 31 deletions cli/migration.go

This file was deleted.

41 changes: 37 additions & 4 deletions cli/retrieval-asks.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ var retirevalAsksCmds = &cli.Command{
Name: "ask",
Usage: "Configure retrieval asks",
Subcommands: []*cli.Command{
retrievalGetAskCmd,
retrievalSetAskCmd,
getRetrievalAskCmd,
setRetrievalAskCmd,
listRetrievalAskCmd,
},
}

var retrievalSetAskCmd = &cli.Command{
var setRetrievalAskCmd = &cli.Command{
Name: "set",
ArgsUsage: "<miner address>",
Usage: "Configure(set/update)the provider's retrieval ask",
Expand Down Expand Up @@ -139,7 +140,7 @@ var retrievalSetAskCmd = &cli.Command{
},
}

var retrievalGetAskCmd = &cli.Command{
var getRetrievalAskCmd = &cli.Command{
Name: "get",
ArgsUsage: "<miner address>",
Usage: "Get the provider's current retrieval ask",
Expand Down Expand Up @@ -181,3 +182,35 @@ var retrievalGetAskCmd = &cli.Command{
return w.Flush()
},
}

var listRetrievalAskCmd = &cli.Command{
Name: "list",
Usage: "List the currently configured retrieval miner asks",
Action: func(cctx *cli.Context) error {
ctx := DaemonContext(cctx)

api, closer, err := NewMarketNode(cctx)
if err != nil {
return err
}
defer closer()

asks, err := api.MarketListRetrievalAsk(ctx)
if err != nil {
return err
}

w := tabwriter.NewWriter(os.Stdout, 2, 4, 2, ' ', 0)
fmt.Fprintf(w, "Miner\tPrice per Byte\tUnseal Price\tPayment Interval\tPayment Interval Increase\n")
for _, ask := range asks {
fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\n",
ask.Miner,
types.FIL(ask.PricePerByte),
types.FIL(ask.UnsealPrice),
units.BytesSize(float64(ask.PaymentInterval)),
units.BytesSize(float64(ask.PaymentIntervalIncrease)),
)
}
return w.Flush()
},
}
58 changes: 54 additions & 4 deletions cli/storage-ask.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ var storageAsksCmds = &cli.Command{
Name: "ask",
Usage: "Configure storage asks",
Subcommands: []*cli.Command{
setAskCmd,
getAskCmd,
setStorageAskCmd,
getStorageAskCmd,
listStorageAsksCmd,
},
}

var setAskCmd = &cli.Command{
var setStorageAskCmd = &cli.Command{
Name: "set",
ArgsUsage: "<miner address>",
Usage: "Configure(set/update) the miner's ask",
Expand Down Expand Up @@ -150,7 +151,7 @@ var setAskCmd = &cli.Command{
},
}

var getAskCmd = &cli.Command{
var getStorageAskCmd = &cli.Command{
Name: "get",
Usage: "Print the miner's ask",
ArgsUsage: "<miner address>",
Expand Down Expand Up @@ -210,3 +211,52 @@ var getAskCmd = &cli.Command{
return w.Flush()
},
}

var listStorageAsksCmd = &cli.Command{
Name: "list",
Usage: "List the currently configured storage provider asks",
Action: func(cctx *cli.Context) error {
ctx := DaemonContext(cctx)

fnapi, closer, err := NewFullNode(cctx)
if err != nil {
return err
}
defer closer()

smapi, closer, err := NewMarketNode(cctx)
if err != nil {
return err
}
defer closer()

asks, err := smapi.MarketListStorageAsk(ctx)
if err != nil {
return err
}

head, err := fnapi.ChainHead(ctx)
if err != nil {
return err
}

w := tabwriter.NewWriter(os.Stdout, 2, 4, 2, ' ', 0)
fmt.Fprintf(w, "Miner\tPrice per GiB/Epoch\tVerified\tMin. Piece Size (padded)\tMax. Piece Size (padded)\tExpiry (Epoch)\tExpiry (Appx. Rem. Time)\tSeq. No.\n")

for _, sask := range asks {
var ask *storagemarket.StorageAsk
if sask != nil && sask.Ask != nil {
ask = sask.Ask
}

dlt := ask.Expiry - head.Height()
rem := "<expired>"
if dlt > 0 {
rem = (time.Second * time.Duration(int64(dlt)*int64(constants.MainNetBlockDelaySecs))).String()
}

fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\t%d\t%s\t%d\n", ask.Miner, 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()
},
}
1 change: 0 additions & 1 deletion cmd/venus-market/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ func main() {
cli2.NetCmd,
cli2.DataTransfersCmd,
cli2.DagstoreCmd,
cli2.MigrateCmd,
cli2.PieceStorageCmd,
cli2.MarketCmds,
cli2.StatsCmds,
Expand Down
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,22 @@ require (
github.com/filecoin-project/go-fil-markets v1.24.0-v17
github.com/filecoin-project/go-jsonrpc v0.1.5
github.com/filecoin-project/go-padreader v0.0.1
github.com/filecoin-project/go-state-types v0.9.8
github.com/filecoin-project/go-state-types v0.9.9
github.com/filecoin-project/go-statemachine v1.0.2
github.com/filecoin-project/go-statestore v0.2.0
github.com/filecoin-project/specs-actors/v2 v2.3.6
github.com/filecoin-project/specs-actors/v7 v7.0.1
github.com/filecoin-project/venus v1.9.0
github.com/filecoin-project/venus v1.9.0-rc1.0.20230203064217-14f0513a243e
github.com/filecoin-project/venus-auth v1.9.0
github.com/filecoin-project/venus-messager v1.9.0
github.com/filecoin-project/venus-messager v1.9.0-rc1
github.com/golang/mock v1.6.0
github.com/google/uuid v1.3.0
github.com/gorilla/mux v1.8.0
github.com/hannahhoward/go-pubsub v0.0.0-20200423002714-8d62886cc36e
github.com/howeyc/gopass v0.0.0-20210920133722-c8aef6fb66ef
github.com/ipfs-force-community/metrics v1.0.1-0.20220824061112-ac916bacf2ea
github.com/ipfs-force-community/venus-common-utils v0.0.0-20220217030526-e5e4c6bc14f7
github.com/ipfs-force-community/venus-gateway v1.9.0
github.com/ipfs-force-community/venus-gateway v1.9.0-rc1
github.com/ipfs/go-block-format v0.0.3
github.com/ipfs/go-blockservice v0.4.0
github.com/ipfs/go-cid v0.2.0
Expand Down
16 changes: 8 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -408,8 +408,8 @@ github.com/filecoin-project/go-state-types v0.1.4/go.mod h1:xCA/WfKlC2zcn3fUmDv4
github.com/filecoin-project/go-state-types v0.1.6/go.mod h1:UwGVoMsULoCK+bWjEdd/xLCvLAQFBC7EDT477SKml+Q=
github.com/filecoin-project/go-state-types v0.1.8/go.mod h1:UwGVoMsULoCK+bWjEdd/xLCvLAQFBC7EDT477SKml+Q=
github.com/filecoin-project/go-state-types v0.1.10/go.mod h1:UwGVoMsULoCK+bWjEdd/xLCvLAQFBC7EDT477SKml+Q=
github.com/filecoin-project/go-state-types v0.9.8 h1:xkdITiR7h691z1tWOhNCJxHI+cq+Mq7ATkpHQ7f1gu8=
github.com/filecoin-project/go-state-types v0.9.8/go.mod h1:+HCZifUV+e8TlQkgll22Ucuiq8OrVJkK+4Kh4u75iiw=
github.com/filecoin-project/go-state-types v0.9.9 h1:gd7Mo6f9jHHpLahttBE88YeQA77i4GK6W5kFdQDnuME=
github.com/filecoin-project/go-state-types v0.9.9/go.mod h1:+HCZifUV+e8TlQkgll22Ucuiq8OrVJkK+4Kh4u75iiw=
github.com/filecoin-project/go-statemachine v0.0.0-20200925024713-05bd7c71fbfe/go.mod h1:FGwQgZAt2Gh5mjlwJUlVB62JeYdo+if0xWxSEfBD9ig=
github.com/filecoin-project/go-statemachine v1.0.1/go.mod h1:jZdXXiHa61n4NmgWFG4w8tnqgvZVHYbJ3yW7+y8bF54=
github.com/filecoin-project/go-statemachine v1.0.2-0.20220322104818-27f8fbb86dfd/go.mod h1:jZdXXiHa61n4NmgWFG4w8tnqgvZVHYbJ3yW7+y8bF54=
Expand Down Expand Up @@ -457,13 +457,13 @@ github.com/filecoin-project/storetheindex v0.4.17 h1:w0dVc954TGPukoVbidlYvn9Xt+w
github.com/filecoin-project/storetheindex v0.4.17/go.mod h1:y2dL8C5D3PXi183hdxgGtM8vVYOZ1lg515tpl/D3tN8=
github.com/filecoin-project/test-vectors/schema v0.0.5/go.mod h1:iQ9QXLpYWL3m7warwvK1JC/pTri8mnfEmKygNDqqY6E=
github.com/filecoin-project/venus v1.2.4/go.mod h1:hJULXHGAnWuq5S5KRtPkwbT8DqgM9II7NwyNU7t59D0=
github.com/filecoin-project/venus v1.9.0 h1:JdGPR7ank9XxlTmcaoXKKofqP+QnTmpiG5lEvJ5AixQ=
github.com/filecoin-project/venus v1.9.0/go.mod h1:3fBoP8nPxHYGerersp5m0J5hY0wsDGnWtolTEao/lwE=
github.com/filecoin-project/venus v1.9.0-rc1.0.20230203064217-14f0513a243e h1:l2EhKlBboVUij2CTf0iHtQvrCmOn52qTbtJAvjDjxss=
github.com/filecoin-project/venus v1.9.0-rc1.0.20230203064217-14f0513a243e/go.mod h1:TIRaBucKJIIe0QxuSWsRkO6fpRdKWdYY990KjQ/Fa38=
github.com/filecoin-project/venus-auth v1.3.2/go.mod h1:m5Jog2GYxztwP7w3m/iJdv/V1/bTcAVU9rm/CbhxRQU=
github.com/filecoin-project/venus-auth v1.9.0 h1:GH0o/jPdF55/U/uLoMzrqR9+DOsMf5oWM/X4UPuyWPA=
github.com/filecoin-project/venus-auth v1.9.0/go.mod h1:Ckj8F/iuSgXnCb9LvH0IiPR7swJZQAhabDOxVycLGWs=
github.com/filecoin-project/venus-messager v1.9.0 h1:owOTGzqlVcB46nROj/c1xBoFqBhFnljmWbXjaAKEXZA=
github.com/filecoin-project/venus-messager v1.9.0/go.mod h1:UgUU95+8G7ffHyXO/WLIl75ZBqj1NU9DjxMo5ZN3U+w=
github.com/filecoin-project/venus-messager v1.9.0-rc1 h1:NpjCXY1IMfUhoNvvocNxIirC+Q8iZsQYB8XXHe7s5mY=
github.com/filecoin-project/venus-messager v1.9.0-rc1/go.mod h1:1v7uhBYR1IsIeCud4a+scDVNgVtjCxS/DVIxnXQiuMo=
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc=
github.com/flynn/noise v0.0.0-20180327030543-2492fe189ae6/go.mod h1:1i71OnUq3iUe1ma7Lr6yG6/rjvM3emb6yoL7xLFzcVQ=
github.com/flynn/noise v1.0.0 h1:DlTHqmzmvcEiKj+4RYo/imoswx/4r6iBlCMfVtrMXpQ=
Expand Down Expand Up @@ -819,8 +819,8 @@ github.com/ipfs-force-community/metrics v1.0.1-0.20220824061112-ac916bacf2ea/go.
github.com/ipfs-force-community/venus-common-utils v0.0.0-20210924063144-1d3a5b30de87/go.mod h1:RTVEOzM+hkpqmcEWpyLDkx1oGO5r9ZWCgYxG/CsXzJQ=
github.com/ipfs-force-community/venus-common-utils v0.0.0-20220217030526-e5e4c6bc14f7 h1:v/1/INcqm3kHLauWQYB63MwWJRWGz+3WEuUPp0jzIl8=
github.com/ipfs-force-community/venus-common-utils v0.0.0-20220217030526-e5e4c6bc14f7/go.mod h1:sSTUXgIu95tPHvgcYhdLuELmgPJWCP/pNMFtsrVtOyA=
github.com/ipfs-force-community/venus-gateway v1.9.0 h1:/Gaax6I4sJLDQSpMdjBArQyHPNEjRqtMTaOOVGyr5Fs=
github.com/ipfs-force-community/venus-gateway v1.9.0/go.mod h1:5cqgQrA4Sv8nrJENG02JLVe+aourp9ouQJeaHHirrOM=
github.com/ipfs-force-community/venus-gateway v1.9.0-rc1 h1:eXBREWs0mkscx+vrwcgCNal+QlNGqazULU5kargzkhU=
github.com/ipfs-force-community/venus-gateway v1.9.0-rc1/go.mod h1:+TXUDejSPrY8aNLJcbAn5e6QU3xxirhxNvHUszGuESY=
github.com/ipfs/bbloom v0.0.1/go.mod h1:oqo8CVWsJFMOZqTglBG4wydCE4IQA/G2/SEofB0rjUI=
github.com/ipfs/bbloom v0.0.4 h1:Gi+8EGJ2y5qiD5FbsbpX/TMNcJw8gSqr7eyjHa4Fhvs=
github.com/ipfs/bbloom v0.0.4/go.mod h1:cS9YprKXpoZ9lT0n/Mw/a6/aFV6DTjTLYHeA+gyqMG0=
Expand Down