lighthouse/common/eth2_config/src/lib.rs

292 lines
11 KiB
Rust
Raw Normal View History

//! This crate primarily exists to serve the `common/eth2_network_configs` crate, by providing the
//! canonical list of built-in-networks and some tooling to help include those configurations in the
//! `lighthouse` binary.
//!
//! It also provides some additional structs which are useful to other components of `lighthouse`
//! (e.g., `Eth2Config`).
use std::env;
use std::path::PathBuf;
use types::{ChainSpec, EthSpecId};
2019-06-08 17:17:03 +00:00
pub use paste::paste;
// A macro is used to define this constant so it can be used with `include_bytes!`.
#[macro_export]
macro_rules! predefined_networks_dir {
() => {
"built_in_network_configs"
};
}
pub const PREDEFINED_NETWORKS_DIR: &str = predefined_networks_dir!();
pub const GENESIS_FILE_NAME: &str = "genesis.ssz";
pub const GENESIS_ZIP_FILE_NAME: &str = "genesis.ssz.zip";
2019-06-08 17:17:03 +00:00
/// The core configuration of a Lighthouse beacon node.
#[derive(Debug, Clone)]
2019-06-08 17:17:03 +00:00
pub struct Eth2Config {
pub eth_spec_id: EthSpecId,
2019-06-08 17:17:03 +00:00
pub spec: ChainSpec,
}
impl Default for Eth2Config {
fn default() -> Self {
Self {
eth_spec_id: EthSpecId::Minimal,
2019-06-08 17:17:03 +00:00
spec: ChainSpec::minimal(),
}
}
}
impl Eth2Config {
pub fn mainnet() -> Self {
Self {
eth_spec_id: EthSpecId::Mainnet,
spec: ChainSpec::mainnet(),
}
}
pub fn minimal() -> Self {
Self {
eth_spec_id: EthSpecId::Minimal,
spec: ChainSpec::minimal(),
}
}
pub fn gnosis() -> Self {
Self {
eth_spec_id: EthSpecId::Gnosis,
spec: ChainSpec::gnosis(),
}
}
}
/// A directory that can be built by downloading files via HTTP.
///
/// Used by the `eth2_network_config` crate to initialize the network directories during build and
/// access them at runtime.
#[derive(Copy, Clone, Debug, PartialEq)]
pub struct Eth2NetArchiveAndDirectory<'a> {
pub name: &'a str,
Add Goerli `--network` flag as duplicate of Prater: Option A (#3346) ## Issue Addressed - Resolves #3338 ## Proposed Changes This PR adds a new `--network goerli` flag that reuses the [Prater network configs](https://github.com/sigp/lighthouse/tree/stable/common/eth2_network_config/built_in_network_configs/prater). As you'll see in #3338, there are several approaches to the problem of the Goerli/Prater alias. This approach achieves: 1. No duplication of the genesis state between Goerli and Prater. - Upside: the genesis state for Prater is ~17mb, duplication would increase the size of the binary by that much. 2. When the user supplies `--network goerli`, they will get a datadir in `~/.lighthouse/goerli`. - Upside: our docs stay correct when they declare a datadir is located at `~/.lighthouse/{network}` - Downside: switching from `--network prater` to `--network goerli` will require some manual migration. 3. When using `--network goerli`, the [`config/spec`](https://ethereum.github.io/beacon-APIs/#/Config/getSpec) endpoint will return a [`CONFIG_NAME`](https://github.com/ethereum/consensus-specs/blob/02a2b71d64fcf5023a8bd890dabce774a6e9802e/configs/mainnet.yaml#L11) of "prater". - Upside: VC running `--network prater` will still think it's on the same network as one using `--network goerli`. - Downside: potentially confusing. #3348 achieves the same goal as this PR with a different approach and set of trade-offs. ## Additional Info ### Notes for reviewers: In https://github.com/sigp/lighthouse/commit/e4896c268217e501ab581ce857d526572b235b91 you'll see that I remove the `$name_str` by just using `stringify!($name_ident)` instead. This is a simplification that should have have been there in the first place. Then, in https://github.com/sigp/lighthouse/commit/90b5e22fca366c1db741c6d8f02902d9e375279f I reclaim that second parameter with a new purpose; to specify the directory from which to load configs.
2022-07-20 23:16:56 +00:00
pub config_dir: &'a str,
pub genesis_is_known: bool,
}
impl<'a> Eth2NetArchiveAndDirectory<'a> {
/// The directory that should be used to store files downloaded for this net.
pub fn dir(&self) -> PathBuf {
env::var("CARGO_MANIFEST_DIR")
.expect("should know manifest dir")
.parse::<PathBuf>()
.expect("should parse manifest dir as path")
.join(PREDEFINED_NETWORKS_DIR)
Add Goerli `--network` flag as duplicate of Prater: Option A (#3346) ## Issue Addressed - Resolves #3338 ## Proposed Changes This PR adds a new `--network goerli` flag that reuses the [Prater network configs](https://github.com/sigp/lighthouse/tree/stable/common/eth2_network_config/built_in_network_configs/prater). As you'll see in #3338, there are several approaches to the problem of the Goerli/Prater alias. This approach achieves: 1. No duplication of the genesis state between Goerli and Prater. - Upside: the genesis state for Prater is ~17mb, duplication would increase the size of the binary by that much. 2. When the user supplies `--network goerli`, they will get a datadir in `~/.lighthouse/goerli`. - Upside: our docs stay correct when they declare a datadir is located at `~/.lighthouse/{network}` - Downside: switching from `--network prater` to `--network goerli` will require some manual migration. 3. When using `--network goerli`, the [`config/spec`](https://ethereum.github.io/beacon-APIs/#/Config/getSpec) endpoint will return a [`CONFIG_NAME`](https://github.com/ethereum/consensus-specs/blob/02a2b71d64fcf5023a8bd890dabce774a6e9802e/configs/mainnet.yaml#L11) of "prater". - Upside: VC running `--network prater` will still think it's on the same network as one using `--network goerli`. - Downside: potentially confusing. #3348 achieves the same goal as this PR with a different approach and set of trade-offs. ## Additional Info ### Notes for reviewers: In https://github.com/sigp/lighthouse/commit/e4896c268217e501ab581ce857d526572b235b91 you'll see that I remove the `$name_str` by just using `stringify!($name_ident)` instead. This is a simplification that should have have been there in the first place. Then, in https://github.com/sigp/lighthouse/commit/90b5e22fca366c1db741c6d8f02902d9e375279f I reclaim that second parameter with a new purpose; to specify the directory from which to load configs.
2022-07-20 23:16:56 +00:00
.join(self.config_dir)
}
pub fn genesis_state_archive(&self) -> PathBuf {
self.dir().join(GENESIS_ZIP_FILE_NAME)
}
}
/// Indicates that the `genesis.ssz.zip` file is present on the filesystem. This means that the
/// deposit ceremony has concluded and the final genesis `BeaconState` is known.
const GENESIS_STATE_IS_KNOWN: bool = true;
#[derive(Copy, Clone, Debug, PartialEq)]
pub struct HardcodedNet {
pub name: &'static str,
Add Goerli `--network` flag as duplicate of Prater: Option A (#3346) ## Issue Addressed - Resolves #3338 ## Proposed Changes This PR adds a new `--network goerli` flag that reuses the [Prater network configs](https://github.com/sigp/lighthouse/tree/stable/common/eth2_network_config/built_in_network_configs/prater). As you'll see in #3338, there are several approaches to the problem of the Goerli/Prater alias. This approach achieves: 1. No duplication of the genesis state between Goerli and Prater. - Upside: the genesis state for Prater is ~17mb, duplication would increase the size of the binary by that much. 2. When the user supplies `--network goerli`, they will get a datadir in `~/.lighthouse/goerli`. - Upside: our docs stay correct when they declare a datadir is located at `~/.lighthouse/{network}` - Downside: switching from `--network prater` to `--network goerli` will require some manual migration. 3. When using `--network goerli`, the [`config/spec`](https://ethereum.github.io/beacon-APIs/#/Config/getSpec) endpoint will return a [`CONFIG_NAME`](https://github.com/ethereum/consensus-specs/blob/02a2b71d64fcf5023a8bd890dabce774a6e9802e/configs/mainnet.yaml#L11) of "prater". - Upside: VC running `--network prater` will still think it's on the same network as one using `--network goerli`. - Downside: potentially confusing. #3348 achieves the same goal as this PR with a different approach and set of trade-offs. ## Additional Info ### Notes for reviewers: In https://github.com/sigp/lighthouse/commit/e4896c268217e501ab581ce857d526572b235b91 you'll see that I remove the `$name_str` by just using `stringify!($name_ident)` instead. This is a simplification that should have have been there in the first place. Then, in https://github.com/sigp/lighthouse/commit/90b5e22fca366c1db741c6d8f02902d9e375279f I reclaim that second parameter with a new purpose; to specify the directory from which to load configs.
2022-07-20 23:16:56 +00:00
pub config_dir: &'static str,
pub genesis_is_known: bool,
pub config: &'static [u8],
pub deploy_block: &'static [u8],
pub boot_enr: &'static [u8],
pub genesis_state_bytes: &'static [u8],
}
/// Defines an `Eth2NetArchiveAndDirectory` for some network.
///
/// It also defines a `include_<title>_file!` macro which provides a wrapper around
/// `std::include_bytes`, allowing the inclusion of bytes from the specific testnet directory.
macro_rules! define_archive {
Add Goerli `--network` flag as duplicate of Prater: Option A (#3346) ## Issue Addressed - Resolves #3338 ## Proposed Changes This PR adds a new `--network goerli` flag that reuses the [Prater network configs](https://github.com/sigp/lighthouse/tree/stable/common/eth2_network_config/built_in_network_configs/prater). As you'll see in #3338, there are several approaches to the problem of the Goerli/Prater alias. This approach achieves: 1. No duplication of the genesis state between Goerli and Prater. - Upside: the genesis state for Prater is ~17mb, duplication would increase the size of the binary by that much. 2. When the user supplies `--network goerli`, they will get a datadir in `~/.lighthouse/goerli`. - Upside: our docs stay correct when they declare a datadir is located at `~/.lighthouse/{network}` - Downside: switching from `--network prater` to `--network goerli` will require some manual migration. 3. When using `--network goerli`, the [`config/spec`](https://ethereum.github.io/beacon-APIs/#/Config/getSpec) endpoint will return a [`CONFIG_NAME`](https://github.com/ethereum/consensus-specs/blob/02a2b71d64fcf5023a8bd890dabce774a6e9802e/configs/mainnet.yaml#L11) of "prater". - Upside: VC running `--network prater` will still think it's on the same network as one using `--network goerli`. - Downside: potentially confusing. #3348 achieves the same goal as this PR with a different approach and set of trade-offs. ## Additional Info ### Notes for reviewers: In https://github.com/sigp/lighthouse/commit/e4896c268217e501ab581ce857d526572b235b91 you'll see that I remove the `$name_str` by just using `stringify!($name_ident)` instead. This is a simplification that should have have been there in the first place. Then, in https://github.com/sigp/lighthouse/commit/90b5e22fca366c1db741c6d8f02902d9e375279f I reclaim that second parameter with a new purpose; to specify the directory from which to load configs.
2022-07-20 23:16:56 +00:00
($name_ident: ident, $config_dir: tt, $genesis_is_known: ident) => {
paste! {
#[macro_use]
pub mod $name_ident {
use super::*;
pub const ETH2_NET_DIR: Eth2NetArchiveAndDirectory = Eth2NetArchiveAndDirectory {
Add Goerli `--network` flag as duplicate of Prater: Option A (#3346) ## Issue Addressed - Resolves #3338 ## Proposed Changes This PR adds a new `--network goerli` flag that reuses the [Prater network configs](https://github.com/sigp/lighthouse/tree/stable/common/eth2_network_config/built_in_network_configs/prater). As you'll see in #3338, there are several approaches to the problem of the Goerli/Prater alias. This approach achieves: 1. No duplication of the genesis state between Goerli and Prater. - Upside: the genesis state for Prater is ~17mb, duplication would increase the size of the binary by that much. 2. When the user supplies `--network goerli`, they will get a datadir in `~/.lighthouse/goerli`. - Upside: our docs stay correct when they declare a datadir is located at `~/.lighthouse/{network}` - Downside: switching from `--network prater` to `--network goerli` will require some manual migration. 3. When using `--network goerli`, the [`config/spec`](https://ethereum.github.io/beacon-APIs/#/Config/getSpec) endpoint will return a [`CONFIG_NAME`](https://github.com/ethereum/consensus-specs/blob/02a2b71d64fcf5023a8bd890dabce774a6e9802e/configs/mainnet.yaml#L11) of "prater". - Upside: VC running `--network prater` will still think it's on the same network as one using `--network goerli`. - Downside: potentially confusing. #3348 achieves the same goal as this PR with a different approach and set of trade-offs. ## Additional Info ### Notes for reviewers: In https://github.com/sigp/lighthouse/commit/e4896c268217e501ab581ce857d526572b235b91 you'll see that I remove the `$name_str` by just using `stringify!($name_ident)` instead. This is a simplification that should have have been there in the first place. Then, in https://github.com/sigp/lighthouse/commit/90b5e22fca366c1db741c6d8f02902d9e375279f I reclaim that second parameter with a new purpose; to specify the directory from which to load configs.
2022-07-20 23:16:56 +00:00
name: stringify!($name_ident),
config_dir: $config_dir,
genesis_is_known: $genesis_is_known,
};
/// A wrapper around `std::include_bytes` which includes a file from a specific network
/// directory. Used by upstream crates to import files at compile time.
#[macro_export]
macro_rules! [<include_ $name_ident _file>] {
($this_crate: ident, $base_dir: tt, $filename: tt) => {
include_bytes!(concat!(
$base_dir,
"/",
$this_crate::predefined_networks_dir!(),
"/",
Add Goerli `--network` flag as duplicate of Prater: Option A (#3346) ## Issue Addressed - Resolves #3338 ## Proposed Changes This PR adds a new `--network goerli` flag that reuses the [Prater network configs](https://github.com/sigp/lighthouse/tree/stable/common/eth2_network_config/built_in_network_configs/prater). As you'll see in #3338, there are several approaches to the problem of the Goerli/Prater alias. This approach achieves: 1. No duplication of the genesis state between Goerli and Prater. - Upside: the genesis state for Prater is ~17mb, duplication would increase the size of the binary by that much. 2. When the user supplies `--network goerli`, they will get a datadir in `~/.lighthouse/goerli`. - Upside: our docs stay correct when they declare a datadir is located at `~/.lighthouse/{network}` - Downside: switching from `--network prater` to `--network goerli` will require some manual migration. 3. When using `--network goerli`, the [`config/spec`](https://ethereum.github.io/beacon-APIs/#/Config/getSpec) endpoint will return a [`CONFIG_NAME`](https://github.com/ethereum/consensus-specs/blob/02a2b71d64fcf5023a8bd890dabce774a6e9802e/configs/mainnet.yaml#L11) of "prater". - Upside: VC running `--network prater` will still think it's on the same network as one using `--network goerli`. - Downside: potentially confusing. #3348 achieves the same goal as this PR with a different approach and set of trade-offs. ## Additional Info ### Notes for reviewers: In https://github.com/sigp/lighthouse/commit/e4896c268217e501ab581ce857d526572b235b91 you'll see that I remove the `$name_str` by just using `stringify!($name_ident)` instead. This is a simplification that should have have been there in the first place. Then, in https://github.com/sigp/lighthouse/commit/90b5e22fca366c1db741c6d8f02902d9e375279f I reclaim that second parameter with a new purpose; to specify the directory from which to load configs.
2022-07-20 23:16:56 +00:00
$config_dir,
"/",
$filename
))
};
}
}
}
};
}
/// Creates a `HardcodedNet` definition for some network.
#[macro_export]
macro_rules! define_net {
($this_crate: ident, $mod: ident, $include_file: tt) => {{
use $this_crate::$mod::ETH2_NET_DIR;
$this_crate::HardcodedNet {
name: ETH2_NET_DIR.name,
Add Goerli `--network` flag as duplicate of Prater: Option A (#3346) ## Issue Addressed - Resolves #3338 ## Proposed Changes This PR adds a new `--network goerli` flag that reuses the [Prater network configs](https://github.com/sigp/lighthouse/tree/stable/common/eth2_network_config/built_in_network_configs/prater). As you'll see in #3338, there are several approaches to the problem of the Goerli/Prater alias. This approach achieves: 1. No duplication of the genesis state between Goerli and Prater. - Upside: the genesis state for Prater is ~17mb, duplication would increase the size of the binary by that much. 2. When the user supplies `--network goerli`, they will get a datadir in `~/.lighthouse/goerli`. - Upside: our docs stay correct when they declare a datadir is located at `~/.lighthouse/{network}` - Downside: switching from `--network prater` to `--network goerli` will require some manual migration. 3. When using `--network goerli`, the [`config/spec`](https://ethereum.github.io/beacon-APIs/#/Config/getSpec) endpoint will return a [`CONFIG_NAME`](https://github.com/ethereum/consensus-specs/blob/02a2b71d64fcf5023a8bd890dabce774a6e9802e/configs/mainnet.yaml#L11) of "prater". - Upside: VC running `--network prater` will still think it's on the same network as one using `--network goerli`. - Downside: potentially confusing. #3348 achieves the same goal as this PR with a different approach and set of trade-offs. ## Additional Info ### Notes for reviewers: In https://github.com/sigp/lighthouse/commit/e4896c268217e501ab581ce857d526572b235b91 you'll see that I remove the `$name_str` by just using `stringify!($name_ident)` instead. This is a simplification that should have have been there in the first place. Then, in https://github.com/sigp/lighthouse/commit/90b5e22fca366c1db741c6d8f02902d9e375279f I reclaim that second parameter with a new purpose; to specify the directory from which to load configs.
2022-07-20 23:16:56 +00:00
config_dir: ETH2_NET_DIR.config_dir,
genesis_is_known: ETH2_NET_DIR.genesis_is_known,
config: $this_crate::$include_file!($this_crate, "../", "config.yaml"),
deploy_block: $this_crate::$include_file!($this_crate, "../", "deploy_block.txt"),
boot_enr: $this_crate::$include_file!($this_crate, "../", "boot_enr.yaml"),
genesis_state_bytes: $this_crate::$include_file!($this_crate, "../", "genesis.ssz"),
}
}};
}
/// Calls `define_net` on a list of networks, and then defines two more lists:
///
/// - `HARDCODED_NETS`: a list of all the networks defined by this macro.
/// - `HARDCODED_NET_NAMES`: a list of the *names* of the networks defined by this macro.
#[macro_export]
macro_rules! define_nets {
Add Goerli `--network` flag as duplicate of Prater: Option A (#3346) ## Issue Addressed - Resolves #3338 ## Proposed Changes This PR adds a new `--network goerli` flag that reuses the [Prater network configs](https://github.com/sigp/lighthouse/tree/stable/common/eth2_network_config/built_in_network_configs/prater). As you'll see in #3338, there are several approaches to the problem of the Goerli/Prater alias. This approach achieves: 1. No duplication of the genesis state between Goerli and Prater. - Upside: the genesis state for Prater is ~17mb, duplication would increase the size of the binary by that much. 2. When the user supplies `--network goerli`, they will get a datadir in `~/.lighthouse/goerli`. - Upside: our docs stay correct when they declare a datadir is located at `~/.lighthouse/{network}` - Downside: switching from `--network prater` to `--network goerli` will require some manual migration. 3. When using `--network goerli`, the [`config/spec`](https://ethereum.github.io/beacon-APIs/#/Config/getSpec) endpoint will return a [`CONFIG_NAME`](https://github.com/ethereum/consensus-specs/blob/02a2b71d64fcf5023a8bd890dabce774a6e9802e/configs/mainnet.yaml#L11) of "prater". - Upside: VC running `--network prater` will still think it's on the same network as one using `--network goerli`. - Downside: potentially confusing. #3348 achieves the same goal as this PR with a different approach and set of trade-offs. ## Additional Info ### Notes for reviewers: In https://github.com/sigp/lighthouse/commit/e4896c268217e501ab581ce857d526572b235b91 you'll see that I remove the `$name_str` by just using `stringify!($name_ident)` instead. This is a simplification that should have have been there in the first place. Then, in https://github.com/sigp/lighthouse/commit/90b5e22fca366c1db741c6d8f02902d9e375279f I reclaim that second parameter with a new purpose; to specify the directory from which to load configs.
2022-07-20 23:16:56 +00:00
($this_crate: ident, $($name_ident: ident,)+) => {
$this_crate::paste! {
$(
const [<$name_ident:upper>]: $this_crate::HardcodedNet = $this_crate::define_net!($this_crate, $name_ident, [<include_ $name_ident _file>]);
)+
const HARDCODED_NETS: &[$this_crate::HardcodedNet] = &[$([<$name_ident:upper>],)+];
Add Goerli `--network` flag as duplicate of Prater: Option A (#3346) ## Issue Addressed - Resolves #3338 ## Proposed Changes This PR adds a new `--network goerli` flag that reuses the [Prater network configs](https://github.com/sigp/lighthouse/tree/stable/common/eth2_network_config/built_in_network_configs/prater). As you'll see in #3338, there are several approaches to the problem of the Goerli/Prater alias. This approach achieves: 1. No duplication of the genesis state between Goerli and Prater. - Upside: the genesis state for Prater is ~17mb, duplication would increase the size of the binary by that much. 2. When the user supplies `--network goerli`, they will get a datadir in `~/.lighthouse/goerli`. - Upside: our docs stay correct when they declare a datadir is located at `~/.lighthouse/{network}` - Downside: switching from `--network prater` to `--network goerli` will require some manual migration. 3. When using `--network goerli`, the [`config/spec`](https://ethereum.github.io/beacon-APIs/#/Config/getSpec) endpoint will return a [`CONFIG_NAME`](https://github.com/ethereum/consensus-specs/blob/02a2b71d64fcf5023a8bd890dabce774a6e9802e/configs/mainnet.yaml#L11) of "prater". - Upside: VC running `--network prater` will still think it's on the same network as one using `--network goerli`. - Downside: potentially confusing. #3348 achieves the same goal as this PR with a different approach and set of trade-offs. ## Additional Info ### Notes for reviewers: In https://github.com/sigp/lighthouse/commit/e4896c268217e501ab581ce857d526572b235b91 you'll see that I remove the `$name_str` by just using `stringify!($name_ident)` instead. This is a simplification that should have have been there in the first place. Then, in https://github.com/sigp/lighthouse/commit/90b5e22fca366c1db741c6d8f02902d9e375279f I reclaim that second parameter with a new purpose; to specify the directory from which to load configs.
2022-07-20 23:16:56 +00:00
pub const HARDCODED_NET_NAMES: &[&'static str] = &[$(stringify!($name_ident),)+];
}
};
}
/// The canonical macro for defining built-in network configurations.
///
/// This macro will provide:
///
/// - An `Eth2NetArchiveAndDirectory` for each network.
/// - `ETH2_NET_DIRS`: a list of all the above `Eth2NetArchiveAndDirectory`.
/// - The `instantiate_hardcoded_nets` macro (see its documentation).
///
/// ## Design Justification
///
/// Ultimately, this macro serves as a single list of all the networks. The reason it is structured
/// in such a complex web-of-macros way is because two requirements of built-in (hard-coded) networks:
///
/// 1. We must use `std::include_bytes!` to "bake" arbitrary bytes (genesis states, etc) into the binary.
/// 2. We must use a `build.rs` script to decompress the genesis state from a zip file, before we
/// can include those bytes.
///
/// Because of these two constraints, we must first define all of the networks and the paths to
/// their files in this crate. Then, we must use another crate (`eth2_network_configs`) to run a
/// `build.rs` which will unzip the genesis states. Then, that `eth2_network_configs` crate can
/// perform the final step of using `std::include_bytes` to bake the files (bytes) into the binary.
macro_rules! define_hardcoded_nets {
Add Goerli `--network` flag as duplicate of Prater: Option A (#3346) ## Issue Addressed - Resolves #3338 ## Proposed Changes This PR adds a new `--network goerli` flag that reuses the [Prater network configs](https://github.com/sigp/lighthouse/tree/stable/common/eth2_network_config/built_in_network_configs/prater). As you'll see in #3338, there are several approaches to the problem of the Goerli/Prater alias. This approach achieves: 1. No duplication of the genesis state between Goerli and Prater. - Upside: the genesis state for Prater is ~17mb, duplication would increase the size of the binary by that much. 2. When the user supplies `--network goerli`, they will get a datadir in `~/.lighthouse/goerli`. - Upside: our docs stay correct when they declare a datadir is located at `~/.lighthouse/{network}` - Downside: switching from `--network prater` to `--network goerli` will require some manual migration. 3. When using `--network goerli`, the [`config/spec`](https://ethereum.github.io/beacon-APIs/#/Config/getSpec) endpoint will return a [`CONFIG_NAME`](https://github.com/ethereum/consensus-specs/blob/02a2b71d64fcf5023a8bd890dabce774a6e9802e/configs/mainnet.yaml#L11) of "prater". - Upside: VC running `--network prater` will still think it's on the same network as one using `--network goerli`. - Downside: potentially confusing. #3348 achieves the same goal as this PR with a different approach and set of trade-offs. ## Additional Info ### Notes for reviewers: In https://github.com/sigp/lighthouse/commit/e4896c268217e501ab581ce857d526572b235b91 you'll see that I remove the `$name_str` by just using `stringify!($name_ident)` instead. This is a simplification that should have have been there in the first place. Then, in https://github.com/sigp/lighthouse/commit/90b5e22fca366c1db741c6d8f02902d9e375279f I reclaim that second parameter with a new purpose; to specify the directory from which to load configs.
2022-07-20 23:16:56 +00:00
($(($name_ident: ident, $config_dir: tt, $genesis_is_known: ident)),+) => {
$(
Add Goerli `--network` flag as duplicate of Prater: Option A (#3346) ## Issue Addressed - Resolves #3338 ## Proposed Changes This PR adds a new `--network goerli` flag that reuses the [Prater network configs](https://github.com/sigp/lighthouse/tree/stable/common/eth2_network_config/built_in_network_configs/prater). As you'll see in #3338, there are several approaches to the problem of the Goerli/Prater alias. This approach achieves: 1. No duplication of the genesis state between Goerli and Prater. - Upside: the genesis state for Prater is ~17mb, duplication would increase the size of the binary by that much. 2. When the user supplies `--network goerli`, they will get a datadir in `~/.lighthouse/goerli`. - Upside: our docs stay correct when they declare a datadir is located at `~/.lighthouse/{network}` - Downside: switching from `--network prater` to `--network goerli` will require some manual migration. 3. When using `--network goerli`, the [`config/spec`](https://ethereum.github.io/beacon-APIs/#/Config/getSpec) endpoint will return a [`CONFIG_NAME`](https://github.com/ethereum/consensus-specs/blob/02a2b71d64fcf5023a8bd890dabce774a6e9802e/configs/mainnet.yaml#L11) of "prater". - Upside: VC running `--network prater` will still think it's on the same network as one using `--network goerli`. - Downside: potentially confusing. #3348 achieves the same goal as this PR with a different approach and set of trade-offs. ## Additional Info ### Notes for reviewers: In https://github.com/sigp/lighthouse/commit/e4896c268217e501ab581ce857d526572b235b91 you'll see that I remove the `$name_str` by just using `stringify!($name_ident)` instead. This is a simplification that should have have been there in the first place. Then, in https://github.com/sigp/lighthouse/commit/90b5e22fca366c1db741c6d8f02902d9e375279f I reclaim that second parameter with a new purpose; to specify the directory from which to load configs.
2022-07-20 23:16:56 +00:00
define_archive!($name_ident, $config_dir, $genesis_is_known);
)+
pub const ETH2_NET_DIRS: &[Eth2NetArchiveAndDirectory<'static>] = &[$($name_ident::ETH2_NET_DIR,)+];
/// This macro is designed to be called by an external crate. When called, it will
/// define in that external crate:
///
/// - A `HardcodedNet` for each network.
/// - `HARDCODED_NETS`: a list of all the above `HardcodedNet`.
/// - `HARDCODED_NET_NAMES`: a list of all the names of the above `HardcodedNet` (as `&str`).
#[macro_export]
macro_rules! instantiate_hardcoded_nets {
($this_crate: ident) => {
Add Goerli `--network` flag as duplicate of Prater: Option A (#3346) ## Issue Addressed - Resolves #3338 ## Proposed Changes This PR adds a new `--network goerli` flag that reuses the [Prater network configs](https://github.com/sigp/lighthouse/tree/stable/common/eth2_network_config/built_in_network_configs/prater). As you'll see in #3338, there are several approaches to the problem of the Goerli/Prater alias. This approach achieves: 1. No duplication of the genesis state between Goerli and Prater. - Upside: the genesis state for Prater is ~17mb, duplication would increase the size of the binary by that much. 2. When the user supplies `--network goerli`, they will get a datadir in `~/.lighthouse/goerli`. - Upside: our docs stay correct when they declare a datadir is located at `~/.lighthouse/{network}` - Downside: switching from `--network prater` to `--network goerli` will require some manual migration. 3. When using `--network goerli`, the [`config/spec`](https://ethereum.github.io/beacon-APIs/#/Config/getSpec) endpoint will return a [`CONFIG_NAME`](https://github.com/ethereum/consensus-specs/blob/02a2b71d64fcf5023a8bd890dabce774a6e9802e/configs/mainnet.yaml#L11) of "prater". - Upside: VC running `--network prater` will still think it's on the same network as one using `--network goerli`. - Downside: potentially confusing. #3348 achieves the same goal as this PR with a different approach and set of trade-offs. ## Additional Info ### Notes for reviewers: In https://github.com/sigp/lighthouse/commit/e4896c268217e501ab581ce857d526572b235b91 you'll see that I remove the `$name_str` by just using `stringify!($name_ident)` instead. This is a simplification that should have have been there in the first place. Then, in https://github.com/sigp/lighthouse/commit/90b5e22fca366c1db741c6d8f02902d9e375279f I reclaim that second parameter with a new purpose; to specify the directory from which to load configs.
2022-07-20 23:16:56 +00:00
$this_crate::define_nets!($this_crate, $($name_ident,)+);
}
}
};
}
Add --testnet mainnet and start HTTP server before genesis (#1862) ## Issue Addressed NA ## Proposed Changes - Adds support for `--testnet mainnet` - Start HTTP server prior to genesis ## Additional Info **Note: This is an incomplete work-in-progress. Use Lighthouse for mainnet at your own risk.** With this PR, you can check the deposits: ```bash lighthouse --testnet mainnet bn --http ``` ```bash curl localhost:5052/lighthouse/eth1/deposit_cache | jq ``` ```json { "data": [ { "deposit_data": { "pubkey": "0x854980aa9bf2e84723e1fa6ef682e3537257984cc9cb1daea2ce6b268084b414f0bb43206e9fa6fd7a202357d6eb2b0d", "withdrawal_credentials": "0x00cacf703c658b802d55baa2a5c1777500ef5051fc084330d2761bcb6ab6182b", "amount": "32000000000", "signature": "0xace226cdfd9da6b1d827c3a6ab93f91f53e8e090eb6ca5ee7c7c5fe3acc75558240ca9291684a2a7af5cac67f0558d1109cc95309f5cdf8c125185ec9dcd22635f900d791316924aed7c40cff2ffccdac0d44cf496853db678c8c53745b3545b" }, "block_number": 3492981, "index": 0, "signature_is_valid": true }, { "deposit_data": { "pubkey": "0x93da03a71bc4ed163c2f91c8a54ea3ba2461383dd615388fd494670f8ce571b46e698fc8d04b49e4a8ffe653f581806b", "withdrawal_credentials": "0x006ebfbb7c8269a78018c8b810492979561d0404d74ba9c234650baa7524dcc4", "amount": "32000000000", "signature": "0x8d1f4a1683f798a76effcc6e2cdb8c3eed5a79123d201c5ecd4ab91f768a03c30885455b8a952aeec3c02110457f97ae0a60724187b6d4129d7c352f2e1ac19b4210daacd892fe4629ad3260ce2911dceae3890b04ed28267b2d8cb831f6a92d" }, "block_number": 3493427, "index": 1, "signature_is_valid": true }, ```
2020-11-09 05:04:03 +00:00
// Add a new "built-in" network by adding it to the list below.
//
// The last entry must not end with a comma, otherwise compilation will fail.
//
// This is the canonical place for defining the built-in network configurations that are present in
// the `common/eth2_network_config/built_in_network_configs` directory.
//
// Each net is defined as a three-tuple:
//
// 0. The name of the testnet as an "ident" (i.e. something that can be a Rust variable name).
// 1. The human-friendly name of the testnet (i.e. usually with "-" instead of "_").
// 2. A bool indicating if the genesis state is known and present as a `genesis.ssz.zip`.
//
// The directory containing the testnet files should match the human-friendly name (element 1).
define_hardcoded_nets!(
Add Goerli `--network` flag as duplicate of Prater: Option A (#3346) ## Issue Addressed - Resolves #3338 ## Proposed Changes This PR adds a new `--network goerli` flag that reuses the [Prater network configs](https://github.com/sigp/lighthouse/tree/stable/common/eth2_network_config/built_in_network_configs/prater). As you'll see in #3338, there are several approaches to the problem of the Goerli/Prater alias. This approach achieves: 1. No duplication of the genesis state between Goerli and Prater. - Upside: the genesis state for Prater is ~17mb, duplication would increase the size of the binary by that much. 2. When the user supplies `--network goerli`, they will get a datadir in `~/.lighthouse/goerli`. - Upside: our docs stay correct when they declare a datadir is located at `~/.lighthouse/{network}` - Downside: switching from `--network prater` to `--network goerli` will require some manual migration. 3. When using `--network goerli`, the [`config/spec`](https://ethereum.github.io/beacon-APIs/#/Config/getSpec) endpoint will return a [`CONFIG_NAME`](https://github.com/ethereum/consensus-specs/blob/02a2b71d64fcf5023a8bd890dabce774a6e9802e/configs/mainnet.yaml#L11) of "prater". - Upside: VC running `--network prater` will still think it's on the same network as one using `--network goerli`. - Downside: potentially confusing. #3348 achieves the same goal as this PR with a different approach and set of trade-offs. ## Additional Info ### Notes for reviewers: In https://github.com/sigp/lighthouse/commit/e4896c268217e501ab581ce857d526572b235b91 you'll see that I remove the `$name_str` by just using `stringify!($name_ident)` instead. This is a simplification that should have have been there in the first place. Then, in https://github.com/sigp/lighthouse/commit/90b5e22fca366c1db741c6d8f02902d9e375279f I reclaim that second parameter with a new purpose; to specify the directory from which to load configs.
2022-07-20 23:16:56 +00:00
(
// Network name (must be unique among all networks).
mainnet,
// The name of the directory in the `eth2_network_config/built_in_network_configs`
// directory where the configuration files are located for this network.
"mainnet",
// Set to `true` if the genesis state can be found in the `built_in_network_configs`
// directory.
GENESIS_STATE_IS_KNOWN
),
(
// Network name (must be unique among all networks).
prater,
// The name of the directory in the `eth2_network_config/built_in_network_configs`
// directory where the configuration files are located for this network.
"prater",
// Set to `true` if the genesis state can be found in the `built_in_network_configs`
// directory.
GENESIS_STATE_IS_KNOWN
),
(
// Network name (must be unique among all networks).
goerli,
// The name of the directory in the `eth2_network_config/built_in_network_configs`
// directory where the configuration files are located for this network.
//
// The Goerli network is effectively an alias to Prater.
"prater",
// Set to `true` if the genesis state can be found in the `built_in_network_configs`
// directory.
GENESIS_STATE_IS_KNOWN
),
(
// Network name (must be unique among all networks).
gnosis,
// The name of the directory in the `eth2_network_config/built_in_network_configs`
// directory where the configuration files are located for this network.
"gnosis",
// Set to `true` if the genesis state can be found in the `built_in_network_configs`
// directory.
GENESIS_STATE_IS_KNOWN
),
(
// Network name (must be unique among all networks).
sepolia,
// The name of the directory in the `eth2_network_config/built_in_network_configs`
// directory where the configuration files are located for this network.
"sepolia",
// Set to `true` if the genesis state can be found in the `built_in_network_configs`
// directory.
GENESIS_STATE_IS_KNOWN
)
);