From 487191156477f6d30580087ffa86765deac5fbaa Mon Sep 17 00:00:00 2001 From: Ashutosh Varma Date: Tue, 24 Oct 2023 15:49:05 +0530 Subject: [PATCH] feat: remove `AccountMapping` trait --- chain-extensions/unified-accounts/src/lib.rs | 10 ++--- pallets/ethereum-checked/src/lib.rs | 11 +++--- pallets/ethereum-checked/src/mock.rs | 34 +++++++++++++---- pallets/unified-accounts/src/benchmarking.rs | 7 ++-- pallets/unified-accounts/src/lib.rs | 38 +++---------------- pallets/unified-accounts/src/mock.rs | 7 ++-- pallets/unified-accounts/src/tests.rs | 5 +-- pallets/xvm/src/lib.rs | 9 ++--- pallets/xvm/src/mock.rs | 11 +----- pallets/xvm/src/tests.rs | 1 - primitives/src/ethereum_checked.rs | 17 --------- primitives/src/evm.rs | 39 ++++++++++++++++++-- runtime/local/src/lib.rs | 12 +++--- runtime/shibuya/src/lib.rs | 15 ++++---- tests/integration/src/setup.rs | 2 +- 15 files changed, 106 insertions(+), 112 deletions(-) diff --git a/chain-extensions/unified-accounts/src/lib.rs b/chain-extensions/unified-accounts/src/lib.rs index 17ab43f4e4..bc04187e11 100644 --- a/chain-extensions/unified-accounts/src/lib.rs +++ b/chain-extensions/unified-accounts/src/lib.rs @@ -18,10 +18,7 @@ #![cfg_attr(not(feature = "std"), no_std)] -use astar_primitives::{ - ethereum_checked::AccountMapping, - evm::{EvmAddress, UnifiedAddressMapper}, -}; +use astar_primitives::evm::{EvmAddress, UnifiedAddressMapper}; use core::marker::PhantomData; use sp_runtime::DispatchError; @@ -29,7 +26,6 @@ use frame_support::{traits::Get, DefaultNoBound}; use pallet_contracts::chain_extension::{ ChainExtension, Environment, Ext, InitState, Result as DispatchResult, RetVal, }; -use pallet_evm::AddressMapping; use parity_scale_codec::Encode; pub use unified_accounts_chain_extension_types::{ Command::{self, *}, @@ -69,7 +65,7 @@ where let evm_address = if let Some(h160) = UA::to_h160(&account_id) { UnifiedAddress::Mapped(h160) } else { - UnifiedAddress::Default(T::DefaultNativeToEvm::into_h160(account_id)) + UnifiedAddress::Default(UA::to_default_h160(&account_id)) }; // write to buffer evm_address.using_encoded(|r| env.write(r, false, None))?; @@ -92,7 +88,7 @@ where let native_address = if let Some(native) = UA::to_account_id(&evm_address) { UnifiedAddress::Mapped(native) } else { - UnifiedAddress::Default(T::DefaultEvmToNative::into_account_id(evm_address)) + UnifiedAddress::Default(UA::to_default_account_id(&evm_address)) }; // write to buffer diff --git a/pallets/ethereum-checked/src/lib.rs b/pallets/ethereum-checked/src/lib.rs index 506bcf5fdd..35a281be95 100644 --- a/pallets/ethereum-checked/src/lib.rs +++ b/pallets/ethereum-checked/src/lib.rs @@ -64,8 +64,9 @@ use sp_runtime::traits::TrailingZeroInput; use sp_runtime::traits::UniqueSaturatedInto; use sp_std::{marker::PhantomData, result::Result}; -use astar_primitives::ethereum_checked::{ - AccountMapping, CheckedEthereumTransact, CheckedEthereumTx, +use astar_primitives::{ + ethereum_checked::{CheckedEthereumTransact, CheckedEthereumTx}, + evm::UnifiedAddressMapper, }; pub use pallet::*; @@ -141,7 +142,7 @@ pub mod pallet { type ValidatedTransaction: ValidatedTransaction; /// Account mapping. - type AccountMapping: AccountMapping; + type AddressMapper: UnifiedAddressMapper; /// Origin for `transact` call. type XcmTransactOrigin: EnsureOrigin; @@ -170,7 +171,7 @@ pub mod pallet { pub fn transact(origin: OriginFor, tx: CheckedEthereumTx) -> DispatchResultWithPostInfo { let source = T::XcmTransactOrigin::ensure_origin(origin)?; Self::do_transact( - T::AccountMapping::into_h160(source), + T::AddressMapper::to_h160_or_default(&source), tx.into(), CheckedEthereumTxKind::Xcm, false, @@ -283,7 +284,7 @@ impl Pallet { ) -> DispatchResultWithPostInfo { let source = T::XcmTransactOrigin::ensure_origin(origin)?; Self::do_transact( - T::AccountMapping::into_h160(source), + T::AddressMapper::to_h160_or_default(&source), tx.into(), CheckedEthereumTxKind::Xcm, true, diff --git a/pallets/ethereum-checked/src/mock.rs b/pallets/ethereum-checked/src/mock.rs index f4575e956d..12dc023172 100644 --- a/pallets/ethereum-checked/src/mock.rs +++ b/pallets/ethereum-checked/src/mock.rs @@ -127,22 +127,42 @@ impl AddressMapping for MockAddressMapping { } } -pub struct MockAccountMapping; -impl AccountMapping for MockAccountMapping { - fn into_h160(account_id: AccountId) -> H160 { - if account_id == ALICE { +pub struct MockAddressMapper; +impl UnifiedAddressMapper for MockAddressMapper { + fn to_h160_or_default(account_id: &AccountId) -> H160 { + if account_id == &ALICE { return ALICE_H160; } - if account_id == BOB { + if account_id == &BOB { return BOB_H160; } - if account_id == CHARLIE { + if account_id == &CHARLIE { return CHARLIE_H160; } let data = (b"evm:", account_id); return H160::from_slice(&data.using_encoded(blake2_256)[0..20]); } + + // this method is not used in tests + fn to_account_id(_: &H160) -> Option { + None + } + + // this method is not used in tests + fn to_h160(_: &AccountId32) -> Option { + None + } + + // this method is not used in tests + fn to_default_account_id(_: &H160) -> AccountId32 { + [0u8; 32].into() + } + + // this method is not used in tests + fn to_default_h160(_: &AccountId32) -> H160 { + [0u8; 20].into() + } } parameter_types! { @@ -193,7 +213,7 @@ impl pallet_ethereum_checked::Config for TestRuntime { type XvmTxWeightLimit = TxWeightLimit; type InvalidEvmTransactionError = pallet_ethereum::InvalidTransactionWrapper; type ValidatedTransaction = pallet_ethereum::ValidatedTransaction; - type AccountMapping = MockAccountMapping; + type AddressMapper = MockAddressMapper; type XcmTransactOrigin = EnsureXcmEthereumTx; type WeightInfo = (); } diff --git a/pallets/unified-accounts/src/benchmarking.rs b/pallets/unified-accounts/src/benchmarking.rs index e1a88290e3..9c5f2ef5ad 100644 --- a/pallets/unified-accounts/src/benchmarking.rs +++ b/pallets/unified-accounts/src/benchmarking.rs @@ -64,8 +64,7 @@ mod benchmarks { #[benchmark] fn claim_default_evm_address() { let caller: T::AccountId = whitelisted_caller(); - let caller_clone = caller.clone(); - let evm_address = T::DefaultNativeToEvm::into_h160(caller.clone()); + let evm_address = T::DefaultMappings::to_default_h160(&caller); assert_ok!(T::Currency::mint_into( &caller, @@ -73,11 +72,11 @@ mod benchmarks { )); #[extrinsic_call] - _(RawOrigin::Signed(caller)); + _(RawOrigin::Signed(caller.clone())); assert_last_event::( Event::::AccountClaimed { - account_id: caller_clone, + account_id: caller, evm_address, } .into(), diff --git a/pallets/unified-accounts/src/lib.rs b/pallets/unified-accounts/src/lib.rs index cb804d2f3b..89dbb26150 100644 --- a/pallets/unified-accounts/src/lib.rs +++ b/pallets/unified-accounts/src/lib.rs @@ -58,15 +58,12 @@ //! * [`StaticLookup`](sp_runtime::traits::StaticLookup): Lookup implementations for accepting H160 //! * [`AddressMapping`](pallet_evm::AddressMapping): Wrapper over `UnifiedAddressMapper` for evm address mapping //! to account id. -//! * [`AccountMapping`](astar_primitives::ethereum_checked::AccountMapping): Wrapper over `UnifiedAddressMapper` -//! for account id mappings to h160. //! * `KillAccountMapping`: [`OnKilledAccount`](frame_support::traits::OnKilledAccount) implementation to remove //! the mappings from storage after account is reaped. #![cfg_attr(not(feature = "std"), no_std)] use astar_primitives::{ - ethereum_checked::AccountMapping, evm::{EvmAddress, UnifiedAddressMapper}, Balance, }; @@ -115,10 +112,8 @@ pub mod pallet { type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The Currency for managing evm address assets type Currency: FungibleMutate; - /// Default evm address to account id conversion - type DefaultEvmToNative: AddressMapping; - /// Default account id to evm address conversion - type DefaultNativeToEvm: AccountMapping; + /// Default address conversion + type DefaultMappings: UnifiedAddressMapper; /// EVM chain id #[pallet::constant] type ChainId: Get; @@ -205,7 +200,7 @@ pub mod pallet { Self::charge_storage_fee(&who)?; // Check if the default account id already exists for this evm address - let default_account_id = T::DefaultEvmToNative::into_account_id(evm_address.clone()); + let default_account_id = T::DefaultMappings::to_default_account_id(&evm_address); if frame_system::Pallet::::account_exists(&default_account_id) { // Transfer all the free native balance from old account id to the newly // since this `default_account_id` will no longer be connected to evm address @@ -253,7 +248,7 @@ impl Pallet { Error::::AlreadyMapped ); // get the default evm address - let evm_address = T::DefaultNativeToEvm::into_h160(account_id.clone()); + let evm_address = T::DefaultMappings::to_default_h160(&account_id); // make sure default address is not already mapped, this should not // happen but for sanity check. ensure!( @@ -351,37 +346,16 @@ impl UnifiedAddressMapper for Pallet { EvmToNative::::get(evm_address) } - fn to_account_id_or_default(evm_address: &EvmAddress) -> T::AccountId { - EvmToNative::::get(evm_address).unwrap_or_else(|| { - // fallback to default account_id - T::DefaultEvmToNative::into_account_id(evm_address.clone()) - }) - } - fn to_default_account_id(evm_address: &EvmAddress) -> T::AccountId { - T::DefaultEvmToNative::into_account_id(evm_address.clone()) + T::DefaultMappings::to_default_account_id(evm_address) } fn to_h160(account_id: &T::AccountId) -> Option { NativeToEvm::::get(account_id) } - fn to_h160_or_default(account_id: &T::AccountId) -> EvmAddress { - NativeToEvm::::get(account_id).unwrap_or_else(|| { - // fallback to default account_id - T::DefaultNativeToEvm::into_h160(account_id.clone()) - }) - } - fn to_default_h160(account_id: &T::AccountId) -> EvmAddress { - T::DefaultNativeToEvm::into_h160(account_id.clone()) - } -} - -/// AccountMapping wrapper implementation -impl AccountMapping for Pallet { - fn into_h160(account: T::AccountId) -> H160 { - >::to_h160_or_default(&account) + T::DefaultMappings::to_default_h160(account_id) } } diff --git a/pallets/unified-accounts/src/mock.rs b/pallets/unified-accounts/src/mock.rs index 74e60d54b4..0cb1f880c5 100644 --- a/pallets/unified-accounts/src/mock.rs +++ b/pallets/unified-accounts/src/mock.rs @@ -20,7 +20,7 @@ use super::*; use crate as pallet_unified_accounts; -use astar_primitives::ethereum_checked::HashedAccountMapping; +use astar_primitives::evm::HashedDefaultMappings; use frame_support::{ construct_runtime, parameter_types, sp_io::TestExternalities, @@ -28,7 +28,7 @@ use frame_support::{ weights::Weight, }; use pallet_ethereum::PostLogContent; -use pallet_evm::{FeeCalculator, HashedAddressMapping}; +use pallet_evm::FeeCalculator; use sp_core::{keccak_256, H160, H256, U256}; use sp_runtime::{ testing::Header, @@ -155,8 +155,7 @@ parameter_types! { impl pallet_unified_accounts::Config for TestRuntime { type RuntimeEvent = RuntimeEvent; type Currency = Balances; - type DefaultEvmToNative = HashedAddressMapping; - type DefaultNativeToEvm = HashedAccountMapping; + type DefaultMappings = HashedDefaultMappings; type ChainId = ChainId; type AccountMappingStorageFee = AccountMappingStorageFee; type WeightInfo = (); diff --git a/pallets/unified-accounts/src/tests.rs b/pallets/unified-accounts/src/tests.rs index d625c1d78e..e21ced2763 100644 --- a/pallets/unified-accounts/src/tests.rs +++ b/pallets/unified-accounts/src/tests.rs @@ -145,7 +145,7 @@ fn account_claim_should_work() { let alice_eth = UnifiedAccounts::eth_address(&alice_secret()); // default ss58 account associated with eth address let alice_eth_old_account = - ::DefaultEvmToNative::into_account_id(alice_eth.clone()); + ::DefaultMappings::to_default_account_id(&alice_eth); let signature = get_evm_signature(&ALICE, &alice_secret()); // transfer some funds to alice_eth (H160) @@ -194,8 +194,7 @@ fn account_claim_should_work() { #[test] fn account_default_claim_works() { ExtBuilder::default().build().execute_with(|| { - let alice_default_evm = - ::DefaultNativeToEvm::into_h160(ALICE.into()); + let alice_default_evm = ::DefaultMappings::to_default_h160(&ALICE); // claim default account assert_ok!(UnifiedAccounts::claim_default_evm_address( diff --git a/pallets/xvm/src/lib.rs b/pallets/xvm/src/lib.rs index 1b5de63c64..b6486c2720 100644 --- a/pallets/xvm/src/lib.rs +++ b/pallets/xvm/src/lib.rs @@ -50,9 +50,8 @@ use sp_core::{H160, U256}; use sp_std::{marker::PhantomData, prelude::*}; use astar_primitives::{ - ethereum_checked::{ - AccountMapping, CheckedEthereumTransact, CheckedEthereumTx, EthereumTxInput, - }, + ethereum_checked::{CheckedEthereumTransact, CheckedEthereumTx, EthereumTxInput}, + evm::UnifiedAddressMapper, xvm::{ CallFailure, CallOutput, CallResult, Context, FailureError::*, FailureRevert::*, VmId, XvmCall, @@ -85,7 +84,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config + pallet_contracts::Config { /// Mapping from `Account` to `H160`. - type AccountMapping: AccountMapping; + type AddressMapper: UnifiedAddressMapper; /// Mapping from Ethereum gas to Substrate weight. type GasWeightMapping: GasWeightMapping; @@ -213,7 +212,7 @@ where let weight_limit = context.weight_limit.saturating_sub(overheads); let gas_limit = U256::from(T::GasWeightMapping::weight_to_gas(weight_limit)); - let source = T::AccountMapping::into_h160(source); + let source = T::AddressMapper::to_h160_or_default(&source); let tx = CheckedEthereumTx { gas_limit, target: target_decoded, diff --git a/pallets/xvm/src/mock.rs b/pallets/xvm/src/mock.rs index 7f134b4c3c..027bbf72a4 100644 --- a/pallets/xvm/src/mock.rs +++ b/pallets/xvm/src/mock.rs @@ -21,6 +21,7 @@ use super::*; use crate as pallet_xvm; +use astar_primitives::evm::HashedDefaultMappings; use fp_evm::{CallInfo as EvmCallInfo, ExitReason, ExitSucceed, UsedGas}; use frame_support::{ construct_runtime, @@ -124,14 +125,6 @@ impl pallet_contracts::Config for TestRuntime { type MaxDebugBufferLen = ConstU32<{ 2 * 1024 * 1024 }>; } -pub struct HashedAccountMapping; -impl astar_primitives::ethereum_checked::AccountMapping for HashedAccountMapping { - fn into_h160(account_id: AccountId) -> H160 { - let data = (b"evm:", account_id); - return H160::from_slice(&data.using_encoded(sp_io::hashing::blake2_256)[0..20]); - } -} - thread_local! { static TRANSACTED: RefCell> = RefCell::new(None); } @@ -180,7 +173,7 @@ impl GasWeightMapping for MockGasWeightMapping { impl pallet_xvm::Config for TestRuntime { type GasWeightMapping = MockGasWeightMapping; - type AccountMapping = HashedAccountMapping; + type AddressMapper = HashedDefaultMappings; type EthereumTransact = MockEthereumTransact; type WeightInfo = weights::SubstrateWeight; } diff --git a/pallets/xvm/src/tests.rs b/pallets/xvm/src/tests.rs index 09593bd012..77eafe80c9 100644 --- a/pallets/xvm/src/tests.rs +++ b/pallets/xvm/src/tests.rs @@ -24,7 +24,6 @@ use mock::*; use frame_support::{assert_noop, assert_ok, weights::Weight}; use parity_scale_codec::Encode; use sp_core::H160; -use sp_runtime::MultiAddress; #[test] fn calling_into_same_vm_is_not_allowed() { diff --git a/primitives/src/ethereum_checked.rs b/primitives/src/ethereum_checked.rs index 51eda15a0b..890f284fa8 100644 --- a/primitives/src/ethereum_checked.rs +++ b/primitives/src/ethereum_checked.rs @@ -30,11 +30,8 @@ use frame_support::{ traits::ConstU32, BoundedVec, }; -use sp_core::Hasher; use sp_std::{prelude::*, result::Result}; -use crate::AccountId; - /// Max Ethereum tx input size: 65_536 bytes pub const MAX_ETHEREUM_TX_INPUT_SIZE: u32 = 2u32.pow(16); @@ -99,17 +96,3 @@ pub trait CheckedEthereumTransact { checked_tx: CheckedEthereumTx, ) -> Result<(PostDispatchInfo, CallInfo), DispatchErrorWithPostInfo>; } - -/// Mapping from `Account` to `H160`. -pub trait AccountMapping { - fn into_h160(account: AccountId) -> H160; -} - -/// Hashed derive mapping for converting account id to evm address -pub struct HashedAccountMapping(sp_std::marker::PhantomData); -impl> AccountMapping for HashedAccountMapping { - fn into_h160(account: AccountId) -> H160 { - let payload = (b"evm:", account); - H160::from_slice(&payload.using_encoded(H::hash)[0..20]) - } -} diff --git a/primitives/src/evm.rs b/primitives/src/evm.rs index 766f7bf7a8..fa31f4976a 100644 --- a/primitives/src/evm.rs +++ b/primitives/src/evm.rs @@ -19,7 +19,9 @@ use crate::{AccountId, AssetId}; use frame_support::ensure; -use sp_core::H160; +use pallet_evm::{AddressMapping, HashedAddressMapping}; +use parity_scale_codec::Encode; +use sp_core::{Hasher, H160, H256}; use sp_std::marker::PhantomData; use pallet_assets::AssetsCallback; @@ -64,7 +66,12 @@ pub trait UnifiedAddressMapper { fn to_account_id(evm_address: &EvmAddress) -> Option; /// Gets the account id associated with given evm address. /// If no mapping exists, then return the default evm address. - fn to_account_id_or_default(evm_address: &EvmAddress) -> AccountId; + fn to_account_id_or_default(evm_address: &EvmAddress) -> AccountId { + Self::to_account_id(evm_address).unwrap_or_else(|| { + // fallback to default account_id + Self::to_default_account_id(evm_address) + }) + } /// Gets the default account id which is associated with given evm address. fn to_default_account_id(evm_address: &EvmAddress) -> AccountId; @@ -72,7 +79,33 @@ pub trait UnifiedAddressMapper { fn to_h160(account_id: &AccountId) -> Option; /// Gets the evm address associated with given account id. /// If no mapping exists, then return the default account id. - fn to_h160_or_default(account_id: &AccountId) -> EvmAddress; + fn to_h160_or_default(account_id: &AccountId) -> EvmAddress { + Self::to_h160(account_id).unwrap_or_else(|| { + // fallback to default account_id + Self::to_default_h160(account_id) + }) + } /// Gets the default evm address which is associated with given account id. fn to_default_h160(account_id: &AccountId) -> EvmAddress; } + +/// Mappings derieved from hashing the original address +pub struct HashedDefaultMappings(PhantomData); +impl> UnifiedAddressMapper for HashedDefaultMappings { + fn to_default_account_id(evm_address: &EvmAddress) -> AccountId { + HashedAddressMapping::::into_account_id(evm_address.clone()) + } + + fn to_default_h160(account_id: &AccountId) -> EvmAddress { + let payload = (b"evm:", account_id); + H160::from_slice(&payload.using_encoded(H::hash)[0..20]) + } + + fn to_account_id(_: &EvmAddress) -> Option { + None + } + + fn to_h160(_: &AccountId) -> Option { + None + } +} diff --git a/runtime/local/src/lib.rs b/runtime/local/src/lib.rs index 2df0db9035..5b910c3ce8 100644 --- a/runtime/local/src/lib.rs +++ b/runtime/local/src/lib.rs @@ -24,6 +24,7 @@ #[cfg(feature = "std")] include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); +use astar_primitives::evm::HashedDefaultMappings; use frame_support::{ construct_runtime, parameter_types, traits::{ @@ -61,8 +62,8 @@ use sp_runtime::{ use sp_std::prelude::*; pub use astar_primitives::{ - ethereum_checked::HashedAccountMapping, evm::EvmRevertCodeHandler, AccountId, Address, AssetId, - Balance, BlockNumber, Hash, Header, Index, Signature, + evm::EvmRevertCodeHandler, AccountId, Address, AssetId, Balance, BlockNumber, Hash, Header, + Index, Signature, }; pub use crate::precompiles::WhitelistedCalls; @@ -515,8 +516,7 @@ parameter_types! { impl pallet_unified_accounts::Config for Runtime { type RuntimeEvent = RuntimeEvent; type Currency = Balances; - type DefaultEvmToNative = pallet_evm::HashedAddressMapping; - type DefaultNativeToEvm = HashedAccountMapping; + type DefaultMappings = HashedDefaultMappings; type ChainId = ChainId; type AccountMappingStorageFee = AccountMappingStorageFee; type WeightInfo = pallet_unified_accounts::weights::SubstrateWeight; @@ -533,14 +533,14 @@ impl pallet_ethereum_checked::Config for Runtime { type XvmTxWeightLimit = XvmTxWeightLimit; type InvalidEvmTransactionError = pallet_ethereum::InvalidTransactionWrapper; type ValidatedTransaction = pallet_ethereum::ValidatedTransaction; - type AccountMapping = UnifiedAccounts; + type AddressMapper = UnifiedAccounts; type XcmTransactOrigin = pallet_ethereum_checked::EnsureXcmEthereumTx; type WeightInfo = pallet_ethereum_checked::weights::SubstrateWeight; } impl pallet_xvm::Config for Runtime { type GasWeightMapping = pallet_evm::FixedGasWeightMapping; - type AccountMapping = UnifiedAccounts; + type AddressMapper = UnifiedAccounts; type EthereumTransact = EthereumChecked; type WeightInfo = pallet_xvm::weights::SubstrateWeight; } diff --git a/runtime/shibuya/src/lib.rs b/runtime/shibuya/src/lib.rs index 86b0048531..ded9937046 100644 --- a/runtime/shibuya/src/lib.rs +++ b/runtime/shibuya/src/lib.rs @@ -22,6 +22,7 @@ // `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256. #![recursion_limit = "256"] +use astar_primitives::evm::HashedDefaultMappings; use cumulus_pallet_parachain_system::AnyRelayNumber; use frame_support::{ construct_runtime, @@ -67,10 +68,9 @@ use sp_runtime::{ use sp_std::prelude::*; pub use astar_primitives::{ - ethereum_checked::{CheckedEthereumTransact, HashedAccountMapping}, - evm::EvmRevertCodeHandler, - xcm::AssetLocationIdConverter, - AccountId, Address, AssetId, Balance, BlockNumber, Hash, Header, Index, Signature, + ethereum_checked::CheckedEthereumTransact, evm::EvmRevertCodeHandler, + xcm::AssetLocationIdConverter, AccountId, Address, AssetId, Balance, BlockNumber, Hash, Header, + Index, Signature, }; pub use crate::precompiles::WhitelistedCalls; @@ -784,14 +784,14 @@ impl pallet_ethereum_checked::Config for Runtime { type XvmTxWeightLimit = XvmTxWeightLimit; type InvalidEvmTransactionError = pallet_ethereum::InvalidTransactionWrapper; type ValidatedTransaction = pallet_ethereum::ValidatedTransaction; - type AccountMapping = UnifiedAccounts; + type AddressMapper = UnifiedAccounts; type XcmTransactOrigin = pallet_ethereum_checked::EnsureXcmEthereumTx; type WeightInfo = pallet_ethereum_checked::weights::SubstrateWeight; } impl pallet_xvm::Config for Runtime { type GasWeightMapping = pallet_evm::FixedGasWeightMapping; - type AccountMapping = UnifiedAccounts; + type AddressMapper = UnifiedAccounts; type EthereumTransact = EthereumChecked; type WeightInfo = pallet_xvm::weights::SubstrateWeight; } @@ -1212,8 +1212,7 @@ parameter_types! { impl pallet_unified_accounts::Config for Runtime { type RuntimeEvent = RuntimeEvent; type Currency = Balances; - type DefaultEvmToNative = pallet_evm::HashedAddressMapping; - type DefaultNativeToEvm = HashedAccountMapping; + type DefaultMappings = HashedDefaultMappings; type ChainId = EVMChainId; type AccountMappingStorageFee = AccountMappingStorageFee; type WeightInfo = pallet_unified_accounts::weights::SubstrateWeight; diff --git a/tests/integration/src/setup.rs b/tests/integration/src/setup.rs index 7d59f3ac04..1e1b6b5f2a 100644 --- a/tests/integration/src/setup.rs +++ b/tests/integration/src/setup.rs @@ -28,7 +28,7 @@ pub use sp_core::{H160, H256, U256}; pub use sp_io::hashing::keccak_256; pub use sp_runtime::{AccountId32, MultiAddress}; -pub use astar_primitives::{ethereum_checked::AccountMapping, evm::UnifiedAddressMapper}; +pub use astar_primitives::evm::UnifiedAddressMapper; #[cfg(feature = "shibuya")] pub use shibuya::*;