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
15
17
from chia .consensus .default_constants import DEFAULT_CONSTANTS
16
18
from chia .plotting .manager import PlotManager
19
+ from chia .plotting .prover import PlotVersion
17
20
from chia .plotting .util import (
18
21
PlotInfo ,
19
22
PlotRefreshEvents ,
23
26
get_plot_filenames ,
24
27
parse_plot_info ,
25
28
)
29
+ from chia .types .blockchain_format .proof_of_space import (
30
+ quality_for_partial_proof ,
31
+ solve_proof ,
32
+ )
26
33
from chia .util .bech32m import encode_puzzle_hash
27
34
from chia .util .config import load_config
28
35
from chia .util .cpu import available_logical_cores
@@ -169,12 +176,20 @@ def process_plot(plot_path: Path, plot_info: PlotInfo, num_start: int, num_end:
169
176
170
177
total_proofs = 0
171
178
caught_exception : bool = False
179
+ version = pr .get_version ()
172
180
for i in range (num_start , num_end ):
173
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 ]]
174
184
# Some plot errors cause get_qualities_for_challenge to throw a RuntimeError
175
185
try :
176
186
quality_start_time = round (monotonic () * 1000 )
177
- qualities = pr .get_qualities_for_challenge (challenge , DEFAULT_CONSTANTS .PLOT_DIFFICULTY_INITIAL )
187
+ if version == PlotVersion .V1 :
188
+ proofs = pr .get_qualities_for_challenge (challenge , DEFAULT_CONSTANTS .PLOT_DIFFICULTY_INITIAL )
189
+ else :
190
+ proofs = pr .get_partial_proofs_for_challenge (
191
+ challenge , DEFAULT_CONSTANTS .PLOT_DIFFICULTY_INITIAL
192
+ )
178
193
quality_spent_time = round (monotonic () * 1000 ) - quality_start_time
179
194
if quality_spent_time > 8000 :
180
195
log .warning (
@@ -202,12 +217,17 @@ def process_plot(plot_path: Path, plot_info: PlotInfo, num_start: int, num_end:
202
217
caught_exception = True
203
218
break
204
219
205
- for index , quality_str in enumerate (qualities ):
220
+ for index , proof in enumerate (proofs ):
206
221
# Other plot errors cause get_full_proof or validate_proof to throw an AssertionError
207
222
try :
208
223
proof_start_time = round (monotonic () * 1000 )
209
- # TODO : todo_v2_plots handle v2 plots
210
- proof = pr .get_full_proof (challenge , index , parallel_read )
224
+ if version == PlotVersion .V1 :
225
+ quality_str = bytes32 (proof )
226
+ full_proof = pr .get_full_proof (challenge , index , parallel_read )
227
+ else :
228
+ quality_str = quality_for_partial_proof (proof , challenge )
229
+ full_proof = solve_proof (proof )
230
+
211
231
proof_spent_time = round (monotonic () * 1000 ) - proof_start_time
212
232
if proof_spent_time > 15000 :
213
233
log .warning (
@@ -217,7 +237,7 @@ def process_plot(plot_path: Path, plot_info: PlotInfo, num_start: int, num_end:
217
237
else :
218
238
log .info (f"\t Finding proof took: { proof_spent_time } ms. Filepath: { plot_path } " )
219
239
220
- ver_quality_str = v .validate_proof (pr .get_id (), pr .get_size ().size_v1 , challenge , proof )
240
+ ver_quality_str = v .validate_proof (pr .get_id (), pr .get_size ().size_v1 , challenge , full_proof )
221
241
if quality_str == ver_quality_str :
222
242
total_proofs += 1
223
243
else :
0 commit comments