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

Chore/merge v2.8 #372

Merged
merged 17 commits into from
Jul 7, 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
45 changes: 42 additions & 3 deletions .github/workflows/docker_image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,46 @@ on:

jobs:


# build_docker_image:
# uses: filecoin-project/venus/.github/workflows/common_docker_image.yml@master
# secrets:
# DOCKER_PASSWORD: ${{secrets.DOCKER_PASSWORD}}

# todo: replace this job with action from venus
build_docker_image:
uses: filecoin-project/venus/.github/workflows/common_docker_image.yml@master
secrets:
DOCKER_PASSWORD: ${{secrets.DOCKER_PASSWORD}}
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Create vars
id: vars
run: |
export github_tag=${{ github.ref_name }}
export repo_name=${GITHUB_REPOSITORY##*/}
export is_tag_create=false
export docker_user_name='filvenus'

export rx_tag='^refs\/tags\/.*'
export rx_version_tag='^v([0-9]+\.){0,2}(\*|[0-9]+)(-rc[0-9]*){0,1}$'
if [[ "${{github.ref}}" =~ $rx_tag ]]; then
export is_tag_create=true
fi

echo "::set-output name=github_tag::$github_tag"
echo "::set-output name=repo_name::$repo_name"
echo "::set-output name=is_tag_create::$is_tag_create"
echo "::set-output name=docker_user_name::$docker_user_name"

- name: Show environment
run: |
echo is_tag_create = ${{ steps.vars.outputs.is_tag_create }}
echo github_tag = ${{ steps.vars.outputs.github_tag }}
echo repo_name = ${{ steps.vars.outputs.repo_name }}
echo docker_user_name = ${{steps.vars.outputs.docker_user_name}}
echo docker_password = ${{secrets.DOCKER_PASSWORD}}

- name: Build the Docker image
if: ${{ steps.vars.outputs.is_tag_create == 'true' }}
run: |
docker login --username=${{steps.vars.outputs.docker_user_name}} --password ${{ secrets.DOCKER_PASSWORD }}
make docker-push TAG=${{ steps.vars.outputs.github_tag }}
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# droplet changelog

## v2.8.0

* fix: repo compatibility for cli [[#348](https://github.com/ipfs-force-community/droplet/pull/348)]
* chore: output piece size to log [[#351](https://github.com/ipfs-force-community/droplet/pull/351)]
* fix: use old client repo when create market client[[#353](https://github.com/ipfs-force-community/droplet/pull/353)]

## v2.8.0-rc1

* feat: set address.CurrentNetwork when launch up [[#321](https://github.com/ipfs-force-community/droplet/pull/321)]
Expand Down
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -101,5 +101,14 @@ endif


docker-push: docker
ifdef PRIVATE_REGISTRY
docker push $(PRIVATE_REGISTRY)/filvenus/droplet:$(TAG)
docker push $(PRIVATE_REGISTRY)/filvenus/droplet-client:$(TAG)
else
docker tag droplet filvenus/droplet:latest
docker tag droplet-client filvenus/droplet-client:latest
docker push filvenus/droplet:latest
docker push filvenus/droplet-client:latest
docker push filvenus/droplet:$(TAG)
docker push filvenus/droplet-client:$(TAG)
endif
6 changes: 3 additions & 3 deletions cli/actor.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ var actorSetAddrsCmd = &cli.Command{
}
defer closer()

api, acloser, err := NewFullNode(cctx)
api, acloser, err := NewFullNode(cctx, OldMarketRepoPath)
if err != nil {
return err
}
Expand Down Expand Up @@ -256,7 +256,7 @@ var actorSetPeeridCmd = &cli.Command{
}
defer closer()

api, acloser, err := NewFullNode(cctx)
api, acloser, err := NewFullNode(cctx, OldMarketRepoPath)
if err != nil {
return err
}
Expand Down Expand Up @@ -323,7 +323,7 @@ var actorInfoCmd = &cli.Command{
}
defer closer()

api, acloser, err := NewFullNode(cctx)
api, acloser, err := NewFullNode(cctx, OldMarketRepoPath)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions cli/market_funds.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var marketBalancesCmd = &cli.Command{
Usage: "Print storage market client balances",
Flags: []cli.Flag{},
Action: func(cctx *cli.Context) error {
fapi, fcloser, err := NewFullNode(cctx)
fapi, fcloser, err := NewFullNode(cctx, OldMarketRepoPath)
if err != nil {
return err
}
Expand Down Expand Up @@ -184,7 +184,7 @@ var walletMarketWithdraw = &cli.Command{
},
},
Action: func(cctx *cli.Context) error {
api, acloser, err := NewFullNode(cctx)
api, acloser, err := NewFullNode(cctx, OldMarketRepoPath)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion cli/retrieval-deals.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ var queryProtocols = &cli.Command{
return fmt.Errorf("must pass miner")
}

api, closer, err := NewFullNode(cctx)
api, closer, err := NewFullNode(cctx, OldMarketRepoPath)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions cli/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ var StatsPowerCmd = &cli.Command{
log.SetOutput(bytes.NewBuffer(nil))
}

api, acloser, err := NewFullNode(cctx)
api, acloser, err := NewFullNode(cctx, OldMarketRepoPath)
if err != nil {
return fmt.Errorf("setting up venus node connection: %w", err)
}
Expand Down Expand Up @@ -259,7 +259,7 @@ var StatsDealsCmd = &cli.Command{
Description: "Statistics on active market deals",
Action: func(cctx *cli.Context) error {
ctx := ReqContext(cctx)
api, closer, err := NewFullNode(cctx)
api, closer, err := NewFullNode(cctx, OldMarketRepoPath)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions cli/storage-ask.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ var getStorageAskCmd = &cli.Command{
Action: func(cctx *cli.Context) error {
ctx := DaemonContext(cctx)

fnapi, closer, err := NewFullNode(cctx)
fnapi, closer, err := NewFullNode(cctx, OldMarketRepoPath)
if err != nil {
return err
}
Expand Down Expand Up @@ -218,7 +218,7 @@ var listStorageAsksCmd = &cli.Command{
Action: func(cctx *cli.Context) error {
ctx := DaemonContext(cctx)

fnapi, closer, err := NewFullNode(cctx)
fnapi, closer, err := NewFullNode(cctx, OldMarketRepoPath)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion cli/storage-deals.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ part states:
}
defer closer()

fapi, fcloser, err := NewFullNode(cctx)
fapi, fcloser, err := NewFullNode(cctx, OldMarketRepoPath)
if err != nil {
return err
}
Expand Down
66 changes: 61 additions & 5 deletions cli/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@ const (
API_NAMESPACE_MARKET_CLIENT = "VENUS_MARKET_CLIENT" //nolint
)

const (
OldMarketRepoPath = "~/.venusmarket"
DefMarketRepoPath = "~/.droplet"
)

const (
OldClientRepoPath = "~/.marketclient"
DefClientRepoPath = "~/.droplet-client"
)

// GetCidEncoder returns an encoder using the `cid-base` flag if provided, or
// the default (Base32) encoder if not.
func GetCidEncoder(cctx *cli.Context) (cidenc.Encoder, error) {
Expand All @@ -82,7 +92,7 @@ var minerFlag = &cli.StringFlag{
}

func NewMarketNode(cctx *cli.Context) (marketapi.IMarket, jsonrpc.ClientCloser, error) {
homePath, err := homedir.Expand(cctx.String("repo"))
homePath, err := GetRepoPath(cctx, "repo", OldMarketRepoPath)
if err != nil {
return nil, nil, err
}
Expand All @@ -106,7 +116,7 @@ func NewMarketNode(cctx *cli.Context) (marketapi.IMarket, jsonrpc.ClientCloser,
}

func NewMarketClientNode(cctx *cli.Context) (clientapi.IMarketClient, jsonrpc.ClientCloser, error) {
homePath, err := homedir.Expand(cctx.String("repo"))
homePath, err := GetRepoPath(cctx, "repo", OldClientRepoPath)
if err != nil {
return nil, nil, err
}
Expand All @@ -128,10 +138,14 @@ func NewMarketClientNode(cctx *cli.Context) (clientapi.IMarketClient, jsonrpc.Cl
return clientapi.NewIMarketClientRPC(cctx.Context, addr, apiInfo.AuthHeader())
}

func NewFullNode(cctx *cli.Context) (v1api.FullNode, jsonrpc.ClientCloser, error) {
cfgPath := path.Join(cctx.String("repo"), "config.toml")
func NewFullNode(cctx *cli.Context, legacyRepo string) (v1api.FullNode, jsonrpc.ClientCloser, error) {
repoPath, err := GetRepoPath(cctx, "repo", legacyRepo)
if err != nil {
return nil, nil, err
}
cfgPath := path.Join(repoPath, "config.toml")
marketCfg := config.DefaultMarketConfig
err := config.LoadConfig(cfgPath, marketCfg)
err = config.LoadConfig(cfgPath, marketCfg)
if err != nil {
return nil, nil, err
}
Expand Down Expand Up @@ -555,3 +569,45 @@ func getPayloadSizeFunc(dirs []string) func(pieceCID cid.Cid) uint64 {
return sizes[pieceCID]
}
}

// todo: remove legacy repo path after v1.13
func GetRepoPath(cctx *cli.Context, repoFlagName, oldRepoPath string) (string, error) {
repoPath, err := homedir.Expand(cctx.String(repoFlagName))
if err != nil {
return "", err
}
has, err := exist(repoPath)
if err != nil {
return "", err
}
if !has {
oldRepoPath, err = homedir.Expand(oldRepoPath)
if err != nil {
return "", err
}
has, err = exist(oldRepoPath)
if err != nil {
return "", err
}
if has {
return oldRepoPath, nil
}
}

return repoPath, nil
}

func exist(path string) (bool, error) {
f, err := os.Stat(path)
if err != nil {
if os.IsNotExist(err) {
return false, nil
}
return false, err
}
if !f.IsDir() {
return false, fmt.Errorf("%s not a file directory", path)
}

return true, nil
}
4 changes: 2 additions & 2 deletions cmd/droplet-client/actor-funds.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ var actorFundsBalancesCmd = &cli.Command{
},
},
Action: func(cctx *cli.Context) error {
fapi, fcloser, err := cli2.NewFullNode(cctx)
fapi, fcloser, err := cli2.NewFullNode(cctx, cli2.OldClientRepoPath)
if err != nil {
return err
}
Expand Down Expand Up @@ -191,7 +191,7 @@ var actorFundsWithdrawCmd = &cli.Command{
defer closer()
ctx := cli2.ReqContext(cctx)

fapi, fcloser, err := cli2.NewFullNode(cctx)
fapi, fcloser, err := cli2.NewFullNode(cctx, cli2.OldClientRepoPath)
if err != nil {
return err
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/droplet-client/datacap.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ var datacapExtendCmd = &cli.Command{
defer closer()
ctx := cli2.ReqContext(cliCtx)

fapi, fcloser, err := cli2.NewFullNode(cliCtx)
fapi, fcloser, err := cli2.NewFullNode(cliCtx, cli2.OldClientRepoPath)
if err != nil {
return err
}
Expand Down Expand Up @@ -286,7 +286,7 @@ var datacapClaimsListCmd = &cli.Command{
return fmt.Errorf("must pass provider address")
}

fapi, fcloser, err := cli2.NewFullNode(cliCtx)
fapi, fcloser, err := cli2.NewFullNode(cliCtx, cli2.OldClientRepoPath)
if err != nil {
return err
}
Expand Down Expand Up @@ -368,7 +368,7 @@ var datacapAllocationListCmd = &cli.Command{
return fmt.Errorf("must pass client address")
}

fapi, fcloser, err := cli2.NewFullNode(cliCtx)
fapi, fcloser, err := cli2.NewFullNode(cliCtx, cli2.OldClientRepoPath)
if err != nil {
return err
}
Expand Down
9 changes: 2 additions & 7 deletions cmd/droplet-client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@ import (
"github.com/filecoin-project/venus/venus-shared/api/permission"
)

const (
oldRepoPath = "~/.marketclient"
defRepoPath = "~/.droplet-client"
)

var (
ExtractApiKey = builder.NextInvoke()
log = logging.Logger("main")
Expand All @@ -54,7 +49,7 @@ var (
RepoFlag = &cli.StringFlag{
Name: "repo",
EnvVars: []string{"DROPLET_CLIENT_PATH", "VENUS_MARKET_CLIENT_PATH"},
Value: defRepoPath,
Value: cli2.DefClientRepoPath,
}

APIListenFlag = &cli.StringFlag{
Expand Down Expand Up @@ -225,7 +220,7 @@ func flagData(cctx *cli.Context, cfg *config.MarketClientConfig) error {
func prepare(cctx *cli.Context) (*config.MarketClientConfig, error) {
var err error
cfg := config.DefaultMarketClientConfig
cfg.HomeDir, err = cmd.GetRepoPath(cctx, RepoFlag.Name, oldRepoPath)
cfg.HomeDir, err = cli2.GetRepoPath(cctx, RepoFlag.Name, cli2.OldClientRepoPath)
if err != nil {
return nil, err
}
Expand Down
Loading