Change --testnet flag to --network (#1751)

## Issue Addressed

- Resolves #1689

## Proposed Changes

TBC

## Additional Info

NA
This commit is contained in:
Paul Hauner 2020-11-23 23:54:03 +00:00
parent 7d644103c6
commit 21617aa87f
28 changed files with 110 additions and 128 deletions

View File

@ -52,7 +52,7 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
Arg::with_name(WALLETS_DIR_FLAG)
.long(WALLETS_DIR_FLAG)
.value_name(WALLETS_DIR_FLAG)
.help("A path containing Eth2 EIP-2386 wallets. Defaults to ~/.lighthouse/{testnet}/wallets")
.help("A path containing Eth2 EIP-2386 wallets. Defaults to ~/.lighthouse/{network}/wallets")
.takes_value(true)
.conflicts_with("datadir"),
)
@ -62,7 +62,7 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
.value_name("SECRETS_DIR")
.help(
"The path where the validator keystore passwords will be stored. \
Defaults to ~/.lighthouse/{testnet}/secrets",
Defaults to ~/.lighthouse/{network}/secrets",
)
.conflicts_with("datadir")
.takes_value(true),

View File

@ -23,7 +23,7 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
.value_name("VALIDATOR_DIRECTORY")
.help(
"The path to search for validator directories. \
Defaults to ~/.lighthouse/{testnet}/validators",
Defaults to ~/.lighthouse/{network}/validators",
)
.takes_value(true)
.conflicts_with("datadir"),

View File

@ -56,7 +56,7 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
.value_name("SECRETS_DIR")
.help(
"The path where the validator keystore passwords will be stored. \
Defaults to ~/.lighthouse/{testnet}/secrets",
Defaults to ~/.lighthouse/{network}/secrets",
)
.takes_value(true),
)

View File

@ -16,7 +16,7 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
Arg::with_name(WALLETS_DIR_FLAG)
.long(WALLETS_DIR_FLAG)
.value_name("WALLETS_DIRECTORY")
.help("A path containing Eth2 EIP-2386 wallets. Defaults to ~/.lighthouse/{testnet}/wallets")
.help("A path containing Eth2 EIP-2386 wallets. Defaults to ~/.lighthouse/{network}/wallets")
.takes_value(true)
.conflicts_with("datadir"),
)

View File

@ -258,13 +258,7 @@ pub fn get_config<E: EthSpec>(
*/
let eth2_testnet_config = get_eth2_testnet_config(&cli_args)?;
client_config.eth1.deposit_contract_address =
format!("{:?}", eth2_testnet_config.deposit_contract_address()?);
let spec_contract_address = format!("{:?}", spec.deposit_contract_address);
if client_config.eth1.deposit_contract_address != spec_contract_address {
return Err("Testnet contract address does not match spec".into());
}
client_config.eth1.deposit_contract_address = format!("{:?}", spec.deposit_contract_address);
client_config.eth1.deposit_contract_deploy_block =
eth2_testnet_config.deposit_contract_deploy_block;
client_config.eth1.lowest_cached_block_number =
@ -274,6 +268,13 @@ pub fn get_config<E: EthSpec>(
client_config.eth1.chain_id = spec.deposit_chain_id.into();
client_config.eth1.set_block_cache_truncation::<E>(spec);
info!(
log,
"Deposit contract";
"deploy_block" => client_config.eth1.deposit_contract_deploy_block,
"address" => &client_config.eth1.deposit_contract_address
);
if let Some(mut boot_nodes) = eth2_testnet_config.boot_enr {
client_config.network.boot_nodes_enr.append(&mut boot_nodes)
}
@ -593,15 +594,17 @@ pub fn get_data_dir(cli_args: &ArgMatches) -> PathBuf {
.unwrap_or_else(|| PathBuf::from("."))
}
/// Try to parse the eth2 testnet config from the `testnet`, `testnet-dir` flags in that order.
/// Try to parse the eth2 testnet config from the `network`, `testnet-dir` flags in that order.
/// Returns the default hardcoded testnet if neither flags are set.
pub fn get_eth2_testnet_config(cli_args: &ArgMatches) -> Result<Eth2TestnetConfig, String> {
let optional_testnet_config = if cli_args.is_present("testnet") {
clap_utils::parse_hardcoded_network(cli_args, "testnet")?
let optional_testnet_config = if cli_args.is_present("network") {
clap_utils::parse_hardcoded_network(cli_args, "network")?
} else if cli_args.is_present("testnet-dir") {
clap_utils::parse_testnet_dir(cli_args, "testnet-dir")?
} else {
Eth2TestnetConfig::hard_coded_default()?
return Err(
"No --network or --testnet-dir flags provided, cannot load config.".to_string(),
);
};
optional_testnet_config.ok_or_else(|| BAD_TESTNET_DIR_MESSAGE.to_string())
}

View File

@ -22,7 +22,7 @@ The API token can be obtained via two methods:
### Method 1: Reading from a file
The API token is stored as a file in the `validators` directory. For most users
this is `~/.lighthouse/{testnet}/validators/api-token.txt`. Here's an
this is `~/.lighthouse/{network}/validators/api-token.txt`. Here's an
example using the `cat` command to print the token to the terminal, but any
text editor will suffice:

View File

@ -67,10 +67,10 @@ $ docker run lighthouse:local lighthouse --help
You can run a Docker beacon node with the following command:
```bash
$ docker run -p 9000:9000 -p 127.0.0.1:5052:5052 -v $HOME/.lighthouse:/root/.lighthouse sigp/lighthouse lighthouse --testnet medalla beacon --http --http-address 0.0.0.0
$ docker run -p 9000:9000 -p 127.0.0.1:5052:5052 -v $HOME/.lighthouse:/root/.lighthouse sigp/lighthouse lighthouse --network medalla beacon --http --http-address 0.0.0.0
```
> To join the altona testnet, use --testnet altona instead.
> To join the altona testnet, use --network altona instead.
> The `-p` and `-v` and values are described below.

View File

@ -42,12 +42,12 @@ keypairs. Creating a single validator looks like this:
- `lighthouse --testnet medalla account validator create --wallet-name wally --wallet-password wally.pass --count 1`
In step (1), we created a wallet in `~/.lighthouse/{testnet}/wallets` with the name
In step (1), we created a wallet in `~/.lighthouse/{network}/wallets` with the name
`wally`. We encrypted this using a pre-defined password in the
`wally.pass` file. Then, in step (2), we created one new validator in the
`~/.lighthouse/{testnet}/validators` directory using `wally` (unlocking it with
`~/.lighthouse/{network}/validators` directory using `wally` (unlocking it with
`wally.pass`) and storing the passwords to the validators voting key in
`~/.lighthouse/{testnet}/secrets`.
`~/.lighthouse/{network}/secrets`.
Thanks to the hierarchical key derivation scheme, we can delete all of the
aforementioned directories and then regenerate them as long as we remembered
@ -65,16 +65,16 @@ There are three important directories in Lighthouse validator key management:
- `wallets/`: contains encrypted wallets which are used for hierarchical
key derivation.
- Defaults to `~/.lighthouse/{testnet}/wallets`
- Defaults to `~/.lighthouse/{network}/wallets`
- `validators/`: contains a directory for each validator containing
encrypted keystores and other validator-specific data.
- Defaults to `~/.lighthouse/{testnet}/validators`
- Defaults to `~/.lighthouse/{network}/validators`
- `secrets/`: since the validator signing keys are "hot", the validator process
needs access to the passwords to decrypt the keystores in the validators
dir. These passwords are stored here.
- Defaults to `~/.lighthouse/{testnet}/secrets`
- Defaults to `~/.lighthouse/{network}/secrets`
where `testnet` is the name of the testnet passed in the `--testnet` parameter (default is `medalla`).
where `network` is the name of the network passed in the `--network` parameter (default is `medalla`).
When the validator client boots, it searches the `validators/` for directories
containing voting keystores. When it discovers a keystore, it searches the

View File

@ -50,9 +50,11 @@ cd lighthouse
make
```
Compiling Lighthouse can take up to an hour. The safety guarantees provided by
the Rust language unfortunately result in a lengthy compilation time on a
low-spec CPU like a Raspberry Pi.
>
> Compiling Lighthouse can take up to an hour. The safety guarantees provided by the Rust language
unfortunately result in a lengthy compilation time on a low-spec CPU like a Raspberry Pi. For faster
compilation on low-spec hardware, try [cross-compiling](./cross-compiling.md) on a more powerful
computer (e.g., compile for RasPi from your desktop computer).
Once installation has finished, confirm Lighthouse is installed by viewing the
usage instructions with `lighthouse --help`.

View File

@ -9,25 +9,26 @@ DEPOSITS WITH LIGHTHOUSE. 🚨🚨🚨**
## Supported Testnets
Lighthouse supports four testnets:
Lighthouse supports the "mainnet" network and four test networks:
- [Medalla](https://github.com/goerli/medalla/tree/master/medalla) (default)
- [Pyrmont](https://github.com/protolambda/pyrmont)
- [Spadina](https://github.com/goerli/medalla/tree/master/spadina) (deprecated)
- [Altona](https://github.com/goerli/medalla/tree/master/altona) (deprecated)
When using Lighthouse, the `--testnet` flag selects a testnet. E.g.,
When using Lighthouse, the `--network` flag selects a network. E.g.,
- `lighthouse` (no flag): Medalla.
- `lighthouse --testnet medalla`: Medalla.
- `lighthouse --testnet pyrmont`: Pyrmont.
- `lighthouse --network mainnet`: Mainnet.
- `lighthouse --network medalla`: Medalla.
- `lighthouse --network pyrmont`: Pyrmont.
Using the correct `--testnet` flag is very important; using the wrong flag can
Using the correct `--network` flag is very important; using the wrong flag can
result in penalties, slashings or lost deposits. As a rule of thumb, always
provide a `--testnet` flag instead of relying on the default.
provide a `--network` flag instead of relying on the default.
> Note: In these documents we use `--testnet MY_TESTNET` for demonstration. You
> must replace `MY_TESTNET` with a valid testnet name.
> Note: In these documents we use `--network MY_NETWORK` for demonstration. You
> must replace `MY_NETWORK` with a valid network name. E.g., `--network pyrmont`.
## Joining a Testnet
@ -112,14 +113,14 @@ Starting these processes is different for binary and docker users:
Those using the pre- or custom-built binaries can start the two processes with:
```bash
lighthouse --testnet MY_TESTNET bn --staking
lighthouse --network MY_NETWORK bn --staking
```
```bash
lighthouse --testnet MY_TESTNET vc
lighthouse --network MY_NETWORK vc
```
> Note: `~/.lighthouse/{testnet}` is the default directory which contains the keys and databases.
> Note: `~/.lighthouse/{network}` is the default directory which contains the keys and databases.
> To specify a custom dir, see [this](#custom-directories) section
#### Docker users
@ -130,7 +131,7 @@ Those using Docker images can start the processes with:
$ docker run \
--network host \
-v $HOME/.lighthouse:/root/.lighthouse sigp/lighthouse \
lighthouse --testnet MY_TESTNET bn --staking --http-address 0.0.0.0
lighthouse --network MY_NETWORK bn --staking --http-address 0.0.0.0
```
```bash
@ -138,7 +139,7 @@ $ docker run \
--network host \
-v $HOME/.lighthouse:/root/.lighthouse \
sigp/lighthouse \
lighthouse --testnet MY_TESTNET vc
lighthouse --network MY_NETWORK vc
```
### Step 6. Leave Lighthouse running
@ -171,16 +172,16 @@ Happy staking!
## Custom directories
Users can override the default Lighthouse data directories (`~/.lighthouse/{testnet}`) using the `--datadir` flag. The custom data directory mirrors the structure of any testnet specific default directory (e.g. `~/.lighthouse/medalla`).
Users can override the default Lighthouse data directories (`~/.lighthouse/{network}`) using the `--datadir` flag. The custom data directory mirrors the structure of any network specific default directory (e.g. `~/.lighthouse/medalla`).
> Note: Users should specify different custom directories for different testnets.
> Note: Users should specify different custom directories for different networks.
Below is an example flow for importing validator keys, running a beacon node and validator client using a custom data directory `/var/lib/my-custom-dir` for the medalla testnet.
```bash
lighthouse --testnet medalla --datadir /var/lib/my-custom-dir account validator import --directory <PATH-TO-LAUNCHPAD-KEYS-DIRECTORY>
lighthouse --testnet medalla --datadir /var/lib/my-custom-dir bn --staking
lighthouse --testnet medalla --datadir /var/lib/my-custom-dir vc
lighthouse --network medalla --datadir /var/lib/my-custom-dir account validator import --directory <PATH-TO-LAUNCHPAD-KEYS-DIRECTORY>
lighthouse --network medalla --datadir /var/lib/my-custom-dir bn --staking
lighthouse --network medalla --datadir /var/lib/my-custom-dir vc
```
The first step creates a `validators` directory under `/var/lib/my-custom-dir` which contains the imported keys and [`validator_definitions.yml`](./validator-management.md).
After that, we simply run the beacon chain and validator client with the custom dir path.

View File

@ -21,10 +21,11 @@ lighthouse account validator create --help
Creates new validators from an existing EIP-2386 wallet using the EIP-2333 HD key derivation scheme.
USAGE:
lighthouse account_manager validator create [FLAGS] [OPTIONS] --wallet-name <WALLET_NAME> --wallet-password <WALLET_PASSWORD_PATH>
lighthouse account_manager validator create [FLAGS] [OPTIONS]
FLAGS:
-h, --help Prints help information
--stdin-inputs If present, read all user inputs from stdin instead of tty.
--store-withdrawal-keystore If present, the withdrawal keystore will be stored alongside the voting keypair.
It is generally recommended to *not* store the withdrawal key and instead
generate them from the wallet seed when required.
@ -37,28 +38,34 @@ OPTIONS:
--count <VALIDATOR_COUNT>
The number of validators to create, regardless of how many already exist
-d, --datadir <DIR> Data directory for lighthouse keys and databases.
-d, --datadir <DIR>
Used to specify a custom root data directory for lighthouse keys and databases. Defaults to
$HOME/.lighthouse/{network} where network is the value of the `network` flag Note: Users should specify
separate custom datadirs for different networks.
--debug-level <LEVEL>
The verbosity level for emitting logs. [default: info] [possible values: info, debug, trace, warn, error,
crit]
--deposit-gwei <DEPOSIT_GWEI>
The GWEI value of the deposit amount. Defaults to the minimum amount required for an active validator
(MAX_EFFECTIVE_BALANCE)
--network <network>
Name of the Eth2 chain Lighthouse will sync and follow. [default: mainnet] [possible values: medalla,
altona, spadina, pyrmont, mainnet, toledo]
--secrets-dir <SECRETS_DIR>
The path where the validator keystore passwords will be stored. Defaults to ~/.lighthouse/{testnet}/secrets
--testnet <testnet>
Name of network lighthouse will connect to [possible values: medalla, altona]
The path where the validator keystore passwords will be stored. Defaults to ~/.lighthouse/{network}/secrets
-s, --spec <DEPRECATED>
This flag is deprecated, it will be disallowed in a future release. This value is now derived from the
--network or --testnet-dir flags.
-t, --testnet-dir <DIR>
Path to directory containing eth2_testnet specs. Defaults to a hard-coded Lighthouse testnet. Only effective
if there is no existing database.
--validator-dir <VALIDATOR_DIRECTORY>
The path where the validator directories will be created. Defaults to ~/.lighthouse/{testnet}/validators
--wallet-name <WALLET_NAME> Use the wallet identified by this name
--wallet-password <WALLET_PASSWORD_PATH>
A path to a file containing the password which will unlock the wallet.
--wallets-dir <wallets-dir>
A path containing Eth2 EIP-2386 wallets. Defaults to ~/.lighthouse/{network}/wallets
```
## Example
@ -67,19 +74,17 @@ The example assumes that the `wally` wallet was generated from the
[wallet](./wallet-create.md) example.
```bash
lighthouse --testnet medalla account validator create --name wally --wallet-password wally.pass --count 1
lighthouse --network medalla account validator create --name wally --wallet-password wally.pass --count 1
```
This command will:
- Derive a single new BLS keypair from wallet `wally` in `~/.lighthouse/{testnet}/wallets`, updating it so that it generates a
new key next time.
- Create a new directory in `~/.lighthouse/{testnet}/validators` containing:
- Create a new directory in `~/.lighthouse/{network}/validators` containing:
- An encrypted keystore containing the validators voting keypair.
- An `eth1_deposit_data.rlp` assuming the default deposit amount (`32 ETH`
for most testnets and mainnet) which can be submitted to the deposit
contract for the medalla testnet. Other testnets can be set via the
`--testnet` CLI param.
- Store a password to the validators voting keypair in `~/.lighthouse/{testnet}/secrets`.
where `testnet` is the name of the testnet passed in the `--testnet` parameter (default is `medalla`).
contract for the Medalla testnet. Other testnets can be set via the
`--network` CLI param.
- Store a password to the validators voting keypair in `~/.lighthouse/{network}/secrets`.

View File

@ -35,7 +35,7 @@ section, all other users can use:
```bash
lighthouse --testnet medalla account validator import --directory validator_keys
lighthouse --network medalla account validator import --directory validator_keys
```
Note: The user must specify the testnet that they are importing the keys for using the `--testnet` flag.
@ -101,7 +101,7 @@ docker run -it \
-v $HOME/.lighthouse:/root/.lighthouse \
-v $(pwd)/validator_keys:/root/validator_keys \
sigp/lighthouse \
lighthouse --testnet medalla account validator import --directory /root/validator_keys
lighthouse --network MY_NETWORK account validator import --directory /root/validator_keys
```
Here we use two `-v` volumes to attach:

View File

@ -16,7 +16,7 @@ useful.
## Introducing the `validator_definitions.yml` file
The `validator_definitions.yml` file is located in the `validator-dir`, which
defaults to `~/.lighthouse/{testnet}/validators`. It is a
defaults to `~/.lighthouse/{network}/validators`. It is a
[YAML](https://en.wikipedia.org/wiki/YAML) encoded file defining exactly which
validators the validator client will (and won't) act for.
@ -92,7 +92,7 @@ name identical to the `voting_public_key` value.
Lets assume the following directory structure:
```
~/.lighthouse/{testnet}/validators
~/.lighthouse/{network}/validators
├── john
│   └── voting-keystore.json
├── sally
@ -135,7 +135,7 @@ In order for the validator client to decrypt the validators, they will need to
ensure their `secrets-dir` is organised as below:
```
~/.lighthouse/{testnet}/secrets
~/.lighthouse/{network}/secrets
├── 0xa5566f9ec3c6e1fdf362634ebec9ef7aceb0e460e5079714808388e5d48f4ae1e12897fed1bea951c17fa389d511e477
├── 0xaa440c566fcf34dedf233baf56cf5fb05bb420d9663b4208272545608c27c13d5b08174518c758ecd814f158f2b4a337
└── 0x87a580d31d7bc69069b55f5a01995a610dd391a26dc9e36e81057a17211983a79266800ab8531f21f1083d7d84085007

View File

@ -30,7 +30,7 @@ impl<T: EthSpec> TryFrom<&ArgMatches<'_>> for BootNodeConfig<T> {
// Try and grab testnet config from input CLI params
let eth2_testnet_config = {
if matches.is_present("testnet") {
if matches.is_present("network") {
Some(get_eth2_testnet_config(&matches)?)
} else {
None

View File

@ -14,13 +14,13 @@ pub const DEFAULT_WALLET_DIR: &str = "wallets";
/// Base directory name for unnamed testnets passed through the --testnet-dir flag
pub const CUSTOM_TESTNET_DIR: &str = "custom";
/// Gets the testnet directory name
/// Gets the network directory name
///
/// Tries to get the name first from the "testnet" flag,
/// Tries to get the name first from the "network" flag,
/// if not present, then checks the "testnet-dir" flag and returns a custom name
/// If neither flags are present, returns the default hardcoded network name.
pub fn get_testnet_name(matches: &ArgMatches) -> String {
if let Some(testnet_name) = matches.value_of("testnet") {
if let Some(testnet_name) = matches.value_of("network") {
testnet_name.to_string()
} else if matches.value_of("testnet-dir").is_some() {
CUSTOM_TESTNET_DIR.to_string()

View File

@ -1 +0,0 @@
0x16e82D77882A663454Ef92806b7DeCa1D394810f

View File

@ -1 +0,0 @@
0x00000000219ab540356cBB839Cbe05303d7705Fa

View File

@ -1 +0,0 @@
0x07b39F4fDE4A38bACe212b546dAc87C58DfE3fDC

View File

@ -1 +0,0 @@
0x8c5fecdC472E27Bc447696F431E425D02dd46a8c

View File

@ -1 +0,0 @@
0x48B597F4b53C21B48AD95c7256B49D1779Bd5890

View File

@ -1 +0,0 @@
0x47709dC7a8c18688a1f051761fc34ac253970bC0

View File

@ -14,7 +14,7 @@ use ssz::Decode;
use std::fs::{create_dir_all, File};
use std::io::{Read, Write};
use std::path::PathBuf;
use types::{Address, BeaconState, EthSpec, EthSpecId, YamlConfig};
use types::{BeaconState, EthSpec, EthSpecId, YamlConfig};
pub const ADDRESS_FILE: &str = "deposit_contract.txt";
pub const DEPLOY_BLOCK_FILE: &str = "deploy_block.txt";
@ -29,7 +29,6 @@ pub struct HardcodedNet {
pub yaml_config: &'static [u8],
pub deploy_block: &'static [u8],
pub boot_enr: &'static [u8],
pub deposit_contract_address: &'static [u8],
pub genesis_state_bytes: &'static [u8],
}
@ -43,7 +42,6 @@ macro_rules! define_net {
yaml_config: $include_file!("../", "config.yaml"),
deploy_block: $include_file!("../", "deploy_block.txt"),
boot_enr: $include_file!("../", "boot_enr.yaml"),
deposit_contract_address: $include_file!("../", "deposit_contract.txt"),
genesis_state_bytes: $include_file!("../", "genesis.ssz"),
}
}};
@ -57,14 +55,13 @@ const MAINNET: HardcodedNet = define_net!(mainnet, include_mainnet_file);
const TOLEDO: HardcodedNet = define_net!(toledo, include_toledo_file);
const HARDCODED_NETS: &[HardcodedNet] = &[ALTONA, MEDALLA, SPADINA, PYRMONT, MAINNET, TOLEDO];
pub const DEFAULT_HARDCODED_TESTNET: &str = "medalla";
pub const DEFAULT_HARDCODED_TESTNET: &str = "mainnet";
/// Specifies an Eth2 testnet.
///
/// See the crate-level documentation for more details.
#[derive(Clone, PartialEq, Debug)]
pub struct Eth2TestnetConfig {
pub deposit_contract_address: String,
/// Note: instead of the block where the contract is deployed, it is acceptable to set this
/// value to be the block number where the first deposit occurs.
pub deposit_contract_deploy_block: u64,
@ -74,10 +71,6 @@ pub struct Eth2TestnetConfig {
}
impl Eth2TestnetConfig {
/// Returns the default hard coded testnet.
pub fn hard_coded_default() -> Result<Option<Self>, String> {
Self::constant(DEFAULT_HARDCODED_TESTNET)
}
/// When Lighthouse is built it includes zero or more "hardcoded" network specifications. This
/// function allows for instantiating one of these nets by name.
pub fn constant(name: &str) -> Result<Option<Self>, String> {
@ -91,8 +84,6 @@ impl Eth2TestnetConfig {
/// Instantiates `Self` from a `HardcodedNet`.
fn from_hardcoded_net(net: &HardcodedNet) -> Result<Self, String> {
Ok(Self {
deposit_contract_address: serde_yaml::from_reader(net.deposit_contract_address)
.map_err(|e| format!("Unable to parse contract address: {:?}", e))?,
deposit_contract_deploy_block: serde_yaml::from_reader(net.deploy_block)
.map_err(|e| format!("Unable to parse deploy block: {:?}", e))?,
boot_enr: Some(
@ -177,7 +168,6 @@ impl Eth2TestnetConfig {
};
}
write_to_yaml_file!(ADDRESS_FILE, self.deposit_contract_address);
write_to_yaml_file!(DEPLOY_BLOCK_FILE, self.deposit_contract_deploy_block);
if let Some(boot_enr) = &self.boot_enr {
@ -225,7 +215,6 @@ impl Eth2TestnetConfig {
};
}
let deposit_contract_address = load_from_file!(ADDRESS_FILE);
let deposit_contract_deploy_block = load_from_file!(DEPLOY_BLOCK_FILE);
let boot_enr = optional_load_from_file!(BOOT_ENR_FILE);
let yaml_config = optional_load_from_file!(YAML_CONFIG_FILE);
@ -247,23 +236,12 @@ impl Eth2TestnetConfig {
};
Ok(Self {
deposit_contract_address,
deposit_contract_deploy_block,
boot_enr,
genesis_state_bytes,
yaml_config,
})
}
pub fn deposit_contract_address(&self) -> Result<Address, String> {
if self.deposit_contract_address.starts_with("0x") {
self.deposit_contract_address[2..]
.parse()
.map_err(|e| format!("Corrupted address, unable to parse: {:?}", e))
} else {
Err("Corrupted address, must start with 0x".to_string())
}
}
}
#[cfg(test)]
@ -334,11 +312,9 @@ mod tests {
) {
let temp_dir = TempDir::new("eth2_testnet_test").expect("should create temp dir");
let base_dir = temp_dir.path().join("my_testnet");
let deposit_contract_address = "0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413".to_string();
let deposit_contract_deploy_block = 42;
let testnet: Eth2TestnetConfig = Eth2TestnetConfig {
deposit_contract_address,
deposit_contract_deploy_block,
boot_enr,
genesis_state_bytes: genesis_state.as_ref().map(Encode::as_ssz_bytes),

View File

@ -41,7 +41,7 @@ pub fn run<T: EthSpec>(mut env: Environment<T>, matches: &ArgMatches<'_>) -> Res
let mut config = Eth1Config::default();
config.endpoint = endpoint.to_string();
config.deposit_contract_address = eth2_testnet_config.deposit_contract_address.clone();
config.deposit_contract_address = format!("{:?}", spec.deposit_contract_address);
config.deposit_contract_deploy_block = eth2_testnet_config.deposit_contract_deploy_block;
config.lowest_cached_block_number = eth2_testnet_config.deposit_contract_deploy_block;
config.follow_distance = spec.eth1_follow_distance / 2;

View File

@ -35,6 +35,8 @@ pub fn run<T: EthSpec>(matches: &ArgMatches) -> Result<(), String> {
};
}
spec.deposit_contract_address = deposit_contract_address;
maybe_update!("min-genesis-time", min_genesis_time);
maybe_update!("min-deposit-amount", min_deposit_amount);
maybe_update!(
@ -52,7 +54,6 @@ pub fn run<T: EthSpec>(matches: &ArgMatches) -> Result<(), String> {
}
let testnet = Eth2TestnetConfig {
deposit_contract_address: format!("{:?}", deposit_contract_address),
deposit_contract_deploy_block,
boot_enr: Some(vec![]),
genesis_state_bytes: None,

View File

@ -1,7 +1,7 @@
#![cfg(test)]
use environment::EnvironmentBuilder;
use eth2_testnet_config::Eth2TestnetConfig;
use eth2_testnet_config::{Eth2TestnetConfig, DEFAULT_HARDCODED_TESTNET};
use std::path::PathBuf;
use types::{V012LegacyEthSpec, YamlConfig};
@ -14,7 +14,7 @@ fn builder() -> EnvironmentBuilder<V012LegacyEthSpec> {
}
fn eth2_testnet_config() -> Option<Eth2TestnetConfig> {
Eth2TestnetConfig::hard_coded_default().expect("should decode hard_coded params")
Eth2TestnetConfig::constant(DEFAULT_HARDCODED_TESTNET).expect("should decode mainnet params")
}
mod setup_eth2_config {

View File

@ -47,7 +47,7 @@ fn main() {
.long("spec")
.value_name("DEPRECATED")
.help("This flag is deprecated, it will be disallowed in a future release. This \
value is now derived from the --testnet or --testnet-dir flags.")
value is now derived from the --network or --testnet-dir flags.")
.takes_value(true)
.global(true)
)
@ -93,8 +93,8 @@ fn main() {
.global(true)
.help(
"Used to specify a custom root data directory for lighthouse keys and databases. \
Defaults to $HOME/.lighthouse/{testnet} where testnet is the value of the `testnet` flag \
Note: Users should specify separate custom datadirs for different testnets.")
Defaults to $HOME/.lighthouse/{network} where network is the value of the `network` flag \
Note: Users should specify separate custom datadirs for different networks.")
.takes_value(true),
)
.arg(
@ -111,12 +111,13 @@ fn main() {
.global(true),
)
.arg(
Arg::with_name("testnet")
.long("testnet")
.value_name("testnet")
.help("Name of network lighthouse will connect to")
Arg::with_name("network")
.long("network")
.value_name("network")
.help("Name of the Eth2 chain Lighthouse will sync and follow.")
.possible_values(&["medalla", "altona", "spadina", "pyrmont", "mainnet", "toledo"])
.conflicts_with("testnet-dir")
.default_value(DEFAULT_HARDCODED_TESTNET)
.takes_value(true)
.global(true)
@ -176,12 +177,11 @@ fn load_testnet_config(matches: &ArgMatches) -> Result<Eth2TestnetConfig, String
if matches.is_present("testnet-dir") {
clap_utils::parse_testnet_dir(matches, "testnet-dir")?
.ok_or_else(|| "Unable to load testnet dir".to_string())
} else if matches.is_present("testnet") {
clap_utils::parse_hardcoded_network(matches, "testnet")?
} else if matches.is_present("network") {
clap_utils::parse_hardcoded_network(matches, "network")?
.ok_or_else(|| "Unable to load hard coded network config".to_string())
} else {
Eth2TestnetConfig::hard_coded_default()?
.ok_or_else(|| "Unable to load default network config".to_string())
Err("No --network or --testnet-dir flags provided, cannot start.".to_string())
}
}
@ -192,7 +192,7 @@ fn run<E: EthSpec>(
) -> Result<(), String> {
if std::mem::size_of::<usize>() != 8 {
return Err(format!(
"{}bit architecture is not supported (64bit only).",
"{}-bit architecture is not supported (64-bit only).",
std::mem::size_of::<usize>() * 8
));
}
@ -244,18 +244,18 @@ fn run<E: EthSpec>(
// Creating a command which can run both might be useful future works.
// Print an indication of which network is currently in use.
let optional_testnet = clap_utils::parse_optional::<String>(matches, "testnet")?;
let optional_testnet = clap_utils::parse_optional::<String>(matches, "network")?;
let optional_testnet_dir = clap_utils::parse_optional::<PathBuf>(matches, "testnet-dir")?;
let testnet_name = match (optional_testnet, optional_testnet_dir) {
(Some(testnet), None) => testnet,
(None, Some(testnet_dir)) => format!("custom ({})", testnet_dir.display()),
(None, None) => DEFAULT_HARDCODED_TESTNET.to_string(),
(Some(_), Some(_)) => panic!("CLI prevents both --testnet and --testnet-dir"),
(Some(_), Some(_)) => panic!("CLI prevents both --network and --testnet-dir"),
};
if let Some(sub_matches) = matches.subcommand_matches("account_manager") {
eprintln!("Running account manager for {} testnet", testnet_name);
eprintln!("Running account manager for {} network", testnet_name);
// Pass the entire `environment` to the account manager so it can run blocking operations.
account_manager::run(sub_matches, environment)?;

View File

@ -47,7 +47,7 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
"The directory which contains the password to unlock the validator \
voting keypairs. Each password should be contained in a file where the \
name is the 0x-prefixed hex representation of the validators voting public \
key. Defaults to ~/.lighthouse/{testnet}/secrets.",
key. Defaults to ~/.lighthouse/{network}/secrets.",
)
.takes_value(true)
.conflicts_with("datadir")

View File

@ -188,13 +188,13 @@ impl<T: EthSpec> ProductionValidatorClient<T> {
let beacon_node_spec = yaml_config.apply_to_chain_spec::<T>(&T::default_spec())
.ok_or_else(||
"The minimal/mainnet spec type of the beacon node does not match the validator client. \
See the --testnet command.".to_string()
See the --network command.".to_string()
)?;
if context.eth2_config.spec != beacon_node_spec {
return Err(
"The beacon node is using a different Eth2 specification to this validator client. \
See the --testnet command."
See the --network command."
.to_string(),
);
}