From 2cabedc223c615d39d10cb755ee934dc697e4bcb Mon Sep 17 00:00:00 2001 From: Steve Degosserie <723552+stiiifff@users.noreply.github.com> Date: Mon, 31 Mar 2025 20:37:59 +0200 Subject: [PATCH] Fix FindAuthorAdapter (#19) Current implementation was incorrect as `Babe::find_author` returns an index, not the author's account. Deferred the logic of looking up the author's account based on the index to the `pallet_session::FindAccountFromAuthorIndex` function, and use the existing conversion from `AccountId20` to `H160`. --- operator/runtime/src/configs/mod.rs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/operator/runtime/src/configs/mod.rs b/operator/runtime/src/configs/mod.rs index f61fe23f..c7a1b9b3 100644 --- a/operator/runtime/src/configs/mod.rs +++ b/operator/runtime/src/configs/mod.rs @@ -340,16 +340,18 @@ impl FeeCalculator for TransactionPaymentAsGasPrice { } } -pub struct FindAuthorAdapter; -impl FindAuthor for FindAuthorAdapter { +pub struct FindAuthorAdapter(core::marker::PhantomData); +impl FindAuthor for FindAuthorAdapter +where + T: frame_system::Config + pallet_session::Config, + ::ValidatorId: Into, +{ fn find_author<'a, I>(digests: I) -> Option where I: 'a + IntoIterator, { - if let Some(author) = Babe::find_author(digests) { - return Some(H160::from_slice(&author.encode()[0..20])); - } - None + pallet_session::FindAccountFromAuthorIndex::::find_author(digests) + .map(|author| author.into()) } } @@ -383,7 +385,7 @@ impl pallet_evm::Config for Runtime { type Runner = pallet_evm::runner::stack::Runner; type OnChargeTransaction = OnChargeEVMTransaction<()>; type OnCreate = (); - type FindAuthor = FindAuthorAdapter; + type FindAuthor = FindAuthorAdapter; type GasLimitPovSizeRatio = GasLimitPovSizeRatio; type GasLimitStorageGrowthRatio = (); type Timestamp = Timestamp;