From e1f99dd5167553c4e4d933f14cffd22cc44c4707 Mon Sep 17 00:00:00 2001 From: Szegoo Date: Sat, 2 Mar 2024 17:16:23 +0100 Subject: [PATCH 01/11] Region reserve transfers --- .../frame/broker/src/dispatchable_impls.rs | 8 +-- substrate/frame/broker/src/lib.rs | 4 +- .../frame/broker/src/nonfungible_impl.rs | 53 +++++++++++++++---- substrate/frame/broker/src/types.rs | 2 +- substrate/frame/broker/src/utility_impls.rs | 4 +- 5 files changed, 53 insertions(+), 18 deletions(-) diff --git a/substrate/frame/broker/src/dispatchable_impls.rs b/substrate/frame/broker/src/dispatchable_impls.rs index f2451013251f..b44318993145 100644 --- a/substrate/frame/broker/src/dispatchable_impls.rs +++ b/substrate/frame/broker/src/dispatchable_impls.rs @@ -178,11 +178,11 @@ impl Pallet { let mut region = Regions::::get(®ion_id).ok_or(Error::::UnknownRegion)?; if let Some(check_owner) = maybe_check_owner { - ensure!(check_owner == region.owner, Error::::NotOwner); + ensure!(Some(check_owner) == region.owner, Error::::NotOwner); } let old_owner = region.owner; - region.owner = new_owner; + region.owner = Some(new_owner); Regions::::insert(®ion_id, ®ion); let duration = region.end.saturating_sub(region_id.begin); Self::deposit_event(Event::Transferred { @@ -203,7 +203,7 @@ impl Pallet { let mut region = Regions::::get(®ion_id).ok_or(Error::::UnknownRegion)?; if let Some(check_owner) = maybe_check_owner { - ensure!(check_owner == region.owner, Error::::NotOwner); + ensure!(Some(check_owner) == region.owner, Error::::NotOwner); } let pivot = region_id.begin.saturating_add(pivot_offset); ensure!(pivot < region.end, Error::::PivotTooLate); @@ -227,7 +227,7 @@ impl Pallet { let region = Regions::::get(®ion_id).ok_or(Error::::UnknownRegion)?; if let Some(check_owner) = maybe_check_owner { - ensure!(check_owner == region.owner, Error::::NotOwner); + ensure!(Some(check_owner) == region.owner, Error::::NotOwner); } ensure!((pivot & !region_id.mask).is_void(), Error::::ExteriorPivot); diff --git a/substrate/frame/broker/src/lib.rs b/substrate/frame/broker/src/lib.rs index a669463aa02d..445050ac2f67 100644 --- a/substrate/frame/broker/src/lib.rs +++ b/substrate/frame/broker/src/lib.rs @@ -214,9 +214,9 @@ pub mod pallet { /// The duration of the Region. duration: Timeslice, /// The old owner of the Region. - old_owner: T::AccountId, + old_owner: Option, /// The new owner of the Region. - owner: T::AccountId, + owner: Option, }, /// A Region has been split into two non-overlapping Regions. Partitioned { diff --git a/substrate/frame/broker/src/nonfungible_impl.rs b/substrate/frame/broker/src/nonfungible_impl.rs index b2e88bf09a0e..13d98be833bf 100644 --- a/substrate/frame/broker/src/nonfungible_impl.rs +++ b/substrate/frame/broker/src/nonfungible_impl.rs @@ -25,12 +25,13 @@ use sp_std::vec::Vec; impl Inspect for Pallet { type ItemId = u128; - fn owner(index: &Self::ItemId) -> Option { - Regions::::get(RegionId::from(*index)).map(|r| r.owner) + fn owner(item: &Self::ItemId) -> Option { + let record = Regions::::get(RegionId::from(*item))?; + record.owner } - fn attribute(index: &Self::ItemId, key: &[u8]) -> Option> { - let id = RegionId::from(*index); + fn attribute(item: &Self::ItemId, key: &[u8]) -> Option> { + let id = RegionId::from(*item); let item = Regions::::get(id)?; match key { b"begin" => Some(id.begin.encode()), @@ -46,11 +47,45 @@ impl Inspect for Pallet { } impl Transfer for Pallet { - fn transfer(index: &Self::ItemId, dest: &T::AccountId) -> DispatchResult { - Self::do_transfer((*index).into(), None, dest.clone()).map_err(Into::into) + fn transfer(item: &Self::ItemId, dest: &T::AccountId) -> DispatchResult { + Self::do_transfer((*item).into(), None, dest.clone()).map_err(Into::into) } } -// We don't allow any of the mutate operations, so the default implementation is used, which will -// return `TokenError::Unsupported` in case any of the operations is called. -impl Mutate for Pallet {} +/// We don't really support burning and minting. +/// +/// We only need this to allow the region to be reserve transferable. +/// +/// For reserve transfers that are not 'local', the asset must first be withdrawn to the holding +/// register and then deposited into the designated account. This process necessitates that the +/// asset is capable of being 'burned' and 'minted'. +/// +/// Since each region is associated with specific record data, we will not actually burn the asset. +/// If we did, we wouldn't know what record to assign to the newly minted region. Therefore, instead +/// of burning, we set the asset's owner to `None`. In essence, 'burning' a region involves setting +/// its owner to `None`, whereas 'minting' the region assigns its owner to an actual account. This +/// way we never lose track of the associated record data. +impl Mutate for Pallet { + fn mint_into(item: &Self::ItemId, who: &T::AccountId) -> DispatchResult { + let region_id: RegionId = (*item).into(); + let record = Regions::::get(®ion_id).ok_or(Error::::UnknownRegion)?; + + // 'Minting' can only occur if the asset has previously been burned(i.e. moved to the + // holding registrar) + ensure!(record.owner.is_none(), Error::::NotAllowed); + Self::issue(region_id.core, region_id.begin, record.end, who.clone(), record.paid); + + Ok(()) + } + + fn burn(item: &Self::ItemId, maybe_check_owner: Option<&T::AccountId>) -> DispatchResult { + let region_id: RegionId = (*item).into(); + let mut record = Regions::::get(®ion_id).ok_or(Error::::UnknownRegion)?; + if let Some(owner) = maybe_check_owner { + ensure!(Some(owner.clone()) == record.owner, Error::::NotOwner); + } + + record.owner = None; + Ok(()) + } +} diff --git a/substrate/frame/broker/src/types.rs b/substrate/frame/broker/src/types.rs index 7e9f351723a5..f0fecbedcdb3 100644 --- a/substrate/frame/broker/src/types.rs +++ b/substrate/frame/broker/src/types.rs @@ -84,7 +84,7 @@ pub struct RegionRecord { /// The end of the Region. pub end: Timeslice, /// The owner of the Region. - pub owner: AccountId, + pub owner: Option, /// The amount paid to Polkadot for this Region, or `None` if renewal is not allowed. pub paid: Option, } diff --git a/substrate/frame/broker/src/utility_impls.rs b/substrate/frame/broker/src/utility_impls.rs index 3dba5be5b398..3d35805b91a4 100644 --- a/substrate/frame/broker/src/utility_impls.rs +++ b/substrate/frame/broker/src/utility_impls.rs @@ -80,7 +80,7 @@ impl Pallet { paid: Option>, ) -> RegionId { let id = RegionId { begin, core, mask: CoreMask::complete() }; - let record = RegionRecord { end, owner, paid }; + let record = RegionRecord { end, owner: Some(owner), paid }; Regions::::insert(&id, &record); id } @@ -94,7 +94,7 @@ impl Pallet { let region = Regions::::get(®ion_id).ok_or(Error::::UnknownRegion)?; if let Some(check_owner) = maybe_check_owner { - ensure!(check_owner == region.owner, Error::::NotOwner); + ensure!(Some(check_owner) == region.owner, Error::::NotOwner); } Regions::::remove(®ion_id); From 01ffbe01fe61ca4852ee7fd6504c7ee68a0f8d66 Mon Sep 17 00:00:00 2001 From: Szegoo Date: Mon, 4 Mar 2024 17:33:45 +0100 Subject: [PATCH 02/11] tests & migration --- Cargo.lock | 1 + substrate/frame/broker/Cargo.toml | 2 + substrate/frame/broker/src/lib.rs | 7 ++ substrate/frame/broker/src/migration.rs | 67 +++++++++++++++++++ .../frame/broker/src/nonfungible_impl.rs | 2 + substrate/frame/broker/src/tests.rs | 25 +++++-- 6 files changed, 98 insertions(+), 6 deletions(-) create mode 100644 substrate/frame/broker/src/migration.rs diff --git a/Cargo.lock b/Cargo.lock index 3838ed0e94a1..6f1f8a7ed243 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9572,6 +9572,7 @@ dependencies = [ "frame-benchmarking", "frame-support", "frame-system", + "log", "parity-scale-codec", "scale-info", "sp-arithmetic", diff --git a/substrate/frame/broker/Cargo.toml b/substrate/frame/broker/Cargo.toml index 31f9a6b63178..2b63bbdad888 100644 --- a/substrate/frame/broker/Cargo.toml +++ b/substrate/frame/broker/Cargo.toml @@ -15,6 +15,7 @@ workspace = true targets = ["x86_64-unknown-linux-gnu"] [dependencies] +log = { workspace = true } codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } scale-info = { version = "2.10.0", default-features = false, features = ["derive"] } bitvec = { version = "1.0.0", default-features = false } @@ -38,6 +39,7 @@ std = [ "frame-benchmarking?/std", "frame-support/std", "frame-system/std", + "log/std", "scale-info/std", "sp-arithmetic/std", "sp-core/std", diff --git a/substrate/frame/broker/src/lib.rs b/substrate/frame/broker/src/lib.rs index 445050ac2f67..edfe327ae2f2 100644 --- a/substrate/frame/broker/src/lib.rs +++ b/substrate/frame/broker/src/lib.rs @@ -36,6 +36,7 @@ mod tick_impls; mod types; mod utility_impls; +pub mod migration; pub mod weights; pub use weights::WeightInfo; @@ -44,6 +45,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::*; @@ -59,7 +63,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(_); #[pallet::config] diff --git a/substrate/frame/broker/src/migration.rs b/substrate/frame/broker/src/migration.rs new file mode 100644 index 000000000000..4f4fe886d64f --- /dev/null +++ b/substrate/frame/broker/src/migration.rs @@ -0,0 +1,67 @@ +// This file is part of Substrate. + +// Copyright (C) Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +use super::*; +use crate::types::RegionRecord; +use codec::{Decode, Encode}; +use core::marker::PhantomData; +use frame_support::traits::{Get, OnRuntimeUpgrade}; +use sp_runtime::Saturating; + +#[derive(Encode, Decode)] +pub struct RegionRecordV0 { + /// The end of the Region. + pub end: Timeslice, + /// The owner of the Region. + pub owner: AccountId, + /// The amount paid to Polkadot for this Region, or `None` if renewal is not allowed. + pub paid: Option, +} + +mod v1 { + use super::*; + + pub struct MigrateToV1Impl(PhantomData); + + impl OnRuntimeUpgrade for MigrateToV1Impl { + fn on_runtime_upgrade() -> frame_support::weights::Weight { + let mut count: u64 = 0; + + >::translate::>, _>(|_, v0| { + count.saturating_inc(); + Some(RegionRecord { end: v0.end, owner: Some(v0.owner), paid: v0.paid }) + }); + + log::info!( + target: LOG_TARGET, + "Storage migration v1 for pallet-broker finished.", + ); + + // calculate and return migration weights + T::DbWeight::get().reads_writes(count as u64 + 1, count as u64 + 1) + } + } +} + +/// Migrate the pallet storage from `0` to `1`. +pub type MigrateV0ToV1 = frame_support::migrations::VersionedMigration< + 0, + 1, + v1::MigrateToV1Impl, + Pallet, + ::DbWeight, +>; diff --git a/substrate/frame/broker/src/nonfungible_impl.rs b/substrate/frame/broker/src/nonfungible_impl.rs index 13d98be833bf..f6ef7cccacb8 100644 --- a/substrate/frame/broker/src/nonfungible_impl.rs +++ b/substrate/frame/broker/src/nonfungible_impl.rs @@ -86,6 +86,8 @@ impl Mutate for Pallet { } record.owner = None; + Regions::::insert(region_id, record); + Ok(()) } } diff --git a/substrate/frame/broker/src/tests.rs b/substrate/frame/broker/src/tests.rs index 3e1e36f7d448..12672e6667e3 100644 --- a/substrate/frame/broker/src/tests.rs +++ b/substrate/frame/broker/src/tests.rs @@ -198,14 +198,27 @@ fn transfer_works() { } #[test] -fn mutate_operations_unsupported_for_regions() { - TestExt::new().execute_with(|| { +fn mutate_operations_work() { + TestExt::new().endow(1, 1000).execute_with(|| { let region_id = RegionId { begin: 0, core: 0, mask: CoreMask::complete() }; assert_noop!( >::mint_into(®ion_id.into(), &2), - TokenError::Unsupported + Error::::UnknownRegion ); - assert_noop!(>::burn(®ion_id.into(), None), TokenError::Unsupported); + + assert_ok!(Broker::do_start_sales(100, 1)); + advance_to(2); + let region_id = Broker::do_purchase(1, u64::max_value()).unwrap(); + assert_noop!( + >::mint_into(®ion_id.into(), &2), + Error::::NotAllowed + ); + assert_ok!(>::burn(®ion_id.into(), None)); + assert_eq!(Regions::::get(region_id).unwrap().owner, None); + assert_ok!(>::mint_into(®ion_id.into(), &2)); + assert_eq!(Regions::::get(region_id).unwrap().owner, Some(2)); + + // Unsupported operations: assert_noop!( >::set_attribute(®ion_id.into(), &[], &[]), TokenError::Unsupported @@ -283,7 +296,7 @@ fn nft_metadata_works() { assert_eq!(attribute::(region, b"begin"), 4); assert_eq!(attribute::(region, b"length"), 3); assert_eq!(attribute::(region, b"end"), 7); - assert_eq!(attribute::(region, b"owner"), 1); + assert_eq!(attribute::>(region, b"owner"), Some(1)); assert_eq!(attribute::(region, b"part"), 0xfffff_fffff_fffff_fffff.into()); assert_eq!(attribute::(region, b"core"), 0); assert_eq!(attribute::>(region, b"paid"), Some(100)); @@ -295,7 +308,7 @@ fn nft_metadata_works() { assert_eq!(attribute::(region, b"begin"), 6); assert_eq!(attribute::(region, b"length"), 1); assert_eq!(attribute::(region, b"end"), 7); - assert_eq!(attribute::(region, b"owner"), 42); + assert_eq!(attribute::>(region, b"owner"), Some(42)); assert_eq!(attribute::(region, b"part"), 0x00000_fffff_fffff_00000.into()); assert_eq!(attribute::(region, b"core"), 0); assert_eq!(attribute::>(region, b"paid"), None); From 6307dd34b5aff0f4c91010b9ca866e2b74ba4541 Mon Sep 17 00:00:00 2001 From: Szegoo Date: Mon, 4 Mar 2024 18:04:16 +0100 Subject: [PATCH 03/11] fix benchmarks --- substrate/frame/broker/src/benchmarking.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/substrate/frame/broker/src/benchmarking.rs b/substrate/frame/broker/src/benchmarking.rs index 70f488e998cc..c45e5caf1dbf 100644 --- a/substrate/frame/broker/src/benchmarking.rs +++ b/substrate/frame/broker/src/benchmarking.rs @@ -313,8 +313,8 @@ mod benches { assert_last_event::( Event::Transferred { region_id: region, - old_owner: caller, - owner: recipient, + old_owner: Some(caller), + owner: Some(recipient), duration: 3u32.into(), } .into(), From c9c25041e5284cea3fe98accd498830dfb131c5d Mon Sep 17 00:00:00 2001 From: Szegoo Date: Mon, 4 Mar 2024 18:08:48 +0100 Subject: [PATCH 04/11] try runtmie --- substrate/frame/broker/src/migration.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/substrate/frame/broker/src/migration.rs b/substrate/frame/broker/src/migration.rs index 4f4fe886d64f..33be3fbcfe48 100644 --- a/substrate/frame/broker/src/migration.rs +++ b/substrate/frame/broker/src/migration.rs @@ -22,6 +22,9 @@ use core::marker::PhantomData; use frame_support::traits::{Get, OnRuntimeUpgrade}; use sp_runtime::Saturating; +#[cfg(feature = "try-runtime")] +use frame_support::ensure; + #[derive(Encode, Decode)] pub struct RegionRecordV0 { /// The end of the Region. @@ -54,6 +57,20 @@ mod v1 { // calculate and return migration weights T::DbWeight::get().reads_writes(count as u64 + 1, count as u64 + 1) } + + #[cfg(feature = "try-runtime")] + fn pre_upgrade() -> Result, sp_runtime::TryRuntimeError> { + Ok((Regions::::iter_keys().count() as u32).encode()) + } + + #[cfg(feature = "try-runtime")] + fn post_upgrade(state: Vec) -> Result<(), sp_runtime::TryRuntimeError> { + let old_count = u32::decode(&mut &state[..]).expect("Known good"); + let new_count = Regions::::iter_values().count() as u32; + + ensure!(old_count == new_count, "Regions count should not change"); + Ok(()) + } } } From 2ebe29d4401367ea21d47d1d303f553b2b4444e7 Mon Sep 17 00:00:00 2001 From: Szegoo Date: Mon, 4 Mar 2024 18:23:13 +0100 Subject: [PATCH 05/11] fix --- substrate/frame/broker/src/migration.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/substrate/frame/broker/src/migration.rs b/substrate/frame/broker/src/migration.rs index 33be3fbcfe48..333958e85678 100644 --- a/substrate/frame/broker/src/migration.rs +++ b/substrate/frame/broker/src/migration.rs @@ -21,6 +21,7 @@ use codec::{Decode, Encode}; use core::marker::PhantomData; use frame_support::traits::{Get, OnRuntimeUpgrade}; use sp_runtime::Saturating; +use sp_std::prelude::vec::Vec; #[cfg(feature = "try-runtime")] use frame_support::ensure; From 5448324c11b7d88ba627a8606dcf0811bf6168ef Mon Sep 17 00:00:00 2001 From: Szegoo Date: Thu, 7 Mar 2024 13:32:27 +0100 Subject: [PATCH 06/11] fix --- substrate/frame/broker/src/migration.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/substrate/frame/broker/src/migration.rs b/substrate/frame/broker/src/migration.rs index 333958e85678..2457e7862164 100644 --- a/substrate/frame/broker/src/migration.rs +++ b/substrate/frame/broker/src/migration.rs @@ -21,7 +21,7 @@ use codec::{Decode, Encode}; use core::marker::PhantomData; use frame_support::traits::{Get, OnRuntimeUpgrade}; use sp_runtime::Saturating; -use sp_std::prelude::vec::Vec; +use sp_std::vec::Vec; #[cfg(feature = "try-runtime")] use frame_support::ensure; From 663dc0bac625e25d87cf7aa6d879181b6aa07b59 Mon Sep 17 00:00:00 2001 From: Szegoo Date: Fri, 8 Mar 2024 20:07:19 +0100 Subject: [PATCH 07/11] ... --- substrate/frame/broker/src/migration.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/substrate/frame/broker/src/migration.rs b/substrate/frame/broker/src/migration.rs index 2457e7862164..d6ae4d7a8fad 100644 --- a/substrate/frame/broker/src/migration.rs +++ b/substrate/frame/broker/src/migration.rs @@ -21,10 +21,11 @@ use codec::{Decode, Encode}; use core::marker::PhantomData; use frame_support::traits::{Get, OnRuntimeUpgrade}; use sp_runtime::Saturating; -use sp_std::vec::Vec; #[cfg(feature = "try-runtime")] use frame_support::ensure; +#[cfg(feature = "try-runtime")] +use sp_std::vec::Vec; #[derive(Encode, Decode)] pub struct RegionRecordV0 { From b41485606c044d827c38aa6cb1a4d1275ed51e59 Mon Sep 17 00:00:00 2001 From: Szegoo Date: Thu, 14 Mar 2024 18:06:02 +0100 Subject: [PATCH 08/11] improve docs & tests --- substrate/frame/broker/src/migration.rs | 1 + substrate/frame/broker/src/nonfungible_impl.rs | 2 ++ substrate/frame/broker/src/tests.rs | 7 ++++++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/substrate/frame/broker/src/migration.rs b/substrate/frame/broker/src/migration.rs index d6ae4d7a8fad..8a4ecfc21c30 100644 --- a/substrate/frame/broker/src/migration.rs +++ b/substrate/frame/broker/src/migration.rs @@ -27,6 +27,7 @@ use frame_support::ensure; #[cfg(feature = "try-runtime")] use sp_std::vec::Vec; +/// V0 region record. #[derive(Encode, Decode)] pub struct RegionRecordV0 { /// The end of the Region. diff --git a/substrate/frame/broker/src/nonfungible_impl.rs b/substrate/frame/broker/src/nonfungible_impl.rs index f6ef7cccacb8..b4e4353f7d4c 100644 --- a/substrate/frame/broker/src/nonfungible_impl.rs +++ b/substrate/frame/broker/src/nonfungible_impl.rs @@ -66,6 +66,7 @@ impl Transfer for Pallet { /// its owner to `None`, whereas 'minting' the region assigns its owner to an actual account. This /// way we never lose track of the associated record data. impl Mutate for Pallet { + /// Deposit a region into an account. fn mint_into(item: &Self::ItemId, who: &T::AccountId) -> DispatchResult { let region_id: RegionId = (*item).into(); let record = Regions::::get(®ion_id).ok_or(Error::::UnknownRegion)?; @@ -78,6 +79,7 @@ impl Mutate for Pallet { Ok(()) } + /// Withdraw a region from account. fn burn(item: &Self::ItemId, maybe_check_owner: Option<&T::AccountId>) -> DispatchResult { let region_id: RegionId = (*item).into(); let mut record = Regions::::get(®ion_id).ok_or(Error::::UnknownRegion)?; diff --git a/substrate/frame/broker/src/tests.rs b/substrate/frame/broker/src/tests.rs index 12672e6667e3..f7a6c1338343 100644 --- a/substrate/frame/broker/src/tests.rs +++ b/substrate/frame/broker/src/tests.rs @@ -213,8 +213,13 @@ fn mutate_operations_work() { >::mint_into(®ion_id.into(), &2), Error::::NotAllowed ); - assert_ok!(>::burn(®ion_id.into(), None)); + + assert_noop!(>::burn(®ion_id.into(), Some(&2)), Error::::NotOwner); + // 'withdraw' the region from user 1: + assert_ok!(>::burn(®ion_id.into(), Some(&1))); assert_eq!(Regions::::get(region_id).unwrap().owner, None); + + // `mint_into` works after burning: assert_ok!(>::mint_into(®ion_id.into(), &2)); assert_eq!(Regions::::get(region_id).unwrap().owner, Some(2)); From fd70daaf3c6059e56511c24ff030696cb2cf08bc Mon Sep 17 00:00:00 2001 From: Szegoo Date: Thu, 14 Mar 2024 18:25:20 +0100 Subject: [PATCH 09/11] prdoc --- prdoc/pr_3553.prdoc | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 prdoc/pr_3553.prdoc diff --git a/prdoc/pr_3553.prdoc b/prdoc/pr_3553.prdoc new file mode 100644 index 000000000000..5f8c94667c3f --- /dev/null +++ b/prdoc/pr_3553.prdoc @@ -0,0 +1,28 @@ +# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0 +# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json + +title: Region reserve transfers fix + +doc: + - audience: Runtime User + description: | + This PR addresses the issue with cross-chain transferring regions back to the + Coretime chain. TL;DR: 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 + +migrations: + db: [] + runtime: + - reference: pallet-regions + description: | + The region owner is optional. + +crates: + - name: pallet-regions From 59c5c03466ab7ef22d7cb4725276729ca1ae89ba Mon Sep 17 00:00:00 2001 From: Sergej Sakac <73715684+Szegoo@users.noreply.github.com> Date: Wed, 20 Mar 2024 07:47:46 +0100 Subject: [PATCH 10/11] Update prdoc/pr_3553.prdoc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Dónal Murray --- prdoc/pr_3553.prdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prdoc/pr_3553.prdoc b/prdoc/pr_3553.prdoc index 5f8c94667c3f..07f2add1a093 100644 --- a/prdoc/pr_3553.prdoc +++ b/prdoc/pr_3553.prdoc @@ -20,7 +20,7 @@ doc: migrations: db: [] runtime: - - reference: pallet-regions + - reference: pallet-broker description: | The region owner is optional. From 2a36d4c6044dda773fe2de9f668f61fd80560c81 Mon Sep 17 00:00:00 2001 From: Sergej Sakac <73715684+Szegoo@users.noreply.github.com> Date: Wed, 20 Mar 2024 07:47:51 +0100 Subject: [PATCH 11/11] Update prdoc/pr_3553.prdoc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Dónal Murray --- prdoc/pr_3553.prdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prdoc/pr_3553.prdoc b/prdoc/pr_3553.prdoc index 07f2add1a093..3cc7fbb0233d 100644 --- a/prdoc/pr_3553.prdoc +++ b/prdoc/pr_3553.prdoc @@ -25,4 +25,4 @@ migrations: The region owner is optional. crates: - - name: pallet-regions + - name: pallet-broker