2424use codec:: { Decode , Encode } ;
2525use frame_support:: {
2626 decl_error, decl_module, decl_storage,
27+ dispatch:: DispatchResultWithPostInfo ,
2728 traits:: { FindAuthor , Get , KeyOwnerProofSystem , Randomness as RandomnessT } ,
28- weights:: Weight ,
29+ weights:: { Pays , Weight } ,
2930 Parameter ,
3031} ;
3132use frame_system:: { ensure_none, ensure_signed} ;
@@ -260,14 +261,14 @@ decl_module! {
260261 origin,
261262 equivocation_proof: EquivocationProof <T :: Header >,
262263 key_owner_proof: T :: KeyOwnerProof ,
263- ) {
264+ ) -> DispatchResultWithPostInfo {
264265 let reporter = ensure_signed( origin) ?;
265266
266267 Self :: do_report_equivocation(
267268 Some ( reporter) ,
268269 equivocation_proof,
269270 key_owner_proof,
270- ) ? ;
271+ )
271272 }
272273
273274 /// Report authority equivocation/misbehavior. This method will verify
@@ -283,14 +284,14 @@ decl_module! {
283284 origin,
284285 equivocation_proof: EquivocationProof <T :: Header >,
285286 key_owner_proof: T :: KeyOwnerProof ,
286- ) {
287+ ) -> DispatchResultWithPostInfo {
287288 ensure_none( origin) ?;
288289
289290 Self :: do_report_equivocation(
290291 T :: HandleEquivocation :: block_author( ) ,
291292 equivocation_proof,
292293 key_owner_proof,
293- ) ? ;
294+ )
294295 }
295296 }
296297}
@@ -637,13 +638,13 @@ impl<T: Trait> Module<T> {
637638 reporter : Option < T :: AccountId > ,
638639 equivocation_proof : EquivocationProof < T :: Header > ,
639640 key_owner_proof : T :: KeyOwnerProof ,
640- ) -> Result < ( ) , Error < T > > {
641+ ) -> DispatchResultWithPostInfo {
641642 let offender = equivocation_proof. offender . clone ( ) ;
642643 let slot_number = equivocation_proof. slot_number ;
643644
644645 // validate the equivocation proof
645646 if !sp_consensus_babe:: check_equivocation_proof ( equivocation_proof) {
646- return Err ( Error :: InvalidEquivocationProof . into ( ) ) ;
647+ return Err ( Error :: < T > :: InvalidEquivocationProof . into ( ) ) ;
647648 }
648649
649650 let validator_set_count = key_owner_proof. validator_count ( ) ;
@@ -655,13 +656,13 @@ impl<T: Trait> Module<T> {
655656 // check that the slot number is consistent with the session index
656657 // in the key ownership proof (i.e. slot is for that epoch)
657658 if epoch_index != session_index {
658- return Err ( Error :: InvalidKeyOwnershipProof . into ( ) ) ;
659+ return Err ( Error :: < T > :: InvalidKeyOwnershipProof . into ( ) ) ;
659660 }
660661
661662 // check the membership proof and extract the offender's id
662663 let key = ( sp_consensus_babe:: KEY_TYPE , offender) ;
663664 let offender = T :: KeyOwnerProofSystem :: check_proof ( key, key_owner_proof)
664- . ok_or ( Error :: InvalidKeyOwnershipProof ) ?;
665+ . ok_or ( Error :: < T > :: InvalidKeyOwnershipProof ) ?;
665666
666667 let offence = BabeEquivocationOffence {
667668 slot : slot_number,
@@ -676,9 +677,10 @@ impl<T: Trait> Module<T> {
676677 } ;
677678
678679 T :: HandleEquivocation :: report_offence ( reporters, offence)
679- . map_err ( |_| Error :: DuplicateOffenceReport ) ?;
680+ . map_err ( |_| Error :: < T > :: DuplicateOffenceReport ) ?;
680681
681- Ok ( ( ) )
682+ // waive the fee since the report is valid and beneficial
683+ Ok ( Pays :: No . into ( ) )
682684 }
683685
684686 /// Submits an extrinsic to report an equivocation. This method will create
0 commit comments