Skip to content

Commit 9657869

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 f55392d commit 9657869

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
@@ -1639,16 +1639,23 @@ async def peak_post_processing(
16391639
)
16401640

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

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

0 commit comments

Comments
 (0)