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

@@ -5,8 +5,8 @@ use std::fs::File;
use std::io::Write;
use std::time::{SystemTime, UNIX_EPOCH};
use types::{
EthSpec, ExecutionPayloadHeader, ExecutionPayloadHeaderCapella, ExecutionPayloadHeaderMerge,
ForkName,
EthSpec, ExecutionPayloadHeader, ExecutionPayloadHeaderCapella, ExecutionPayloadHeaderDeneb,
ExecutionPayloadHeaderMerge, ForkName,
};
pub fn run<T: EthSpec>(matches: &ArgMatches) -> Result<(), String> {
@@ -40,6 +40,14 @@ pub fn run<T: EthSpec>(matches: &ArgMatches) -> Result<(), String> {
prev_randao: eth1_block_hash.into_root(),
..ExecutionPayloadHeaderCapella::default()
}),
ForkName::Deneb => ExecutionPayloadHeader::Deneb(ExecutionPayloadHeaderDeneb {
gas_limit,
base_fee_per_gas,
timestamp: genesis_time,
block_hash: eth1_block_hash,
prev_randao: eth1_block_hash.into_root(),
..ExecutionPayloadHeaderDeneb::default()
}),
};
let mut file = File::create(file_name).map_err(|_| "Unable to create file".to_string())?;

View File

@@ -433,7 +433,7 @@ fn main() {
.takes_value(true)
.default_value("bellatrix")
.help("The fork for which the execution payload header should be created.")
.possible_values(&["merge", "bellatrix", "capella"])
.possible_values(&["merge", "bellatrix", "capella", "deneb"])
)
)
.subcommand(
@@ -609,6 +609,15 @@ fn main() {
"The epoch at which to enable the Capella hard fork",
),
)
.arg(
Arg::with_name("deneb-fork-epoch")
.long("deneb-fork-epoch")
.value_name("EPOCH")
.takes_value(true)
.help(
"The epoch at which to enable the deneb hard fork",
),
)
.arg(
Arg::with_name("ttd")
.long("ttd")

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())
}
}
}

View File

@@ -78,6 +78,9 @@ pub fn run_parse_ssz<T: EthSpec>(
SignedBeaconBlockCapella::<T>::from_ssz_bytes,
format,
)?,
"SignedBeaconBlockDeneb" => {
decode_and_print(&bytes, SignedBeaconBlockDeneb::<T>::from_ssz_bytes, format)?
}
"BeaconState" => decode_and_print::<BeaconState<T>>(
&bytes,
|bytes| BeaconState::from_ssz_bytes(bytes, spec),
@@ -95,6 +98,10 @@ pub fn run_parse_ssz<T: EthSpec>(
"BeaconStateCapella" => {
decode_and_print(&bytes, BeaconStateCapella::<T>::from_ssz_bytes, format)?
}
"BeaconStateDeneb" => {
decode_and_print(&bytes, BeaconStateDeneb::<T>::from_ssz_bytes, format)?
}
"BlobSidecar" => decode_and_print(&bytes, BlobSidecar::<T>::from_ssz_bytes, format)?,
other => return Err(format!("Unknown type: {}", other)),
};