Skip to content

Commit

Permalink
Remove old uses of testnet
Browse files Browse the repository at this point in the history
  • Loading branch information
paulhauner committed Nov 11, 2021
1 parent 3178743 commit 954a9c2
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
10 changes: 5 additions & 5 deletions account_manager/src/validator/exit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
);

let testnet_config = env
.testnet
let eth2_network_config = env
.eth2_network_config
.clone()
.expect("network should have a valid config");

Expand All @@ -95,7 +95,7 @@ pub fn cli_run<E: EthSpec>(matches: &ArgMatches, env: Environment<E>) -> Result<
&client,
&spec,
stdin_inputs,
&testnet_config,
&eth2_network_config,
no_wait,
))?;

Expand All @@ -109,11 +109,11 @@ async fn publish_voluntary_exit<E: EthSpec>(
client: &BeaconNodeHttpClient,
spec: &ChainSpec,
stdin_inputs: bool,
testnet_config: &Eth2NetworkConfig,
eth2_network_config: &Eth2NetworkConfig,
no_wait: bool,
) -> Result<(), String> {
let genesis_data = get_geneisis_data(client).await?;
let testnet_genesis_root = testnet_config
let testnet_genesis_root = eth2_network_config
.beacon_state::<E>()
.as_ref()
.expect("network should have valid genesis state")
Expand Down
6 changes: 3 additions & 3 deletions account_manager/src/validator/slashing_protection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ pub fn cli_run<T: EthSpec>(
) -> Result<(), String> {
let slashing_protection_db_path = validator_base_dir.join(SLASHING_PROTECTION_FILENAME);

let testnet_config = env
.testnet
let eth2_network_config = env
.eth2_network_config
.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>()
.map(|state: BeaconState<T>| state.genesis_validators_root())
.map_err(|e| {
Expand Down
16 changes: 8 additions & 8 deletions lighthouse/environment/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub struct EnvironmentBuilder<E: EthSpec> {
log: Option<Logger>,
eth_spec_instance: E,
eth2_config: Eth2Config,
testnet: Option<Eth2NetworkConfig>,
eth2_network_config: Option<Eth2NetworkConfig>,
}

impl EnvironmentBuilder<MinimalEthSpec> {
Expand All @@ -55,7 +55,7 @@ impl EnvironmentBuilder<MinimalEthSpec> {
log: None,
eth_spec_instance: MinimalEthSpec,
eth2_config: Eth2Config::minimal(),
testnet: None,
eth2_network_config: None,
}
}
}
Expand All @@ -68,7 +68,7 @@ impl EnvironmentBuilder<MainnetEthSpec> {
log: None,
eth_spec_instance: MainnetEthSpec,
eth2_config: Eth2Config::mainnet(),
testnet: None,
eth2_network_config: None,
}
}
}
Expand Down Expand Up @@ -216,19 +216,19 @@ impl<E: EthSpec> EnvironmentBuilder<E> {
Ok(self)
}

/// Adds a testnet configuration to the environment.
/// Adds a network configuration to the environment.
pub fn eth2_network_config(
mut self,
eth2_network_config: Eth2NetworkConfig,
) -> Result<Self, String> {
// Create a new chain spec from the default configuration.
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)
}

/// Optionally adds a testnet configuration to the environment.
/// Optionally adds a network configuration to the environment.
pub fn optional_eth2_network_config(
self,
optional_config: Option<Eth2NetworkConfig>,
Expand All @@ -255,7 +255,7 @@ impl<E: EthSpec> EnvironmentBuilder<E> {
log: self.log.ok_or("Cannot build environment without log")?,
eth_spec_instance: self.eth_spec_instance,
eth2_config: self.eth2_config,
testnet: self.testnet,
eth2_network_config: self.eth2_network_config,
})
}
}
Expand Down Expand Up @@ -307,7 +307,7 @@ pub struct Environment<E: EthSpec> {
log: Logger,
eth_spec_instance: E,
pub eth2_config: Eth2Config,
pub testnet: Option<Eth2NetworkConfig>,
pub eth2_network_config: Option<Eth2NetworkConfig>,
}

impl<E: EthSpec> Environment<E> {
Expand Down
12 changes: 6 additions & 6 deletions lighthouse/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ fn main() {
Builder::from_env(Env::default()).init();
}

let result = get_eth2_network_config(&matches).and_then(|testnet_config| {
let eth_spec_id = testnet_config.eth_spec_id()?;
let result = get_eth2_network_config(&matches).and_then(|eth2_network_config| {
let eth_spec_id = eth2_network_config.eth_spec_id()?;

// boot node subcommand circumvents the environment
if let Some(bootnode_matches) = matches.subcommand_matches("boot_node") {
Expand All @@ -210,9 +210,9 @@ fn main() {
}

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")]
EthSpecId::Minimal => run(EnvironmentBuilder::minimal(), &matches, testnet_config),
EthSpecId::Minimal => run(EnvironmentBuilder::minimal(), &matches, eth2_network_config),
#[cfg(not(feature = "spec-minimal"))]
other => {
eprintln!(
Expand Down Expand Up @@ -242,7 +242,7 @@ fn main() {
fn run<E: EthSpec>(
environment_builder: EnvironmentBuilder<E>,
matches: &ArgMatches,
testnet_config: Eth2NetworkConfig,
eth2_network_config: Eth2NetworkConfig,
) -> Result<(), String> {
if std::mem::size_of::<usize>() != 8 {
return Err(format!(
Expand All @@ -268,7 +268,7 @@ fn run<E: EthSpec>(

let mut environment = builder
.multi_threaded_tokio_runtime()?
.optional_eth2_network_config(Some(testnet_config))?
.optional_eth2_network_config(Some(eth2_network_config))?
.build()?;

let log = environment.core_context().log().clone();
Expand Down

0 comments on commit 954a9c2

Please sign in to comment.