@@ -9,9 +9,8 @@ use serde_json;
99use slot_clock:: { SlotClock , SystemTimeSlotClock } ;
1010use std:: path:: PathBuf ;
1111use std:: time:: Duration ;
12- // use tokio::time::sleep;
12+ use tokio:: time:: sleep;
1313use types:: { ChainSpec , EthSpec , PublicKeyBytes } ;
14- // use validator_http_api::create_signed_voluntary_exit::get_current_epoch;
1514
1615pub const CMD : & str = "exit" ;
1716pub const BEACON_URL_FLAG : & str = "beacon-node" ;
@@ -141,17 +140,15 @@ async fn run<E: EthSpec>(config: ExitConfig) -> Result<(), String> {
141140 validators_to_exit = validators. iter ( ) . map ( |v| v. validating_pubkey ) . collect ( ) ;
142141 }
143142
144- // Check that the validators_to_exit is in the validator client
145- for validator_to_exit in & validators_to_exit {
143+ for validator_to_exit in validators_to_exit {
144+ // Check that the validators_to_exit is in the validator client
146145 if !validators
147146 . iter ( )
148- . any ( |validator| & validator. validating_pubkey == validator_to_exit)
147+ . any ( |validator| validator. validating_pubkey == validator_to_exit)
149148 {
150149 return Err ( format ! ( "Validator {} doesn't exist" , validator_to_exit) ) ;
151150 }
152- }
153151
154- for validator_to_exit in validators_to_exit {
155152 let exit_message = http_client
156153 . post_validator_voluntary_exit ( & validator_to_exit, exit_epoch)
157154 . await
@@ -190,7 +187,6 @@ async fn run<E: EthSpec>(config: ExitConfig) -> Result<(), String> {
190187 ) ;
191188 }
192189
193- // Get beacon node spec to be used later
194190 let genesis_data = beacon_node
195191 . get_beacon_genesis ( )
196192 . await
@@ -239,7 +235,7 @@ async fn run<E: EthSpec>(config: ExitConfig) -> Result<(), String> {
239235 validator_to_exit, validator_data. status
240236 )
241237 } else {
242- // Only publish voluntary exit if validator is ActiveOngoing
238+ // Only publish voluntary exit if validator status is ActiveOngoing
243239 beacon_node
244240 . post_beacon_pool_voluntary_exits ( & exit_message. data )
245241 . await
@@ -250,23 +246,16 @@ async fn run<E: EthSpec>(config: ExitConfig) -> Result<(), String> {
250246 validator_to_exit
251247 ) ;
252248 }
253- // sleep(Duration::from_secs(spec.seconds_per_slot)).await;
249+
250+ // Sleep a constant 12s as in testnet 3s would be too short for validator status to update
251+ sleep ( Duration :: from_secs ( 12 ) ) . await ;
254252
255253 // Check validator status after publishing voluntary exit
256254 match validator_data. status {
257255 ValidatorStatus :: ActiveExiting => {
258256 let exit_epoch = validator_data. validator . exit_epoch ;
259257 let withdrawal_epoch = validator_data. validator . withdrawable_epoch ;
260258
261- // let slot_clock = SystemTimeSlotClock::new(
262- // spec.genesis_slot,
263- // Duration::from_secs(genesis_data.genesis_time),
264- // Duration::from_secs(spec.config().seconds_per_slot),
265- // );
266-
267- // let current_epoch = get_current_epoch::<SystemTimeSlotClock, E>(slot_clock)
268- // .ok_or_else(|| "Unable to determine current epoch".to_string())?;
269-
270259 eprintln ! ( "Voluntary exit has been accepted into the beacon chain, but not yet finalized. \
271260 Finalization may take several minutes or longer. Before finalization there is a low \
272261 probability that the exit may be reverted.") ;
@@ -283,17 +272,7 @@ async fn run<E: EthSpec>(config: ExitConfig) -> Result<(), String> {
283272
284273 _ => {
285274 eprintln ! ( "Waiting for voluntary exit to be accepted into the beacon chain..." )
286- } // fn get_current_epoch<T: 'static + SlotClock + Clone, E: EthSpec>(
287- // slot_clock: T,
288- // ) -> Option<Epoch> {
289- // slot_clock.now().map(|s| s.epoch(E::slots_per_epoch()))
290- // }
291-
292- // let spec = ChainSpec::mainnet();
293-
294- // let current_epoch =
295- // get_current_epoch::<E>(genesis_time, &spec).ok_or("Failed to get current epoch")?;
296- //let current_epoch = get_current_epoch::<E>(genesis_data.genesis_time, spec);
275+ }
297276 }
298277 }
299278 }
0 commit comments