Skip to content

Commit

Permalink
fix the rollback of fork_info when validating a block fails
Browse files Browse the repository at this point in the history
  • Loading branch information
arvidn committed Nov 18, 2024
1 parent 05cddcc commit a19633e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion chia/consensus/blockchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ async def add_block(
# in case we fail and need to restore the blockchain state, remember the
# peak height
previous_peak_height = self._peak_height
prev_fork_peak = (fork_info.peak_height, fork_info.peak_hash)

try:
# Always add the block to the database
Expand Down Expand Up @@ -425,7 +426,8 @@ async def add_block(
self.remove_block_record(header_hash)
except KeyError:
pass
fork_info.rollback(header_hash, -1 if previous_peak_height is None else previous_peak_height)
# restore fork_info to the state before adding the block
fork_info.rollback(prev_fork_peak[1], prev_fork_peak[0])
self.block_store.rollback_cache_block(header_hash)
self._peak_height = previous_peak_height
log.error(
Expand Down

0 comments on commit a19633e

Please sign in to comment.