Skip to content
This repository has been archived by the owner on Dec 19, 2022. It is now read-only.

Commit

Permalink
use market namespace while in gateway mode (#160)
Browse files Browse the repository at this point in the history
  • Loading branch information
hunjixin authored and ta0li committed Jan 10, 2022
1 parent 675d3c2 commit f2c9c6b
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 45 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/tag-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ jobs:
run: sudo apt-get install make ncftp mesa-opencl-icd ocl-icd-opencl-dev gcc git bzr jq pkg-config curl clang build-essential hwloc libhwloc-dev wget -y && sudo apt upgrade -y
- name: Build
run: |
sudo make deps
sudo make
make deps && make
mkdir ./release && mv ./venus-sealer ./venus-worker ./release
- name: Zip Release
uses: TheDoctor0/zip-release@0.6.0
Expand Down
3 changes: 0 additions & 3 deletions api/impl/strageminer.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ import (
"github.com/filecoin-project/venus-sealer/storage-sealing/sealiface"
"github.com/filecoin-project/venus-sealer/storage/sectorblocks"
types2 "github.com/filecoin-project/venus-sealer/types"

api2 "github.com/filecoin-project/venus-market/api"
"github.com/filecoin-project/venus-market/piece"
)

var log = logging.Logger("sealer")
Expand Down
17 changes: 2 additions & 15 deletions app/venus-sealer/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package main
import (
"bytes"
"context"
"crypto/rand"
"encoding/json"
"fmt"
"github.com/filecoin-project/venus-market/piecestorage"
Expand All @@ -23,8 +22,6 @@ import (

"github.com/docker/go-units"
"github.com/google/uuid"
"github.com/libp2p/go-libp2p-core/crypto"
"github.com/libp2p/go-libp2p-core/peer"
"github.com/mitchellh/go-homedir"
"github.com/urfave/cli/v2"
"golang.org/x/xerrors"
Expand Down Expand Up @@ -441,15 +438,6 @@ func storageMinerInit(ctx context.Context, cctx *cli.Context, api api.FullNode,

metaDataService := service.NewMetadataService(repo)
sectorInfoService := service.NewSectorInfoService(repo)
p2pSk, _, err := crypto.GenerateEd25519Key(rand.Reader)
if err != nil {
return address.Undef, xerrors.Errorf("make host key: %w", err)
}

peerid, err := peer.IDFromPrivateKey(p2pSk)
if err != nil {
return address.Undef, xerrors.Errorf("peer ID from private key: %w", err)
}

var addr address.Address
if act := cctx.String("actor"); act != "" {
Expand Down Expand Up @@ -494,7 +482,7 @@ func storageMinerInit(ctx context.Context, cctx *cli.Context, api api.FullNode,

addr = a
} else {
a, err := createStorageMiner(ctx, api, messagerClient, peerid, gasPrice, cctx)
a, err := createStorageMiner(ctx, api, messagerClient, gasPrice, cctx)
if err != nil {
return address.Undef, xerrors.Errorf("creating miner failed: %w", err)
}
Expand All @@ -511,7 +499,7 @@ func storageMinerInit(ctx context.Context, cctx *cli.Context, api api.FullNode,
return addr, nil
}

func createStorageMiner(ctx context.Context, nodeAPI api.FullNode, messagerClient api.IMessager, peerid peer.ID, gasPrice types.BigInt, cctx *cli.Context) (address.Address, error) {
func createStorageMiner(ctx context.Context, nodeAPI api.FullNode, messagerClient api.IMessager, gasPrice types.BigInt, cctx *cli.Context) (address.Address, error) {
var err error
var owner address.Address
if cctx.String("owner") != "" {
Expand Down Expand Up @@ -574,7 +562,6 @@ func createStorageMiner(ctx context.Context, nodeAPI api.FullNode, messagerClien
Owner: owner,
Worker: worker,
SealProofType: spt,
Peer: abi.PeerID(peerid),
})
if err != nil {
return address.Undef, err
Expand Down
1 change: 0 additions & 1 deletion builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ func Online(cfg *config.StorageMiner) Option {
Override(new(storage2.Prover), From(new(sectorstorage.SectorManager))),
Override(new(storiface.WorkerReturn), From(new(sectorstorage.SectorManager))),

Override(new(types.MarketMode), types.MarketMode(cfg.MarketNode.Mode)),
Override(new(types.GetSealingConfigFunc), NewGetSealConfigFunc),
Override(new(*sectorblocks.SectorBlocks), sectorblocks.NewSectorBlocks),
Override(new(*storage.Miner), StorageMiner(config.DefaultMainnetStorageMiner().Fees)),
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ replace github.com/filecoin-project/filecoin-ffi => ./extern/filecoin-ffi

replace github.com/ipfs/go-ipfs-cmds => github.com/ipfs-force-community/go-ipfs-cmds v0.6.1-0.20210521090123-4587df7fa0ab

replace github.com/filecoin-project/go-jsonrpc => github.com/ipfs-force-community/go-jsonrpc v0.1.4-0.20211222073806-e895f2de9729
replace github.com/filecoin-project/go-jsonrpc => github.com/ipfs-force-community/go-jsonrpc v0.1.4-0.20210721095535-a67dff16de21

replace github.com/filecoin-project/go-statemachine => github.com/hunjixin/go-statemachine v0.0.0-20210309063909-a65119041e93

Expand Down
5 changes: 2 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -713,9 +713,8 @@ github.com/influxdata/line-protocol v0.0.0-20200327222509-2487e7298839 h1:W9WBk7
github.com/influxdata/line-protocol v0.0.0-20200327222509-2487e7298839/go.mod h1:xaLFMmpvUxqXtVkUJfg9QmT88cDaCJ3ZKgdZ78oO8Qo=
github.com/ipfs-force-community/go-ipfs-cmds v0.6.1-0.20210521090123-4587df7fa0ab h1:+Jov61TTljdzTKBecQizmUWJ6IIoVgzjukKppVr5TgI=
github.com/ipfs-force-community/go-ipfs-cmds v0.6.1-0.20210521090123-4587df7fa0ab/go.mod h1:ZgYiWVnCk43ChwoH8hAmI1IRbuVtq3GSTHwtRB/Kqhk=
github.com/ipfs-force-community/go-jsonrpc v0.1.4-0.20211222073806-e895f2de9729 h1:iVN4bTg0gA4kSiSTgdqXQ9JC6CfruZKC1CjxVL9DBUI=
github.com/ipfs-force-community/go-jsonrpc v0.1.4-0.20211222073806-e895f2de9729/go.mod h1:XBBpuKIMaXIIzeqzO1iucq4GvbF8CxmXRFoezRh+Cx4=
github.com/ipfs-force-community/metrics v0.0.0-20210714124606-3d65e2d7cec1/go.mod h1:mn40SioMuKtjmRumHFy/fJ26Pn028XuDjUJE9dorjyw=
github.com/ipfs-force-community/go-jsonrpc v0.1.4-0.20210721095535-a67dff16de21 h1:ht754GJKTx1uYy4gYUhJxxefhKqxReo/654URuB+Ksk=
github.com/ipfs-force-community/go-jsonrpc v0.1.4-0.20210721095535-a67dff16de21/go.mod h1:XBBpuKIMaXIIzeqzO1iucq4GvbF8CxmXRFoezRh+Cx4=
github.com/ipfs-force-community/metrics v0.0.0-20210721095706-e644662d8554/go.mod h1:mn40SioMuKtjmRumHFy/fJ26Pn028XuDjUJE9dorjyw=
github.com/ipfs-force-community/metrics v1.0.0/go.mod h1:mn40SioMuKtjmRumHFy/fJ26Pn028XuDjUJE9dorjyw=
github.com/ipfs-force-community/metrics v1.0.1-0.20211022060227-11142a08b729 h1:elS3KmzAMVrcZpmP2RMEjs9Zlwh6LfhJTfYQdj4TREs=
Expand Down
13 changes: 2 additions & 11 deletions market_client/market_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,14 @@ import (
"github.com/ipfs-force-community/venus-common-utils/apiinfo"
"github.com/ipfs-force-community/venus-gateway/marketevent"
types2 "github.com/ipfs-force-community/venus-gateway/types"

"github.com/filecoin-project/venus-sealer/types"
)

type MarketEventClient struct {
ResponseMarketEvent func(ctx context.Context, resp *types2.ResponseEvent) error
ListenMarketEvent func(ctx context.Context, policy *marketevent.MarketRegisterPolicy) (<-chan *types2.RequestEvent, error)
}

func NewMarketEventClient(lc fx.Lifecycle, mode types.MarketMode, url, token string) (*MarketEventClient, error) {
func NewMarketEventClient(lc fx.Lifecycle, url, token string) (*MarketEventClient, error) {
pvc := &MarketEventClient{}
apiInfo := apiinfo.APIInfo{
Addr: url,
Expand All @@ -30,14 +28,7 @@ func NewMarketEventClient(lc fx.Lifecycle, mode types.MarketMode, url, token str
return nil, err
}

namespace := "VENUS_MARKET"
if mode == types.MarketPool {
namespace = "Gateway"
} else if mode == types.MarketSolo {
namespace = "VENUS_MARKET"
}

closer, err := jsonrpc.NewMergeClient(context.Background(), addr, namespace, []interface{}{pvc}, apiInfo.AuthHeader())
closer, err := jsonrpc.NewMergeClient(context.Background(), addr, "VENUS_MARKET", []interface{}{pvc}, apiInfo.AuthHeader())
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions market_client/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ import (
"github.com/filecoin-project/venus-sealer/types"
)

func StartMarketEvent(lc fx.Lifecycle, stores *stores.Remote, pieceStorage piecestorage.IPieceStorage, sectorBlocks *sectorblocks.SectorBlocks, storageMgr *sectorstorage.Manager, index stores.SectorIndex, mode types.MarketMode, cfg *config.RegisterMarketConfig, mAddr types.MinerAddress) error {
func StartMarketEvent(lc fx.Lifecycle, stores *stores.Remote, pieceStorage piecestorage.IPieceStorage, sectorBlocks *sectorblocks.SectorBlocks, storageMgr *sectorstorage.Manager, index stores.SectorIndex, cfg *config.RegisterMarketConfig, mAddr types.MinerAddress) error {
if len(cfg.Urls) == 0 {
log.Warnf("register market config is empty ...")
return nil
}

for _, url := range cfg.Urls {
client, err := NewMarketEventClient(lc, mode, url, cfg.Token)
client, err := NewMarketEventClient(lc, url, cfg.Token)
if err != nil {
return err
}
Expand Down
3 changes: 3 additions & 0 deletions sector-storage/fsutil/statfs_unix.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//go:build !windows
// +build !windows

package fsutil

import (
Expand Down
7 changes: 0 additions & 7 deletions types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,3 @@ type DealAssign struct {
Offset abi.PaddedPieceSize
Size abi.PaddedPieceSize
}

type MarketMode string

const (
MarketSolo MarketMode = "solo"
MarketPool MarketMode = "pool"
)

0 comments on commit f2c9c6b

Please sign in to comment.