Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable cross-chain Coretime region transfers #3077

Merged
merged 6 commits into from
Jan 27, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.

use super::{
AccountId, AllPalletsWithSystem, Balances, BaseDeliveryFee, FeeAssetId, ParachainInfo,
AccountId, AllPalletsWithSystem, Balances, BaseDeliveryFee, Broker, FeeAssetId, ParachainInfo,
ParachainSystem, PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin,
TransactionByteFee, WeightToFee, XcmpQueue,
};
use frame_support::{
pallet_prelude::PalletInfoAccess,
parameter_types,
traits::{ConstU32, Contains, Equals, Everything, Nothing},
};
Expand All @@ -42,11 +43,12 @@ use xcm_builder::CurrencyAdapter;
use xcm_builder::{
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses,
AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, DenyReserveTransferToRelayChain,
DenyThenTry, EnsureXcmOrigin, FrameTransactionalProcessor, IsConcrete, ParentAsSuperuser,
ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,
SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,
TrailingSetTopicAsId, UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic,
XcmFeeManagerFromComponents, XcmFeeToAccount,
DenyThenTry, EnsureXcmOrigin, FrameTransactionalProcessor, IsConcrete, NonFungibleAdapter,
ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative,
SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32,
SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId, UsingComponents,
WeightInfoBounds, WithComputedOrigin, WithUniqueTopic, XcmFeeManagerFromComponents,
XcmFeeToAccount,
};
use xcm_executor::{traits::WithOriginFilter, XcmExecutor};

Expand All @@ -56,6 +58,8 @@ parameter_types! {
pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into();
pub UniversalLocation: InteriorLocation =
[GlobalConsensus(RelayNetwork::get().unwrap()), Parachain(ParachainInfo::parachain_id().into())].into();
pub BrokerPalletLocation: Location =
PalletInstance(<Broker as PalletInfoAccess>::index() as u8).into();
pub const MaxInstructions: u32 = 100;
pub const MaxAssetsIntoHolding: u32 = 64;
pub const GovernanceLocation: Location = Location::parent();
Expand Down Expand Up @@ -90,6 +94,21 @@ pub type CurrencyTransactor = CurrencyAdapter<
(),
>;

pub type RegionTransactor = NonFungibleAdapter<
Szegoo marked this conversation as resolved.
Show resolved Hide resolved
// Use this non-fungible implementation:
Broker,
// This adapter will handle coretime regions from the broker pallet.
IsConcrete<BrokerPalletLocation>,
// Convert an XCM Location into a local account id:
LocationToAccountId,
// Our chain's account ID type (we can't get away without mentioning it explicitly):
AccountId,
// We don't track any teleports.
(),
>;

pub type AssetTransactors = (CurrencyTransactor, RegionTransactor);
Szegoo marked this conversation as resolved.
Show resolved Hide resolved

/// This is the type we use to convert an (incoming) XCM origin into a local `Origin` instance,
/// ready for dispatching a transaction with XCM's `Transact`. There is an `OriginKind` that can
/// bias the kind of local `Origin` it will become.
Expand Down Expand Up @@ -205,7 +224,7 @@ pub struct XcmConfig;
impl xcm_executor::Config for XcmConfig {
type RuntimeCall = RuntimeCall;
type XcmSender = XcmRouter;
type AssetTransactor = CurrencyTransactor;
type AssetTransactor = AssetTransactors;
type OriginConverter = XcmOriginToTransactDispatchOrigin;
// Coretime chain does not recognize a reserve location for any asset. Users must teleport ROC
// where allowed (e.g. with the Relay Chain).
Expand Down
13 changes: 13 additions & 0 deletions prdoc/pr_3077.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# 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: Enable cross-chain Coretime region transfers on Rococo Coretime chain

doc:
- audience: Runtime User
description: |
This PR allows Coretime regions to be cross-chain transferred from the Rococo Coretime chain.

crates:
- name: pallet-broker
- name: coretime-rococo-runtime
6 changes: 5 additions & 1 deletion substrate/frame/broker/src/nonfungible_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use super::*;
use frame_support::{
pallet_prelude::{DispatchResult, *},
traits::nonfungible::{Inspect, Transfer},
traits::nonfungible::{Inspect, Mutate, Transfer},
};
use sp_std::vec::Vec;

Expand Down Expand Up @@ -50,3 +50,7 @@ impl<T: Config> Transfer<T::AccountId> for Pallet<T> {
Self::do_transfer((*index).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<T: Config> Mutate<T::AccountId> for Pallet<T> {}
Szegoo marked this conversation as resolved.
Show resolved Hide resolved
Loading