Remove old uses of testnet

This commit is contained in:
Paul Hauner 2021-11-11 14:08:56 +11:00
parent 24966c059d
commit eb35c64afd
No known key found for this signature in database
GPG Key ID: 5E2CFF9B75FA63DF
4 changed files with 22 additions and 22 deletions

View File

@ -84,8 +84,8 @@ pub fn cli_run<E: EthSpec>(matches: &ArgMatches, env: Environment<E>) -> Result<
Timeouts::set_all(Duration::from_secs(env.eth2_config.spec.seconds_per_slot)), Timeouts::set_all(Duration::from_secs(env.eth2_config.spec.seconds_per_slot)),
); );
let testnet_config = env let eth2_network_config = env
.testnet .eth2_network_config
.clone() .clone()
.expect("network should have a valid config"); .expect("network should have a valid config");
@ -95,7 +95,7 @@ pub fn cli_run<E: EthSpec>(matches: &ArgMatches, env: Environment<E>) -> Result<
&client, &client,
&spec, &spec,
stdin_inputs, stdin_inputs,
&testnet_config, &eth2_network_config,
no_wait, no_wait,
))?; ))?;
@ -109,11 +109,11 @@ async fn publish_voluntary_exit<E: EthSpec>(
client: &BeaconNodeHttpClient, client: &BeaconNodeHttpClient,
spec: &ChainSpec, spec: &ChainSpec,
stdin_inputs: bool, stdin_inputs: bool,
testnet_config: &Eth2NetworkConfig, eth2_network_config: &Eth2NetworkConfig,
no_wait: bool, no_wait: bool,
) -> Result<(), String> { ) -> Result<(), String> {
let genesis_data = get_geneisis_data(client).await?; let genesis_data = get_geneisis_data(client).await?;
let testnet_genesis_root = testnet_config let testnet_genesis_root = eth2_network_config
.beacon_state::<E>() .beacon_state::<E>()
.as_ref() .as_ref()
.expect("network should have valid genesis state") .expect("network should have valid genesis state")

View File

@ -82,11 +82,11 @@ pub fn cli_run<T: EthSpec>(
) -> Result<(), String> { ) -> Result<(), String> {
let slashing_protection_db_path = validator_base_dir.join(SLASHING_PROTECTION_FILENAME); let slashing_protection_db_path = validator_base_dir.join(SLASHING_PROTECTION_FILENAME);
let testnet_config = env let eth2_network_config = env
.testnet .eth2_network_config
.ok_or("Unable to get testnet configuration from the environment")?; .ok_or("Unable to get testnet configuration from the environment")?;
let genesis_validators_root = testnet_config let genesis_validators_root = eth2_network_config
.beacon_state::<T>() .beacon_state::<T>()
.map(|state: BeaconState<T>| state.genesis_validators_root()) .map(|state: BeaconState<T>| state.genesis_validators_root())
.map_err(|e| { .map_err(|e| {

View File

@ -58,7 +58,7 @@ pub struct EnvironmentBuilder<E: EthSpec> {
log: Option<Logger>, log: Option<Logger>,
eth_spec_instance: E, eth_spec_instance: E,
eth2_config: Eth2Config, eth2_config: Eth2Config,
testnet: Option<Eth2NetworkConfig>, eth2_network_config: Option<Eth2NetworkConfig>,
} }
impl EnvironmentBuilder<MinimalEthSpec> { impl EnvironmentBuilder<MinimalEthSpec> {
@ -69,7 +69,7 @@ impl EnvironmentBuilder<MinimalEthSpec> {
log: None, log: None,
eth_spec_instance: MinimalEthSpec, eth_spec_instance: MinimalEthSpec,
eth2_config: Eth2Config::minimal(), eth2_config: Eth2Config::minimal(),
testnet: None, eth2_network_config: None,
} }
} }
} }
@ -82,7 +82,7 @@ impl EnvironmentBuilder<MainnetEthSpec> {
log: None, log: None,
eth_spec_instance: MainnetEthSpec, eth_spec_instance: MainnetEthSpec,
eth2_config: Eth2Config::mainnet(), eth2_config: Eth2Config::mainnet(),
testnet: None, eth2_network_config: None,
} }
} }
} }
@ -210,19 +210,19 @@ impl<E: EthSpec> EnvironmentBuilder<E> {
Ok(self) Ok(self)
} }
/// Adds a testnet configuration to the environment. /// Adds a network configuration to the environment.
pub fn eth2_network_config( pub fn eth2_network_config(
mut self, mut self,
eth2_network_config: Eth2NetworkConfig, eth2_network_config: Eth2NetworkConfig,
) -> Result<Self, String> { ) -> Result<Self, String> {
// Create a new chain spec from the default configuration. // Create a new chain spec from the default configuration.
self.eth2_config.spec = eth2_network_config.chain_spec::<E>()?; self.eth2_config.spec = eth2_network_config.chain_spec::<E>()?;
self.testnet = Some(eth2_network_config); self.eth2_network_config = Some(eth2_network_config);
Ok(self) Ok(self)
} }
/// Optionally adds a testnet configuration to the environment. /// Optionally adds a network configuration to the environment.
pub fn optional_eth2_network_config( pub fn optional_eth2_network_config(
self, self,
optional_config: Option<Eth2NetworkConfig>, optional_config: Option<Eth2NetworkConfig>,
@ -249,7 +249,7 @@ impl<E: EthSpec> EnvironmentBuilder<E> {
log: self.log.ok_or("Cannot build environment without log")?, log: self.log.ok_or("Cannot build environment without log")?,
eth_spec_instance: self.eth_spec_instance, eth_spec_instance: self.eth_spec_instance,
eth2_config: self.eth2_config, eth2_config: self.eth2_config,
testnet: self.testnet, eth2_network_config: self.eth2_network_config,
}) })
} }
} }
@ -301,7 +301,7 @@ pub struct Environment<E: EthSpec> {
log: Logger, log: Logger,
eth_spec_instance: E, eth_spec_instance: E,
pub eth2_config: Eth2Config, pub eth2_config: Eth2Config,
pub testnet: Option<Eth2NetworkConfig>, pub eth2_network_config: Option<Eth2NetworkConfig>,
} }
impl<E: EthSpec> Environment<E> { impl<E: EthSpec> Environment<E> {

View File

@ -239,8 +239,8 @@ fn main() {
Builder::from_env(Env::default()).init(); Builder::from_env(Env::default()).init();
} }
let result = get_eth2_network_config(&matches).and_then(|testnet_config| { let result = get_eth2_network_config(&matches).and_then(|eth2_network_config| {
let eth_spec_id = testnet_config.eth_spec_id()?; let eth_spec_id = eth2_network_config.eth_spec_id()?;
// boot node subcommand circumvents the environment // boot node subcommand circumvents the environment
if let Some(bootnode_matches) = matches.subcommand_matches("boot_node") { if let Some(bootnode_matches) = matches.subcommand_matches("boot_node") {
@ -256,9 +256,9 @@ fn main() {
} }
match eth_spec_id { match eth_spec_id {
EthSpecId::Mainnet => run(EnvironmentBuilder::mainnet(), &matches, testnet_config), EthSpecId::Mainnet => run(EnvironmentBuilder::mainnet(), &matches, eth2_network_config),
#[cfg(feature = "spec-minimal")] #[cfg(feature = "spec-minimal")]
EthSpecId::Minimal => run(EnvironmentBuilder::minimal(), &matches, testnet_config), EthSpecId::Minimal => run(EnvironmentBuilder::minimal(), &matches, eth2_network_config),
#[cfg(not(feature = "spec-minimal"))] #[cfg(not(feature = "spec-minimal"))]
other => { other => {
eprintln!( eprintln!(
@ -288,7 +288,7 @@ fn main() {
fn run<E: EthSpec>( fn run<E: EthSpec>(
environment_builder: EnvironmentBuilder<E>, environment_builder: EnvironmentBuilder<E>,
matches: &ArgMatches, matches: &ArgMatches,
testnet_config: Eth2NetworkConfig, eth2_network_config: Eth2NetworkConfig,
) -> Result<(), String> { ) -> Result<(), String> {
if std::mem::size_of::<usize>() != 8 { if std::mem::size_of::<usize>() != 8 {
return Err(format!( return Err(format!(
@ -357,7 +357,7 @@ fn run<E: EthSpec>(
let mut environment = builder let mut environment = builder
.multi_threaded_tokio_runtime()? .multi_threaded_tokio_runtime()?
.optional_eth2_network_config(Some(testnet_config))? .optional_eth2_network_config(Some(eth2_network_config))?
.build()?; .build()?;
let log = environment.core_context().log().clone(); let log = environment.core_context().log().clone();