XCM coretime region transfers (#3455)

This PR introduces changes enabling the transfer of coretime regions via
XCM.

TL;DR: There are two primary issues that are resolved in this PR:

1. The `mint` and `burn` functions were not implemented for coretime
regions. These operations are essential for moving assets to and from
the XCM holding register.
2. The transfer of non-fungible assets through XCM was previously
disallowed. This was due to incorrectly benchmarking non-fungible asset
transfers via XCM, which led to assigning it a weight of `Weight::Max`,
effectively preventing its execution.

### `mint_into` and `burn` implementation

This PR addresses the issue with cross-chain transferring regions back
to the Coretime chain. Remote reserve transfers are performed by
withdrawing and depositing the asset to and from the holding registry.
This requires the asset to support burning and minting functionality.

This PR adds burning and minting; however, they work a bit differently
than usual so that the associated region record is not lost when
burning. Instead of removing all the data, burning will set the owner of
the region to `None`, and when minting it back, it will set it to an
actual value. So, when cross-chain transferring, withdrawing into the
registry will remove the region from its original owner, and when
depositing it from the registry, it will set its owner to another
account

This was originally implemented in this PR: #3455, however we decided to
move all of it to this single PR
(https://github.com/paritytech/polkadot-sdk/pull/3455#discussion_r1547324892)

### Fixes made in this PR

- Update the `XcmReserveTransferFilter` on coretime chain since it is
meant as a reserve chain for coretime regions.
- Update the XCM benchmark to use `AssetTransactor` instead of assuming
`pallet-balances` for fungible transfers.
- Update the XCM benchmark to properly measure weight consumption for
nonfungible reserve asset transfers. ATM reserve transfers via the
extrinsic do not work since the weight for it is set to `Weight::max()`.

Closes: https://github.com/paritytech/polkadot-sdk/issues/865

---------

Co-authored-by: Branislav Kontur <bkontur@gmail.com>
Co-authored-by: Francisco Aguirre <franciscoaguirreperez@gmail.com>
Co-authored-by: Dónal Murray <donalm@seadanda.dev>
This commit is contained in:
Sergej Sakac
2024-04-17 11:25:33 +02:00
committed by GitHub
parent 4be9f93cd7
commit e6f3106d89
16 changed files with 368 additions and 94 deletions
+9 -2
View File
@@ -36,6 +36,7 @@ mod tick_impls;
mod types;
mod utility_impls;
pub mod migration;
pub mod runtime_api;
pub mod weights;
@@ -46,6 +47,9 @@ pub use core_mask::*;
pub use coretime_interface::*;
pub use types::*;
/// The log target for this pallet.
const LOG_TARGET: &str = "runtime::broker";
#[frame_support::pallet]
pub mod pallet {
use super::*;
@@ -61,7 +65,10 @@ pub mod pallet {
use sp_runtime::traits::{Convert, ConvertBack};
use sp_std::vec::Vec;
const STORAGE_VERSION: StorageVersion = StorageVersion::new(1);
#[pallet::pallet]
#[pallet::storage_version(STORAGE_VERSION)]
pub struct Pallet<T>(_);
#[pallet::config]
@@ -216,9 +223,9 @@ pub mod pallet {
/// The duration of the Region.
duration: Timeslice,
/// The old owner of the Region.
old_owner: T::AccountId,
old_owner: Option<T::AccountId>,
/// The new owner of the Region.
owner: T::AccountId,
owner: Option<T::AccountId>,
},
/// A Region has been split into two non-overlapping Regions.
Partitioned {