Skip to content

Commit fbe4c7f

Browse files
committed
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 903d48d commit fbe4c7f

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
@@ -1430,16 +1430,23 @@ async def peak_post_processing(
14301430
)
14311431

14321432
if fns_peak_result.new_signage_points is not None and peer is not None:
1433-
for index, sp in fns_peak_result.new_signage_points:
1434-
assert (
1435-
sp.cc_vdf is not None
1436-
and sp.cc_proof is not None
1437-
and sp.rc_vdf is not None
1438-
and sp.rc_proof is not None
1439-
)
1440-
await self.signage_point_post_processing(
1441-
RespondSignagePoint(index, sp.cc_vdf, sp.cc_proof, sp.rc_vdf, sp.rc_proof), peer, sub_slots[1]
1442-
)
1433+
# this is protecting the signage point store, to ensure we only
1434+
# process one at a time and never add the same SP twice
1435+
async with self.timelord_lock:
1436+
for index, sp in fns_peak_result.new_signage_points:
1437+
assert (
1438+
sp.cc_vdf is not None
1439+
and sp.cc_proof is not None
1440+
and sp.rc_vdf is not None
1441+
and sp.rc_proof is not None
1442+
)
1443+
sphash = sp.cc_vdf.output.get_hash()
1444+
if self.full_node_store.get_signage_point(sphash) is not None:
1445+
self.log.debug("signage point already processed, skipping: %s", sphash)
1446+
continue
1447+
await self.signage_point_post_processing(
1448+
RespondSignagePoint(index, sp.cc_vdf, sp.cc_proof, sp.rc_vdf, sp.rc_proof), peer, sub_slots[1]
1449+
)
14431450

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

0 commit comments

Comments
 (0)