diff --git a/node/service/src/chain_spec/moonbeam.rs b/node/service/src/chain_spec/moonbeam.rs index d719d0a3fa..a6580221d7 100644 --- a/node/service/src/chain_spec/moonbeam.rs +++ b/node/service/src/chain_spec/moonbeam.rs @@ -208,7 +208,7 @@ pub fn testnet_genesis( accounts: Precompiles::used_addresses() .map(|addr| { ( - addr, + addr.into(), GenesisAccount { nonce: Default::default(), balance: Default::default(), diff --git a/node/service/src/chain_spec/moonriver.rs b/node/service/src/chain_spec/moonriver.rs index b89b818f0c..9e81737e37 100644 --- a/node/service/src/chain_spec/moonriver.rs +++ b/node/service/src/chain_spec/moonriver.rs @@ -202,7 +202,7 @@ pub fn testnet_genesis( accounts: Precompiles::used_addresses() .map(|addr| { ( - addr, + addr.into(), GenesisAccount { nonce: Default::default(), balance: Default::default(), diff --git a/runtime/moonbeam/src/lib.rs b/runtime/moonbeam/src/lib.rs index b32b350698..e28f791f54 100644 --- a/runtime/moonbeam/src/lib.rs +++ b/runtime/moonbeam/src/lib.rs @@ -28,6 +28,7 @@ #[cfg(feature = "std")] include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); +use account::AccountId20; use cumulus_pallet_parachain_system::RelaychainBlockNumberProvider; use fp_rpc::TransactionStatus; use frame_support::{ @@ -50,7 +51,7 @@ use pallet_ethereum::Call::transact; use pallet_ethereum::Transaction as EthereumTransaction; use pallet_evm::{ Account as EVMAccount, EnsureAddressNever, EnsureAddressRoot, FeeCalculator, GasWeightMapping, - IdentityAddressMapping, Runner, + Runner, }; use pallet_transaction_payment::{CurrencyAdapter, Multiplier, TargetedFeeAdjustment}; pub use parachain_staking::{InflationInfo, Range}; @@ -369,13 +370,33 @@ impl FeeCalculator for FixedGasPrice { pub type SlowAdjustingFeeUpdate = TargetedFeeAdjustment; +use frame_support::traits::FindAuthor; +//TODO It feels like this shold be able to work for any T: H160, but I tried for +// embarassingly long and couldn't figure that out. + +/// The author inherent provides a AccountId20, but pallet evm needs an H160. +/// This simple adapter makes the conversion. +pub struct FindAuthorAdapter(sp_std::marker::PhantomData); + +impl FindAuthor for FindAuthorAdapter +where + Inner: FindAuthor, +{ + fn find_author<'a, I>(digests: I) -> Option + where + I: 'a + IntoIterator, + { + Inner::find_author(digests).map(Into::into) + } +} + impl pallet_evm::Config for Runtime { type FeeCalculator = FixedGasPrice; type GasWeightMapping = MoonbeamGasWeightMapping; type BlockHashMapping = pallet_ethereum::EthereumBlockHashMapping; type CallOrigin = EnsureAddressRoot; type WithdrawOrigin = EnsureAddressNever; - type AddressMapping = IdentityAddressMapping; + type AddressMapping = runtime_common::IntoAddressMapping; type Currency = Balances; type Event = Event; type Runner = pallet_evm::runner::stack::Runner; @@ -383,7 +404,7 @@ impl pallet_evm::Config for Runtime { type ChainId = EthereumChainId; type OnChargeTransaction = pallet_evm::EVMCurrencyAdapter>; type BlockGasLimit = BlockGasLimit; - type FindAuthor = AuthorInherent; + type FindAuthor = FindAuthorAdapter; } parameter_types! { diff --git a/runtime/moonriver/src/lib.rs b/runtime/moonriver/src/lib.rs index bc22e5f31f..f48aab7b0c 100644 --- a/runtime/moonriver/src/lib.rs +++ b/runtime/moonriver/src/lib.rs @@ -28,6 +28,7 @@ #[cfg(feature = "std")] include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); +use account::AccountId20; use cumulus_pallet_parachain_system::RelaychainBlockNumberProvider; use fp_rpc::TransactionStatus; use frame_support::{ @@ -50,7 +51,7 @@ use pallet_ethereum::Call::transact; use pallet_ethereum::Transaction as EthereumTransaction; use pallet_evm::{ Account as EVMAccount, EnsureAddressNever, EnsureAddressRoot, FeeCalculator, GasWeightMapping, - IdentityAddressMapping, Runner, + Runner, }; use pallet_transaction_payment::{CurrencyAdapter, Multiplier, TargetedFeeAdjustment}; pub use parachain_staking::{InflationInfo, Range}; @@ -349,13 +350,33 @@ impl FeeCalculator for FixedGasPrice { pub type SlowAdjustingFeeUpdate = TargetedFeeAdjustment; +use frame_support::traits::FindAuthor; +//TODO It feels like this shold be able to work for any T: H160, but I tried for +// embarassingly long and couldn't figure that out. + +/// The author inherent provides a AccountId20, but pallet evm needs an H160. +/// This simple adapter makes the conversion. +pub struct FindAuthorAdapter(sp_std::marker::PhantomData); + +impl FindAuthor for FindAuthorAdapter +where + Inner: FindAuthor, +{ + fn find_author<'a, I>(digests: I) -> Option + where + I: 'a + IntoIterator, + { + Inner::find_author(digests).map(Into::into) + } +} + impl pallet_evm::Config for Runtime { type FeeCalculator = FixedGasPrice; type GasWeightMapping = MoonbeamGasWeightMapping; type BlockHashMapping = pallet_ethereum::EthereumBlockHashMapping; type CallOrigin = EnsureAddressRoot; type WithdrawOrigin = EnsureAddressNever; - type AddressMapping = IdentityAddressMapping; + type AddressMapping = runtime_common::IntoAddressMapping; type Currency = Balances; type Event = Event; type Runner = pallet_evm::runner::stack::Runner; @@ -363,7 +384,7 @@ impl pallet_evm::Config for Runtime { type ChainId = EthereumChainId; type OnChargeTransaction = pallet_evm::EVMCurrencyAdapter>; type BlockGasLimit = BlockGasLimit; - type FindAuthor = AuthorInherent; + type FindAuthor = FindAuthorAdapter; } parameter_types! {