Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - Static testnet configs #1603

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
135 changes: 52 additions & 83 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 19 additions & 10 deletions common/eth2_config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,22 +48,29 @@ impl Eth2Config {
/// Used by the `eth2_testnet_config` crate to initialize testnet directories during build and
/// access them at runtime.
#[derive(Copy, Clone, Debug, PartialEq)]
pub struct Eth2NetDirectory<'a> {
pub struct Eth2NetArchiveAndDirectory<'a> {
pub name: &'a str,
pub unique_id: &'a str,
pub archive_name: &'a str,
pub commit: &'a str,
pub url_template: &'a str,
pub genesis_is_known: bool,
}

impl<'a> Eth2NetDirectory<'a> {
impl<'a> Eth2NetArchiveAndDirectory<'a> {
/// The directory that should be used to store files downloaded for this net.
pub fn dir(&self) -> PathBuf {
fn pwd(&self) -> PathBuf {
env::var("CARGO_MANIFEST_DIR")
.expect("should know manifest dir")
.parse::<PathBuf>()
.expect("should parse manifest dir as path")
.join(self.unique_id)
}

pub fn dir(&self) -> PathBuf {
self.pwd().join(self.unique_id)
}

pub fn archive_fullpath(&self) -> PathBuf {
self.pwd().join(self.archive_name)
}
}

Expand All @@ -72,19 +79,23 @@ macro_rules! unique_id {
($name: tt, $commit: tt, $genesis_is_known: tt) => {
concat!("testnet_", $name, "_", $commit, "_", $genesis_is_known);
};

($name: tt, $commit: tt) => {
concat!("testnet_", $name, "_", $commit, ".zip");
};
}

macro_rules! define_net {
($title: ident, $macro_title: tt, $name: tt, $commit: tt, $url_template: tt, $genesis_is_known: tt) => {
($title: ident, $macro_title: tt, $name: tt, $commit: tt, $genesis_is_known: tt) => {
#[macro_use]
pub mod $title {
use super::*;

pub const ETH2_NET_DIR: Eth2NetDirectory = Eth2NetDirectory {
pub const ETH2_NET_DIR: Eth2NetArchiveAndDirectory = Eth2NetArchiveAndDirectory {
name: $name,
unique_id: unique_id!($name, $commit, $genesis_is_known),
archive_name: unique_id!($name, $commit),
commit: $commit,
url_template: $url_template,
genesis_is_known: $genesis_is_known,
};

Expand All @@ -110,7 +121,6 @@ define_net!(
include_altona_file,
"altona",
"a94e00c1a03df851f960fcf44a79f2a6b1d29af1",
"https://raw.githubusercontent.com/sigp/witti/{{ commit }}/altona/lighthouse/{{ file }}",
true
);

Expand All @@ -119,7 +129,6 @@ define_net!(
include_medalla_file,
"medalla",
"09bbf2c9d108944ac934f94ec6a1d0684ca062a5",
"https://raw.githubusercontent.com/sigp/witti/{{ commit }}/medalla/{{ file }}",
true
);

Expand Down
2 changes: 1 addition & 1 deletion common/eth2_testnet_config/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
testnet*
testnet*/*
schlesi-*
witti-*
altona*
6 changes: 2 additions & 4 deletions common/eth2_testnet_config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ edition = "2018"
build = "build.rs"

[build-dependencies]
reqwest = { version = "0.10.4", features = ["blocking", "native-tls-vendored"] }
zip = "0.5"
eth2_config = { path = "../eth2_config"}
handlebars = "3.3.0"
serde_json = "1.0.56"

[dev-dependencies]
tempdir = "0.3.7"
Expand All @@ -21,4 +19,4 @@ serde_yaml = "0.8.11"
types = { path = "../../consensus/types"}
enr = { version = "0.1.0", features = ["libsecp256k1", "ed25519"] }
eth2_ssz = "0.1.2"
eth2_config = { path = "../eth2_config"}
eth2_config = { path = "../eth2_config"}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a newline here

Loading