Skip to content

Commit

Permalink
go/tendermint: Add config for private & persistent peers, disabling Pex
Browse files Browse the repository at this point in the history
  • Loading branch information
tjanez committed Nov 6, 2019
1 parent 312bfe0 commit 3cbbc99
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
21 changes: 21 additions & 0 deletions go/oasis-test-runner/oasis/args.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,27 @@ func (args *argBuilder) tendermintCoreListenAddress(port uint16) *argBuilder {
return args
}

func (args *argBuilder) tendermintPersistentPeers(peers string) *argBuilder {
args.vec = append(args.vec, []string{
"--" + tendermint.CfgP2PPersistentPeers, peers,
}...)
return args
}

func (args *argBuilder) tendermintPrivatePeers(peers string) *argBuilder {
args.vec = append(args.vec, []string{
"--" + tendermint.CfgP2PPrivatePeers, peers,
}...)
return args
}

func (args *argBuilder) tendermintDisablePeerExchange() *argBuilder {
args.vec = append(args.vec, []string{
"--" + tendermint.CfgP2PDisablePeerExchange,
}...)
return args
}

func (args *argBuilder) tendermintSeedMode() *argBuilder {
args.vec = append(args.vec, "--"+tendermint.CfgP2PSeedMode)
return args
Expand Down
16 changes: 15 additions & 1 deletion go/tendermint/tendermint.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ const (
cfgABCIPruneStrategy = "tendermint.abci.prune.strategy"
cfgABCIPruneNumKept = "tendermint.abci.prune.num_kept"

CfgP2PPrivatePeers = "tendermint.private_peers"
CfgP2PPersistentPeers = "tendermint.persistent_peers"
CfgP2PDisablePeerExchange = "tendermint.disable_peer_exchange"

// CfgP2PSeeds configures the tendermint seed nodes.
CfgP2PSeeds = "tendermint.seeds"
// CfgP2PSeedMode enables the tendermint seed mode.
Expand Down Expand Up @@ -514,9 +518,16 @@ func (t *tendermintService) lazyInit() error {
tenderConfig.P2P.ListenAddress = viper.GetString(CfgCoreListenAddress)
tenderConfig.P2P.ExternalAddress = viper.GetString(cfgCoreExternalAddress)
tenderConfig.P2P.AllowDuplicateIP = true // HACK: e2e tests need this.
tenderConfig.P2P.PrivatePeerIDs = viper.GetString(CfgP2PPrivatePeers)
// Persistent peers need to be lowecase as p2p/transport.go:MultiplexTransport.upgrade()
// uses a case sensitive string comparision to validate public keys.
// Since persistent peers is expected to be in comma-delimited id@host:port format,
// lowercasing the whole string is ok.
tenderConfig.P2P.PersistentPeers = strings.ToLower(viper.GetString(CfgP2PPersistentPeers))
tenderConfig.P2P.PexReactor = !viper.GetBool(CfgP2PDisablePeerExchange)
tenderConfig.P2P.SeedMode = viper.GetBool(CfgP2PSeedMode)
// Seed Ids need to be Lowecase as p2p/transport.go:MultiplexTransport.upgrade()
// uses a case sensitive string comparision to validate public keys
// uses a case sensitive string comparision to validate public keys.
// Since Seeds is expected to be in comma-delimited id@host:port format,
// lowercasing the whole string is ok.
tenderConfig.P2P.Seeds = strings.ToLower(viper.GetString(CfgP2PSeeds))
Expand Down Expand Up @@ -865,6 +876,9 @@ func init() {
Flags.String(cfgCoreExternalAddress, "", "tendermint address advertised to other nodes")
Flags.String(cfgABCIPruneStrategy, abci.PruneDefault, "ABCI state pruning strategy")
Flags.Int64(cfgABCIPruneNumKept, 3600, "ABCI state versions kept (when applicable)")
Flags.String(CfgP2PPrivatePeers, "", "comma-delimited list of private peers (i.e. they will not be gossiped to other peers)")
Flags.String(CfgP2PPersistentPeers, "", "comma-delimited list of nodes to keep persistent connections to")
Flags.Bool(CfgP2PDisablePeerExchange, false, "disable peer-exchange reactor")
Flags.Bool(CfgP2PSeedMode, false, "run the tendermint node in seed mode")
Flags.String(CfgP2PSeeds, "", "comma-delimited id@host:port tendermint seed nodes")
Flags.Bool(cfgLogDebug, false, "enable tendermint debug logs (very verbose)")
Expand Down

0 comments on commit 3cbbc99

Please sign in to comment.