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

dmp: Check that the para exist before delivering a message #6604

Merged
merged 34 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
7c9cea6
dmp: Check that the para exist before delivering a message
bkchr Nov 21, 2024
0d23781
Update from bkchr running command 'prdoc --audience runtime_dev --bum…
actions-user Nov 29, 2024
70b42e0
Fix compilation + tests
bkchr Nov 29, 2024
6c040a4
Merge remote-tracking branch 'refs/remotes/origin/bkchr-dmp-check-par…
bkchr Nov 29, 2024
575294f
Update pr_6604.prdoc
bkchr Nov 29, 2024
a1c1153
Update prdoc/pr_6604.prdoc
bkchr Nov 29, 2024
3646d0f
Update prdoc/pr_6604.prdoc
bkchr Nov 29, 2024
086192a
Add test that checks it fails
bkchr Nov 29, 2024
a6a0406
Merge remote-tracking branch 'refs/remotes/origin/bkchr-dmp-check-par…
bkchr Nov 29, 2024
1b43681
Remove duplicate code
bkchr Nov 29, 2024
040da5d
Starting to fix some benchmarks
bkchr Nov 30, 2024
080ff18
Fix pallet-xcm
bkchr Nov 30, 2024
ef2a7c0
Small clean-up for `EnsureForParachain` stuff (#6714)
bkontur Nov 30, 2024
7d0f520
More fixes
bkchr Nov 30, 2024
af60dd5
Fix coretime benchmark
bkchr Nov 30, 2024
77f6a1e
Fix identity migration benchmarks
bkchr Dec 2, 2024
3bd4868
Fix the treasury benchmarks
bkchr Dec 2, 2024
7f9791a
Use zepter to correct features
bkchr Dec 2, 2024
de2e5ef
Merge remote-tracking branch 'refs/remotes/origin/master'
bkchr Dec 2, 2024
123a805
Update polkadot/runtime/parachains/src/dmp/tests.rs
bkchr Dec 3, 2024
01dc000
Update polkadot/runtime/common/src/xcm_sender.rs
bkchr Dec 3, 2024
eaaf4cb
Update polkadot/runtime/common/src/xcm_sender.rs
bkchr Dec 3, 2024
38b8775
Update polkadot/xcm/src/v5/traits.rs
bkchr Dec 3, 2024
3348079
".git/.scripts/commands/fmt/fmt.sh"
Dec 9, 2024
411de11
Merge branch 'master' into bkchr-dmp-check-para-exists
bkchr Dec 9, 2024
e759d38
Update polkadot/runtime/parachains/src/dmp/tests.rs
bkchr Dec 10, 2024
bb73ce0
Fix test
bkchr Dec 10, 2024
4efbafa
Fix warning
bkchr Dec 10, 2024
29e87af
Update from bkchr running command 'prdoc --audience runtime_dev --bum…
Dec 10, 2024
d285d85
Update prdoc/pr_6604.prdoc
bkchr Dec 10, 2024
141035a
Fix test
bkchr Dec 11, 2024
60c70af
Merge remote-tracking branch 'refs/remotes/origin/bkchr-dmp-check-par…
bkchr Dec 11, 2024
5fe3379
Fix integration tests
bkchr Dec 12, 2024
d198303
Merge branch 'master' into bkchr-dmp-check-para-exists
bkchr Dec 12, 2024
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
4 changes: 3 additions & 1 deletion Cargo.lock

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

1 change: 1 addition & 0 deletions bridges/bin/runtime-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ runtime-benchmarks = [
"pallet-utility/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"sp-trie",
"xcm/runtime-benchmarks",
]
integrity-test = ["static_assertions"]
test-helpers = ["bp-runtime/test-helpers", "sp-trie"]
1 change: 1 addition & 0 deletions bridges/modules/xcm-bridge-hub-router/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ runtime-benchmarks = [
"frame-system/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"xcm-builder/runtime-benchmarks",
"xcm/runtime-benchmarks",
]
try-runtime = [
"frame-support/try-runtime",
Expand Down
1 change: 1 addition & 0 deletions bridges/modules/xcm-bridge-hub/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ runtime-benchmarks = [
"sp-runtime/runtime-benchmarks",
"xcm-builder/runtime-benchmarks",
"xcm-executor/runtime-benchmarks",
"xcm/runtime-benchmarks",
]
try-runtime = [
"frame-support/try-runtime",
Expand Down
1 change: 1 addition & 0 deletions bridges/snowbridge/pallets/inbound-queue/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ runtime-benchmarks = [
"snowbridge-router-primitives/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"xcm-executor/runtime-benchmarks",
"xcm/runtime-benchmarks",
]
try-runtime = [
"frame-support/try-runtime",
Expand Down
1 change: 1 addition & 0 deletions bridges/snowbridge/pallets/system/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ runtime-benchmarks = [
"snowbridge-pallet-outbound-queue/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"xcm-executor/runtime-benchmarks",
"xcm/runtime-benchmarks",
]
try-runtime = [
"frame-support/try-runtime",
Expand Down
1 change: 1 addition & 0 deletions bridges/snowbridge/primitives/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,5 @@ runtime-benchmarks = [
"sp-runtime/runtime-benchmarks",
"xcm-builder/runtime-benchmarks",
"xcm-executor/runtime-benchmarks",
"xcm/runtime-benchmarks",
]
1 change: 1 addition & 0 deletions bridges/snowbridge/primitives/router/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,5 @@ runtime-benchmarks = [
"snowbridge-core/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"xcm-executor/runtime-benchmarks",
"xcm/runtime-benchmarks",
]
1 change: 1 addition & 0 deletions bridges/snowbridge/runtime/runtime-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,5 @@ runtime-benchmarks = [
"snowbridge-core/runtime-benchmarks",
"xcm-builder/runtime-benchmarks",
"xcm-executor/runtime-benchmarks",
"xcm/runtime-benchmarks",
]
1 change: 1 addition & 0 deletions bridges/snowbridge/runtime/test-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,6 @@ runtime-benchmarks = [
"snowbridge-pallet-system/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"xcm-executor/runtime-benchmarks",
"xcm/runtime-benchmarks",
]
fast-runtime = []
1 change: 1 addition & 0 deletions cumulus/pallets/dmp-queue/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ runtime-benchmarks = [
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"xcm/runtime-benchmarks",
]

try-runtime = [
Expand Down
5 changes: 1 addition & 4 deletions cumulus/pallets/parachain-system/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ sp-version = { workspace = true }
# Polkadot
polkadot-parachain-primitives = { features = ["wasm-api"], workspace = true }
polkadot-runtime-parachains = { workspace = true }
polkadot-runtime-common = { optional = true, workspace = true }
xcm = { workspace = true }
xcm-builder = { workspace = true }

Expand Down Expand Up @@ -84,7 +83,6 @@ std = [
"log/std",
"pallet-message-queue/std",
"polkadot-parachain-primitives/std",
"polkadot-runtime-common/std",
"polkadot-runtime-parachains/std",
"scale-info/std",
"sp-core/std",
Expand All @@ -109,17 +107,16 @@ runtime-benchmarks = [
"frame-system/runtime-benchmarks",
"pallet-message-queue/runtime-benchmarks",
"polkadot-parachain-primitives/runtime-benchmarks",
"polkadot-runtime-common/runtime-benchmarks",
"polkadot-runtime-parachains/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"xcm-builder/runtime-benchmarks",
"xcm/runtime-benchmarks",
]

try-runtime = [
"frame-support/try-runtime",
"frame-system/try-runtime",
"pallet-message-queue/try-runtime",
"polkadot-runtime-common?/try-runtime",
"polkadot-runtime-parachains/try-runtime",
"sp-runtime/try-runtime",
]
Expand Down
2 changes: 1 addition & 1 deletion cumulus/pallets/parachain-system/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1636,7 +1636,7 @@ impl<T: Config> InspectMessageQueues for Pallet<T> {
}

#[cfg(feature = "runtime-benchmarks")]
impl<T: Config> polkadot_runtime_common::xcm_sender::EnsureForParachain for Pallet<T> {
impl<T: Config> polkadot_runtime_parachains::EnsureForParachain for Pallet<T> {
fn ensure(para_id: ParaId) {
if let ChannelStatus::Closed = Self::get_channel_status(para_id) {
Self::open_outbound_hrmp_channel_for_benchmarks_or_tests(para_id)
Expand Down
1 change: 1 addition & 0 deletions cumulus/pallets/xcmp-queue/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ runtime-benchmarks = [
"sp-runtime/runtime-benchmarks",
"xcm-builder/runtime-benchmarks",
"xcm-executor/runtime-benchmarks",
"xcm/runtime-benchmarks",
]
try-runtime = [
"cumulus-pallet-parachain-system/try-runtime",
Expand Down
1 change: 1 addition & 0 deletions cumulus/parachains/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,5 @@ runtime-benchmarks = [
"polkadot-primitives/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"xcm-executor/runtime-benchmarks",
"xcm/runtime-benchmarks",
]
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,8 @@ macro_rules! impl_send_transact_helpers_for_relay_chain {
let destination: $crate::impls::Location = <Self as RelayChain>::child_location_of(recipient);
let xcm = $crate::impls::xcm_transact_unpaid_execution(call, $crate::impls::OriginKind::Superuser);

$crate::impls::dmp::Pallet::<<Self as $crate::impls::Chain>::Runtime>::make_parachain_reachable(recipient);

// Send XCM `Transact`
$crate::impls::assert_ok!(<Self as [<$chain RelayPallet>]>::XcmPallet::send(
root_origin,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pub use pallet_message_queue;
pub use pallet_xcm;

// Polkadot
pub use polkadot_runtime_parachains::dmp::Pallet as Dmp;
pub use xcm::{
prelude::{
AccountId32, All, Asset, AssetId, BuyExecution, DepositAsset, ExpectTransactStatus,
Expand Down Expand Up @@ -156,6 +157,8 @@ macro_rules! test_relay_is_trusted_teleporter {

// Send XCM message from Relay
<$sender_relay>::execute_with(|| {
$crate::macros::Dmp::<<$sender_relay as $crate::macros::Chain>::Runtime>::make_parachain_reachable(<$receiver_para>::para_id());

assert_ok!(<$sender_relay as [<$sender_relay Pallet>]>::XcmPallet::limited_teleport_assets(
origin.clone(),
bx!(para_destination.clone().into()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use rococo_system_emulated_network::rococo_emulated_chain::rococo_runtime::Dmp;

use super::reserve_transfer::*;
use crate::{
imports::*,
Expand Down Expand Up @@ -777,6 +779,8 @@ fn transfer_native_asset_from_relay_to_para_through_asset_hub() {
xcm: xcm_on_final_dest,
}]);

Dmp::make_parachain_reachable(AssetHubRococo::para_id());

// First leg is a teleport, from there a local-reserve-transfer to final dest
<Rococo as RococoPallet>::XcmPallet::transfer_assets_using_type_and_then(
t.signed_origin,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
// limitations under the License.

use crate::imports::*;
use rococo_system_emulated_network::rococo_emulated_chain::rococo_runtime::Dmp;
use sp_core::{crypto::get_public_from_string_or_panic, sr25519};

fn relay_to_para_sender_assertions(t: RelayToParaTest) {
Expand Down Expand Up @@ -487,6 +488,11 @@ pub fn para_to_para_through_hop_receiver_assertions<Hop: Clone>(t: Test<PenpalA,
}

fn relay_to_para_reserve_transfer_assets(t: RelayToParaTest) -> DispatchResult {
let Junction::Parachain(para_id) = *t.args.dest.chain_location().last().unwrap() else {
unimplemented!("Destination is not a parachain?")
};

Dmp::make_parachain_reachable(para_id);
<Rococo as RococoPallet>::XcmPallet::limited_reserve_transfer_assets(
t.signed_origin,
bx!(t.args.dest.into()),
Expand Down Expand Up @@ -546,6 +552,13 @@ fn para_to_system_para_reserve_transfer_assets(t: ParaToSystemParaTest) -> Dispa
fn para_to_para_through_relay_limited_reserve_transfer_assets(
t: ParaToParaThroughRelayTest,
) -> DispatchResult {
let Junction::Parachain(para_id) = *t.args.dest.chain_location().last().unwrap() else {
unimplemented!("Destination is not a parachain?")
};

Rococo::ext_wrapper(|| {
Dmp::make_parachain_reachable(para_id);
});
<PenpalA as PenpalAPallet>::PolkadotXcm::limited_reserve_transfer_assets(
t.signed_origin,
bx!(t.args.dest.into()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ use frame_support::{
use parachains_common::AccountId;
use polkadot_runtime_common::impls::VersionedLocatableAsset;
use rococo_runtime_constants::currency::GRAND;
use rococo_system_emulated_network::rococo_emulated_chain::rococo_runtime::Dmp;
use xcm_executor::traits::ConvertLocation;

// Fund Treasury account on Asset Hub from Treasury account on Relay Chain with ROCs.
Expand Down Expand Up @@ -64,6 +65,7 @@ fn spend_roc_on_asset_hub() {
treasury_balance * 2,
));

Dmp::make_parachain_reachable(1000);
let native_asset = Location::here();
let asset_hub_location: Location = [Parachain(1000)].into();
let treasury_location: Location = (Parent, PalletInstance(18)).into();
Expand Down Expand Up @@ -199,6 +201,8 @@ fn create_and_claim_treasury_spend_in_usdt() {
// create a conversion rate from `asset_kind` to the native currency.
assert_ok!(AssetRate::create(root.clone(), Box::new(asset_kind.clone()), 2.into()));

Dmp::make_parachain_reachable(1000);

// create and approve a treasury spend.
assert_ok!(Treasury::spend(
root,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use westend_system_emulated_network::westend_emulated_chain::westend_runtime::Dmp;

use super::reserve_transfer::*;
use crate::{
imports::*,
Expand Down Expand Up @@ -778,6 +780,8 @@ fn transfer_native_asset_from_relay_to_penpal_through_asset_hub() {
xcm: xcm_on_final_dest,
}]);

Dmp::make_parachain_reachable(AssetHubWestend::para_id());

// First leg is a teleport, from there a local-reserve-transfer to final dest
<Westend as WestendPallet>::XcmPallet::transfer_assets_using_type_and_then(
t.signed_origin,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

use crate::{create_pool_with_wnd_on, foreign_balance_on, imports::*};
use sp_core::{crypto::get_public_from_string_or_panic, sr25519};
use westend_system_emulated_network::westend_emulated_chain::westend_runtime::Dmp;

fn relay_to_para_sender_assertions(t: RelayToParaTest) {
type RuntimeEvent = <Westend as Chain>::RuntimeEvent;
Expand Down Expand Up @@ -487,6 +488,11 @@ pub fn para_to_para_through_hop_receiver_assertions<Hop: Clone>(t: Test<PenpalA,
}

fn relay_to_para_reserve_transfer_assets(t: RelayToParaTest) -> DispatchResult {
let Junction::Parachain(para_id) = *t.args.dest.chain_location().last().unwrap() else {
unimplemented!("Destination is not a parachain?")
};

Dmp::make_parachain_reachable(para_id);
<Westend as WestendPallet>::XcmPallet::limited_reserve_transfer_assets(
t.signed_origin,
bx!(t.args.dest.into()),
Expand Down Expand Up @@ -533,6 +539,13 @@ fn para_to_system_para_reserve_transfer_assets(t: ParaToSystemParaTest) -> Dispa
fn para_to_para_through_relay_limited_reserve_transfer_assets(
t: ParaToParaThroughRelayTest,
) -> DispatchResult {
let Junction::Parachain(para_id) = *t.args.dest.chain_location().last().unwrap() else {
unimplemented!("Destination is not a parachain?")
};

Westend::ext_wrapper(|| {
Dmp::make_parachain_reachable(para_id);
});
<PenpalA as PenpalAPallet>::PolkadotXcm::limited_reserve_transfer_assets(
t.signed_origin,
bx!(t.args.dest.into()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use emulated_integration_tests_common::{
};
use frame_support::traits::fungibles::{Inspect, Mutate};
use polkadot_runtime_common::impls::VersionedLocatableAsset;
use westend_system_emulated_network::westend_emulated_chain::westend_runtime::Dmp;
use xcm_executor::traits::ConvertLocation;

#[test]
Expand Down Expand Up @@ -58,6 +59,8 @@ fn create_and_claim_treasury_spend() {
// create a conversion rate from `asset_kind` to the native currency.
assert_ok!(AssetRate::create(root.clone(), Box::new(asset_kind.clone()), 2.into()));

Dmp::make_parachain_reachable(1000);

// create and approve a treasury spend.
assert_ok!(Treasury::spend(
root,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use rococo_system_emulated_network::rococo_emulated_chain::rococo_runtime::Dmp;

use crate::tests::*;

#[test]
Expand All @@ -38,6 +40,8 @@ fn send_xcm_from_rococo_relay_to_westend_asset_hub_should_fail_on_not_applicable
// Rococo Global Consensus
// Send XCM message from Relay Chain to Bridge Hub source Parachain
Rococo::execute_with(|| {
Dmp::make_parachain_reachable(BridgeHubRococo::para_id());

assert_ok!(<Rococo as RococoPallet>::XcmPallet::send(
sudo_origin,
bx!(destination),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use rococo_westend_system_emulated_network::westend_emulated_chain::westend_runtime::Dmp;

use crate::tests::*;

#[test]
Expand All @@ -38,6 +40,8 @@ fn send_xcm_from_westend_relay_to_rococo_asset_hub_should_fail_on_not_applicable
// Westend Global Consensus
// Send XCM message from Relay Chain to Bridge Hub source Parachain
Westend::execute_with(|| {
Dmp::make_parachain_reachable(BridgeHubWestend::para_id());

assert_ok!(<Westend as WestendPallet>::XcmPallet::send(
sudo_origin,
bx!(destination),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use frame_support::{
};
use polkadot_runtime_common::impls::VersionedLocatableAsset;
use westend_runtime_constants::currency::UNITS;
use westend_system_emulated_network::westend_emulated_chain::westend_runtime::Dmp;
use xcm_executor::traits::ConvertLocation;

// Fund Fellowship Treasury from Westend Treasury and spend from Fellowship Treasury.
Expand Down Expand Up @@ -57,6 +58,8 @@ fn fellowship_treasury_spend() {
treasury_balance * 2,
));

Dmp::make_parachain_reachable(1000);

let native_asset = Location::here();
let asset_hub_location: Location = [Parachain(1000)].into();
let treasury_location: Location = (Parent, PalletInstance(37)).into();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use crate::imports::*;
use frame_support::traits::OnInitialize;
use pallet_broker::{ConfigRecord, Configuration, CoreAssignment, CoreMask, ScheduleItem};
use rococo_runtime_constants::system_parachain::coretime::TIMESLICE_PERIOD;
use rococo_system_emulated_network::rococo_emulated_chain::rococo_runtime::Dmp;
use sp_runtime::Perbill;

#[test]
Expand All @@ -34,6 +35,10 @@ fn transact_hardcoded_weights_are_sane() {
type CoretimeEvent = <CoretimeRococo as Chain>::RuntimeEvent;
type RelayEvent = <Rococo as Chain>::RuntimeEvent;

Rococo::execute_with(|| {
Dmp::make_parachain_reachable(CoretimeRococo::para_id());
});

// Reserve a workload, configure broker and start sales.
CoretimeRococo::execute_with(|| {
// Hooks don't run in emulated tests - workaround as we need `on_initialize` to tick things
Expand Down
Loading
Loading