Skip to content

Commit

Permalink
brake if end of ses list (#3583)
Browse files Browse the repository at this point in the history
* brake if end of ses list

* log

* throw if wp peak is not heavier

* comment

* handle sync from scratch

* comment
  • Loading branch information
almogdepaz committed May 4, 2021
1 parent faa5c83 commit 859a080
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
7 changes: 7 additions & 0 deletions chia/full_node/full_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,13 @@ async def _sync(self):
await weight_proof_peer.close(600)
raise RuntimeError(f"Weight proof had the wrong weight: {weight_proof_peer.peer_host}")

# dont sync to wp if local peak is heavier,
# dont ban peer, we asked for this peak
current_peak = self.blockchain.get_peak()
if current_peak is not None:
if response.wp.recent_chain_data[-1].reward_chain_block.weight <= current_peak.weight:
raise RuntimeError(f"current peak is heavier than Weight proof peek: {weight_proof_peer.peer_host}")

try:
validated, fork_point, summaries = await self.weight_proof_handler.validate_weight_proof(response.wp)
except Exception as e:
Expand Down
3 changes: 3 additions & 0 deletions chia/full_node/weight_proof.py
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,9 @@ def get_fork_point(self, received_summaries: List[SubEpochSummary]) -> uint32:
for idx, summary_height in enumerate(ses_heights):
log.debug(f"check summary {idx} height {summary_height}")
local_ses = self.blockchain.get_ses(summary_height)
if idx == len(received_summaries) - 1:
# end of wp summaries, local chain is longer or equal to wp chain
break
if local_ses is None or local_ses.get_hash() != received_summaries[idx].get_hash():
break
fork_point_index = idx
Expand Down

0 comments on commit 859a080

Please sign in to comment.