Skip to content

Commit

Permalink
feat: unified run mode
Browse files Browse the repository at this point in the history
  • Loading branch information
ta0li committed Nov 25, 2022
1 parent c092170 commit ebacb64
Show file tree
Hide file tree
Showing 20 changed files with 263 additions and 574 deletions.
19 changes: 13 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,26 @@ git clone https://github.com/filecoin-project/venus-market.git
cd venus-market
make
```
## how to setup venus-market
## how to set up venus-market

run as venus-pool service
run:

- run in chain service
```shell script
./venus-market run --auth-url=<auth url> --node-url=<node url> --messager-url=<messager url> --gateway-url=<signer url> --cs-token=<token of admin-authority> --signer-type="gateway"
```

- run in local, conn venus chain service and use lotus-wallet/venus-wallet to sign
```shell script
./venus-market pool-run --auth-url <auth url> --node-url <node url> --messager-url <messager url> --gateway-url <signer url> --auth-token <auth token> --payment-addr <addr:account>
./venus-market run --auth-url=<auth url> --node-url=<node url> --messager-url=<messager url> --cs-token=<token of write-authority> --signer-type="wallet" --signer-url=<wallet url> --signer-token=<wallet token>
```

run in local
- run in local, conn lotus full node and use lotus full node to sign
```shell script
./venus-market solo-run --node-url <node url> --node-token <auth token> --signer-url <local wallet url> --signer-token <local wallet token> --payment-addr <addr:account>
./venus-market run --node-url=<node url> --messager-url=<node url> --cs-token=<token of lotus> --signer-type="lotusnode"
```

set peerid and address
set peer id and address

```shell script
./venus-market net listen #query venus-market address and peerid
Expand Down
2 changes: 1 addition & 1 deletion api/clients/mix_msgclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type MixMsgClient struct {
full v1api.FullNode
venusMessager IVenusMessager
signer signer.ISigner
nonceAssign *nonceAssigner
nonceAssign INonceAssigner
}

func NewMixMsgClient(params MPoolReplaceParams) IMixMessage {
Expand Down
23 changes: 3 additions & 20 deletions api/clients/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,16 @@ package clients
import (
logging "github.com/ipfs/go-log/v2"

"github.com/ipfs-force-community/metrics"
"github.com/ipfs-force-community/venus-common-utils/builder"
"github.com/ipfs-force-community/venus-gateway/marketevent"

gwTypes "github.com/ipfs-force-community/venus-gateway/types"

"github.com/filecoin-project/venus-market/v2/api/clients/signer"
"github.com/filecoin-project/venus-market/v2/config"
"github.com/ipfs-force-community/venus-common-utils/builder"

v1api "github.com/filecoin-project/venus/venus-shared/api/chain/v1"
gwAPI "github.com/filecoin-project/venus/venus-shared/api/gateway/v2"
)

var log = logging.Logger("clients")

func NewMarketEvent(mctx metrics.MetricsCtx) (gwAPI.IMarketEvent, error) {
stream := marketevent.NewMarketEventStream(mctx, &localMinerValidator{}, gwTypes.DefaultConfig())
return stream, nil
}

var ClientsOpts = func(server bool, mode string, msgCfg *config.Messager, signerCfg *config.Signer) builder.Option {
var ClientsOpts = func(server bool, msgCfg *config.Messager, signerCfg *config.Signer) builder.Option {
opts := builder.Options(
builder.Override(new(IMixMessage), NewMixMsgClient),
builder.Override(new(signer.ISigner), signer.NewISignerClient(server)),
Expand All @@ -37,13 +26,7 @@ var ClientsOpts = func(server bool, mode string, msgCfg *config.Messager, signer
if server {
return builder.Options(opts,
builder.Override(new(v1api.FullNode), NodeClient),

builder.ApplyIf(
func(s *builder.Settings) bool {
return mode == "solo"
},
builder.Override(new(gwAPI.IMarketEvent), NewMarketEvent),
),
// builder.Override(new(gwAPI.IMarketEvent), NewMarketEvent), // 部署在线下充当gateway的MarketEventStream功能,实现方式需进一步调研?
)
}

Expand Down
5 changes: 3 additions & 2 deletions api/clients/nonce_assign.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"sync"

"github.com/filecoin-project/go-address"

v1api "github.com/filecoin-project/venus/venus-shared/api/chain/v1"
)

Expand All @@ -17,11 +18,11 @@ type nonceAssigner struct {
full v1api.FullNode
}

func newNonceAssign(full v1api.FullNode) *nonceAssigner {
func newNonceAssign(full v1api.FullNode) INonceAssigner {
return &nonceAssigner{full: full, lk: sync.Mutex{}}
}

// AssignNonce assign next nonce for address, in solo mode, should use a separate address for market message, should save nonce
// AssignNonce assign next nonce for address, should use a separate address for market message, should save nonce
// when only connect one daemon, MpoolGetNonce works well, but may have conflict nonce if use multiple daemon behind proxy
// todo save assgined nonce in local database
func (nonceAssign *nonceAssigner) AssignNonce(ctx context.Context, addr address.Address) (uint64, error) {
Expand Down
1 change: 1 addition & 0 deletions api/clients/storage_miner.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/ipfs/go-cid"
)

// MarketRequestEvent todo no use
type MarketRequestEvent interface {
IsUnsealed(ctx context.Context, miner address.Address, pieceCid cid.Cid, sector storage.SectorRef, offset types.PaddedByteIndex, size abi.PaddedPieceSize) (bool, error)
// SectorsUnsealPiece will Unseal a Sealed sector file for the given sector.
Expand Down
33 changes: 0 additions & 33 deletions api/impl/market_event.go

This file was deleted.

16 changes: 8 additions & 8 deletions api/impl/venus_market.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ import (
"sort"
"time"

"github.com/ipfs/go-cid"
logging "github.com/ipfs/go-log/v2"
"github.com/libp2p/go-libp2p/core/host"
"github.com/libp2p/go-libp2p/core/peer"
"github.com/pkg/errors"
"go.uber.org/fx"

"github.com/filecoin-project/dagstore"
Expand All @@ -27,6 +22,11 @@ import (
"github.com/filecoin-project/go-jsonrpc/auth"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/builtin/v8/paych"
"github.com/ipfs/go-cid"
logging "github.com/ipfs/go-log/v2"
"github.com/libp2p/go-libp2p/core/host"
"github.com/libp2p/go-libp2p/core/peer"
"github.com/pkg/errors"

"github.com/filecoin-project/venus-auth/jwtclient"

Expand Down Expand Up @@ -54,10 +54,10 @@ var (
)

type MarketNodeImpl struct {
FundAPI
MarketEventAPI
fx.In

FundAPI

FullNode v1api.FullNode
Host host.Host
StorageProvider storageprovider.StorageProvider
Expand Down Expand Up @@ -478,7 +478,7 @@ func (m *MarketNodeImpl) MarketDataTransferPath(ctx context.Context, mAddr addre
return m.TransferPathFunc(mAddr)
}

func (m *MarketNodeImpl) MarketDataSetTransferPath(ctx context.Context, mAddr address.Address, path string) error {
func (m *MarketNodeImpl) MarketSetDataTransferPath(ctx context.Context, mAddr address.Address, path string) error {
return m.SetTransferPathFunc(mAddr, path)
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/market-client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ func marketClient(cctx *cli.Context) error {

config.ConfigClientOpts(cfg),

clients2.ClientsOpts(false, "", &cfg.Messager, &cfg.Signer),
clients2.ClientsOpts(false, &cfg.Messager, &cfg.Signer),
models.DBOptions(false, nil),
network.NetworkOpts(false, cfg.SimultaneousTransfersForStorage, 0, cfg.SimultaneousTransfersForRetrieval),
paychmgr.PaychOpts,
Expand Down
44 changes: 13 additions & 31 deletions cmd/venus-market/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,34 +36,31 @@ var (
Name: "node-url",
Usage: "url to connect to daemon service",
}
NodeTokenFlag = &cli.StringFlag{
Name: "node-token",
Usage: "node token",
}

AuthUrlFlag = &cli.StringFlag{
Name: "auth-url",
Usage: "url to connect to auth service",
}
AuthTokeFlag = &cli.StringFlag{
Name: "auth-token",
Usage: "token for connect venus components",
}

MessagerUrlFlag = &cli.StringFlag{
Name: "messager-url",
Usage: "url to connect messager service",
}
MessagerTokenFlag = &cli.StringFlag{
Name: "messager-token",
Usage: "messager token",
Hidden: true,

GatewayUrlFlag = &cli.StringFlag{
Name: "gateway-url",
Usage: "used to connect gateway service for sign",
}

ChainServiceTokenFlag = &cli.StringFlag{
Name: "cs-token",
Usage: "chain service token",
}

SignerTypeFlag = &cli.StringFlag{
Name: "signer-type",
Usage: "signer service type(lotusnode, wallet, gateway)",
Hidden: false,
Name: "signer-type",
Usage: "signer service type(lotusnode, wallet, gateway)",
Value: "wallet",
}
SignerUrlFlag = &cli.StringFlag{
Name: "signer-url",
Expand All @@ -74,24 +71,10 @@ var (
Usage: "auth token for connect signer service",
}

GatewayUrlFlag = &cli.StringFlag{
Name: "gateway-url",
Usage: "used to connect gateway service for sign",
}
GatewayTokenFlag = &cli.StringFlag{
Name: "gateway-token",
Usage: "used to connect gateway service for sign",
}

MysqlDsnFlag = &cli.StringFlag{
Name: "mysql-dsn",
Usage: "mysql connection string",
}

RetrievalPaymentAddress = &cli.StringFlag{
Name: "payment-addr",
Usage: "payment address for retrieval, eg. f01000",
}
)

func main() {
Expand All @@ -104,8 +87,7 @@ func main() {
RepoFlag,
},
Commands: []*cli.Command{
soloRunCmd,
poolRunCmd,
runCmd,
cli2.PiecesCmd,
cli2.RetrievalDealsCmd,
cli2.StorageDealsCmd,
Expand Down
Loading

0 comments on commit ebacb64

Please sign in to comment.