8
8
from chia_rs .sized_ints import uint8
9
9
from chiapos import DiskProver
10
10
11
+ from chia .types .blockchain_format .proof_of_space import quality_for_partial_proof
12
+
11
13
if TYPE_CHECKING :
12
14
from chiapos import DiskProver
13
15
@@ -27,8 +29,13 @@ def get_compression_level(self) -> uint8: ...
27
29
def get_version (self ) -> PlotVersion : ...
28
30
def __bytes__ (self ) -> bytes : ...
29
31
def get_id (self ) -> bytes32 : ...
30
- def get_qualities_for_challenge (self , challenge : bytes32 ) -> list [bytes32 ]: ...
31
- def get_partial_proofs_for_challenge (self , challenge : bytes32 ) -> list [bytes ]: ...
32
+ def get_qualities_for_challenge (self , challenge : bytes32 , plot_strength : uint8 ) -> list [bytes32 ]: ...
33
+
34
+ # this is only supported by v2 plots
35
+ def get_partial_proofs_for_challenge (self , challenge : bytes32 , plot_strength : uint8 ) -> list [bytes ]: ...
36
+
37
+ # this is only supported by v1 plots. v2 plots first get the partial proof
38
+ # and turn it into a full proof by calling solve_proof(), or pass it to the solver service
32
39
def get_full_proof (self , challenge : bytes32 , index : int , parallel_read : bool = True ) -> bytes : ...
33
40
34
41
@classmethod
@@ -56,7 +63,8 @@ def get_memo(self) -> bytes:
56
63
raise NotImplementedError ("V2 plot format is not yet implemented" )
57
64
58
65
def get_compression_level (self ) -> uint8 :
59
- raise AssertionError ("get_compression_level() should never be called on V2 plots" )
66
+ # v2 plots are never compressed
67
+ return uint8 (0 )
60
68
61
69
def get_version (self ) -> PlotVersion :
62
70
return PlotVersion .V2
@@ -69,13 +77,15 @@ def get_id(self) -> bytes32:
69
77
# TODO: Extract plot ID from V2 plot file
70
78
raise NotImplementedError ("V2 plot format is not yet implemented" )
71
79
72
- def get_qualities_for_challenge (self , challenge : bytes32 ) -> list [bytes32 ]:
80
+ def get_partial_proofs_for_challenge (self , challenge : bytes , plot_strength : uint8 ) -> list [bytes ]:
73
81
# TODO: todo_v2_plots Implement plot quality lookup
74
82
raise NotImplementedError ("V2 plot format is not yet implemented" )
75
83
76
- def get_partial_proofs_for_challenge (self , challenge : bytes32 ) -> list [bytes ]:
77
- # TODO: todo_v2_plots Implement quality chain lookup (16 * k bits blobs)
78
- raise NotImplementedError ("V2 plot format is not yet implemented" )
84
+ def get_qualities_for_challenge (self , challenge : bytes32 , plot_strength : uint8 ) -> list [bytes32 ]:
85
+ return [
86
+ quality_for_partial_proof (partial , challenge )
87
+ for partial in self .get_partial_proofs_for_challenge (challenge , plot_strength )
88
+ ]
79
89
80
90
def get_full_proof (self , challenge : bytes32 , index : int , parallel_read : bool = True ) -> bytes :
81
91
raise AssertionError ("V2 plot format require solver to get full proof" )
@@ -116,11 +126,11 @@ def __bytes__(self) -> bytes:
116
126
def get_id (self ) -> bytes32 :
117
127
return bytes32 (self ._disk_prover .get_id ())
118
128
119
- def get_qualities_for_challenge (self , challenge : bytes32 ) -> list [bytes32 ]:
120
- return [ bytes32 ( quality ) for quality in self . _disk_prover . get_qualities_for_challenge ( challenge )]
129
+ def get_partial_proofs_for_challenge (self , challenge : bytes32 , plot_strength : uint8 ) -> list [bytes ]:
130
+ raise AssertionError ( "V1 plot format doesn't use partial proofs" )
121
131
122
- def get_partial_proofs_for_challenge (self , challenge : bytes32 ) -> list [bytes ]:
123
- raise AssertionError ( "V1 does not implement quality chains, only qualities" )
132
+ def get_qualities_for_challenge (self , challenge : bytes32 , plot_strength : uint8 ) -> list [bytes32 ]:
133
+ return [ bytes32 ( quality ) for quality in self . _disk_prover . get_qualities_for_challenge ( challenge )]
124
134
125
135
def get_full_proof (self , challenge : bytes32 , index : int , parallel_read : bool = True ) -> bytes :
126
136
return bytes (self ._disk_prover .get_full_proof (challenge , index , parallel_read ))
0 commit comments