@@ -26,8 +26,6 @@ use std::path::PathBuf;
2626
2727pub use storage_proofs:: election_post:: Candidate ;
2828
29- pub const CHALLENGE_COUNT_DENOMINATOR : f64 = 25. ;
30-
3129/// The minimal information required about a replica, in order to be able to generate
3230/// a PoSt over it.
3331#[ derive( Clone , Debug , PartialEq , Eq , Hash ) ]
@@ -38,8 +36,6 @@ pub struct PrivateReplicaInfo {
3836 comm_r : Commitment ,
3937 /// Persistent Aux.
4038 aux : PersistentAux ,
41- /// Is this sector marked as a fault?
42- is_fault : bool ,
4339 /// Contains sector-specific (e.g. merkle trees) assets
4440 cache_dir : PathBuf ,
4541}
@@ -62,22 +58,6 @@ impl PrivateReplicaInfo {
6258 access,
6359 comm_r,
6460 aux,
65- is_fault : false ,
66- cache_dir,
67- }
68- }
69-
70- pub fn new_faulty (
71- access : String ,
72- comm_r : Commitment ,
73- aux : PersistentAux ,
74- cache_dir : PathBuf ,
75- ) -> Self {
76- PrivateReplicaInfo {
77- access,
78- comm_r,
79- aux,
80- is_fault : true ,
8161 cache_dir,
8262 }
8363 }
@@ -113,8 +93,6 @@ impl PrivateReplicaInfo {
11393pub struct PublicReplicaInfo {
11494 /// The replica commitment.
11595 comm_r : Commitment ,
116- /// Is this sector marked as a fault?
117- is_fault : bool ,
11896}
11997
12098impl std:: cmp:: Ord for PublicReplicaInfo {
@@ -131,17 +109,7 @@ impl std::cmp::PartialOrd for PublicReplicaInfo {
131109
132110impl PublicReplicaInfo {
133111 pub fn new ( comm_r : Commitment ) -> Self {
134- PublicReplicaInfo {
135- comm_r,
136- is_fault : false ,
137- }
138- }
139-
140- pub fn new_faulty ( comm_r : Commitment ) -> Self {
141- PublicReplicaInfo {
142- comm_r,
143- is_fault : true ,
144- }
112+ PublicReplicaInfo { comm_r }
145113 }
146114
147115 pub fn safe_comm_r ( & self ) -> Result < <DefaultTreeHasher as Hasher >:: Domain , failure:: Error > {
@@ -170,17 +138,8 @@ pub fn generate_candidates(
170138 let sector_size = u64:: from ( PaddedBytesAmount :: from ( post_config) ) ;
171139
172140 let sectors = replicas. keys ( ) . copied ( ) . collect ( ) ;
173- let faults = replicas
174- . iter ( )
175- . filter ( |( _id, replica) | replica. is_fault )
176- . count ( ) ;
177-
178- let active_sector_count = sector_count - faults as u64 ;
179- let challenged_sectors_count =
180- ( active_sector_count as f64 / CHALLENGE_COUNT_DENOMINATOR ) . ceil ( ) as usize ;
181141
182- let challenged_sectors =
183- election_post:: generate_sector_challenges ( randomness, challenged_sectors_count, & sectors) ?;
142+ let challenged_sectors = election_post:: generate_sector_challenges ( randomness, & sectors) ?;
184143
185144 // Match the replicas to the challenges, as these are the only ones required.
186145 let challenged_replicas: Vec < _ > = challenged_sectors
@@ -310,6 +269,7 @@ pub fn verify_post(
310269 "Missmatch between winners and proofs"
311270 ) ;
312271
272+ let sectors = replicas. keys ( ) . copied ( ) . collect ( ) ;
313273 let vanilla_params = post_setup_params ( post_config) ;
314274 let setup_params = compound_proof:: SetupParams {
315275 vanilla_params,
@@ -331,6 +291,22 @@ pub fn verify_post(
331291 } ;
332292 let comm_r = replica. safe_comm_r ( ) ?;
333293
294+ if !election_post:: is_valid_sector_challenge_index (
295+ sector_count as usize ,
296+ winner. sector_challenge_index ,
297+ ) {
298+ return Ok ( false ) ;
299+ }
300+
301+ let expected_sector_id = election_post:: generate_sector_challenge (
302+ randomness,
303+ winner. sector_challenge_index as usize ,
304+ & sectors,
305+ ) ?;
306+ if expected_sector_id != winner. sector_id {
307+ return Ok ( false ) ;
308+ }
309+
334310 let proof = MultiProof :: new_from_reader ( None , & proof[ ..] , & verifying_key) ?;
335311 let pub_inputs = election_post:: PublicInputs {
336312 randomness : * randomness,
0 commit comments