From f2c9c6bd97fbf7a6b3a72421a209340dbcce3af3 Mon Sep 17 00:00:00 2001 From: Mike <41407352+hunjixin@users.noreply.github.com> Date: Thu, 30 Dec 2021 11:31:31 +0800 Subject: [PATCH] use market namespace while in gateway mode (#160) --- .github/workflows/tag-workflow.yml | 3 +-- api/impl/strageminer.go | 3 --- app/venus-sealer/init.go | 17 ++--------------- builder.go | 1 - go.mod | 2 +- go.sum | 5 ++--- market_client/market_client.go | 13 ++----------- market_client/modules.go | 4 ++-- sector-storage/fsutil/statfs_unix.go | 3 +++ types/types.go | 7 ------- 10 files changed, 13 insertions(+), 45 deletions(-) diff --git a/.github/workflows/tag-workflow.yml b/.github/workflows/tag-workflow.yml index d2753b15..55db6501 100644 --- a/.github/workflows/tag-workflow.yml +++ b/.github/workflows/tag-workflow.yml @@ -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 diff --git a/api/impl/strageminer.go b/api/impl/strageminer.go index 355d20da..e301e469 100644 --- a/api/impl/strageminer.go +++ b/api/impl/strageminer.go @@ -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") diff --git a/app/venus-sealer/init.go b/app/venus-sealer/init.go index 5ccc9f4e..ae3c945c 100644 --- a/app/venus-sealer/init.go +++ b/app/venus-sealer/init.go @@ -3,7 +3,6 @@ package main import ( "bytes" "context" - "crypto/rand" "encoding/json" "fmt" "github.com/filecoin-project/venus-market/piecestorage" @@ -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" @@ -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 != "" { @@ -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) } @@ -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") != "" { @@ -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 diff --git a/builder.go b/builder.go index c9b335b6..4c607435 100644 --- a/builder.go +++ b/builder.go @@ -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)), diff --git a/go.mod b/go.mod index 3334b2f3..f25749cc 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/go.sum b/go.sum index c8fdef70..9ac3f8ae 100644 --- a/go.sum +++ b/go.sum @@ -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= diff --git a/market_client/market_client.go b/market_client/market_client.go index 777cc7f9..961a98d1 100644 --- a/market_client/market_client.go +++ b/market_client/market_client.go @@ -10,8 +10,6 @@ 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 { @@ -19,7 +17,7 @@ type MarketEventClient struct { 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, @@ -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 } diff --git a/market_client/modules.go b/market_client/modules.go index 92d95b49..6b775ef4 100644 --- a/market_client/modules.go +++ b/market_client/modules.go @@ -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 } diff --git a/sector-storage/fsutil/statfs_unix.go b/sector-storage/fsutil/statfs_unix.go index da09c5c6..da87c336 100644 --- a/sector-storage/fsutil/statfs_unix.go +++ b/sector-storage/fsutil/statfs_unix.go @@ -1,3 +1,6 @@ +//go:build !windows +// +build !windows + package fsutil import ( diff --git a/types/types.go b/types/types.go index bfc68922..f8600725 100644 --- a/types/types.go +++ b/types/types.go @@ -235,10 +235,3 @@ type DealAssign struct { Offset abi.PaddedPieceSize Size abi.PaddedPieceSize } - -type MarketMode string - -const ( - MarketSolo MarketMode = "solo" - MarketPool MarketMode = "pool" -)