2019-08-23 06:39:32 +00:00
|
|
|
use clap::ArgMatches;
|
2021-11-16 00:46:12 +00:00
|
|
|
use clap_utils::flags::DISABLE_MALLOC_TUNING_FLAG;
|
2020-09-29 00:02:44 +00:00
|
|
|
use client::{ClientConfig, ClientGenesis};
|
|
|
|
use directory::{DEFAULT_BEACON_NODE_DIR, DEFAULT_NETWORK_DIR, DEFAULT_ROOT_DIR};
|
2021-11-16 00:46:12 +00:00
|
|
|
use environment::RuntimeContext;
|
2022-06-29 09:07:09 +00:00
|
|
|
use genesis::Eth1Endpoint;
|
2021-10-12 03:35:49 +00:00
|
|
|
use http_api::TlsConfig;
|
Rename eth2_libp2p to lighthouse_network (#2702)
## Description
The `eth2_libp2p` crate was originally named and designed to incorporate a simple libp2p integration into lighthouse. Since its origins the crates purpose has expanded dramatically. It now houses a lot more sophistication that is specific to lighthouse and no longer just a libp2p integration.
As of this writing it currently houses the following high-level lighthouse-specific logic:
- Lighthouse's implementation of the eth2 RPC protocol and specific encodings/decodings
- Integration and handling of ENRs with respect to libp2p and eth2
- Lighthouse's discovery logic, its integration with discv5 and logic about searching and handling peers.
- Lighthouse's peer manager - This is a large module handling various aspects of Lighthouse's network, such as peer scoring, handling pings and metadata, connection maintenance and recording, etc.
- Lighthouse's peer database - This is a collection of information stored for each individual peer which is specific to lighthouse. We store connection state, sync state, last seen ips and scores etc. The data stored for each peer is designed for various elements of the lighthouse code base such as syncing and the http api.
- Gossipsub scoring - This stores a collection of gossipsub 1.1 scoring mechanisms that are continuously analyssed and updated based on the ethereum 2 networks and how Lighthouse performs on these networks.
- Lighthouse specific types for managing gossipsub topics, sync status and ENR fields
- Lighthouse's network HTTP API metrics - A collection of metrics for lighthouse network monitoring
- Lighthouse's custom configuration of all networking protocols, RPC, gossipsub, discovery, identify and libp2p.
Therefore it makes sense to rename the crate to be more akin to its current purposes, simply that it manages the majority of Lighthouse's network stack. This PR renames this crate to `lighthouse_network`
Co-authored-by: Paul Hauner <paul@paulhauner.com>
2021-10-19 00:30:39 +00:00
|
|
|
use lighthouse_network::{multiaddr::Protocol, Enr, Multiaddr, NetworkConfig, PeerIdSerialized};
|
2021-05-04 01:59:51 +00:00
|
|
|
use sensitive_url::SensitiveUrl;
|
2020-10-28 22:19:38 +00:00
|
|
|
use slog::{info, warn, Logger};
|
2020-08-04 07:44:53 +00:00
|
|
|
use std::cmp;
|
2020-11-27 08:37:44 +00:00
|
|
|
use std::cmp::max;
|
2022-06-29 09:07:09 +00:00
|
|
|
use std::fmt::Debug;
|
2022-06-30 22:51:49 +00:00
|
|
|
use std::fmt::Write;
|
2019-08-23 06:39:32 +00:00
|
|
|
use std::fs;
|
2020-05-03 13:18:19 +00:00
|
|
|
use std::net::{IpAddr, Ipv4Addr, ToSocketAddrs};
|
2021-03-26 04:53:57 +00:00
|
|
|
use std::path::{Path, PathBuf};
|
2021-01-20 19:19:38 +00:00
|
|
|
use std::str::FromStr;
|
2022-02-08 19:52:20 +00:00
|
|
|
use types::{Checkpoint, Epoch, EthSpec, Hash256, PublicKeyBytes, GRAFFITI_BYTES_LEN};
|
2022-02-17 21:47:06 +00:00
|
|
|
use unused_port::{unused_tcp_port, unused_udp_port};
|
2019-08-23 06:39:32 +00:00
|
|
|
|
2020-04-02 07:47:00 +00:00
|
|
|
/// Gets the fully-initialized global client.
|
2019-08-31 02:34:27 +00:00
|
|
|
///
|
2019-12-09 07:50:21 +00:00
|
|
|
/// The top-level `clap` arguments should be provided as `cli_args`.
|
2019-08-31 02:34:27 +00:00
|
|
|
///
|
|
|
|
/// The output of this function depends primarily upon the given `cli_args`, however it's behaviour
|
|
|
|
/// may be influenced by other external services like the contents of the file system or the
|
|
|
|
/// response of some remote server.
|
2020-04-02 07:47:00 +00:00
|
|
|
pub fn get_config<E: EthSpec>(
|
Prepare for public testnet (#628)
* Update to spec v0.9.0
* Update to v0.9.1
* Bump spec tags for v0.9.1
* Formatting, fix CI failures
* Resolve accidental KeyPair merge conflict
* Document new BeaconState functions
* Add `validator` changes from `validator-to-rest`
* Add initial (failing) REST api tests
* Fix signature parsing
* Add more tests
* Refactor http router
* Add working tests for publish beacon block
* Add validator duties tests
* Move account_manager under `lighthouse` binary
* Unify logfile handling in `environment` crate.
* Fix incorrect cache drops in `advance_caches`
* Update fork choice for v0.9.1
* Add `deposit_contract` crate
* Add progress on validator onboarding
* Add unfinished attesation code
* Update account manager CLI
* Write eth1 data file as hex string
* Integrate ValidatorDirectory with validator_client
* Move ValidatorDirectory into validator_client
* Clean up some FIXMEs
* Add beacon_chain_sim
* Fix a few docs/logs
* Expand `beacon_chain_sim`
* Fix spec for `beacon_chain_sim
* More testing for api
* Start work on attestation endpoint
* Reject empty attestations
* Allow attestations to genesis block
* Add working tests for `rest_api` validator endpoint
* Remove grpc from beacon_node
* Start heavy refactor of validator client
- Block production is working
* Prune old validator client files
* Start works on attestation service
* Add attestation service to validator client
* Use full pubkey for validator directories
* Add validator duties post endpoint
* Use par_iter for keypair generation
* Use bulk duties request in validator client
* Add version http endpoint tests
* Add interop keys and startup wait
* Ensure a prompt exit
* Add duties pruning
* Fix compile error in beacon node tests
* Add github workflow
* Modify rust.yaml
* Modify gitlab actions
* Add to CI file
* Add sudo to CI npm install
* Move cargo fmt to own job in tests
* Fix cargo fmt in CI
* Add rustup update before cargo fmt
* Change name of CI job
* Make other CI jobs require cargo fmt
* Add CI badge
* Remove gitlab and travis files
* Add different http timeout for debug
* Update docker file, use makefile in CI
* Use make in the dockerfile, skip the test
* Use the makefile for debug GI test
* Update book
* Tidy grpc and misc things
* Apply discv5 fixes
* Address other minor issues
* Fix warnings
* Attempt fix for addr parsing
* Tidy validator config, CLIs
* Tidy comments
* Tidy signing, reduce ForkService duplication
* Fail if skipping too many slots
* Set default recent genesis time to 0
* Add custom http timeout to validator
* Fix compile bug in node_test_rig
* Remove old bootstrap flag from val CLI
* Update docs
* Tidy val client
* Change val client log levels
* Add comments, more validity checks
* Fix compile error, add comments
* Undo changes to eth2-libp2p/src
* Reduce duplication of keypair generation
* Add more logging for validator duties
* Fix beacon_chain_sim, nitpicks
* Fix compile error, minor nits
* Update to use v0.9.2 version of deposit contract
* Add efforts to automate eth1 testnet deployment
* Fix lcli testnet deployer
* Modify bn CLI to parse eth2_testnet_dir
* Progress with account_manager deposit tools
* Make account manager submit deposits
* Add password option for submitting deposits
* Allow custom deposit amount
* Add long names to lcli clap
* Add password option to lcli deploy command
* Fix minor bugs whilst testing
* Address Michael's comments
* Add refund-deposit-contract to lcli
* Use time instead of skip count for denying long skips
* Improve logging for eth1
* Fix bug with validator services exiting on error
* Drop the block cache after genesis
* Modify eth1 testnet config
* Improve eth1 logging
* Make validator wait until genesis time
* Fix bug in eth1 voting
* Add more logging to eth1 voting
* Handle errors in eth1 http module
* Set SECONDS_PER_DAY to sensible minimum
* Shorten delay before testnet start
* Ensure eth1 block is produced without any votes
* Improve eth1 logging
* Fix broken tests in eth1
* Tidy code in rest_api
* Fix failing test in deposit_contract
* Make CLI args more consistent
* Change validator/duties endpoint
* Add time-based skip slot limiting
* Add new error type missed in previous commit
* Add log when waiting for genesis
* Refactor beacon node CLI
* Remove unused dep
* Add lcli eth1-genesis command
* Fix bug in master merge
* Apply clippy lints to beacon node
* Add support for YamlConfig in Eth2TestnetDir
* Upgrade tesnet deposit contract version
* Remove unnecessary logging and correct formatting
* Add a hardcoded eth2 testnet config
* Ensure http server flag works. Overwrite configs with flags.
* Ensure boot nodes are loaded from testnet dir
* Fix account manager CLI bugs
* Fix bugs with beacon node cli
* Allow testnet dir without boot nodes
* Write genesis state as SSZ
* Remove ---/n from the start of testnet_dir files
* Set default libp2p address
* Tidy account manager CLI, add logging
* Add check to see if testnet dir exists
* Apply reviewers suggestions
* Add HeadTracker struct
* Add fork choice persistence
* Shorten slot time for simulator
* Add the /beacon/heads API endpoint
* Update hardcoded testnet
* Add tests for BeaconChain persistence + fix bugs
* Extend BeaconChain persistence testing
* Ensure chain is finalized b4 persistence tests
* Ensure boot_enr.yaml is include in binary
* Refactor beacon_chain_sim
* Move files about in beacon sim
* Update beacon_chain_sim
* Fix bug with deposit inclusion
* Increase log in genesis service, fix todo
* Tidy sim, fix broken rest_api tests
* Fix more broken tests
* Update testnet
* Fix broken rest api test
* Tidy account manager CLI
* Use tempdir for account manager
* Stop hardcoded testnet dir from creating dir
* Rename Eth2TestnetDir to Eth2TestnetConfig
* Change hardcoded -> hard_coded
* Tidy account manager
* Add log to account manager
* Tidy, ensure head tracker is loaded from disk
* Tidy beacon chain builder
* Tidy eth1_chain
* Adds log support for simulator
* Revert "Adds log support for simulator"
This reverts commit ec77c66a052350f551db145cf20f213823428dd3.
* Adds log support for simulator
* Tidy after self-review
* Change default log level
* Address Michael's delicious PR comments
* Fix off-by-one in tests
2019-12-03 04:28:57 +00:00
|
|
|
cli_args: &ArgMatches,
|
2021-11-16 00:46:12 +00:00
|
|
|
context: &RuntimeContext<E>,
|
2020-04-09 15:13:44 +00:00
|
|
|
) -> Result<ClientConfig, String> {
|
2021-11-16 00:46:12 +00:00
|
|
|
let spec = &context.eth2_config.spec;
|
|
|
|
let log = context.log();
|
|
|
|
|
2021-01-19 00:34:28 +00:00
|
|
|
let mut client_config = ClientConfig {
|
|
|
|
data_dir: get_data_dir(cli_args),
|
|
|
|
..Default::default()
|
|
|
|
};
|
Prepare for public testnet (#628)
* Update to spec v0.9.0
* Update to v0.9.1
* Bump spec tags for v0.9.1
* Formatting, fix CI failures
* Resolve accidental KeyPair merge conflict
* Document new BeaconState functions
* Add `validator` changes from `validator-to-rest`
* Add initial (failing) REST api tests
* Fix signature parsing
* Add more tests
* Refactor http router
* Add working tests for publish beacon block
* Add validator duties tests
* Move account_manager under `lighthouse` binary
* Unify logfile handling in `environment` crate.
* Fix incorrect cache drops in `advance_caches`
* Update fork choice for v0.9.1
* Add `deposit_contract` crate
* Add progress on validator onboarding
* Add unfinished attesation code
* Update account manager CLI
* Write eth1 data file as hex string
* Integrate ValidatorDirectory with validator_client
* Move ValidatorDirectory into validator_client
* Clean up some FIXMEs
* Add beacon_chain_sim
* Fix a few docs/logs
* Expand `beacon_chain_sim`
* Fix spec for `beacon_chain_sim
* More testing for api
* Start work on attestation endpoint
* Reject empty attestations
* Allow attestations to genesis block
* Add working tests for `rest_api` validator endpoint
* Remove grpc from beacon_node
* Start heavy refactor of validator client
- Block production is working
* Prune old validator client files
* Start works on attestation service
* Add attestation service to validator client
* Use full pubkey for validator directories
* Add validator duties post endpoint
* Use par_iter for keypair generation
* Use bulk duties request in validator client
* Add version http endpoint tests
* Add interop keys and startup wait
* Ensure a prompt exit
* Add duties pruning
* Fix compile error in beacon node tests
* Add github workflow
* Modify rust.yaml
* Modify gitlab actions
* Add to CI file
* Add sudo to CI npm install
* Move cargo fmt to own job in tests
* Fix cargo fmt in CI
* Add rustup update before cargo fmt
* Change name of CI job
* Make other CI jobs require cargo fmt
* Add CI badge
* Remove gitlab and travis files
* Add different http timeout for debug
* Update docker file, use makefile in CI
* Use make in the dockerfile, skip the test
* Use the makefile for debug GI test
* Update book
* Tidy grpc and misc things
* Apply discv5 fixes
* Address other minor issues
* Fix warnings
* Attempt fix for addr parsing
* Tidy validator config, CLIs
* Tidy comments
* Tidy signing, reduce ForkService duplication
* Fail if skipping too many slots
* Set default recent genesis time to 0
* Add custom http timeout to validator
* Fix compile bug in node_test_rig
* Remove old bootstrap flag from val CLI
* Update docs
* Tidy val client
* Change val client log levels
* Add comments, more validity checks
* Fix compile error, add comments
* Undo changes to eth2-libp2p/src
* Reduce duplication of keypair generation
* Add more logging for validator duties
* Fix beacon_chain_sim, nitpicks
* Fix compile error, minor nits
* Update to use v0.9.2 version of deposit contract
* Add efforts to automate eth1 testnet deployment
* Fix lcli testnet deployer
* Modify bn CLI to parse eth2_testnet_dir
* Progress with account_manager deposit tools
* Make account manager submit deposits
* Add password option for submitting deposits
* Allow custom deposit amount
* Add long names to lcli clap
* Add password option to lcli deploy command
* Fix minor bugs whilst testing
* Address Michael's comments
* Add refund-deposit-contract to lcli
* Use time instead of skip count for denying long skips
* Improve logging for eth1
* Fix bug with validator services exiting on error
* Drop the block cache after genesis
* Modify eth1 testnet config
* Improve eth1 logging
* Make validator wait until genesis time
* Fix bug in eth1 voting
* Add more logging to eth1 voting
* Handle errors in eth1 http module
* Set SECONDS_PER_DAY to sensible minimum
* Shorten delay before testnet start
* Ensure eth1 block is produced without any votes
* Improve eth1 logging
* Fix broken tests in eth1
* Tidy code in rest_api
* Fix failing test in deposit_contract
* Make CLI args more consistent
* Change validator/duties endpoint
* Add time-based skip slot limiting
* Add new error type missed in previous commit
* Add log when waiting for genesis
* Refactor beacon node CLI
* Remove unused dep
* Add lcli eth1-genesis command
* Fix bug in master merge
* Apply clippy lints to beacon node
* Add support for YamlConfig in Eth2TestnetDir
* Upgrade tesnet deposit contract version
* Remove unnecessary logging and correct formatting
* Add a hardcoded eth2 testnet config
* Ensure http server flag works. Overwrite configs with flags.
* Ensure boot nodes are loaded from testnet dir
* Fix account manager CLI bugs
* Fix bugs with beacon node cli
* Allow testnet dir without boot nodes
* Write genesis state as SSZ
* Remove ---/n from the start of testnet_dir files
* Set default libp2p address
* Tidy account manager CLI, add logging
* Add check to see if testnet dir exists
* Apply reviewers suggestions
* Add HeadTracker struct
* Add fork choice persistence
* Shorten slot time for simulator
* Add the /beacon/heads API endpoint
* Update hardcoded testnet
* Add tests for BeaconChain persistence + fix bugs
* Extend BeaconChain persistence testing
* Ensure chain is finalized b4 persistence tests
* Ensure boot_enr.yaml is include in binary
* Refactor beacon_chain_sim
* Move files about in beacon sim
* Update beacon_chain_sim
* Fix bug with deposit inclusion
* Increase log in genesis service, fix todo
* Tidy sim, fix broken rest_api tests
* Fix more broken tests
* Update testnet
* Fix broken rest api test
* Tidy account manager CLI
* Use tempdir for account manager
* Stop hardcoded testnet dir from creating dir
* Rename Eth2TestnetDir to Eth2TestnetConfig
* Change hardcoded -> hard_coded
* Tidy account manager
* Add log to account manager
* Tidy, ensure head tracker is loaded from disk
* Tidy beacon chain builder
* Tidy eth1_chain
* Adds log support for simulator
* Revert "Adds log support for simulator"
This reverts commit ec77c66a052350f551db145cf20f213823428dd3.
* Adds log support for simulator
* Tidy after self-review
* Change default log level
* Address Michael's delicious PR comments
* Fix off-by-one in tests
2019-12-03 04:28:57 +00:00
|
|
|
|
2020-04-17 07:49:29 +00:00
|
|
|
// If necessary, remove any existing database and configuration
|
|
|
|
if client_config.data_dir.exists() && cli_args.is_present("purge-db") {
|
|
|
|
// Remove the chain_db.
|
2021-11-29 22:32:53 +00:00
|
|
|
let chain_db = client_config.get_db_path();
|
|
|
|
if chain_db.exists() {
|
|
|
|
fs::remove_dir_all(chain_db)
|
|
|
|
.map_err(|err| format!("Failed to remove chain_db: {}", err))?;
|
|
|
|
}
|
2020-04-17 07:49:29 +00:00
|
|
|
|
|
|
|
// Remove the freezer db.
|
2021-11-29 22:32:53 +00:00
|
|
|
let freezer_db = client_config.get_freezer_db_path();
|
|
|
|
if freezer_db.exists() {
|
|
|
|
fs::remove_dir_all(freezer_db)
|
|
|
|
.map_err(|err| format!("Failed to remove freezer_db: {}", err))?;
|
|
|
|
}
|
2020-04-17 07:49:29 +00:00
|
|
|
}
|
|
|
|
|
2020-04-09 15:13:44 +00:00
|
|
|
// Create `datadir` and any non-existing parent directories.
|
|
|
|
fs::create_dir_all(&client_config.data_dir)
|
|
|
|
.map_err(|e| format!("Failed to create data dir: {}", e))?;
|
|
|
|
|
2020-04-14 05:29:29 +00:00
|
|
|
// logs the chosen data directory
|
|
|
|
let mut log_dir = client_config.data_dir.clone();
|
|
|
|
// remove /beacon from the end
|
|
|
|
log_dir.pop();
|
2020-07-23 14:18:00 +00:00
|
|
|
info!(log, "Data directory initialised"; "datadir" => log_dir.into_os_string().into_string().expect("Datadir should be a valid os string"));
|
2020-04-14 05:29:29 +00:00
|
|
|
|
Prepare for public testnet (#628)
* Update to spec v0.9.0
* Update to v0.9.1
* Bump spec tags for v0.9.1
* Formatting, fix CI failures
* Resolve accidental KeyPair merge conflict
* Document new BeaconState functions
* Add `validator` changes from `validator-to-rest`
* Add initial (failing) REST api tests
* Fix signature parsing
* Add more tests
* Refactor http router
* Add working tests for publish beacon block
* Add validator duties tests
* Move account_manager under `lighthouse` binary
* Unify logfile handling in `environment` crate.
* Fix incorrect cache drops in `advance_caches`
* Update fork choice for v0.9.1
* Add `deposit_contract` crate
* Add progress on validator onboarding
* Add unfinished attesation code
* Update account manager CLI
* Write eth1 data file as hex string
* Integrate ValidatorDirectory with validator_client
* Move ValidatorDirectory into validator_client
* Clean up some FIXMEs
* Add beacon_chain_sim
* Fix a few docs/logs
* Expand `beacon_chain_sim`
* Fix spec for `beacon_chain_sim
* More testing for api
* Start work on attestation endpoint
* Reject empty attestations
* Allow attestations to genesis block
* Add working tests for `rest_api` validator endpoint
* Remove grpc from beacon_node
* Start heavy refactor of validator client
- Block production is working
* Prune old validator client files
* Start works on attestation service
* Add attestation service to validator client
* Use full pubkey for validator directories
* Add validator duties post endpoint
* Use par_iter for keypair generation
* Use bulk duties request in validator client
* Add version http endpoint tests
* Add interop keys and startup wait
* Ensure a prompt exit
* Add duties pruning
* Fix compile error in beacon node tests
* Add github workflow
* Modify rust.yaml
* Modify gitlab actions
* Add to CI file
* Add sudo to CI npm install
* Move cargo fmt to own job in tests
* Fix cargo fmt in CI
* Add rustup update before cargo fmt
* Change name of CI job
* Make other CI jobs require cargo fmt
* Add CI badge
* Remove gitlab and travis files
* Add different http timeout for debug
* Update docker file, use makefile in CI
* Use make in the dockerfile, skip the test
* Use the makefile for debug GI test
* Update book
* Tidy grpc and misc things
* Apply discv5 fixes
* Address other minor issues
* Fix warnings
* Attempt fix for addr parsing
* Tidy validator config, CLIs
* Tidy comments
* Tidy signing, reduce ForkService duplication
* Fail if skipping too many slots
* Set default recent genesis time to 0
* Add custom http timeout to validator
* Fix compile bug in node_test_rig
* Remove old bootstrap flag from val CLI
* Update docs
* Tidy val client
* Change val client log levels
* Add comments, more validity checks
* Fix compile error, add comments
* Undo changes to eth2-libp2p/src
* Reduce duplication of keypair generation
* Add more logging for validator duties
* Fix beacon_chain_sim, nitpicks
* Fix compile error, minor nits
* Update to use v0.9.2 version of deposit contract
* Add efforts to automate eth1 testnet deployment
* Fix lcli testnet deployer
* Modify bn CLI to parse eth2_testnet_dir
* Progress with account_manager deposit tools
* Make account manager submit deposits
* Add password option for submitting deposits
* Allow custom deposit amount
* Add long names to lcli clap
* Add password option to lcli deploy command
* Fix minor bugs whilst testing
* Address Michael's comments
* Add refund-deposit-contract to lcli
* Use time instead of skip count for denying long skips
* Improve logging for eth1
* Fix bug with validator services exiting on error
* Drop the block cache after genesis
* Modify eth1 testnet config
* Improve eth1 logging
* Make validator wait until genesis time
* Fix bug in eth1 voting
* Add more logging to eth1 voting
* Handle errors in eth1 http module
* Set SECONDS_PER_DAY to sensible minimum
* Shorten delay before testnet start
* Ensure eth1 block is produced without any votes
* Improve eth1 logging
* Fix broken tests in eth1
* Tidy code in rest_api
* Fix failing test in deposit_contract
* Make CLI args more consistent
* Change validator/duties endpoint
* Add time-based skip slot limiting
* Add new error type missed in previous commit
* Add log when waiting for genesis
* Refactor beacon node CLI
* Remove unused dep
* Add lcli eth1-genesis command
* Fix bug in master merge
* Apply clippy lints to beacon node
* Add support for YamlConfig in Eth2TestnetDir
* Upgrade tesnet deposit contract version
* Remove unnecessary logging and correct formatting
* Add a hardcoded eth2 testnet config
* Ensure http server flag works. Overwrite configs with flags.
* Ensure boot nodes are loaded from testnet dir
* Fix account manager CLI bugs
* Fix bugs with beacon node cli
* Allow testnet dir without boot nodes
* Write genesis state as SSZ
* Remove ---/n from the start of testnet_dir files
* Set default libp2p address
* Tidy account manager CLI, add logging
* Add check to see if testnet dir exists
* Apply reviewers suggestions
* Add HeadTracker struct
* Add fork choice persistence
* Shorten slot time for simulator
* Add the /beacon/heads API endpoint
* Update hardcoded testnet
* Add tests for BeaconChain persistence + fix bugs
* Extend BeaconChain persistence testing
* Ensure chain is finalized b4 persistence tests
* Ensure boot_enr.yaml is include in binary
* Refactor beacon_chain_sim
* Move files about in beacon sim
* Update beacon_chain_sim
* Fix bug with deposit inclusion
* Increase log in genesis service, fix todo
* Tidy sim, fix broken rest_api tests
* Fix more broken tests
* Update testnet
* Fix broken rest api test
* Tidy account manager CLI
* Use tempdir for account manager
* Stop hardcoded testnet dir from creating dir
* Rename Eth2TestnetDir to Eth2TestnetConfig
* Change hardcoded -> hard_coded
* Tidy account manager
* Add log to account manager
* Tidy, ensure head tracker is loaded from disk
* Tidy beacon chain builder
* Tidy eth1_chain
* Adds log support for simulator
* Revert "Adds log support for simulator"
This reverts commit ec77c66a052350f551db145cf20f213823428dd3.
* Adds log support for simulator
* Tidy after self-review
* Change default log level
* Address Michael's delicious PR comments
* Fix off-by-one in tests
2019-12-03 04:28:57 +00:00
|
|
|
/*
|
|
|
|
* Networking
|
|
|
|
*/
|
2020-08-21 12:00:01 +00:00
|
|
|
set_network_config(
|
|
|
|
&mut client_config.network,
|
|
|
|
cli_args,
|
|
|
|
&client_config.data_dir,
|
2021-11-16 00:46:12 +00:00
|
|
|
log,
|
2020-08-21 12:00:01 +00:00
|
|
|
false,
|
|
|
|
)?;
|
2020-06-23 03:45:40 +00:00
|
|
|
|
2020-09-23 01:19:58 +00:00
|
|
|
/*
|
|
|
|
* Staking flag
|
|
|
|
* Note: the config values set here can be overwritten by other more specific cli params
|
|
|
|
*/
|
|
|
|
|
|
|
|
if cli_args.is_present("staking") {
|
2020-09-29 03:46:54 +00:00
|
|
|
client_config.http_api.enabled = true;
|
2020-09-23 01:19:58 +00:00
|
|
|
client_config.sync_eth1_chain = true;
|
|
|
|
}
|
|
|
|
|
Prepare for public testnet (#628)
* Update to spec v0.9.0
* Update to v0.9.1
* Bump spec tags for v0.9.1
* Formatting, fix CI failures
* Resolve accidental KeyPair merge conflict
* Document new BeaconState functions
* Add `validator` changes from `validator-to-rest`
* Add initial (failing) REST api tests
* Fix signature parsing
* Add more tests
* Refactor http router
* Add working tests for publish beacon block
* Add validator duties tests
* Move account_manager under `lighthouse` binary
* Unify logfile handling in `environment` crate.
* Fix incorrect cache drops in `advance_caches`
* Update fork choice for v0.9.1
* Add `deposit_contract` crate
* Add progress on validator onboarding
* Add unfinished attesation code
* Update account manager CLI
* Write eth1 data file as hex string
* Integrate ValidatorDirectory with validator_client
* Move ValidatorDirectory into validator_client
* Clean up some FIXMEs
* Add beacon_chain_sim
* Fix a few docs/logs
* Expand `beacon_chain_sim`
* Fix spec for `beacon_chain_sim
* More testing for api
* Start work on attestation endpoint
* Reject empty attestations
* Allow attestations to genesis block
* Add working tests for `rest_api` validator endpoint
* Remove grpc from beacon_node
* Start heavy refactor of validator client
- Block production is working
* Prune old validator client files
* Start works on attestation service
* Add attestation service to validator client
* Use full pubkey for validator directories
* Add validator duties post endpoint
* Use par_iter for keypair generation
* Use bulk duties request in validator client
* Add version http endpoint tests
* Add interop keys and startup wait
* Ensure a prompt exit
* Add duties pruning
* Fix compile error in beacon node tests
* Add github workflow
* Modify rust.yaml
* Modify gitlab actions
* Add to CI file
* Add sudo to CI npm install
* Move cargo fmt to own job in tests
* Fix cargo fmt in CI
* Add rustup update before cargo fmt
* Change name of CI job
* Make other CI jobs require cargo fmt
* Add CI badge
* Remove gitlab and travis files
* Add different http timeout for debug
* Update docker file, use makefile in CI
* Use make in the dockerfile, skip the test
* Use the makefile for debug GI test
* Update book
* Tidy grpc and misc things
* Apply discv5 fixes
* Address other minor issues
* Fix warnings
* Attempt fix for addr parsing
* Tidy validator config, CLIs
* Tidy comments
* Tidy signing, reduce ForkService duplication
* Fail if skipping too many slots
* Set default recent genesis time to 0
* Add custom http timeout to validator
* Fix compile bug in node_test_rig
* Remove old bootstrap flag from val CLI
* Update docs
* Tidy val client
* Change val client log levels
* Add comments, more validity checks
* Fix compile error, add comments
* Undo changes to eth2-libp2p/src
* Reduce duplication of keypair generation
* Add more logging for validator duties
* Fix beacon_chain_sim, nitpicks
* Fix compile error, minor nits
* Update to use v0.9.2 version of deposit contract
* Add efforts to automate eth1 testnet deployment
* Fix lcli testnet deployer
* Modify bn CLI to parse eth2_testnet_dir
* Progress with account_manager deposit tools
* Make account manager submit deposits
* Add password option for submitting deposits
* Allow custom deposit amount
* Add long names to lcli clap
* Add password option to lcli deploy command
* Fix minor bugs whilst testing
* Address Michael's comments
* Add refund-deposit-contract to lcli
* Use time instead of skip count for denying long skips
* Improve logging for eth1
* Fix bug with validator services exiting on error
* Drop the block cache after genesis
* Modify eth1 testnet config
* Improve eth1 logging
* Make validator wait until genesis time
* Fix bug in eth1 voting
* Add more logging to eth1 voting
* Handle errors in eth1 http module
* Set SECONDS_PER_DAY to sensible minimum
* Shorten delay before testnet start
* Ensure eth1 block is produced without any votes
* Improve eth1 logging
* Fix broken tests in eth1
* Tidy code in rest_api
* Fix failing test in deposit_contract
* Make CLI args more consistent
* Change validator/duties endpoint
* Add time-based skip slot limiting
* Add new error type missed in previous commit
* Add log when waiting for genesis
* Refactor beacon node CLI
* Remove unused dep
* Add lcli eth1-genesis command
* Fix bug in master merge
* Apply clippy lints to beacon node
* Add support for YamlConfig in Eth2TestnetDir
* Upgrade tesnet deposit contract version
* Remove unnecessary logging and correct formatting
* Add a hardcoded eth2 testnet config
* Ensure http server flag works. Overwrite configs with flags.
* Ensure boot nodes are loaded from testnet dir
* Fix account manager CLI bugs
* Fix bugs with beacon node cli
* Allow testnet dir without boot nodes
* Write genesis state as SSZ
* Remove ---/n from the start of testnet_dir files
* Set default libp2p address
* Tidy account manager CLI, add logging
* Add check to see if testnet dir exists
* Apply reviewers suggestions
* Add HeadTracker struct
* Add fork choice persistence
* Shorten slot time for simulator
* Add the /beacon/heads API endpoint
* Update hardcoded testnet
* Add tests for BeaconChain persistence + fix bugs
* Extend BeaconChain persistence testing
* Ensure chain is finalized b4 persistence tests
* Ensure boot_enr.yaml is include in binary
* Refactor beacon_chain_sim
* Move files about in beacon sim
* Update beacon_chain_sim
* Fix bug with deposit inclusion
* Increase log in genesis service, fix todo
* Tidy sim, fix broken rest_api tests
* Fix more broken tests
* Update testnet
* Fix broken rest api test
* Tidy account manager CLI
* Use tempdir for account manager
* Stop hardcoded testnet dir from creating dir
* Rename Eth2TestnetDir to Eth2TestnetConfig
* Change hardcoded -> hard_coded
* Tidy account manager
* Add log to account manager
* Tidy, ensure head tracker is loaded from disk
* Tidy beacon chain builder
* Tidy eth1_chain
* Adds log support for simulator
* Revert "Adds log support for simulator"
This reverts commit ec77c66a052350f551db145cf20f213823428dd3.
* Adds log support for simulator
* Tidy after self-review
* Change default log level
* Address Michael's delicious PR comments
* Fix off-by-one in tests
2019-12-03 04:28:57 +00:00
|
|
|
/*
|
2020-09-29 03:46:54 +00:00
|
|
|
* Http API server
|
Prepare for public testnet (#628)
* Update to spec v0.9.0
* Update to v0.9.1
* Bump spec tags for v0.9.1
* Formatting, fix CI failures
* Resolve accidental KeyPair merge conflict
* Document new BeaconState functions
* Add `validator` changes from `validator-to-rest`
* Add initial (failing) REST api tests
* Fix signature parsing
* Add more tests
* Refactor http router
* Add working tests for publish beacon block
* Add validator duties tests
* Move account_manager under `lighthouse` binary
* Unify logfile handling in `environment` crate.
* Fix incorrect cache drops in `advance_caches`
* Update fork choice for v0.9.1
* Add `deposit_contract` crate
* Add progress on validator onboarding
* Add unfinished attesation code
* Update account manager CLI
* Write eth1 data file as hex string
* Integrate ValidatorDirectory with validator_client
* Move ValidatorDirectory into validator_client
* Clean up some FIXMEs
* Add beacon_chain_sim
* Fix a few docs/logs
* Expand `beacon_chain_sim`
* Fix spec for `beacon_chain_sim
* More testing for api
* Start work on attestation endpoint
* Reject empty attestations
* Allow attestations to genesis block
* Add working tests for `rest_api` validator endpoint
* Remove grpc from beacon_node
* Start heavy refactor of validator client
- Block production is working
* Prune old validator client files
* Start works on attestation service
* Add attestation service to validator client
* Use full pubkey for validator directories
* Add validator duties post endpoint
* Use par_iter for keypair generation
* Use bulk duties request in validator client
* Add version http endpoint tests
* Add interop keys and startup wait
* Ensure a prompt exit
* Add duties pruning
* Fix compile error in beacon node tests
* Add github workflow
* Modify rust.yaml
* Modify gitlab actions
* Add to CI file
* Add sudo to CI npm install
* Move cargo fmt to own job in tests
* Fix cargo fmt in CI
* Add rustup update before cargo fmt
* Change name of CI job
* Make other CI jobs require cargo fmt
* Add CI badge
* Remove gitlab and travis files
* Add different http timeout for debug
* Update docker file, use makefile in CI
* Use make in the dockerfile, skip the test
* Use the makefile for debug GI test
* Update book
* Tidy grpc and misc things
* Apply discv5 fixes
* Address other minor issues
* Fix warnings
* Attempt fix for addr parsing
* Tidy validator config, CLIs
* Tidy comments
* Tidy signing, reduce ForkService duplication
* Fail if skipping too many slots
* Set default recent genesis time to 0
* Add custom http timeout to validator
* Fix compile bug in node_test_rig
* Remove old bootstrap flag from val CLI
* Update docs
* Tidy val client
* Change val client log levels
* Add comments, more validity checks
* Fix compile error, add comments
* Undo changes to eth2-libp2p/src
* Reduce duplication of keypair generation
* Add more logging for validator duties
* Fix beacon_chain_sim, nitpicks
* Fix compile error, minor nits
* Update to use v0.9.2 version of deposit contract
* Add efforts to automate eth1 testnet deployment
* Fix lcli testnet deployer
* Modify bn CLI to parse eth2_testnet_dir
* Progress with account_manager deposit tools
* Make account manager submit deposits
* Add password option for submitting deposits
* Allow custom deposit amount
* Add long names to lcli clap
* Add password option to lcli deploy command
* Fix minor bugs whilst testing
* Address Michael's comments
* Add refund-deposit-contract to lcli
* Use time instead of skip count for denying long skips
* Improve logging for eth1
* Fix bug with validator services exiting on error
* Drop the block cache after genesis
* Modify eth1 testnet config
* Improve eth1 logging
* Make validator wait until genesis time
* Fix bug in eth1 voting
* Add more logging to eth1 voting
* Handle errors in eth1 http module
* Set SECONDS_PER_DAY to sensible minimum
* Shorten delay before testnet start
* Ensure eth1 block is produced without any votes
* Improve eth1 logging
* Fix broken tests in eth1
* Tidy code in rest_api
* Fix failing test in deposit_contract
* Make CLI args more consistent
* Change validator/duties endpoint
* Add time-based skip slot limiting
* Add new error type missed in previous commit
* Add log when waiting for genesis
* Refactor beacon node CLI
* Remove unused dep
* Add lcli eth1-genesis command
* Fix bug in master merge
* Apply clippy lints to beacon node
* Add support for YamlConfig in Eth2TestnetDir
* Upgrade tesnet deposit contract version
* Remove unnecessary logging and correct formatting
* Add a hardcoded eth2 testnet config
* Ensure http server flag works. Overwrite configs with flags.
* Ensure boot nodes are loaded from testnet dir
* Fix account manager CLI bugs
* Fix bugs with beacon node cli
* Allow testnet dir without boot nodes
* Write genesis state as SSZ
* Remove ---/n from the start of testnet_dir files
* Set default libp2p address
* Tidy account manager CLI, add logging
* Add check to see if testnet dir exists
* Apply reviewers suggestions
* Add HeadTracker struct
* Add fork choice persistence
* Shorten slot time for simulator
* Add the /beacon/heads API endpoint
* Update hardcoded testnet
* Add tests for BeaconChain persistence + fix bugs
* Extend BeaconChain persistence testing
* Ensure chain is finalized b4 persistence tests
* Ensure boot_enr.yaml is include in binary
* Refactor beacon_chain_sim
* Move files about in beacon sim
* Update beacon_chain_sim
* Fix bug with deposit inclusion
* Increase log in genesis service, fix todo
* Tidy sim, fix broken rest_api tests
* Fix more broken tests
* Update testnet
* Fix broken rest api test
* Tidy account manager CLI
* Use tempdir for account manager
* Stop hardcoded testnet dir from creating dir
* Rename Eth2TestnetDir to Eth2TestnetConfig
* Change hardcoded -> hard_coded
* Tidy account manager
* Add log to account manager
* Tidy, ensure head tracker is loaded from disk
* Tidy beacon chain builder
* Tidy eth1_chain
* Adds log support for simulator
* Revert "Adds log support for simulator"
This reverts commit ec77c66a052350f551db145cf20f213823428dd3.
* Adds log support for simulator
* Tidy after self-review
* Change default log level
* Address Michael's delicious PR comments
* Fix off-by-one in tests
2019-12-03 04:28:57 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
if cli_args.is_present("http") {
|
2020-09-29 03:46:54 +00:00
|
|
|
client_config.http_api.enabled = true;
|
Prepare for public testnet (#628)
* Update to spec v0.9.0
* Update to v0.9.1
* Bump spec tags for v0.9.1
* Formatting, fix CI failures
* Resolve accidental KeyPair merge conflict
* Document new BeaconState functions
* Add `validator` changes from `validator-to-rest`
* Add initial (failing) REST api tests
* Fix signature parsing
* Add more tests
* Refactor http router
* Add working tests for publish beacon block
* Add validator duties tests
* Move account_manager under `lighthouse` binary
* Unify logfile handling in `environment` crate.
* Fix incorrect cache drops in `advance_caches`
* Update fork choice for v0.9.1
* Add `deposit_contract` crate
* Add progress on validator onboarding
* Add unfinished attesation code
* Update account manager CLI
* Write eth1 data file as hex string
* Integrate ValidatorDirectory with validator_client
* Move ValidatorDirectory into validator_client
* Clean up some FIXMEs
* Add beacon_chain_sim
* Fix a few docs/logs
* Expand `beacon_chain_sim`
* Fix spec for `beacon_chain_sim
* More testing for api
* Start work on attestation endpoint
* Reject empty attestations
* Allow attestations to genesis block
* Add working tests for `rest_api` validator endpoint
* Remove grpc from beacon_node
* Start heavy refactor of validator client
- Block production is working
* Prune old validator client files
* Start works on attestation service
* Add attestation service to validator client
* Use full pubkey for validator directories
* Add validator duties post endpoint
* Use par_iter for keypair generation
* Use bulk duties request in validator client
* Add version http endpoint tests
* Add interop keys and startup wait
* Ensure a prompt exit
* Add duties pruning
* Fix compile error in beacon node tests
* Add github workflow
* Modify rust.yaml
* Modify gitlab actions
* Add to CI file
* Add sudo to CI npm install
* Move cargo fmt to own job in tests
* Fix cargo fmt in CI
* Add rustup update before cargo fmt
* Change name of CI job
* Make other CI jobs require cargo fmt
* Add CI badge
* Remove gitlab and travis files
* Add different http timeout for debug
* Update docker file, use makefile in CI
* Use make in the dockerfile, skip the test
* Use the makefile for debug GI test
* Update book
* Tidy grpc and misc things
* Apply discv5 fixes
* Address other minor issues
* Fix warnings
* Attempt fix for addr parsing
* Tidy validator config, CLIs
* Tidy comments
* Tidy signing, reduce ForkService duplication
* Fail if skipping too many slots
* Set default recent genesis time to 0
* Add custom http timeout to validator
* Fix compile bug in node_test_rig
* Remove old bootstrap flag from val CLI
* Update docs
* Tidy val client
* Change val client log levels
* Add comments, more validity checks
* Fix compile error, add comments
* Undo changes to eth2-libp2p/src
* Reduce duplication of keypair generation
* Add more logging for validator duties
* Fix beacon_chain_sim, nitpicks
* Fix compile error, minor nits
* Update to use v0.9.2 version of deposit contract
* Add efforts to automate eth1 testnet deployment
* Fix lcli testnet deployer
* Modify bn CLI to parse eth2_testnet_dir
* Progress with account_manager deposit tools
* Make account manager submit deposits
* Add password option for submitting deposits
* Allow custom deposit amount
* Add long names to lcli clap
* Add password option to lcli deploy command
* Fix minor bugs whilst testing
* Address Michael's comments
* Add refund-deposit-contract to lcli
* Use time instead of skip count for denying long skips
* Improve logging for eth1
* Fix bug with validator services exiting on error
* Drop the block cache after genesis
* Modify eth1 testnet config
* Improve eth1 logging
* Make validator wait until genesis time
* Fix bug in eth1 voting
* Add more logging to eth1 voting
* Handle errors in eth1 http module
* Set SECONDS_PER_DAY to sensible minimum
* Shorten delay before testnet start
* Ensure eth1 block is produced without any votes
* Improve eth1 logging
* Fix broken tests in eth1
* Tidy code in rest_api
* Fix failing test in deposit_contract
* Make CLI args more consistent
* Change validator/duties endpoint
* Add time-based skip slot limiting
* Add new error type missed in previous commit
* Add log when waiting for genesis
* Refactor beacon node CLI
* Remove unused dep
* Add lcli eth1-genesis command
* Fix bug in master merge
* Apply clippy lints to beacon node
* Add support for YamlConfig in Eth2TestnetDir
* Upgrade tesnet deposit contract version
* Remove unnecessary logging and correct formatting
* Add a hardcoded eth2 testnet config
* Ensure http server flag works. Overwrite configs with flags.
* Ensure boot nodes are loaded from testnet dir
* Fix account manager CLI bugs
* Fix bugs with beacon node cli
* Allow testnet dir without boot nodes
* Write genesis state as SSZ
* Remove ---/n from the start of testnet_dir files
* Set default libp2p address
* Tidy account manager CLI, add logging
* Add check to see if testnet dir exists
* Apply reviewers suggestions
* Add HeadTracker struct
* Add fork choice persistence
* Shorten slot time for simulator
* Add the /beacon/heads API endpoint
* Update hardcoded testnet
* Add tests for BeaconChain persistence + fix bugs
* Extend BeaconChain persistence testing
* Ensure chain is finalized b4 persistence tests
* Ensure boot_enr.yaml is include in binary
* Refactor beacon_chain_sim
* Move files about in beacon sim
* Update beacon_chain_sim
* Fix bug with deposit inclusion
* Increase log in genesis service, fix todo
* Tidy sim, fix broken rest_api tests
* Fix more broken tests
* Update testnet
* Fix broken rest api test
* Tidy account manager CLI
* Use tempdir for account manager
* Stop hardcoded testnet dir from creating dir
* Rename Eth2TestnetDir to Eth2TestnetConfig
* Change hardcoded -> hard_coded
* Tidy account manager
* Add log to account manager
* Tidy, ensure head tracker is loaded from disk
* Tidy beacon chain builder
* Tidy eth1_chain
* Adds log support for simulator
* Revert "Adds log support for simulator"
This reverts commit ec77c66a052350f551db145cf20f213823428dd3.
* Adds log support for simulator
* Tidy after self-review
* Change default log level
* Address Michael's delicious PR comments
* Fix off-by-one in tests
2019-12-03 04:28:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if let Some(address) = cli_args.value_of("http-address") {
|
2020-09-29 03:46:54 +00:00
|
|
|
client_config.http_api.listen_addr = address
|
2022-03-24 00:04:49 +00:00
|
|
|
.parse::<IpAddr>()
|
|
|
|
.map_err(|_| "http-address is not a valid IP address.")?;
|
Prepare for public testnet (#628)
* Update to spec v0.9.0
* Update to v0.9.1
* Bump spec tags for v0.9.1
* Formatting, fix CI failures
* Resolve accidental KeyPair merge conflict
* Document new BeaconState functions
* Add `validator` changes from `validator-to-rest`
* Add initial (failing) REST api tests
* Fix signature parsing
* Add more tests
* Refactor http router
* Add working tests for publish beacon block
* Add validator duties tests
* Move account_manager under `lighthouse` binary
* Unify logfile handling in `environment` crate.
* Fix incorrect cache drops in `advance_caches`
* Update fork choice for v0.9.1
* Add `deposit_contract` crate
* Add progress on validator onboarding
* Add unfinished attesation code
* Update account manager CLI
* Write eth1 data file as hex string
* Integrate ValidatorDirectory with validator_client
* Move ValidatorDirectory into validator_client
* Clean up some FIXMEs
* Add beacon_chain_sim
* Fix a few docs/logs
* Expand `beacon_chain_sim`
* Fix spec for `beacon_chain_sim
* More testing for api
* Start work on attestation endpoint
* Reject empty attestations
* Allow attestations to genesis block
* Add working tests for `rest_api` validator endpoint
* Remove grpc from beacon_node
* Start heavy refactor of validator client
- Block production is working
* Prune old validator client files
* Start works on attestation service
* Add attestation service to validator client
* Use full pubkey for validator directories
* Add validator duties post endpoint
* Use par_iter for keypair generation
* Use bulk duties request in validator client
* Add version http endpoint tests
* Add interop keys and startup wait
* Ensure a prompt exit
* Add duties pruning
* Fix compile error in beacon node tests
* Add github workflow
* Modify rust.yaml
* Modify gitlab actions
* Add to CI file
* Add sudo to CI npm install
* Move cargo fmt to own job in tests
* Fix cargo fmt in CI
* Add rustup update before cargo fmt
* Change name of CI job
* Make other CI jobs require cargo fmt
* Add CI badge
* Remove gitlab and travis files
* Add different http timeout for debug
* Update docker file, use makefile in CI
* Use make in the dockerfile, skip the test
* Use the makefile for debug GI test
* Update book
* Tidy grpc and misc things
* Apply discv5 fixes
* Address other minor issues
* Fix warnings
* Attempt fix for addr parsing
* Tidy validator config, CLIs
* Tidy comments
* Tidy signing, reduce ForkService duplication
* Fail if skipping too many slots
* Set default recent genesis time to 0
* Add custom http timeout to validator
* Fix compile bug in node_test_rig
* Remove old bootstrap flag from val CLI
* Update docs
* Tidy val client
* Change val client log levels
* Add comments, more validity checks
* Fix compile error, add comments
* Undo changes to eth2-libp2p/src
* Reduce duplication of keypair generation
* Add more logging for validator duties
* Fix beacon_chain_sim, nitpicks
* Fix compile error, minor nits
* Update to use v0.9.2 version of deposit contract
* Add efforts to automate eth1 testnet deployment
* Fix lcli testnet deployer
* Modify bn CLI to parse eth2_testnet_dir
* Progress with account_manager deposit tools
* Make account manager submit deposits
* Add password option for submitting deposits
* Allow custom deposit amount
* Add long names to lcli clap
* Add password option to lcli deploy command
* Fix minor bugs whilst testing
* Address Michael's comments
* Add refund-deposit-contract to lcli
* Use time instead of skip count for denying long skips
* Improve logging for eth1
* Fix bug with validator services exiting on error
* Drop the block cache after genesis
* Modify eth1 testnet config
* Improve eth1 logging
* Make validator wait until genesis time
* Fix bug in eth1 voting
* Add more logging to eth1 voting
* Handle errors in eth1 http module
* Set SECONDS_PER_DAY to sensible minimum
* Shorten delay before testnet start
* Ensure eth1 block is produced without any votes
* Improve eth1 logging
* Fix broken tests in eth1
* Tidy code in rest_api
* Fix failing test in deposit_contract
* Make CLI args more consistent
* Change validator/duties endpoint
* Add time-based skip slot limiting
* Add new error type missed in previous commit
* Add log when waiting for genesis
* Refactor beacon node CLI
* Remove unused dep
* Add lcli eth1-genesis command
* Fix bug in master merge
* Apply clippy lints to beacon node
* Add support for YamlConfig in Eth2TestnetDir
* Upgrade tesnet deposit contract version
* Remove unnecessary logging and correct formatting
* Add a hardcoded eth2 testnet config
* Ensure http server flag works. Overwrite configs with flags.
* Ensure boot nodes are loaded from testnet dir
* Fix account manager CLI bugs
* Fix bugs with beacon node cli
* Allow testnet dir without boot nodes
* Write genesis state as SSZ
* Remove ---/n from the start of testnet_dir files
* Set default libp2p address
* Tidy account manager CLI, add logging
* Add check to see if testnet dir exists
* Apply reviewers suggestions
* Add HeadTracker struct
* Add fork choice persistence
* Shorten slot time for simulator
* Add the /beacon/heads API endpoint
* Update hardcoded testnet
* Add tests for BeaconChain persistence + fix bugs
* Extend BeaconChain persistence testing
* Ensure chain is finalized b4 persistence tests
* Ensure boot_enr.yaml is include in binary
* Refactor beacon_chain_sim
* Move files about in beacon sim
* Update beacon_chain_sim
* Fix bug with deposit inclusion
* Increase log in genesis service, fix todo
* Tidy sim, fix broken rest_api tests
* Fix more broken tests
* Update testnet
* Fix broken rest api test
* Tidy account manager CLI
* Use tempdir for account manager
* Stop hardcoded testnet dir from creating dir
* Rename Eth2TestnetDir to Eth2TestnetConfig
* Change hardcoded -> hard_coded
* Tidy account manager
* Add log to account manager
* Tidy, ensure head tracker is loaded from disk
* Tidy beacon chain builder
* Tidy eth1_chain
* Adds log support for simulator
* Revert "Adds log support for simulator"
This reverts commit ec77c66a052350f551db145cf20f213823428dd3.
* Adds log support for simulator
* Tidy after self-review
* Change default log level
* Address Michael's delicious PR comments
* Fix off-by-one in tests
2019-12-03 04:28:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if let Some(port) = cli_args.value_of("http-port") {
|
2020-09-29 03:46:54 +00:00
|
|
|
client_config.http_api.listen_port = port
|
Prepare for public testnet (#628)
* Update to spec v0.9.0
* Update to v0.9.1
* Bump spec tags for v0.9.1
* Formatting, fix CI failures
* Resolve accidental KeyPair merge conflict
* Document new BeaconState functions
* Add `validator` changes from `validator-to-rest`
* Add initial (failing) REST api tests
* Fix signature parsing
* Add more tests
* Refactor http router
* Add working tests for publish beacon block
* Add validator duties tests
* Move account_manager under `lighthouse` binary
* Unify logfile handling in `environment` crate.
* Fix incorrect cache drops in `advance_caches`
* Update fork choice for v0.9.1
* Add `deposit_contract` crate
* Add progress on validator onboarding
* Add unfinished attesation code
* Update account manager CLI
* Write eth1 data file as hex string
* Integrate ValidatorDirectory with validator_client
* Move ValidatorDirectory into validator_client
* Clean up some FIXMEs
* Add beacon_chain_sim
* Fix a few docs/logs
* Expand `beacon_chain_sim`
* Fix spec for `beacon_chain_sim
* More testing for api
* Start work on attestation endpoint
* Reject empty attestations
* Allow attestations to genesis block
* Add working tests for `rest_api` validator endpoint
* Remove grpc from beacon_node
* Start heavy refactor of validator client
- Block production is working
* Prune old validator client files
* Start works on attestation service
* Add attestation service to validator client
* Use full pubkey for validator directories
* Add validator duties post endpoint
* Use par_iter for keypair generation
* Use bulk duties request in validator client
* Add version http endpoint tests
* Add interop keys and startup wait
* Ensure a prompt exit
* Add duties pruning
* Fix compile error in beacon node tests
* Add github workflow
* Modify rust.yaml
* Modify gitlab actions
* Add to CI file
* Add sudo to CI npm install
* Move cargo fmt to own job in tests
* Fix cargo fmt in CI
* Add rustup update before cargo fmt
* Change name of CI job
* Make other CI jobs require cargo fmt
* Add CI badge
* Remove gitlab and travis files
* Add different http timeout for debug
* Update docker file, use makefile in CI
* Use make in the dockerfile, skip the test
* Use the makefile for debug GI test
* Update book
* Tidy grpc and misc things
* Apply discv5 fixes
* Address other minor issues
* Fix warnings
* Attempt fix for addr parsing
* Tidy validator config, CLIs
* Tidy comments
* Tidy signing, reduce ForkService duplication
* Fail if skipping too many slots
* Set default recent genesis time to 0
* Add custom http timeout to validator
* Fix compile bug in node_test_rig
* Remove old bootstrap flag from val CLI
* Update docs
* Tidy val client
* Change val client log levels
* Add comments, more validity checks
* Fix compile error, add comments
* Undo changes to eth2-libp2p/src
* Reduce duplication of keypair generation
* Add more logging for validator duties
* Fix beacon_chain_sim, nitpicks
* Fix compile error, minor nits
* Update to use v0.9.2 version of deposit contract
* Add efforts to automate eth1 testnet deployment
* Fix lcli testnet deployer
* Modify bn CLI to parse eth2_testnet_dir
* Progress with account_manager deposit tools
* Make account manager submit deposits
* Add password option for submitting deposits
* Allow custom deposit amount
* Add long names to lcli clap
* Add password option to lcli deploy command
* Fix minor bugs whilst testing
* Address Michael's comments
* Add refund-deposit-contract to lcli
* Use time instead of skip count for denying long skips
* Improve logging for eth1
* Fix bug with validator services exiting on error
* Drop the block cache after genesis
* Modify eth1 testnet config
* Improve eth1 logging
* Make validator wait until genesis time
* Fix bug in eth1 voting
* Add more logging to eth1 voting
* Handle errors in eth1 http module
* Set SECONDS_PER_DAY to sensible minimum
* Shorten delay before testnet start
* Ensure eth1 block is produced without any votes
* Improve eth1 logging
* Fix broken tests in eth1
* Tidy code in rest_api
* Fix failing test in deposit_contract
* Make CLI args more consistent
* Change validator/duties endpoint
* Add time-based skip slot limiting
* Add new error type missed in previous commit
* Add log when waiting for genesis
* Refactor beacon node CLI
* Remove unused dep
* Add lcli eth1-genesis command
* Fix bug in master merge
* Apply clippy lints to beacon node
* Add support for YamlConfig in Eth2TestnetDir
* Upgrade tesnet deposit contract version
* Remove unnecessary logging and correct formatting
* Add a hardcoded eth2 testnet config
* Ensure http server flag works. Overwrite configs with flags.
* Ensure boot nodes are loaded from testnet dir
* Fix account manager CLI bugs
* Fix bugs with beacon node cli
* Allow testnet dir without boot nodes
* Write genesis state as SSZ
* Remove ---/n from the start of testnet_dir files
* Set default libp2p address
* Tidy account manager CLI, add logging
* Add check to see if testnet dir exists
* Apply reviewers suggestions
* Add HeadTracker struct
* Add fork choice persistence
* Shorten slot time for simulator
* Add the /beacon/heads API endpoint
* Update hardcoded testnet
* Add tests for BeaconChain persistence + fix bugs
* Extend BeaconChain persistence testing
* Ensure chain is finalized b4 persistence tests
* Ensure boot_enr.yaml is include in binary
* Refactor beacon_chain_sim
* Move files about in beacon sim
* Update beacon_chain_sim
* Fix bug with deposit inclusion
* Increase log in genesis service, fix todo
* Tidy sim, fix broken rest_api tests
* Fix more broken tests
* Update testnet
* Fix broken rest api test
* Tidy account manager CLI
* Use tempdir for account manager
* Stop hardcoded testnet dir from creating dir
* Rename Eth2TestnetDir to Eth2TestnetConfig
* Change hardcoded -> hard_coded
* Tidy account manager
* Add log to account manager
* Tidy, ensure head tracker is loaded from disk
* Tidy beacon chain builder
* Tidy eth1_chain
* Adds log support for simulator
* Revert "Adds log support for simulator"
This reverts commit ec77c66a052350f551db145cf20f213823428dd3.
* Adds log support for simulator
* Tidy after self-review
* Change default log level
* Address Michael's delicious PR comments
* Fix off-by-one in tests
2019-12-03 04:28:57 +00:00
|
|
|
.parse::<u16>()
|
|
|
|
.map_err(|_| "http-port is not a valid u16.")?;
|
|
|
|
}
|
|
|
|
|
2020-07-16 07:23:14 +00:00
|
|
|
if let Some(allow_origin) = cli_args.value_of("http-allow-origin") {
|
|
|
|
// Pre-validate the config value to give feedback to the user on node startup, instead of
|
|
|
|
// as late as when the first API response is produced.
|
|
|
|
hyper::header::HeaderValue::from_str(allow_origin)
|
|
|
|
.map_err(|_| "Invalid allow-origin value")?;
|
|
|
|
|
2020-09-29 03:46:54 +00:00
|
|
|
client_config.http_api.allow_origin = Some(allow_origin.to_string());
|
|
|
|
}
|
|
|
|
|
2021-07-09 06:15:32 +00:00
|
|
|
if cli_args.is_present("http-disable-legacy-spec") {
|
2022-08-10 07:52:59 +00:00
|
|
|
warn!(
|
|
|
|
log,
|
|
|
|
"The flag --http-disable-legacy-spec is deprecated and will be removed"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if let Some(fork_name) = clap_utils::parse_optional(cli_args, "http-spec-fork")? {
|
|
|
|
client_config.http_api.spec_fork_name = Some(fork_name);
|
2021-07-09 06:15:32 +00:00
|
|
|
}
|
|
|
|
|
2021-10-12 03:35:49 +00:00
|
|
|
if cli_args.is_present("http-enable-tls") {
|
|
|
|
client_config.http_api.tls_config = Some(TlsConfig {
|
|
|
|
cert: cli_args
|
|
|
|
.value_of("http-tls-cert")
|
|
|
|
.ok_or("--http-tls-cert was not provided.")?
|
|
|
|
.parse::<PathBuf>()
|
|
|
|
.map_err(|_| "http-tls-cert is not a valid path name.")?,
|
|
|
|
key: cli_args
|
|
|
|
.value_of("http-tls-key")
|
|
|
|
.ok_or("--http-tls-key was not provided.")?
|
|
|
|
.parse::<PathBuf>()
|
|
|
|
.map_err(|_| "http-tls-key is not a valid path name.")?,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-10-02 19:57:23 +00:00
|
|
|
if cli_args.is_present("http-allow-sync-stalled") {
|
|
|
|
client_config.http_api.allow_sync_stalled = true;
|
|
|
|
}
|
|
|
|
|
2020-09-29 03:46:54 +00:00
|
|
|
/*
|
|
|
|
* Prometheus metrics HTTP server
|
|
|
|
*/
|
|
|
|
|
|
|
|
if cli_args.is_present("metrics") {
|
|
|
|
client_config.http_metrics.enabled = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if let Some(address) = cli_args.value_of("metrics-address") {
|
|
|
|
client_config.http_metrics.listen_addr = address
|
2022-03-24 00:04:49 +00:00
|
|
|
.parse::<IpAddr>()
|
|
|
|
.map_err(|_| "metrics-address is not a valid IP address.")?;
|
2020-09-29 03:46:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if let Some(port) = cli_args.value_of("metrics-port") {
|
|
|
|
client_config.http_metrics.listen_port = port
|
|
|
|
.parse::<u16>()
|
|
|
|
.map_err(|_| "metrics-port is not a valid u16.")?;
|
|
|
|
}
|
|
|
|
|
|
|
|
if let Some(allow_origin) = cli_args.value_of("metrics-allow-origin") {
|
|
|
|
// Pre-validate the config value to give feedback to the user on node startup, instead of
|
|
|
|
// as late as when the first API response is produced.
|
|
|
|
hyper::header::HeaderValue::from_str(allow_origin)
|
|
|
|
.map_err(|_| "Invalid allow-origin value")?;
|
|
|
|
|
|
|
|
client_config.http_metrics.allow_origin = Some(allow_origin.to_string());
|
2020-07-16 07:23:14 +00:00
|
|
|
}
|
|
|
|
|
2021-05-26 05:58:41 +00:00
|
|
|
/*
|
|
|
|
* Explorer metrics
|
|
|
|
*/
|
|
|
|
if let Some(monitoring_endpoint) = cli_args.value_of("monitoring-endpoint") {
|
2022-09-05 08:29:00 +00:00
|
|
|
let update_period_secs =
|
|
|
|
clap_utils::parse_optional(cli_args, "monitoring-endpoint-period")?;
|
|
|
|
|
2021-05-26 05:58:41 +00:00
|
|
|
client_config.monitoring_api = Some(monitoring_api::Config {
|
|
|
|
db_path: None,
|
|
|
|
freezer_db_path: None,
|
2022-09-05 08:29:00 +00:00
|
|
|
update_period_secs,
|
2021-05-26 05:58:41 +00:00
|
|
|
monitoring_endpoint: monitoring_endpoint.to_string(),
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-09-23 01:19:58 +00:00
|
|
|
// Log a warning indicating an open HTTP server if it wasn't specified explicitly
|
|
|
|
// (e.g. using the --staking flag).
|
|
|
|
if cli_args.is_present("staking") {
|
|
|
|
warn!(
|
|
|
|
log,
|
2020-09-29 03:46:54 +00:00
|
|
|
"Running HTTP server on port {}", client_config.http_api.listen_port
|
2020-09-23 01:19:58 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-05-28 05:59:45 +00:00
|
|
|
// Do not scrape for malloc metrics if we've disabled tuning malloc as it may cause panics.
|
|
|
|
if cli_args.is_present(DISABLE_MALLOC_TUNING_FLAG) {
|
|
|
|
client_config.http_metrics.allocator_metrics_enabled = false;
|
|
|
|
}
|
|
|
|
|
Prepare for public testnet (#628)
* Update to spec v0.9.0
* Update to v0.9.1
* Bump spec tags for v0.9.1
* Formatting, fix CI failures
* Resolve accidental KeyPair merge conflict
* Document new BeaconState functions
* Add `validator` changes from `validator-to-rest`
* Add initial (failing) REST api tests
* Fix signature parsing
* Add more tests
* Refactor http router
* Add working tests for publish beacon block
* Add validator duties tests
* Move account_manager under `lighthouse` binary
* Unify logfile handling in `environment` crate.
* Fix incorrect cache drops in `advance_caches`
* Update fork choice for v0.9.1
* Add `deposit_contract` crate
* Add progress on validator onboarding
* Add unfinished attesation code
* Update account manager CLI
* Write eth1 data file as hex string
* Integrate ValidatorDirectory with validator_client
* Move ValidatorDirectory into validator_client
* Clean up some FIXMEs
* Add beacon_chain_sim
* Fix a few docs/logs
* Expand `beacon_chain_sim`
* Fix spec for `beacon_chain_sim
* More testing for api
* Start work on attestation endpoint
* Reject empty attestations
* Allow attestations to genesis block
* Add working tests for `rest_api` validator endpoint
* Remove grpc from beacon_node
* Start heavy refactor of validator client
- Block production is working
* Prune old validator client files
* Start works on attestation service
* Add attestation service to validator client
* Use full pubkey for validator directories
* Add validator duties post endpoint
* Use par_iter for keypair generation
* Use bulk duties request in validator client
* Add version http endpoint tests
* Add interop keys and startup wait
* Ensure a prompt exit
* Add duties pruning
* Fix compile error in beacon node tests
* Add github workflow
* Modify rust.yaml
* Modify gitlab actions
* Add to CI file
* Add sudo to CI npm install
* Move cargo fmt to own job in tests
* Fix cargo fmt in CI
* Add rustup update before cargo fmt
* Change name of CI job
* Make other CI jobs require cargo fmt
* Add CI badge
* Remove gitlab and travis files
* Add different http timeout for debug
* Update docker file, use makefile in CI
* Use make in the dockerfile, skip the test
* Use the makefile for debug GI test
* Update book
* Tidy grpc and misc things
* Apply discv5 fixes
* Address other minor issues
* Fix warnings
* Attempt fix for addr parsing
* Tidy validator config, CLIs
* Tidy comments
* Tidy signing, reduce ForkService duplication
* Fail if skipping too many slots
* Set default recent genesis time to 0
* Add custom http timeout to validator
* Fix compile bug in node_test_rig
* Remove old bootstrap flag from val CLI
* Update docs
* Tidy val client
* Change val client log levels
* Add comments, more validity checks
* Fix compile error, add comments
* Undo changes to eth2-libp2p/src
* Reduce duplication of keypair generation
* Add more logging for validator duties
* Fix beacon_chain_sim, nitpicks
* Fix compile error, minor nits
* Update to use v0.9.2 version of deposit contract
* Add efforts to automate eth1 testnet deployment
* Fix lcli testnet deployer
* Modify bn CLI to parse eth2_testnet_dir
* Progress with account_manager deposit tools
* Make account manager submit deposits
* Add password option for submitting deposits
* Allow custom deposit amount
* Add long names to lcli clap
* Add password option to lcli deploy command
* Fix minor bugs whilst testing
* Address Michael's comments
* Add refund-deposit-contract to lcli
* Use time instead of skip count for denying long skips
* Improve logging for eth1
* Fix bug with validator services exiting on error
* Drop the block cache after genesis
* Modify eth1 testnet config
* Improve eth1 logging
* Make validator wait until genesis time
* Fix bug in eth1 voting
* Add more logging to eth1 voting
* Handle errors in eth1 http module
* Set SECONDS_PER_DAY to sensible minimum
* Shorten delay before testnet start
* Ensure eth1 block is produced without any votes
* Improve eth1 logging
* Fix broken tests in eth1
* Tidy code in rest_api
* Fix failing test in deposit_contract
* Make CLI args more consistent
* Change validator/duties endpoint
* Add time-based skip slot limiting
* Add new error type missed in previous commit
* Add log when waiting for genesis
* Refactor beacon node CLI
* Remove unused dep
* Add lcli eth1-genesis command
* Fix bug in master merge
* Apply clippy lints to beacon node
* Add support for YamlConfig in Eth2TestnetDir
* Upgrade tesnet deposit contract version
* Remove unnecessary logging and correct formatting
* Add a hardcoded eth2 testnet config
* Ensure http server flag works. Overwrite configs with flags.
* Ensure boot nodes are loaded from testnet dir
* Fix account manager CLI bugs
* Fix bugs with beacon node cli
* Allow testnet dir without boot nodes
* Write genesis state as SSZ
* Remove ---/n from the start of testnet_dir files
* Set default libp2p address
* Tidy account manager CLI, add logging
* Add check to see if testnet dir exists
* Apply reviewers suggestions
* Add HeadTracker struct
* Add fork choice persistence
* Shorten slot time for simulator
* Add the /beacon/heads API endpoint
* Update hardcoded testnet
* Add tests for BeaconChain persistence + fix bugs
* Extend BeaconChain persistence testing
* Ensure chain is finalized b4 persistence tests
* Ensure boot_enr.yaml is include in binary
* Refactor beacon_chain_sim
* Move files about in beacon sim
* Update beacon_chain_sim
* Fix bug with deposit inclusion
* Increase log in genesis service, fix todo
* Tidy sim, fix broken rest_api tests
* Fix more broken tests
* Update testnet
* Fix broken rest api test
* Tidy account manager CLI
* Use tempdir for account manager
* Stop hardcoded testnet dir from creating dir
* Rename Eth2TestnetDir to Eth2TestnetConfig
* Change hardcoded -> hard_coded
* Tidy account manager
* Add log to account manager
* Tidy, ensure head tracker is loaded from disk
* Tidy beacon chain builder
* Tidy eth1_chain
* Adds log support for simulator
* Revert "Adds log support for simulator"
This reverts commit ec77c66a052350f551db145cf20f213823428dd3.
* Adds log support for simulator
* Tidy after self-review
* Change default log level
* Address Michael's delicious PR comments
* Fix off-by-one in tests
2019-12-03 04:28:57 +00:00
|
|
|
/*
|
|
|
|
* Eth1
|
|
|
|
*/
|
|
|
|
|
|
|
|
// When present, use an eth1 backend that generates deterministic junk.
|
|
|
|
//
|
|
|
|
// Useful for running testnets without the overhead of a deposit contract.
|
|
|
|
if cli_args.is_present("dummy-eth1") {
|
|
|
|
client_config.dummy_eth1_backend = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// When present, attempt to sync to an eth1 node.
|
|
|
|
//
|
|
|
|
// Required for block production.
|
|
|
|
if cli_args.is_present("eth1") {
|
|
|
|
client_config.sync_eth1_chain = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Defines the URL to reach the eth1 node.
|
2021-05-04 01:59:51 +00:00
|
|
|
if let Some(endpoint) = cli_args.value_of("eth1-endpoint") {
|
2020-12-18 09:17:03 +00:00
|
|
|
warn!(
|
|
|
|
log,
|
|
|
|
"The --eth1-endpoint flag is deprecated";
|
|
|
|
"msg" => "please use --eth1-endpoints instead"
|
|
|
|
);
|
2020-04-01 06:41:19 +00:00
|
|
|
client_config.sync_eth1_chain = true;
|
2022-06-29 09:07:09 +00:00
|
|
|
|
|
|
|
let endpoints = vec![SensitiveUrl::parse(endpoint)
|
2021-05-04 01:59:51 +00:00
|
|
|
.map_err(|e| format!("eth1-endpoint was an invalid URL: {:?}", e))?];
|
2022-06-29 09:07:09 +00:00
|
|
|
client_config.eth1.endpoints = Eth1Endpoint::NoAuth(endpoints);
|
2021-05-04 01:59:51 +00:00
|
|
|
} else if let Some(endpoints) = cli_args.value_of("eth1-endpoints") {
|
2021-06-04 00:10:59 +00:00
|
|
|
client_config.sync_eth1_chain = true;
|
2022-06-29 09:07:09 +00:00
|
|
|
let endpoints = endpoints
|
2021-05-04 01:59:51 +00:00
|
|
|
.split(',')
|
2021-12-03 04:44:30 +00:00
|
|
|
.map(SensitiveUrl::parse)
|
2021-05-04 01:59:51 +00:00
|
|
|
.collect::<Result<_, _>>()
|
|
|
|
.map_err(|e| format!("eth1-endpoints contains an invalid URL {:?}", e))?;
|
2022-06-29 09:07:09 +00:00
|
|
|
client_config.eth1.endpoints = Eth1Endpoint::NoAuth(endpoints);
|
2019-09-03 06:40:53 +00:00
|
|
|
}
|
|
|
|
|
2020-11-18 22:18:59 +00:00
|
|
|
if let Some(val) = cli_args.value_of("eth1-blocks-per-log-query") {
|
|
|
|
client_config.eth1.blocks_per_log_query = val
|
|
|
|
.parse()
|
|
|
|
.map_err(|_| "eth1-blocks-per-log-query is not a valid integer".to_string())?;
|
|
|
|
}
|
|
|
|
|
2020-12-04 05:03:28 +00:00
|
|
|
if cli_args.is_present("eth1-purge-cache") {
|
|
|
|
client_config.eth1.purge_cache = true;
|
|
|
|
}
|
|
|
|
|
2022-06-03 06:05:03 +00:00
|
|
|
if let Some(follow_distance) =
|
|
|
|
clap_utils::parse_optional(cli_args, "eth1-cache-follow-distance")?
|
|
|
|
{
|
|
|
|
client_config.eth1.cache_follow_distance = Some(follow_distance);
|
|
|
|
}
|
|
|
|
|
2022-06-29 09:07:09 +00:00
|
|
|
if cli_args.is_present("merge") {
|
|
|
|
if cli_args.is_present("execution-endpoint") {
|
|
|
|
warn!(
|
|
|
|
log,
|
|
|
|
"The --merge flag is deprecated";
|
|
|
|
"info" => "the --execution-endpoint flag automatically enables this feature"
|
|
|
|
)
|
|
|
|
} else {
|
|
|
|
return Err("The --merge flag is deprecated. \
|
|
|
|
Supply a value to --execution-endpoint instead."
|
|
|
|
.into());
|
2022-03-08 06:46:24 +00:00
|
|
|
}
|
2022-06-29 09:07:09 +00:00
|
|
|
}
|
2022-03-08 06:46:24 +00:00
|
|
|
|
2022-06-29 09:07:09 +00:00
|
|
|
if let Some(endpoints) = cli_args.value_of("execution-endpoint") {
|
|
|
|
let mut el_config = execution_layer::Config::default();
|
2022-03-31 07:52:23 +00:00
|
|
|
|
2022-06-29 09:07:09 +00:00
|
|
|
// Always follow the deposit contract when there is an execution endpoint.
|
|
|
|
//
|
|
|
|
// This is wasteful for non-staking nodes as they have no need to process deposit contract
|
|
|
|
// logs and build an "eth1" cache. The alternative is to explicitly require the `--eth1` or
|
|
|
|
// `--staking` flags, however that poses a risk to stakers since they cannot produce blocks
|
|
|
|
// without "eth1".
|
|
|
|
//
|
|
|
|
// The waste for non-staking nodes is relatively small so we err on the side of safety for
|
|
|
|
// stakers. The merge is already complicated enough.
|
|
|
|
client_config.sync_eth1_chain = true;
|
|
|
|
|
|
|
|
// Parse a single execution endpoint, logging warnings if multiple endpoints are supplied.
|
|
|
|
let execution_endpoint =
|
|
|
|
parse_only_one_value(endpoints, SensitiveUrl::parse, "--execution-endpoint", log)?;
|
|
|
|
|
|
|
|
// Parse a single JWT secret, logging warnings if multiple are supplied.
|
|
|
|
//
|
|
|
|
// JWTs are required if `--execution-endpoint` is supplied.
|
|
|
|
let secret_files: String = clap_utils::parse_required(cli_args, "execution-jwt")?;
|
|
|
|
let secret_file =
|
|
|
|
parse_only_one_value(&secret_files, PathBuf::from_str, "--execution-jwt", log)?;
|
|
|
|
|
|
|
|
// Parse and set the payload builder, if any.
|
2022-07-01 01:15:19 +00:00
|
|
|
if let Some(endpoint) = cli_args.value_of("builder") {
|
2022-06-29 09:07:09 +00:00
|
|
|
let payload_builder =
|
2022-07-01 01:15:19 +00:00
|
|
|
parse_only_one_value(endpoint, SensitiveUrl::parse, "--builder", log)?;
|
|
|
|
el_config.builder_url = Some(payload_builder);
|
2022-03-08 06:46:24 +00:00
|
|
|
}
|
2021-09-29 22:14:15 +00:00
|
|
|
|
2022-06-29 09:07:09 +00:00
|
|
|
// Set config values from parse values.
|
|
|
|
el_config.secret_files = vec![secret_file.clone()];
|
|
|
|
el_config.execution_endpoints = vec![execution_endpoint.clone()];
|
2022-03-08 06:46:24 +00:00
|
|
|
el_config.suggested_fee_recipient =
|
|
|
|
clap_utils::parse_optional(cli_args, "suggested-fee-recipient")?;
|
2022-06-29 09:07:09 +00:00
|
|
|
el_config.jwt_id = clap_utils::parse_optional(cli_args, "execution-jwt-id")?;
|
|
|
|
el_config.jwt_version = clap_utils::parse_optional(cli_args, "execution-jwt-version")?;
|
2022-03-08 06:46:24 +00:00
|
|
|
el_config.default_datadir = client_config.data_dir.clone();
|
2022-09-05 04:50:49 +00:00
|
|
|
el_config.builder_profit_threshold =
|
|
|
|
clap_utils::parse_required(cli_args, "builder-profit-threshold")?;
|
2022-06-29 09:07:09 +00:00
|
|
|
|
|
|
|
// If `--execution-endpoint` is provided, we should ignore any `--eth1-endpoints` values and
|
|
|
|
// use `--execution-endpoint` instead. Also, log a deprecation warning.
|
|
|
|
if cli_args.is_present("eth1-endpoints") || cli_args.is_present("eth1-endpoint") {
|
|
|
|
warn!(
|
|
|
|
log,
|
|
|
|
"Ignoring --eth1-endpoints flag";
|
|
|
|
"info" => "the value for --execution-endpoint will be used instead. \
|
|
|
|
--eth1-endpoints has been deprecated for post-merge configurations"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
client_config.eth1.endpoints = Eth1Endpoint::Auth {
|
|
|
|
endpoint: execution_endpoint,
|
|
|
|
jwt_path: secret_file,
|
|
|
|
jwt_id: el_config.jwt_id.clone(),
|
|
|
|
jwt_version: el_config.jwt_version.clone(),
|
|
|
|
};
|
|
|
|
|
|
|
|
// Store the EL config in the client config.
|
2022-03-08 06:46:24 +00:00
|
|
|
client_config.execution_layer = Some(el_config);
|
|
|
|
}
|
2021-09-29 22:14:15 +00:00
|
|
|
|
Prepare for public testnet (#628)
* Update to spec v0.9.0
* Update to v0.9.1
* Bump spec tags for v0.9.1
* Formatting, fix CI failures
* Resolve accidental KeyPair merge conflict
* Document new BeaconState functions
* Add `validator` changes from `validator-to-rest`
* Add initial (failing) REST api tests
* Fix signature parsing
* Add more tests
* Refactor http router
* Add working tests for publish beacon block
* Add validator duties tests
* Move account_manager under `lighthouse` binary
* Unify logfile handling in `environment` crate.
* Fix incorrect cache drops in `advance_caches`
* Update fork choice for v0.9.1
* Add `deposit_contract` crate
* Add progress on validator onboarding
* Add unfinished attesation code
* Update account manager CLI
* Write eth1 data file as hex string
* Integrate ValidatorDirectory with validator_client
* Move ValidatorDirectory into validator_client
* Clean up some FIXMEs
* Add beacon_chain_sim
* Fix a few docs/logs
* Expand `beacon_chain_sim`
* Fix spec for `beacon_chain_sim
* More testing for api
* Start work on attestation endpoint
* Reject empty attestations
* Allow attestations to genesis block
* Add working tests for `rest_api` validator endpoint
* Remove grpc from beacon_node
* Start heavy refactor of validator client
- Block production is working
* Prune old validator client files
* Start works on attestation service
* Add attestation service to validator client
* Use full pubkey for validator directories
* Add validator duties post endpoint
* Use par_iter for keypair generation
* Use bulk duties request in validator client
* Add version http endpoint tests
* Add interop keys and startup wait
* Ensure a prompt exit
* Add duties pruning
* Fix compile error in beacon node tests
* Add github workflow
* Modify rust.yaml
* Modify gitlab actions
* Add to CI file
* Add sudo to CI npm install
* Move cargo fmt to own job in tests
* Fix cargo fmt in CI
* Add rustup update before cargo fmt
* Change name of CI job
* Make other CI jobs require cargo fmt
* Add CI badge
* Remove gitlab and travis files
* Add different http timeout for debug
* Update docker file, use makefile in CI
* Use make in the dockerfile, skip the test
* Use the makefile for debug GI test
* Update book
* Tidy grpc and misc things
* Apply discv5 fixes
* Address other minor issues
* Fix warnings
* Attempt fix for addr parsing
* Tidy validator config, CLIs
* Tidy comments
* Tidy signing, reduce ForkService duplication
* Fail if skipping too many slots
* Set default recent genesis time to 0
* Add custom http timeout to validator
* Fix compile bug in node_test_rig
* Remove old bootstrap flag from val CLI
* Update docs
* Tidy val client
* Change val client log levels
* Add comments, more validity checks
* Fix compile error, add comments
* Undo changes to eth2-libp2p/src
* Reduce duplication of keypair generation
* Add more logging for validator duties
* Fix beacon_chain_sim, nitpicks
* Fix compile error, minor nits
* Update to use v0.9.2 version of deposit contract
* Add efforts to automate eth1 testnet deployment
* Fix lcli testnet deployer
* Modify bn CLI to parse eth2_testnet_dir
* Progress with account_manager deposit tools
* Make account manager submit deposits
* Add password option for submitting deposits
* Allow custom deposit amount
* Add long names to lcli clap
* Add password option to lcli deploy command
* Fix minor bugs whilst testing
* Address Michael's comments
* Add refund-deposit-contract to lcli
* Use time instead of skip count for denying long skips
* Improve logging for eth1
* Fix bug with validator services exiting on error
* Drop the block cache after genesis
* Modify eth1 testnet config
* Improve eth1 logging
* Make validator wait until genesis time
* Fix bug in eth1 voting
* Add more logging to eth1 voting
* Handle errors in eth1 http module
* Set SECONDS_PER_DAY to sensible minimum
* Shorten delay before testnet start
* Ensure eth1 block is produced without any votes
* Improve eth1 logging
* Fix broken tests in eth1
* Tidy code in rest_api
* Fix failing test in deposit_contract
* Make CLI args more consistent
* Change validator/duties endpoint
* Add time-based skip slot limiting
* Add new error type missed in previous commit
* Add log when waiting for genesis
* Refactor beacon node CLI
* Remove unused dep
* Add lcli eth1-genesis command
* Fix bug in master merge
* Apply clippy lints to beacon node
* Add support for YamlConfig in Eth2TestnetDir
* Upgrade tesnet deposit contract version
* Remove unnecessary logging and correct formatting
* Add a hardcoded eth2 testnet config
* Ensure http server flag works. Overwrite configs with flags.
* Ensure boot nodes are loaded from testnet dir
* Fix account manager CLI bugs
* Fix bugs with beacon node cli
* Allow testnet dir without boot nodes
* Write genesis state as SSZ
* Remove ---/n from the start of testnet_dir files
* Set default libp2p address
* Tidy account manager CLI, add logging
* Add check to see if testnet dir exists
* Apply reviewers suggestions
* Add HeadTracker struct
* Add fork choice persistence
* Shorten slot time for simulator
* Add the /beacon/heads API endpoint
* Update hardcoded testnet
* Add tests for BeaconChain persistence + fix bugs
* Extend BeaconChain persistence testing
* Ensure chain is finalized b4 persistence tests
* Ensure boot_enr.yaml is include in binary
* Refactor beacon_chain_sim
* Move files about in beacon sim
* Update beacon_chain_sim
* Fix bug with deposit inclusion
* Increase log in genesis service, fix todo
* Tidy sim, fix broken rest_api tests
* Fix more broken tests
* Update testnet
* Fix broken rest api test
* Tidy account manager CLI
* Use tempdir for account manager
* Stop hardcoded testnet dir from creating dir
* Rename Eth2TestnetDir to Eth2TestnetConfig
* Change hardcoded -> hard_coded
* Tidy account manager
* Add log to account manager
* Tidy, ensure head tracker is loaded from disk
* Tidy beacon chain builder
* Tidy eth1_chain
* Adds log support for simulator
* Revert "Adds log support for simulator"
This reverts commit ec77c66a052350f551db145cf20f213823428dd3.
* Adds log support for simulator
* Tidy after self-review
* Change default log level
* Address Michael's delicious PR comments
* Fix off-by-one in tests
2019-12-03 04:28:57 +00:00
|
|
|
if let Some(freezer_dir) = cli_args.value_of("freezer-dir") {
|
2020-02-10 00:30:21 +00:00
|
|
|
client_config.freezer_db_path = Some(PathBuf::from(freezer_dir));
|
2019-12-06 03:29:06 +00:00
|
|
|
}
|
|
|
|
|
2022-04-01 07:16:25 +00:00
|
|
|
let (sprp, sprp_explicit) = get_slots_per_restore_point::<E>(cli_args)?;
|
|
|
|
client_config.store.slots_per_restore_point = sprp;
|
|
|
|
client_config.store.slots_per_restore_point_set_explicitly = sprp_explicit;
|
Prepare for public testnet (#628)
* Update to spec v0.9.0
* Update to v0.9.1
* Bump spec tags for v0.9.1
* Formatting, fix CI failures
* Resolve accidental KeyPair merge conflict
* Document new BeaconState functions
* Add `validator` changes from `validator-to-rest`
* Add initial (failing) REST api tests
* Fix signature parsing
* Add more tests
* Refactor http router
* Add working tests for publish beacon block
* Add validator duties tests
* Move account_manager under `lighthouse` binary
* Unify logfile handling in `environment` crate.
* Fix incorrect cache drops in `advance_caches`
* Update fork choice for v0.9.1
* Add `deposit_contract` crate
* Add progress on validator onboarding
* Add unfinished attesation code
* Update account manager CLI
* Write eth1 data file as hex string
* Integrate ValidatorDirectory with validator_client
* Move ValidatorDirectory into validator_client
* Clean up some FIXMEs
* Add beacon_chain_sim
* Fix a few docs/logs
* Expand `beacon_chain_sim`
* Fix spec for `beacon_chain_sim
* More testing for api
* Start work on attestation endpoint
* Reject empty attestations
* Allow attestations to genesis block
* Add working tests for `rest_api` validator endpoint
* Remove grpc from beacon_node
* Start heavy refactor of validator client
- Block production is working
* Prune old validator client files
* Start works on attestation service
* Add attestation service to validator client
* Use full pubkey for validator directories
* Add validator duties post endpoint
* Use par_iter for keypair generation
* Use bulk duties request in validator client
* Add version http endpoint tests
* Add interop keys and startup wait
* Ensure a prompt exit
* Add duties pruning
* Fix compile error in beacon node tests
* Add github workflow
* Modify rust.yaml
* Modify gitlab actions
* Add to CI file
* Add sudo to CI npm install
* Move cargo fmt to own job in tests
* Fix cargo fmt in CI
* Add rustup update before cargo fmt
* Change name of CI job
* Make other CI jobs require cargo fmt
* Add CI badge
* Remove gitlab and travis files
* Add different http timeout for debug
* Update docker file, use makefile in CI
* Use make in the dockerfile, skip the test
* Use the makefile for debug GI test
* Update book
* Tidy grpc and misc things
* Apply discv5 fixes
* Address other minor issues
* Fix warnings
* Attempt fix for addr parsing
* Tidy validator config, CLIs
* Tidy comments
* Tidy signing, reduce ForkService duplication
* Fail if skipping too many slots
* Set default recent genesis time to 0
* Add custom http timeout to validator
* Fix compile bug in node_test_rig
* Remove old bootstrap flag from val CLI
* Update docs
* Tidy val client
* Change val client log levels
* Add comments, more validity checks
* Fix compile error, add comments
* Undo changes to eth2-libp2p/src
* Reduce duplication of keypair generation
* Add more logging for validator duties
* Fix beacon_chain_sim, nitpicks
* Fix compile error, minor nits
* Update to use v0.9.2 version of deposit contract
* Add efforts to automate eth1 testnet deployment
* Fix lcli testnet deployer
* Modify bn CLI to parse eth2_testnet_dir
* Progress with account_manager deposit tools
* Make account manager submit deposits
* Add password option for submitting deposits
* Allow custom deposit amount
* Add long names to lcli clap
* Add password option to lcli deploy command
* Fix minor bugs whilst testing
* Address Michael's comments
* Add refund-deposit-contract to lcli
* Use time instead of skip count for denying long skips
* Improve logging for eth1
* Fix bug with validator services exiting on error
* Drop the block cache after genesis
* Modify eth1 testnet config
* Improve eth1 logging
* Make validator wait until genesis time
* Fix bug in eth1 voting
* Add more logging to eth1 voting
* Handle errors in eth1 http module
* Set SECONDS_PER_DAY to sensible minimum
* Shorten delay before testnet start
* Ensure eth1 block is produced without any votes
* Improve eth1 logging
* Fix broken tests in eth1
* Tidy code in rest_api
* Fix failing test in deposit_contract
* Make CLI args more consistent
* Change validator/duties endpoint
* Add time-based skip slot limiting
* Add new error type missed in previous commit
* Add log when waiting for genesis
* Refactor beacon node CLI
* Remove unused dep
* Add lcli eth1-genesis command
* Fix bug in master merge
* Apply clippy lints to beacon node
* Add support for YamlConfig in Eth2TestnetDir
* Upgrade tesnet deposit contract version
* Remove unnecessary logging and correct formatting
* Add a hardcoded eth2 testnet config
* Ensure http server flag works. Overwrite configs with flags.
* Ensure boot nodes are loaded from testnet dir
* Fix account manager CLI bugs
* Fix bugs with beacon node cli
* Allow testnet dir without boot nodes
* Write genesis state as SSZ
* Remove ---/n from the start of testnet_dir files
* Set default libp2p address
* Tidy account manager CLI, add logging
* Add check to see if testnet dir exists
* Apply reviewers suggestions
* Add HeadTracker struct
* Add fork choice persistence
* Shorten slot time for simulator
* Add the /beacon/heads API endpoint
* Update hardcoded testnet
* Add tests for BeaconChain persistence + fix bugs
* Extend BeaconChain persistence testing
* Ensure chain is finalized b4 persistence tests
* Ensure boot_enr.yaml is include in binary
* Refactor beacon_chain_sim
* Move files about in beacon sim
* Update beacon_chain_sim
* Fix bug with deposit inclusion
* Increase log in genesis service, fix todo
* Tidy sim, fix broken rest_api tests
* Fix more broken tests
* Update testnet
* Fix broken rest api test
* Tidy account manager CLI
* Use tempdir for account manager
* Stop hardcoded testnet dir from creating dir
* Rename Eth2TestnetDir to Eth2TestnetConfig
* Change hardcoded -> hard_coded
* Tidy account manager
* Add log to account manager
* Tidy, ensure head tracker is loaded from disk
* Tidy beacon chain builder
* Tidy eth1_chain
* Adds log support for simulator
* Revert "Adds log support for simulator"
This reverts commit ec77c66a052350f551db145cf20f213823428dd3.
* Adds log support for simulator
* Tidy after self-review
* Change default log level
* Address Michael's delicious PR comments
* Fix off-by-one in tests
2019-12-03 04:28:57 +00:00
|
|
|
|
2020-02-10 00:30:21 +00:00
|
|
|
if let Some(block_cache_size) = cli_args.value_of("block-cache-size") {
|
|
|
|
client_config.store.block_cache_size = block_cache_size
|
|
|
|
.parse()
|
|
|
|
.map_err(|_| "block-cache-size is not a valid integer".to_string())?;
|
|
|
|
}
|
|
|
|
|
2020-11-17 09:10:53 +00:00
|
|
|
client_config.store.compact_on_init = cli_args.is_present("compact-db");
|
|
|
|
if let Some(compact_on_prune) = cli_args.value_of("auto-compact-db") {
|
|
|
|
client_config.store.compact_on_prune = compact_on_prune
|
|
|
|
.parse()
|
|
|
|
.map_err(|_| "auto-compact-db takes a boolean".to_string())?;
|
|
|
|
}
|
|
|
|
|
Prepare for public testnet (#628)
* Update to spec v0.9.0
* Update to v0.9.1
* Bump spec tags for v0.9.1
* Formatting, fix CI failures
* Resolve accidental KeyPair merge conflict
* Document new BeaconState functions
* Add `validator` changes from `validator-to-rest`
* Add initial (failing) REST api tests
* Fix signature parsing
* Add more tests
* Refactor http router
* Add working tests for publish beacon block
* Add validator duties tests
* Move account_manager under `lighthouse` binary
* Unify logfile handling in `environment` crate.
* Fix incorrect cache drops in `advance_caches`
* Update fork choice for v0.9.1
* Add `deposit_contract` crate
* Add progress on validator onboarding
* Add unfinished attesation code
* Update account manager CLI
* Write eth1 data file as hex string
* Integrate ValidatorDirectory with validator_client
* Move ValidatorDirectory into validator_client
* Clean up some FIXMEs
* Add beacon_chain_sim
* Fix a few docs/logs
* Expand `beacon_chain_sim`
* Fix spec for `beacon_chain_sim
* More testing for api
* Start work on attestation endpoint
* Reject empty attestations
* Allow attestations to genesis block
* Add working tests for `rest_api` validator endpoint
* Remove grpc from beacon_node
* Start heavy refactor of validator client
- Block production is working
* Prune old validator client files
* Start works on attestation service
* Add attestation service to validator client
* Use full pubkey for validator directories
* Add validator duties post endpoint
* Use par_iter for keypair generation
* Use bulk duties request in validator client
* Add version http endpoint tests
* Add interop keys and startup wait
* Ensure a prompt exit
* Add duties pruning
* Fix compile error in beacon node tests
* Add github workflow
* Modify rust.yaml
* Modify gitlab actions
* Add to CI file
* Add sudo to CI npm install
* Move cargo fmt to own job in tests
* Fix cargo fmt in CI
* Add rustup update before cargo fmt
* Change name of CI job
* Make other CI jobs require cargo fmt
* Add CI badge
* Remove gitlab and travis files
* Add different http timeout for debug
* Update docker file, use makefile in CI
* Use make in the dockerfile, skip the test
* Use the makefile for debug GI test
* Update book
* Tidy grpc and misc things
* Apply discv5 fixes
* Address other minor issues
* Fix warnings
* Attempt fix for addr parsing
* Tidy validator config, CLIs
* Tidy comments
* Tidy signing, reduce ForkService duplication
* Fail if skipping too many slots
* Set default recent genesis time to 0
* Add custom http timeout to validator
* Fix compile bug in node_test_rig
* Remove old bootstrap flag from val CLI
* Update docs
* Tidy val client
* Change val client log levels
* Add comments, more validity checks
* Fix compile error, add comments
* Undo changes to eth2-libp2p/src
* Reduce duplication of keypair generation
* Add more logging for validator duties
* Fix beacon_chain_sim, nitpicks
* Fix compile error, minor nits
* Update to use v0.9.2 version of deposit contract
* Add efforts to automate eth1 testnet deployment
* Fix lcli testnet deployer
* Modify bn CLI to parse eth2_testnet_dir
* Progress with account_manager deposit tools
* Make account manager submit deposits
* Add password option for submitting deposits
* Allow custom deposit amount
* Add long names to lcli clap
* Add password option to lcli deploy command
* Fix minor bugs whilst testing
* Address Michael's comments
* Add refund-deposit-contract to lcli
* Use time instead of skip count for denying long skips
* Improve logging for eth1
* Fix bug with validator services exiting on error
* Drop the block cache after genesis
* Modify eth1 testnet config
* Improve eth1 logging
* Make validator wait until genesis time
* Fix bug in eth1 voting
* Add more logging to eth1 voting
* Handle errors in eth1 http module
* Set SECONDS_PER_DAY to sensible minimum
* Shorten delay before testnet start
* Ensure eth1 block is produced without any votes
* Improve eth1 logging
* Fix broken tests in eth1
* Tidy code in rest_api
* Fix failing test in deposit_contract
* Make CLI args more consistent
* Change validator/duties endpoint
* Add time-based skip slot limiting
* Add new error type missed in previous commit
* Add log when waiting for genesis
* Refactor beacon node CLI
* Remove unused dep
* Add lcli eth1-genesis command
* Fix bug in master merge
* Apply clippy lints to beacon node
* Add support for YamlConfig in Eth2TestnetDir
* Upgrade tesnet deposit contract version
* Remove unnecessary logging and correct formatting
* Add a hardcoded eth2 testnet config
* Ensure http server flag works. Overwrite configs with flags.
* Ensure boot nodes are loaded from testnet dir
* Fix account manager CLI bugs
* Fix bugs with beacon node cli
* Allow testnet dir without boot nodes
* Write genesis state as SSZ
* Remove ---/n from the start of testnet_dir files
* Set default libp2p address
* Tidy account manager CLI, add logging
* Add check to see if testnet dir exists
* Apply reviewers suggestions
* Add HeadTracker struct
* Add fork choice persistence
* Shorten slot time for simulator
* Add the /beacon/heads API endpoint
* Update hardcoded testnet
* Add tests for BeaconChain persistence + fix bugs
* Extend BeaconChain persistence testing
* Ensure chain is finalized b4 persistence tests
* Ensure boot_enr.yaml is include in binary
* Refactor beacon_chain_sim
* Move files about in beacon sim
* Update beacon_chain_sim
* Fix bug with deposit inclusion
* Increase log in genesis service, fix todo
* Tidy sim, fix broken rest_api tests
* Fix more broken tests
* Update testnet
* Fix broken rest api test
* Tidy account manager CLI
* Use tempdir for account manager
* Stop hardcoded testnet dir from creating dir
* Rename Eth2TestnetDir to Eth2TestnetConfig
* Change hardcoded -> hard_coded
* Tidy account manager
* Add log to account manager
* Tidy, ensure head tracker is loaded from disk
* Tidy beacon chain builder
* Tidy eth1_chain
* Adds log support for simulator
* Revert "Adds log support for simulator"
This reverts commit ec77c66a052350f551db145cf20f213823428dd3.
* Adds log support for simulator
* Tidy after self-review
* Change default log level
* Address Michael's delicious PR comments
* Fix off-by-one in tests
2019-12-03 04:28:57 +00:00
|
|
|
/*
|
|
|
|
* Zero-ports
|
|
|
|
*
|
|
|
|
* Replaces previously set flags.
|
2020-01-03 04:37:05 +00:00
|
|
|
* Libp2p and discovery ports are set explicitly by selecting
|
|
|
|
* a random free port so that we aren't needlessly updating ENR
|
|
|
|
* from lighthouse.
|
|
|
|
* Discovery address is set to localhost by default.
|
Prepare for public testnet (#628)
* Update to spec v0.9.0
* Update to v0.9.1
* Bump spec tags for v0.9.1
* Formatting, fix CI failures
* Resolve accidental KeyPair merge conflict
* Document new BeaconState functions
* Add `validator` changes from `validator-to-rest`
* Add initial (failing) REST api tests
* Fix signature parsing
* Add more tests
* Refactor http router
* Add working tests for publish beacon block
* Add validator duties tests
* Move account_manager under `lighthouse` binary
* Unify logfile handling in `environment` crate.
* Fix incorrect cache drops in `advance_caches`
* Update fork choice for v0.9.1
* Add `deposit_contract` crate
* Add progress on validator onboarding
* Add unfinished attesation code
* Update account manager CLI
* Write eth1 data file as hex string
* Integrate ValidatorDirectory with validator_client
* Move ValidatorDirectory into validator_client
* Clean up some FIXMEs
* Add beacon_chain_sim
* Fix a few docs/logs
* Expand `beacon_chain_sim`
* Fix spec for `beacon_chain_sim
* More testing for api
* Start work on attestation endpoint
* Reject empty attestations
* Allow attestations to genesis block
* Add working tests for `rest_api` validator endpoint
* Remove grpc from beacon_node
* Start heavy refactor of validator client
- Block production is working
* Prune old validator client files
* Start works on attestation service
* Add attestation service to validator client
* Use full pubkey for validator directories
* Add validator duties post endpoint
* Use par_iter for keypair generation
* Use bulk duties request in validator client
* Add version http endpoint tests
* Add interop keys and startup wait
* Ensure a prompt exit
* Add duties pruning
* Fix compile error in beacon node tests
* Add github workflow
* Modify rust.yaml
* Modify gitlab actions
* Add to CI file
* Add sudo to CI npm install
* Move cargo fmt to own job in tests
* Fix cargo fmt in CI
* Add rustup update before cargo fmt
* Change name of CI job
* Make other CI jobs require cargo fmt
* Add CI badge
* Remove gitlab and travis files
* Add different http timeout for debug
* Update docker file, use makefile in CI
* Use make in the dockerfile, skip the test
* Use the makefile for debug GI test
* Update book
* Tidy grpc and misc things
* Apply discv5 fixes
* Address other minor issues
* Fix warnings
* Attempt fix for addr parsing
* Tidy validator config, CLIs
* Tidy comments
* Tidy signing, reduce ForkService duplication
* Fail if skipping too many slots
* Set default recent genesis time to 0
* Add custom http timeout to validator
* Fix compile bug in node_test_rig
* Remove old bootstrap flag from val CLI
* Update docs
* Tidy val client
* Change val client log levels
* Add comments, more validity checks
* Fix compile error, add comments
* Undo changes to eth2-libp2p/src
* Reduce duplication of keypair generation
* Add more logging for validator duties
* Fix beacon_chain_sim, nitpicks
* Fix compile error, minor nits
* Update to use v0.9.2 version of deposit contract
* Add efforts to automate eth1 testnet deployment
* Fix lcli testnet deployer
* Modify bn CLI to parse eth2_testnet_dir
* Progress with account_manager deposit tools
* Make account manager submit deposits
* Add password option for submitting deposits
* Allow custom deposit amount
* Add long names to lcli clap
* Add password option to lcli deploy command
* Fix minor bugs whilst testing
* Address Michael's comments
* Add refund-deposit-contract to lcli
* Use time instead of skip count for denying long skips
* Improve logging for eth1
* Fix bug with validator services exiting on error
* Drop the block cache after genesis
* Modify eth1 testnet config
* Improve eth1 logging
* Make validator wait until genesis time
* Fix bug in eth1 voting
* Add more logging to eth1 voting
* Handle errors in eth1 http module
* Set SECONDS_PER_DAY to sensible minimum
* Shorten delay before testnet start
* Ensure eth1 block is produced without any votes
* Improve eth1 logging
* Fix broken tests in eth1
* Tidy code in rest_api
* Fix failing test in deposit_contract
* Make CLI args more consistent
* Change validator/duties endpoint
* Add time-based skip slot limiting
* Add new error type missed in previous commit
* Add log when waiting for genesis
* Refactor beacon node CLI
* Remove unused dep
* Add lcli eth1-genesis command
* Fix bug in master merge
* Apply clippy lints to beacon node
* Add support for YamlConfig in Eth2TestnetDir
* Upgrade tesnet deposit contract version
* Remove unnecessary logging and correct formatting
* Add a hardcoded eth2 testnet config
* Ensure http server flag works. Overwrite configs with flags.
* Ensure boot nodes are loaded from testnet dir
* Fix account manager CLI bugs
* Fix bugs with beacon node cli
* Allow testnet dir without boot nodes
* Write genesis state as SSZ
* Remove ---/n from the start of testnet_dir files
* Set default libp2p address
* Tidy account manager CLI, add logging
* Add check to see if testnet dir exists
* Apply reviewers suggestions
* Add HeadTracker struct
* Add fork choice persistence
* Shorten slot time for simulator
* Add the /beacon/heads API endpoint
* Update hardcoded testnet
* Add tests for BeaconChain persistence + fix bugs
* Extend BeaconChain persistence testing
* Ensure chain is finalized b4 persistence tests
* Ensure boot_enr.yaml is include in binary
* Refactor beacon_chain_sim
* Move files about in beacon sim
* Update beacon_chain_sim
* Fix bug with deposit inclusion
* Increase log in genesis service, fix todo
* Tidy sim, fix broken rest_api tests
* Fix more broken tests
* Update testnet
* Fix broken rest api test
* Tidy account manager CLI
* Use tempdir for account manager
* Stop hardcoded testnet dir from creating dir
* Rename Eth2TestnetDir to Eth2TestnetConfig
* Change hardcoded -> hard_coded
* Tidy account manager
* Add log to account manager
* Tidy, ensure head tracker is loaded from disk
* Tidy beacon chain builder
* Tidy eth1_chain
* Adds log support for simulator
* Revert "Adds log support for simulator"
This reverts commit ec77c66a052350f551db145cf20f213823428dd3.
* Adds log support for simulator
* Tidy after self-review
* Change default log level
* Address Michael's delicious PR comments
* Fix off-by-one in tests
2019-12-03 04:28:57 +00:00
|
|
|
*/
|
|
|
|
if cli_args.is_present("zero-ports") {
|
2020-03-19 04:11:08 +00:00
|
|
|
if client_config.network.enr_address == Some(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0))) {
|
|
|
|
client_config.network.enr_address = None
|
2020-01-03 04:37:05 +00:00
|
|
|
}
|
|
|
|
client_config.network.libp2p_port =
|
2022-02-17 21:47:06 +00:00
|
|
|
unused_tcp_port().map_err(|e| format!("Failed to get port for libp2p: {}", e))?;
|
2020-01-03 04:37:05 +00:00
|
|
|
client_config.network.discovery_port =
|
2022-02-17 21:47:06 +00:00
|
|
|
unused_udp_port().map_err(|e| format!("Failed to get port for discovery: {}", e))?;
|
2020-09-29 03:46:54 +00:00
|
|
|
client_config.http_api.listen_port = 0;
|
|
|
|
client_config.http_metrics.listen_port = 0;
|
Prepare for public testnet (#628)
* Update to spec v0.9.0
* Update to v0.9.1
* Bump spec tags for v0.9.1
* Formatting, fix CI failures
* Resolve accidental KeyPair merge conflict
* Document new BeaconState functions
* Add `validator` changes from `validator-to-rest`
* Add initial (failing) REST api tests
* Fix signature parsing
* Add more tests
* Refactor http router
* Add working tests for publish beacon block
* Add validator duties tests
* Move account_manager under `lighthouse` binary
* Unify logfile handling in `environment` crate.
* Fix incorrect cache drops in `advance_caches`
* Update fork choice for v0.9.1
* Add `deposit_contract` crate
* Add progress on validator onboarding
* Add unfinished attesation code
* Update account manager CLI
* Write eth1 data file as hex string
* Integrate ValidatorDirectory with validator_client
* Move ValidatorDirectory into validator_client
* Clean up some FIXMEs
* Add beacon_chain_sim
* Fix a few docs/logs
* Expand `beacon_chain_sim`
* Fix spec for `beacon_chain_sim
* More testing for api
* Start work on attestation endpoint
* Reject empty attestations
* Allow attestations to genesis block
* Add working tests for `rest_api` validator endpoint
* Remove grpc from beacon_node
* Start heavy refactor of validator client
- Block production is working
* Prune old validator client files
* Start works on attestation service
* Add attestation service to validator client
* Use full pubkey for validator directories
* Add validator duties post endpoint
* Use par_iter for keypair generation
* Use bulk duties request in validator client
* Add version http endpoint tests
* Add interop keys and startup wait
* Ensure a prompt exit
* Add duties pruning
* Fix compile error in beacon node tests
* Add github workflow
* Modify rust.yaml
* Modify gitlab actions
* Add to CI file
* Add sudo to CI npm install
* Move cargo fmt to own job in tests
* Fix cargo fmt in CI
* Add rustup update before cargo fmt
* Change name of CI job
* Make other CI jobs require cargo fmt
* Add CI badge
* Remove gitlab and travis files
* Add different http timeout for debug
* Update docker file, use makefile in CI
* Use make in the dockerfile, skip the test
* Use the makefile for debug GI test
* Update book
* Tidy grpc and misc things
* Apply discv5 fixes
* Address other minor issues
* Fix warnings
* Attempt fix for addr parsing
* Tidy validator config, CLIs
* Tidy comments
* Tidy signing, reduce ForkService duplication
* Fail if skipping too many slots
* Set default recent genesis time to 0
* Add custom http timeout to validator
* Fix compile bug in node_test_rig
* Remove old bootstrap flag from val CLI
* Update docs
* Tidy val client
* Change val client log levels
* Add comments, more validity checks
* Fix compile error, add comments
* Undo changes to eth2-libp2p/src
* Reduce duplication of keypair generation
* Add more logging for validator duties
* Fix beacon_chain_sim, nitpicks
* Fix compile error, minor nits
* Update to use v0.9.2 version of deposit contract
* Add efforts to automate eth1 testnet deployment
* Fix lcli testnet deployer
* Modify bn CLI to parse eth2_testnet_dir
* Progress with account_manager deposit tools
* Make account manager submit deposits
* Add password option for submitting deposits
* Allow custom deposit amount
* Add long names to lcli clap
* Add password option to lcli deploy command
* Fix minor bugs whilst testing
* Address Michael's comments
* Add refund-deposit-contract to lcli
* Use time instead of skip count for denying long skips
* Improve logging for eth1
* Fix bug with validator services exiting on error
* Drop the block cache after genesis
* Modify eth1 testnet config
* Improve eth1 logging
* Make validator wait until genesis time
* Fix bug in eth1 voting
* Add more logging to eth1 voting
* Handle errors in eth1 http module
* Set SECONDS_PER_DAY to sensible minimum
* Shorten delay before testnet start
* Ensure eth1 block is produced without any votes
* Improve eth1 logging
* Fix broken tests in eth1
* Tidy code in rest_api
* Fix failing test in deposit_contract
* Make CLI args more consistent
* Change validator/duties endpoint
* Add time-based skip slot limiting
* Add new error type missed in previous commit
* Add log when waiting for genesis
* Refactor beacon node CLI
* Remove unused dep
* Add lcli eth1-genesis command
* Fix bug in master merge
* Apply clippy lints to beacon node
* Add support for YamlConfig in Eth2TestnetDir
* Upgrade tesnet deposit contract version
* Remove unnecessary logging and correct formatting
* Add a hardcoded eth2 testnet config
* Ensure http server flag works. Overwrite configs with flags.
* Ensure boot nodes are loaded from testnet dir
* Fix account manager CLI bugs
* Fix bugs with beacon node cli
* Allow testnet dir without boot nodes
* Write genesis state as SSZ
* Remove ---/n from the start of testnet_dir files
* Set default libp2p address
* Tidy account manager CLI, add logging
* Add check to see if testnet dir exists
* Apply reviewers suggestions
* Add HeadTracker struct
* Add fork choice persistence
* Shorten slot time for simulator
* Add the /beacon/heads API endpoint
* Update hardcoded testnet
* Add tests for BeaconChain persistence + fix bugs
* Extend BeaconChain persistence testing
* Ensure chain is finalized b4 persistence tests
* Ensure boot_enr.yaml is include in binary
* Refactor beacon_chain_sim
* Move files about in beacon sim
* Update beacon_chain_sim
* Fix bug with deposit inclusion
* Increase log in genesis service, fix todo
* Tidy sim, fix broken rest_api tests
* Fix more broken tests
* Update testnet
* Fix broken rest api test
* Tidy account manager CLI
* Use tempdir for account manager
* Stop hardcoded testnet dir from creating dir
* Rename Eth2TestnetDir to Eth2TestnetConfig
* Change hardcoded -> hard_coded
* Tidy account manager
* Add log to account manager
* Tidy, ensure head tracker is loaded from disk
* Tidy beacon chain builder
* Tidy eth1_chain
* Adds log support for simulator
* Revert "Adds log support for simulator"
This reverts commit ec77c66a052350f551db145cf20f213823428dd3.
* Adds log support for simulator
* Tidy after self-review
* Change default log level
* Address Michael's delicious PR comments
* Fix off-by-one in tests
2019-12-03 04:28:57 +00:00
|
|
|
}
|
|
|
|
|
2020-04-09 15:13:44 +00:00
|
|
|
/*
|
2020-12-08 05:41:10 +00:00
|
|
|
* Load the eth2 network dir to obtain some additional config values.
|
2020-04-14 02:23:47 +00:00
|
|
|
*/
|
2021-11-16 00:46:12 +00:00
|
|
|
let eth2_network_config = context
|
|
|
|
.eth2_network_config
|
|
|
|
.as_ref()
|
|
|
|
.ok_or("Context is missing eth2 network config")?;
|
2020-04-14 02:23:47 +00:00
|
|
|
|
2020-11-23 23:54:03 +00:00
|
|
|
client_config.eth1.deposit_contract_address = format!("{:?}", spec.deposit_contract_address);
|
2020-04-14 02:23:47 +00:00
|
|
|
client_config.eth1.deposit_contract_deploy_block =
|
2020-12-08 05:41:10 +00:00
|
|
|
eth2_network_config.deposit_contract_deploy_block;
|
2020-04-14 02:23:47 +00:00
|
|
|
client_config.eth1.lowest_cached_block_number =
|
|
|
|
client_config.eth1.deposit_contract_deploy_block;
|
2020-04-30 07:14:57 +00:00
|
|
|
client_config.eth1.follow_distance = spec.eth1_follow_distance;
|
2020-11-27 08:37:44 +00:00
|
|
|
client_config.eth1.node_far_behind_seconds =
|
|
|
|
max(5, spec.eth1_follow_distance / 2) * spec.seconds_per_eth1_block;
|
2020-11-16 23:10:42 +00:00
|
|
|
client_config.eth1.chain_id = spec.deposit_chain_id.into();
|
2020-11-21 00:26:15 +00:00
|
|
|
client_config.eth1.set_block_cache_truncation::<E>(spec);
|
2020-04-14 02:23:47 +00:00
|
|
|
|
2020-11-23 23:54:03 +00:00
|
|
|
info!(
|
|
|
|
log,
|
|
|
|
"Deposit contract";
|
|
|
|
"deploy_block" => client_config.eth1.deposit_contract_deploy_block,
|
|
|
|
"address" => &client_config.eth1.deposit_contract_address
|
|
|
|
);
|
|
|
|
|
2021-03-08 06:27:49 +00:00
|
|
|
// Only append network config bootnodes if discovery is not disabled
|
|
|
|
if !client_config.network.disable_discovery {
|
2021-11-16 00:46:12 +00:00
|
|
|
if let Some(boot_nodes) = ð2_network_config.boot_enr {
|
|
|
|
client_config
|
|
|
|
.network
|
|
|
|
.boot_nodes_enr
|
|
|
|
.extend_from_slice(boot_nodes)
|
2021-03-08 06:27:49 +00:00
|
|
|
}
|
2020-04-14 02:23:47 +00:00
|
|
|
}
|
|
|
|
|
2021-09-22 00:37:28 +00:00
|
|
|
client_config.genesis = if let Some(genesis_state_bytes) =
|
2021-11-16 00:46:12 +00:00
|
|
|
eth2_network_config.genesis_state_bytes.clone()
|
2021-09-22 00:37:28 +00:00
|
|
|
{
|
|
|
|
// Set up weak subjectivity sync, or start from the hardcoded genesis state.
|
|
|
|
if let (Some(initial_state_path), Some(initial_block_path)) = (
|
|
|
|
cli_args.value_of("checkpoint-state"),
|
|
|
|
cli_args.value_of("checkpoint-block"),
|
|
|
|
) {
|
|
|
|
let read = |path: &str| {
|
|
|
|
use std::fs::File;
|
|
|
|
use std::io::Read;
|
|
|
|
File::open(Path::new(path))
|
|
|
|
.and_then(|mut f| {
|
|
|
|
let mut buffer = vec![];
|
|
|
|
f.read_to_end(&mut buffer)?;
|
|
|
|
Ok(buffer)
|
|
|
|
})
|
|
|
|
.map_err(|e| format!("Unable to open {}: {:?}", path, e))
|
|
|
|
};
|
|
|
|
|
|
|
|
let anchor_state_bytes = read(initial_state_path)?;
|
|
|
|
let anchor_block_bytes = read(initial_block_path)?;
|
|
|
|
|
|
|
|
ClientGenesis::WeakSubjSszBytes {
|
|
|
|
genesis_state_bytes,
|
|
|
|
anchor_state_bytes,
|
|
|
|
anchor_block_bytes,
|
|
|
|
}
|
|
|
|
} else if let Some(remote_bn_url) = cli_args.value_of("checkpoint-sync-url") {
|
|
|
|
let url = SensitiveUrl::parse(remote_bn_url)
|
|
|
|
.map_err(|e| format!("Invalid checkpoint sync URL: {:?}", e))?;
|
|
|
|
|
|
|
|
ClientGenesis::CheckpointSyncUrl {
|
|
|
|
genesis_state_bytes,
|
|
|
|
url,
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Note: re-serializing the genesis state is not so efficient, however it avoids adding
|
|
|
|
// trait bounds to the `ClientGenesis` enum. This would have significant flow-on
|
|
|
|
// effects.
|
|
|
|
ClientGenesis::SszBytes {
|
|
|
|
genesis_state_bytes,
|
|
|
|
}
|
|
|
|
}
|
2020-04-09 15:13:44 +00:00
|
|
|
} else {
|
2021-09-22 00:37:28 +00:00
|
|
|
if cli_args.is_present("checkpoint-state") || cli_args.is_present("checkpoint-sync-url") {
|
|
|
|
return Err(
|
|
|
|
"Checkpoint sync is not available for this network as no genesis state is known"
|
|
|
|
.to_string(),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
ClientGenesis::DepositContract
|
|
|
|
};
|
|
|
|
|
|
|
|
if cli_args.is_present("reconstruct-historic-states") {
|
|
|
|
client_config.chain.reconstruct_historic_states = true;
|
2020-04-09 15:13:44 +00:00
|
|
|
}
|
|
|
|
|
2020-08-04 07:44:53 +00:00
|
|
|
let raw_graffiti = if let Some(graffiti) = cli_args.value_of("graffiti") {
|
|
|
|
if graffiti.len() > GRAFFITI_BYTES_LEN {
|
2020-07-14 08:05:02 +00:00
|
|
|
return Err(format!(
|
|
|
|
"Your graffiti is too long! {} bytes maximum!",
|
|
|
|
GRAFFITI_BYTES_LEN
|
|
|
|
));
|
|
|
|
}
|
2020-08-04 07:44:53 +00:00
|
|
|
|
|
|
|
graffiti.as_bytes()
|
2020-11-30 22:55:08 +00:00
|
|
|
} else if cli_args.is_present("private") {
|
|
|
|
b""
|
2020-08-04 07:44:53 +00:00
|
|
|
} else {
|
|
|
|
lighthouse_version::VERSION.as_bytes()
|
|
|
|
};
|
|
|
|
|
|
|
|
let trimmed_graffiti_len = cmp::min(raw_graffiti.len(), GRAFFITI_BYTES_LEN);
|
2020-09-29 03:46:54 +00:00
|
|
|
client_config.graffiti.0[..trimmed_graffiti_len]
|
2020-08-04 07:44:53 +00:00
|
|
|
.copy_from_slice(&raw_graffiti[..trimmed_graffiti_len]);
|
2020-07-14 08:05:02 +00:00
|
|
|
|
2020-10-01 01:41:58 +00:00
|
|
|
if let Some(wss_checkpoint) = cli_args.value_of("wss-checkpoint") {
|
|
|
|
let mut split = wss_checkpoint.split(':');
|
|
|
|
let root_str = split
|
|
|
|
.next()
|
2020-12-03 01:10:26 +00:00
|
|
|
.ok_or("Improperly formatted weak subjectivity checkpoint")?;
|
2020-10-01 01:41:58 +00:00
|
|
|
let epoch_str = split
|
|
|
|
.next()
|
2020-12-03 01:10:26 +00:00
|
|
|
.ok_or("Improperly formatted weak subjectivity checkpoint")?;
|
2020-10-01 01:41:58 +00:00
|
|
|
|
|
|
|
if !root_str.starts_with("0x") {
|
|
|
|
return Err(
|
|
|
|
"Unable to parse weak subjectivity checkpoint root, must have 0x prefix"
|
|
|
|
.to_string(),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if !root_str.chars().count() == 66 {
|
|
|
|
return Err(
|
|
|
|
"Unable to parse weak subjectivity checkpoint root, must have 32 bytes".to_string(),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
let root =
|
|
|
|
Hash256::from_slice(&hex::decode(&root_str[2..]).map_err(|e| {
|
|
|
|
format!("Unable to parse weak subjectivity checkpoint root: {:?}", e)
|
|
|
|
})?);
|
|
|
|
let epoch = Epoch::new(
|
|
|
|
epoch_str
|
|
|
|
.parse()
|
|
|
|
.map_err(|_| "Invalid weak subjectivity checkpoint epoch".to_string())?,
|
|
|
|
);
|
|
|
|
|
|
|
|
client_config.chain.weak_subjectivity_checkpoint = Some(Checkpoint { epoch, root })
|
|
|
|
}
|
|
|
|
|
2020-08-17 10:54:58 +00:00
|
|
|
if let Some(max_skip_slots) = cli_args.value_of("max-skip-slots") {
|
|
|
|
client_config.chain.import_max_skip_slots = match max_skip_slots {
|
|
|
|
"none" => None,
|
|
|
|
n => Some(
|
|
|
|
n.parse()
|
|
|
|
.map_err(|_| "Invalid max-skip-slots".to_string())?,
|
|
|
|
),
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-12-02 02:00:39 +00:00
|
|
|
client_config.chain.max_network_size =
|
2022-01-19 00:24:19 +00:00
|
|
|
lighthouse_network::gossip_max_size(spec.bellatrix_fork_epoch.is_some());
|
2021-11-09 16:42:02 +00:00
|
|
|
|
2020-11-23 03:43:22 +00:00
|
|
|
if cli_args.is_present("slasher") {
|
|
|
|
let slasher_dir = if let Some(slasher_dir) = cli_args.value_of("slasher-dir") {
|
|
|
|
PathBuf::from(slasher_dir)
|
|
|
|
} else {
|
|
|
|
client_config.data_dir.join("slasher_db")
|
|
|
|
};
|
|
|
|
|
|
|
|
let mut slasher_config = slasher::Config::new(slasher_dir);
|
|
|
|
|
|
|
|
if let Some(update_period) = clap_utils::parse_optional(cli_args, "slasher-update-period")?
|
|
|
|
{
|
|
|
|
slasher_config.update_period = update_period;
|
|
|
|
}
|
|
|
|
|
2021-11-08 00:01:09 +00:00
|
|
|
if let Some(slot_offset) =
|
|
|
|
clap_utils::parse_optional::<f64>(cli_args, "slasher-slot-offset")?
|
|
|
|
{
|
|
|
|
if slot_offset.is_finite() {
|
|
|
|
slasher_config.slot_offset = slot_offset;
|
|
|
|
} else {
|
|
|
|
return Err(format!(
|
|
|
|
"invalid float for slasher-slot-offset: {}",
|
|
|
|
slot_offset
|
|
|
|
));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-23 03:43:22 +00:00
|
|
|
if let Some(history_length) =
|
|
|
|
clap_utils::parse_optional(cli_args, "slasher-history-length")?
|
|
|
|
{
|
|
|
|
slasher_config.history_length = history_length;
|
|
|
|
}
|
|
|
|
|
Tweak slasher DB schema and pruning (#1948)
## Issue Addressed
Resolves #1890
## Proposed Changes
Change the slasher database schema to key indexed attestations by `(target_epoch, indexed_attestation_root)` instead of just `indexed_attestation_root`. This allows more straight-forward pruning (linear scan), that is also "re-entrant". By re-entrant, we mean that a pruning pass that gets stuck because of a `MapFull` error can attempt to commit midway, and be resumed later without issue. The previous pruning strategy for indexed attestations did not have this property. There was also a flaw in the previous pruning that could leave "zombie" indexed attestations in the database (ones not referenced by any attester record), which could build up and contribute to bloat (although in practice I think they occur quite infrequently).
## Additional Info
During testing I noticed that a `MapFull` error can still occur during the commit of the transaction itself, which is irritating, but not unbearable. This PR should at least reduce the frequency with which users need to manually resize their DB, and if the `MapFull` on commit rears its ugly head too often we could use a dynamic strategy (temporarily increase the size of the map until the transaction commits).
The extra bytes for the epoch make the database a bit heavier, so the size estimate docs have been updated to reflect this. This is also a breaking schema change, so anyone using a v0 database from a few hours ago will need to drop it and update :sweat_smile:
2020-11-23 21:33:51 +00:00
|
|
|
if let Some(max_db_size_gbs) =
|
|
|
|
clap_utils::parse_optional::<usize>(cli_args, "slasher-max-db-size")?
|
|
|
|
{
|
|
|
|
slasher_config.max_db_size_mbs = max_db_size_gbs * 1024;
|
2020-11-23 03:43:22 +00:00
|
|
|
}
|
|
|
|
|
2021-12-21 08:23:17 +00:00
|
|
|
if let Some(attestation_cache_size) =
|
|
|
|
clap_utils::parse_optional(cli_args, "slasher-att-cache-size")?
|
|
|
|
{
|
|
|
|
slasher_config.attestation_root_cache_size = attestation_cache_size;
|
|
|
|
}
|
|
|
|
|
2020-11-23 03:43:22 +00:00
|
|
|
if let Some(chunk_size) = clap_utils::parse_optional(cli_args, "slasher-chunk-size")? {
|
|
|
|
slasher_config.chunk_size = chunk_size;
|
|
|
|
}
|
|
|
|
|
|
|
|
if let Some(validator_chunk_size) =
|
|
|
|
clap_utils::parse_optional(cli_args, "slasher-validator-chunk-size")?
|
|
|
|
{
|
|
|
|
slasher_config.validator_chunk_size = validator_chunk_size;
|
|
|
|
}
|
|
|
|
|
2020-12-16 03:44:01 +00:00
|
|
|
slasher_config.broadcast = cli_args.is_present("slasher-broadcast");
|
|
|
|
|
2022-08-15 01:30:56 +00:00
|
|
|
if let Some(backend) = clap_utils::parse_optional(cli_args, "slasher-backend")? {
|
|
|
|
slasher_config.backend = backend;
|
|
|
|
}
|
|
|
|
|
2020-11-23 03:43:22 +00:00
|
|
|
client_config.slasher = Some(slasher_config);
|
|
|
|
}
|
|
|
|
|
2021-01-20 19:19:38 +00:00
|
|
|
if cli_args.is_present("validator-monitor-auto") {
|
|
|
|
client_config.validator_monitor_auto = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if let Some(pubkeys) = cli_args.value_of("validator-monitor-pubkeys") {
|
|
|
|
let pubkeys = pubkeys
|
|
|
|
.split(',')
|
|
|
|
.map(PublicKeyBytes::from_str)
|
|
|
|
.collect::<Result<Vec<_>, _>>()
|
|
|
|
.map_err(|e| format!("Invalid --validator-monitor-pubkeys value: {:?}", e))?;
|
|
|
|
client_config
|
|
|
|
.validator_monitor_pubkeys
|
|
|
|
.extend_from_slice(&pubkeys);
|
|
|
|
}
|
|
|
|
|
|
|
|
if let Some(path) = cli_args.value_of("validator-monitor-file") {
|
|
|
|
let string = fs::read(path)
|
|
|
|
.map_err(|e| format!("Unable to read --validator-monitor-file: {}", e))
|
|
|
|
.and_then(|bytes| {
|
|
|
|
String::from_utf8(bytes)
|
|
|
|
.map_err(|e| format!("--validator-monitor-file is not utf8: {}", e))
|
|
|
|
})?;
|
|
|
|
let pubkeys = string
|
|
|
|
.trim_end() // Remove trailing white space
|
|
|
|
.split(',')
|
|
|
|
.map(PublicKeyBytes::from_str)
|
|
|
|
.collect::<Result<Vec<_>, _>>()
|
|
|
|
.map_err(|e| format!("Invalid --validator-monitor-file contents: {:?}", e))?;
|
|
|
|
client_config
|
|
|
|
.validator_monitor_pubkeys
|
|
|
|
.extend_from_slice(&pubkeys);
|
|
|
|
}
|
|
|
|
|
2021-10-19 00:30:40 +00:00
|
|
|
if cli_args.is_present("disable-lock-timeouts") {
|
|
|
|
client_config.chain.enable_lock_timeouts = false;
|
|
|
|
}
|
|
|
|
|
Run fork choice before block proposal (#3168)
## Issue Addressed
Upcoming spec change https://github.com/ethereum/consensus-specs/pull/2878
## Proposed Changes
1. Run fork choice at the start of every slot, and wait for this run to complete before proposing a block.
2. As an optimisation, also run fork choice 3/4 of the way through the slot (at 9s), _dequeueing attestations for the next slot_.
3. Remove the fork choice run from the state advance timer that occurred before advancing the state.
## Additional Info
### Block Proposal Accuracy
This change makes us more likely to propose on top of the correct head in the presence of re-orgs with proposer boost in play. The main scenario that this change is designed to address is described in the linked spec issue.
### Attestation Accuracy
This change _also_ makes us more likely to attest to the correct head. Currently in the case of a skipped slot at `slot` we only run fork choice 9s into `slot - 1`. This means the attestations from `slot - 1` aren't taken into consideration, and any boost applied to the block from `slot - 1` is not removed (it should be). In the language of the linked spec issue, this means we are liable to attest to C, even when the majority voting weight has already caused a re-org to B.
### Why remove the call before the state advance?
If we've run fork choice at the start of the slot then it has already dequeued all the attestations from the previous slot, which are the only ones eligible to influence the head in the current slot. Running fork choice again is unnecessary (unless we run it for the next slot and try to pre-empt a re-org, but I don't currently think this is a great idea).
### Performance
Based on Prater testing this adds about 5-25ms of runtime to block proposal times, which are 500-1000ms on average (and spike to 5s+ sometimes due to state handling issues :cry: ). I believe this is a small enough penalty to enable it by default, with the option to disable it via the new flag `--fork-choice-before-proposal-timeout 0`. Upcoming work on block packing and state representation will also reduce block production times in general, while removing the spikes.
### Implementation
Fork choice gets invoked at the start of the slot via the `per_slot_task` function called from the slot timer. It then uses a condition variable to signal to block production that fork choice has been updated. This is a bit funky, but it seems to work. One downside of the timer-based approach is that it doesn't happen automatically in most of the tests. The test added by this PR has to trigger the run manually.
2022-05-20 05:02:11 +00:00
|
|
|
if let Some(timeout) =
|
|
|
|
clap_utils::parse_optional(cli_args, "fork-choice-before-proposal-timeout")?
|
|
|
|
{
|
|
|
|
client_config.chain.fork_choice_before_proposal_timeout_ms = timeout;
|
|
|
|
}
|
|
|
|
|
2022-07-30 00:22:41 +00:00
|
|
|
client_config.chain.count_unrealized =
|
|
|
|
clap_utils::parse_required(cli_args, "count-unrealized")?;
|
2022-09-05 04:50:47 +00:00
|
|
|
client_config.chain.count_unrealized_full =
|
|
|
|
clap_utils::parse_required::<bool>(cli_args, "count-unrealized-full")?.into();
|
2022-07-25 23:53:26 +00:00
|
|
|
|
2022-08-29 14:34:41 +00:00
|
|
|
client_config.chain.always_reset_payload_statuses =
|
|
|
|
cli_args.is_present("reset-payload-statuses");
|
|
|
|
|
Refactor op pool for speed and correctness (#3312)
## Proposed Changes
This PR has two aims: to speed up attestation packing in the op pool, and to fix bugs in the verification of attester slashings, proposer slashings and voluntary exits. The changes are bundled into a single database schema upgrade (v12).
Attestation packing is sped up by removing several inefficiencies:
- No more recalculation of `attesting_indices` during packing.
- No (unnecessary) examination of the `ParticipationFlags`: a bitfield suffices. See `RewardCache`.
- No re-checking of attestation validity during packing: the `AttestationMap` provides attestations which are "correct by construction" (I have checked this using Hydra).
- No SSZ re-serialization for the clunky `AttestationId` type (it can be removed in a future release).
So far the speed-up seems to be roughly 2-10x, from 500ms down to 50-100ms.
Verification of attester slashings, proposer slashings and voluntary exits is fixed by:
- Tracking the `ForkVersion`s that were used to verify each message inside the `SigVerifiedOp`. This allows us to quickly re-verify that they match the head state's opinion of what the `ForkVersion` should be at the epoch(s) relevant to the message.
- Storing the `SigVerifiedOp` on disk rather than the raw operation. This allows us to continue track the fork versions after a reboot.
This is mostly contained in this commit 52bb1840ae5c4356a8fc3a51e5df23ed65ed2c7f.
## Additional Info
The schema upgrade uses the justified state to re-verify attestations and compute `attesting_indices` for them. It will drop any attestations that fail to verify, by the logic that attestations are most valuable in the few slots after they're observed, and are probably stale and useless by the time a node restarts. Exits and proposer slashings and similarly re-verified to obtain `SigVerifiedOp`s.
This PR contains a runtime killswitch `--paranoid-block-proposal` which opts out of all the optimisations in favour of closely verifying every included message. Although I'm quite sure that the optimisations are correct this flag could be useful in the event of an unforeseen emergency.
Finally, you might notice that the `RewardCache` appears quite useless in its current form because it is only updated on the hot-path immediately before proposal. My hope is that in future we can shift calls to `RewardCache::update` into the background, e.g. while performing the state advance. It is also forward-looking to `tree-states` compatibility, where iterating and indexing `state.{previous,current}_epoch_participation` is expensive and needs to be minimised.
2022-08-29 09:10:26 +00:00
|
|
|
client_config.chain.paranoid_block_proposal = cli_args.is_present("paranoid-block-proposal");
|
|
|
|
|
2022-07-30 00:22:37 +00:00
|
|
|
/*
|
|
|
|
* Builder fallback configs.
|
|
|
|
*/
|
|
|
|
client_config.chain.builder_fallback_skips =
|
|
|
|
clap_utils::parse_required(cli_args, "builder-fallback-skips")?;
|
|
|
|
client_config.chain.builder_fallback_skips_per_epoch =
|
|
|
|
clap_utils::parse_required(cli_args, "builder-fallback-skips-per-epoch")?;
|
|
|
|
client_config
|
|
|
|
.chain
|
|
|
|
.builder_fallback_epochs_since_finalization =
|
|
|
|
clap_utils::parse_required(cli_args, "builder-fallback-epochs-since-finalization")?;
|
|
|
|
client_config.chain.builder_fallback_disable_checks =
|
|
|
|
cli_args.is_present("builder-fallback-disable-checks");
|
|
|
|
|
2020-04-02 07:47:00 +00:00
|
|
|
Ok(client_config)
|
|
|
|
}
|
|
|
|
|
2020-08-21 12:00:01 +00:00
|
|
|
/// Sets the network config from the command line arguments
|
|
|
|
pub fn set_network_config(
|
|
|
|
config: &mut NetworkConfig,
|
|
|
|
cli_args: &ArgMatches,
|
2021-03-26 04:53:57 +00:00
|
|
|
data_dir: &Path,
|
2020-08-21 12:00:01 +00:00
|
|
|
log: &Logger,
|
|
|
|
use_listening_port_as_enr_port_by_default: bool,
|
|
|
|
) -> Result<(), String> {
|
|
|
|
// If a network dir has been specified, override the `datadir` definition.
|
|
|
|
if let Some(dir) = cli_args.value_of("network-dir") {
|
|
|
|
config.network_dir = PathBuf::from(dir);
|
|
|
|
} else {
|
2020-09-29 00:02:44 +00:00
|
|
|
config.network_dir = data_dir.join(DEFAULT_NETWORK_DIR);
|
2020-08-21 12:00:01 +00:00
|
|
|
};
|
|
|
|
|
2020-11-13 06:06:33 +00:00
|
|
|
if cli_args.is_present("subscribe-all-subnets") {
|
|
|
|
config.subscribe_all_subnets = true;
|
|
|
|
}
|
|
|
|
|
2020-11-22 23:58:25 +00:00
|
|
|
if cli_args.is_present("import-all-attestations") {
|
|
|
|
config.import_all_attestations = true;
|
|
|
|
}
|
|
|
|
|
2021-08-30 13:46:13 +00:00
|
|
|
if cli_args.is_present("shutdown-after-sync") {
|
|
|
|
config.shutdown_after_sync = true;
|
|
|
|
}
|
|
|
|
|
2020-08-21 12:00:01 +00:00
|
|
|
if let Some(listen_address_str) = cli_args.value_of("listen-address") {
|
|
|
|
let listen_address = listen_address_str
|
|
|
|
.parse()
|
|
|
|
.map_err(|_| format!("Invalid listen address: {:?}", listen_address_str))?;
|
|
|
|
config.listen_address = listen_address;
|
|
|
|
}
|
|
|
|
|
|
|
|
if let Some(target_peers_str) = cli_args.value_of("target-peers") {
|
|
|
|
config.target_peers = target_peers_str
|
|
|
|
.parse::<usize>()
|
|
|
|
.map_err(|_| format!("Invalid number of target peers: {}", target_peers_str))?;
|
|
|
|
}
|
|
|
|
|
|
|
|
if let Some(port_str) = cli_args.value_of("port") {
|
|
|
|
let port = port_str
|
|
|
|
.parse::<u16>()
|
|
|
|
.map_err(|_| format!("Invalid port: {}", port_str))?;
|
|
|
|
config.libp2p_port = port;
|
|
|
|
config.discovery_port = port;
|
|
|
|
}
|
|
|
|
|
|
|
|
if let Some(port_str) = cli_args.value_of("discovery-port") {
|
|
|
|
let port = port_str
|
|
|
|
.parse::<u16>()
|
|
|
|
.map_err(|_| format!("Invalid port: {}", port_str))?;
|
|
|
|
config.discovery_port = port;
|
|
|
|
}
|
|
|
|
|
2022-01-14 05:42:47 +00:00
|
|
|
if let Some(value) = cli_args.value_of("network-load") {
|
|
|
|
let network_load = value
|
|
|
|
.parse::<u8>()
|
|
|
|
.map_err(|_| format!("Invalid integer: {}", value))?;
|
|
|
|
config.network_load = network_load;
|
|
|
|
}
|
|
|
|
|
2020-08-21 12:00:01 +00:00
|
|
|
if let Some(boot_enr_str) = cli_args.value_of("boot-nodes") {
|
|
|
|
let mut enrs: Vec<Enr> = vec![];
|
|
|
|
let mut multiaddrs: Vec<Multiaddr> = vec![];
|
|
|
|
for addr in boot_enr_str.split(',') {
|
|
|
|
match addr.parse() {
|
|
|
|
Ok(enr) => enrs.push(enr),
|
|
|
|
Err(_) => {
|
|
|
|
// parsing as ENR failed, try as Multiaddr
|
|
|
|
let multi: Multiaddr = addr
|
|
|
|
.parse()
|
|
|
|
.map_err(|_| format!("Not valid as ENR nor Multiaddr: {}", addr))?;
|
|
|
|
if !multi.iter().any(|proto| matches!(proto, Protocol::Udp(_))) {
|
|
|
|
slog::error!(log, "Missing UDP in Multiaddr {}", multi.to_string());
|
|
|
|
}
|
|
|
|
if !multi.iter().any(|proto| matches!(proto, Protocol::P2p(_))) {
|
|
|
|
slog::error!(log, "Missing P2P in Multiaddr {}", multi.to_string());
|
|
|
|
}
|
|
|
|
multiaddrs.push(multi);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
config.boot_nodes_enr = enrs;
|
|
|
|
config.boot_nodes_multiaddr = multiaddrs;
|
|
|
|
}
|
|
|
|
|
|
|
|
if let Some(libp2p_addresses_str) = cli_args.value_of("libp2p-addresses") {
|
|
|
|
config.libp2p_nodes = libp2p_addresses_str
|
|
|
|
.split(',')
|
|
|
|
.map(|multiaddr| {
|
|
|
|
multiaddr
|
|
|
|
.parse()
|
|
|
|
.map_err(|_| format!("Invalid Multiaddr: {}", multiaddr))
|
|
|
|
})
|
|
|
|
.collect::<Result<Vec<Multiaddr>, _>>()?;
|
|
|
|
}
|
|
|
|
|
2020-09-22 01:12:36 +00:00
|
|
|
if let Some(trusted_peers_str) = cli_args.value_of("trusted-peers") {
|
|
|
|
config.trusted_peers = trusted_peers_str
|
|
|
|
.split(',')
|
|
|
|
.map(|peer_id| {
|
|
|
|
peer_id
|
|
|
|
.parse()
|
|
|
|
.map_err(|_| format!("Invalid trusted peer id: {}", peer_id))
|
|
|
|
})
|
|
|
|
.collect::<Result<Vec<PeerIdSerialized>, _>>()?;
|
|
|
|
}
|
|
|
|
|
2020-08-21 12:00:01 +00:00
|
|
|
if let Some(enr_udp_port_str) = cli_args.value_of("enr-udp-port") {
|
|
|
|
config.enr_udp_port = Some(
|
|
|
|
enr_udp_port_str
|
|
|
|
.parse::<u16>()
|
|
|
|
.map_err(|_| format!("Invalid discovery port: {}", enr_udp_port_str))?,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if let Some(enr_tcp_port_str) = cli_args.value_of("enr-tcp-port") {
|
|
|
|
config.enr_tcp_port = Some(
|
|
|
|
enr_tcp_port_str
|
|
|
|
.parse::<u16>()
|
|
|
|
.map_err(|_| format!("Invalid ENR TCP port: {}", enr_tcp_port_str))?,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if cli_args.is_present("enr-match") {
|
|
|
|
// set the enr address to localhost if the address is 0.0.0.0
|
|
|
|
if config.listen_address == "0.0.0.0".parse::<IpAddr>().expect("valid ip addr") {
|
|
|
|
config.enr_address = Some("127.0.0.1".parse::<IpAddr>().expect("valid ip addr"));
|
|
|
|
} else {
|
|
|
|
config.enr_address = Some(config.listen_address);
|
|
|
|
}
|
|
|
|
config.enr_udp_port = Some(config.discovery_port);
|
|
|
|
}
|
|
|
|
|
|
|
|
if let Some(enr_address) = cli_args.value_of("enr-address") {
|
|
|
|
let resolved_addr = match enr_address.parse::<IpAddr>() {
|
|
|
|
Ok(addr) => addr, // // Input is an IpAddr
|
|
|
|
Err(_) => {
|
|
|
|
let mut addr = enr_address.to_string();
|
|
|
|
// Appending enr-port to the dns hostname to appease `to_socket_addrs()` parsing.
|
|
|
|
// Since enr-update is disabled with a dns address, not setting the enr-udp-port
|
|
|
|
// will make the node undiscoverable.
|
2022-02-25 00:10:17 +00:00
|
|
|
if let Some(enr_udp_port) =
|
|
|
|
config
|
|
|
|
.enr_udp_port
|
|
|
|
.or(if use_listening_port_as_enr_port_by_default {
|
|
|
|
Some(config.discovery_port)
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
})
|
|
|
|
{
|
2022-06-30 22:51:49 +00:00
|
|
|
write!(addr, ":{}", enr_udp_port)
|
|
|
|
.map_err(|e| format!("Failed to write enr address {}", e))?;
|
2020-08-21 12:00:01 +00:00
|
|
|
} else {
|
|
|
|
return Err(
|
|
|
|
"enr-udp-port must be set for node to be discoverable with dns address"
|
|
|
|
.into(),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
// `to_socket_addr()` does the dns resolution
|
|
|
|
// Note: `to_socket_addrs()` is a blocking call
|
|
|
|
let resolved_addr = if let Ok(mut resolved_addrs) = addr.to_socket_addrs() {
|
|
|
|
// Pick the first ip from the list of resolved addresses
|
|
|
|
resolved_addrs
|
|
|
|
.next()
|
|
|
|
.map(|a| a.ip())
|
2020-12-03 01:10:26 +00:00
|
|
|
.ok_or("Resolved dns addr contains no entries")?
|
2020-08-21 12:00:01 +00:00
|
|
|
} else {
|
|
|
|
return Err(format!("Failed to parse enr-address: {}", enr_address));
|
|
|
|
};
|
|
|
|
config.discv5_config.enr_update = false;
|
|
|
|
resolved_addr
|
|
|
|
}
|
|
|
|
};
|
|
|
|
config.enr_address = Some(resolved_addr);
|
|
|
|
}
|
|
|
|
|
2020-10-02 08:47:00 +00:00
|
|
|
if cli_args.is_present("disable-enr-auto-update") {
|
2020-08-21 12:00:01 +00:00
|
|
|
config.discv5_config.enr_update = false;
|
|
|
|
}
|
|
|
|
|
2021-08-26 00:29:39 +00:00
|
|
|
if cli_args.is_present("disable-packet-filter") {
|
|
|
|
warn!(log, "Discv5 packet filter is disabled");
|
|
|
|
config.discv5_config.enable_packet_filter = false;
|
|
|
|
}
|
|
|
|
|
2020-08-21 12:00:01 +00:00
|
|
|
if cli_args.is_present("disable-discovery") {
|
|
|
|
config.disable_discovery = true;
|
2020-09-23 01:19:58 +00:00
|
|
|
warn!(log, "Discovery is disabled. New peers will not be found");
|
2020-08-21 12:00:01 +00:00
|
|
|
}
|
|
|
|
|
2020-10-02 08:47:00 +00:00
|
|
|
if cli_args.is_present("disable-upnp") {
|
|
|
|
config.upnp_enabled = false;
|
|
|
|
}
|
|
|
|
|
2020-11-30 22:55:08 +00:00
|
|
|
if cli_args.is_present("private") {
|
|
|
|
config.private = true;
|
|
|
|
}
|
|
|
|
|
2021-11-03 00:06:03 +00:00
|
|
|
if cli_args.is_present("metrics") {
|
|
|
|
config.metrics_enabled = true;
|
|
|
|
}
|
|
|
|
|
2022-03-02 03:14:27 +00:00
|
|
|
if cli_args.is_present("enable-private-discovery") {
|
|
|
|
config.discv5_config.table_filter = |_| true;
|
|
|
|
}
|
|
|
|
|
2020-08-21 12:00:01 +00:00
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
2020-04-02 07:47:00 +00:00
|
|
|
/// Gets the datadir which should be used.
|
|
|
|
pub fn get_data_dir(cli_args: &ArgMatches) -> PathBuf {
|
|
|
|
// Read the `--datadir` flag.
|
|
|
|
//
|
|
|
|
// If it's not present, try and find the home directory (`~`) and push the default data
|
2020-09-29 00:02:44 +00:00
|
|
|
// directory and the testnet name onto it.
|
|
|
|
|
2020-04-02 07:47:00 +00:00
|
|
|
cli_args
|
|
|
|
.value_of("datadir")
|
2020-09-29 00:02:44 +00:00
|
|
|
.map(|path| PathBuf::from(path).join(DEFAULT_BEACON_NODE_DIR))
|
|
|
|
.or_else(|| {
|
|
|
|
dirs::home_dir().map(|home| {
|
|
|
|
home.join(DEFAULT_ROOT_DIR)
|
2020-12-08 05:41:10 +00:00
|
|
|
.join(directory::get_network_dir(cli_args))
|
2020-09-29 00:02:44 +00:00
|
|
|
.join(DEFAULT_BEACON_NODE_DIR)
|
|
|
|
})
|
|
|
|
})
|
2020-04-02 07:47:00 +00:00
|
|
|
.unwrap_or_else(|| PathBuf::from("."))
|
|
|
|
}
|
2022-04-01 00:58:59 +00:00
|
|
|
|
|
|
|
/// Get the `slots_per_restore_point` value to use for the database.
|
2022-04-01 07:16:25 +00:00
|
|
|
///
|
|
|
|
/// Return `(sprp, set_explicitly)` where `set_explicitly` is `true` if the user provided the value.
|
|
|
|
pub fn get_slots_per_restore_point<E: EthSpec>(
|
|
|
|
cli_args: &ArgMatches,
|
|
|
|
) -> Result<(u64, bool), String> {
|
2022-04-01 00:58:59 +00:00
|
|
|
if let Some(slots_per_restore_point) =
|
|
|
|
clap_utils::parse_optional(cli_args, "slots-per-restore-point")?
|
|
|
|
{
|
2022-04-01 07:16:25 +00:00
|
|
|
Ok((slots_per_restore_point, true))
|
2022-04-01 00:58:59 +00:00
|
|
|
} else {
|
2022-04-01 07:16:25 +00:00
|
|
|
let default = std::cmp::min(
|
2022-04-01 00:58:59 +00:00
|
|
|
E::slots_per_historical_root() as u64,
|
|
|
|
store::config::DEFAULT_SLOTS_PER_RESTORE_POINT,
|
2022-04-01 07:16:25 +00:00
|
|
|
);
|
|
|
|
Ok((default, false))
|
2022-04-01 00:58:59 +00:00
|
|
|
}
|
|
|
|
}
|
2022-06-29 09:07:09 +00:00
|
|
|
|
|
|
|
/// Parses the `cli_value` as a comma-separated string of values to be parsed with `parser`.
|
|
|
|
///
|
|
|
|
/// If there is more than one value, log a warning. If there are no values, return an error.
|
|
|
|
pub fn parse_only_one_value<F, T, E>(
|
|
|
|
cli_value: &str,
|
|
|
|
parser: F,
|
|
|
|
flag_name: &str,
|
|
|
|
log: &Logger,
|
|
|
|
) -> Result<T, String>
|
|
|
|
where
|
|
|
|
F: Fn(&str) -> Result<T, E>,
|
|
|
|
E: Debug,
|
|
|
|
{
|
|
|
|
let values = cli_value
|
|
|
|
.split(',')
|
|
|
|
.map(parser)
|
|
|
|
.collect::<Result<Vec<_>, _>>()
|
|
|
|
.map_err(|e| format!("{} contains an invalid value {:?}", flag_name, e))?;
|
|
|
|
|
|
|
|
if values.len() > 1 {
|
|
|
|
warn!(
|
|
|
|
log,
|
|
|
|
"Multiple values provided";
|
|
|
|
"info" => "multiple values are deprecated, only the first value will be used",
|
|
|
|
"count" => values.len(),
|
|
|
|
"flag" => flag_name
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
values
|
|
|
|
.into_iter()
|
|
|
|
.next()
|
|
|
|
.ok_or(format!("Must provide at least one value to {}", flag_name))
|
|
|
|
}
|