diff --git a/.gitignore b/.gitignore index d6b4306ef..9376efc76 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ flamegraph.svg perf.data* *.tar.gz /bin +genesis.ssz diff --git a/common/eth2_network_config/build.rs b/common/eth2_network_config/build.rs index f6a07171f..2879925dd 100644 --- a/common/eth2_network_config/build.rs +++ b/common/eth2_network_config/build.rs @@ -1,5 +1,4 @@ -//! Downloads a network configuration from Github. - +//! Extracts zipped genesis states on first run. use eth2_config::{ altona, mainnet, medalla, pyrmont, spadina, toledo, Eth2NetArchiveAndDirectory, GENESIS_FILE_NAME, @@ -31,7 +30,16 @@ fn main() { /// Uncompress the network configs archive into a network configs folder. fn uncompress_state(network: &Eth2NetArchiveAndDirectory<'static>) -> Result<(), String> { + let genesis_ssz_path = network.dir().join(GENESIS_FILE_NAME); + + // Take care to not overwrite the genesis.ssz if it already exists, as that causes + // spurious rebuilds. + if genesis_ssz_path.exists() { + return Ok(()); + } + if network.genesis_is_known { + // Extract genesis state from genesis.ssz.zip let archive_path = network.genesis_state_archive(); let archive_file = File::open(&archive_path) .map_err(|e| format!("Failed to open archive file {:?}: {:?}", archive_path, e))?; @@ -45,18 +53,14 @@ fn uncompress_state(network: &Eth2NetArchiveAndDirectory<'static>) -> Result<(), GENESIS_FILE_NAME, e ) })?; - let path = network.dir().join(GENESIS_FILE_NAME); - let mut outfile = File::create(&path) - .map_err(|e| format!("Error while creating file {:?}: {}", path, e))?; + let mut outfile = File::create(&genesis_ssz_path) + .map_err(|e| format!("Error while creating file {:?}: {}", genesis_ssz_path, e))?; io::copy(&mut file, &mut outfile) - .map_err(|e| format!("Error writing file {:?}: {}", path, e))?; + .map_err(|e| format!("Error writing file {:?}: {}", genesis_ssz_path, e))?; } else { // Create empty genesis.ssz if genesis is unknown - let genesis_file = network.dir().join(GENESIS_FILE_NAME); - if !genesis_file.exists() { - File::create(genesis_file) - .map_err(|e| format!("Failed to create {}: {}", GENESIS_FILE_NAME, e))?; - } + File::create(genesis_ssz_path) + .map_err(|e| format!("Failed to create {}: {}", GENESIS_FILE_NAME, e))?; } Ok(()) diff --git a/common/eth2_network_config/built_in_network_configs/altona/genesis.ssz b/common/eth2_network_config/built_in_network_configs/altona/genesis.ssz deleted file mode 100644 index 7a91759df..000000000 Binary files a/common/eth2_network_config/built_in_network_configs/altona/genesis.ssz and /dev/null differ diff --git a/common/eth2_network_config/built_in_network_configs/mainnet/genesis.ssz b/common/eth2_network_config/built_in_network_configs/mainnet/genesis.ssz deleted file mode 100644 index f68d0e967..000000000 Binary files a/common/eth2_network_config/built_in_network_configs/mainnet/genesis.ssz and /dev/null differ diff --git a/common/eth2_network_config/built_in_network_configs/medalla/genesis.ssz b/common/eth2_network_config/built_in_network_configs/medalla/genesis.ssz deleted file mode 100644 index 6691c8992..000000000 Binary files a/common/eth2_network_config/built_in_network_configs/medalla/genesis.ssz and /dev/null differ diff --git a/common/eth2_network_config/built_in_network_configs/pyrmont/genesis.ssz b/common/eth2_network_config/built_in_network_configs/pyrmont/genesis.ssz deleted file mode 100644 index c566d7e04..000000000 Binary files a/common/eth2_network_config/built_in_network_configs/pyrmont/genesis.ssz and /dev/null differ diff --git a/common/eth2_network_config/built_in_network_configs/spadina/genesis.ssz b/common/eth2_network_config/built_in_network_configs/spadina/genesis.ssz deleted file mode 100644 index ccc90a001..000000000 Binary files a/common/eth2_network_config/built_in_network_configs/spadina/genesis.ssz and /dev/null differ diff --git a/common/eth2_network_config/built_in_network_configs/toledo/genesis.ssz b/common/eth2_network_config/built_in_network_configs/toledo/genesis.ssz deleted file mode 100644 index a5b588a9f..000000000 Binary files a/common/eth2_network_config/built_in_network_configs/toledo/genesis.ssz and /dev/null differ diff --git a/common/eth2_network_config/built_in_network_configs/zinken/genesis.ssz b/common/eth2_network_config/built_in_network_configs/zinken/genesis.ssz deleted file mode 100644 index f645a7f24..000000000 Binary files a/common/eth2_network_config/built_in_network_configs/zinken/genesis.ssz and /dev/null differ