mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-17 07:01:20 +00:00
Integrate PrivValidator socket server
This commit is contained in:
@ -14,7 +14,7 @@ func main() {
|
|||||||
var (
|
var (
|
||||||
chainID = flag.String("chain-id", "mychain", "chain id")
|
chainID = flag.String("chain-id", "mychain", "chain id")
|
||||||
listenAddr = flag.String("laddr", ":46659", "Validator listen address (0.0.0.0:0 means any interface, any port")
|
listenAddr = flag.String("laddr", ":46659", "Validator listen address (0.0.0.0:0 means any interface, any port")
|
||||||
maxClients = flag.Int("clients", 3, "number of concurrently connected clients")
|
maxConn = flag.Int("clients", 3, "maximum of concurrent connections")
|
||||||
privValPath = flag.String("priv", "", "priv val file path")
|
privValPath = flag.String("priv", "", "priv val file path")
|
||||||
|
|
||||||
logger = log.NewTMLogger(log.NewSyncWriter(os.Stdout)).With("module", "priv_val")
|
logger = log.NewTMLogger(log.NewSyncWriter(os.Stdout)).With("module", "priv_val")
|
||||||
@ -25,7 +25,7 @@ func main() {
|
|||||||
"Starting private validator",
|
"Starting private validator",
|
||||||
"chainID", *chainID,
|
"chainID", *chainID,
|
||||||
"listenAddr", *listenAddr,
|
"listenAddr", *listenAddr,
|
||||||
"maxClients", *maxClients,
|
"maxConn", *maxConn,
|
||||||
"privPath", *privValPath,
|
"privPath", *privValPath,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ func main() {
|
|||||||
logger,
|
logger,
|
||||||
*chainID,
|
*chainID,
|
||||||
*listenAddr,
|
*listenAddr,
|
||||||
*maxClients,
|
*maxConn,
|
||||||
privVal,
|
privVal,
|
||||||
nil,
|
nil,
|
||||||
)
|
)
|
||||||
|
@ -16,6 +16,7 @@ func AddNodeFlags(cmd *cobra.Command) {
|
|||||||
|
|
||||||
// priv val flags
|
// priv val flags
|
||||||
cmd.Flags().String("priv_validator_addr", config.PrivValidatorAddr, "Socket address for private validator")
|
cmd.Flags().String("priv_validator_addr", config.PrivValidatorAddr, "Socket address for private validator")
|
||||||
|
cmd.Flags().Int("priv_validator_max_conn", config.PrivValidatorMaxConn, "Limit of concurrent connections to the PrivValidator")
|
||||||
|
|
||||||
// node flags
|
// node flags
|
||||||
cmd.Flags().Bool("fast_sync", config.FastSync, "Fast blockchain syncing")
|
cmd.Flags().Bool("fast_sync", config.FastSync, "Fast blockchain syncing")
|
||||||
|
@ -20,7 +20,9 @@ var (
|
|||||||
|
|
||||||
defaultConfigFileName = "config.toml"
|
defaultConfigFileName = "config.toml"
|
||||||
defaultGenesisJSONName = "genesis.json"
|
defaultGenesisJSONName = "genesis.json"
|
||||||
|
|
||||||
defaultPrivValName = "priv_validator.json"
|
defaultPrivValName = "priv_validator.json"
|
||||||
|
defaultPrivValMaxConn = 3
|
||||||
defaultNodeKeyName = "node_key.json"
|
defaultNodeKeyName = "node_key.json"
|
||||||
defaultAddrBookName = "addrbook.json"
|
defaultAddrBookName = "addrbook.json"
|
||||||
|
|
||||||
@ -106,6 +108,9 @@ type BaseConfig struct {
|
|||||||
// TCP or UNIX socket address of the PrivValidator server
|
// TCP or UNIX socket address of the PrivValidator server
|
||||||
PrivValidatorAddr string `mapstructure:"priv_validator_addr"`
|
PrivValidatorAddr string `mapstructure:"priv_validator_addr"`
|
||||||
|
|
||||||
|
// Limit of concurrent connections to the PrivValidator.
|
||||||
|
PrivValidatorMaxConn int `mapstructure:"priv_validator_max_conn"`
|
||||||
|
|
||||||
// TCP or UNIX socket address of the ABCI application,
|
// TCP or UNIX socket address of the ABCI application,
|
||||||
// or the name of an ABCI application compiled in with the Tendermint binary
|
// or the name of an ABCI application compiled in with the Tendermint binary
|
||||||
ProxyApp string `mapstructure:"proxy_app"`
|
ProxyApp string `mapstructure:"proxy_app"`
|
||||||
@ -144,6 +149,7 @@ func DefaultBaseConfig() BaseConfig {
|
|||||||
return BaseConfig{
|
return BaseConfig{
|
||||||
Genesis: defaultGenesisJSONPath,
|
Genesis: defaultGenesisJSONPath,
|
||||||
PrivValidator: defaultPrivValPath,
|
PrivValidator: defaultPrivValPath,
|
||||||
|
PrivValidatorMaxConn: defaultPrivValMaxConn,
|
||||||
NodeKey: defaultNodeKeyPath,
|
NodeKey: defaultNodeKeyPath,
|
||||||
Moniker: defaultMoniker,
|
Moniker: defaultMoniker,
|
||||||
ProxyApp: "tcp://127.0.0.1:46658",
|
ProxyApp: "tcp://127.0.0.1:46658",
|
||||||
|
32
node/node.go
32
node/node.go
@ -34,6 +34,7 @@ import (
|
|||||||
"github.com/tendermint/tendermint/state/txindex/kv"
|
"github.com/tendermint/tendermint/state/txindex/kv"
|
||||||
"github.com/tendermint/tendermint/state/txindex/null"
|
"github.com/tendermint/tendermint/state/txindex/null"
|
||||||
"github.com/tendermint/tendermint/types"
|
"github.com/tendermint/tendermint/types"
|
||||||
|
priv_val "github.com/tendermint/tendermint/types/priv_validator"
|
||||||
"github.com/tendermint/tendermint/version"
|
"github.com/tendermint/tendermint/version"
|
||||||
|
|
||||||
_ "net/http/pprof"
|
_ "net/http/pprof"
|
||||||
@ -77,20 +78,8 @@ type NodeProvider func(*cfg.Config, log.Logger) (*Node, error)
|
|||||||
// PrivValidator, ClientCreator, GenesisDoc, and DBProvider.
|
// PrivValidator, ClientCreator, GenesisDoc, and DBProvider.
|
||||||
// It implements NodeProvider.
|
// It implements NodeProvider.
|
||||||
func DefaultNewNode(config *cfg.Config, logger log.Logger) (*Node, error) {
|
func DefaultNewNode(config *cfg.Config, logger log.Logger) (*Node, error) {
|
||||||
var privVal types.PrivValidator
|
|
||||||
privVal = types.LoadOrGenPrivValidatorFS(config.PrivValidatorFile())
|
|
||||||
/* TODO
|
|
||||||
if config.PrivValidatorAddr != "" {
|
|
||||||
pvsc := priv_val.NewPrivValidatorSocketClient(logger.With("module", "priv_val"),
|
|
||||||
config.PrivValidatorAddr)
|
|
||||||
pvsc.Start()
|
|
||||||
privVal = pvsc
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
fmt.Println("PRIV", config.PrivValidatorAddr)
|
|
||||||
|
|
||||||
return NewNode(config,
|
return NewNode(config,
|
||||||
privVal,
|
types.LoadOrGenPrivValidatorFS(config.PrivValidatorFile()),
|
||||||
proxy.DefaultClientCreator(config.ProxyApp, config.ABCI, config.DBDir()),
|
proxy.DefaultClientCreator(config.ProxyApp, config.ABCI, config.DBDir()),
|
||||||
DefaultGenesisDocProviderFunc(config),
|
DefaultGenesisDocProviderFunc(config),
|
||||||
DefaultDBProvider,
|
DefaultDBProvider,
|
||||||
@ -184,20 +173,21 @@ func NewNode(config *cfg.Config,
|
|||||||
// reload the state (it may have been updated by the handshake)
|
// reload the state (it may have been updated by the handshake)
|
||||||
state = sm.LoadState(stateDB)
|
state = sm.LoadState(stateDB)
|
||||||
|
|
||||||
/* TODO
|
|
||||||
// Generate node PrivKey
|
|
||||||
privKey := crypto.GenPrivKeyEd25519()
|
|
||||||
|
|
||||||
if config.PrivValidatorAddr != "" {
|
if config.PrivValidatorAddr != "" {
|
||||||
pvsc := priv_val.NewPrivValidatorSocketClient(
|
var (
|
||||||
|
privKey = crypto.GenPrivKeyEd25519()
|
||||||
|
pvss = priv_val.NewPrivValidatorSocketServer(
|
||||||
logger.With("module", "priv_val"),
|
logger.With("module", "priv_val"),
|
||||||
|
config.ChainID(),
|
||||||
config.PrivValidatorAddr,
|
config.PrivValidatorAddr,
|
||||||
|
config.PrivValidatorMaxConn,
|
||||||
|
priv_val.LoadPrivValidatorJSON(config.PrivValidatorFile()),
|
||||||
&privKey,
|
&privKey,
|
||||||
)
|
)
|
||||||
pvsc.Start()
|
)
|
||||||
privValidator = pvsc
|
|
||||||
|
pvss.Start()
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
// Decide whether to fast-sync or not
|
// Decide whether to fast-sync or not
|
||||||
// We don't fast-sync when the only validator is us.
|
// We don't fast-sync when the only validator is us.
|
||||||
|
Reference in New Issue
Block a user