From 8c28d175b8737957c658e2a8b98c74818f4c0bce Mon Sep 17 00:00:00 2001 From: Michael Sproul Date: Thu, 19 Oct 2023 05:19:25 +0000 Subject: [PATCH] Fix: write post state in lcli skip-slots (#4843) ## Issue Addressed Fix a bug in `lcli skip-slots` that resulted in it always writing the pre-state to the output file. ## Proposed Changes Correctly keep track of the post-state, and write it. --- lcli/src/skip_slots.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lcli/src/skip_slots.rs b/lcli/src/skip_slots.rs index 31fe9fe6480..cdbacfe4d52 100644 --- a/lcli/src/skip_slots.rs +++ b/lcli/src/skip_slots.rs @@ -109,6 +109,7 @@ pub fn run( } _ => return Err("must supply either --state-path or --beacon-url".into()), }; + let mut post_state = None; let initial_slot = state.slot(); let target_slot = initial_slot + slots; @@ -140,14 +141,15 @@ pub fn run( let duration = Instant::now().duration_since(start); info!("Run {}: {:?}", i, duration); + post_state = Some(state); } - if let Some(output_path) = output_path { + if let (Some(post_state), Some(output_path)) = (post_state, output_path) { let mut output_file = File::create(output_path) .map_err(|e| format!("Unable to create output file: {:?}", e))?; output_file - .write_all(&state.as_ssz_bytes()) + .write_all(&post_state.as_ssz_bytes()) .map_err(|e| format!("Unable to write to output file: {:?}", e))?; }