From 79f23b670938a4580c7cc4c9cc9481e01c75ce46 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Wed, 13 Nov 2024 12:08:16 -0500 Subject: [PATCH] v2.0: Invoke ancient slots shrinking only if skipping rewrites is enabled (backport of #3266) (#3580) Invoke ancient slots shrinking only if skipping rewrites is enabled (#3266) (cherry picked from commit 8ff5dae418be0caa916d8d724f64f2738cc2a4ea) Co-authored-by: dmakarov --- 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 5d5b54eb384ed9..07832cc81a6450 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -6300,10 +6300,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 validate_fee_collector_account(&self) -> bool {