From 8ff5dae418be0caa916d8d724f64f2738cc2a4ea Mon Sep 17 00:00:00 2001 From: dmakarov Date: Tue, 22 Oct 2024 15:48:21 -0400 Subject: [PATCH] Invoke ancient slots shrinking only if skipping rewrites is enabled (#3266) --- runtime/src/bank.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index 9cef07564966f5..9c9879ae438417 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -6434,10 +6434,21 @@ impl Bank { } pub(crate) fn shrink_ancient_slots(&self) { - self.rc + let can_skip_rewrites = self.bank_hash_skips_rent_rewrites(); + let test_skip_rewrites_but_include_in_bank_hash = self + .rc .accounts .accounts_db - .shrink_ancient_slots(self.epoch_schedule()) + .test_skip_rewrites_but_include_in_bank_hash; + // Invoke ancient slot shrinking only when the validator is + // explicitly configured to do so. This condition may be + // removed when the skip rewrites feature is enabled. + if can_skip_rewrites || test_skip_rewrites_but_include_in_bank_hash { + self.rc + .accounts + .accounts_db + .shrink_ancient_slots(self.epoch_schedule()) + } } pub fn read_cost_tracker(&self) -> LockResult> {