diff --git a/modules/asset-registry/src/lib.rs b/modules/asset-registry/src/lib.rs index 1bd77004ea..80dfca2cbc 100644 --- a/modules/asset-registry/src/lib.rs +++ b/modules/asset-registry/src/lib.rs @@ -24,7 +24,6 @@ #![allow(clippy::unused_unit)] use frame_support::{ - assert_ok, dispatch::DispatchResult, ensure, pallet_prelude::*, @@ -195,7 +194,7 @@ pub mod module { impl GenesisBuild for GenesisConfig { fn build(&self) { self.assets.iter().for_each(|(asset, ed)| { - assert_ok!(Pallet::::do_register_native_asset( + frame_support::assert_ok!(Pallet::::do_register_native_asset( *asset, &AssetMetadata { name: asset.name().unwrap().as_bytes().to_vec(), diff --git a/modules/currencies/src/lib.rs b/modules/currencies/src/lib.rs index e9deac415f..5cacdf3bf6 100644 --- a/modules/currencies/src/lib.rs +++ b/modules/currencies/src/lib.rs @@ -283,6 +283,13 @@ pub mod module { } } +impl Pallet { + fn get_evm_origin() -> Result { + let origin = T::EVMBridge::get_origin().ok_or(Error::::RealOriginNotFound)?; + Ok(T::AddressMapping::get_or_create_evm_address(&origin)) + } +} + impl MultiCurrency for Pallet { type CurrencyId = CurrencyId; type Balance = BalanceOf; @@ -382,14 +389,12 @@ impl MultiCurrency for Pallet { match currency_id { CurrencyId::Erc20(contract) => { let sender = T::AddressMapping::get_evm_address(from).ok_or(Error::::EvmAccountNotFound)?; - let origin = T::EVMBridge::get_origin().ok_or(Error::::RealOriginNotFound)?; - let origin_address = T::AddressMapping::get_or_create_evm_address(&origin); let address = T::AddressMapping::get_or_create_evm_address(to); T::EVMBridge::transfer( InvokeContext { contract, sender, - origin: origin_address, + origin: Self::get_evm_origin()?, }, address, amount, @@ -428,7 +433,7 @@ impl MultiCurrency for Pallet { InvokeContext { contract, sender, - origin: receiver, + origin: Self::get_evm_origin().unwrap_or(receiver), }, receiver, amount, @@ -467,7 +472,7 @@ impl MultiCurrency for Pallet { InvokeContext { contract, sender, - origin: sender, + origin: Self::get_evm_origin().unwrap_or(sender), }, receiver, amount, @@ -611,7 +616,7 @@ impl MultiReservableCurrency for Pallet { InvokeContext { contract, sender: address, - origin: address, + origin: Self::get_evm_origin().unwrap_or(address), }, reserve_address(address), value, @@ -644,7 +649,7 @@ impl MultiReservableCurrency for Pallet { InvokeContext { contract, sender, - origin: address, + origin: Self::get_evm_origin().unwrap_or(address), }, address, actual, @@ -704,7 +709,7 @@ impl MultiReservableCurrency for Pallet { InvokeContext { contract, sender: slashed_reserve_address, - origin: slashed_address, + origin: Self::get_evm_origin().unwrap_or(slashed_address), }, beneficiary_address, actual, @@ -713,7 +718,7 @@ impl MultiReservableCurrency for Pallet { InvokeContext { contract, sender: slashed_reserve_address, - origin: slashed_address, + origin: Self::get_evm_origin().unwrap_or(slashed_address), }, beneficiary_reserve_address, actual, diff --git a/modules/currencies/src/tests.rs b/modules/currencies/src/tests.rs index d02cd61c0d..7b536c34b7 100644 --- a/modules/currencies/src/tests.rs +++ b/modules/currencies/src/tests.rs @@ -230,7 +230,7 @@ fn multi_currency_should_work() { .one_hundred_for_alice_n_bob() .build() .execute_with(|| { - >::set_origin(alice()); + >::push_origin(alice()); assert_ok!(Currencies::transfer(Some(alice()).into(), bob(), X_TOKEN_ID, 50)); assert_eq!(Currencies::free_balance(X_TOKEN_ID, &alice()), 50); assert_eq!(Currencies::free_balance(X_TOKEN_ID, &bob()), 150); @@ -544,7 +544,7 @@ fn erc20_ensure_withdraw_should_work() { .build() .execute_with(|| { deploy_contracts(); - >::set_origin(alice()); + >::push_origin(alice()); assert_ok!(Currencies::ensure_can_withdraw( CurrencyId::Erc20(erc20_address()), &alice(), @@ -583,7 +583,7 @@ fn erc20_transfer_should_work() { .build() .execute_with(|| { deploy_contracts(); - >::set_origin(eva()); + >::push_origin(eva()); assert_ok!(Currencies::transfer( RuntimeOrigin::signed(alice()), @@ -656,8 +656,8 @@ fn erc20_transfer_should_fail() { Error::::RealOriginNotFound ); - >::set_origin(alice()); - >::set_origin(bob()); + >::push_origin(alice()); + >::push_origin(bob()); // empty address assert!(Currencies::transfer( @@ -843,7 +843,7 @@ fn erc20_repatriate_reserved_should_work() { .execute_with(|| { deploy_contracts(); let bob_balance = 100; - >::set_origin(alice()); + >::push_origin(alice()); assert_ok!(Currencies::transfer( RuntimeOrigin::signed(alice()), bob(), @@ -975,7 +975,7 @@ fn erc20_invalid_operation() { .build() .execute_with(|| { deploy_contracts(); - >::set_origin(alice()); + >::push_origin(alice()); assert_noop!( Currencies::update_balance(RuntimeOrigin::root(), alice(), CurrencyId::Erc20(erc20_address()), 1), @@ -994,7 +994,7 @@ fn erc20_withdraw_deposit_works() { .build() .execute_with(|| { deploy_contracts(); - >::set_origin(alice()); + >::push_origin(alice()); let erc20_holding_account = MockAddressMapping::get_account_id(&Erc20HoldingAccount::get()); @@ -1668,7 +1668,7 @@ fn fungible_transfer_trait_should_work() { assert_eq!(>::balance(&bob()), 20000); deploy_contracts(); - >::set_origin(alice()); + >::push_origin(alice()); assert_eq!( >::balance(CurrencyId::Erc20(erc20_address()), &alice()), ALICE_BALANCE diff --git a/modules/evm-bridge/src/lib.rs b/modules/evm-bridge/src/lib.rs index 2150287a09..9b74db74dc 100644 --- a/modules/evm-bridge/src/lib.rs +++ b/modules/evm-bridge/src/lib.rs @@ -251,8 +251,12 @@ impl EVMBridgeTrait, BalanceOf> for EVMBridge { T::EVM::get_origin() } - fn set_origin(origin: AccountIdOf) { - T::EVM::set_origin(origin); + fn push_origin(origin: AccountIdOf) { + T::EVM::push_origin(origin); + } + + fn pop_origin() { + T::EVM::pop_origin(); } } diff --git a/modules/evm/src/lib.rs b/modules/evm/src/lib.rs index be355a5a95..696ac5810e 100644 --- a/modules/evm/src/lib.rs +++ b/modules/evm/src/lib.rs @@ -345,7 +345,7 @@ pub mod module { /// ExtrinsicOrigin: Option #[pallet::storage] #[pallet::getter(fn extrinsic_origin)] - pub type ExtrinsicOrigin = StorageValue<_, T::AccountId, OptionQuery>; + pub type ExtrinsicOrigin = StorageValue<_, Vec, OptionQuery>; #[pallet::genesis_config] pub struct GenesisConfig { @@ -1863,12 +1863,30 @@ impl EVMTrait for Pallet { /// Get the real origin account and charge storage rent from the origin. fn get_origin() -> Option { - ExtrinsicOrigin::::get() + ExtrinsicOrigin::::get().and_then(|o| o.last().cloned()) } - /// Provide a method to set origin for `on_initialize` - fn set_origin(origin: T::AccountId) { - ExtrinsicOrigin::::set(Some(origin)); + // Set the EVM origin + fn push_origin(origin: T::AccountId) { + ExtrinsicOrigin::::mutate(|o| { + if let Some(o) = o { + o.push(origin); + } else { + *o = Some(vec![origin]); + } + }); + } + + // Pop the EVM origin + fn pop_origin() { + ExtrinsicOrigin::::mutate(|o| { + if let Some(arr) = o { + arr.pop(); + if arr.is_empty() { + *o = None; + } + } + }); } } @@ -1996,7 +2014,7 @@ impl SignedExtension for SetEvmOrigin { _info: &DispatchInfoOf, _len: usize, ) -> TransactionValidity { - ExtrinsicOrigin::::set(Some(who.clone())); + ExtrinsicOrigin::::set(Some(vec![who.clone()])); Ok(ValidTransaction::default()) } @@ -2007,7 +2025,7 @@ impl SignedExtension for SetEvmOrigin { _info: &DispatchInfoOf, _len: usize, ) -> Result<(), TransactionValidityError> { - ExtrinsicOrigin::::set(Some(who.clone())); + ExtrinsicOrigin::::set(Some(vec![who.clone()])); Ok(()) } diff --git a/modules/honzon-bridge/src/tests.rs b/modules/honzon-bridge/src/tests.rs index ece0b3cacf..befbc8af0d 100644 --- a/modules/honzon-bridge/src/tests.rs +++ b/modules/honzon-bridge/src/tests.rs @@ -61,7 +61,7 @@ fn to_bridged_works() { erc20_address() )); // ensure the honzon-bridge pallet account bind the evmaddress - >::set_origin(EvmAccountsModule::get_account_id(&alice_evm_addr())); + >::push_origin(EvmAccountsModule::get_account_id(&alice_evm_addr())); assert_ok!(Currencies::transfer( RuntimeOrigin::signed(alice()), HonzonBridgeAccount::get(), @@ -132,7 +132,7 @@ fn from_bridged_works() { erc20_address() )); // ensure the honzon-bridge pallet account bind the evmaddress - >::set_origin(EvmAccountsModule::get_account_id(&alice_evm_addr())); + >::push_origin(EvmAccountsModule::get_account_id(&alice_evm_addr())); assert_ok!(Currencies::transfer( RuntimeOrigin::signed(alice()), HonzonBridgeAccount::get(), diff --git a/modules/support/src/evm.rs b/modules/support/src/evm.rs index 4b6c17e94d..215ed424a4 100644 --- a/modules/support/src/evm.rs +++ b/modules/support/src/evm.rs @@ -57,8 +57,10 @@ pub trait EVM { /// Get the real origin account and charge storage rent from the origin. fn get_origin() -> Option; - /// Provide a method to set origin for `on_initialize` - fn set_origin(origin: AccountId); + /// Push new EVM origin + fn push_origin(origin: AccountId); + /// Pop EVM origin + fn pop_origin(); } #[derive(Encode, Decode, Eq, PartialEq, Copy, Clone, RuntimeDebug)] @@ -96,8 +98,10 @@ pub trait EVMBridge { fn transfer(context: InvokeContext, to: EvmAddress, value: Balance) -> DispatchResult; /// Get the real origin account and charge storage rent from the origin. fn get_origin() -> Option; - /// Provide a method to set origin for `on_initialize` - fn set_origin(origin: AccountId); + /// Push new EVM origin + fn push_origin(origin: AccountId); + /// Pop EVM origin + fn pop_origin(); } #[cfg(feature = "std")] @@ -123,7 +127,8 @@ impl EVMBridge for () { fn get_origin() -> Option { None } - fn set_origin(_origin: AccountId) {} + fn push_origin(_origin: AccountId) {} + fn pop_origin() {} } /// EVM bridge for collateral liquidation. diff --git a/runtime/acala/src/xcm_config.rs b/runtime/acala/src/xcm_config.rs index 0266273693..cd16ac808d 100644 --- a/runtime/acala/src/xcm_config.rs +++ b/runtime/acala/src/xcm_config.rs @@ -52,7 +52,6 @@ pub use xcm_builder::{ SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeRevenue, TakeWeightCredit, }; -use xcm_executor::XcmExecutor; parameter_types! { pub DotLocation: MultiLocation = MultiLocation::parent(); @@ -194,13 +193,21 @@ pub type XcmRouter = ( XcmpQueue, ); +pub type XcmExecutor = runtime_common::XcmExecutor< + XcmConfig, + AccountId, + Balance, + LocationToAccountId, + module_evm_bridge::EVMBridge, +>; + impl pallet_xcm::Config for Runtime { type RuntimeEvent = RuntimeEvent; type SendXcmOrigin = EnsureXcmOrigin; type XcmRouter = XcmRouter; type ExecuteXcmOrigin = EnsureXcmOrigin; type XcmExecuteFilter = Nothing; - type XcmExecutor = XcmExecutor; + type XcmExecutor = XcmExecutor; type XcmTeleportFilter = Nothing; type XcmReserveTransferFilter = Everything; type Weigher = FixedWeightBounds; @@ -213,12 +220,12 @@ impl pallet_xcm::Config for Runtime { impl cumulus_pallet_xcm::Config for Runtime { type RuntimeEvent = RuntimeEvent; - type XcmExecutor = XcmExecutor; + type XcmExecutor = XcmExecutor; } impl cumulus_pallet_xcmp_queue::Config for Runtime { type RuntimeEvent = RuntimeEvent; - type XcmExecutor = XcmExecutor; + type XcmExecutor = XcmExecutor; type ChannelInfo = ParachainSystem; type VersionWrapper = PolkadotXcm; type ExecuteOverweightOrigin = EnsureRootOrHalfGeneralCouncil; @@ -229,7 +236,7 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime { impl cumulus_pallet_dmp_queue::Config for Runtime { type RuntimeEvent = RuntimeEvent; - type XcmExecutor = XcmExecutor; + type XcmExecutor = XcmExecutor; type ExecuteOverweightOrigin = EnsureRootOrHalfGeneralCouncil; } @@ -371,7 +378,7 @@ impl orml_xtokens::Config for Runtime { type CurrencyIdConvert = CurrencyIdConvert; type AccountIdToMultiLocation = AccountIdToMultiLocation; type SelfLocation = SelfLocation; - type XcmExecutor = XcmExecutor; + type XcmExecutor = XcmExecutor; type Weigher = FixedWeightBounds; type BaseXcmWeight = BaseXcmWeight; type LocationInverter = LocationInverter; diff --git a/runtime/common/src/lib.rs b/runtime/common/src/lib.rs index 78dc3ce164..4c594de67c 100644 --- a/runtime/common/src/lib.rs +++ b/runtime/common/src/lib.rs @@ -56,7 +56,7 @@ pub use primitives::{ }, AccountId, }; -pub use xcm_impl::{local_currency_location, native_currency_location, AcalaDropAssets, FixedRateOfAsset}; +pub use xcm_impl::{local_currency_location, native_currency_location, AcalaDropAssets, FixedRateOfAsset, XcmExecutor}; #[cfg(feature = "std")] use sp_core::bytes::from_hex; diff --git a/runtime/common/src/xcm_impl.rs b/runtime/common/src/xcm_impl.rs index 4b57375f5f..7894bec1f7 100644 --- a/runtime/common/src/xcm_impl.rs +++ b/runtime/common/src/xcm_impl.rs @@ -235,6 +235,41 @@ impl, R: TakeRevenue, M: BuyWeightRate> Drop for FixedRateO } } +pub struct XcmExecutor( + PhantomData<(Config, AccountId, Balance, AccountIdConvert, EVMBridge)>, +); + +impl< + Config: xcm_executor::Config, + AccountId: Clone, + Balance, + AccountIdConvert: xcm_executor::traits::Convert, + EVMBridge: module_support::EVMBridge, + > ExecuteXcm for XcmExecutor +{ + fn execute_xcm_in_credit( + origin: impl Into, + message: Xcm, + weight_limit: XcmWeight, + weight_credit: XcmWeight, + ) -> Outcome { + let origin = origin.into(); + let account = AccountIdConvert::convert(origin.clone()); + let clear = if let Ok(account) = account { + EVMBridge::push_origin(account); + true + } else { + false + }; + let res = + xcm_executor::XcmExecutor::::execute_xcm_in_credit(origin, message, weight_limit, weight_credit); + if clear { + EVMBridge::pop_origin(); + } + res + } +} + #[cfg(test)] mod tests { use super::*; diff --git a/runtime/integration-tests/src/evm.rs b/runtime/integration-tests/src/evm.rs index 9b92f48ef0..a34b744729 100644 --- a/runtime/integration-tests/src/evm.rs +++ b/runtime/integration-tests/src/evm.rs @@ -238,7 +238,7 @@ fn dex_module_works_with_evm_contract() { 0, )); - >::set_origin(MockAddressMapping::get_account_id(&alice_evm_addr())); + >::push_origin(MockAddressMapping::get_account_id(&alice_evm_addr())); assert_ok!(Dex::add_provision( RuntimeOrigin::signed(MockAddressMapping::get_account_id(&alice_evm_addr())), CurrencyId::Erc20(erc20_address_0()), @@ -261,7 +261,7 @@ fn dex_module_works_with_evm_contract() { ); // CurrencyId::DexShare(Erc20, Erc20) - >::set_origin(EvmAddressMapping::::get_account_id(&alice_evm_addr())); + >::push_origin(EvmAddressMapping::::get_account_id(&alice_evm_addr())); assert_ok!(Dex::add_provision( RuntimeOrigin::signed(EvmAddressMapping::::get_account_id(&alice_evm_addr())), @@ -431,7 +431,7 @@ fn test_multicurrency_precompile_module() { )); // CurrencyId::DexShare(Erc20, Erc20) - >::set_origin(MockAddressMapping::get_account_id(&alice_evm_addr())); + >::push_origin(MockAddressMapping::get_account_id(&alice_evm_addr())); assert_ok!(Dex::add_provision( RuntimeOrigin::signed(MockAddressMapping::get_account_id(&alice_evm_addr())), CurrencyId::Erc20(erc20_address_0()), @@ -762,7 +762,7 @@ fn test_default_evm_address_in_evm_accounts_module() { assert!(EvmAccounts::evm_addresses(AccountId::from(ALICE)).is_some()); // get_or_create_evm_address - >::set_origin(alice()); + >::push_origin(alice()); assert_ok!(Currencies::transfer( RuntimeOrigin::signed(EvmAddressMapping::::get_account_id(&alice_evm_addr())), sp_runtime::MultiAddress::Id(AccountId::from(BOB)), @@ -858,7 +858,7 @@ fn transaction_payment_module_works_with_evm_contract() { 0, )); - >::set_origin(alice_evm_account.clone()); + >::push_origin(alice_evm_account.clone()); assert_ok!(Dex::add_provision( RuntimeOrigin::signed(alice_evm_account.clone()), erc20_token, @@ -872,7 +872,7 @@ fn transaction_payment_module_works_with_evm_contract() { assert_eq!(Currencies::free_balance(dex_share, &alice_evm_account), 0); // CurrencyId::DexShare(Erc20, ACA) - >::set_origin(alice_evm_account.clone()); + >::push_origin(alice_evm_account.clone()); assert_ok!(Dex::add_provision( RuntimeOrigin::signed(alice_evm_account.clone()), erc20_token, @@ -1250,7 +1250,7 @@ fn honzon_works_with_evm_contract() { .map(|n| n.saturating_mul_int(MinimumDebitValue::get())) .unwrap(); - >::set_origin(alice_evm_account.clone()); + >::push_origin(alice_evm_account.clone()); // 1.Honzon::adjust_loan assert_ok!(Honzon::adjust_loan( RuntimeOrigin::signed(alice_evm_account.clone()), diff --git a/runtime/integration-tests/src/relaychain/erc20.rs b/runtime/integration-tests/src/relaychain/erc20.rs index a616342561..ead632d115 100644 --- a/runtime/integration-tests/src/relaychain/erc20.rs +++ b/runtime/integration-tests/src/relaychain/erc20.rs @@ -163,10 +163,10 @@ fn erc20_transfer_between_sibling() { deploy_erc20_contracts(); // `transfer` invoked by `TransferReserveAsset` xcm instruction need to passing origin check. - // In frontend/js, when issue xtokens extrinsic, it have `EvmSetOrigin` SignedExtra to `set_origin`. - // In testcase, we're manual invoke `set_origin` here. because in erc20 xtokens transfer, - // the `from` or `to` is not erc20 holding account. so we need make sure origin exists. - >::set_origin(alith.clone()); + // In frontend/js, when issue xtokens extrinsic, it have `EvmSetOrigin` SignedExtra to + // `push_origin`. In testcase, we're manual invoke `push_origin` here. because in erc20 xtokens + // transfer, the `from` or `to` is not erc20 holding account. so we need make sure origin exists. + >::push_origin(alith.clone()); assert_eq!( Currencies::free_balance(CurrencyId::Erc20(erc20_address_0()), &alith), @@ -244,8 +244,29 @@ fn erc20_transfer_between_sibling() { WeightLimit::Limited(1_000_000_000), )); + // transfer erc20 token to new account on Karura + assert_ok!(XTokens::transfer( + RuntimeOrigin::signed(BOB.into()), + CurrencyId::ForeignAsset(0), + 1_000_000_000_000, + Box::new( + MultiLocation::new( + 1, + X2( + Parachain(2000), + Junction::AccountId32 { + network: NetworkId::Any, + id: CHARLIE.into(), + }, + ), + ) + .into(), + ), + WeightLimit::Limited(1_000_000_000), + )); + assert_eq!( - 4_999_191_760_000, + 3_999_191_760_000, Currencies::free_balance(CurrencyId::ForeignAsset(0), &AccountId::from(BOB)) ); }); @@ -254,7 +275,7 @@ fn erc20_transfer_between_sibling() { use karura_runtime::{RuntimeEvent, System}; let erc20_holding_account = EvmAddressMapping::::get_account_id(&Erc20HoldingAccount::get()); assert_eq!( - 5_000_000_000_000, + 4_000_000_000_000, Currencies::free_balance(CurrencyId::Erc20(erc20_address_0()), &sibling_reserve_account()) ); assert_eq!( @@ -262,23 +283,29 @@ fn erc20_transfer_between_sibling() { Currencies::free_balance(CurrencyId::Erc20(erc20_address_0()), &AccountId::from(BOB)) ); assert_eq!( - 8_082_400_000, + 8_082_400_000 * 2, Currencies::free_balance(CurrencyId::Erc20(erc20_address_0()), &KaruraTreasuryAccount::get()) ); + assert_eq!( + 991_917_600_000, + Currencies::free_balance(CurrencyId::Erc20(erc20_address_0()), &AccountId::from(CHARLIE)) + ); assert_eq!( 0, Currencies::free_balance(CurrencyId::Erc20(erc20_address_0()), &erc20_holding_account) ); - // withdraw erc20 need charge storage fee + // withdraw erc20 need charge storage fee for both sibling, BOB and CHARLIE assert_eq!( - initial_native_amount - storage_fee, + initial_native_amount - storage_fee * 3, Currencies::free_balance(NATIVE_CURRENCY, &sibling_reserve_account()) ); - // deposit erc20 need charge storage fee + // no storage fee for BOB assert_eq!( - initial_native_amount - storage_fee, + initial_native_amount, Currencies::free_balance(NATIVE_CURRENCY, &AccountId::from(BOB)) ); + // CHARLIE doesn't need native token + assert_eq!(0, Currencies::free_balance(NATIVE_CURRENCY, &AccountId::from(CHARLIE))); // deposit reserve and unreserve storage fee, so the native token not changed. assert_eq!( 1_100_000_000_000, @@ -343,9 +370,14 @@ fn sibling_erc20_to_self_as_foreign_asset() { )); assert_ok!(Currencies::deposit( NATIVE_CURRENCY, - &alith.clone(), + &alith, 1_000_000 * dollar(NATIVE_CURRENCY) )); + assert_ok!(Currencies::deposit( + NATIVE_CURRENCY, + &CHARLIE.into(), + 10 * dollar(NATIVE_CURRENCY) + )); deploy_erc20_contracts(); @@ -356,7 +388,7 @@ fn sibling_erc20_to_self_as_foreign_asset() { EvmAccounts::eth_sign(&alice_key(), &AccountId::from(ALICE)) )); - >::set_origin(alith.clone()); + >::push_origin(alith.clone()); // use Currencies `transfer` dispatch call to transfer erc20 token to bob. assert_ok!(Currencies::transfer( @@ -395,6 +427,11 @@ fn sibling_erc20_to_self_as_foreign_asset() { 990_000_000_000_000, Currencies::free_balance(CurrencyId::Erc20(erc20_address_0()), &AccountId::from(CHARLIE)) ); + // charge storage fee from CHARLIE + assert_eq!( + 10 * dollar(NATIVE_CURRENCY) - 6_400_000_000u128, + Currencies::free_balance(NATIVE_CURRENCY, &AccountId::from(CHARLIE)) + ); assert_eq!( 10_000_000_000_000, Currencies::free_balance(CurrencyId::Erc20(erc20_address_0()), &karura_reserve_account()) diff --git a/runtime/integration-tests/src/stable_asset.rs b/runtime/integration-tests/src/stable_asset.rs index 41ad486351..dd6036aed1 100644 --- a/runtime/integration-tests/src/stable_asset.rs +++ b/runtime/integration-tests/src/stable_asset.rs @@ -213,7 +213,7 @@ fn three_usd_pool_works() { EvmAccounts::eth_sign(&bob_key(), &AccountId::from(BOB)) )); // transfer USDC erc20 from alith to ALICE/BOB, used for swap - >::set_origin(alith.clone()); + >::push_origin(alith.clone()); assert_ok!(Currencies::transfer( RuntimeOrigin::signed(alith.clone()), sp_runtime::MultiAddress::Id(AccountId::from(BOB)), diff --git a/runtime/karura/src/xcm_config.rs b/runtime/karura/src/xcm_config.rs index 5164f20496..68528a4360 100644 --- a/runtime/karura/src/xcm_config.rs +++ b/runtime/karura/src/xcm_config.rs @@ -49,7 +49,6 @@ pub use xcm_builder::{ SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeRevenue, TakeWeightCredit, }; -use xcm_executor::XcmExecutor; parameter_types! { pub KsmLocation: MultiLocation = MultiLocation::parent(); @@ -229,13 +228,21 @@ pub type XcmRouter = ( XcmpQueue, ); +pub type XcmExecutor = runtime_common::XcmExecutor< + XcmConfig, + AccountId, + Balance, + LocationToAccountId, + module_evm_bridge::EVMBridge, +>; + impl pallet_xcm::Config for Runtime { type RuntimeEvent = RuntimeEvent; type SendXcmOrigin = EnsureXcmOrigin; type XcmRouter = XcmRouter; type ExecuteXcmOrigin = EnsureXcmOrigin; type XcmExecuteFilter = Nothing; - type XcmExecutor = XcmExecutor; + type XcmExecutor = XcmExecutor; type XcmTeleportFilter = Nothing; type XcmReserveTransferFilter = Everything; type Weigher = FixedWeightBounds; @@ -248,12 +255,12 @@ impl pallet_xcm::Config for Runtime { impl cumulus_pallet_xcm::Config for Runtime { type RuntimeEvent = RuntimeEvent; - type XcmExecutor = XcmExecutor; + type XcmExecutor = XcmExecutor; } impl cumulus_pallet_xcmp_queue::Config for Runtime { type RuntimeEvent = RuntimeEvent; - type XcmExecutor = XcmExecutor; + type XcmExecutor = XcmExecutor; type ChannelInfo = ParachainSystem; type VersionWrapper = PolkadotXcm; type ExecuteOverweightOrigin = EnsureRootOrHalfGeneralCouncil; @@ -264,7 +271,7 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime { impl cumulus_pallet_dmp_queue::Config for Runtime { type RuntimeEvent = RuntimeEvent; - type XcmExecutor = XcmExecutor; + type XcmExecutor = XcmExecutor; type ExecuteOverweightOrigin = EnsureRootOrHalfGeneralCouncil; } @@ -305,7 +312,7 @@ impl orml_xtokens::Config for Runtime { type CurrencyIdConvert = CurrencyIdConvert; type AccountIdToMultiLocation = AccountIdToMultiLocation; type SelfLocation = SelfLocation; - type XcmExecutor = XcmExecutor; + type XcmExecutor = XcmExecutor; type Weigher = FixedWeightBounds; type BaseXcmWeight = BaseXcmWeight; type LocationInverter = LocationInverter; diff --git a/runtime/mandala/src/xcm_config.rs b/runtime/mandala/src/xcm_config.rs index 4c799ab393..68c100eefc 100644 --- a/runtime/mandala/src/xcm_config.rs +++ b/runtime/mandala/src/xcm_config.rs @@ -47,7 +47,6 @@ pub use xcm_builder::{ SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeRevenue, TakeWeightCredit, }; -use xcm_executor::XcmExecutor; parameter_types! { pub const DotLocation: MultiLocation = MultiLocation::parent(); @@ -177,13 +176,21 @@ pub type XcmRouter = ( XcmpQueue, ); +pub type XcmExecutor = runtime_common::XcmExecutor< + XcmConfig, + AccountId, + Balance, + LocationToAccountId, + module_evm_bridge::EVMBridge, +>; + impl pallet_xcm::Config for Runtime { type RuntimeEvent = RuntimeEvent; type SendXcmOrigin = EnsureXcmOrigin; type XcmRouter = XcmRouter; type ExecuteXcmOrigin = EnsureXcmOrigin; type XcmExecuteFilter = Nothing; - type XcmExecutor = XcmExecutor; + type XcmExecutor = XcmExecutor; type XcmTeleportFilter = Nothing; type XcmReserveTransferFilter = Everything; type Weigher = FixedWeightBounds; @@ -196,12 +203,12 @@ impl pallet_xcm::Config for Runtime { impl cumulus_pallet_xcm::Config for Runtime { type RuntimeEvent = RuntimeEvent; - type XcmExecutor = XcmExecutor; + type XcmExecutor = XcmExecutor; } impl cumulus_pallet_xcmp_queue::Config for Runtime { type RuntimeEvent = RuntimeEvent; - type XcmExecutor = XcmExecutor; + type XcmExecutor = XcmExecutor; type ChannelInfo = ParachainSystem; type VersionWrapper = (); type ExecuteOverweightOrigin = EnsureRootOrHalfGeneralCouncil; @@ -212,7 +219,7 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime { impl cumulus_pallet_dmp_queue::Config for Runtime { type RuntimeEvent = RuntimeEvent; - type XcmExecutor = XcmExecutor; + type XcmExecutor = XcmExecutor; type ExecuteOverweightOrigin = EnsureRootOrHalfGeneralCouncil; } @@ -345,7 +352,7 @@ impl orml_xtokens::Config for Runtime { type CurrencyIdConvert = CurrencyIdConvert; type AccountIdToMultiLocation = AccountIdToMultiLocation; type SelfLocation = SelfLocation; - type XcmExecutor = XcmExecutor; + type XcmExecutor = XcmExecutor; type Weigher = FixedWeightBounds; type BaseXcmWeight = BaseXcmWeight; type LocationInverter = LocationInverter;