From af1507ad6854f66992d5a11f35c32cec5a356a45 Mon Sep 17 00:00:00 2001 From: William Blanke Date: Sun, 1 May 2022 11:15:19 -0700 Subject: [PATCH 1/2] make sure we set the syncto height correctly when we roll back instead of noop --- chia/wallet/wallet_blockchain.py | 4 ++-- chia/wallet/wallet_node.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/chia/wallet/wallet_blockchain.py b/chia/wallet/wallet_blockchain.py index d0ebc650e8be..e4066380d3b2 100644 --- a/chia/wallet/wallet_blockchain.py +++ b/chia/wallet/wallet_blockchain.py @@ -184,8 +184,8 @@ async def get_peak_block(self) -> Optional[HeaderBlock]: return self._peak return await self._basic_store.get_object("PEAK_BLOCK", HeaderBlock) - async def set_finished_sync_up_to(self, height: int, in_transaction=False): - if height > await self.get_finished_sync_up_to(): + async def set_finished_sync_up_to(self, height: int, in_transaction=False, in_rollback=False): + if in_rollback or height > await self.get_finished_sync_up_to(): await self._basic_store.set_object("FINISHED_SYNC_UP_TO", uint32(height), in_transaction) if not in_transaction: await self.clean_block_records() diff --git a/chia/wallet/wallet_node.py b/chia/wallet/wallet_node.py index 79e2508266a6..d3d6d6640346 100644 --- a/chia/wallet/wallet_node.py +++ b/chia/wallet/wallet_node.py @@ -479,7 +479,7 @@ async def perform_atomic_rollback(self, fork_height: int, cache: Optional[PeerRe try: await self.wallet_state_manager.db_wrapper.begin_transaction() removed_wallet_ids = await self.wallet_state_manager.reorg_rollback(fork_height) - await self.wallet_state_manager.blockchain.set_finished_sync_up_to(fork_height, True) + await self.wallet_state_manager.blockchain.set_finished_sync_up_to(fork_height, True, in_rollback=True) if cache is None: self.rollback_request_caches(fork_height) else: From 8cc3103fea134000b785f933fc4447b3e010092b Mon Sep 17 00:00:00 2001 From: William Blanke Date: Mon, 2 May 2022 10:36:34 -0700 Subject: [PATCH 2/2] don't error out if height is -1 on rollback --- chia/wallet/wallet_blockchain.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chia/wallet/wallet_blockchain.py b/chia/wallet/wallet_blockchain.py index e4066380d3b2..64ffb7206247 100644 --- a/chia/wallet/wallet_blockchain.py +++ b/chia/wallet/wallet_blockchain.py @@ -185,7 +185,7 @@ async def get_peak_block(self) -> Optional[HeaderBlock]: return await self._basic_store.get_object("PEAK_BLOCK", HeaderBlock) async def set_finished_sync_up_to(self, height: int, in_transaction=False, in_rollback=False): - if in_rollback or height > await self.get_finished_sync_up_to(): + if (in_rollback and height >= 0) or (height > await self.get_finished_sync_up_to()): await self._basic_store.set_object("FINISHED_SYNC_UP_TO", uint32(height), in_transaction) if not in_transaction: await self.clean_block_records()