@@ -9,9 +9,8 @@ use serde_json;
9
9
use slot_clock:: { SlotClock , SystemTimeSlotClock } ;
10
10
use std:: path:: PathBuf ;
11
11
use std:: time:: Duration ;
12
- // use tokio::time::sleep;
12
+ use tokio:: time:: sleep;
13
13
use types:: { ChainSpec , EthSpec , PublicKeyBytes } ;
14
- // use validator_http_api::create_signed_voluntary_exit::get_current_epoch;
15
14
16
15
pub const CMD : & str = "exit" ;
17
16
pub const BEACON_URL_FLAG : & str = "beacon-node" ;
@@ -141,17 +140,15 @@ async fn run<E: EthSpec>(config: ExitConfig) -> Result<(), String> {
141
140
validators_to_exit = validators. iter ( ) . map ( |v| v. validating_pubkey ) . collect ( ) ;
142
141
}
143
142
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
146
145
if !validators
147
146
. iter ( )
148
- . any ( |validator| & validator. validating_pubkey == validator_to_exit)
147
+ . any ( |validator| validator. validating_pubkey == validator_to_exit)
149
148
{
150
149
return Err ( format ! ( "Validator {} doesn't exist" , validator_to_exit) ) ;
151
150
}
152
- }
153
151
154
- for validator_to_exit in validators_to_exit {
155
152
let exit_message = http_client
156
153
. post_validator_voluntary_exit ( & validator_to_exit, exit_epoch)
157
154
. await
@@ -190,7 +187,6 @@ async fn run<E: EthSpec>(config: ExitConfig) -> Result<(), String> {
190
187
) ;
191
188
}
192
189
193
- // Get beacon node spec to be used later
194
190
let genesis_data = beacon_node
195
191
. get_beacon_genesis ( )
196
192
. await
@@ -239,7 +235,7 @@ async fn run<E: EthSpec>(config: ExitConfig) -> Result<(), String> {
239
235
validator_to_exit, validator_data. status
240
236
)
241
237
} else {
242
- // Only publish voluntary exit if validator is ActiveOngoing
238
+ // Only publish voluntary exit if validator status is ActiveOngoing
243
239
beacon_node
244
240
. post_beacon_pool_voluntary_exits ( & exit_message. data )
245
241
. await
@@ -250,23 +246,16 @@ async fn run<E: EthSpec>(config: ExitConfig) -> Result<(), String> {
250
246
validator_to_exit
251
247
) ;
252
248
}
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 ;
254
252
255
253
// Check validator status after publishing voluntary exit
256
254
match validator_data. status {
257
255
ValidatorStatus :: ActiveExiting => {
258
256
let exit_epoch = validator_data. validator . exit_epoch ;
259
257
let withdrawal_epoch = validator_data. validator . withdrawable_epoch ;
260
258
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
-
270
259
eprintln ! ( "Voluntary exit has been accepted into the beacon chain, but not yet finalized. \
271
260
Finalization may take several minutes or longer. Before finalization there is a low \
272
261
probability that the exit may be reverted.") ;
@@ -283,17 +272,7 @@ async fn run<E: EthSpec>(config: ExitConfig) -> Result<(), String> {
283
272
284
273
_ => {
285
274
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
+ }
297
276
}
298
277
}
299
278
}
0 commit comments