Fix trusted setup in lcli::new_testnet

This commit is contained in:
Pawan Dhananjay 2023-01-19 17:45:15 +05:30
parent f04486dc71
commit fd08a2cb0a
No known key found for this signature in database
GPG Key ID: 647E56278D7E9B4C
3 changed files with 20 additions and 4 deletions

1
Cargo.lock generated
View File

@ -3322,6 +3322,7 @@ dependencies = [
"eth2_wallet",
"genesis",
"int_to_bytes",
"kzg",
"lighthouse_network",
"lighthouse_version",
"log",

View File

@ -12,6 +12,7 @@ withdrawals-processing = ["beacon_chain/withdrawals-processing", "store/withdraw
[dependencies]
bls = { path = "../crypto/bls" }
kzg = { path = "../crypto/kzg" }
clap = "2.33.3"
log = "0.4.11"
serde = "1.0.116"

View File

@ -1,7 +1,8 @@
use clap::ArgMatches;
use clap_utils::{parse_optional, parse_required, parse_ssz_optional};
use eth2_hashing::hash;
use eth2_network_config::Eth2NetworkConfig;
use eth2_network_config::{Eth2NetworkConfig, TRUSTED_SETUP};
use kzg::TrustedSetup;
use ssz::Decode;
use ssz::Encode;
use state_processing::process_activations;
@ -13,9 +14,9 @@ use std::str::FromStr;
use std::time::{SystemTime, UNIX_EPOCH};
use types::ExecutionBlockHash;
use types::{
test_utils::generate_deterministic_keypairs, Address, BeaconState, ChainSpec, Config, Eth1Data,
EthSpec, ExecutionPayloadHeader, ExecutionPayloadHeaderMerge, Hash256, Keypair, PublicKey,
Validator,
test_utils::generate_deterministic_keypairs, Address, BeaconState, ChainSpec, Config, Epoch,
Eth1Data, EthSpec, ExecutionPayloadHeader, ExecutionPayloadHeaderMerge, Hash256, Keypair,
PublicKey, Validator,
};
pub fn run<T: EthSpec>(testnet_dir_path: PathBuf, matches: &ArgMatches) -> Result<(), String> {
@ -142,11 +143,24 @@ pub fn run<T: EthSpec>(testnet_dir_path: PathBuf, matches: &ArgMatches) -> Resul
None
};
let kzg_trusted_setup = if let Some(epoch) = spec.eip4844_fork_epoch {
// Only load the trusted setup if the eip4844 fork epoch is set
if epoch != Epoch::max_value() {
let trusted_setup: TrustedSetup = serde_json::from_reader(TRUSTED_SETUP)
.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,
config: Config::from_chain_spec::<T>(&spec),
kzg_trusted_setup,
};
testnet.write_to_file(testnet_dir_path, overwrite_files)