Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ pallet-bridge-relayers = { workspace = true }
# Cumulus
asset-hub-westend-runtime = { workspace = true }
bp-asset-hub-westend = { workspace = true }
bridge-hub-common = { workspace = true }
bridge-hub-westend-runtime = { workspace = true }
cumulus-pallet-parachain-system = { workspace = true }
cumulus-pallet-xcmp-queue = { workspace = true }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,3 +243,59 @@ fn export_from_system_parachain_but_not_root_will_fail() {
);
});
}

#[test]
fn export_from_non_system_parachain_will_fail() {
let penpal_sovereign = BridgeHubWestend::sovereign_account_id_of(Location::new(
1,
[Parachain(PenpalB::para_id().into())],
));
BridgeHubWestend::fund_accounts(vec![(penpal_sovereign.clone(), INITIAL_FUND)]);

PenpalB::execute_with(|| {
type RuntimeEvent = <PenpalB as Chain>::RuntimeEvent;
type RuntimeOrigin = <PenpalB as Chain>::RuntimeOrigin;

let local_fee_asset =
Asset { id: AssetId(Location::here()), fun: Fungible(1_000_000_000_000) };

let weth_location_reanchored =
Location::new(0, [AccountKey20 { network: None, key: WETH.into() }]);

let weth_asset =
Asset { id: AssetId(weth_location_reanchored.clone()), fun: Fungible(TOKEN_AMOUNT) };

assert_ok!(<PenpalB as PenpalBPallet>::PolkadotXcm::send(
RuntimeOrigin::root(),
bx!(VersionedLocation::from(bridge_hub())),
bx!(VersionedXcm::from(Xcm(vec![
WithdrawAsset(local_fee_asset.clone().into()),
BuyExecution { fees: local_fee_asset.clone(), weight_limit: Unlimited },
ExportMessage {
network: Ethereum { chain_id: CHAIN_ID },
destination: Here,
xcm: Xcm(vec![
WithdrawAsset(weth_asset.clone().into()),
DepositAsset { assets: Wild(All), beneficiary: beneficiary() },
SetTopic([0; 32]),
]),
},
]))),
));

assert_expected_events!(
PenpalB,
vec![RuntimeEvent::PolkadotXcm(pallet_xcm::Event::Sent{ .. }) => {},]
);
});

BridgeHubWestend::execute_with(|| {
type RuntimeEvent = <BridgeHubWestend as Chain>::RuntimeEvent;
assert_expected_events!(
BridgeHubWestend,
vec![RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed{ success:false, origin, .. }) => {
origin: *origin == bridge_hub_common::AggregateMessageOrigin::Sibling(PenpalB::para_id()),
},]
);
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,14 @@ use super::{
ParachainSystem, PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin,
TransactionByteFee, WeightToFee, XcmOverBridgeHubRococo, XcmpQueue,
};
use crate::bridge_to_ethereum_config::SnowbridgeFrontendLocation;
use crate::bridge_to_ethereum_config::{AssetHubLocation, SnowbridgeFrontendLocation};
use bridge_hub_common::DenyExportMessageFrom;
use frame_support::{
parameter_types,
traits::{tokens::imbalance::ResolveTo, ConstU32, Contains, Equals, Everything, Nothing},
traits::{
tokens::imbalance::ResolveTo, ConstU32, Contains, Equals, Everything, EverythingBut,
Nothing,
},
};
use frame_system::EnsureRoot;
use pallet_collator_selection::StakingPotAccountId;
Expand Down Expand Up @@ -136,7 +140,15 @@ impl Contains<Location> for ParentOrParentsPlurality {

pub type Barrier = TrailingSetTopicAsId<
DenyThenTry<
DenyRecursively<DenyReserveTransferToRelayChain>,
(
DenyRecursively<DenyReserveTransferToRelayChain>,
DenyRecursively<
DenyExportMessageFrom<
EverythingBut<Equals<AssetHubLocation>>,
Equals<EthereumNetwork>,
>,
>,
),
(
// Allow local users to buy weight credit.
TakeWeightCredit,
Expand Down
Loading