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

Network selector #1729

Merged
merged 10 commits into from Mar 11, 2019

Conversation

@cryptocode
Copy link
Collaborator

commented Feb 15, 2019

Closes #1099

A new CLI option is added:

--network live|beta|test

Example of using a livenet-compiled wallet to run on betanet:

./nano_wallet --network beta --data_path MyBetaDirectory

This is a CLI option instead of a config option because the config-file may not exist yet.

The ACTIVE_NETWORK build flag is still there to define the default value if no network option is present. As a result, RC builds for beta don't require a network option, so startup scripts, etc should work as before.

As discussed in #1099, some other projects use flags such as -testnet, but those mean sightly different things. A --network flag makes it clear that we don't follow any other projects' network naming standard and it mirrors how we choose network at compile-time (this doesn't seem like an option regular users will employ)

Implementation details:

  • The main function of tests forces testnet. Hence, tests can be run even when compiled for live- or betanet.
  • Any option whose value depends on network is now placed in config.hpp in the appropriate class.
  • Ledger constants are moved to config.hpp as well. Reason is these constants depend on the selected network, and initialization-order of globals in different translation units is unspecified.
  • The node and a few other classes have a nano::network_params member where the per-network values can be queried.
  • For freestanding functions, a static local is used for the params. A singleton could have been used, but we may want to inject params everywhere in the future (and perhaps remove freestanding functions) and a singleton would make that harder.
  • For network constants used as default function arguments (bound at compile-time), an overload without the argument is created which forwards to the original. One such example is work_generate_blocking (nano::uint256_union const &, uint64_t = nano::work_pool::publish_threshold);
  • Globals such as nano::genesis_amount used to depend on the compile-time network value. These are now only available for tests, which enforces the testnet. Since only tests include testutil.hpp, any attempts to use these in the node results in a compile error. As a result, this PR contains almost no changes to tests (initially there was a network_params in system, etc, but that meant a huge amount of changes with no gain)

Tests pass and it appears to sync fine on both networks.

@cryptocode cryptocode added this to the V19.0 milestone Feb 15, 2019

@cryptocode cryptocode self-assigned this Feb 15, 2019

@cryptocode cryptocode requested review from clemahieu and argakiig Feb 15, 2019

@cryptocode cryptocode added this to CP0 in V19 Feb 15, 2019

@guilhermelawless

This comment has been minimized.

Copy link
Contributor

commented Feb 15, 2019

Does the data path change to /NanoBeta by default if a live net node is compiled and only --network beta is given?

What are the consequences if an already complete beta database is provided by accident to a live net node?

@cryptocode

This comment has been minimized.

Copy link
Collaborator Author

commented Feb 15, 2019

@guilhermelawless If you pick the wrong database, an error is logged and the node exits (that's already the case). The data path should probably change to defaults if you don't supply a path; I'll change it so that the network is checked before data_path. Thanks.

@cryptocode cryptocode force-pushed the cryptocode:network-selector branch 2 times, most recently from 89b8739 to ea5e10f Feb 15, 2019

@cryptocode cryptocode force-pushed the cryptocode:network-selector branch 6 times, most recently from 3e33371 to 0503787 Feb 19, 2019

@cryptocode cryptocode force-pushed the cryptocode:network-selector branch 3 times, most recently from 9855632 to bdba1da Feb 26, 2019

cryptocode added some commits Mar 3, 2019

@cryptocode cryptocode force-pushed the cryptocode:network-selector branch from bdba1da to 8c88616 Mar 6, 2019

@cryptocode cryptocode merged commit bab4474 into nanocurrency:master Mar 11, 2019

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@cryptocode cryptocode deleted the cryptocode:network-selector branch Mar 11, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.