This commit is contained in:
realbigsean
2022-12-30 11:00:14 -05:00
parent 222a514506
commit d8f7277beb
18 changed files with 109 additions and 302 deletions

View File

@@ -9,8 +9,9 @@ use std::io::Read;
use std::path::PathBuf;
use std::time::{SystemTime, UNIX_EPOCH};
use types::{
test_utils::generate_deterministic_keypairs, Address, Config, EthSpec, ExecutionPayloadHeader,
ExecutionPayloadHeaderMerge,
test_utils::generate_deterministic_keypairs, Address, Config, Epoch, EthSpec,
ExecutionPayloadHeader, ExecutionPayloadHeaderCapella, ExecutionPayloadHeaderEip4844,
ExecutionPayloadHeaderMerge, ForkName,
};
pub fn run<T: EthSpec>(testnet_dir_path: PathBuf, matches: &ArgMatches) -> Result<(), String> {
@@ -80,10 +81,25 @@ pub fn run<T: EthSpec>(testnet_dir_path: PathBuf, matches: &ArgMatches) -> Resul
.map_err(|e| format!("Unable to open {}: {}", filename, e))?;
file.read_to_end(&mut bytes)
.map_err(|e| format!("Unable to read {}: {}", filename, e))?;
//FIXME(sean)
ExecutionPayloadHeaderMerge::<T>::from_ssz_bytes(bytes.as_slice())
.map(ExecutionPayloadHeader::Merge)
.map_err(|e| format!("SSZ decode failed: {:?}", e))
let fork_name = spec.fork_name_at_epoch(Epoch::new(0));
match fork_name {
ForkName::Base | ForkName::Altair => Err(ssz::DecodeError::BytesInvalid(
"genesis fork must be post-merge".to_string(),
)),
ForkName::Merge => {
ExecutionPayloadHeaderMerge::<T>::from_ssz_bytes(bytes.as_slice())
.map(ExecutionPayloadHeader::Merge)
}
ForkName::Capella => {
ExecutionPayloadHeaderCapella::<T>::from_ssz_bytes(bytes.as_slice())
.map(ExecutionPayloadHeader::Capella)
}
ForkName::Eip4844 => {
ExecutionPayloadHeaderEip4844::<T>::from_ssz_bytes(bytes.as_slice())
.map(ExecutionPayloadHeader::Eip4844)
}
}
.map_err(|e| format!("SSZ decode failed: {:?}", e))
})
.transpose()?;