Ensure deposits are generated with correct fork (#855)
* Ensure genesis fork is applied to spec * Ensure account man uses testnet spec
This commit is contained in:
parent
123c63119d
commit
1cf8769c07
@ -87,9 +87,53 @@ fn run_new_validator_subcommand<T: EthSpec>(
|
|||||||
datadir: PathBuf,
|
datadir: PathBuf,
|
||||||
mut env: Environment<T>,
|
mut env: Environment<T>,
|
||||||
) -> Result<(), String> {
|
) -> Result<(), String> {
|
||||||
let context = env.core_context();
|
let mut context = env.core_context();
|
||||||
let log = context.log.clone();
|
let log = context.log.clone();
|
||||||
|
|
||||||
|
// Load the testnet configuration from disk, or use the default testnet.
|
||||||
|
let eth2_testnet_config: Eth2TestnetConfig<T> =
|
||||||
|
if let Some(testnet_dir_str) = matches.value_of("testnet-dir") {
|
||||||
|
let testnet_dir = testnet_dir_str
|
||||||
|
.parse::<PathBuf>()
|
||||||
|
.map_err(|e| format!("Unable to parse testnet-dir: {}", e))?;
|
||||||
|
|
||||||
|
if !testnet_dir.exists() {
|
||||||
|
return Err(format!(
|
||||||
|
"Testnet directory at {:?} does not exist",
|
||||||
|
testnet_dir
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
info!(
|
||||||
|
log,
|
||||||
|
"Loading deposit contract address";
|
||||||
|
"testnet_dir" => format!("{:?}", &testnet_dir)
|
||||||
|
);
|
||||||
|
|
||||||
|
Eth2TestnetConfig::load(testnet_dir.clone())
|
||||||
|
.map_err(|e| format!("Failed to load testnet dir at {:?}: {}", testnet_dir, e))?
|
||||||
|
} else {
|
||||||
|
info!(
|
||||||
|
log,
|
||||||
|
"Using Lighthouse testnet deposit contract";
|
||||||
|
);
|
||||||
|
|
||||||
|
Eth2TestnetConfig::hard_coded()
|
||||||
|
.map_err(|e| format!("Failed to load hard_coded testnet dir: {}", e))?
|
||||||
|
};
|
||||||
|
|
||||||
|
context.eth2_config.spec = eth2_testnet_config
|
||||||
|
.yaml_config
|
||||||
|
.as_ref()
|
||||||
|
.ok_or_else(|| "The testnet directory must contain a spec config".to_string())?
|
||||||
|
.apply_to_chain_spec::<T>(&context.eth2_config.spec)
|
||||||
|
.ok_or_else(|| {
|
||||||
|
format!(
|
||||||
|
"The loaded config is not compatible with the {} spec",
|
||||||
|
&context.eth2_config.spec_constants
|
||||||
|
)
|
||||||
|
})?;
|
||||||
|
|
||||||
let methods: Vec<KeygenMethod> = match matches.subcommand() {
|
let methods: Vec<KeygenMethod> = match matches.subcommand() {
|
||||||
("insecure", Some(matches)) => {
|
("insecure", Some(matches)) => {
|
||||||
let first = matches
|
let first = matches
|
||||||
@ -130,7 +174,7 @@ fn run_new_validator_subcommand<T: EthSpec>(
|
|||||||
&methods,
|
&methods,
|
||||||
deposit_value,
|
deposit_value,
|
||||||
&context.eth2_config.spec,
|
&context.eth2_config.spec,
|
||||||
&env.core_context().log,
|
&log,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
if matches.is_present("send-deposits") {
|
if matches.is_present("send-deposits") {
|
||||||
@ -173,39 +217,6 @@ fn run_new_validator_subcommand<T: EthSpec>(
|
|||||||
"eth1_node_http_endpoint" => eth1_endpoint
|
"eth1_node_http_endpoint" => eth1_endpoint
|
||||||
);
|
);
|
||||||
|
|
||||||
// Load the testnet configuration from disk, or use the default testnet.
|
|
||||||
let eth2_testnet_config: Eth2TestnetConfig<T> = if let Some(testnet_dir_str) =
|
|
||||||
matches.value_of("testnet-dir")
|
|
||||||
{
|
|
||||||
let testnet_dir = testnet_dir_str
|
|
||||||
.parse::<PathBuf>()
|
|
||||||
.map_err(|e| format!("Unable to parse testnet-dir: {}", e))?;
|
|
||||||
|
|
||||||
if !testnet_dir.exists() {
|
|
||||||
return Err(format!(
|
|
||||||
"Testnet directory at {:?} does not exist",
|
|
||||||
testnet_dir
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
info!(
|
|
||||||
log,
|
|
||||||
"Loading deposit contract address";
|
|
||||||
"testnet_dir" => format!("{:?}", &testnet_dir)
|
|
||||||
);
|
|
||||||
|
|
||||||
Eth2TestnetConfig::load(testnet_dir.clone())
|
|
||||||
.map_err(|e| format!("Failed to load testnet dir at {:?}: {}", testnet_dir, e))?
|
|
||||||
} else {
|
|
||||||
info!(
|
|
||||||
log,
|
|
||||||
"Using Lighthouse testnet deposit contract";
|
|
||||||
);
|
|
||||||
|
|
||||||
Eth2TestnetConfig::hard_coded()
|
|
||||||
.map_err(|e| format!("Failed to load hard_coded testnet dir: {}", e))?
|
|
||||||
};
|
|
||||||
|
|
||||||
// Convert from `types::Address` to `web3::types::Address`.
|
// Convert from `types::Address` to `web3::types::Address`.
|
||||||
let deposit_contract = Address::from_slice(
|
let deposit_contract = Address::from_slice(
|
||||||
eth2_testnet_config
|
eth2_testnet_config
|
||||||
|
@ -612,7 +612,7 @@ impl YamlConfig {
|
|||||||
domain_deposit: self.domain_deposit,
|
domain_deposit: self.domain_deposit,
|
||||||
domain_voluntary_exit: self.domain_voluntary_exit,
|
domain_voluntary_exit: self.domain_voluntary_exit,
|
||||||
boot_nodes: chain_spec.boot_nodes.clone(),
|
boot_nodes: chain_spec.boot_nodes.clone(),
|
||||||
genesis_fork_version: chain_spec.genesis_fork_version.clone(),
|
genesis_fork_version: self.genesis_fork_version.clone(),
|
||||||
eth1_follow_distance: self.eth1_follow_distance,
|
eth1_follow_distance: self.eth1_follow_distance,
|
||||||
..*chain_spec
|
..*chain_spec
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user