diff --git a/cmd/priv_val_server/main.go b/cmd/priv_val_server/main.go index 6b10b8178..98e7dceed 100644 --- a/cmd/priv_val_server/main.go +++ b/cmd/priv_val_server/main.go @@ -8,7 +8,7 @@ import ( cmn "github.com/tendermint/tmlibs/common" "github.com/tendermint/tmlibs/log" - priv_val "github.com/tendermint/tendermint/types/priv_validator" + "github.com/tendermint/tendermint/privval" ) func main() { @@ -30,13 +30,13 @@ func main() { "privPath", *privValPath, ) - privVal := priv_val.LoadFilePV(*privValPath) + pv := privval.LoadFilePV(*privValPath) - rs := priv_val.NewRemoteSigner( + rs := privval.NewRemoteSigner( logger, *chainID, *addr, - privVal, + pv, crypto.GenPrivKeyEd25519(), ) err := rs.Start() diff --git a/cmd/tendermint/commands/gen_validator.go b/cmd/tendermint/commands/gen_validator.go index ff0d97d76..20d43d4dd 100644 --- a/cmd/tendermint/commands/gen_validator.go +++ b/cmd/tendermint/commands/gen_validator.go @@ -5,7 +5,7 @@ import ( "github.com/spf13/cobra" - pvm "github.com/tendermint/tendermint/types/priv_validator" + "github.com/tendermint/tendermint/privval" ) // GenValidatorCmd allows the generation of a keypair for a @@ -17,7 +17,7 @@ var GenValidatorCmd = &cobra.Command{ } func genValidator(cmd *cobra.Command, args []string) { - pv := pvm.GenFilePV("") + pv := privval.GenFilePV("") jsbz, err := cdc.MarshalJSON(pv) if err != nil { panic(err) diff --git a/cmd/tendermint/commands/init.go b/cmd/tendermint/commands/init.go index 430a6c7c9..45812b9ed 100644 --- a/cmd/tendermint/commands/init.go +++ b/cmd/tendermint/commands/init.go @@ -7,8 +7,8 @@ import ( cfg "github.com/tendermint/tendermint/config" "github.com/tendermint/tendermint/p2p" + "github.com/tendermint/tendermint/privval" "github.com/tendermint/tendermint/types" - pvm "github.com/tendermint/tendermint/types/priv_validator" cmn "github.com/tendermint/tmlibs/common" ) @@ -26,12 +26,12 @@ func initFiles(cmd *cobra.Command, args []string) error { func initFilesWithConfig(config *cfg.Config) error { // private validator privValFile := config.PrivValidatorFile() - var pv *pvm.FilePV + var pv *privval.FilePV if cmn.FileExists(privValFile) { - pv = pvm.LoadFilePV(privValFile) + pv = privval.LoadFilePV(privValFile) logger.Info("Found private validator", "path", privValFile) } else { - pv = pvm.GenFilePV(privValFile) + pv = privval.GenFilePV(privValFile) pv.Save() logger.Info("Generated private validator", "path", privValFile) } diff --git a/cmd/tendermint/commands/reset_priv_validator.go b/cmd/tendermint/commands/reset_priv_validator.go index 78db87ded..cf4b7c575 100644 --- a/cmd/tendermint/commands/reset_priv_validator.go +++ b/cmd/tendermint/commands/reset_priv_validator.go @@ -5,7 +5,7 @@ import ( "github.com/spf13/cobra" - pvm "github.com/tendermint/tendermint/types/priv_validator" + "github.com/tendermint/tendermint/privval" "github.com/tendermint/tmlibs/log" ) @@ -50,11 +50,11 @@ func resetPrivValidator(cmd *cobra.Command, args []string) { func resetFilePV(privValFile string, logger log.Logger) { // Get PrivValidator if _, err := os.Stat(privValFile); err == nil { - pv := pvm.LoadFilePV(privValFile) + pv := privval.LoadFilePV(privValFile) pv.Reset() logger.Info("Reset PrivValidator", "file", privValFile) } else { - pv := pvm.GenFilePV(privValFile) + pv := privval.GenFilePV(privValFile) pv.Save() logger.Info("Generated PrivValidator", "file", privValFile) } diff --git a/cmd/tendermint/commands/show_validator.go b/cmd/tendermint/commands/show_validator.go index b354683b4..54765164b 100644 --- a/cmd/tendermint/commands/show_validator.go +++ b/cmd/tendermint/commands/show_validator.go @@ -5,7 +5,7 @@ import ( "github.com/spf13/cobra" - privval "github.com/tendermint/tendermint/types/priv_validator" + "github.com/tendermint/tendermint/privval" ) // ShowValidatorCmd adds capabilities for showing the validator info. diff --git a/cmd/tendermint/commands/testnet.go b/cmd/tendermint/commands/testnet.go index 3b29e20a2..660bab151 100644 --- a/cmd/tendermint/commands/testnet.go +++ b/cmd/tendermint/commands/testnet.go @@ -12,8 +12,8 @@ import ( cfg "github.com/tendermint/tendermint/config" "github.com/tendermint/tendermint/p2p" + "github.com/tendermint/tendermint/privval" "github.com/tendermint/tendermint/types" - pvm "github.com/tendermint/tendermint/types/priv_validator" cmn "github.com/tendermint/tmlibs/common" ) @@ -89,7 +89,7 @@ func testnetFiles(cmd *cobra.Command, args []string) error { initFilesWithConfig(config) pvFile := filepath.Join(nodeDir, config.BaseConfig.PrivValidator) - pv := pvm.LoadFilePV(pvFile) + pv := privval.LoadFilePV(pvFile) genVals[i] = types.GenesisValidator{ PubKey: pv.GetPubKey(), Power: 1, diff --git a/consensus/common_test.go b/consensus/common_test.go index 3eaeea700..94ab70de5 100644 --- a/consensus/common_test.go +++ b/consensus/common_test.go @@ -19,9 +19,9 @@ import ( cstypes "github.com/tendermint/tendermint/consensus/types" mempl "github.com/tendermint/tendermint/mempool" "github.com/tendermint/tendermint/p2p" + "github.com/tendermint/tendermint/privval" sm "github.com/tendermint/tendermint/state" "github.com/tendermint/tendermint/types" - pvm "github.com/tendermint/tendermint/types/priv_validator" cmn "github.com/tendermint/tmlibs/common" dbm "github.com/tendermint/tmlibs/db" "github.com/tendermint/tmlibs/log" @@ -278,10 +278,10 @@ func newConsensusStateWithConfigAndBlockStore(thisConfig *cfg.Config, state sm.S return cs } -func loadPrivValidator(config *cfg.Config) *pvm.FilePV { +func loadPrivValidator(config *cfg.Config) *privval.FilePV { privValidatorFile := config.PrivValidatorFile() ensureDir(path.Dir(privValidatorFile), 0700) - privValidator := pvm.LoadOrGenFilePV(privValidatorFile) + privValidator := privval.LoadOrGenFilePV(privValidatorFile) privValidator.Reset() return privValidator } @@ -379,7 +379,7 @@ func randConsensusNetWithPeers(nValidators, nPeers int, testName string, tickerF privVal = privVals[i] } else { _, tempFilePath := cmn.Tempfile("priv_validator_") - privVal = pvm.GenFilePV(tempFilePath) + privVal = privval.GenFilePV(tempFilePath) } app := appFunc() diff --git a/consensus/replay_test.go b/consensus/replay_test.go index 84b1e1180..766a6e52e 100644 --- a/consensus/replay_test.go +++ b/consensus/replay_test.go @@ -23,10 +23,10 @@ import ( dbm "github.com/tendermint/tmlibs/db" cfg "github.com/tendermint/tendermint/config" + "github.com/tendermint/tendermint/privval" "github.com/tendermint/tendermint/proxy" sm "github.com/tendermint/tendermint/state" "github.com/tendermint/tendermint/types" - pvm "github.com/tendermint/tendermint/types/priv_validator" "github.com/tendermint/tmlibs/log" ) @@ -329,7 +329,7 @@ func testHandshakeReplay(t *testing.T, nBlocks int, mode uint) { walFile := tempWALWithData(walBody) config.Consensus.SetWalFile(walFile) - privVal := pvm.LoadFilePV(config.PrivValidatorFile()) + privVal := privval.LoadFilePV(config.PrivValidatorFile()) wal, err := NewWAL(walFile) if err != nil { diff --git a/consensus/wal_generator.go b/consensus/wal_generator.go index dc364df0e..5de808868 100644 --- a/consensus/wal_generator.go +++ b/consensus/wal_generator.go @@ -13,10 +13,10 @@ import ( "github.com/tendermint/abci/example/kvstore" bc "github.com/tendermint/tendermint/blockchain" cfg "github.com/tendermint/tendermint/config" + "github.com/tendermint/tendermint/privval" "github.com/tendermint/tendermint/proxy" sm "github.com/tendermint/tendermint/state" "github.com/tendermint/tendermint/types" - pvm "github.com/tendermint/tendermint/types/priv_validator" auto "github.com/tendermint/tmlibs/autofile" cmn "github.com/tendermint/tmlibs/common" "github.com/tendermint/tmlibs/db" @@ -40,7 +40,7 @@ func WALWithNBlocks(numBlocks int) (data []byte, err error) { // COPY PASTE FROM node.go WITH A FEW MODIFICATIONS // NOTE: we can't import node package because of circular dependency privValidatorFile := config.PrivValidatorFile() - privValidator := pvm.LoadOrGenFilePV(privValidatorFile) + privValidator := privval.LoadOrGenFilePV(privValidatorFile) genDoc, err := types.GenesisDocFromFile(config.GenesisFile()) if err != nil { return nil, errors.Wrap(err, "failed to read genesis file") diff --git a/node/node.go b/node/node.go index 5cae4a4b1..5da57665b 100644 --- a/node/node.go +++ b/node/node.go @@ -21,6 +21,7 @@ import ( mempl "github.com/tendermint/tendermint/mempool" "github.com/tendermint/tendermint/p2p" "github.com/tendermint/tendermint/p2p/pex" + "github.com/tendermint/tendermint/privval" "github.com/tendermint/tendermint/proxy" rpccore "github.com/tendermint/tendermint/rpc/core" ctypes "github.com/tendermint/tendermint/rpc/core/types" @@ -32,7 +33,6 @@ import ( "github.com/tendermint/tendermint/state/txindex/kv" "github.com/tendermint/tendermint/state/txindex/null" "github.com/tendermint/tendermint/types" - pvm "github.com/tendermint/tendermint/types/priv_validator" "github.com/tendermint/tendermint/version" _ "net/http/pprof" @@ -77,7 +77,7 @@ type NodeProvider func(*cfg.Config, log.Logger) (*Node, error) // It implements NodeProvider. func DefaultNewNode(config *cfg.Config, logger log.Logger) (*Node, error) { return NewNode(config, - pvm.LoadOrGenFilePV(config.PrivValidatorFile()), + privval.LoadOrGenFilePV(config.PrivValidatorFile()), proxy.DefaultClientCreator(config.ProxyApp, config.ABCI, config.DBDir()), DefaultGenesisDocProviderFunc(config), DefaultDBProvider, @@ -177,8 +177,8 @@ func NewNode(config *cfg.Config, // TODO: persist this key so external signer // can actually authenticate us privKey = crypto.GenPrivKeyEd25519() - pvsc = pvm.NewSocketPV( - logger.With("module", "pvm"), + pvsc = privval.NewSocketPV( + logger.With("module", "privval"), config.PrivValidatorListenAddr, privKey, ) @@ -447,7 +447,7 @@ func (n *Node) OnStop() { n.eventBus.Stop() n.indexerService.Stop() - if pvsc, ok := n.privValidator.(*pvm.SocketPV); ok { + if pvsc, ok := n.privValidator.(*privval.SocketPV); ok { if err := pvsc.Stop(); err != nil { n.Logger.Error("Error stopping priv validator socket client", "err", err) } diff --git a/types/priv_validator/priv_validator.go b/privval/priv_validator.go similarity index 100% rename from types/priv_validator/priv_validator.go rename to privval/priv_validator.go diff --git a/types/priv_validator/priv_validator_test.go b/privval/priv_validator_test.go similarity index 100% rename from types/priv_validator/priv_validator_test.go rename to privval/priv_validator_test.go diff --git a/types/priv_validator/socket.go b/privval/socket.go similarity index 100% rename from types/priv_validator/socket.go rename to privval/socket.go diff --git a/types/priv_validator/socket_tcp.go b/privval/socket_tcp.go similarity index 100% rename from types/priv_validator/socket_tcp.go rename to privval/socket_tcp.go diff --git a/types/priv_validator/socket_tcp_test.go b/privval/socket_tcp_test.go similarity index 100% rename from types/priv_validator/socket_tcp_test.go rename to privval/socket_tcp_test.go diff --git a/types/priv_validator/socket_test.go b/privval/socket_test.go similarity index 100% rename from types/priv_validator/socket_test.go rename to privval/socket_test.go diff --git a/types/priv_validator/wire.go b/privval/wire.go similarity index 100% rename from types/priv_validator/wire.go rename to privval/wire.go diff --git a/rpc/test/helpers.go b/rpc/test/helpers.go index 11cafa0cd..5d18299bc 100644 --- a/rpc/test/helpers.go +++ b/rpc/test/helpers.go @@ -15,11 +15,11 @@ import ( cfg "github.com/tendermint/tendermint/config" nm "github.com/tendermint/tendermint/node" + "github.com/tendermint/tendermint/privval" "github.com/tendermint/tendermint/proxy" ctypes "github.com/tendermint/tendermint/rpc/core/types" core_grpc "github.com/tendermint/tendermint/rpc/grpc" rpcclient "github.com/tendermint/tendermint/rpc/lib/client" - pvm "github.com/tendermint/tendermint/types/priv_validator" ) var globalConfig *cfg.Config @@ -118,7 +118,7 @@ func NewTendermint(app abci.Application) *nm.Node { logger := log.NewTMLogger(log.NewSyncWriter(os.Stdout)) logger = log.NewFilter(logger, log.AllowError()) pvFile := config.PrivValidatorFile() - pv := pvm.LoadOrGenFilePV(pvFile) + pv := privval.LoadOrGenFilePV(pvFile) papp := proxy.NewLocalClientCreator(app) node, err := nm.NewNode(config, pv, papp, nm.DefaultGenesisDocProviderFunc(config), diff --git a/scripts/wire2amino.go b/scripts/wire2amino.go index 949082877..a942ceaad 100644 --- a/scripts/wire2amino.go +++ b/scripts/wire2amino.go @@ -13,8 +13,8 @@ import ( cmn "github.com/tendermint/tmlibs/common" "github.com/tendermint/tendermint/p2p" + "github.com/tendermint/tendermint/privval" "github.com/tendermint/tendermint/types" - priv_val "github.com/tendermint/tendermint/types/priv_validator" ) type GenesisValidator struct { @@ -84,7 +84,7 @@ func convertPrivVal(cdc *amino.Codec, jsonBytes []byte) ([]byte, error) { var pubKey crypto.PubKeyEd25519 copy(pubKey[:], privVal.PubKey.Data) - privValNew := priv_val.FilePV{ + privValNew := privval.FilePV{ Address: pubKey.Address(), PubKey: pubKey, LastHeight: privVal.LastHeight,