Skip to content

Commit

Permalink
Move ValidatorPubKey under cosmos config
Browse files Browse the repository at this point in the history
  • Loading branch information
krhubert committed Aug 13, 2019
1 parent 6e738a6 commit 867203d
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 8 deletions.
6 changes: 3 additions & 3 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ type Config struct {

Tendermint struct {
*tmconfig.Config
Path string `ignored:"true"`
ValidatorPubKey PubKeyEd25519
Path string `ignored:"true"`
}

Cosmos CosmosConfig
Expand All @@ -64,7 +63,8 @@ type Config struct {
}

type CosmosConfig struct {
Path string `ignored:"true"`
Path string `ignored:"true"`
ValidatorPubKey PubKeyEd25519 `split_words:"true"`
}

// New creates a new config with default values.
Expand Down
4 changes: 4 additions & 0 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

homedir "github.com/mitchellh/go-homedir"
"github.com/stretchr/testify/require"
"github.com/tendermint/tendermint/crypto/ed25519"
)

func TestDefaultValue(t *testing.T) {
Expand Down Expand Up @@ -36,6 +37,7 @@ func TestLoad(t *testing.T) {
"MESG_LOG_LEVEL": "",
"MESG_LOG_FORCECOLORS": "",
"MESG_TENDERMINT_P2P_PERSISTENTPEERS": "",
"MESG_COSMOS_VALIDATOR_PUB_KEY": "",
}
for key := range snapsnot {
snapsnot[key] = os.Getenv(key)
Expand All @@ -51,6 +53,7 @@ func TestLoad(t *testing.T) {
os.Setenv("MESG_LOG_LEVEL", "test_log_level")
os.Setenv("MESG_LOG_FORCECOLORS", "true")
os.Setenv("MESG_TENDERMINT_P2P_PERSISTENTPEERS", "localhost")
os.Setenv("MESG_COSMOS_VALIDATOR_PUB_KEY", "0000000000000000000000000000000000000000000000000000000000000001")

c, _ := New()
c.Load()
Expand All @@ -59,6 +62,7 @@ func TestLoad(t *testing.T) {
require.Equal(t, "test_log_level", c.Log.Level)
require.Equal(t, true, c.Log.ForceColors)
require.Equal(t, "localhost", c.Tendermint.P2P.PersistentPeers)
require.Equal(t, "PubKeyEd25519{0000000000000000000000000000000000000000000000000000000000000001}", ed25519.PubKeyEd25519(c.Cosmos.ValidatorPubKey).String())
}

func TestValidate(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion core/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func main() {
logger.Init(cfg.Log.Format, cfg.Log.Level, cfg.Log.ForceColors)

// create tendermint node
node, err := tendermint.NewNode(cfg.Tendermint.Config, &cfg.Cosmos, cfg.Tendermint.ValidatorPubKey)
node, err := tendermint.NewNode(cfg.Tendermint.Config, &cfg.Cosmos)
if err != nil {
logrus.Fatalln(err)
}
Expand Down
4 changes: 2 additions & 2 deletions dev
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ TENDERMINT_VALIDATOR_PATH=${TENDERMINT_VALIDATOR_PATH:-".tendermint-validator"}
# Init and read validator identity
eval $(go run internal/tools/gen_tm_identity.go -name=$TENDERMINT_VALIDATOR_NAME -port=$TENDERMINT_VALIDATOR_PORT -path=$TENDERMINT_VALIDATOR_PATH)
MESG_TENDERMINT_P2P_PERSISTENTPEERS=${MESG_TENDERMINT_P2P_PERSISTENTPEERS:-$NODE_PUBKEY}
MESG_TENDERMINT_VALIDATORPUBKEY=${MESG_TENDERMINT_VALIDATORPUBKEY:-$VALIDATOR_PUBKEY}
MESG_COSMOS_VALIDATOR_PUB_KEY=${MESG_COSMOS_VALIDATOR_PUB_KEY:-$VALIDATOR_PUBKEY}

# Setup the validator private keys
if [[ $* == *--validator* ]]; then
Expand Down Expand Up @@ -134,7 +134,7 @@ docker service create \
--env MESG_LOG_FORMAT=$MESG_LOG_FORMAT \
--env MESG_LOG_FORCECOLORS=$MESG_LOG_FORCECOLORS \
--env MESG_LOG_LEVEL=$MESG_LOG_LEVEL \
--env MESG_TENDERMINT_VALIDATORPUBKEY=$MESG_TENDERMINT_VALIDATORPUBKEY \
--env MESG_COSMOS_VALIDATOR_PUB_KEY=$MESG_COSMOS_VALIDATOR_PUB_KEY \
--env MESG_TENDERMINT_P2P_PERSISTENTPEERS=$MESG_TENDERMINT_P2P_PERSISTENTPEERS \
--env MESG_TENDERMINT_P2P_EXTERNALADDRESS=$MESG_TENDERMINT_P2P_EXTERNALADDRESS \
--mount type=bind,source=/var/run/docker.sock,destination=/var/run/docker.sock \
Expand Down
4 changes: 2 additions & 2 deletions tendermint/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const (
)

// NewNode retruns new tendermint node that runs the app.
func NewNode(cfg *tmconfig.Config, ccfg *config.CosmosConfig, validatorPubKey config.PubKeyEd25519) (*node.Node, error) {
func NewNode(cfg *tmconfig.Config, ccfg *config.CosmosConfig) (*node.Node, error) {
nodeKey, err := p2p.LoadOrGenNodeKey(cfg.NodeKeyFile())
if err != nil {
return nil, err
Expand Down Expand Up @@ -62,7 +62,7 @@ func NewNode(cfg *tmconfig.Config, ccfg *config.CosmosConfig, validatorPubKey co
app, cdc := app.NewNameServiceApp(logger, db)

// build a message to create validator
msg := newMsgCreateValidator(sdktypes.ValAddress(account.GetAddress()), ed25519.PubKeyEd25519(validatorPubKey))
msg := newMsgCreateValidator(sdktypes.ValAddress(account.GetAddress()), ed25519.PubKeyEd25519(ccfg.ValidatorPubKey))
logrus.WithField("msg", msg).Info("validator tx")

// sign the message
Expand Down

0 comments on commit 867203d

Please sign in to comment.