Asset conversion nits (#2860)

* [asset-conv] Unused Balances type

* [asset-conv] native asset change

* Dedicated `AssetBalance` type for `pallet_assets` instances

* Improved local vs foreign asset handling + test for not allowing pool_assets in pool

* Removed `into_multiasset_id`

* Fix

* Refactor

* Fixed create_pool for benchmark with LocalAndForeignAssets (finally found it)

* ".git/.scripts/commands/fmt/fmt.sh"

* Revert

* fmt

* Migrates pools with `MultiLocation { parents: 0, interior: Here }` to `MultiLocation { parents: 1, interior: Here }`

* Allow `set_storage` for `AllowMultiAssetPools` / `LiquidityWithdrawalFee`

* Benchmarks work

* Removed comment + more defensive migration

* `T::Currency::transfer` -> `Balances::transfer_all` in migration

* Change pool_id in migration

* Update parachains/runtimes/assets/asset-hub-westend/src/lib.rs

* Bump substrate (manually)

* Bump polkadot

* Fixes from polkadot + clippy

* Fix for xcm-emulator tests (thank you Nacho)

---------

Co-authored-by: command-bot <>
Co-authored-by: Jegor Sidorenko <5252494+jsidorenko@users.noreply.github.com>
This commit is contained in:
Branislav Kontur
2023-07-21 23:53:51 +02:00
committed by GitHub
parent 849964bf18
commit 8171890f9b
25 changed files with 1060 additions and 486 deletions
@@ -54,6 +54,9 @@ use xcm_executor::XcmExecutor;
// Re-export test_case from assets
pub use asset_test_utils::include_teleports_for_native_asset_works;
// Re-export test_case from `parachains-runtimes-test-utils`
pub use parachains_runtimes_test_utils::test_cases::change_storage_constant_by_governance_works;
/// Test-case makes sure that `Runtime` can process bridging initialize via governance-like call
pub fn initialize_bridge_by_governance_works<Runtime, GrandpaPalletInstance>(
collator_session_key: CollatorSessionKeys<Runtime>,
@@ -114,76 +117,6 @@ pub fn initialize_bridge_by_governance_works<Runtime, GrandpaPalletInstance>(
})
}
/// Test-case makes sure that `Runtime` can change storage constant via governance-like call
pub fn change_storage_constant_by_governance_works<Runtime, StorageConstant, StorageConstantType>(
collator_session_key: CollatorSessionKeys<Runtime>,
runtime_para_id: u32,
runtime_call_encode: Box<dyn Fn(frame_system::Call<Runtime>) -> Vec<u8>>,
storage_constant_key_value: fn() -> (Vec<u8>, StorageConstantType),
new_storage_constant_value: fn(&StorageConstantType) -> StorageConstantType,
) where
Runtime: frame_system::Config
+ pallet_balances::Config
+ pallet_session::Config
+ pallet_xcm::Config
+ parachain_info::Config
+ pallet_collator_selection::Config
+ cumulus_pallet_dmp_queue::Config
+ cumulus_pallet_parachain_system::Config,
ValidatorIdOf<Runtime>: From<AccountIdOf<Runtime>>,
StorageConstant: Get<StorageConstantType>,
StorageConstantType: Encode + PartialEq + std::fmt::Debug,
{
ExtBuilder::<Runtime>::default()
.with_collators(collator_session_key.collators())
.with_session_keys(collator_session_key.session_keys())
.with_para_id(runtime_para_id.into())
.with_tracing()
.build()
.execute_with(|| {
let (storage_constant_key, storage_constant_init_value): (
Vec<u8>,
StorageConstantType,
) = storage_constant_key_value();
// check delivery reward constant before (not stored yet, just as default value is used)
assert_eq!(StorageConstant::get(), storage_constant_init_value);
assert_eq!(sp_io::storage::get(&storage_constant_key), None);
let new_storage_constant_value =
new_storage_constant_value(&storage_constant_init_value);
assert_ne!(new_storage_constant_value, storage_constant_init_value);
// encode `set_storage` call
let set_storage_call =
runtime_call_encode(frame_system::Call::<Runtime>::set_storage {
items: vec![(
storage_constant_key.clone(),
new_storage_constant_value.encode(),
)],
});
// estimate - storing just 1 value
use frame_system::WeightInfo;
let require_weight_at_most =
<Runtime as frame_system::Config>::SystemWeightInfo::set_storage(1);
// execute XCM with Transact to `set_storage` as governance does
assert_ok!(RuntimeHelper::<Runtime>::execute_as_governance(
set_storage_call,
require_weight_at_most
)
.ensure_complete());
// check delivery reward constant after (stored)
assert_eq!(StorageConstant::get(), new_storage_constant_value);
assert_eq!(
sp_io::storage::get(&storage_constant_key),
Some(new_storage_constant_value.encode().into())
);
})
}
/// Test-case makes sure that `Runtime` can handle xcm `ExportMessage`:
/// Checks if received XCM messages is correctly added to the message outbound queue for delivery.
/// For SystemParachains we expect unpaid execution.