Skip to content

Commit 871692a

Browse files
committed
remove loop
1 parent 8d4b6a4 commit 871692a

File tree

1 file changed

+44
-38
lines changed

1 file changed

+44
-38
lines changed

validator_manager/src/exit_validators.rs

Lines changed: 44 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -260,51 +260,57 @@ async fn run<E: EthSpec>(config: ExitConfig) -> Result<(), String> {
260260
first_sleep = false;
261261
}
262262

263-
loop {
264-
// Check validator status after publishing voluntary exit
265-
let updated_validator_data = beacon_node
266-
.get_beacon_states_validator_id(
267-
StateId::Head,
268-
&ValidatorId::PublicKey(validator_to_exit),
263+
// Check validator status after publishing voluntary exit
264+
let updated_validator_data = beacon_node
265+
.get_beacon_states_validator_id(
266+
StateId::Head,
267+
&ValidatorId::PublicKey(validator_to_exit),
268+
)
269+
.await
270+
.map_err(|e| format!("Failed to get updated validator details: {:?}", e))?
271+
.ok_or_else(|| {
272+
format!(
273+
"Validator {} is not present in the beacon state",
274+
validator_to_exit
269275
)
270-
.await
271-
.map_err(|e| format!("Failed to get updated validator details: {:?}", e))?
272-
.ok_or_else(|| {
273-
format!(
274-
"Validator {} is not present in the beacon state",
275-
validator_to_exit
276-
)
277-
})?
278-
.data;
279-
280-
if validator_data.status == ValidatorStatus::ActiveOngoing
281-
&& updated_validator_data.status == ValidatorStatus::ActiveOngoing
282-
// The case where the beacon node has not yet published the voluntary exit
283-
{
284-
eprintln!("Waiting for voluntary exit to be accepted into the beacon chain...");
285-
} else if updated_validator_data.status == ValidatorStatus::ActiveExiting {
286-
let exit_epoch = updated_validator_data.validator.exit_epoch;
287-
let withdrawal_epoch = updated_validator_data.validator.withdrawable_epoch;
276+
})?
277+
.data;
288278

289-
eprintln!("Voluntary exit has been accepted into the beacon chain, but not yet finalized. \
279+
if validator_data.status == ValidatorStatus::ActiveOngoing
280+
&& updated_validator_data.status == ValidatorStatus::ActiveOngoing
281+
// The case where the beacon node has not yet published the voluntary exit
282+
{
283+
eprintln!("Waiting for voluntary exit to be accepted into the beacon chain...");
284+
} else if updated_validator_data.status == ValidatorStatus::ActiveExiting {
285+
let exit_epoch = updated_validator_data.validator.exit_epoch;
286+
let withdrawal_epoch = updated_validator_data.validator.withdrawable_epoch;
287+
288+
eprintln!("Voluntary exit has been accepted into the beacon chain, but not yet finalized. \
290289
Finalization may take several minutes or longer. Before finalization there is a low \
291290
probability that the exit may be reverted.");
291+
eprintln!(
292+
"Current epoch: {}, Exit epoch: {}, Withdrawable epoch: {}",
293+
current_epoch, exit_epoch, withdrawal_epoch
294+
);
295+
eprintln!("Please keep your validator running till exit epoch");
296+
eprintln!(
297+
"Exit epoch in approximately {} secs",
298+
(exit_epoch - current_epoch) * spec.seconds_per_slot * E::slots_per_epoch()
299+
);
300+
} else if updated_validator_data.status == ValidatorStatus::ExitedSlashed
301+
|| updated_validator_data.status == ValidatorStatus::ExitedUnslashed
302+
{
303+
{
292304
eprintln!(
293-
"Current epoch: {}, Exit epoch: {}, Withdrawable epoch: {}",
294-
current_epoch, exit_epoch, withdrawal_epoch
295-
);
296-
eprintln!("Please keep your validator running till exit epoch");
297-
eprintln!(
298-
"Exit epoch in approximately {} secs",
299-
(exit_epoch - current_epoch) * spec.seconds_per_slot * E::slots_per_epoch()
305+
"Validator has exited on epoch: {}",
306+
updated_validator_data.validator.exit_epoch
300307
);
301-
break;
302-
} else {
303-
eprintln!(
304-
"Validator has not exited. Validator status is: {}",
305-
updated_validator_data.status
306-
)
307308
}
309+
} else {
310+
eprintln!(
311+
"Validator has not initiated voluntary exit. Validator status is: {}",
312+
updated_validator_data.status
313+
)
308314
}
309315
}
310316
}

0 commit comments

Comments
 (0)