Skip to content
This repository has been archived by the owner on Nov 30, 2021. It is now read-only.

fix chainid error #758

Closed
wants to merge 1 commit into from
Closed
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
18 changes: 18 additions & 0 deletions server/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
pvm "github.com/tendermint/tendermint/privval"
"github.com/tendermint/tendermint/proxy"
"github.com/tendermint/tendermint/rpc/client/local"
tmtypes "github.com/tendermint/tendermint/types"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
Expand Down Expand Up @@ -76,6 +77,21 @@ which accepts a path for the resulting pprof file.
serverCtx := sdkserver.GetServerContextFromCmd(cmd)
clientCtx := client.GetClientContextFromCmd(cmd)

// validate genesis file before running start
var genesisf string

clientCtx.ChainID, _ = cmd.Flags().GetString(flags.FlagChainID)
if clientCtx.ChainID == "" {
genesisf = serverCtx.Config.GenesisFile()
genDoc, err := tmtypes.GenesisDocFromFile(genesisf)
if err != nil {
return fmt.Errorf("%s - chainID could not be found",
err.Error(),
)
}
clientCtx.ChainID = genDoc.ChainID
}

withTM, _ := cmd.Flags().GetBool(flagWithTendermint)
if !withTM {
serverCtx.Logger.Info("starting ABCI without Tendermint")
Expand Down Expand Up @@ -120,6 +136,8 @@ which accepts a path for the resulting pprof file.
cmd.Flags().Uint64(sdkserver.FlagStateSyncSnapshotInterval, 0, "State sync snapshot interval")
cmd.Flags().Uint32(sdkserver.FlagStateSyncSnapshotKeepRecent, 2, "State sync snapshot to keep")

cmd.Flags().String(flags.FlagChainID, "", "genesis file chain-id, if left blank will be randomly created")

// add support for all Tendermint-specific command line options
tcmd.AddNodeFlags(cmd)
return cmd
Expand Down