From 4f259d8644b458793fda8c9dee8d3fa695d43b0a Mon Sep 17 00:00:00 2001 From: Aayush Date: Wed, 15 Feb 2023 11:09:24 -0500 Subject: [PATCH] Revert "Standardize path variable" This reverts commit a9c1caa1886fbb7c576c46d4ade90f5c1561f6a2. --- cmd/lotus-shed/balances.go | 10 ++++------ cmd/lotus-shed/datastore.go | 12 +----------- cmd/lotus-shed/deal-label.go | 5 ++--- cmd/lotus-shed/diff.go | 5 ++--- cmd/lotus-shed/export-car.go | 5 ++--- cmd/lotus-shed/export.go | 10 ++++------ cmd/lotus-shed/fip-0036.go | 11 ++++++++--- cmd/lotus-shed/gas-estimation.go | 10 ++++------ cmd/lotus-shed/import-car.go | 14 -------------- cmd/lotus-shed/invariants.go | 5 ++--- cmd/lotus-shed/keyinfo.go | 11 +++-------- cmd/lotus-shed/main.go | 14 ++++++++++++++ cmd/lotus-shed/market.go | 10 ++++------ cmd/lotus-shed/migrations.go | 5 ++--- cmd/lotus-shed/miner-peerid.go | 8 +++----- cmd/lotus-shed/miner-types.go | 8 +++----- cmd/lotus-shed/msig.go | 5 ++--- cmd/lotus-shed/nonce-fix.go | 6 ++++++ cmd/lotus-shed/pruning.go | 5 ++--- cmd/lotus-shed/splitstore.go | 10 ++++------ cmd/lotus-shed/terminations.go | 5 ++--- 21 files changed, 74 insertions(+), 100 deletions(-) diff --git a/cmd/lotus-shed/balances.go b/cmd/lotus-shed/balances.go index c647f3b8e..9ce4faf72 100644 --- a/cmd/lotus-shed/balances.go +++ b/cmd/lotus-shed/balances.go @@ -454,9 +454,8 @@ var chainBalanceStateCmd = &cli.Command{ Description: "Produces a csv file of all account balances from a given stateroot", Flags: []cli.Flag{ &cli.StringFlag{ - Name: "repo", - Value: "~/.lotus", - EnvVars: []string{"LOTUS_PATH"}, + Name: "repo", + Value: "~/.lotus", }, &cli.BoolFlag{ Name: "miner-info", @@ -678,9 +677,8 @@ var chainPledgeCmd = &cli.Command{ Description: "Calculate sector pledge numbers", Flags: []cli.Flag{ &cli.StringFlag{ - Name: "repo", - Value: "~/.lotus", - EnvVars: []string{"LOTUS_PATH"}, + Name: "repo", + Value: "~/.lotus", }, }, ArgsUsage: "[stateroot epoch]", diff --git a/cmd/lotus-shed/datastore.go b/cmd/lotus-shed/datastore.go index d6b932954..5614e34f6 100644 --- a/cmd/lotus-shed/datastore.go +++ b/cmd/lotus-shed/datastore.go @@ -41,11 +41,6 @@ var datastoreListCmd = &cli.Command{ Name: "list", Description: "list datastore keys", Flags: []cli.Flag{ - &cli.StringFlag{ - Name: "repo", - Value: "~/.lotus", - EnvVars: []string{"LOTUS_PATH"}, - }, &cli.StringFlag{ Name: "repo-type", Usage: "node type (FullNode, StorageMiner, Worker, Wallet)", @@ -115,11 +110,6 @@ var datastoreGetCmd = &cli.Command{ Name: "get", Description: "list datastore keys", Flags: []cli.Flag{ - &cli.StringFlag{ - Name: "repo", - Value: "~/.lotus", - EnvVars: []string{"LOTUS_PATH"}, - }, &cli.StringFlag{ Name: "repo-type", Usage: "node type (FullNode, StorageMiner, Worker, Wallet)", @@ -133,7 +123,7 @@ var datastoreGetCmd = &cli.Command{ }, ArgsUsage: "[namespace key]", Action: func(cctx *cli.Context) error { - _ = logging.SetLogLevel("badger", "ERROR") + logging.SetLogLevel("badger", "ERROR") // nolint:errcheck r, err := repo.NewFS(cctx.String("repo")) if err != nil { diff --git a/cmd/lotus-shed/deal-label.go b/cmd/lotus-shed/deal-label.go index 2baa751a9..417d13701 100644 --- a/cmd/lotus-shed/deal-label.go +++ b/cmd/lotus-shed/deal-label.go @@ -24,9 +24,8 @@ var dealLabelCmd = &cli.Command{ Usage: "Scrape state to report on how many deals have non UTF-8 labels", Flags: []cli.Flag{ &cli.StringFlag{ - Name: "repo", - Value: "~/.lotus", - EnvVars: []string{"LOTUS_PATH"}, + Name: "repo", + Value: "~/.lotus", }, }, Action: func(cctx *cli.Context) error { diff --git a/cmd/lotus-shed/diff.go b/cmd/lotus-shed/diff.go index e29d9ca6d..981dc850c 100644 --- a/cmd/lotus-shed/diff.go +++ b/cmd/lotus-shed/diff.go @@ -33,9 +33,8 @@ var diffMinerStates = &cli.Command{ ArgsUsage: " ", Flags: []cli.Flag{ &cli.StringFlag{ - Name: "repo", - Value: "~/.lotus", - EnvVars: []string{"LOTUS_PATH"}, + Name: "repo", + Value: "~/.lotus", }, }, Action: func(cctx *cli.Context) error { diff --git a/cmd/lotus-shed/export-car.go b/cmd/lotus-shed/export-car.go index e32dbb2cf..5cb4737ea 100644 --- a/cmd/lotus-shed/export-car.go +++ b/cmd/lotus-shed/export-car.go @@ -35,9 +35,8 @@ var exportCarCmd = &cli.Command{ Description: "Export a car from repo", Flags: []cli.Flag{ &cli.StringFlag{ - Name: "repo", - Value: "~/.lotus", - EnvVars: []string{"LOTUS_PATH"}, + Name: "repo", + Value: "~/.lotus", }, }, ArgsUsage: "[outfile] [root cid]", diff --git a/cmd/lotus-shed/export.go b/cmd/lotus-shed/export.go index ab6d88698..459de3383 100644 --- a/cmd/lotus-shed/export.go +++ b/cmd/lotus-shed/export.go @@ -42,9 +42,8 @@ var exportChainCmd = &cli.Command{ Description: "Export chain from repo (requires node to be offline)", Flags: []cli.Flag{ &cli.StringFlag{ - Name: "repo", - Value: "~/.lotus", - EnvVars: []string{"LOTUS_PATH"}, + Name: "repo", + Value: "~/.lotus", }, &cli.StringFlag{ Name: "tipset", @@ -147,9 +146,8 @@ var exportRawCmd = &cli.Command{ Description: "Export raw blocks from repo (requires node to be offline)", Flags: []cli.Flag{ &cli.StringFlag{ - Name: "repo", - Value: "~/.lotus", - EnvVars: []string{"LOTUS_PATH"}, + Name: "repo", + Value: "~/.lotus", }, &cli.StringFlag{ Name: "car-size", diff --git a/cmd/lotus-shed/fip-0036.go b/cmd/lotus-shed/fip-0036.go index 1929eb4dd..485302b9b 100644 --- a/cmd/lotus-shed/fip-0036.go +++ b/cmd/lotus-shed/fip-0036.go @@ -58,6 +58,12 @@ var fip36PollCmd = &cli.Command{ Name: "fip36poll", Usage: "Process the FIP0036 FilPoll result", ArgsUsage: "[state root, votes]", + Flags: []cli.Flag{ + &cli.StringFlag{ + Name: "repo", + Value: "~/.lotus", + }, + }, Subcommands: []*cli.Command{ finalResultCmd, }, @@ -69,9 +75,8 @@ var finalResultCmd = &cli.Command{ ArgsUsage: "[state root] [height] [votes json]", Flags: []cli.Flag{ &cli.StringFlag{ - Name: "repo", - Value: "~/.lotus", - EnvVars: []string{"LOTUS_PATH"}, + Name: "repo", + Value: "~/.lotus", }, }, diff --git a/cmd/lotus-shed/gas-estimation.go b/cmd/lotus-shed/gas-estimation.go index 669c1c345..cf56ea03d 100644 --- a/cmd/lotus-shed/gas-estimation.go +++ b/cmd/lotus-shed/gas-estimation.go @@ -42,9 +42,8 @@ var gasTraceCmd = &cli.Command{ ArgsUsage: "[migratedStateRootCid networkVersion messageCid]", Flags: []cli.Flag{ &cli.StringFlag{ - Name: "repo", - Value: "~/.lotus", - EnvVars: []string{"LOTUS_PATH"}, + Name: "repo", + Value: "~/.lotus", }, }, Action: func(cctx *cli.Context) error { @@ -147,9 +146,8 @@ var replayOfflineCmd = &cli.Command{ ArgsUsage: "[messageCid]", Flags: []cli.Flag{ &cli.StringFlag{ - Name: "repo", - Value: "~/.lotus", - EnvVars: []string{"LOTUS_PATH"}, + Name: "repo", + Value: "~/.lotus", }, &cli.Int64Flag{ Name: "lookback-limit", diff --git a/cmd/lotus-shed/import-car.go b/cmd/lotus-shed/import-car.go index 6bba1d980..973e7b31b 100644 --- a/cmd/lotus-shed/import-car.go +++ b/cmd/lotus-shed/import-car.go @@ -19,13 +19,6 @@ import ( var importCarCmd = &cli.Command{ Name: "import-car", Description: "Import a car file into node chain blockstore", - Flags: []cli.Flag{ - &cli.StringFlag{ - Name: "repo", - Value: "~/.lotus", - EnvVars: []string{"LOTUS_PATH"}, - }, - }, Action: func(cctx *cli.Context) error { r, err := repo.NewFS(cctx.String("repo")) if err != nil { @@ -103,13 +96,6 @@ var importCarCmd = &cli.Command{ var importObjectCmd = &cli.Command{ Name: "import-obj", Usage: "import a raw ipld object into your datastore", - Flags: []cli.Flag{ - &cli.StringFlag{ - Name: "repo", - Value: "~/.lotus", - EnvVars: []string{"LOTUS_PATH"}, - }, - }, Action: func(cctx *cli.Context) error { r, err := repo.NewFS(cctx.String("repo")) if err != nil { diff --git a/cmd/lotus-shed/invariants.go b/cmd/lotus-shed/invariants.go index 953674ed0..e48f301c4 100644 --- a/cmd/lotus-shed/invariants.go +++ b/cmd/lotus-shed/invariants.go @@ -35,9 +35,8 @@ var invariantsCmd = &cli.Command{ ArgsUsage: "[StateRootCid, height]", Flags: []cli.Flag{ &cli.StringFlag{ - Name: "repo", - Value: "~/.lotus", - EnvVars: []string{"LOTUS_PATH"}, + Name: "repo", + Value: "~/.lotus", }, }, Action: func(cctx *cli.Context) error { diff --git a/cmd/lotus-shed/keyinfo.go b/cmd/lotus-shed/keyinfo.go index 1c322f7d6..38f5ee6fe 100644 --- a/cmd/lotus-shed/keyinfo.go +++ b/cmd/lotus-shed/keyinfo.go @@ -146,14 +146,9 @@ var keyinfoImportCmd = &cli.Command{ Examples env LOTUS_PATH=/var/lib/lotus lotus-shed keyinfo import libp2p-host.keyinfo`, - Flags: []cli.Flag{ - &cli.StringFlag{ - Name: "repo", - Value: "~/.lotus", - EnvVars: []string{"LOTUS_PATH"}, - }, - }, Action: func(cctx *cli.Context) error { + flagRepo := cctx.String("repo") + var input io.Reader if cctx.NArg() == 0 { input = os.Stdin @@ -182,7 +177,7 @@ var keyinfoImportCmd = &cli.Command{ return err } - fsrepo, err := repo.NewFS(cctx.String("repo")) + fsrepo, err := repo.NewFS(flagRepo) if err != nil { return err } diff --git a/cmd/lotus-shed/main.go b/cmd/lotus-shed/main.go index c0d0043f1..28a59f14d 100644 --- a/cmd/lotus-shed/main.go +++ b/cmd/lotus-shed/main.go @@ -1,6 +1,7 @@ package main import ( + "fmt" "os" logging "github.com/ipfs/go-log/v2" @@ -88,6 +89,19 @@ func main() { Version: build.UserVersion(), Commands: local, Flags: []cli.Flag{ + &cli.StringFlag{ + Name: "repo", + EnvVars: []string{"LOTUS_PATH"}, + Hidden: true, + Value: "~/.lotus", // TODO: Consider XDG_DATA_HOME + }, + &cli.StringFlag{ + Name: "miner-repo", + Aliases: []string{"storagerepo"}, + EnvVars: []string{"LOTUS_MINER_PATH", "LOTUS_STORAGE_PATH"}, + Value: "~/.lotusminer", // TODO: Consider XDG_DATA_HOME + Usage: fmt.Sprintf("Specify miner repo path. flag storagerepo and env LOTUS_STORAGE_PATH are DEPRECATION, will REMOVE SOON"), + }, &cli.StringFlag{ Name: "log-level", Value: "info", diff --git a/cmd/lotus-shed/market.go b/cmd/lotus-shed/market.go index 6d86c90b9..0c5e7c81d 100644 --- a/cmd/lotus-shed/market.go +++ b/cmd/lotus-shed/market.go @@ -124,9 +124,8 @@ var marketExportDatastoreCmd = &cli.Command{ Description: "export markets datastore key/values to a file", Flags: []cli.Flag{ &cli.StringFlag{ - Name: "repo", - Value: "~/.lotus", - EnvVars: []string{"LOTUS_PATH"}, + Name: "repo", + Usage: "path to the repo", }, &cli.StringFlag{ Name: "backup-dir", @@ -242,9 +241,8 @@ var marketImportDatastoreCmd = &cli.Command{ Description: "import markets datastore key/values from a backup file", Flags: []cli.Flag{ &cli.StringFlag{ - Name: "repo", - Value: "~/.lotus", - EnvVars: []string{"LOTUS_PATH"}, + Name: "repo", + Usage: "path to the repo", }, &cli.StringFlag{ Name: "backup-path", diff --git a/cmd/lotus-shed/migrations.go b/cmd/lotus-shed/migrations.go index e0336283a..a7e0ee34f 100644 --- a/cmd/lotus-shed/migrations.go +++ b/cmd/lotus-shed/migrations.go @@ -54,9 +54,8 @@ var migrationsCmd = &cli.Command{ ArgsUsage: "[new network version, block to look back from]", Flags: []cli.Flag{ &cli.StringFlag{ - Name: "repo", - Value: "~/.lotus", - EnvVars: []string{"LOTUS_PATH"}, + Name: "repo", + Value: "~/.lotus", }, &cli.BoolFlag{ Name: "skip-pre-migration", diff --git a/cmd/lotus-shed/miner-peerid.go b/cmd/lotus-shed/miner-peerid.go index fdf8dae8d..e43063797 100644 --- a/cmd/lotus-shed/miner-peerid.go +++ b/cmd/lotus-shed/miner-peerid.go @@ -26,12 +26,10 @@ import ( var minerPeeridCmd = &cli.Command{ Name: "miner-peerid", - Usage: "Scrape state to find a miner based on peerid", - Flags: []cli.Flag{ + Usage: "Scrape state to find a miner based on peerid", Flags: []cli.Flag{ &cli.StringFlag{ - Name: "repo", - Value: "~/.lotus", - EnvVars: []string{"LOTUS_PATH"}, + Name: "repo", + Value: "~/.lotus", }, }, Action: func(cctx *cli.Context) error { diff --git a/cmd/lotus-shed/miner-types.go b/cmd/lotus-shed/miner-types.go index 15e5db265..822d037aa 100644 --- a/cmd/lotus-shed/miner-types.go +++ b/cmd/lotus-shed/miner-types.go @@ -28,12 +28,10 @@ import ( var minerTypesCmd = &cli.Command{ Name: "miner-types", - Usage: "Scrape state to report on how many miners of each WindowPoStProofType exist", - Flags: []cli.Flag{ + Usage: "Scrape state to report on how many miners of each WindowPoStProofType exist", Flags: []cli.Flag{ &cli.StringFlag{ - Name: "repo", - Value: "~/.lotus", - EnvVars: []string{"LOTUS_PATH"}, + Name: "repo", + Value: "~/.lotus", }, }, Action: func(cctx *cli.Context) error { diff --git a/cmd/lotus-shed/msig.go b/cmd/lotus-shed/msig.go index 96ba91219..ccc932c93 100644 --- a/cmd/lotus-shed/msig.go +++ b/cmd/lotus-shed/msig.go @@ -43,9 +43,8 @@ var multisigGetAllCmd = &cli.Command{ ArgsUsage: "[state root]", Flags: []cli.Flag{ &cli.StringFlag{ - Name: "repo", - Value: "~/.lotus", - EnvVars: []string{"LOTUS_PATH"}, + Name: "repo", + Value: "~/.lotus", }, }, Action: func(cctx *cli.Context) error { diff --git a/cmd/lotus-shed/nonce-fix.go b/cmd/lotus-shed/nonce-fix.go index d68f22e0b..d69c8a48d 100644 --- a/cmd/lotus-shed/nonce-fix.go +++ b/cmd/lotus-shed/nonce-fix.go @@ -17,6 +17,12 @@ import ( var noncefix = &cli.Command{ Name: "noncefix", Flags: []cli.Flag{ + &cli.StringFlag{ + Name: "repo", + EnvVars: []string{"LOTUS_PATH"}, + Hidden: true, + Value: "~/.lotus", // TODO: Consider XDG_DATA_HOME + }, &cli.Uint64Flag{ Name: "start", }, diff --git a/cmd/lotus-shed/pruning.go b/cmd/lotus-shed/pruning.go index 1b6553057..275f3bc0a 100644 --- a/cmd/lotus-shed/pruning.go +++ b/cmd/lotus-shed/pruning.go @@ -86,9 +86,8 @@ var stateTreePruneCmd = &cli.Command{ Description: "Deletes old state root data from local chainstore", Flags: []cli.Flag{ &cli.StringFlag{ - Name: "repo", - Value: "~/.lotus", - EnvVars: []string{"LOTUS_PATH"}, + Name: "repo", + Value: "~/.lotus", }, &cli.Int64Flag{ Name: "keep-from-lookback", diff --git a/cmd/lotus-shed/splitstore.go b/cmd/lotus-shed/splitstore.go index 348f2e36d..e8c45a0c5 100644 --- a/cmd/lotus-shed/splitstore.go +++ b/cmd/lotus-shed/splitstore.go @@ -39,9 +39,8 @@ var splitstoreRollbackCmd = &cli.Command{ Description: "rollbacks a splitstore installation", Flags: []cli.Flag{ &cli.StringFlag{ - Name: "repo", - Value: "~/.lotus", - EnvVars: []string{"LOTUS_PATH"}, + Name: "repo", + Value: "~/.lotus", }, &cli.BoolFlag{ Name: "gc-coldstore", @@ -130,9 +129,8 @@ var splitstoreClearCmd = &cli.Command{ Description: "clears a splitstore installation for restart from snapshot", Flags: []cli.Flag{ &cli.StringFlag{ - Name: "repo", - Value: "~/.lotus", - EnvVars: []string{"LOTUS_PATH"}, + Name: "repo", + Value: "~/.lotus", }, &cli.BoolFlag{ Name: "keys-only", diff --git a/cmd/lotus-shed/terminations.go b/cmd/lotus-shed/terminations.go index c9e3d26bb..c5f35995a 100644 --- a/cmd/lotus-shed/terminations.go +++ b/cmd/lotus-shed/terminations.go @@ -33,9 +33,8 @@ var terminationsCmd = &cli.Command{ ArgsUsage: "[block to look back from] [lookback period (epochs)]", Flags: []cli.Flag{ &cli.StringFlag{ - Name: "repo", - Value: "~/.lotus", - EnvVars: []string{"LOTUS_PATH"}, + Name: "repo", + Value: "~/.lotus", }, }, Action: func(cctx *cli.Context) error {