Skip to content

Commit de0fabd

Browse files
arvidnaltendky
authored andcommitted
hold the timelord_lock when calling signage_point_post_processing() also when receiving a new peak. Also, don't call it for SPs we already have
1 parent 2ad6443 commit de0fabd

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

chia/full_node/full_node.py

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1636,16 +1636,23 @@ async def peak_post_processing(
16361636
)
16371637

16381638
if fns_peak_result.new_signage_points is not None and peer is not None:
1639-
for index, sp in fns_peak_result.new_signage_points:
1640-
assert (
1641-
sp.cc_vdf is not None
1642-
and sp.cc_proof is not None
1643-
and sp.rc_vdf is not None
1644-
and sp.rc_proof is not None
1645-
)
1646-
await self.signage_point_post_processing(
1647-
RespondSignagePoint(index, sp.cc_vdf, sp.cc_proof, sp.rc_vdf, sp.rc_proof), peer, sub_slots[1]
1648-
)
1639+
# this is protecting the signage point store, to ensure we only
1640+
# process one at a time and never add the same SP twice
1641+
async with self.timelord_lock:
1642+
for index, sp in fns_peak_result.new_signage_points:
1643+
assert (
1644+
sp.cc_vdf is not None
1645+
and sp.cc_proof is not None
1646+
and sp.rc_vdf is not None
1647+
and sp.rc_proof is not None
1648+
)
1649+
sphash = sp.cc_vdf.output.get_hash()
1650+
if self.full_node_store.get_signage_point(sphash) is not None:
1651+
self.log.debug("signage point already processed, skipping: %s", sphash)
1652+
continue
1653+
await self.signage_point_post_processing(
1654+
RespondSignagePoint(index, sp.cc_vdf, sp.cc_proof, sp.rc_vdf, sp.rc_proof), peer, sub_slots[1]
1655+
)
16491656

16501657
if sub_slots[1] is None:
16511658
assert record.ip_sub_slot_total_iters(self.constants) == 0

0 commit comments

Comments
 (0)