mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-03 00:31:50 +00:00
check if the slashing protection database is locked before creating keys (#1949)
## Issue Addressed Closes #1790 ## Proposed Changes Make a new method that creates an empty transaction with `TransactionBehavior::Exclusive` to check whether the slashing protection is locked. Call this method before attempting to create or import new validator keystores. ## Additional Info N/A Co-authored-by: realbigsean <seananderson33@gmail.com>
This commit is contained in:
@@ -192,6 +192,14 @@ pub fn cli_run<T: EthSpec>(
|
||||
)
|
||||
})?;
|
||||
|
||||
// Create an empty transaction and drops it. Used to test if the database is locked.
|
||||
slashing_protection.test_transaction().map_err(|e| {
|
||||
format!(
|
||||
"Cannot create keys while the validator client is running: {:?}",
|
||||
e
|
||||
)
|
||||
})?;
|
||||
|
||||
for i in 0..n {
|
||||
let voting_password = random_password();
|
||||
let withdrawal_password = random_password();
|
||||
|
||||
@@ -86,6 +86,14 @@ pub fn cli_run(matches: &ArgMatches, validator_dir: PathBuf) -> Result<(), Strin
|
||||
)
|
||||
})?;
|
||||
|
||||
// Create an empty transaction and drop it. Used to test if the database is locked.
|
||||
slashing_protection.test_transaction().map_err(|e| {
|
||||
format!(
|
||||
"Cannot import keys while the validator client is running: {:?}",
|
||||
e
|
||||
)
|
||||
})?;
|
||||
|
||||
eprintln!("validator-dir path: {:?}", validator_dir);
|
||||
// Collect the paths for the keystores that should be imported.
|
||||
let keystore_paths = match (keystore, keystores_dir) {
|
||||
|
||||
Reference in New Issue
Block a user