5
5
from collections import Counter
6
6
from pathlib import Path
7
7
from threading import Lock
8
- from time import sleep , time
8
+ from time import monotonic , sleep
9
9
from typing import Optional
10
10
11
11
from chia_rs import G1Element
@@ -173,47 +173,16 @@ def process_plot(plot_path: Path, plot_info: PlotInfo, num_start: int, num_end:
173
173
challenge = std_hash (i .to_bytes (32 , "big" ))
174
174
# Some plot errors cause get_qualities_for_challenge to throw a RuntimeError
175
175
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"\t Looking 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"\t Looking 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"\t Finding 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"\t Finding 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"\t Quality 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"\t Looking 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"\t Looking up qualities took: { quality_spent_time } ms. Filepath: { plot_path } " )
217
186
except KeyboardInterrupt :
218
187
log .warning ("Interrupted, closing" )
219
188
return
@@ -227,9 +196,40 @@ def process_plot(plot_path: Path, plot_info: PlotInfo, num_start: int, num_end:
227
196
else :
228
197
log .error (f"{ type (e )} : { e } error in getting challenge qualities for plot { plot_path } " )
229
198
caught_exception = True
199
+ continue
230
200
except Exception as e :
231
201
log .error (f"{ type (e )} : { e } error in getting challenge qualities for plot { plot_path } " )
232
202
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"\t Finding 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"\t Finding 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"\t Quality 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
233
233
if caught_exception is True :
234
234
break
235
235
0 commit comments