mirror of
https://github.com/datahaven-xyz/datahaven
synced 2026-05-24 09:50:01 +00:00
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`.
This commit is contained in:
parent
b2031f4d00
commit
2cabedc223
1 changed files with 9 additions and 7 deletions
|
|
@ -340,16 +340,18 @@ impl FeeCalculator for TransactionPaymentAsGasPrice {
|
|||
}
|
||||
}
|
||||
|
||||
pub struct FindAuthorAdapter;
|
||||
impl FindAuthor<H160> for FindAuthorAdapter {
|
||||
pub struct FindAuthorAdapter<T>(core::marker::PhantomData<T>);
|
||||
impl<T> FindAuthor<H160> for FindAuthorAdapter<T>
|
||||
where
|
||||
T: frame_system::Config + pallet_session::Config,
|
||||
<T as pallet_session::Config>::ValidatorId: Into<H160>,
|
||||
{
|
||||
fn find_author<'a, I>(digests: I) -> Option<H160>
|
||||
where
|
||||
I: 'a + IntoIterator<Item = (sp_runtime::ConsensusEngineId, &'a [u8])>,
|
||||
{
|
||||
if let Some(author) = Babe::find_author(digests) {
|
||||
return Some(H160::from_slice(&author.encode()[0..20]));
|
||||
}
|
||||
None
|
||||
pallet_session::FindAccountFromAuthorIndex::<T, Babe>::find_author(digests)
|
||||
.map(|author| author.into())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -383,7 +385,7 @@ impl pallet_evm::Config for Runtime {
|
|||
type Runner = pallet_evm::runner::stack::Runner<Self>;
|
||||
type OnChargeTransaction = OnChargeEVMTransaction<()>;
|
||||
type OnCreate = ();
|
||||
type FindAuthor = FindAuthorAdapter;
|
||||
type FindAuthor = FindAuthorAdapter<Self>;
|
||||
type GasLimitPovSizeRatio = GasLimitPovSizeRatio;
|
||||
type GasLimitStorageGrowthRatio = ();
|
||||
type Timestamp = Timestamp;
|
||||
|
|
|
|||
Loading…
Reference in a new issue