Skip to content

Commit

Permalink
change(kreivo-runtime): trust reserves from DOT (#363)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
pandres95 and olanod authored Jun 27, 2024
1 parent 3d0bcdd commit 0a05c39
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
4 changes: 2 additions & 2 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
23 changes: 19 additions & 4 deletions runtime/kreivo/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ parameter_types! {
pub AssetsPalletLocation: Location =
PalletInstance(<Assets as PalletInfoAccess>::index() as u8).into();
pub UniversalLocation: InteriorLocation = [
GlobalConsensus(NetworkId::Polkadot),
GlobalConsensus(NetworkId::Kusama),
Parachain(ParachainInfo::parachain_id().into()),
].into();
Expand All @@ -68,7 +69,7 @@ pub type LocationToAccountId = (
pub type LocationConvertedConcreteId = xcm_builder::MatchedConvertedConcreteId<
FungibleAssetLocation,
Balance,
StartsWith<AssetHubLocation>,
(StartsWith<AssetHubLocation>, StartsWith<PolkadotLocation>),
AsFungibleAssetLocation,
JustTry,
>;
Expand Down Expand Up @@ -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
Expand All @@ -183,9 +185,18 @@ fn matches_prefix(prefix: &Location, loc: &Location) -> bool {
}
pub struct ReserveAssetsFrom<T>(PhantomData<T>);
impl<Prefix: Get<Location>> ContainsPair<Asset, Location> for ReserveAssetsFrom<Prefix> {
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<P, R>(PhantomData<(P, R)>);
impl<Prefix: Get<Location>, ReserveLocation: Get<Location>> ContainsPair<Asset, Location>
for ReserveForeignAssetsFrom<Prefix, ReserveLocation>
{
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)
}
}

Expand All @@ -208,7 +219,11 @@ pub type Traders = (
UsingComponents<WeightToFee, RelayLocation, AccountId, Balances, ResolveTo<TreasuryAccount, Balances>>,
);

pub type Reserves = (NativeAsset, ReserveAssetsFrom<AssetHubLocation>);
pub type Reserves = (
NativeAsset,
ReserveAssetsFrom<AssetHubLocation>,
ReserveForeignAssetsFrom<PolkadotLocation, AssetHubLocation>,
);

pub struct XcmConfig;
impl xcm_executor::Config for XcmConfig {
Expand Down

0 comments on commit 0a05c39

Please sign in to comment.