@@ -20,7 +20,7 @@ use crate::LOG_TARGET;
2020
2121use beefy_primitives:: {
2222 crypto:: { AuthorityId , Public , Signature } ,
23- Commitment , EquivocationProof , SignedCommitment , ValidatorSet , ValidatorSetId , VoteMessage ,
23+ Commitment , SignedCommitment , ValidatorSet , ValidatorSetId , VoteMessage ,
2424} ;
2525use codec:: { Decode , Encode } ;
2626use log:: debug;
@@ -61,7 +61,7 @@ pub fn threshold(authorities: usize) -> usize {
6161pub enum VoteImportResult < B : Block > {
6262 Ok ,
6363 RoundConcluded ( SignedCommitment < NumberFor < B > , Signature > ) ,
64- Equivocation ( EquivocationProof < NumberFor < B > , Public , Signature > ) ,
64+ Equivocation , /* TODO: (EquivocationProof<NumberFor<B>, Public, Signature>) */
6565 Invalid ,
6666 Stale ,
6767}
@@ -149,10 +149,8 @@ where
149149 target: LOG_TARGET ,
150150 "🥩 detected equivocated vote: 1st: {:?}, 2nd: {:?}" , previous_vote, vote
151151 ) ;
152- return VoteImportResult :: Equivocation ( EquivocationProof {
153- first : previous_vote. clone ( ) ,
154- second : vote,
155- } )
152+ // TODO: build `EquivocationProof` and return it here.
153+ return VoteImportResult :: Equivocation
156154 }
157155 } else {
158156 // this is the first vote sent by `id` for `num`, all good
@@ -199,8 +197,8 @@ mod tests {
199197 use sc_network_test:: Block ;
200198
201199 use beefy_primitives:: {
202- crypto:: Public , known_payloads:: MMR_ROOT_ID , Commitment , EquivocationProof , Keyring ,
203- Payload , SignedCommitment , ValidatorSet , VoteMessage ,
200+ crypto:: Public , keyring :: Keyring , known_payloads:: MMR_ROOT_ID , Commitment , Payload ,
201+ SignedCommitment , ValidatorSet , VoteMessage ,
204202 } ;
205203
206204 use super :: { threshold, Block as BlockT , RoundTracker , Rounds } ;
@@ -454,42 +452,4 @@ mod tests {
454452 rounds. conclude ( 3 ) ;
455453 assert ! ( rounds. previous_votes. is_empty( ) ) ;
456454 }
457-
458- #[ test]
459- fn should_provide_equivocation_proof ( ) {
460- sp_tracing:: try_init_simple ( ) ;
461-
462- let validators = ValidatorSet :: < Public > :: new (
463- vec ! [ Keyring :: Alice . public( ) , Keyring :: Bob . public( ) ] ,
464- Default :: default ( ) ,
465- )
466- . unwrap ( ) ;
467- let validator_set_id = validators. id ( ) ;
468- let session_start = 1u64 . into ( ) ;
469- let mut rounds = Rounds :: < Block > :: new ( session_start, validators) ;
470-
471- let payload1 = Payload :: from_single_entry ( MMR_ROOT_ID , vec ! [ 1 , 1 , 1 , 1 ] ) ;
472- let payload2 = Payload :: from_single_entry ( MMR_ROOT_ID , vec ! [ 2 , 2 , 2 , 2 ] ) ;
473- let commitment1 = Commitment { block_number : 1 , payload : payload1, validator_set_id } ;
474- let commitment2 = Commitment { block_number : 1 , payload : payload2, validator_set_id } ;
475-
476- let alice_vote1 = VoteMessage {
477- id : Keyring :: Alice . public ( ) ,
478- commitment : commitment1,
479- signature : Keyring :: Alice . sign ( b"I am committed" ) ,
480- } ;
481- let mut alice_vote2 = alice_vote1. clone ( ) ;
482- alice_vote2. commitment = commitment2;
483-
484- let expected_result = VoteImportResult :: Equivocation ( EquivocationProof {
485- first : alice_vote1. clone ( ) ,
486- second : alice_vote2. clone ( ) ,
487- } ) ;
488-
489- // vote on one payload - ok
490- assert_eq ! ( rounds. add_vote( alice_vote1) , VoteImportResult :: Ok ) ;
491-
492- // vote on _another_ commitment/payload -> expected equivocation proof
493- assert_eq ! ( rounds. add_vote( alice_vote2) , expected_result) ;
494- }
495455}
0 commit comments