From 3ad8998e5aee510bdcd8cae6673edef1cd0a21a3 Mon Sep 17 00:00:00 2001 From: Dmitri Makarov Date: Tue, 22 Oct 2024 13:56:05 -0400 Subject: [PATCH] Invoke ancient slots shrinking only if skipping rewrites is enabled --- 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 d88c03b0662a60..04d07e1ef589b0 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -6445,10 +6445,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> {