Update testnet configs, change on-disk format (#1799)

## Issue Addressed

- Related to #1691

## Proposed Changes

- Add `DEPOSIT_CHAIN_ID` and `DEPOSIT_NETWORK_ID` to `config.yaml`.
    - Pass the `DEPOSIT_NETWORK_ID` to the `eth1::Service`.
- Remove the unused `MAX_EPOCHS_PER_CROSSLINK` from the `altona` and `medalla` configs (see [spec commit](2befe90032 (diff-efb845ac2ebd4aafbc23df40f47ce25699255064e99d36d0406d0a14ca7953ec))).
- Change from compressing the whole testnet directory, to only compressing the genesis state file. This is the only file we need to compress and *not* compressing the others makes them work nicely with git.
    - We can modify the boot nodes, configs, etc. without incurring an eternal binary-blob cost on our git history.
    - This change is backwards compatible (i.e., non-breaking).

## Additional Info

NA
This commit is contained in:
Paul Hauner
2020-10-25 22:15:46 +00:00
parent 7453f39d68
commit eba51f0973
29 changed files with 353 additions and 52 deletions

View File

@@ -3,6 +3,18 @@ use std::env;
use std::path::PathBuf;
use types::ChainSpec;
// A macro is used to define this constant so it can be used with `include_bytes!`.
#[macro_export]
macro_rules! testnets_dir {
() => {
"built_in_testnet_configs"
};
}
pub const TESTNETS_DIR: &str = testnets_dir!();
pub const GENESIS_FILE_NAME: &str = "genesis.ssz";
pub const GENESIS_ZIP_FILE_NAME: &str = "genesis.ssz.zip";
/// The core configuration of a Lighthouse beacon node.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(default)]
@@ -51,33 +63,23 @@ impl Eth2Config {
pub struct Eth2NetArchiveAndDirectory<'a> {
pub name: &'a str,
pub unique_id: &'a str,
pub archive_name: &'a str,
pub genesis_is_known: bool,
}
impl<'a> Eth2NetArchiveAndDirectory<'a> {
/// The directory that should be used to store files downloaded for this net.
fn pwd(&self) -> PathBuf {
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(TESTNETS_DIR)
.join(self.unique_id)
}
pub fn dir(&self) -> PathBuf {
self.pwd().join(self.unique_id)
pub fn genesis_state_archive(&self) -> PathBuf {
self.dir().join(GENESIS_ZIP_FILE_NAME)
}
pub fn archive_fullpath(&self) -> PathBuf {
self.pwd().join(self.archive_name)
}
}
#[macro_export]
macro_rules! unique_id {
($name: tt) => {
concat!("testnet_", $name);
};
}
macro_rules! define_net {
@@ -88,8 +90,7 @@ macro_rules! define_net {
pub const ETH2_NET_DIR: Eth2NetArchiveAndDirectory = Eth2NetArchiveAndDirectory {
name: $name,
unique_id: unique_id!($name),
archive_name: concat!(unique_id!($name), ".zip"),
unique_id: $name,
genesis_is_known: $genesis_is_known,
};
@@ -98,7 +99,15 @@ macro_rules! define_net {
#[macro_export]
macro_rules! $macro_title {
($base_dir: tt, $filename: tt) => {
include_bytes!(concat!($base_dir, unique_id!($name), "/", $filename))
include_bytes!(concat!(
$base_dir,
"/",
testnets_dir!(),
"/",
$name,
"/",
$filename
))
};
}
}