diff --git a/frame/babe/src/equivocation.rs b/frame/babe/src/equivocation.rs index d9a097da76b24..bafec08d98d90 100644 --- a/frame/babe/src/equivocation.rs +++ b/frame/babe/src/equivocation.rs @@ -34,7 +34,7 @@ //! that the `ValidateUnsigned` for the BABE pallet is used in the runtime //! definition. -use frame_support::traits::{Get, KeyOwnerProofSystem}; +use frame_support::traits::{Get, KeyOwnerProofSystem, FindAuthor}; use frame_system::pallet_prelude::HeaderFor; use log::{error, info}; @@ -164,7 +164,11 @@ where evidence: (EquivocationProof>, T::KeyOwnerProof), ) -> Result<(), DispatchError> { let (equivocation_proof, key_owner_proof) = evidence; - let reporter = reporter.or_else(|| >::author()); + let reporter = reporter.or_else(|| { + let digest = >::digest(); + let pre_runtime_digests = digest.logs.iter().filter_map(|d| d.as_pre_runtime()); + ::FindAuthor::find_author(pre_runtime_digests) + }); let offender = equivocation_proof.offender.clone(); let slot = equivocation_proof.slot; diff --git a/frame/babe/src/lib.rs b/frame/babe/src/lib.rs index 793718146462b..c2915a4172476 100644 --- a/frame/babe/src/lib.rs +++ b/frame/babe/src/lib.rs @@ -166,6 +166,8 @@ pub mod pallet { Option, (EquivocationProof>, Self::KeyOwnerProof), >; + + type FindAuthor: FindAuthor; } #[pallet::error] diff --git a/frame/grandpa/src/equivocation.rs b/frame/grandpa/src/equivocation.rs index e32886603e8f5..1da836c8e927d 100644 --- a/frame/grandpa/src/equivocation.rs +++ b/frame/grandpa/src/equivocation.rs @@ -37,7 +37,7 @@ //! definition. use codec::{self as codec, Decode, Encode}; -use frame_support::traits::{Get, KeyOwnerProofSystem}; +use frame_support::traits::{Get, KeyOwnerProofSystem, FindAuthor}; use frame_system::pallet_prelude::BlockNumberFor; use log::{error, info}; use sp_consensus_grandpa::{AuthorityId, EquivocationProof, RoundNumber, SetId, KEY_TYPE}; @@ -177,7 +177,11 @@ where evidence: (EquivocationProof>, T::KeyOwnerProof), ) -> Result<(), DispatchError> { let (equivocation_proof, key_owner_proof) = evidence; - let reporter = reporter.or_else(|| >::author()); + let reporter = reporter.or_else(|| { + let digest = >::digest(); + let pre_runtime_digests = digest.logs.iter().filter_map(|d| d.as_pre_runtime()); + ::FindAuthor::find_author(pre_runtime_digests) + }); let offender = equivocation_proof.offender().clone(); // We check the equivocation within the context of its set id (and diff --git a/frame/grandpa/src/lib.rs b/frame/grandpa/src/lib.rs index a9f0ccfeb7482..475b2d6d8d90a 100644 --- a/frame/grandpa/src/lib.rs +++ b/frame/grandpa/src/lib.rs @@ -39,7 +39,7 @@ use frame_support::{ dispatch::{DispatchResultWithPostInfo, Pays}, pallet_prelude::Get, storage, - traits::OneSessionHandler, + traits::{OneSessionHandler, FindAuthor}, weights::Weight, WeakBoundedVec, }; @@ -117,6 +117,8 @@ pub mod pallet { Option, (EquivocationProof>, Self::KeyOwnerProof), >; + + type FindAuthor: FindAuthor; } #[pallet::hooks]