From 0a05c3998d5e596911989f813a91affa44e6ee65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Andr=C3=A9s=20Dorado=20Su=C3=A1rez?= Date: Thu, 27 Jun 2024 03:18:41 -0500 Subject: [PATCH] change(kreivo-runtime): trust reserves from DOT (#363) * Update build-container task builder image * change(kreivo-runtime): trust reserves from DOT * fix(kreivo-runtime): remove redundant prefix check for reserved assets * change(kreivo-runtime): use separate filter for specific foreign assets reserves --------- Co-authored-by: Daniel Olano --- justfile | 4 ++-- runtime/kreivo/src/xcm_config.rs | 23 +++++++++++++++++++---- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/justfile b/justfile index fce48bae..cdef6be4 100644 --- a/justfile +++ b/justfile @@ -67,12 +67,12 @@ benchmark pallet="" extrinsic="*": build-container: #!/usr/bin/env nu - 'FROM docker.io/paritytech/ci-linux:production as builder + 'FROM docker.io/paritytech/ci-unified:latest as builder WORKDIR /virto COPY . /virto RUN cargo build --release - FROM debian:bookworm-slim + FROM debian:bullseye-slim VOLUME /data COPY --from=builder /virto/{{ node }} /usr/bin ENTRYPOINT ["/usr/bin/virto-node"] diff --git a/runtime/kreivo/src/xcm_config.rs b/runtime/kreivo/src/xcm_config.rs index a429828d..b2c2b446 100644 --- a/runtime/kreivo/src/xcm_config.rs +++ b/runtime/kreivo/src/xcm_config.rs @@ -42,6 +42,7 @@ parameter_types! { pub AssetsPalletLocation: Location = PalletInstance(::index() as u8).into(); pub UniversalLocation: InteriorLocation = [ + GlobalConsensus(NetworkId::Polkadot), GlobalConsensus(NetworkId::Kusama), Parachain(ParachainInfo::parachain_id().into()), ].into(); @@ -68,7 +69,7 @@ pub type LocationToAccountId = ( pub type LocationConvertedConcreteId = xcm_builder::MatchedConvertedConcreteId< FungibleAssetLocation, Balance, - StartsWith, + (StartsWith, StartsWith), AsFungibleAssetLocation, JustTry, >; @@ -168,7 +169,8 @@ pub type Barrier = ( pub type AssetTransactors = (FungibleTransactor, FungiblesTransactor); parameter_types! { - pub AssetHubLocation: Location = Location::new(1, [Junction::Parachain(ASSET_HUB_ID)]); + pub AssetHubLocation: Location = Location::new(1, [Parachain(ASSET_HUB_ID)]); + pub PolkadotLocation: Location = Location::new(2, [GlobalConsensus(NetworkId::Polkadot)]); } //- From PR https://github.com/paritytech/cumulus/pull/936 @@ -183,9 +185,18 @@ fn matches_prefix(prefix: &Location, loc: &Location) -> bool { } pub struct ReserveAssetsFrom(PhantomData); impl> ContainsPair for ReserveAssetsFrom { + fn contains(asset: &Asset, _origin: &Location) -> bool { + log::trace!(target: "xcm::AssetsFrom", "prefix: {:?}, origin: {:?}", Prefix::get(), _origin); + matches_prefix(&Prefix::get(), &asset.id.0) + } +} +pub struct ReserveForeignAssetsFrom(PhantomData<(P, R)>); +impl, ReserveLocation: Get> ContainsPair + for ReserveForeignAssetsFrom +{ fn contains(asset: &Asset, origin: &Location) -> bool { log::trace!(target: "xcm::AssetsFrom", "prefix: {:?}, origin: {:?}", Prefix::get(), origin); - &Prefix::get() == origin && matches_prefix(&Prefix::get(), &asset.id.0) + &ReserveLocation::get() == origin && matches_prefix(&Prefix::get(), &asset.id.0) } } @@ -208,7 +219,11 @@ pub type Traders = ( UsingComponents>, ); -pub type Reserves = (NativeAsset, ReserveAssetsFrom); +pub type Reserves = ( + NativeAsset, + ReserveAssetsFrom, + ReserveForeignAssetsFrom, +); pub struct XcmConfig; impl xcm_executor::Config for XcmConfig {