From 637b131f1a5002ea8f281d3b3fa4c77ca2128bf2 Mon Sep 17 00:00:00 2001 From: Pablo Deymonnaz Date: Tue, 17 Mar 2026 17:33:00 -0300 Subject: [PATCH 1/3] Increase STATES_TO_KEEP from 900 to 3000 Extends state retention from ~1 hour to ~3.3 hours (at 4-second slots), reducing the likelihood of state-header gaps during finalization stalls. Closes #239 --- crates/storage/src/store.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/storage/src/store.rs b/crates/storage/src/store.rs index 42dc494..93974a3 100644 --- a/crates/storage/src/store.rs +++ b/crates/storage/src/store.rs @@ -83,8 +83,8 @@ const KEY_LATEST_FINALIZED: &[u8] = b"latest_finalized"; /// ~1 day of block history at 4-second slots (86400 / 4 = 21600). const BLOCKS_TO_KEEP: usize = 21_600; -/// ~1 hour of state history at 4-second slots (3600 / 4 = 900). -const STATES_TO_KEEP: usize = 900; +/// ~3.3 hours of state history at 4-second slots (12000 / 4 = 3000). +const STATES_TO_KEEP: usize = 3_000; const _: () = assert!( BLOCKS_TO_KEEP >= STATES_TO_KEEP, From cadd3f68c5ef8be30ee96eff44cd60bb5ee3ad93 Mon Sep 17 00:00:00 2001 From: Pablo Deymonnaz Date: Tue, 17 Mar 2026 17:39:50 -0300 Subject: [PATCH 2/3] Fixing comment in test --- crates/storage/src/store.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/storage/src/store.rs b/crates/storage/src/store.rs index 93974a3..d0ad364 100644 --- a/crates/storage/src/store.rs +++ b/crates/storage/src/store.rs @@ -1486,9 +1486,9 @@ mod tests { let head_root = root(total_states as u64 - 1); store.update_checkpoints(ForkCheckpoints::head_only(head_root)); - // 905 headers total. Top 900 by slot are kept in the retention window, + // 905 headers total. Top 3000 by slot are kept in the retention window, // leaving 5 candidates. 2 are protected (finalized + justified), - // so 3 are pruned → 905 - 3 = 902 states remaining. + // so 3 are pruned → 3005 - 3 = 3002 states remaining. assert_eq!( count_entries(backend.as_ref(), Table::States), STATES_TO_KEEP + 2 From e66d980ba0cafc4ba0d0d220ba411cc563e965b2 Mon Sep 17 00:00:00 2001 From: Pablo Deymonnaz Date: Tue, 17 Mar 2026 17:56:12 -0300 Subject: [PATCH 3/3] Apply suggestion from @MegaRedHand MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Tomás Grüner <47506558+MegaRedHand@users.noreply.github.com> --- crates/storage/src/store.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/storage/src/store.rs b/crates/storage/src/store.rs index d0ad364..359c165 100644 --- a/crates/storage/src/store.rs +++ b/crates/storage/src/store.rs @@ -1486,7 +1486,7 @@ mod tests { let head_root = root(total_states as u64 - 1); store.update_checkpoints(ForkCheckpoints::head_only(head_root)); - // 905 headers total. Top 3000 by slot are kept in the retention window, + // 3005 headers total. Top 3000 by slot are kept in the retention window, // leaving 5 candidates. 2 are protected (finalized + justified), // so 3 are pruned → 3005 - 3 = 3002 states remaining. assert_eq!(