Skip to content
This repository has been archived by the owner on Oct 22, 2024. It is now read-only.

Commit

Permalink
fixes send token
Browse files Browse the repository at this point in the history
  • Loading branch information
claravanstaden authored and claravanstaden committed Oct 26, 2023
1 parent 1217723 commit 5e480dd
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,7 @@ impl xcm_executor::Config for XcmConfig {
type IsReserve = (
bridging::to_wococo::IsTrustedBridgedReserveLocationForConcreteAsset,
bridging::to_rococo::IsTrustedBridgedReserveLocationForConcreteAsset,
bridging::to_rococo::IsTrustedBridgedReserveLocationForForeignAsset,
);
type IsTeleporter = TrustedTeleporters;
type UniversalLocation = UniversalLocation;
Expand Down Expand Up @@ -678,7 +679,7 @@ impl pallet_xcm::Config for Runtime {
type XcmReserveTransferFilter = (
LocationWithAssetFilters<WithParentsZeroOrOne, AllAssets>,
bridging::to_rococo::AllowedReserveTransferAssets,
bridging::to_rococo::AllowedReserveTransferAssetsEthereum,
//bridging::to_rococo::AllowedReserveTransferAssetsEthereum,
bridging::to_wococo::AllowedReserveTransferAssets,
);

Expand Down Expand Up @@ -872,6 +873,7 @@ pub mod bridging {

pub mod to_rococo {
use super::*;
use assets_common::matching::FromNetwork;

parameter_types! {
pub SiblingBridgeHubWithBridgeHubRococoInstance: MultiLocation = MultiLocation::new(
Expand Down Expand Up @@ -903,10 +905,10 @@ pub mod bridging {
AssetHubRococo::get()
);

pub EtherFromEthereum: (MultiAssetFilter, MultiLocation) = (
Wild(AllOf { fun: WildFungible, id: Concrete(EthereumLocation::get()) }),
EthereumLocation::get()
);
/*pub EtherFromEthereum: (MultiAssetFilter, MultiLocation) = (
EthereumGatewayLocation::get().into(),
EthereumGatewayLocation::get()
);*/

/// Set up exporters configuration.
/// `Option<MultiAsset>` represents static "base fee" which is used for total delivery fee calculation.
Expand Down Expand Up @@ -941,14 +943,14 @@ pub mod bridging {
];

pub AllowedReserveTransferAssetsToEthereum: sp_std::vec::Vec<MultiAssetFilter> = sp_std::vec![
Wild(AllOf { fun: WildFungible, id: Concrete(EthereumGatewayLocation::get()) }), // TODO check
Wild(AllOf { fun: WildFungible, id: Concrete(EthereumGatewayLocation::get()) }),
];

/// Universal aliases
pub UniversalAliases: BTreeSet<(MultiLocation, Junction)> = BTreeSet::from_iter(
sp_std::vec![
(SiblingBridgeHubWithBridgeHubRococoInstance::get(), GlobalConsensus(RococoNetwork::get())),
(SiblingBridgeHub::get(), GlobalConsensus(EthereumNetwork::get())), // TODO check
(SiblingBridgeHub::get(), GlobalConsensus(EthereumNetwork::get())),
]
);
}
Expand All @@ -967,21 +969,24 @@ pub mod bridging {
(
// allow receive ROC from AssetHubRococo
xcm_builder::Case<RocFromAssetHubRococo>,
xcm_builder::Case<EtherFromEthereum>,
// and nothing else
),
>;

pub type IsTrustedBridgedReserveLocationForForeignAsset =
matching::IsForeignConcreteAsset<FromNetwork<EthereumNetwork>>;

/// Allows to reserve transfer assets to `AssetHubRococo`.
pub type AllowedReserveTransferAssets = LocationWithAssetFilters<
Equals<AssetHubRococo>,
AllowedReserveTransferAssetsToAssetHubRococo,
>;

/*
pub type AllowedReserveTransferAssetsEthereum = LocationWithAssetFilters<
StartsWithExplicitGlobalConsensus<EthereumNetwork>, // TODO check
AllowedReserveTransferAssetsToEthereum,
>;
>;*/

impl Contains<RuntimeCall> for ToRococoXcmRouter {
fn contains(call: &RuntimeCall) -> bool {
Expand Down
27 changes: 23 additions & 4 deletions cumulus/parachains/runtimes/assets/common/src/matching.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,37 @@ impl<SelfParaId: Get<ParaId>> ContainsPair<MultiLocation, MultiLocation>
fn contains(&a: &MultiLocation, b: &MultiLocation) -> bool {
// `a` needs to be from `b` at least
if !a.starts_with(b) {
return false
return false;
}

// here we check if sibling
match a {
MultiLocation { parents: 1, interior } =>
matches!(interior.first(), Some(Parachain(sibling_para_id)) if sibling_para_id.ne(&u32::from(SelfParaId::get()))),
MultiLocation { parents: 1, interior } => {
matches!(interior.first(), Some(Parachain(sibling_para_id)) if sibling_para_id.ne(&u32::from(SelfParaId::get())))
},
_ => false,
}
}
}

pub struct FromNetwork<SelfNetworkId>(sp_std::marker::PhantomData<SelfNetworkId>);
impl<SelfNetworkId: Get<NetworkId>> ContainsPair<MultiLocation, MultiLocation>
for FromNetwork<SelfNetworkId>
{
fn contains(&a: &MultiLocation, b: &MultiLocation) -> bool {
// `a` needs to be from `b` at least
if !a.starts_with(b) {
return false;
}

match a {
MultiLocation { parents: 2, interior } => {
matches!(interior.first(), Some(GlobalConsensus(network)) if *network == SelfNetworkId::get())
},
_ => false,
}
}
}
/// Adapter verifies if it is allowed to receive `MultiAsset` from `MultiLocation`.
///
/// Note: `MultiLocation` has to be from a different global consensus.
Expand Down Expand Up @@ -87,7 +106,7 @@ impl<
"IsTrustedBridgedReserveLocationForConcreteAsset origin: {:?} is not remote to the universal_source: {:?}",
origin, universal_source
);
return false
return false;
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -480,16 +480,14 @@ impl pallet_utility::Config for Runtime {

parameter_types! {
/// Amount of weight that can be spent per block to service messages.
pub MessageQueueServiceWeight: Weight = Weight::from_parts(1_000_000_000, 1_000_000);
pub const MessageQueueHeapSize: u32 = 65_536;
pub const MessageQueueMaxStale: u32 = 16;
pub MessageQueueServiceWeight: Weight = Perbill::from_percent(35) * RuntimeBlockWeights::get().max_block;
}

impl pallet_message_queue::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type Size = u32;
type HeapSize = MessageQueueHeapSize;
type MaxStale = MessageQueueMaxStale;
type HeapSize = ConstU32<{ 64 * 1024 }>;
type MaxStale = ConstU32<8>;
type ServiceWeight = MessageQueueServiceWeight;
type MessageProcessor = EthereumOutboundQueue;
type QueueChangeHandler = ();
Expand Down

0 comments on commit 5e480dd

Please sign in to comment.