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: unified run mode #244

Closed
wants to merge 1 commit into from
Closed
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
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
33 changes: 4 additions & 29 deletions api/clients/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,51 +3,26 @@ 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"

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 {
opts := builder.Options(
var ClientsOpts = func(server bool, msgCfg *config.Messager, signerCfg *config.Signer) builder.Option {
return builder.Options(
builder.Override(new(IMixMessage), NewMixMsgClient),
builder.Override(new(signer.ISigner), signer.NewISignerClient(server)),
builder.ApplyIf(
func(s *builder.Settings) bool {
return len(msgCfg.Url) > 0
},
builder.Override(new(IVenusMessager), MessagerClient)),
)

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),
),
)
}

return builder.Options(opts,
builder.Override(new(IVenusMessager), MessagerClient),
),
builder.Override(new(v1api.FullNode), NodeClient),
)
}
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.

31 changes: 21 additions & 10 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 All @@ -43,21 +43,24 @@ import (

"github.com/filecoin-project/venus/pkg/constants"
v1api "github.com/filecoin-project/venus/venus-shared/api/chain/v1"
marketapi "github.com/filecoin-project/venus/venus-shared/api/market"
gatewayAPIV2 "github.com/filecoin-project/venus/venus-shared/api/gateway/v2"
marketAPI "github.com/filecoin-project/venus/venus-shared/api/market"
vTypes "github.com/filecoin-project/venus/venus-shared/types"
gatewayTypes "github.com/filecoin-project/venus/venus-shared/types/gateway"
types "github.com/filecoin-project/venus/venus-shared/types/market"
)

var (
_ marketapi.IMarket = (*MarketNodeImpl)(nil)
_ marketAPI.IMarket = (*MarketNodeImpl)(nil)
log = logging.Logger("market_api")
)

type MarketNodeImpl struct {
FundAPI
MarketEventAPI
fx.In

FundAPI
gatewayAPIV2.IMarketServiceProvider

FullNode v1api.FullNode
Host host.Host
StorageProvider storageprovider.StorageProvider
Expand Down Expand Up @@ -114,6 +117,14 @@ type MarketNodeImpl struct {
SetMaxMarketBalanceAddFeeFunc config.SetMaxMarketBalanceAddFeeFunc
}

func (m MarketNodeImpl) ResponseMarketEvent(ctx context.Context, resp *gatewayTypes.ResponseEvent) error {
return m.IMarketServiceProvider.ResponseMarketEvent(ctx, resp)
}

func (m MarketNodeImpl) ListenMarketEvent(ctx context.Context, policy *gatewayTypes.MarketRegisterPolicy) (<-chan *gatewayTypes.RequestEvent, error) {
return m.IMarketServiceProvider.ListenMarketEvent(ctx, policy)
}

func (m MarketNodeImpl) ActorList(ctx context.Context) ([]types.User, error) {
return m.UserMgr.ActorList(ctx)
}
Expand Down Expand Up @@ -478,7 +489,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