Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tendermint testnet: Allow for better hostname control #3661

Merged
merged 8 commits into from May 27, 2019

Conversation

thanethomson
Copy link
Contributor

@thanethomson thanethomson commented May 14, 2019

This attempts to address issue #3660. It adds two additional flags to the tendermint testnet command:

  1. --hostname-suffix - to automatically append a suffix to each and every generated (non-IP) hostname
  2. --hostname - a StringArray parameter to manually override all peer hostnames. Using this flag causes tendermint testnet to completely ignore the --hostname-prefix, --hostname-suffix and --starting-ip-address fields.

Example 1 with --hostname-suffix:

> tendermint testnet --v 4 --n 0 --o /tmp/testnet \
    --hostname-prefix mynode \
    --hostname-suffix .xyz.com

> cat /tmp/testnet/node0/config/config.toml | grep persistent_peers
persistent_peers = "42311234da9693ff1affa073f7ef9984a0674582@mynode0.xyz.com:26656,470c1c72deacad25c61673c0b452d5ef99b6053a@mynode1.xyz.com:26656,4a60e1b25e8af75d8688f8c81e93b6c45a8e2991@mynode2.xyz.com:26656,a8d586a3ed4b47b0b04b049445d27113ac031f03@mynode3.xyz.com:26656"

Example 2 with --hostname:

> tendermint testnet --v 4 --n 0 --o /tmp/testnet \
    --hostname alpha.xyz.com \
    --hostname beta.xyz.com \
    --hostname alpha.abcd.com \
    --hostname beta.abcd.com

> cat /tmp/testnet/node0/config/config.toml | grep persistent_peers
persistent_peers = "42311234da9693ff1affa073f7ef9984a0674582@alpha.xyz.com:26656,470c1c72deacad25c61673c0b452d5ef99b6053a@beta.xyz.com:26656,4a60e1b25e8af75d8688f8c81e93b6c45a8e2991@alpha.abcd.com:26656,a8d586a3ed4b47b0b04b049445d27113ac031f03@beta.abcd.com:26656"
  • Updated all relevant documentation in docs
  • Updated all code comments where relevant
  • Wrote tests
  • Updated CHANGELOG_PENDING.md

This allows one to specify the `--hostname` flag multiple times, each
time providing an additional custom hostname for a respective peer
(validator or non-validator). This overrides any of the
`--hostname-prefix` or `--starting-ip-address` flags.

The string array approach is taken instead of the string slice approach
(see the pflag docs:
https://godoc.org/github.com/spf13/pflag#StringArray) because the string
slice approach (a comma-separated string) doesn't allow for cleaner
multi-line BASH scripts - where this feature is intended to be used.
@thanethomson thanethomson self-assigned this May 14, 2019
@codecov-io
Copy link

codecov-io commented May 14, 2019

Codecov Report

Merging #3661 into develop will increase coverage by 0.15%.
The diff coverage is 22.22%.

@@             Coverage Diff             @@
##           develop    #3661      +/-   ##
===========================================
+ Coverage    63.18%   63.34%   +0.15%     
===========================================
  Files          218      218              
  Lines        18194    18226      +32     
===========================================
+ Hits         11496    11545      +49     
+ Misses        5727     5721       -6     
+ Partials       971      960      -11
Impacted Files Coverage Δ
cmd/tendermint/commands/testnet.go 18.38% <22.22%> (+1.41%) ⬆️
privval/signer_service_endpoint.go 83.63% <0%> (-1.82%) ⬇️
tools/tm-bench/transacter.go 8.49% <0%> (-0.47%) ⬇️
consensus/state.go 79.97% <0%> (+0.11%) ⬆️
p2p/pex/addrbook.go 68% <0%> (+0.5%) ⬆️
consensus/replay.go 71.02% <0%> (+0.81%) ⬆️
blockchain/pool.go 81.25% <0%> (+0.98%) ⬆️
consensus/reactor.go 72.37% <0%> (+1.77%) ⬆️
p2p/pex/pex_reactor.go 83.97% <0%> (+1.78%) ⬆️
privval/signer_remote.go 82% <0%> (+2%) ⬆️
... and 3 more

The current approach to generating monikers for testnet nodes assigns
the local hostname of the machine on which the testnet config was
generated to all nodes. This results in the same moniker for each and
every node.

This commit makes use of the supplied `--hostname-prefix` and
`--hostname-suffix`, or `--hostname` parameters to generate unique
monikers for each node. Alternatively, another parameter
(`--random-monikers`) allows one to forcibly override all of the other
options with random hexadecimal strings.
@thanethomson
Copy link
Contributor Author

The latest commit now adds support for the generation of unique monikers for each node configuration generated using the same scheme as for generating peer hostnames (except if --starting-ip-address is used, it will create random hexadecimal strings for monikers). It also adds another command line flag (--random-monikers) which overrides all other configuration to force the tool to generate random hexadecimal strings for monikers.

Previously the command would just use your local hostname, resulting in the same moniker for all nodes. This is not particularly useful when generating configurations for remote nodes, and results in needing to use tools like sed to overwrite the monikers.

@ebuchman ebuchman merged commit a6ac611 into develop May 27, 2019
@ebuchman ebuchman deleted the issues/3660-testnet-hostnames branch May 27, 2019 19:33
@melekes melekes mentioned this pull request May 30, 2019
44 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants