3
3
import concurrent .futures
4
4
import logging
5
5
from collections import Counter
6
+ from collections .abc import Sequence
6
7
from pathlib import Path
7
8
from threading import Lock
8
9
from time import monotonic , sleep
9
- from typing import Optional
10
+ from typing import Optional , Union
10
11
11
12
from chia_rs import G1Element
13
+ from chia_rs .sized_bytes import bytes32
12
14
from chia_rs .sized_ints import uint8 , uint32
13
15
from chiapos import Verifier
14
16
17
+ from chia .consensus .default_constants import DEFAULT_CONSTANTS
15
18
from chia .plotting .manager import PlotManager
19
+ from chia .plotting .prover import PlotVersion
16
20
from chia .plotting .util import (
17
21
PlotInfo ,
18
22
PlotRefreshEvents ,
22
26
get_plot_filenames ,
23
27
parse_plot_info ,
24
28
)
29
+ from chia .types .blockchain_format .proof_of_space import (
30
+ quality_for_partial_proof ,
31
+ solve_proof ,
32
+ )
25
33
from chia .util .bech32m import encode_puzzle_hash
26
34
from chia .util .config import load_config
27
35
from chia .util .cpu import available_logical_cores
@@ -168,12 +176,18 @@ def process_plot(plot_path: Path, plot_info: PlotInfo, num_start: int, num_end:
168
176
169
177
total_proofs = 0
170
178
caught_exception : bool = False
179
+ version = pr .get_version ()
171
180
for i in range (num_start , num_end ):
172
181
challenge = std_hash (i .to_bytes (32 , "big" ))
182
+ # these are either qualities (v1) or partial proofs (v2)
183
+ proofs : Sequence [Union [bytes32 , bytes ]]
173
184
# Some plot errors cause get_qualities_for_challenge to throw a RuntimeError
174
185
try :
175
186
quality_start_time = round (monotonic () * 1000 )
176
- qualities = pr .get_qualities_for_challenge (challenge )
187
+ if version == PlotVersion .V1 :
188
+ proofs = pr .get_qualities_for_challenge (challenge )
189
+ else :
190
+ proofs = pr .get_partial_proofs_for_challenge (challenge , DEFAULT_CONSTANTS .PLOT_STRENGTH_INITIAL )
177
191
quality_spent_time = round (monotonic () * 1000 ) - quality_start_time
178
192
if quality_spent_time > 8000 :
179
193
log .warning (
@@ -201,13 +215,19 @@ def process_plot(plot_path: Path, plot_info: PlotInfo, num_start: int, num_end:
201
215
caught_exception = True
202
216
break
203
217
204
- for index , quality_str in enumerate (qualities ):
218
+ for index , proof in enumerate (proofs ):
205
219
# Other plot errors cause get_full_proof or validate_proof to throw an AssertionError
206
220
try :
207
221
proof_start_time = round (monotonic () * 1000 )
208
- # TODO : todo_v2_plots handle v2 plots
209
- proof = pr .get_full_proof (challenge , index , parallel_read )
210
- proof_spent_time = round (monotonic () * 1000 ) - proof_start_time
222
+ if version == PlotVersion .V1 :
223
+ quality_str = bytes32 (proof )
224
+ full_proof = pr .get_full_proof (challenge , index , parallel_read )
225
+ proof_spent_time = round (monotonic () * 1000 ) - proof_start_time
226
+ else :
227
+ quality_str = quality_for_partial_proof (proof , challenge )
228
+ proof_spent_time = round (monotonic () * 1000 ) - proof_start_time
229
+ full_proof = solve_proof (proof )
230
+
211
231
if proof_spent_time > 15000 :
212
232
log .warning (
213
233
f"\t Finding proof took: { proof_spent_time } ms. This should be below 15 seconds "
@@ -216,7 +236,7 @@ def process_plot(plot_path: Path, plot_info: PlotInfo, num_start: int, num_end:
216
236
else :
217
237
log .info (f"\t Finding proof took: { proof_spent_time } ms. Filepath: { plot_path } " )
218
238
219
- ver_quality_str = v .validate_proof (pr .get_id (), pr .get_size ().size_v1 , challenge , proof )
239
+ ver_quality_str = v .validate_proof (pr .get_id (), pr .get_size ().size_v1 , challenge , full_proof )
220
240
if quality_str == ver_quality_str :
221
241
total_proofs += 1
222
242
else :
0 commit comments