Merge remote-tracking branch 'origin/deneb-free-blobs' into tree-states

This commit is contained in:
Michael Sproul
2023-09-29 16:34:29 +10:00
253 changed files with 21791 additions and 3122 deletions

View File

@@ -1,11 +1,12 @@
use account_utils::eth2_keystore::keypair_from_secret;
use clap::ArgMatches;
use clap_utils::{parse_optional, parse_required, parse_ssz_optional};
use eth2_network_config::{Eth2NetworkConfig, GenesisStateSource};
use eth2_network_config::{get_trusted_setup, Eth2NetworkConfig, GenesisStateSource};
use eth2_wallet::bip39::Seed;
use eth2_wallet::bip39::{Language, Mnemonic};
use eth2_wallet::{recover_validator_secret_from_mnemonic, KeyType};
use ethereum_hashing::hash;
use kzg::TrustedSetup;
use ssz::Decode;
use ssz::Encode;
use state_processing::process_activations;
@@ -20,8 +21,8 @@ use types::ExecutionBlockHash;
use types::{
test_utils::generate_deterministic_keypairs, Address, BeaconState, ChainSpec, Config, Epoch,
Eth1Data, EthSpec, ExecutionPayloadHeader, ExecutionPayloadHeaderCapella,
ExecutionPayloadHeaderMerge, ExecutionPayloadHeaderRefMut, ForkName, Hash256, Keypair,
PublicKey, Validator, ValidatorMutable,
ExecutionPayloadHeaderDeneb, ExecutionPayloadHeaderMerge, ExecutionPayloadHeaderRefMut,
ForkName, Hash256, Keypair, PublicKey, Validator, ValidatorMutable,
};
pub fn run<T: EthSpec>(testnet_dir_path: PathBuf, matches: &ArgMatches) -> Result<(), String> {
@@ -86,6 +87,10 @@ pub fn run<T: EthSpec>(testnet_dir_path: PathBuf, matches: &ArgMatches) -> Resul
spec.capella_fork_epoch = Some(fork_epoch);
}
if let Some(fork_epoch) = parse_optional(matches, "deneb-fork-epoch")? {
spec.deneb_fork_epoch = Some(fork_epoch);
}
if let Some(ttd) = parse_optional(matches, "ttd")? {
spec.terminal_total_difficulty = ttd;
}
@@ -112,6 +117,10 @@ pub fn run<T: EthSpec>(testnet_dir_path: PathBuf, matches: &ArgMatches) -> Resul
ExecutionPayloadHeaderCapella::<T>::from_ssz_bytes(bytes.as_slice())
.map(ExecutionPayloadHeader::Capella)
}
ForkName::Deneb => {
ExecutionPayloadHeaderDeneb::<T>::from_ssz_bytes(bytes.as_slice())
.map(ExecutionPayloadHeader::Deneb)
}
}
.map_err(|e| format!("SSZ decode failed: {:?}", e))
})
@@ -188,12 +197,26 @@ pub fn run<T: EthSpec>(testnet_dir_path: PathBuf, matches: &ArgMatches) -> Resul
None
};
let kzg_trusted_setup = if let Some(epoch) = spec.deneb_fork_epoch {
// Only load the trusted setup if the deneb fork epoch is set
if epoch != Epoch::max_value() {
let trusted_setup: TrustedSetup =
serde_json::from_reader(get_trusted_setup::<T::Kzg>())
.map_err(|e| format!("Unable to read trusted setup file: {}", e))?;
Some(trusted_setup)
} else {
None
}
} else {
None
};
let testnet = Eth2NetworkConfig {
deposit_contract_deploy_block,
boot_enr: Some(vec![]),
genesis_state_bytes: genesis_state_bytes.map(Into::into),
genesis_state_source: GenesisStateSource::IncludedBytes,
config: Config::from_chain_spec::<T>(&spec),
kzg_trusted_setup,
};
testnet.write_to_file(testnet_dir_path, overwrite_files)
@@ -303,6 +326,9 @@ fn initialize_state_with_validators<T: EthSpec>(
ExecutionPayloadHeaderRefMut::Capella(_) => {
return Err("Cannot start genesis from a capella state".to_string())
}
ExecutionPayloadHeaderRefMut::Deneb(_) => {
return Err("Cannot start genesis from a deneb state".to_string())
}
}
}