From 2014525882ba26c4441e425df44e8f5452f4ce71 Mon Sep 17 00:00:00 2001 From: "Jeff Washington (jwash)" Date: Tue, 23 Aug 2022 18:12:47 -0500 Subject: [PATCH] clean_rooted_entries adds _EXclusive (#27309) --- runtime/src/accounts_index.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/runtime/src/accounts_index.rs b/runtime/src/accounts_index.rs index 3362db0b49..9c008d8c59 100644 --- a/runtime/src/accounts_index.rs +++ b/runtime/src/accounts_index.rs @@ -1708,6 +1708,9 @@ impl AccountsIndex { slot_list.retain(|(slot, value)| { let should_purge = Self::can_purge_older_entries( + // Note that we have a root that is inclusive here. + // Calling a function that expects 'exclusive' + // This is expected behavior for this call. max_clean_root_inclusive, newest_root_in_slot_list, *slot, @@ -1744,21 +1747,21 @@ impl AccountsIndex { /// When can an entry be purged? /// /// If we get a slot update where slot != newest_root_in_slot_list for an account where slot < - /// max_clean_root, then we know it's safe to delete because: + /// max_clean_root_exclusive, then we know it's safe to delete because: /// /// a) If slot < newest_root_in_slot_list, then we know the update is outdated by a later rooted /// update, namely the one in newest_root_in_slot_list /// - /// b) If slot > newest_root_in_slot_list, then because slot < max_clean_root and we know there are - /// no roots in the slot list between newest_root_in_slot_list and max_clean_root, (otherwise there + /// b) If slot > newest_root_in_slot_list, then because slot < max_clean_root_exclusive and we know there are + /// no roots in the slot list between newest_root_in_slot_list and max_clean_root_exclusive, (otherwise there /// would be a bigger newest_root_in_slot_list, which is a contradiction), then we know slot must be - /// an unrooted slot less than max_clean_root and thus safe to clean as well. + /// an unrooted slot less than max_clean_root_exclusive and thus safe to clean as well. fn can_purge_older_entries( - max_clean_root: Slot, + max_clean_root_exclusive: Slot, newest_root_in_slot_list: Slot, slot: Slot, ) -> bool { - slot < max_clean_root && slot != newest_root_in_slot_list + slot < max_clean_root_exclusive && slot != newest_root_in_slot_list } /// Given a list of slots, return a new list of only the slots that are rooted