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

use height to hash in short sync #19007

Merged
merged 3 commits into from
Dec 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions chia/full_node/full_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,9 @@ async def short_sync_batch(self, peer: WSChiaConnection, start_height: uint32, t
self.sync_store.batch_syncing.remove(peer.peer_node_id)
self.log.error(f"Error short batch syncing, could not fetch block at height {start_height}")
return False
if not self.blockchain.contains_block(first.block.prev_header_hash):
hash = self.blockchain.height_to_hash(first.block.height - 1)
assert hash is not None
emlowe marked this conversation as resolved.
Show resolved Hide resolved
if hash != first.block.prev_header_hash:
self.log.info("Batch syncing stopped, this is a deep chain")
self.sync_store.batch_syncing.remove(peer.peer_node_id)
# First sb not connected to our blockchain, do a long sync instead
Expand Down Expand Up @@ -699,7 +701,11 @@ async def short_sync_backtrack(
f"Failed to fetch block {curr_height} from {peer.get_peer_logging()}, wrong type {type(curr)}"
)
blocks.append(curr.block)
if self.blockchain.contains_block(curr.block.prev_header_hash) or curr_height == 0:
if curr_height == 0:
found_fork_point = True
break
hash_at_height = self.blockchain.height_to_hash(curr.block.height - 1)
if hash_at_height is not None and hash_at_height == curr.block.prev_header_hash:
arvidn marked this conversation as resolved.
Show resolved Hide resolved
found_fork_point = True
break
curr_height -= 1
Expand Down
Loading