From 1ff7e09a5aa635c90e73d428ccff598ee455441b Mon Sep 17 00:00:00 2001 From: Rigidity <35380458+Rigidity@users.noreply.github.com> Date: Sat, 30 Mar 2024 13:48:05 -0400 Subject: [PATCH] Only log rollback if heights are actually deleted (#17803) --- chia/full_node/block_height_map.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/chia/full_node/block_height_map.py b/chia/full_node/block_height_map.py index 38255c101a3a..316eafe2adba 100644 --- a/chia/full_node/block_height_map.py +++ b/chia/full_node/block_height_map.py @@ -246,18 +246,24 @@ def rollback(self, fork_height: int) -> None: # fork height may be -1, in which case all blocks are different and we # should clear all sub epoch summaries heights_to_delete = [] - log.log( - logging.WARNING if fork_height < 100 else logging.INFO, - f"rolling back height-to-hash and sub-epoch-summaries cache to {fork_height}", - ) + for ses_included_height in self.__sub_epoch_summaries.keys(): if ses_included_height > fork_height: heights_to_delete.append(ses_included_height) + for height in heights_to_delete: del self.__sub_epoch_summaries[height] + del self.__height_to_hash[(fork_height + 1) * 32 :] self.__first_dirty = min(self.__first_dirty, fork_height + 1) + if len(heights_to_delete) > 0: + log.log( + logging.WARNING if fork_height < 100 else logging.INFO, + f"rolling back {len(heights_to_delete)} blocks in " + f"height-to-hash and sub-epoch-summaries cache, to height {fork_height}", + ) + def get_ses(self, height: uint32) -> SubEpochSummary: return SubEpochSummary.from_bytes(self.__sub_epoch_summaries[height])