Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add reorg rollback to retry store #15303

Merged
merged 1 commit into from
Jun 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 13 additions & 0 deletions chia/wallet/wallet_retry_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,16 @@ async def remove_state(self, state: CoinState) -> None:
async with self.db_wrapper.writer_maybe_transaction() as conn:
cursor = await conn.execute("DELETE FROM retry_store where coin_state=?", (bytes(state),))
await cursor.close()

async def rollback_to_block(self, height: int) -> None:
"""
Delete all ignored states above a certain height
:param height: Reorg height
:return None:
"""
async with self.db_wrapper.writer_maybe_transaction() as conn:
cursor = await conn.execute(
"DELETE from retry_store WHERE fork_height>?",
(height,),
)
await cursor.close()
1 change: 1 addition & 0 deletions chia/wallet/wallet_state_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -1649,6 +1649,7 @@ async def reorg_rollback(self, height: int) -> List[uint32]:
Rolls back and updates the coin_store and transaction store. It's possible this height
is the tip, or even beyond the tip.
"""
await self.retry_store.rollback_to_block(height)
await self.nft_store.rollback_to_block(height)
await self.coin_store.rollback_to_block(height)
reorged: List[TransactionRecord] = await self.tx_store.get_transaction_above(height)
Expand Down