Merge PR #3498: various improvements to gaiad gentx/init
This commit is contained in:
parent
7173164f73
commit
df94f522f9
|
@ -15,6 +15,7 @@ BREAKING CHANGES
|
||||||
- `--insecure` flag is removed.
|
- `--insecure` flag is removed.
|
||||||
- `--tls` is now used to enable secure layer.
|
- `--tls` is now used to enable secure layer.
|
||||||
- [\#3451](https://github.com/cosmos/cosmos-sdk/pull/3451) `gaiacli` now returns transactions in plain text including tags.
|
- [\#3451](https://github.com/cosmos/cosmos-sdk/pull/3451) `gaiacli` now returns transactions in plain text including tags.
|
||||||
|
- [\#3497](https://github.com/cosmos/cosmos-sdk/issues/3497) `gaiad init` now takes moniker as required arguments, not as parameter.
|
||||||
* [\#3501](https://github.com/cosmos/cosmos-sdk/issues/3501) Change validator
|
* [\#3501](https://github.com/cosmos/cosmos-sdk/issues/3501) Change validator
|
||||||
address Bech32 encoding to consensus address in `tendermint-validator-set`.
|
address Bech32 encoding to consensus address in `tendermint-validator-set`.
|
||||||
|
|
||||||
|
@ -63,6 +64,7 @@ IMPROVEMENTS
|
||||||
|
|
||||||
* Gaia CLI (`gaiacli`)
|
* Gaia CLI (`gaiacli`)
|
||||||
* [\#3476](https://github.com/cosmos/cosmos-sdk/issues/3476) New `withdraw-all-rewards` command to withdraw all delegations rewards for delegators.
|
* [\#3476](https://github.com/cosmos/cosmos-sdk/issues/3476) New `withdraw-all-rewards` command to withdraw all delegations rewards for delegators.
|
||||||
|
- [\#3497](https://github.com/cosmos/cosmos-sdk/issues/3497) `gaiad gentx` supports `--ip` and `--node-id` flags to override defaults.
|
||||||
|
|
||||||
* Gaia
|
* Gaia
|
||||||
* [\#3418](https://github.com/cosmos/cosmos-sdk/issues/3418) Add vesting account
|
* [\#3418](https://github.com/cosmos/cosmos-sdk/issues/3418) Add vesting account
|
||||||
|
|
|
@ -153,7 +153,7 @@ func (f *Fixtures) UnsafeResetAll(flags ...string) {
|
||||||
// GDInit is gaiad init
|
// GDInit is gaiad init
|
||||||
// NOTE: GDInit sets the ChainID for the Fixtures instance
|
// NOTE: GDInit sets the ChainID for the Fixtures instance
|
||||||
func (f *Fixtures) GDInit(moniker string, flags ...string) {
|
func (f *Fixtures) GDInit(moniker string, flags ...string) {
|
||||||
cmd := fmt.Sprintf("gaiad init -o --moniker=%s --home=%s", moniker, f.GDHome)
|
cmd := fmt.Sprintf("gaiad init -o --home=%s %s", f.GDHome, moniker)
|
||||||
_, stderr := tests.ExecuteT(f.T, addFlags(cmd, flags), app.DefaultKeyPass)
|
_, stderr := tests.ExecuteT(f.T, addFlags(cmd, flags), app.DefaultKeyPass)
|
||||||
|
|
||||||
var chainID string
|
var chainID string
|
||||||
|
|
|
@ -62,10 +62,15 @@ following delegation and commission default parameters:
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
ip, err := server.ExternalIP()
|
// Read --nodeID, if empty take it from priv_validator.json
|
||||||
if err != nil {
|
if nodeIDString := viper.GetString(cli.FlagNodeID); nodeIDString != "" {
|
||||||
fmt.Fprintf(os.Stderr, "couldn't retrieve an external IP, "+
|
nodeID = nodeIDString
|
||||||
"consequently the tx's memo field will be unset: %s", err)
|
}
|
||||||
|
|
||||||
|
ip := viper.GetString(cli.FlagIP)
|
||||||
|
if ip == "" {
|
||||||
|
fmt.Fprintf(os.Stderr, "couldn't retrieve an external IP; "+
|
||||||
|
"the tx's memo field will be unset")
|
||||||
}
|
}
|
||||||
|
|
||||||
genDoc, err := LoadGenesisDoc(cdc, config.GenesisFile())
|
genDoc, err := LoadGenesisDoc(cdc, config.GenesisFile())
|
||||||
|
@ -156,11 +161,15 @@ following delegation and commission default parameters:
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ip, _ := server.ExternalIP()
|
||||||
|
|
||||||
cmd.Flags().String(tmcli.HomeFlag, app.DefaultNodeHome, "node's home directory")
|
cmd.Flags().String(tmcli.HomeFlag, app.DefaultNodeHome, "node's home directory")
|
||||||
cmd.Flags().String(flagClientHome, app.DefaultCLIHome, "client's home directory")
|
cmd.Flags().String(flagClientHome, app.DefaultCLIHome, "client's home directory")
|
||||||
cmd.Flags().String(client.FlagName, "", "name of private key with which to sign the gentx")
|
cmd.Flags().String(client.FlagName, "", "name of private key with which to sign the gentx")
|
||||||
cmd.Flags().String(client.FlagOutputDocument, "",
|
cmd.Flags().String(client.FlagOutputDocument, "",
|
||||||
"write the genesis transaction JSON document to the given file instead of the default location")
|
"write the genesis transaction JSON document to the given file instead of the default location")
|
||||||
|
cmd.Flags().String(cli.FlagIP, ip, "The node's public IP")
|
||||||
|
cmd.Flags().String(cli.FlagNodeID, "", "The node's NodeID")
|
||||||
cmd.Flags().AddFlagSet(cli.FsCommissionCreate)
|
cmd.Flags().AddFlagSet(cli.FsCommissionCreate)
|
||||||
cmd.Flags().AddFlagSet(cli.FsAmount)
|
cmd.Flags().AddFlagSet(cli.FsAmount)
|
||||||
cmd.Flags().AddFlagSet(cli.FsPk)
|
cmd.Flags().AddFlagSet(cli.FsPk)
|
||||||
|
|
|
@ -21,7 +21,6 @@ import (
|
||||||
const (
|
const (
|
||||||
flagOverwrite = "overwrite"
|
flagOverwrite = "overwrite"
|
||||||
flagClientHome = "home-client"
|
flagClientHome = "home-client"
|
||||||
flagMoniker = "moniker"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type printInfo struct {
|
type printInfo struct {
|
||||||
|
@ -46,11 +45,11 @@ func displayInfo(cdc *codec.Codec, info printInfo) error {
|
||||||
// nolint
|
// nolint
|
||||||
func InitCmd(ctx *server.Context, cdc *codec.Codec) *cobra.Command {
|
func InitCmd(ctx *server.Context, cdc *codec.Codec) *cobra.Command {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "init",
|
Use: "init [moniker]",
|
||||||
Short: "Initialize private validator, p2p, genesis, and application configuration files",
|
Short: "Initialize private validator, p2p, genesis, and application configuration files",
|
||||||
Long: `Initialize validators's and node's configuration files.`,
|
Long: `Initialize validators's and node's configuration files.`,
|
||||||
Args: cobra.NoArgs,
|
Args: cobra.ExactArgs(1),
|
||||||
RunE: func(_ *cobra.Command, _ []string) error {
|
RunE: func(_ *cobra.Command, args []string) error {
|
||||||
config := ctx.Config
|
config := ctx.Config
|
||||||
config.SetRoot(viper.GetString(cli.HomeFlag))
|
config.SetRoot(viper.GetString(cli.HomeFlag))
|
||||||
|
|
||||||
|
@ -64,7 +63,7 @@ func InitCmd(ctx *server.Context, cdc *codec.Codec) *cobra.Command {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
config.Moniker = viper.GetString(flagMoniker)
|
config.Moniker = args[0]
|
||||||
|
|
||||||
var appState json.RawMessage
|
var appState json.RawMessage
|
||||||
genFile := config.GenesisFile()
|
genFile := config.GenesisFile()
|
||||||
|
@ -89,8 +88,6 @@ func InitCmd(ctx *server.Context, cdc *codec.Codec) *cobra.Command {
|
||||||
cmd.Flags().String(cli.HomeFlag, app.DefaultNodeHome, "node's home directory")
|
cmd.Flags().String(cli.HomeFlag, app.DefaultNodeHome, "node's home directory")
|
||||||
cmd.Flags().BoolP(flagOverwrite, "o", false, "overwrite the genesis.json file")
|
cmd.Flags().BoolP(flagOverwrite, "o", false, "overwrite the genesis.json file")
|
||||||
cmd.Flags().String(client.FlagChainID, "", "genesis file chain-id, if left blank will be randomly created")
|
cmd.Flags().String(client.FlagChainID, "", "genesis file chain-id, if left blank will be randomly created")
|
||||||
cmd.Flags().String(flagMoniker, "", "set the validator's moniker")
|
|
||||||
cmd.MarkFlagRequired(flagMoniker)
|
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,10 +36,7 @@ func TestInitCmd(t *testing.T) {
|
||||||
cdc := app.MakeCodec()
|
cdc := app.MakeCodec()
|
||||||
cmd := InitCmd(ctx, cdc)
|
cmd := InitCmd(ctx, cdc)
|
||||||
|
|
||||||
viper.Set(flagMoniker, "gaianode-test")
|
require.NoError(t, cmd.RunE(nil, []string{"gaianode-test"}))
|
||||||
|
|
||||||
err = cmd.RunE(nil, nil)
|
|
||||||
require.NoError(t, err)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func setupClientHome(t *testing.T) func() {
|
func setupClientHome(t *testing.T) func() {
|
||||||
|
@ -64,11 +61,9 @@ func TestEmptyState(t *testing.T) {
|
||||||
|
|
||||||
ctx := server.NewContext(cfg, logger)
|
ctx := server.NewContext(cfg, logger)
|
||||||
cdc := app.MakeCodec()
|
cdc := app.MakeCodec()
|
||||||
viper.Set(flagMoniker, "gaianode-test")
|
|
||||||
|
|
||||||
cmd := InitCmd(ctx, cdc)
|
cmd := InitCmd(ctx, cdc)
|
||||||
err = cmd.RunE(nil, nil)
|
require.NoError(t, cmd.RunE(nil, []string{"gaianode-test"}))
|
||||||
require.NoError(t, err)
|
|
||||||
|
|
||||||
old := os.Stdout
|
old := os.Stdout
|
||||||
r, w, _ := os.Pipe()
|
r, w, _ := os.Pipe()
|
||||||
|
@ -103,7 +98,6 @@ func TestStartStandAlone(t *testing.T) {
|
||||||
os.RemoveAll(home)
|
os.RemoveAll(home)
|
||||||
}()
|
}()
|
||||||
viper.Set(cli.HomeFlag, home)
|
viper.Set(cli.HomeFlag, home)
|
||||||
viper.Set(client.FlagName, "moniker")
|
|
||||||
defer setupClientHome(t)()
|
defer setupClientHome(t)()
|
||||||
|
|
||||||
logger := log.NewNopLogger()
|
logger := log.NewNopLogger()
|
||||||
|
@ -112,8 +106,7 @@ func TestStartStandAlone(t *testing.T) {
|
||||||
ctx := server.NewContext(cfg, logger)
|
ctx := server.NewContext(cfg, logger)
|
||||||
cdc := app.MakeCodec()
|
cdc := app.MakeCodec()
|
||||||
initCmd := InitCmd(ctx, cdc)
|
initCmd := InitCmd(ctx, cdc)
|
||||||
err = initCmd.RunE(nil, nil)
|
require.NoError(t, initCmd.RunE(nil, []string{"gaianode-test"}))
|
||||||
require.NoError(t, err)
|
|
||||||
|
|
||||||
app, err := mock.NewApp(home, logger)
|
app, err := mock.NewApp(home, logger)
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
|
|
|
@ -26,7 +26,7 @@ This guide helps you create a single validator node that runs a network locally
|
||||||
cd $HOME
|
cd $HOME
|
||||||
|
|
||||||
# Initialize the genesis.json file that will help you to bootstrap the network
|
# Initialize the genesis.json file that will help you to bootstrap the network
|
||||||
gaiad init --chain-id testing --moniker testing
|
gaiad init --chain-id=testing testing
|
||||||
|
|
||||||
# Create a key to hold your validator account
|
# Create a key to hold your validator account
|
||||||
gaiacli keys add validator
|
gaiacli keys add validator
|
||||||
|
|
|
@ -19,11 +19,11 @@ These instructions are for setting up a brand new full node from scratch.
|
||||||
First, initialize the node and create the necessary config files:
|
First, initialize the node and create the necessary config files:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
gaiad init --moniker <your_custom_moniker>
|
gaiad init <your_custom_moniker>
|
||||||
```
|
```
|
||||||
|
|
||||||
::: warning Note
|
::: warning Note
|
||||||
Only ASCII characters are supported for the `--moniker`. Using Unicode characters will render your node unreachable.
|
Monikers can contain only ASCII characters. Using Unicode characters will render your node unreachable.
|
||||||
:::
|
:::
|
||||||
|
|
||||||
You can edit this `moniker` later, in the `~/.gaiad/config/config.toml` file:
|
You can edit this `moniker` later, in the `~/.gaiad/config/config.toml` file:
|
||||||
|
|
Loading…
Reference in New Issue