Skip to content

Commit aa568ac

Browse files
committed
Merge remote-tracking branch 'origin/check-plots' into check-plots-v2
2 parents fbb9cae + 4b5f325 commit aa568ac

File tree

1 file changed

+42
-42
lines changed

1 file changed

+42
-42
lines changed

chia/plotting/check_plots.py

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from collections import Counter
66
from pathlib import Path
77
from threading import Lock
8-
from time import sleep, time
8+
from time import monotonic, sleep
99
from typing import Optional
1010

1111
from chia_rs import G1Element
@@ -173,47 +173,16 @@ def process_plot(plot_path: Path, plot_info: PlotInfo, num_start: int, num_end:
173173
challenge = std_hash(i.to_bytes(32, "big"))
174174
# Some plot errors cause get_qualities_for_challenge to throw a RuntimeError
175175
try:
176-
quality_start_time = round(time() * 1000)
177-
for index, quality_str in enumerate(
178-
pr.get_qualities_for_challenge(challenge, DEFAULT_CONSTANTS.PLOT_DIFFICULTY_INITIAL)
179-
):
180-
quality_spent_time = round(time() * 1000) - quality_start_time
181-
if quality_spent_time > 8000:
182-
log.warning(
183-
f"\tLooking up qualities took: {quality_spent_time} ms. This should be below 8 seconds "
184-
f"to minimize risk of losing rewards. Filepath: {plot_path}"
185-
)
186-
else:
187-
log.info(f"\tLooking up qualities took: {quality_spent_time} ms. Filepath: {plot_path}")
188-
189-
# Other plot errors cause get_full_proof or validate_proof to throw an AssertionError
190-
try:
191-
proof_start_time = round(time() * 1000)
192-
# TODO : todo_v2_plots handle v2 plots
193-
proof = pr.get_full_proof(challenge, index, parallel_read)
194-
proof_spent_time = round(time() * 1000) - proof_start_time
195-
if proof_spent_time > 15000:
196-
log.warning(
197-
f"\tFinding proof took: {proof_spent_time} ms. This should be below 15 seconds "
198-
f"to minimize risk of losing rewards. Filepath: {plot_path}"
199-
)
200-
else:
201-
log.info(f"\tFinding proof took: {proof_spent_time} ms. Filepath: {plot_path}")
202-
203-
ver_quality_str = v.validate_proof(pr.get_id(), pr.get_size(), challenge, proof)
204-
if quality_str == ver_quality_str:
205-
total_proofs += 1
206-
else:
207-
log.warning(
208-
f"\tQuality doesn't match with proof. Filepath: {plot_path} "
209-
"This can occasionally happen with a compressed plot."
210-
)
211-
except AssertionError as e:
212-
log.error(
213-
f"{type(e)}: {e} error in proving/verifying for plot {plot_path}. Filepath: {plot_path}"
214-
)
215-
caught_exception = True
216-
quality_start_time = round(time() * 1000)
176+
quality_start_time = round(monotonic() * 1000)
177+
qualities = pr.get_qualities_for_challenge(challenge, DEFAULT_CONSTANTS.PLOT_DIFFICULTY_INITIAL)
178+
quality_spent_time = round(monotonic() * 1000) - quality_start_time
179+
if quality_spent_time > 8000:
180+
log.warning(
181+
f"\tLooking up qualities took: {quality_spent_time} ms. This should be below 8 seconds "
182+
f"to minimize risk of losing rewards. Filepath: {plot_path}"
183+
)
184+
else:
185+
log.info(f"\tLooking up qualities took: {quality_spent_time} ms. Filepath: {plot_path}")
217186
except KeyboardInterrupt:
218187
log.warning("Interrupted, closing")
219188
return
@@ -227,9 +196,40 @@ def process_plot(plot_path: Path, plot_info: PlotInfo, num_start: int, num_end:
227196
else:
228197
log.error(f"{type(e)}: {e} error in getting challenge qualities for plot {plot_path}")
229198
caught_exception = True
199+
continue
230200
except Exception as e:
231201
log.error(f"{type(e)}: {e} error in getting challenge qualities for plot {plot_path}")
232202
caught_exception = True
203+
break
204+
205+
for index, quality_str in enumerate(qualities):
206+
# Other plot errors cause get_full_proof or validate_proof to throw an AssertionError
207+
try:
208+
proof_start_time = round(monotonic() * 1000)
209+
# TODO : todo_v2_plots handle v2 plots
210+
proof = pr.get_full_proof(challenge, index, parallel_read)
211+
proof_spent_time = round(monotonic() * 1000) - proof_start_time
212+
if proof_spent_time > 15000:
213+
log.warning(
214+
f"\tFinding proof took: {proof_spent_time} ms. This should be below 15 seconds "
215+
f"to minimize risk of losing rewards. Filepath: {plot_path}"
216+
)
217+
else:
218+
log.info(f"\tFinding proof took: {proof_spent_time} ms. Filepath: {plot_path}")
219+
220+
ver_quality_str = v.validate_proof(pr.get_id(), pr.get_size().size_v1, challenge, proof)
221+
if quality_str == ver_quality_str:
222+
total_proofs += 1
223+
else:
224+
log.warning(
225+
f"\tQuality doesn't match with proof. Filepath: {plot_path} "
226+
"This can occasionally happen with a compressed plot."
227+
)
228+
except AssertionError as e:
229+
log.error(
230+
f"{type(e)}: {e} error in proving/verifying for plot {plot_path}. Filepath: {plot_path}"
231+
)
232+
caught_exception = True
233233
if caught_exception is True:
234234
break
235235

0 commit comments

Comments
 (0)