@@ -9,10 +9,11 @@ use filecoin_proofs_v1::{PoRepConfig, PoRepProofPartitions, PoStConfig, PoStType
9
9
use lazy_static:: lazy_static;
10
10
use serde:: { Deserialize , Serialize } ;
11
11
12
- use crate :: { get_parameter_data, get_verifying_key_data, ApiVersion , MerkleTreeTrait } ;
12
+ use crate :: { get_parameter_data, get_verifying_key_data, ApiFeature , ApiVersion , MerkleTreeTrait } ;
13
13
14
14
/// Available seal proofs.
15
15
// Enum is append-only: once published, a `RegisteredSealProof` value must never change.
16
+ #[ allow( non_camel_case_types) ]
16
17
#[ derive( Clone , Copy , Debug , PartialEq , Eq , Hash , Serialize , Deserialize ) ]
17
18
pub enum RegisteredSealProof {
18
19
StackedDrg2KiBV1 ,
@@ -26,6 +27,12 @@ pub enum RegisteredSealProof {
26
27
StackedDrg512MiBV1_1 ,
27
28
StackedDrg32GiBV1_1 ,
28
29
StackedDrg64GiBV1_1 ,
30
+
31
+ StackedDrg2KiBV1_1_Feat_SyntheticPoRep ,
32
+ StackedDrg8MiBV1_1_Feat_SyntheticPoRep ,
33
+ StackedDrg512MiBV1_1_Feat_SyntheticPoRep ,
34
+ StackedDrg32GiBV1_1_Feat_SyntheticPoRep ,
35
+ StackedDrg64GiBV1_1_Feat_SyntheticPoRep ,
29
36
}
30
37
31
38
// This maps all registered seal proof enum types to porep_id values.
@@ -41,6 +48,26 @@ lazy_static! {
41
48
( RegisteredSealProof :: StackedDrg512MiBV1_1 , 7 ) ,
42
49
( RegisteredSealProof :: StackedDrg32GiBV1_1 , 8 ) ,
43
50
( RegisteredSealProof :: StackedDrg64GiBV1_1 , 9 ) ,
51
+ (
52
+ RegisteredSealProof :: StackedDrg2KiBV1_1_Feat_SyntheticPoRep ,
53
+ 10
54
+ ) ,
55
+ (
56
+ RegisteredSealProof :: StackedDrg8MiBV1_1_Feat_SyntheticPoRep ,
57
+ 11
58
+ ) ,
59
+ (
60
+ RegisteredSealProof :: StackedDrg512MiBV1_1_Feat_SyntheticPoRep ,
61
+ 12
62
+ ) ,
63
+ (
64
+ RegisteredSealProof :: StackedDrg32GiBV1_1_Feat_SyntheticPoRep ,
65
+ 13
66
+ ) ,
67
+ (
68
+ RegisteredSealProof :: StackedDrg64GiBV1_1_Feat_SyntheticPoRep ,
69
+ 14
70
+ ) ,
44
71
]
45
72
. into_iter( )
46
73
. collect( ) ;
@@ -85,8 +112,16 @@ impl RegisteredSealProof {
85
112
match self {
86
113
StackedDrg2KiBV1 | StackedDrg8MiBV1 | StackedDrg512MiBV1 | StackedDrg32GiBV1
87
114
| StackedDrg64GiBV1 => ApiVersion :: V1_0_0 ,
88
- StackedDrg2KiBV1_1 | StackedDrg8MiBV1_1 | StackedDrg512MiBV1_1
89
- | StackedDrg32GiBV1_1 | StackedDrg64GiBV1_1 => ApiVersion :: V1_1_0 ,
115
+ StackedDrg2KiBV1_1
116
+ | StackedDrg8MiBV1_1
117
+ | StackedDrg512MiBV1_1
118
+ | StackedDrg32GiBV1_1
119
+ | StackedDrg64GiBV1_1
120
+ | StackedDrg2KiBV1_1_Feat_SyntheticPoRep
121
+ | StackedDrg8MiBV1_1_Feat_SyntheticPoRep
122
+ | StackedDrg512MiBV1_1_Feat_SyntheticPoRep
123
+ | StackedDrg32GiBV1_1_Feat_SyntheticPoRep
124
+ | StackedDrg64GiBV1_1_Feat_SyntheticPoRep => ApiVersion :: V1_1_0 ,
90
125
}
91
126
}
92
127
@@ -109,11 +144,21 @@ impl RegisteredSealProof {
109
144
pub fn sector_size ( self ) -> SectorSize {
110
145
use RegisteredSealProof :: * ;
111
146
let size = match self {
112
- StackedDrg2KiBV1 | StackedDrg2KiBV1_1 => constants:: SECTOR_SIZE_2_KIB ,
113
- StackedDrg8MiBV1 | StackedDrg8MiBV1_1 => constants:: SECTOR_SIZE_8_MIB ,
114
- StackedDrg512MiBV1 | StackedDrg512MiBV1_1 => constants:: SECTOR_SIZE_512_MIB ,
115
- StackedDrg32GiBV1 | StackedDrg32GiBV1_1 => constants:: SECTOR_SIZE_32_GIB ,
116
- StackedDrg64GiBV1 | StackedDrg64GiBV1_1 => constants:: SECTOR_SIZE_64_GIB ,
147
+ StackedDrg2KiBV1 | StackedDrg2KiBV1_1 | StackedDrg2KiBV1_1_Feat_SyntheticPoRep => {
148
+ constants:: SECTOR_SIZE_2_KIB
149
+ }
150
+ StackedDrg8MiBV1 | StackedDrg8MiBV1_1 | StackedDrg8MiBV1_1_Feat_SyntheticPoRep => {
151
+ constants:: SECTOR_SIZE_8_MIB
152
+ }
153
+ StackedDrg512MiBV1
154
+ | StackedDrg512MiBV1_1
155
+ | StackedDrg512MiBV1_1_Feat_SyntheticPoRep => constants:: SECTOR_SIZE_512_MIB ,
156
+ StackedDrg32GiBV1 | StackedDrg32GiBV1_1 | StackedDrg32GiBV1_1_Feat_SyntheticPoRep => {
157
+ constants:: SECTOR_SIZE_32_GIB
158
+ }
159
+ StackedDrg64GiBV1 | StackedDrg64GiBV1_1 | StackedDrg64GiBV1_1_Feat_SyntheticPoRep => {
160
+ constants:: SECTOR_SIZE_64_GIB
161
+ }
117
162
} ;
118
163
SectorSize ( size)
119
164
}
@@ -122,31 +167,41 @@ impl RegisteredSealProof {
122
167
pub fn partitions ( self ) -> u8 {
123
168
use RegisteredSealProof :: * ;
124
169
match self {
125
- StackedDrg2KiBV1 | StackedDrg2KiBV1_1 => * constants:: POREP_PARTITIONS
126
- . read ( )
127
- . expect ( "porep partitions read error" )
128
- . get ( & constants:: SECTOR_SIZE_2_KIB )
129
- . expect ( "invalid sector size" ) ,
130
- StackedDrg8MiBV1 | StackedDrg8MiBV1_1 => * constants:: POREP_PARTITIONS
131
- . read ( )
132
- . expect ( "porep partitions read error" )
133
- . get ( & constants:: SECTOR_SIZE_8_MIB )
134
- . expect ( "invalid sector size" ) ,
135
- StackedDrg512MiBV1 | StackedDrg512MiBV1_1 => * constants:: POREP_PARTITIONS
170
+ StackedDrg2KiBV1 | StackedDrg2KiBV1_1 | StackedDrg2KiBV1_1_Feat_SyntheticPoRep => {
171
+ * constants:: POREP_PARTITIONS
172
+ . read ( )
173
+ . expect ( "porep partitions read error" )
174
+ . get ( & constants:: SECTOR_SIZE_2_KIB )
175
+ . expect ( "invalid sector size" )
176
+ }
177
+ StackedDrg8MiBV1 | StackedDrg8MiBV1_1 | StackedDrg8MiBV1_1_Feat_SyntheticPoRep => {
178
+ * constants:: POREP_PARTITIONS
179
+ . read ( )
180
+ . expect ( "porep partitions read error" )
181
+ . get ( & constants:: SECTOR_SIZE_8_MIB )
182
+ . expect ( "invalid sector size" )
183
+ }
184
+ StackedDrg512MiBV1
185
+ | StackedDrg512MiBV1_1
186
+ | StackedDrg512MiBV1_1_Feat_SyntheticPoRep => * constants:: POREP_PARTITIONS
136
187
. read ( )
137
188
. expect ( "porep partitions read error" )
138
189
. get ( & constants:: SECTOR_SIZE_512_MIB )
139
190
. expect ( "invalid sector size" ) ,
140
- StackedDrg32GiBV1 | StackedDrg32GiBV1_1 => * constants:: POREP_PARTITIONS
141
- . read ( )
142
- . expect ( "porep partitions read error" )
143
- . get ( & constants:: SECTOR_SIZE_32_GIB )
144
- . expect ( "invalid sector size" ) ,
145
- StackedDrg64GiBV1 | StackedDrg64GiBV1_1 => * constants:: POREP_PARTITIONS
146
- . read ( )
147
- . expect ( "porep partitions read error" )
148
- . get ( & constants:: SECTOR_SIZE_64_GIB )
149
- . expect ( "invalid sector size" ) ,
191
+ StackedDrg32GiBV1 | StackedDrg32GiBV1_1 | StackedDrg32GiBV1_1_Feat_SyntheticPoRep => {
192
+ * constants:: POREP_PARTITIONS
193
+ . read ( )
194
+ . expect ( "porep partitions read error" )
195
+ . get ( & constants:: SECTOR_SIZE_32_GIB )
196
+ . expect ( "invalid sector size" )
197
+ }
198
+ StackedDrg64GiBV1 | StackedDrg64GiBV1_1 | StackedDrg64GiBV1_1_Feat_SyntheticPoRep => {
199
+ * constants:: POREP_PARTITIONS
200
+ . read ( )
201
+ . expect ( "porep partitions read error" )
202
+ . get ( & constants:: SECTOR_SIZE_64_GIB )
203
+ . expect ( "invalid sector size" )
204
+ }
150
205
}
151
206
}
152
207
@@ -155,9 +210,21 @@ impl RegisteredSealProof {
155
210
use RegisteredSealProof :: * ;
156
211
157
212
match self {
158
- StackedDrg2KiBV1 | StackedDrg8MiBV1 | StackedDrg512MiBV1 | StackedDrg32GiBV1
159
- | StackedDrg64GiBV1 | StackedDrg2KiBV1_1 | StackedDrg8MiBV1_1
160
- | StackedDrg512MiBV1_1 | StackedDrg32GiBV1_1 | StackedDrg64GiBV1_1 => {
213
+ StackedDrg2KiBV1
214
+ | StackedDrg8MiBV1
215
+ | StackedDrg512MiBV1
216
+ | StackedDrg32GiBV1
217
+ | StackedDrg64GiBV1
218
+ | StackedDrg2KiBV1_1
219
+ | StackedDrg8MiBV1_1
220
+ | StackedDrg512MiBV1_1
221
+ | StackedDrg32GiBV1_1
222
+ | StackedDrg64GiBV1_1
223
+ | StackedDrg2KiBV1_1_Feat_SyntheticPoRep
224
+ | StackedDrg8MiBV1_1_Feat_SyntheticPoRep
225
+ | StackedDrg512MiBV1_1_Feat_SyntheticPoRep
226
+ | StackedDrg32GiBV1_1_Feat_SyntheticPoRep
227
+ | StackedDrg64GiBV1_1_Feat_SyntheticPoRep => {
161
228
filecoin_proofs_v1:: SINGLE_PARTITION_PROOF_LEN
162
229
}
163
230
}
@@ -208,10 +275,29 @@ impl RegisteredSealProof {
208
275
api_version : self . version ( ) ,
209
276
api_features : Vec :: new ( ) ,
210
277
}
278
+ }
279
+ StackedDrg2KiBV1_1_Feat_SyntheticPoRep
280
+ | StackedDrg8MiBV1_1_Feat_SyntheticPoRep
281
+ | StackedDrg512MiBV1_1_Feat_SyntheticPoRep
282
+ | StackedDrg32GiBV1_1_Feat_SyntheticPoRep
283
+ | StackedDrg64GiBV1_1_Feat_SyntheticPoRep => {
284
+ assert_eq ! ( self . version( ) , ApiVersion :: V1_1_0 ) ;
285
+ PoRepConfig {
286
+ sector_size : self . sector_size ( ) ,
287
+ partitions : PoRepProofPartitions ( self . partitions ( ) ) ,
288
+ porep_id : self . porep_id ( ) ,
289
+ api_version : self . version ( ) ,
290
+ api_features : vec ! [ ApiFeature :: SyntheticPoRep ] ,
291
+ }
211
292
} // _ => panic!("Can only be called on V1 configs"),
212
293
}
213
294
}
214
295
296
+ /// Returns if the feature is enabled based on the proof type
297
+ pub fn feature_enabled ( self , api_feature : ApiFeature ) -> bool {
298
+ self . as_v1_config ( ) . api_features . contains ( & api_feature)
299
+ }
300
+
215
301
/// Returns the circuit identifier.
216
302
pub fn circuit_identifier ( self ) -> Result < String > {
217
303
match self . version ( ) {
@@ -284,11 +370,21 @@ impl RegisteredSealProof {
284
370
use RegisteredPoStProof :: * ;
285
371
use RegisteredSealProof :: * ;
286
372
match self {
287
- StackedDrg2KiBV1 | StackedDrg2KiBV1_1 => StackedDrgWinning2KiBV1 ,
288
- StackedDrg8MiBV1 | StackedDrg8MiBV1_1 => StackedDrgWinning8MiBV1 ,
289
- StackedDrg512MiBV1 | StackedDrg512MiBV1_1 => StackedDrgWinning512MiBV1 ,
290
- StackedDrg32GiBV1 | StackedDrg32GiBV1_1 => StackedDrgWinning32GiBV1 ,
291
- StackedDrg64GiBV1 | StackedDrg64GiBV1_1 => StackedDrgWinning64GiBV1 ,
373
+ StackedDrg2KiBV1 | StackedDrg2KiBV1_1 | StackedDrg2KiBV1_1_Feat_SyntheticPoRep => {
374
+ StackedDrgWinning2KiBV1
375
+ }
376
+ StackedDrg8MiBV1 | StackedDrg8MiBV1_1 | StackedDrg8MiBV1_1_Feat_SyntheticPoRep => {
377
+ StackedDrgWinning8MiBV1
378
+ }
379
+ StackedDrg512MiBV1
380
+ | StackedDrg512MiBV1_1
381
+ | StackedDrg512MiBV1_1_Feat_SyntheticPoRep => StackedDrgWinning512MiBV1 ,
382
+ StackedDrg32GiBV1 | StackedDrg32GiBV1_1 | StackedDrg32GiBV1_1_Feat_SyntheticPoRep => {
383
+ StackedDrgWinning32GiBV1
384
+ }
385
+ StackedDrg64GiBV1 | StackedDrg64GiBV1_1 | StackedDrg64GiBV1_1_Feat_SyntheticPoRep => {
386
+ StackedDrgWinning64GiBV1
387
+ }
292
388
}
293
389
}
294
390
@@ -304,11 +400,21 @@ impl RegisteredSealProof {
304
400
use RegisteredPoStProof :: * ;
305
401
use RegisteredSealProof :: * ;
306
402
match self {
307
- StackedDrg2KiBV1 | StackedDrg2KiBV1_1 => StackedDrgWindow2KiBV1_2 ,
308
- StackedDrg8MiBV1 | StackedDrg8MiBV1_1 => StackedDrgWindow8MiBV1_2 ,
309
- StackedDrg512MiBV1 | StackedDrg512MiBV1_1 => StackedDrgWindow512MiBV1_2 ,
310
- StackedDrg32GiBV1 | StackedDrg32GiBV1_1 => StackedDrgWindow32GiBV1_2 ,
311
- StackedDrg64GiBV1 | StackedDrg64GiBV1_1 => StackedDrgWindow64GiBV1_2 ,
403
+ StackedDrg2KiBV1 | StackedDrg2KiBV1_1 | StackedDrg2KiBV1_1_Feat_SyntheticPoRep => {
404
+ StackedDrgWindow2KiBV1_2
405
+ }
406
+ StackedDrg8MiBV1 | StackedDrg8MiBV1_1 | StackedDrg8MiBV1_1_Feat_SyntheticPoRep => {
407
+ StackedDrgWindow8MiBV1_2
408
+ }
409
+ StackedDrg512MiBV1
410
+ | StackedDrg512MiBV1_1
411
+ | StackedDrg512MiBV1_1_Feat_SyntheticPoRep => StackedDrgWindow512MiBV1_2 ,
412
+ StackedDrg32GiBV1 | StackedDrg32GiBV1_1 | StackedDrg32GiBV1_1_Feat_SyntheticPoRep => {
413
+ StackedDrgWindow32GiBV1_2
414
+ }
415
+ StackedDrg64GiBV1 | StackedDrg64GiBV1_1 | StackedDrg64GiBV1_1_Feat_SyntheticPoRep => {
416
+ StackedDrgWindow64GiBV1_2
417
+ }
312
418
}
313
419
}
314
420
}
@@ -770,7 +876,7 @@ mod tests {
770
876
use super :: * ;
771
877
use filecoin_proofs_v1:: MAX_LEGACY_REGISTERED_SEAL_PROOF_ID ;
772
878
773
- const REGISTERED_SEAL_PROOFS : [ RegisteredSealProof ; 10 ] = [
879
+ const REGISTERED_SEAL_PROOFS : [ RegisteredSealProof ; 15 ] = [
774
880
RegisteredSealProof :: StackedDrg2KiBV1 ,
775
881
RegisteredSealProof :: StackedDrg8MiBV1 ,
776
882
RegisteredSealProof :: StackedDrg512MiBV1 ,
@@ -781,6 +887,11 @@ mod tests {
781
887
RegisteredSealProof :: StackedDrg512MiBV1_1 ,
782
888
RegisteredSealProof :: StackedDrg32GiBV1_1 ,
783
889
RegisteredSealProof :: StackedDrg64GiBV1_1 ,
890
+ RegisteredSealProof :: StackedDrg2KiBV1_1_Feat_SyntheticPoRep ,
891
+ RegisteredSealProof :: StackedDrg8MiBV1_1_Feat_SyntheticPoRep ,
892
+ RegisteredSealProof :: StackedDrg512MiBV1_1_Feat_SyntheticPoRep ,
893
+ RegisteredSealProof :: StackedDrg32GiBV1_1_Feat_SyntheticPoRep ,
894
+ RegisteredSealProof :: StackedDrg64GiBV1_1_Feat_SyntheticPoRep ,
784
895
] ;
785
896
786
897
#[ test]
@@ -822,6 +933,21 @@ mod tests {
822
933
RegisteredSealProof :: StackedDrg64GiBV1_1 => {
823
934
"0900000000000000000000000000000000000000000000000000000000000000"
824
935
}
936
+ RegisteredSealProof :: StackedDrg2KiBV1_1_Feat_SyntheticPoRep => {
937
+ "0a00000000000000000000000000000000000000000000000000000000000000"
938
+ }
939
+ RegisteredSealProof :: StackedDrg8MiBV1_1_Feat_SyntheticPoRep => {
940
+ "0b00000000000000000000000000000000000000000000000000000000000000"
941
+ }
942
+ RegisteredSealProof :: StackedDrg512MiBV1_1_Feat_SyntheticPoRep => {
943
+ "0c00000000000000000000000000000000000000000000000000000000000000"
944
+ }
945
+ RegisteredSealProof :: StackedDrg32GiBV1_1_Feat_SyntheticPoRep => {
946
+ "0d00000000000000000000000000000000000000000000000000000000000000"
947
+ }
948
+ RegisteredSealProof :: StackedDrg64GiBV1_1_Feat_SyntheticPoRep => {
949
+ "0e00000000000000000000000000000000000000000000000000000000000000"
950
+ }
825
951
} ;
826
952
let hex: String = rsp
827
953
. porep_id ( )
@@ -854,7 +980,14 @@ mod tests {
854
980
| RegisteredSealProof :: StackedDrg8MiBV1_1
855
981
| RegisteredSealProof :: StackedDrg512MiBV1_1
856
982
| RegisteredSealProof :: StackedDrg32GiBV1_1
857
- | RegisteredSealProof :: StackedDrg64GiBV1_1 => assert ! ( !is_legacy) ,
983
+ | RegisteredSealProof :: StackedDrg64GiBV1_1
984
+ | RegisteredSealProof :: StackedDrg2KiBV1_1_Feat_SyntheticPoRep
985
+ | RegisteredSealProof :: StackedDrg8MiBV1_1_Feat_SyntheticPoRep
986
+ | RegisteredSealProof :: StackedDrg512MiBV1_1_Feat_SyntheticPoRep
987
+ | RegisteredSealProof :: StackedDrg32GiBV1_1_Feat_SyntheticPoRep
988
+ | RegisteredSealProof :: StackedDrg64GiBV1_1_Feat_SyntheticPoRep => {
989
+ assert ! ( !is_legacy)
990
+ }
858
991
}
859
992
}
860
993
}
0 commit comments