From 5a3d95914d41f33d2eccb3856d358c90d2288c28 Mon Sep 17 00:00:00 2001 From: R0GUE Date: Tue, 5 Mar 2024 20:42:38 +0700 Subject: [PATCH 01/23] feat: XCM emulator --- Cargo.toml | 2 +- emulated-integration-tests/Cargo.toml | 61 ++ .../src/chains/asset_hub_rococo/genesis.rs | 70 +++ .../src/chains/asset_hub_rococo/mod.rs | 59 ++ emulated-integration-tests/src/chains/mod.rs | 3 + .../src/chains/pop_network/genesis.rs | 55 ++ .../src/chains/pop_network/mod.rs | 42 ++ .../src/chains/rococo/genesis.rs | 82 +++ .../src/chains/rococo/mod.rs | 50 ++ emulated-integration-tests/src/lib.rs | 51 ++ .../src/rococo_network.rs | 25 + .../src/tests/asset_hub_rococo.rs | 550 ++++++++++++++++++ emulated-integration-tests/src/tests/mod.rs | 1 + 13 files changed, 1050 insertions(+), 1 deletion(-) create mode 100644 emulated-integration-tests/Cargo.toml create mode 100644 emulated-integration-tests/src/chains/asset_hub_rococo/genesis.rs create mode 100644 emulated-integration-tests/src/chains/asset_hub_rococo/mod.rs create mode 100644 emulated-integration-tests/src/chains/mod.rs create mode 100644 emulated-integration-tests/src/chains/pop_network/genesis.rs create mode 100644 emulated-integration-tests/src/chains/pop_network/mod.rs create mode 100644 emulated-integration-tests/src/chains/rococo/genesis.rs create mode 100644 emulated-integration-tests/src/chains/rococo/mod.rs create mode 100644 emulated-integration-tests/src/lib.rs create mode 100644 emulated-integration-tests/src/rococo_network.rs create mode 100644 emulated-integration-tests/src/tests/asset_hub_rococo.rs create mode 100644 emulated-integration-tests/src/tests/mod.rs diff --git a/Cargo.toml b/Cargo.toml index 1aa869717..b37fdab7a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ repository = "https://github.com/r0gue-io/pop-node/" [workspace] members = [ "node", - "runtime", + "runtime", "emulated-integration-tests", "pop-api", ] exclude = [ diff --git a/emulated-integration-tests/Cargo.toml b/emulated-integration-tests/Cargo.toml new file mode 100644 index 000000000..918d87038 --- /dev/null +++ b/emulated-integration-tests/Cargo.toml @@ -0,0 +1,61 @@ +[package] +name = "emulated-integration-tests" +version = "0.1.0" +authors.workspace = true +edition.workspace = true +homepage.workspace = true +license.workspace = true +repository.workspace = true + +[dependencies] +codec = { workspace = true } +assert_matches = "1.5.0" + + +# Substrate +frame-support = { workspace = true } +pallet-assets = { workspace = true } +pallet-balances = { workspace = true } +pallet-message-queue = { workspace = true } +sp-core = { workspace = true } +sp-authority-discovery = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1", default-features = false } +sp-consensus-babe = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1", default-features = false } +sp-consensus-beefy = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1", default-features = false } +sp-consensus-grandpa = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1", default-features = false } +sp-runtime = { workspace = true } + +# Polkadot +polkadot-primitives = { workspace = true } +rococo-runtime-constants = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1" } +rococo-runtime = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1" } +xcm = { workspace = true } +xcm-executor = { workspace = true } + +# Cumulus +asset-hub-rococo-runtime = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1", default-features = false } +asset-test-utils = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1", default-features = false } +cumulus-primitives-core = { workspace = true } +emulated-integration-tests-common = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1", default-features = false } +parachains-common = { workspace = true } + +# Local +pop-runtime = { path = "../runtime", default-features = false } +#testnet-parachains-constants = { workspace = true } + +[features] +default = ["std"] +std = [ + "asset-hub-rococo-runtime/std", + "asset-test-utils/std", + "pallet-assets/std", + "pallet-balances/std", + "pallet-message-queue/std", + "pop-runtime/std", + "rococo-runtime/std", + "rococo-runtime-constants/std", + "sp-authority-discovery/std", + "sp-consensus-babe/std", + "sp-consensus-beefy/std", + "sp-consensus-grandpa/std", +] + diff --git a/emulated-integration-tests/src/chains/asset_hub_rococo/genesis.rs b/emulated-integration-tests/src/chains/asset_hub_rococo/genesis.rs new file mode 100644 index 000000000..fe0a3594c --- /dev/null +++ b/emulated-integration-tests/src/chains/asset_hub_rococo/genesis.rs @@ -0,0 +1,70 @@ +// Copyright (C) Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Substrate +use sp_core::storage::Storage; + +// Cumulus +use emulated_integration_tests_common::{ + accounts, build_genesis_storage, collators, SAFE_XCM_VERSION, +}; +use parachains_common::Balance; + +pub const PARA_ID: u32 = 1000; +pub const ED: Balance = rococo_runtime_constants::currency::EXISTENTIAL_DEPOSIT / 10; + +pub fn genesis() -> Storage { + let genesis_config = asset_hub_rococo_runtime::RuntimeGenesisConfig { + system: asset_hub_rococo_runtime::SystemConfig::default(), + balances: asset_hub_rococo_runtime::BalancesConfig { + balances: accounts::init_balances() + .iter() + .cloned() + .map(|k| (k, ED * 4096 * 4096)) + .collect(), + }, + parachain_info: asset_hub_rococo_runtime::ParachainInfoConfig { + parachain_id: PARA_ID.into(), + ..Default::default() + }, + collator_selection: asset_hub_rococo_runtime::CollatorSelectionConfig { + invulnerables: collators::invulnerables().iter().cloned().map(|(acc, _)| acc).collect(), + candidacy_bond: ED * 16, + ..Default::default() + }, + session: asset_hub_rococo_runtime::SessionConfig { + keys: collators::invulnerables() + .into_iter() + .map(|(acc, aura)| { + ( + acc.clone(), // account id + acc, // validator id + asset_hub_rococo_runtime::SessionKeys { aura }, // session keys + ) + }) + .collect(), + }, + polkadot_xcm: asset_hub_rococo_runtime::PolkadotXcmConfig { + safe_xcm_version: Some(SAFE_XCM_VERSION), + ..Default::default() + }, + ..Default::default() + }; + + build_genesis_storage( + &genesis_config, + asset_hub_rococo_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"), + ) +} diff --git a/emulated-integration-tests/src/chains/asset_hub_rococo/mod.rs b/emulated-integration-tests/src/chains/asset_hub_rococo/mod.rs new file mode 100644 index 000000000..54d2c7bd2 --- /dev/null +++ b/emulated-integration-tests/src/chains/asset_hub_rococo/mod.rs @@ -0,0 +1,59 @@ +// Copyright (C) Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +pub mod genesis; + +// Substrate +use frame_support::traits::OnInitialize; + +// Cumulus +use crate::chains::rococo::Rococo; +use emulated_integration_tests_common::{ + impl_accounts_helpers_for_parachain, impl_assert_events_helpers_for_parachain, + impl_assets_helpers_for_parachain, impl_foreign_assets_helpers_for_parachain, + impl_xcm_helpers_for_parachain, impls::Parachain, xcm_emulator::decl_test_parachains, +}; + +// AssetHubRococo Parachain declaration +decl_test_parachains! { + pub struct AssetHubRococo { + genesis = genesis::genesis(), + on_init = { + asset_hub_rococo_runtime::AuraExt::on_initialize(1); + }, + runtime = asset_hub_rococo_runtime, + core = { + XcmpMessageHandler: asset_hub_rococo_runtime::XcmpQueue, + LocationToAccountId: asset_hub_rococo_runtime::xcm_config::LocationToAccountId, + ParachainInfo: asset_hub_rococo_runtime::ParachainInfo, + MessageOrigin: cumulus_primitives_core::AggregateMessageOrigin, + }, + pallets = { + PolkadotXcm: asset_hub_rococo_runtime::PolkadotXcm, + Assets: asset_hub_rococo_runtime::Assets, + ForeignAssets: asset_hub_rococo_runtime::ForeignAssets, + PoolAssets: asset_hub_rococo_runtime::PoolAssets, + AssetConversion: asset_hub_rococo_runtime::AssetConversion, + Balances: asset_hub_rococo_runtime::Balances, + } + }, +} + +// AssetHubRococo implementation +impl_accounts_helpers_for_parachain!(AssetHubRococo); +impl_assert_events_helpers_for_parachain!(AssetHubRococo); +impl_assets_helpers_for_parachain!(AssetHubRococo, Rococo); +impl_foreign_assets_helpers_for_parachain!(AssetHubRococo, Rococo); +impl_xcm_helpers_for_parachain!(AssetHubRococo); diff --git a/emulated-integration-tests/src/chains/mod.rs b/emulated-integration-tests/src/chains/mod.rs new file mode 100644 index 000000000..6fdeae2f2 --- /dev/null +++ b/emulated-integration-tests/src/chains/mod.rs @@ -0,0 +1,3 @@ +pub mod asset_hub_rococo; +pub mod pop_network; +pub mod rococo; diff --git a/emulated-integration-tests/src/chains/pop_network/genesis.rs b/emulated-integration-tests/src/chains/pop_network/genesis.rs new file mode 100644 index 000000000..03bd98784 --- /dev/null +++ b/emulated-integration-tests/src/chains/pop_network/genesis.rs @@ -0,0 +1,55 @@ +// Substrate +use sp_core::storage::Storage; + +// Cumulus +use emulated_integration_tests_common::{ + accounts, build_genesis_storage, collators, SAFE_XCM_VERSION, +}; +use parachains_common::Balance; + +pub const PARA_ID: u32 = 909; +pub const ED: Balance = rococo_runtime_constants::currency::EXISTENTIAL_DEPOSIT / 10; + +pub fn genesis() -> Storage { + let genesis_config = pop_runtime::RuntimeGenesisConfig { + system: pop_runtime::SystemConfig::default(), + balances: pop_runtime::BalancesConfig { + balances: accounts::init_balances() + .iter() + .cloned() + .map(|k| (k, ED * 4096 * 4096)) + .collect(), + }, + parachain_info: pop_runtime::ParachainInfoConfig { + parachain_id: PARA_ID.into(), + ..Default::default() + }, + collator_selection: pop_runtime::CollatorSelectionConfig { + invulnerables: collators::invulnerables().iter().cloned().map(|(acc, _)| acc).collect(), + candidacy_bond: ED * 16, + ..Default::default() + }, + session: pop_runtime::SessionConfig { + keys: collators::invulnerables() + .into_iter() + .map(|(acc, aura)| { + ( + acc.clone(), // account id + acc, // validator id + pop_runtime::SessionKeys { aura }, // session keys + ) + }) + .collect(), + }, + polkadot_xcm: pop_runtime::PolkadotXcmConfig { + safe_xcm_version: Some(SAFE_XCM_VERSION), + ..Default::default() + }, + ..Default::default() + }; + + build_genesis_storage( + &genesis_config, + pop_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"), + ) +} diff --git a/emulated-integration-tests/src/chains/pop_network/mod.rs b/emulated-integration-tests/src/chains/pop_network/mod.rs new file mode 100644 index 000000000..c72f3eac0 --- /dev/null +++ b/emulated-integration-tests/src/chains/pop_network/mod.rs @@ -0,0 +1,42 @@ +pub mod genesis; + +// Substrate +use frame_support::traits::OnInitialize; + +// Cumulus +use crate::chains::rococo::Rococo; +use emulated_integration_tests_common::{ + impl_accounts_helpers_for_parachain, impl_assert_events_helpers_for_parachain, + impl_assets_helpers_for_parachain, impl_xcm_helpers_for_parachain, impls::Parachain, + xcm_emulator::decl_test_parachains, +}; + +// PopNetwork Parachain declaration +decl_test_parachains! { + pub struct PopNetwork { + genesis = genesis::genesis(), + on_init = { + pop_runtime::AuraExt::on_initialize(1); + }, + runtime = pop_runtime, + core = { + XcmpMessageHandler: pop_runtime::XcmpQueue, + LocationToAccountId: pop_runtime::xcm_config::LocationToAccountId, + ParachainInfo: pop_runtime::ParachainInfo, + MessageOrigin: cumulus_primitives_core::AggregateMessageOrigin, + }, + pallets = { + PolkadotXcm: pop_runtime::PolkadotXcm, + Assets: pop_runtime::Assets, + Balances: pop_runtime::Balances, + Nfts: pop_runtime::Nfts, + } + }, +} + +// PopNetwork implementation +impl_accounts_helpers_for_parachain!(PopNetwork); +impl_assert_events_helpers_for_parachain!(PopNetwork); +impl_assets_helpers_for_parachain!(PopNetwork, Rococo); +// impl_foreign_assets_helpers_for_parachain!(PopNetwork, Rococo); +impl_xcm_helpers_for_parachain!(PopNetwork); diff --git a/emulated-integration-tests/src/chains/rococo/genesis.rs b/emulated-integration-tests/src/chains/rococo/genesis.rs new file mode 100644 index 000000000..6ed4f5e3d --- /dev/null +++ b/emulated-integration-tests/src/chains/rococo/genesis.rs @@ -0,0 +1,82 @@ +// Substrate +use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId; +use sp_consensus_babe::AuthorityId as BabeId; +use sp_consensus_beefy::ecdsa_crypto::AuthorityId as BeefyId; +use sp_consensus_grandpa::AuthorityId as GrandpaId; +use sp_core::{sr25519, storage::Storage}; + +// Polkadot +use polkadot_primitives::{AssignmentId, ValidatorId}; + +// Cumulus +use emulated_integration_tests_common::{ + accounts, build_genesis_storage, get_account_id_from_seed, get_from_seed, get_host_config, + validators, +}; +use parachains_common::Balance; +use rococo_runtime_constants::currency::UNITS as ROC; + +pub const ED: Balance = rococo_runtime_constants::currency::EXISTENTIAL_DEPOSIT; +const ENDOWMENT: u128 = 1_000_000 * ROC; + +fn session_keys( + babe: BabeId, + grandpa: GrandpaId, + para_validator: ValidatorId, + para_assignment: AssignmentId, + authority_discovery: AuthorityDiscoveryId, + beefy: BeefyId, +) -> rococo_runtime::SessionKeys { + rococo_runtime::SessionKeys { + babe, + grandpa, + para_validator, + para_assignment, + authority_discovery, + beefy, + } +} + +pub fn genesis() -> Storage { + let genesis_config = rococo_runtime::RuntimeGenesisConfig { + system: rococo_runtime::SystemConfig::default(), + balances: rococo_runtime::BalancesConfig { + balances: accounts::init_balances().iter().map(|k| (k.clone(), ENDOWMENT)).collect(), + }, + session: rococo_runtime::SessionConfig { + keys: validators::initial_authorities() + .iter() + .map(|x| { + ( + x.0.clone(), + x.0.clone(), + session_keys( + x.2.clone(), + x.3.clone(), + x.4.clone(), + x.5.clone(), + x.6.clone(), + get_from_seed::("Alice"), + ), + ) + }) + .collect::>(), + }, + babe: rococo_runtime::BabeConfig { + authorities: Default::default(), + epoch_config: Some(rococo_runtime::BABE_GENESIS_EPOCH_CONFIG), + ..Default::default() + }, + sudo: rococo_runtime::SudoConfig { + key: Some(get_account_id_from_seed::("Alice")), + }, + configuration: rococo_runtime::ConfigurationConfig { config: get_host_config() }, + registrar: rococo_runtime::RegistrarConfig { + next_free_para_id: polkadot_primitives::LOWEST_PUBLIC_ID, + ..Default::default() + }, + ..Default::default() + }; + + build_genesis_storage(&genesis_config, rococo_runtime::WASM_BINARY.unwrap()) +} diff --git a/emulated-integration-tests/src/chains/rococo/mod.rs b/emulated-integration-tests/src/chains/rococo/mod.rs new file mode 100644 index 000000000..e0d373021 --- /dev/null +++ b/emulated-integration-tests/src/chains/rococo/mod.rs @@ -0,0 +1,50 @@ +// Copyright (C) Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +pub mod genesis; + +// Cumulus +use emulated_integration_tests_common::{ + impl_accounts_helpers_for_relay_chain, impl_assert_events_helpers_for_relay_chain, + impl_hrmp_channels_helpers_for_relay_chain, impl_send_transact_helpers_for_relay_chain, + xcm_emulator::decl_test_relay_chains, +}; + +// Rococo declaration +decl_test_relay_chains! { + #[api_version(10)] + pub struct Rococo { + genesis = genesis::genesis(), + on_init = (), + runtime = rococo_runtime, + core = { + SovereignAccountOf: rococo_runtime::xcm_config::LocationConverter, + }, + pallets = { + XcmPallet: rococo_runtime::XcmPallet, + Sudo: rococo_runtime::Sudo, + Balances: rococo_runtime::Balances, + Hrmp: rococo_runtime::Hrmp, + Identity: rococo_runtime::Identity, + IdentityMigrator: rococo_runtime::IdentityMigrator, + } + }, +} + +// Rococo implementation +impl_accounts_helpers_for_relay_chain!(Rococo); +impl_assert_events_helpers_for_relay_chain!(Rococo); +impl_hrmp_channels_helpers_for_relay_chain!(Rococo); +impl_send_transact_helpers_for_relay_chain!(Rococo); diff --git a/emulated-integration-tests/src/lib.rs b/emulated-integration-tests/src/lib.rs new file mode 100644 index 000000000..0cde546b5 --- /dev/null +++ b/emulated-integration-tests/src/lib.rs @@ -0,0 +1,51 @@ +mod chains; +mod rococo_network; + +pub use codec::Encode; + +// Substrate +pub use frame_support::{ + assert_err, assert_ok, + pallet_prelude::Weight, + sp_runtime::{AccountId32, DispatchError, DispatchResult}, + traits::fungibles::Inspect, +}; + +// Polkadot +pub use xcm::{ + prelude::{AccountId32 as AccountId32Junction, *}, + v3::{self, Error, NetworkId::Rococo as RococoId}, +}; + +// Cumulus +pub use crate::rococo_network::{ + asset_hub_rococo::{ + genesis::ED as ASSET_HUB_ROCOCO_ED, AssetHubRococoParaPallet as AssetHubRococoPallet, + }, + rococo::{genesis::ED as ROCOCO_ED, RococoRelayPallet as RococoPallet}, + AssetHubRococoPara as AssetHubRococo, AssetHubRococoParaReceiver as AssetHubRococoReceiver, + AssetHubRococoParaSender as AssetHubRococoSender, RococoRelay as Rococo, + RococoRelayReceiver as RococoReceiver, RococoRelaySender as RococoSender, +}; +pub use asset_test_utils::xcm_helpers; +pub use emulated_integration_tests_common::{ + test_parachain_is_trusted_teleporter, + xcm_emulator::{ + assert_expected_events, bx, helpers::weight_within_threshold, Chain, Parachain as Para, + RelayChain as Relay, Test, TestArgs, TestContext, TestExt, + }, + xcm_helpers::{xcm_transact_paid_execution, xcm_transact_unpaid_execution}, + PROOF_SIZE_THRESHOLD, REF_TIME_THRESHOLD, XCM_V3, +}; +pub use parachains_common::{AccountId, Balance}; + +pub const ASSET_ID: u32 = 1; +pub const ASSET_MIN_BALANCE: u128 = 1000; +// `Assets` pallet index +pub const ASSETS_PALLET_ID: u8 = 50; + +pub type RelayToSystemParaTest = Test; +pub type SystemParaToRelayTest = Test; + +#[cfg(test)] +mod tests; diff --git a/emulated-integration-tests/src/rococo_network.rs b/emulated-integration-tests/src/rococo_network.rs new file mode 100644 index 000000000..a0d90b3ed --- /dev/null +++ b/emulated-integration-tests/src/rococo_network.rs @@ -0,0 +1,25 @@ +pub use crate::chains::{asset_hub_rococo, pop_network, rococo}; +use crate::chains::{asset_hub_rococo::AssetHubRococo, pop_network::PopNetwork, rococo::Rococo}; + +// Cumulus +use emulated_integration_tests_common::{ + accounts::{ALICE, BOB}, + xcm_emulator::{decl_test_networks, decl_test_sender_receiver_accounts_parameter_types}, +}; + +decl_test_networks! { + pub struct RococoMockNet { + relay_chain = Rococo, + parachains = vec![ + AssetHubRococo, + PopNetwork, + ], + bridge = () + }, +} + +decl_test_sender_receiver_accounts_parameter_types! { + RococoRelay { sender: ALICE, receiver: BOB }, + AssetHubRococoPara { sender: ALICE, receiver: BOB }, + PopNetworkPara { sender: ALICE, receiver: BOB} +} diff --git a/emulated-integration-tests/src/tests/asset_hub_rococo.rs b/emulated-integration-tests/src/tests/asset_hub_rococo.rs new file mode 100644 index 000000000..5512e5d39 --- /dev/null +++ b/emulated-integration-tests/src/tests/asset_hub_rococo.rs @@ -0,0 +1,550 @@ +// Substrate +pub use frame_support::{ + assert_err, + pallet_prelude::Weight, + sp_runtime::{DispatchError, DispatchResult}, + traits::fungibles::Inspect, +}; + +// Polkadot +pub use xcm::prelude::{AccountId32 as AccountId32Junction, *}; + +// Cumulus +pub use crate::rococo_network::{ + asset_hub_rococo::{ + genesis::ED as ASSET_HUB_ROCOCO_ED, AssetHubRococoParaPallet as AssetHubRococoPallet, + }, + pop_network::PopNetworkParaPallet as PopNetworkPallet, + rococo::{genesis::ED as ROCOCO_ED, RococoRelayPallet as RococoPallet}, + AssetHubRococoPara as AssetHubRococo, AssetHubRococoParaReceiver as AssetHubRococoReceiver, + AssetHubRococoParaSender as AssetHubRococoSender, PopNetworkPara as PopNetwork, + PopNetworkParaReceiver as PopNetworkReceiver, PopNetworkParaSender as PopNetworkSender, + RococoRelay as Rococo, RococoRelayReceiver as RococoReceiver, + RococoRelaySender as RococoSender, +}; +pub use asset_test_utils::xcm_helpers; +pub use emulated_integration_tests_common::xcm_emulator::{ + assert_expected_events, bx, Chain, Parachain as Para, RelayChain as Relay, Test, TestArgs, + TestContext, TestExt, +}; +pub use parachains_common::Balance; + +pub const ASSET_ID: u32 = 1; +pub const ASSET_MIN_BALANCE: u128 = 1000; +// `Assets` pallet index +pub const ASSETS_PALLET_ID: u8 = 50; + +pub type RelayToParaTest = Test; +pub type SystemParaToParaTest = Test; +pub type ParaToSystemParaTest = Test; + +#[cfg(test)] +mod tests { + use super::*; + + use asset_hub_rococo_runtime::xcm_config::XcmConfig as AssetHubRococoXcmConfig; + use pop_runtime::xcm_config::XcmConfig as PopNetworkXcmConfig; + use rococo_runtime::xcm_config::XcmConfig as RococoXcmConfig; + + fn relay_to_para_sender_assertions(t: RelayToParaTest) { + type RuntimeEvent = ::RuntimeEvent; + Rococo::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts(864_610_000, 8_799))); + assert_expected_events!( + Rococo, + vec![ + // Amount to reserve transfer is transferred to Parachain's Sovereign account + RuntimeEvent::Balances( + pallet_balances::Event::Transfer { from, to, amount } + ) => { + from: *from == t.sender.account_id, + to: *to == Rococo::sovereign_account_id_of( + t.args.dest.clone() + ), + amount: *amount == t.args.amount, + }, + ] + ); + } + + fn system_para_to_para_sender_assertions(t: SystemParaToParaTest) { + type RuntimeEvent = ::RuntimeEvent; + AssetHubRococo::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts( + 864_610_000, + 8_799, + ))); + assert_expected_events!( + AssetHubRococo, + vec![ + // Amount to reserve transfer is transferred to Parachain's Sovereign account + RuntimeEvent::Balances( + pallet_balances::Event::Transfer { from, to, amount } + ) => { + from: *from == t.sender.account_id, + to: *to == AssetHubRococo::sovereign_account_id_of( + t.args.dest.clone() + ), + amount: *amount == t.args.amount, + }, + ] + ); + } + + fn para_receiver_assertions(_: Test) { + type RuntimeEvent = ::RuntimeEvent; + assert_expected_events!( + PopNetwork, + vec![ + RuntimeEvent::Balances(pallet_balances::Event::Deposit { .. }) => {}, + RuntimeEvent::MessageQueue( + pallet_message_queue::Event::Processed { success: true, .. } + ) => {}, + ] + ); + } + + fn para_to_system_para_sender_assertions(t: ParaToSystemParaTest) { + type RuntimeEvent = ::RuntimeEvent; + PopNetwork::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts( + 864_610_000, + 8_799, + ))); + assert_expected_events!( + PopNetwork, + vec![ + // Amount to reserve transfer is transferred to Parachain's Sovereign account + RuntimeEvent::Balances( + pallet_balances::Event::Withdraw { who, amount } + ) => { + who: *who == t.sender.account_id, + amount: *amount == t.args.amount, + }, + ] + ); + } + + fn para_to_system_para_receiver_assertions(t: ParaToSystemParaTest) { + type RuntimeEvent = ::RuntimeEvent; + let sov_pop_net_on_ahr = AssetHubRococo::sovereign_account_id_of( + AssetHubRococo::sibling_location_of(PopNetwork::para_id()), + ); + assert_expected_events!( + AssetHubRococo, + vec![ + // Amount to reserve transfer is withdrawn from Parachain's Sovereign account + RuntimeEvent::Balances( + pallet_balances::Event::Withdraw { who, amount } + ) => { + who: *who == sov_pop_net_on_ahr.clone().into(), + amount: *amount == t.args.amount, + }, + RuntimeEvent::Balances(pallet_balances::Event::Deposit { .. }) => {}, + RuntimeEvent::MessageQueue( + pallet_message_queue::Event::Processed { success: true, .. } + ) => {}, + ] + ); + } + + fn system_para_to_para_assets_sender_assertions(t: SystemParaToParaTest) { + type RuntimeEvent = ::RuntimeEvent; + AssetHubRococo::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts( + 864_610_000, + 8799, + ))); + assert_expected_events!( + AssetHubRococo, + vec![ + // Amount to reserve transfer is transferred to Parachain's Sovereign account + RuntimeEvent::Assets( + pallet_assets::Event::Transferred { asset_id, from, to, amount } + ) => { + asset_id: *asset_id == ASSET_ID, + from: *from == t.sender.account_id, + to: *to == AssetHubRococo::sovereign_account_id_of( + t.args.dest.clone() + ), + amount: *amount == t.args.amount, + }, + ] + ); + } + + fn system_para_to_para_assets_receiver_assertions(_: Test) { + type RuntimeEvent = ::RuntimeEvent; + assert_expected_events!( + PopNetwork, + vec![ + RuntimeEvent::Balances(pallet_balances::Event::Deposit { .. }) => {}, + RuntimeEvent::Assets(pallet_assets::Event::Issued { .. }) => {}, + RuntimeEvent::MessageQueue( + pallet_message_queue::Event::Processed { success: true, .. } + ) => {}, + ] + ); + } + + fn relay_to_para_reserve_transfer_assets(t: RelayToParaTest) -> DispatchResult { + ::XcmPallet::limited_reserve_transfer_assets( + t.signed_origin, + bx!(t.args.dest.into()), + bx!(t.args.beneficiary.into()), + bx!(t.args.assets.into()), + t.args.fee_asset_item, + t.args.weight_limit, + ) + } + + fn system_para_to_para_reserve_transfer_assets(t: SystemParaToParaTest) -> DispatchResult { + ::PolkadotXcm::limited_reserve_transfer_assets( + t.signed_origin, + bx!(t.args.dest.into()), + bx!(t.args.beneficiary.into()), + bx!(t.args.assets.into()), + t.args.fee_asset_item, + t.args.weight_limit, + ) + } + + fn para_to_system_para_reserve_transfer_assets(t: ParaToSystemParaTest) -> DispatchResult { + ::PolkadotXcm::limited_reserve_transfer_assets( + t.signed_origin, + bx!(t.args.dest.into()), + bx!(t.args.beneficiary.into()), + bx!(t.args.assets.into()), + t.args.fee_asset_item, + t.args.weight_limit, + ) + } + + /// Reserve Transfers of native asset from Relay Chain to the System Parachain shouldn't work + #[test] + fn reserve_transfer_native_asset_from_relay_to_system_para_fails() { + let signed_origin = ::RuntimeOrigin::signed(RococoSender::get().into()); + let destination = Rococo::child_location_of(AssetHubRococo::para_id()); + let beneficiary: Location = + AccountId32Junction { network: None, id: AssetHubRococoReceiver::get().into() }.into(); + let amount_to_send: Balance = ROCOCO_ED * 1000; + let assets: Assets = (Here, amount_to_send).into(); + let fee_asset_item = 0; + + // this should fail + Rococo::execute_with(|| { + let result = ::XcmPallet::limited_reserve_transfer_assets( + signed_origin, + bx!(destination.into()), + bx!(beneficiary.into()), + bx!(assets.into()), + fee_asset_item, + WeightLimit::Unlimited, + ); + assert_err!( + result, + DispatchError::Module(sp_runtime::ModuleError { + index: 99, + error: [2, 0, 0, 0], + message: Some("Filtered") + }) + ); + }); + } + + /// Reserve Transfers of native asset from System Parachain to Relay Chain shouldn't work + #[test] + fn reserve_transfer_native_asset_from_system_para_to_relay_fails() { + // Init values for System Parachain + let signed_origin = + ::RuntimeOrigin::signed(AssetHubRococoSender::get().into()); + let destination = AssetHubRococo::parent_location(); + let beneficiary_id = RococoReceiver::get(); + let beneficiary: Location = + AccountId32Junction { network: None, id: beneficiary_id.into() }.into(); + let amount_to_send: Balance = ASSET_HUB_ROCOCO_ED * 1000; + + let assets: Assets = (Parent, amount_to_send).into(); + let fee_asset_item = 0; + + // this should fail + AssetHubRococo::execute_with(|| { + let result = + ::PolkadotXcm::limited_reserve_transfer_assets( + signed_origin, + bx!(destination.into()), + bx!(beneficiary.into()), + bx!(assets.into()), + fee_asset_item, + WeightLimit::Unlimited, + ); + assert_err!( + result, + DispatchError::Module(sp_runtime::ModuleError { + index: 31, + error: [2, 0, 0, 0], + message: Some("Filtered") + }) + ); + }); + } + + /// Reserve Transfers of native asset from Relay to Parachain should work + #[test] + fn reserve_transfer_native_asset_from_relay_to_para() { + // Init values for Relay + let destination = Rococo::child_location_of(PopNetwork::para_id()); + let beneficiary_id = PopNetworkReceiver::get(); + let amount_to_send: Balance = ROCOCO_ED * 1000; + + let test_args = TestContext { + sender: RococoSender::get(), + receiver: PopNetworkReceiver::get(), + args: TestArgs::new_relay(destination, beneficiary_id, amount_to_send), + }; + + let mut test = RelayToParaTest::new(test_args); + + let sender_balance_before = test.sender.balance; + let receiver_balance_before = test.receiver.balance; + + test.set_assertion::(relay_to_para_sender_assertions); + test.set_assertion::(para_receiver_assertions); + test.set_dispatchable::(relay_to_para_reserve_transfer_assets); + test.assert(); + + let delivery_fees = Rococo::execute_with(|| { + xcm_helpers::transfer_assets_delivery_fees::< + ::XcmSender, + >( + test.args.assets.clone(), + 0, + test.args.weight_limit, + test.args.beneficiary, + test.args.dest, + ) + }); + + let sender_balance_after = test.sender.balance; + let receiver_balance_after = test.receiver.balance; + + // Sender's balance is reduced + assert_eq!(sender_balance_before - amount_to_send - delivery_fees, sender_balance_after); + // Receiver's balance is increased + assert!(receiver_balance_after > receiver_balance_before); + // Receiver's balance increased by `amount_to_send - delivery_fees - bought_execution`; + // `delivery_fees` might be paid from transfer or JIT, also `bought_execution` is unknown + // but should be non-zero + assert!(receiver_balance_after < receiver_balance_before + amount_to_send); + } + + /// Reserve Transfers of native asset from System Parachain to Parachain should work + #[test] + fn reserve_transfer_native_asset_from_system_para_to_para() { + // Init values for System Parachain + let destination = AssetHubRococo::sibling_location_of(PopNetwork::para_id()); + let beneficiary_id = PopNetworkReceiver::get(); + let amount_to_send: Balance = ASSET_HUB_ROCOCO_ED * 1000; + let assets = (Parent, amount_to_send).into(); + + let test_args = TestContext { + sender: AssetHubRococoSender::get(), + receiver: PopNetworkReceiver::get(), + args: TestArgs::new_para(destination, beneficiary_id, amount_to_send, assets, None, 0), + }; + + let mut test = SystemParaToParaTest::new(test_args); + + let sender_balance_before = test.sender.balance; + let receiver_balance_before = test.receiver.balance; + + test.set_assertion::(system_para_to_para_sender_assertions); + test.set_assertion::(para_receiver_assertions); + test.set_dispatchable::(system_para_to_para_reserve_transfer_assets); + test.assert(); + + let sender_balance_after = test.sender.balance; + let receiver_balance_after = test.receiver.balance; + + let delivery_fees = AssetHubRococo::execute_with(|| { + xcm_helpers::transfer_assets_delivery_fees::< + ::XcmSender, + >( + test.args.assets.clone(), + 0, + test.args.weight_limit, + test.args.beneficiary, + test.args.dest, + ) + }); + + // Sender's balance is reduced + assert_eq!(sender_balance_before - amount_to_send - delivery_fees, sender_balance_after); + // Receiver's balance is increased + assert!(receiver_balance_after > receiver_balance_before); + // Receiver's balance increased by `amount_to_send - delivery_fees - bought_execution`; + // `delivery_fees` might be paid from transfer or JIT, also `bought_execution` is unknown + // but should be non-zero + assert!(receiver_balance_after < receiver_balance_before + amount_to_send); + } + + /// Reserve Transfers of native asset from Parachain to System Parachain should work + #[test] + fn reserve_transfer_native_asset_from_para_to_system_para() { + // Init values for Pop Network Parachain + let destination = PopNetwork::sibling_location_of(AssetHubRococo::para_id()); + let beneficiary_id = AssetHubRococoReceiver::get(); + let amount_to_send: Balance = ASSET_HUB_ROCOCO_ED * 1000; + let assets = (Parent, amount_to_send).into(); + + let test_args = TestContext { + sender: PopNetworkSender::get(), + receiver: AssetHubRococoReceiver::get(), + args: TestArgs::new_para(destination, beneficiary_id, amount_to_send, assets, None, 0), + }; + + let mut test = ParaToSystemParaTest::new(test_args); + + let sender_balance_before = test.sender.balance; + let receiver_balance_before = test.receiver.balance; + + let pop_net_location_as_seen_by_ahr = + AssetHubRococo::sibling_location_of(PopNetwork::para_id()); + let sov_pop_net_on_ahr = + AssetHubRococo::sovereign_account_id_of(pop_net_location_as_seen_by_ahr); + + // fund the Pop Network's SA on AHR with the native tokens held in reserve + AssetHubRococo::fund_accounts(vec![(sov_pop_net_on_ahr.into(), amount_to_send * 2)]); + + test.set_assertion::(para_to_system_para_sender_assertions); + test.set_assertion::(para_to_system_para_receiver_assertions); + test.set_dispatchable::(para_to_system_para_reserve_transfer_assets); + test.assert(); + + let sender_balance_after = test.sender.balance; + let receiver_balance_after = test.receiver.balance; + + let delivery_fees = PopNetwork::execute_with(|| { + xcm_helpers::transfer_assets_delivery_fees::< + ::XcmSender, + >( + test.args.assets.clone(), + 0, + test.args.weight_limit, + test.args.beneficiary, + test.args.dest, + ) + }); + + // Sender's balance is reduced + assert_eq!(sender_balance_before - amount_to_send - delivery_fees, sender_balance_after); + // Receiver's balance is increased + assert!(receiver_balance_after > receiver_balance_before); + // Receiver's balance increased by `amount_to_send - delivery_fees - bought_execution`; + // `delivery_fees` might be paid from transfer or JIT, also `bought_execution` is unknown + // but should be non-zero + assert!(receiver_balance_after < receiver_balance_before + amount_to_send); + } + + /// Reserve Transfers of a local asset and native asset from System Parachain to Parachain + /// should work + #[test] + fn reserve_transfer_assets_from_system_para_to_para() { + // Force create asset on AssetHubRococo and PopNetwork from Relay Chain + AssetHubRococo::force_create_and_mint_asset( + ASSET_ID, + ASSET_MIN_BALANCE, + false, + AssetHubRococoSender::get(), + Some(Weight::from_parts(1_019_445_000, 200_000)), + ASSET_MIN_BALANCE * 1_000_000, + ); + PopNetwork::force_create_and_mint_asset( + ASSET_ID, + ASSET_MIN_BALANCE, + false, + PopNetworkSender::get(), + None, + 0, + ); + + // Init values for System Parachain + let destination = AssetHubRococo::sibling_location_of(PopNetwork::para_id()); + let beneficiary_id = PopNetworkReceiver::get(); + let fee_amount_to_send = ASSET_HUB_ROCOCO_ED * 1000; + let asset_amount_to_send = ASSET_MIN_BALANCE * 1000; + let assets: Assets = vec![ + (Parent, fee_amount_to_send).into(), + ( + [PalletInstance(ASSETS_PALLET_ID), GeneralIndex(ASSET_ID.into())], + asset_amount_to_send, + ) + .into(), + ] + .into(); + let fee_asset_index = assets + .inner() + .iter() + .position(|r| r == &(Parent, fee_amount_to_send).into()) + .unwrap() as u32; + + let para_test_args = TestContext { + sender: AssetHubRococoSender::get(), + receiver: PopNetworkReceiver::get(), + args: TestArgs::new_para( + destination, + beneficiary_id, + asset_amount_to_send, + assets, + None, + fee_asset_index, + ), + }; + + let mut test = SystemParaToParaTest::new(para_test_args); + + // Create SA-of-Pop Network-on-AHR with ED. + let pop_net_location = AssetHubRococo::sibling_location_of(PopNetwork::para_id()); + let sov_pop_net_on_ahr = AssetHubRococo::sovereign_account_id_of(pop_net_location); + AssetHubRococo::fund_accounts(vec![(sov_pop_net_on_ahr.into(), ROCOCO_ED)]); + + let sender_balance_before = test.sender.balance; + let receiver_balance_before = test.receiver.balance; + + let sender_assets_before = AssetHubRococo::execute_with(|| { + type Assets = ::Assets; + >::balance(ASSET_ID, &AssetHubRococoSender::get()) + }); + let receiver_assets_before = PopNetwork::execute_with(|| { + type Assets = ::Assets; + >::balance(ASSET_ID, &PopNetworkReceiver::get()) + }); + + test.set_assertion::(system_para_to_para_assets_sender_assertions); + test.set_assertion::(system_para_to_para_assets_receiver_assertions); + test.set_dispatchable::(system_para_to_para_reserve_transfer_assets); + test.assert(); + + let sender_balance_after = test.sender.balance; + let receiver_balance_after = test.receiver.balance; + + // Sender's balance is reduced + assert!(sender_balance_after < sender_balance_before); + // Receiver's balance is increased + assert!(receiver_balance_after > receiver_balance_before); + // Receiver's balance increased by `amount_to_send - delivery_fees - bought_execution`; + // `delivery_fees` might be paid from transfer or JIT, also `bought_execution` is unknown + // but should be non-zero + assert!(receiver_balance_after < receiver_balance_before + fee_amount_to_send); + + let sender_assets_after = AssetHubRococo::execute_with(|| { + type Assets = ::Assets; + >::balance(ASSET_ID, &AssetHubRococoSender::get()) + }); + let receiver_assets_after = PopNetwork::execute_with(|| { + type Assets = ::Assets; + >::balance(ASSET_ID, &PopNetworkReceiver::get()) + }); + + // Sender's balance is reduced by exact amount + assert_eq!(sender_assets_before - asset_amount_to_send, sender_assets_after); + // Receiver's balance is increased by exact amount + assert_eq!(receiver_assets_after, receiver_assets_before + asset_amount_to_send); + } +} diff --git a/emulated-integration-tests/src/tests/mod.rs b/emulated-integration-tests/src/tests/mod.rs new file mode 100644 index 000000000..ca06a9771 --- /dev/null +++ b/emulated-integration-tests/src/tests/mod.rs @@ -0,0 +1 @@ +mod asset_hub_rococo; From 189b0eeebbb6cb07b9926f0d213b2be27de6d7fb Mon Sep 17 00:00:00 2001 From: R0GUE Date: Tue, 5 Mar 2024 21:44:25 +0700 Subject: [PATCH 02/23] fmt --- emulated-integration-tests/Cargo.toml | 5 +- .../src/chains/asset_hub_rococo/genesis.rs | 15 - .../src/chains/asset_hub_rococo/mod.rs | 15 - .../src/chains/pop_network/mod.rs | 1 + .../src/chains/rococo/mod.rs | 15 - emulated-integration-tests/src/lib.rs | 546 ++++++++++++++++- .../src/tests/asset_hub_rococo.rs | 550 ------------------ emulated-integration-tests/src/tests/mod.rs | 1 - 8 files changed, 526 insertions(+), 622 deletions(-) delete mode 100644 emulated-integration-tests/src/tests/asset_hub_rococo.rs delete mode 100644 emulated-integration-tests/src/tests/mod.rs diff --git a/emulated-integration-tests/Cargo.toml b/emulated-integration-tests/Cargo.toml index 918d87038..0e5f8fa77 100644 --- a/emulated-integration-tests/Cargo.toml +++ b/emulated-integration-tests/Cargo.toml @@ -9,8 +9,7 @@ repository.workspace = true [dependencies] codec = { workspace = true } -assert_matches = "1.5.0" - +#assert_matches = "1.5.0" # Substrate frame-support = { workspace = true } @@ -40,7 +39,6 @@ parachains-common = { workspace = true } # Local pop-runtime = { path = "../runtime", default-features = false } -#testnet-parachains-constants = { workspace = true } [features] default = ["std"] @@ -58,4 +56,3 @@ std = [ "sp-consensus-beefy/std", "sp-consensus-grandpa/std", ] - diff --git a/emulated-integration-tests/src/chains/asset_hub_rococo/genesis.rs b/emulated-integration-tests/src/chains/asset_hub_rococo/genesis.rs index fe0a3594c..f89fc5e05 100644 --- a/emulated-integration-tests/src/chains/asset_hub_rococo/genesis.rs +++ b/emulated-integration-tests/src/chains/asset_hub_rococo/genesis.rs @@ -1,18 +1,3 @@ -// Copyright (C) Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - // Substrate use sp_core::storage::Storage; diff --git a/emulated-integration-tests/src/chains/asset_hub_rococo/mod.rs b/emulated-integration-tests/src/chains/asset_hub_rococo/mod.rs index 54d2c7bd2..63a5cec3b 100644 --- a/emulated-integration-tests/src/chains/asset_hub_rococo/mod.rs +++ b/emulated-integration-tests/src/chains/asset_hub_rococo/mod.rs @@ -1,18 +1,3 @@ -// Copyright (C) Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - pub mod genesis; // Substrate diff --git a/emulated-integration-tests/src/chains/pop_network/mod.rs b/emulated-integration-tests/src/chains/pop_network/mod.rs index c72f3eac0..b28b19d52 100644 --- a/emulated-integration-tests/src/chains/pop_network/mod.rs +++ b/emulated-integration-tests/src/chains/pop_network/mod.rs @@ -38,5 +38,6 @@ decl_test_parachains! { impl_accounts_helpers_for_parachain!(PopNetwork); impl_assert_events_helpers_for_parachain!(PopNetwork); impl_assets_helpers_for_parachain!(PopNetwork, Rococo); +// For foreign assets: // impl_foreign_assets_helpers_for_parachain!(PopNetwork, Rococo); impl_xcm_helpers_for_parachain!(PopNetwork); diff --git a/emulated-integration-tests/src/chains/rococo/mod.rs b/emulated-integration-tests/src/chains/rococo/mod.rs index e0d373021..cb55c8a4b 100644 --- a/emulated-integration-tests/src/chains/rococo/mod.rs +++ b/emulated-integration-tests/src/chains/rococo/mod.rs @@ -1,18 +1,3 @@ -// Copyright (C) Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - pub mod genesis; // Cumulus diff --git a/emulated-integration-tests/src/lib.rs b/emulated-integration-tests/src/lib.rs index 0cde546b5..e2fcffd46 100644 --- a/emulated-integration-tests/src/lib.rs +++ b/emulated-integration-tests/src/lib.rs @@ -1,51 +1,553 @@ mod chains; mod rococo_network; -pub use codec::Encode; - // Substrate pub use frame_support::{ - assert_err, assert_ok, + assert_err, pallet_prelude::Weight, - sp_runtime::{AccountId32, DispatchError, DispatchResult}, + sp_runtime::{DispatchError, DispatchResult}, traits::fungibles::Inspect, }; // Polkadot -pub use xcm::{ - prelude::{AccountId32 as AccountId32Junction, *}, - v3::{self, Error, NetworkId::Rococo as RococoId}, -}; +pub use xcm::prelude::{AccountId32 as AccountId32Junction, *}; // Cumulus pub use crate::rococo_network::{ asset_hub_rococo::{ genesis::ED as ASSET_HUB_ROCOCO_ED, AssetHubRococoParaPallet as AssetHubRococoPallet, }, + pop_network::PopNetworkParaPallet as PopNetworkPallet, rococo::{genesis::ED as ROCOCO_ED, RococoRelayPallet as RococoPallet}, AssetHubRococoPara as AssetHubRococo, AssetHubRococoParaReceiver as AssetHubRococoReceiver, - AssetHubRococoParaSender as AssetHubRococoSender, RococoRelay as Rococo, - RococoRelayReceiver as RococoReceiver, RococoRelaySender as RococoSender, + AssetHubRococoParaSender as AssetHubRococoSender, PopNetworkPara as PopNetwork, + PopNetworkParaReceiver as PopNetworkReceiver, PopNetworkParaSender as PopNetworkSender, + RococoRelay as Rococo, RococoRelayReceiver as RococoReceiver, + RococoRelaySender as RococoSender, }; pub use asset_test_utils::xcm_helpers; -pub use emulated_integration_tests_common::{ - test_parachain_is_trusted_teleporter, - xcm_emulator::{ - assert_expected_events, bx, helpers::weight_within_threshold, Chain, Parachain as Para, - RelayChain as Relay, Test, TestArgs, TestContext, TestExt, - }, - xcm_helpers::{xcm_transact_paid_execution, xcm_transact_unpaid_execution}, - PROOF_SIZE_THRESHOLD, REF_TIME_THRESHOLD, XCM_V3, +pub use emulated_integration_tests_common::xcm_emulator::{ + assert_expected_events, bx, Chain, Parachain as Para, RelayChain as Relay, Test, TestArgs, + TestContext, TestExt, }; -pub use parachains_common::{AccountId, Balance}; +pub use parachains_common::Balance; pub const ASSET_ID: u32 = 1; pub const ASSET_MIN_BALANCE: u128 = 1000; // `Assets` pallet index pub const ASSETS_PALLET_ID: u8 = 50; -pub type RelayToSystemParaTest = Test; -pub type SystemParaToRelayTest = Test; +pub type RelayToParaTest = Test; +pub type SystemParaToParaTest = Test; +pub type ParaToSystemParaTest = Test; #[cfg(test)] -mod tests; +mod tests { + use super::*; + + use asset_hub_rococo_runtime::xcm_config::XcmConfig as AssetHubRococoXcmConfig; + use pop_runtime::xcm_config::XcmConfig as PopNetworkXcmConfig; + use rococo_runtime::xcm_config::XcmConfig as RococoXcmConfig; + + fn relay_to_para_sender_assertions(t: RelayToParaTest) { + type RuntimeEvent = ::RuntimeEvent; + Rococo::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts(864_610_000, 8_799))); + assert_expected_events!( + Rococo, + vec![ + // Amount to reserve transfer is transferred to Parachain's Sovereign account + RuntimeEvent::Balances( + pallet_balances::Event::Transfer { from, to, amount } + ) => { + from: *from == t.sender.account_id, + to: *to == Rococo::sovereign_account_id_of( + t.args.dest.clone() + ), + amount: *amount == t.args.amount, + }, + ] + ); + } + + fn system_para_to_para_sender_assertions(t: SystemParaToParaTest) { + type RuntimeEvent = ::RuntimeEvent; + AssetHubRococo::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts( + 864_610_000, + 8_799, + ))); + assert_expected_events!( + AssetHubRococo, + vec![ + // Amount to reserve transfer is transferred to Parachain's Sovereign account + RuntimeEvent::Balances( + pallet_balances::Event::Transfer { from, to, amount } + ) => { + from: *from == t.sender.account_id, + to: *to == AssetHubRococo::sovereign_account_id_of( + t.args.dest.clone() + ), + amount: *amount == t.args.amount, + }, + ] + ); + } + + fn para_receiver_assertions(_: Test) { + type RuntimeEvent = ::RuntimeEvent; + assert_expected_events!( + PopNetwork, + vec![ + RuntimeEvent::Balances(pallet_balances::Event::Deposit { .. }) => {}, + RuntimeEvent::MessageQueue( + pallet_message_queue::Event::Processed { success: true, .. } + ) => {}, + ] + ); + } + + fn para_to_system_para_sender_assertions(t: ParaToSystemParaTest) { + type RuntimeEvent = ::RuntimeEvent; + PopNetwork::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts( + 864_610_000, + 8_799, + ))); + assert_expected_events!( + PopNetwork, + vec![ + // Amount to reserve transfer is transferred to Parachain's Sovereign account + RuntimeEvent::Balances( + pallet_balances::Event::Withdraw { who, amount } + ) => { + who: *who == t.sender.account_id, + amount: *amount == t.args.amount, + }, + ] + ); + } + + fn para_to_system_para_receiver_assertions(t: ParaToSystemParaTest) { + type RuntimeEvent = ::RuntimeEvent; + let sov_pop_net_on_ahr = AssetHubRococo::sovereign_account_id_of( + AssetHubRococo::sibling_location_of(PopNetwork::para_id()), + ); + assert_expected_events!( + AssetHubRococo, + vec![ + // Amount to reserve transfer is withdrawn from Parachain's Sovereign account + RuntimeEvent::Balances( + pallet_balances::Event::Withdraw { who, amount } + ) => { + who: *who == sov_pop_net_on_ahr.clone().into(), + amount: *amount == t.args.amount, + }, + RuntimeEvent::Balances(pallet_balances::Event::Deposit { .. }) => {}, + RuntimeEvent::MessageQueue( + pallet_message_queue::Event::Processed { success: true, .. } + ) => {}, + ] + ); + } + + fn system_para_to_para_assets_sender_assertions(t: SystemParaToParaTest) { + type RuntimeEvent = ::RuntimeEvent; + AssetHubRococo::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts( + 864_610_000, + 8799, + ))); + assert_expected_events!( + AssetHubRococo, + vec![ + // Amount to reserve transfer is transferred to Parachain's Sovereign account + RuntimeEvent::Assets( + pallet_assets::Event::Transferred { asset_id, from, to, amount } + ) => { + asset_id: *asset_id == ASSET_ID, + from: *from == t.sender.account_id, + to: *to == AssetHubRococo::sovereign_account_id_of( + t.args.dest.clone() + ), + amount: *amount == t.args.amount, + }, + ] + ); + } + + fn system_para_to_para_assets_receiver_assertions(_: Test) { + type RuntimeEvent = ::RuntimeEvent; + assert_expected_events!( + PopNetwork, + vec![ + RuntimeEvent::Balances(pallet_balances::Event::Deposit { .. }) => {}, + RuntimeEvent::Assets(pallet_assets::Event::Issued { .. }) => {}, + RuntimeEvent::MessageQueue( + pallet_message_queue::Event::Processed { success: true, .. } + ) => {}, + ] + ); + } + + fn relay_to_para_reserve_transfer_assets(t: RelayToParaTest) -> DispatchResult { + ::XcmPallet::limited_reserve_transfer_assets( + t.signed_origin, + bx!(t.args.dest.into()), + bx!(t.args.beneficiary.into()), + bx!(t.args.assets.into()), + t.args.fee_asset_item, + t.args.weight_limit, + ) + } + + fn system_para_to_para_reserve_transfer_assets(t: SystemParaToParaTest) -> DispatchResult { + ::PolkadotXcm::limited_reserve_transfer_assets( + t.signed_origin, + bx!(t.args.dest.into()), + bx!(t.args.beneficiary.into()), + bx!(t.args.assets.into()), + t.args.fee_asset_item, + t.args.weight_limit, + ) + } + + fn para_to_system_para_reserve_transfer_assets(t: ParaToSystemParaTest) -> DispatchResult { + ::PolkadotXcm::limited_reserve_transfer_assets( + t.signed_origin, + bx!(t.args.dest.into()), + bx!(t.args.beneficiary.into()), + bx!(t.args.assets.into()), + t.args.fee_asset_item, + t.args.weight_limit, + ) + } + + /// Reserve Transfers of native asset from Relay Chain to the System Parachain shouldn't work + #[test] + fn reserve_transfer_native_asset_from_relay_to_system_para_fails() { + let signed_origin = ::RuntimeOrigin::signed(RococoSender::get().into()); + let destination = Rococo::child_location_of(AssetHubRococo::para_id()); + let beneficiary: Location = + AccountId32Junction { network: None, id: AssetHubRococoReceiver::get().into() }.into(); + let amount_to_send: Balance = ROCOCO_ED * 1000; + let assets: Assets = (Here, amount_to_send).into(); + let fee_asset_item = 0; + + // this should fail + Rococo::execute_with(|| { + let result = ::XcmPallet::limited_reserve_transfer_assets( + signed_origin, + bx!(destination.into()), + bx!(beneficiary.into()), + bx!(assets.into()), + fee_asset_item, + WeightLimit::Unlimited, + ); + assert_err!( + result, + DispatchError::Module(sp_runtime::ModuleError { + index: 99, + error: [2, 0, 0, 0], + message: Some("Filtered") + }) + ); + }); + } + + /// Reserve Transfers of native asset from System Parachain to Relay Chain shouldn't work + #[test] + fn reserve_transfer_native_asset_from_system_para_to_relay_fails() { + // Init values for System Parachain + let signed_origin = + ::RuntimeOrigin::signed(AssetHubRococoSender::get().into()); + let destination = AssetHubRococo::parent_location(); + let beneficiary_id = RococoReceiver::get(); + let beneficiary: Location = + AccountId32Junction { network: None, id: beneficiary_id.into() }.into(); + let amount_to_send: Balance = ASSET_HUB_ROCOCO_ED * 1000; + + let assets: Assets = (Parent, amount_to_send).into(); + let fee_asset_item = 0; + + // this should fail + AssetHubRococo::execute_with(|| { + let result = + ::PolkadotXcm::limited_reserve_transfer_assets( + signed_origin, + bx!(destination.into()), + bx!(beneficiary.into()), + bx!(assets.into()), + fee_asset_item, + WeightLimit::Unlimited, + ); + assert_err!( + result, + DispatchError::Module(sp_runtime::ModuleError { + index: 31, + error: [2, 0, 0, 0], + message: Some("Filtered") + }) + ); + }); + } + + /// Reserve Transfers of native asset from Relay to Parachain should work + #[test] + fn reserve_transfer_native_asset_from_relay_to_para() { + // Init values for Relay + let destination = Rococo::child_location_of(PopNetwork::para_id()); + let beneficiary_id = PopNetworkReceiver::get(); + let amount_to_send: Balance = ROCOCO_ED * 1000; + + let test_args = TestContext { + sender: RococoSender::get(), + receiver: PopNetworkReceiver::get(), + args: TestArgs::new_relay(destination, beneficiary_id, amount_to_send), + }; + + let mut test = RelayToParaTest::new(test_args); + + let sender_balance_before = test.sender.balance; + let receiver_balance_before = test.receiver.balance; + + test.set_assertion::(relay_to_para_sender_assertions); + test.set_assertion::(para_receiver_assertions); + test.set_dispatchable::(relay_to_para_reserve_transfer_assets); + test.assert(); + + let delivery_fees = Rococo::execute_with(|| { + xcm_helpers::transfer_assets_delivery_fees::< + ::XcmSender, + >( + test.args.assets.clone(), + 0, + test.args.weight_limit, + test.args.beneficiary, + test.args.dest, + ) + }); + + let sender_balance_after = test.sender.balance; + let receiver_balance_after = test.receiver.balance; + + // Sender's balance is reduced + assert_eq!(sender_balance_before - amount_to_send - delivery_fees, sender_balance_after); + // Receiver's balance is increased + assert!(receiver_balance_after > receiver_balance_before); + // Receiver's balance increased by `amount_to_send - delivery_fees - bought_execution`; + // `delivery_fees` might be paid from transfer or JIT, also `bought_execution` is unknown + // but should be non-zero + assert!(receiver_balance_after < receiver_balance_before + amount_to_send); + } + + /// Reserve Transfers of native asset from System Parachain to Parachain should work + #[test] + fn reserve_transfer_native_asset_from_system_para_to_para() { + // Init values for System Parachain + let destination = AssetHubRococo::sibling_location_of(PopNetwork::para_id()); + let beneficiary_id = PopNetworkReceiver::get(); + let amount_to_send: Balance = ASSET_HUB_ROCOCO_ED * 1000; + let assets = (Parent, amount_to_send).into(); + + let test_args = TestContext { + sender: AssetHubRococoSender::get(), + receiver: PopNetworkReceiver::get(), + args: TestArgs::new_para(destination, beneficiary_id, amount_to_send, assets, None, 0), + }; + + let mut test = SystemParaToParaTest::new(test_args); + + let sender_balance_before = test.sender.balance; + let receiver_balance_before = test.receiver.balance; + + test.set_assertion::(system_para_to_para_sender_assertions); + test.set_assertion::(para_receiver_assertions); + test.set_dispatchable::(system_para_to_para_reserve_transfer_assets); + test.assert(); + + let sender_balance_after = test.sender.balance; + let receiver_balance_after = test.receiver.balance; + + let delivery_fees = AssetHubRococo::execute_with(|| { + xcm_helpers::transfer_assets_delivery_fees::< + ::XcmSender, + >( + test.args.assets.clone(), + 0, + test.args.weight_limit, + test.args.beneficiary, + test.args.dest, + ) + }); + + // Sender's balance is reduced + assert_eq!(sender_balance_before - amount_to_send - delivery_fees, sender_balance_after); + // Receiver's balance is increased + assert!(receiver_balance_after > receiver_balance_before); + // Receiver's balance increased by `amount_to_send - delivery_fees - bought_execution`; + // `delivery_fees` might be paid from transfer or JIT, also `bought_execution` is unknown + // but should be non-zero + assert!(receiver_balance_after < receiver_balance_before + amount_to_send); + } + + /// Reserve Transfers of native asset from Parachain to System Parachain should work + #[test] + fn reserve_transfer_native_asset_from_para_to_system_para() { + // Init values for Pop Network Parachain + let destination = PopNetwork::sibling_location_of(AssetHubRococo::para_id()); + let beneficiary_id = AssetHubRococoReceiver::get(); + let amount_to_send: Balance = ASSET_HUB_ROCOCO_ED * 1000; + let assets = (Parent, amount_to_send).into(); + + let test_args = TestContext { + sender: PopNetworkSender::get(), + receiver: AssetHubRococoReceiver::get(), + args: TestArgs::new_para(destination, beneficiary_id, amount_to_send, assets, None, 0), + }; + + let mut test = ParaToSystemParaTest::new(test_args); + + let sender_balance_before = test.sender.balance; + let receiver_balance_before = test.receiver.balance; + + let pop_net_location_as_seen_by_ahr = + AssetHubRococo::sibling_location_of(PopNetwork::para_id()); + let sov_pop_net_on_ahr = + AssetHubRococo::sovereign_account_id_of(pop_net_location_as_seen_by_ahr); + + // fund the Pop Network's SA on AHR with the native tokens held in reserve + AssetHubRococo::fund_accounts(vec![(sov_pop_net_on_ahr.into(), amount_to_send * 2)]); + + test.set_assertion::(para_to_system_para_sender_assertions); + test.set_assertion::(para_to_system_para_receiver_assertions); + test.set_dispatchable::(para_to_system_para_reserve_transfer_assets); + test.assert(); + + let sender_balance_after = test.sender.balance; + let receiver_balance_after = test.receiver.balance; + + let delivery_fees = PopNetwork::execute_with(|| { + xcm_helpers::transfer_assets_delivery_fees::< + ::XcmSender, + >( + test.args.assets.clone(), + 0, + test.args.weight_limit, + test.args.beneficiary, + test.args.dest, + ) + }); + + // Sender's balance is reduced + assert_eq!(sender_balance_before - amount_to_send - delivery_fees, sender_balance_after); + // Receiver's balance is increased + assert!(receiver_balance_after > receiver_balance_before); + // Receiver's balance increased by `amount_to_send - delivery_fees - bought_execution`; + // `delivery_fees` might be paid from transfer or JIT, also `bought_execution` is unknown + // but should be non-zero + assert!(receiver_balance_after < receiver_balance_before + amount_to_send); + } + + /// Reserve Transfers of a local asset and native asset from System Parachain to Parachain + /// should work + #[test] + fn reserve_transfer_assets_from_system_para_to_para() { + // Force create asset on AssetHubRococo and PopNetwork from Relay Chain + AssetHubRococo::force_create_and_mint_asset( + ASSET_ID, + ASSET_MIN_BALANCE, + false, + AssetHubRococoSender::get(), + Some(Weight::from_parts(1_019_445_000, 200_000)), + ASSET_MIN_BALANCE * 1_000_000, + ); + PopNetwork::force_create_and_mint_asset( + ASSET_ID, + ASSET_MIN_BALANCE, + false, + PopNetworkSender::get(), + None, + 0, + ); + + // Init values for System Parachain + let destination = AssetHubRococo::sibling_location_of(PopNetwork::para_id()); + let beneficiary_id = PopNetworkReceiver::get(); + let fee_amount_to_send = ASSET_HUB_ROCOCO_ED * 1000; + let asset_amount_to_send = ASSET_MIN_BALANCE * 1000; + let assets: Assets = vec![ + (Parent, fee_amount_to_send).into(), + ( + [PalletInstance(ASSETS_PALLET_ID), GeneralIndex(ASSET_ID.into())], + asset_amount_to_send, + ) + .into(), + ] + .into(); + let fee_asset_index = assets + .inner() + .iter() + .position(|r| r == &(Parent, fee_amount_to_send).into()) + .unwrap() as u32; + + let para_test_args = TestContext { + sender: AssetHubRococoSender::get(), + receiver: PopNetworkReceiver::get(), + args: TestArgs::new_para( + destination, + beneficiary_id, + asset_amount_to_send, + assets, + None, + fee_asset_index, + ), + }; + + let mut test = SystemParaToParaTest::new(para_test_args); + + // Create SA-of-Pop Network-on-AHR with ED. + let pop_net_location = AssetHubRococo::sibling_location_of(PopNetwork::para_id()); + let sov_pop_net_on_ahr = AssetHubRococo::sovereign_account_id_of(pop_net_location); + AssetHubRococo::fund_accounts(vec![(sov_pop_net_on_ahr.into(), ROCOCO_ED)]); + + let sender_balance_before = test.sender.balance; + let receiver_balance_before = test.receiver.balance; + + let sender_assets_before = AssetHubRococo::execute_with(|| { + type Assets = ::Assets; + >::balance(ASSET_ID, &AssetHubRococoSender::get()) + }); + let receiver_assets_before = PopNetwork::execute_with(|| { + type Assets = ::Assets; + >::balance(ASSET_ID, &PopNetworkReceiver::get()) + }); + + test.set_assertion::(system_para_to_para_assets_sender_assertions); + test.set_assertion::(system_para_to_para_assets_receiver_assertions); + test.set_dispatchable::(system_para_to_para_reserve_transfer_assets); + test.assert(); + + let sender_balance_after = test.sender.balance; + let receiver_balance_after = test.receiver.balance; + + // Sender's balance is reduced + assert!(sender_balance_after < sender_balance_before); + // Receiver's balance is increased + assert!(receiver_balance_after > receiver_balance_before); + // Receiver's balance increased by `amount_to_send - delivery_fees - bought_execution`; + // `delivery_fees` might be paid from transfer or JIT, also `bought_execution` is unknown + // but should be non-zero + assert!(receiver_balance_after < receiver_balance_before + fee_amount_to_send); + + let sender_assets_after = AssetHubRococo::execute_with(|| { + type Assets = ::Assets; + >::balance(ASSET_ID, &AssetHubRococoSender::get()) + }); + let receiver_assets_after = PopNetwork::execute_with(|| { + type Assets = ::Assets; + >::balance(ASSET_ID, &PopNetworkReceiver::get()) + }); + + // Sender's balance is reduced by exact amount + assert_eq!(sender_assets_before - asset_amount_to_send, sender_assets_after); + // Receiver's balance is increased by exact amount + assert_eq!(receiver_assets_after, receiver_assets_before + asset_amount_to_send); + } +} diff --git a/emulated-integration-tests/src/tests/asset_hub_rococo.rs b/emulated-integration-tests/src/tests/asset_hub_rococo.rs deleted file mode 100644 index 5512e5d39..000000000 --- a/emulated-integration-tests/src/tests/asset_hub_rococo.rs +++ /dev/null @@ -1,550 +0,0 @@ -// Substrate -pub use frame_support::{ - assert_err, - pallet_prelude::Weight, - sp_runtime::{DispatchError, DispatchResult}, - traits::fungibles::Inspect, -}; - -// Polkadot -pub use xcm::prelude::{AccountId32 as AccountId32Junction, *}; - -// Cumulus -pub use crate::rococo_network::{ - asset_hub_rococo::{ - genesis::ED as ASSET_HUB_ROCOCO_ED, AssetHubRococoParaPallet as AssetHubRococoPallet, - }, - pop_network::PopNetworkParaPallet as PopNetworkPallet, - rococo::{genesis::ED as ROCOCO_ED, RococoRelayPallet as RococoPallet}, - AssetHubRococoPara as AssetHubRococo, AssetHubRococoParaReceiver as AssetHubRococoReceiver, - AssetHubRococoParaSender as AssetHubRococoSender, PopNetworkPara as PopNetwork, - PopNetworkParaReceiver as PopNetworkReceiver, PopNetworkParaSender as PopNetworkSender, - RococoRelay as Rococo, RococoRelayReceiver as RococoReceiver, - RococoRelaySender as RococoSender, -}; -pub use asset_test_utils::xcm_helpers; -pub use emulated_integration_tests_common::xcm_emulator::{ - assert_expected_events, bx, Chain, Parachain as Para, RelayChain as Relay, Test, TestArgs, - TestContext, TestExt, -}; -pub use parachains_common::Balance; - -pub const ASSET_ID: u32 = 1; -pub const ASSET_MIN_BALANCE: u128 = 1000; -// `Assets` pallet index -pub const ASSETS_PALLET_ID: u8 = 50; - -pub type RelayToParaTest = Test; -pub type SystemParaToParaTest = Test; -pub type ParaToSystemParaTest = Test; - -#[cfg(test)] -mod tests { - use super::*; - - use asset_hub_rococo_runtime::xcm_config::XcmConfig as AssetHubRococoXcmConfig; - use pop_runtime::xcm_config::XcmConfig as PopNetworkXcmConfig; - use rococo_runtime::xcm_config::XcmConfig as RococoXcmConfig; - - fn relay_to_para_sender_assertions(t: RelayToParaTest) { - type RuntimeEvent = ::RuntimeEvent; - Rococo::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts(864_610_000, 8_799))); - assert_expected_events!( - Rococo, - vec![ - // Amount to reserve transfer is transferred to Parachain's Sovereign account - RuntimeEvent::Balances( - pallet_balances::Event::Transfer { from, to, amount } - ) => { - from: *from == t.sender.account_id, - to: *to == Rococo::sovereign_account_id_of( - t.args.dest.clone() - ), - amount: *amount == t.args.amount, - }, - ] - ); - } - - fn system_para_to_para_sender_assertions(t: SystemParaToParaTest) { - type RuntimeEvent = ::RuntimeEvent; - AssetHubRococo::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts( - 864_610_000, - 8_799, - ))); - assert_expected_events!( - AssetHubRococo, - vec![ - // Amount to reserve transfer is transferred to Parachain's Sovereign account - RuntimeEvent::Balances( - pallet_balances::Event::Transfer { from, to, amount } - ) => { - from: *from == t.sender.account_id, - to: *to == AssetHubRococo::sovereign_account_id_of( - t.args.dest.clone() - ), - amount: *amount == t.args.amount, - }, - ] - ); - } - - fn para_receiver_assertions(_: Test) { - type RuntimeEvent = ::RuntimeEvent; - assert_expected_events!( - PopNetwork, - vec![ - RuntimeEvent::Balances(pallet_balances::Event::Deposit { .. }) => {}, - RuntimeEvent::MessageQueue( - pallet_message_queue::Event::Processed { success: true, .. } - ) => {}, - ] - ); - } - - fn para_to_system_para_sender_assertions(t: ParaToSystemParaTest) { - type RuntimeEvent = ::RuntimeEvent; - PopNetwork::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts( - 864_610_000, - 8_799, - ))); - assert_expected_events!( - PopNetwork, - vec![ - // Amount to reserve transfer is transferred to Parachain's Sovereign account - RuntimeEvent::Balances( - pallet_balances::Event::Withdraw { who, amount } - ) => { - who: *who == t.sender.account_id, - amount: *amount == t.args.amount, - }, - ] - ); - } - - fn para_to_system_para_receiver_assertions(t: ParaToSystemParaTest) { - type RuntimeEvent = ::RuntimeEvent; - let sov_pop_net_on_ahr = AssetHubRococo::sovereign_account_id_of( - AssetHubRococo::sibling_location_of(PopNetwork::para_id()), - ); - assert_expected_events!( - AssetHubRococo, - vec![ - // Amount to reserve transfer is withdrawn from Parachain's Sovereign account - RuntimeEvent::Balances( - pallet_balances::Event::Withdraw { who, amount } - ) => { - who: *who == sov_pop_net_on_ahr.clone().into(), - amount: *amount == t.args.amount, - }, - RuntimeEvent::Balances(pallet_balances::Event::Deposit { .. }) => {}, - RuntimeEvent::MessageQueue( - pallet_message_queue::Event::Processed { success: true, .. } - ) => {}, - ] - ); - } - - fn system_para_to_para_assets_sender_assertions(t: SystemParaToParaTest) { - type RuntimeEvent = ::RuntimeEvent; - AssetHubRococo::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts( - 864_610_000, - 8799, - ))); - assert_expected_events!( - AssetHubRococo, - vec![ - // Amount to reserve transfer is transferred to Parachain's Sovereign account - RuntimeEvent::Assets( - pallet_assets::Event::Transferred { asset_id, from, to, amount } - ) => { - asset_id: *asset_id == ASSET_ID, - from: *from == t.sender.account_id, - to: *to == AssetHubRococo::sovereign_account_id_of( - t.args.dest.clone() - ), - amount: *amount == t.args.amount, - }, - ] - ); - } - - fn system_para_to_para_assets_receiver_assertions(_: Test) { - type RuntimeEvent = ::RuntimeEvent; - assert_expected_events!( - PopNetwork, - vec![ - RuntimeEvent::Balances(pallet_balances::Event::Deposit { .. }) => {}, - RuntimeEvent::Assets(pallet_assets::Event::Issued { .. }) => {}, - RuntimeEvent::MessageQueue( - pallet_message_queue::Event::Processed { success: true, .. } - ) => {}, - ] - ); - } - - fn relay_to_para_reserve_transfer_assets(t: RelayToParaTest) -> DispatchResult { - ::XcmPallet::limited_reserve_transfer_assets( - t.signed_origin, - bx!(t.args.dest.into()), - bx!(t.args.beneficiary.into()), - bx!(t.args.assets.into()), - t.args.fee_asset_item, - t.args.weight_limit, - ) - } - - fn system_para_to_para_reserve_transfer_assets(t: SystemParaToParaTest) -> DispatchResult { - ::PolkadotXcm::limited_reserve_transfer_assets( - t.signed_origin, - bx!(t.args.dest.into()), - bx!(t.args.beneficiary.into()), - bx!(t.args.assets.into()), - t.args.fee_asset_item, - t.args.weight_limit, - ) - } - - fn para_to_system_para_reserve_transfer_assets(t: ParaToSystemParaTest) -> DispatchResult { - ::PolkadotXcm::limited_reserve_transfer_assets( - t.signed_origin, - bx!(t.args.dest.into()), - bx!(t.args.beneficiary.into()), - bx!(t.args.assets.into()), - t.args.fee_asset_item, - t.args.weight_limit, - ) - } - - /// Reserve Transfers of native asset from Relay Chain to the System Parachain shouldn't work - #[test] - fn reserve_transfer_native_asset_from_relay_to_system_para_fails() { - let signed_origin = ::RuntimeOrigin::signed(RococoSender::get().into()); - let destination = Rococo::child_location_of(AssetHubRococo::para_id()); - let beneficiary: Location = - AccountId32Junction { network: None, id: AssetHubRococoReceiver::get().into() }.into(); - let amount_to_send: Balance = ROCOCO_ED * 1000; - let assets: Assets = (Here, amount_to_send).into(); - let fee_asset_item = 0; - - // this should fail - Rococo::execute_with(|| { - let result = ::XcmPallet::limited_reserve_transfer_assets( - signed_origin, - bx!(destination.into()), - bx!(beneficiary.into()), - bx!(assets.into()), - fee_asset_item, - WeightLimit::Unlimited, - ); - assert_err!( - result, - DispatchError::Module(sp_runtime::ModuleError { - index: 99, - error: [2, 0, 0, 0], - message: Some("Filtered") - }) - ); - }); - } - - /// Reserve Transfers of native asset from System Parachain to Relay Chain shouldn't work - #[test] - fn reserve_transfer_native_asset_from_system_para_to_relay_fails() { - // Init values for System Parachain - let signed_origin = - ::RuntimeOrigin::signed(AssetHubRococoSender::get().into()); - let destination = AssetHubRococo::parent_location(); - let beneficiary_id = RococoReceiver::get(); - let beneficiary: Location = - AccountId32Junction { network: None, id: beneficiary_id.into() }.into(); - let amount_to_send: Balance = ASSET_HUB_ROCOCO_ED * 1000; - - let assets: Assets = (Parent, amount_to_send).into(); - let fee_asset_item = 0; - - // this should fail - AssetHubRococo::execute_with(|| { - let result = - ::PolkadotXcm::limited_reserve_transfer_assets( - signed_origin, - bx!(destination.into()), - bx!(beneficiary.into()), - bx!(assets.into()), - fee_asset_item, - WeightLimit::Unlimited, - ); - assert_err!( - result, - DispatchError::Module(sp_runtime::ModuleError { - index: 31, - error: [2, 0, 0, 0], - message: Some("Filtered") - }) - ); - }); - } - - /// Reserve Transfers of native asset from Relay to Parachain should work - #[test] - fn reserve_transfer_native_asset_from_relay_to_para() { - // Init values for Relay - let destination = Rococo::child_location_of(PopNetwork::para_id()); - let beneficiary_id = PopNetworkReceiver::get(); - let amount_to_send: Balance = ROCOCO_ED * 1000; - - let test_args = TestContext { - sender: RococoSender::get(), - receiver: PopNetworkReceiver::get(), - args: TestArgs::new_relay(destination, beneficiary_id, amount_to_send), - }; - - let mut test = RelayToParaTest::new(test_args); - - let sender_balance_before = test.sender.balance; - let receiver_balance_before = test.receiver.balance; - - test.set_assertion::(relay_to_para_sender_assertions); - test.set_assertion::(para_receiver_assertions); - test.set_dispatchable::(relay_to_para_reserve_transfer_assets); - test.assert(); - - let delivery_fees = Rococo::execute_with(|| { - xcm_helpers::transfer_assets_delivery_fees::< - ::XcmSender, - >( - test.args.assets.clone(), - 0, - test.args.weight_limit, - test.args.beneficiary, - test.args.dest, - ) - }); - - let sender_balance_after = test.sender.balance; - let receiver_balance_after = test.receiver.balance; - - // Sender's balance is reduced - assert_eq!(sender_balance_before - amount_to_send - delivery_fees, sender_balance_after); - // Receiver's balance is increased - assert!(receiver_balance_after > receiver_balance_before); - // Receiver's balance increased by `amount_to_send - delivery_fees - bought_execution`; - // `delivery_fees` might be paid from transfer or JIT, also `bought_execution` is unknown - // but should be non-zero - assert!(receiver_balance_after < receiver_balance_before + amount_to_send); - } - - /// Reserve Transfers of native asset from System Parachain to Parachain should work - #[test] - fn reserve_transfer_native_asset_from_system_para_to_para() { - // Init values for System Parachain - let destination = AssetHubRococo::sibling_location_of(PopNetwork::para_id()); - let beneficiary_id = PopNetworkReceiver::get(); - let amount_to_send: Balance = ASSET_HUB_ROCOCO_ED * 1000; - let assets = (Parent, amount_to_send).into(); - - let test_args = TestContext { - sender: AssetHubRococoSender::get(), - receiver: PopNetworkReceiver::get(), - args: TestArgs::new_para(destination, beneficiary_id, amount_to_send, assets, None, 0), - }; - - let mut test = SystemParaToParaTest::new(test_args); - - let sender_balance_before = test.sender.balance; - let receiver_balance_before = test.receiver.balance; - - test.set_assertion::(system_para_to_para_sender_assertions); - test.set_assertion::(para_receiver_assertions); - test.set_dispatchable::(system_para_to_para_reserve_transfer_assets); - test.assert(); - - let sender_balance_after = test.sender.balance; - let receiver_balance_after = test.receiver.balance; - - let delivery_fees = AssetHubRococo::execute_with(|| { - xcm_helpers::transfer_assets_delivery_fees::< - ::XcmSender, - >( - test.args.assets.clone(), - 0, - test.args.weight_limit, - test.args.beneficiary, - test.args.dest, - ) - }); - - // Sender's balance is reduced - assert_eq!(sender_balance_before - amount_to_send - delivery_fees, sender_balance_after); - // Receiver's balance is increased - assert!(receiver_balance_after > receiver_balance_before); - // Receiver's balance increased by `amount_to_send - delivery_fees - bought_execution`; - // `delivery_fees` might be paid from transfer or JIT, also `bought_execution` is unknown - // but should be non-zero - assert!(receiver_balance_after < receiver_balance_before + amount_to_send); - } - - /// Reserve Transfers of native asset from Parachain to System Parachain should work - #[test] - fn reserve_transfer_native_asset_from_para_to_system_para() { - // Init values for Pop Network Parachain - let destination = PopNetwork::sibling_location_of(AssetHubRococo::para_id()); - let beneficiary_id = AssetHubRococoReceiver::get(); - let amount_to_send: Balance = ASSET_HUB_ROCOCO_ED * 1000; - let assets = (Parent, amount_to_send).into(); - - let test_args = TestContext { - sender: PopNetworkSender::get(), - receiver: AssetHubRococoReceiver::get(), - args: TestArgs::new_para(destination, beneficiary_id, amount_to_send, assets, None, 0), - }; - - let mut test = ParaToSystemParaTest::new(test_args); - - let sender_balance_before = test.sender.balance; - let receiver_balance_before = test.receiver.balance; - - let pop_net_location_as_seen_by_ahr = - AssetHubRococo::sibling_location_of(PopNetwork::para_id()); - let sov_pop_net_on_ahr = - AssetHubRococo::sovereign_account_id_of(pop_net_location_as_seen_by_ahr); - - // fund the Pop Network's SA on AHR with the native tokens held in reserve - AssetHubRococo::fund_accounts(vec![(sov_pop_net_on_ahr.into(), amount_to_send * 2)]); - - test.set_assertion::(para_to_system_para_sender_assertions); - test.set_assertion::(para_to_system_para_receiver_assertions); - test.set_dispatchable::(para_to_system_para_reserve_transfer_assets); - test.assert(); - - let sender_balance_after = test.sender.balance; - let receiver_balance_after = test.receiver.balance; - - let delivery_fees = PopNetwork::execute_with(|| { - xcm_helpers::transfer_assets_delivery_fees::< - ::XcmSender, - >( - test.args.assets.clone(), - 0, - test.args.weight_limit, - test.args.beneficiary, - test.args.dest, - ) - }); - - // Sender's balance is reduced - assert_eq!(sender_balance_before - amount_to_send - delivery_fees, sender_balance_after); - // Receiver's balance is increased - assert!(receiver_balance_after > receiver_balance_before); - // Receiver's balance increased by `amount_to_send - delivery_fees - bought_execution`; - // `delivery_fees` might be paid from transfer or JIT, also `bought_execution` is unknown - // but should be non-zero - assert!(receiver_balance_after < receiver_balance_before + amount_to_send); - } - - /// Reserve Transfers of a local asset and native asset from System Parachain to Parachain - /// should work - #[test] - fn reserve_transfer_assets_from_system_para_to_para() { - // Force create asset on AssetHubRococo and PopNetwork from Relay Chain - AssetHubRococo::force_create_and_mint_asset( - ASSET_ID, - ASSET_MIN_BALANCE, - false, - AssetHubRococoSender::get(), - Some(Weight::from_parts(1_019_445_000, 200_000)), - ASSET_MIN_BALANCE * 1_000_000, - ); - PopNetwork::force_create_and_mint_asset( - ASSET_ID, - ASSET_MIN_BALANCE, - false, - PopNetworkSender::get(), - None, - 0, - ); - - // Init values for System Parachain - let destination = AssetHubRococo::sibling_location_of(PopNetwork::para_id()); - let beneficiary_id = PopNetworkReceiver::get(); - let fee_amount_to_send = ASSET_HUB_ROCOCO_ED * 1000; - let asset_amount_to_send = ASSET_MIN_BALANCE * 1000; - let assets: Assets = vec![ - (Parent, fee_amount_to_send).into(), - ( - [PalletInstance(ASSETS_PALLET_ID), GeneralIndex(ASSET_ID.into())], - asset_amount_to_send, - ) - .into(), - ] - .into(); - let fee_asset_index = assets - .inner() - .iter() - .position(|r| r == &(Parent, fee_amount_to_send).into()) - .unwrap() as u32; - - let para_test_args = TestContext { - sender: AssetHubRococoSender::get(), - receiver: PopNetworkReceiver::get(), - args: TestArgs::new_para( - destination, - beneficiary_id, - asset_amount_to_send, - assets, - None, - fee_asset_index, - ), - }; - - let mut test = SystemParaToParaTest::new(para_test_args); - - // Create SA-of-Pop Network-on-AHR with ED. - let pop_net_location = AssetHubRococo::sibling_location_of(PopNetwork::para_id()); - let sov_pop_net_on_ahr = AssetHubRococo::sovereign_account_id_of(pop_net_location); - AssetHubRococo::fund_accounts(vec![(sov_pop_net_on_ahr.into(), ROCOCO_ED)]); - - let sender_balance_before = test.sender.balance; - let receiver_balance_before = test.receiver.balance; - - let sender_assets_before = AssetHubRococo::execute_with(|| { - type Assets = ::Assets; - >::balance(ASSET_ID, &AssetHubRococoSender::get()) - }); - let receiver_assets_before = PopNetwork::execute_with(|| { - type Assets = ::Assets; - >::balance(ASSET_ID, &PopNetworkReceiver::get()) - }); - - test.set_assertion::(system_para_to_para_assets_sender_assertions); - test.set_assertion::(system_para_to_para_assets_receiver_assertions); - test.set_dispatchable::(system_para_to_para_reserve_transfer_assets); - test.assert(); - - let sender_balance_after = test.sender.balance; - let receiver_balance_after = test.receiver.balance; - - // Sender's balance is reduced - assert!(sender_balance_after < sender_balance_before); - // Receiver's balance is increased - assert!(receiver_balance_after > receiver_balance_before); - // Receiver's balance increased by `amount_to_send - delivery_fees - bought_execution`; - // `delivery_fees` might be paid from transfer or JIT, also `bought_execution` is unknown - // but should be non-zero - assert!(receiver_balance_after < receiver_balance_before + fee_amount_to_send); - - let sender_assets_after = AssetHubRococo::execute_with(|| { - type Assets = ::Assets; - >::balance(ASSET_ID, &AssetHubRococoSender::get()) - }); - let receiver_assets_after = PopNetwork::execute_with(|| { - type Assets = ::Assets; - >::balance(ASSET_ID, &PopNetworkReceiver::get()) - }); - - // Sender's balance is reduced by exact amount - assert_eq!(sender_assets_before - asset_amount_to_send, sender_assets_after); - // Receiver's balance is increased by exact amount - assert_eq!(receiver_assets_after, receiver_assets_before + asset_amount_to_send); - } -} diff --git a/emulated-integration-tests/src/tests/mod.rs b/emulated-integration-tests/src/tests/mod.rs deleted file mode 100644 index ca06a9771..000000000 --- a/emulated-integration-tests/src/tests/mod.rs +++ /dev/null @@ -1 +0,0 @@ -mod asset_hub_rococo; From 189c01352edcbeb4d2a8e7734c88f42c580f05c7 Mon Sep 17 00:00:00 2001 From: R0GUE Date: Tue, 5 Mar 2024 21:49:14 +0700 Subject: [PATCH 03/23] Removed unnecessary dependency --- emulated-integration-tests/Cargo.toml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/emulated-integration-tests/Cargo.toml b/emulated-integration-tests/Cargo.toml index 0e5f8fa77..fd7957907 100644 --- a/emulated-integration-tests/Cargo.toml +++ b/emulated-integration-tests/Cargo.toml @@ -9,7 +9,6 @@ repository.workspace = true [dependencies] codec = { workspace = true } -#assert_matches = "1.5.0" # Substrate frame-support = { workspace = true } @@ -45,9 +44,6 @@ default = ["std"] std = [ "asset-hub-rococo-runtime/std", "asset-test-utils/std", - "pallet-assets/std", - "pallet-balances/std", - "pallet-message-queue/std", "pop-runtime/std", "rococo-runtime/std", "rococo-runtime-constants/std", From 21d24670b774bf6cf1504e653f65d697628d1972 Mon Sep 17 00:00:00 2001 From: R0GUE Date: Thu, 7 Mar 2024 08:18:20 +0700 Subject: [PATCH 04/23] fmt --- .../src/chains/asset_hub_rococo/genesis.rs | 86 +- .../src/chains/asset_hub_rococo/mod.rs | 48 +- .../src/chains/pop_network/genesis.rs | 86 +- .../src/chains/pop_network/mod.rs | 44 +- .../src/chains/rococo/genesis.rs | 117 +- .../src/chains/rococo/mod.rs | 40 +- emulated-integration-tests/src/lib.rs | 1054 +++++++++-------- .../src/rococo_network.rs | 26 +- 8 files changed, 769 insertions(+), 732 deletions(-) diff --git a/emulated-integration-tests/src/chains/asset_hub_rococo/genesis.rs b/emulated-integration-tests/src/chains/asset_hub_rococo/genesis.rs index f89fc5e05..a1874b761 100644 --- a/emulated-integration-tests/src/chains/asset_hub_rococo/genesis.rs +++ b/emulated-integration-tests/src/chains/asset_hub_rococo/genesis.rs @@ -3,7 +3,7 @@ use sp_core::storage::Storage; // Cumulus use emulated_integration_tests_common::{ - accounts, build_genesis_storage, collators, SAFE_XCM_VERSION, + accounts, build_genesis_storage, collators, SAFE_XCM_VERSION, }; use parachains_common::Balance; @@ -11,45 +11,49 @@ pub const PARA_ID: u32 = 1000; pub const ED: Balance = rococo_runtime_constants::currency::EXISTENTIAL_DEPOSIT / 10; pub fn genesis() -> Storage { - let genesis_config = asset_hub_rococo_runtime::RuntimeGenesisConfig { - system: asset_hub_rococo_runtime::SystemConfig::default(), - balances: asset_hub_rococo_runtime::BalancesConfig { - balances: accounts::init_balances() - .iter() - .cloned() - .map(|k| (k, ED * 4096 * 4096)) - .collect(), - }, - parachain_info: asset_hub_rococo_runtime::ParachainInfoConfig { - parachain_id: PARA_ID.into(), - ..Default::default() - }, - collator_selection: asset_hub_rococo_runtime::CollatorSelectionConfig { - invulnerables: collators::invulnerables().iter().cloned().map(|(acc, _)| acc).collect(), - candidacy_bond: ED * 16, - ..Default::default() - }, - session: asset_hub_rococo_runtime::SessionConfig { - keys: collators::invulnerables() - .into_iter() - .map(|(acc, aura)| { - ( - acc.clone(), // account id - acc, // validator id - asset_hub_rococo_runtime::SessionKeys { aura }, // session keys - ) - }) - .collect(), - }, - polkadot_xcm: asset_hub_rococo_runtime::PolkadotXcmConfig { - safe_xcm_version: Some(SAFE_XCM_VERSION), - ..Default::default() - }, - ..Default::default() - }; + let genesis_config = asset_hub_rococo_runtime::RuntimeGenesisConfig { + system: asset_hub_rococo_runtime::SystemConfig::default(), + balances: asset_hub_rococo_runtime::BalancesConfig { + balances: accounts::init_balances() + .iter() + .cloned() + .map(|k| (k, ED * 4096 * 4096)) + .collect(), + }, + parachain_info: asset_hub_rococo_runtime::ParachainInfoConfig { + parachain_id: PARA_ID.into(), + ..Default::default() + }, + collator_selection: asset_hub_rococo_runtime::CollatorSelectionConfig { + invulnerables: collators::invulnerables() + .iter() + .cloned() + .map(|(acc, _)| acc) + .collect(), + candidacy_bond: ED * 16, + ..Default::default() + }, + session: asset_hub_rococo_runtime::SessionConfig { + keys: collators::invulnerables() + .into_iter() + .map(|(acc, aura)| { + ( + acc.clone(), // account id + acc, // validator id + asset_hub_rococo_runtime::SessionKeys { aura }, // session keys + ) + }) + .collect(), + }, + polkadot_xcm: asset_hub_rococo_runtime::PolkadotXcmConfig { + safe_xcm_version: Some(SAFE_XCM_VERSION), + ..Default::default() + }, + ..Default::default() + }; - build_genesis_storage( - &genesis_config, - asset_hub_rococo_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"), - ) + build_genesis_storage( + &genesis_config, + asset_hub_rococo_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"), + ) } diff --git a/emulated-integration-tests/src/chains/asset_hub_rococo/mod.rs b/emulated-integration-tests/src/chains/asset_hub_rococo/mod.rs index 63a5cec3b..6c4eb3a14 100644 --- a/emulated-integration-tests/src/chains/asset_hub_rococo/mod.rs +++ b/emulated-integration-tests/src/chains/asset_hub_rococo/mod.rs @@ -6,34 +6,34 @@ use frame_support::traits::OnInitialize; // Cumulus use crate::chains::rococo::Rococo; use emulated_integration_tests_common::{ - impl_accounts_helpers_for_parachain, impl_assert_events_helpers_for_parachain, - impl_assets_helpers_for_parachain, impl_foreign_assets_helpers_for_parachain, - impl_xcm_helpers_for_parachain, impls::Parachain, xcm_emulator::decl_test_parachains, + impl_accounts_helpers_for_parachain, impl_assert_events_helpers_for_parachain, + impl_assets_helpers_for_parachain, impl_foreign_assets_helpers_for_parachain, + impl_xcm_helpers_for_parachain, impls::Parachain, xcm_emulator::decl_test_parachains, }; // AssetHubRococo Parachain declaration decl_test_parachains! { - pub struct AssetHubRococo { - genesis = genesis::genesis(), - on_init = { - asset_hub_rococo_runtime::AuraExt::on_initialize(1); - }, - runtime = asset_hub_rococo_runtime, - core = { - XcmpMessageHandler: asset_hub_rococo_runtime::XcmpQueue, - LocationToAccountId: asset_hub_rococo_runtime::xcm_config::LocationToAccountId, - ParachainInfo: asset_hub_rococo_runtime::ParachainInfo, - MessageOrigin: cumulus_primitives_core::AggregateMessageOrigin, - }, - pallets = { - PolkadotXcm: asset_hub_rococo_runtime::PolkadotXcm, - Assets: asset_hub_rococo_runtime::Assets, - ForeignAssets: asset_hub_rococo_runtime::ForeignAssets, - PoolAssets: asset_hub_rococo_runtime::PoolAssets, - AssetConversion: asset_hub_rococo_runtime::AssetConversion, - Balances: asset_hub_rococo_runtime::Balances, - } - }, + pub struct AssetHubRococo { + genesis = genesis::genesis(), + on_init = { + asset_hub_rococo_runtime::AuraExt::on_initialize(1); + }, + runtime = asset_hub_rococo_runtime, + core = { + XcmpMessageHandler: asset_hub_rococo_runtime::XcmpQueue, + LocationToAccountId: asset_hub_rococo_runtime::xcm_config::LocationToAccountId, + ParachainInfo: asset_hub_rococo_runtime::ParachainInfo, + MessageOrigin: cumulus_primitives_core::AggregateMessageOrigin, + }, + pallets = { + PolkadotXcm: asset_hub_rococo_runtime::PolkadotXcm, + Assets: asset_hub_rococo_runtime::Assets, + ForeignAssets: asset_hub_rococo_runtime::ForeignAssets, + PoolAssets: asset_hub_rococo_runtime::PoolAssets, + AssetConversion: asset_hub_rococo_runtime::AssetConversion, + Balances: asset_hub_rococo_runtime::Balances, + } + }, } // AssetHubRococo implementation diff --git a/emulated-integration-tests/src/chains/pop_network/genesis.rs b/emulated-integration-tests/src/chains/pop_network/genesis.rs index 03bd98784..b933fba88 100644 --- a/emulated-integration-tests/src/chains/pop_network/genesis.rs +++ b/emulated-integration-tests/src/chains/pop_network/genesis.rs @@ -3,7 +3,7 @@ use sp_core::storage::Storage; // Cumulus use emulated_integration_tests_common::{ - accounts, build_genesis_storage, collators, SAFE_XCM_VERSION, + accounts, build_genesis_storage, collators, SAFE_XCM_VERSION, }; use parachains_common::Balance; @@ -11,45 +11,49 @@ pub const PARA_ID: u32 = 909; pub const ED: Balance = rococo_runtime_constants::currency::EXISTENTIAL_DEPOSIT / 10; pub fn genesis() -> Storage { - let genesis_config = pop_runtime::RuntimeGenesisConfig { - system: pop_runtime::SystemConfig::default(), - balances: pop_runtime::BalancesConfig { - balances: accounts::init_balances() - .iter() - .cloned() - .map(|k| (k, ED * 4096 * 4096)) - .collect(), - }, - parachain_info: pop_runtime::ParachainInfoConfig { - parachain_id: PARA_ID.into(), - ..Default::default() - }, - collator_selection: pop_runtime::CollatorSelectionConfig { - invulnerables: collators::invulnerables().iter().cloned().map(|(acc, _)| acc).collect(), - candidacy_bond: ED * 16, - ..Default::default() - }, - session: pop_runtime::SessionConfig { - keys: collators::invulnerables() - .into_iter() - .map(|(acc, aura)| { - ( - acc.clone(), // account id - acc, // validator id - pop_runtime::SessionKeys { aura }, // session keys - ) - }) - .collect(), - }, - polkadot_xcm: pop_runtime::PolkadotXcmConfig { - safe_xcm_version: Some(SAFE_XCM_VERSION), - ..Default::default() - }, - ..Default::default() - }; + let genesis_config = pop_runtime::RuntimeGenesisConfig { + system: pop_runtime::SystemConfig::default(), + balances: pop_runtime::BalancesConfig { + balances: accounts::init_balances() + .iter() + .cloned() + .map(|k| (k, ED * 4096 * 4096)) + .collect(), + }, + parachain_info: pop_runtime::ParachainInfoConfig { + parachain_id: PARA_ID.into(), + ..Default::default() + }, + collator_selection: pop_runtime::CollatorSelectionConfig { + invulnerables: collators::invulnerables() + .iter() + .cloned() + .map(|(acc, _)| acc) + .collect(), + candidacy_bond: ED * 16, + ..Default::default() + }, + session: pop_runtime::SessionConfig { + keys: collators::invulnerables() + .into_iter() + .map(|(acc, aura)| { + ( + acc.clone(), // account id + acc, // validator id + pop_runtime::SessionKeys { aura }, // session keys + ) + }) + .collect(), + }, + polkadot_xcm: pop_runtime::PolkadotXcmConfig { + safe_xcm_version: Some(SAFE_XCM_VERSION), + ..Default::default() + }, + ..Default::default() + }; - build_genesis_storage( - &genesis_config, - pop_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"), - ) + build_genesis_storage( + &genesis_config, + pop_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"), + ) } diff --git a/emulated-integration-tests/src/chains/pop_network/mod.rs b/emulated-integration-tests/src/chains/pop_network/mod.rs index b28b19d52..d7378c5fc 100644 --- a/emulated-integration-tests/src/chains/pop_network/mod.rs +++ b/emulated-integration-tests/src/chains/pop_network/mod.rs @@ -6,32 +6,32 @@ use frame_support::traits::OnInitialize; // Cumulus use crate::chains::rococo::Rococo; use emulated_integration_tests_common::{ - impl_accounts_helpers_for_parachain, impl_assert_events_helpers_for_parachain, - impl_assets_helpers_for_parachain, impl_xcm_helpers_for_parachain, impls::Parachain, - xcm_emulator::decl_test_parachains, + impl_accounts_helpers_for_parachain, impl_assert_events_helpers_for_parachain, + impl_assets_helpers_for_parachain, impl_xcm_helpers_for_parachain, impls::Parachain, + xcm_emulator::decl_test_parachains, }; // PopNetwork Parachain declaration decl_test_parachains! { - pub struct PopNetwork { - genesis = genesis::genesis(), - on_init = { - pop_runtime::AuraExt::on_initialize(1); - }, - runtime = pop_runtime, - core = { - XcmpMessageHandler: pop_runtime::XcmpQueue, - LocationToAccountId: pop_runtime::xcm_config::LocationToAccountId, - ParachainInfo: pop_runtime::ParachainInfo, - MessageOrigin: cumulus_primitives_core::AggregateMessageOrigin, - }, - pallets = { - PolkadotXcm: pop_runtime::PolkadotXcm, - Assets: pop_runtime::Assets, - Balances: pop_runtime::Balances, - Nfts: pop_runtime::Nfts, - } - }, + pub struct PopNetwork { + genesis = genesis::genesis(), + on_init = { + pop_runtime::AuraExt::on_initialize(1); + }, + runtime = pop_runtime, + core = { + XcmpMessageHandler: pop_runtime::XcmpQueue, + LocationToAccountId: pop_runtime::xcm_config::LocationToAccountId, + ParachainInfo: pop_runtime::ParachainInfo, + MessageOrigin: cumulus_primitives_core::AggregateMessageOrigin, + }, + pallets = { + PolkadotXcm: pop_runtime::PolkadotXcm, + Assets: pop_runtime::Assets, + Balances: pop_runtime::Balances, + Nfts: pop_runtime::Nfts, + } + }, } // PopNetwork implementation diff --git a/emulated-integration-tests/src/chains/rococo/genesis.rs b/emulated-integration-tests/src/chains/rococo/genesis.rs index 6ed4f5e3d..3ec8a3b9a 100644 --- a/emulated-integration-tests/src/chains/rococo/genesis.rs +++ b/emulated-integration-tests/src/chains/rococo/genesis.rs @@ -10,8 +10,8 @@ use polkadot_primitives::{AssignmentId, ValidatorId}; // Cumulus use emulated_integration_tests_common::{ - accounts, build_genesis_storage, get_account_id_from_seed, get_from_seed, get_host_config, - validators, + accounts, build_genesis_storage, get_account_id_from_seed, get_from_seed, get_host_config, + validators, }; use parachains_common::Balance; use rococo_runtime_constants::currency::UNITS as ROC; @@ -20,63 +20,68 @@ pub const ED: Balance = rococo_runtime_constants::currency::EXISTENTIAL_DEPOSIT; const ENDOWMENT: u128 = 1_000_000 * ROC; fn session_keys( - babe: BabeId, - grandpa: GrandpaId, - para_validator: ValidatorId, - para_assignment: AssignmentId, - authority_discovery: AuthorityDiscoveryId, - beefy: BeefyId, + babe: BabeId, + grandpa: GrandpaId, + para_validator: ValidatorId, + para_assignment: AssignmentId, + authority_discovery: AuthorityDiscoveryId, + beefy: BeefyId, ) -> rococo_runtime::SessionKeys { - rococo_runtime::SessionKeys { - babe, - grandpa, - para_validator, - para_assignment, - authority_discovery, - beefy, - } + rococo_runtime::SessionKeys { + babe, + grandpa, + para_validator, + para_assignment, + authority_discovery, + beefy, + } } pub fn genesis() -> Storage { - let genesis_config = rococo_runtime::RuntimeGenesisConfig { - system: rococo_runtime::SystemConfig::default(), - balances: rococo_runtime::BalancesConfig { - balances: accounts::init_balances().iter().map(|k| (k.clone(), ENDOWMENT)).collect(), - }, - session: rococo_runtime::SessionConfig { - keys: validators::initial_authorities() - .iter() - .map(|x| { - ( - x.0.clone(), - x.0.clone(), - session_keys( - x.2.clone(), - x.3.clone(), - x.4.clone(), - x.5.clone(), - x.6.clone(), - get_from_seed::("Alice"), - ), - ) - }) - .collect::>(), - }, - babe: rococo_runtime::BabeConfig { - authorities: Default::default(), - epoch_config: Some(rococo_runtime::BABE_GENESIS_EPOCH_CONFIG), - ..Default::default() - }, - sudo: rococo_runtime::SudoConfig { - key: Some(get_account_id_from_seed::("Alice")), - }, - configuration: rococo_runtime::ConfigurationConfig { config: get_host_config() }, - registrar: rococo_runtime::RegistrarConfig { - next_free_para_id: polkadot_primitives::LOWEST_PUBLIC_ID, - ..Default::default() - }, - ..Default::default() - }; + let genesis_config = rococo_runtime::RuntimeGenesisConfig { + system: rococo_runtime::SystemConfig::default(), + balances: rococo_runtime::BalancesConfig { + balances: accounts::init_balances() + .iter() + .map(|k| (k.clone(), ENDOWMENT)) + .collect(), + }, + session: rococo_runtime::SessionConfig { + keys: validators::initial_authorities() + .iter() + .map(|x| { + ( + x.0.clone(), + x.0.clone(), + session_keys( + x.2.clone(), + x.3.clone(), + x.4.clone(), + x.5.clone(), + x.6.clone(), + get_from_seed::("Alice"), + ), + ) + }) + .collect::>(), + }, + babe: rococo_runtime::BabeConfig { + authorities: Default::default(), + epoch_config: Some(rococo_runtime::BABE_GENESIS_EPOCH_CONFIG), + ..Default::default() + }, + sudo: rococo_runtime::SudoConfig { + key: Some(get_account_id_from_seed::("Alice")), + }, + configuration: rococo_runtime::ConfigurationConfig { + config: get_host_config(), + }, + registrar: rococo_runtime::RegistrarConfig { + next_free_para_id: polkadot_primitives::LOWEST_PUBLIC_ID, + ..Default::default() + }, + ..Default::default() + }; - build_genesis_storage(&genesis_config, rococo_runtime::WASM_BINARY.unwrap()) + build_genesis_storage(&genesis_config, rococo_runtime::WASM_BINARY.unwrap()) } diff --git a/emulated-integration-tests/src/chains/rococo/mod.rs b/emulated-integration-tests/src/chains/rococo/mod.rs index cb55c8a4b..83f809e0d 100644 --- a/emulated-integration-tests/src/chains/rococo/mod.rs +++ b/emulated-integration-tests/src/chains/rococo/mod.rs @@ -2,30 +2,30 @@ pub mod genesis; // Cumulus use emulated_integration_tests_common::{ - impl_accounts_helpers_for_relay_chain, impl_assert_events_helpers_for_relay_chain, - impl_hrmp_channels_helpers_for_relay_chain, impl_send_transact_helpers_for_relay_chain, - xcm_emulator::decl_test_relay_chains, + impl_accounts_helpers_for_relay_chain, impl_assert_events_helpers_for_relay_chain, + impl_hrmp_channels_helpers_for_relay_chain, impl_send_transact_helpers_for_relay_chain, + xcm_emulator::decl_test_relay_chains, }; // Rococo declaration decl_test_relay_chains! { - #[api_version(10)] - pub struct Rococo { - genesis = genesis::genesis(), - on_init = (), - runtime = rococo_runtime, - core = { - SovereignAccountOf: rococo_runtime::xcm_config::LocationConverter, - }, - pallets = { - XcmPallet: rococo_runtime::XcmPallet, - Sudo: rococo_runtime::Sudo, - Balances: rococo_runtime::Balances, - Hrmp: rococo_runtime::Hrmp, - Identity: rococo_runtime::Identity, - IdentityMigrator: rococo_runtime::IdentityMigrator, - } - }, + #[api_version(10)] + pub struct Rococo { + genesis = genesis::genesis(), + on_init = (), + runtime = rococo_runtime, + core = { + SovereignAccountOf: rococo_runtime::xcm_config::LocationConverter, + }, + pallets = { + XcmPallet: rococo_runtime::XcmPallet, + Sudo: rococo_runtime::Sudo, + Balances: rococo_runtime::Balances, + Hrmp: rococo_runtime::Hrmp, + Identity: rococo_runtime::Identity, + IdentityMigrator: rococo_runtime::IdentityMigrator, + } + }, } // Rococo implementation diff --git a/emulated-integration-tests/src/lib.rs b/emulated-integration-tests/src/lib.rs index e2fcffd46..4d37828fa 100644 --- a/emulated-integration-tests/src/lib.rs +++ b/emulated-integration-tests/src/lib.rs @@ -3,10 +3,10 @@ mod rococo_network; // Substrate pub use frame_support::{ - assert_err, - pallet_prelude::Weight, - sp_runtime::{DispatchError, DispatchResult}, - traits::fungibles::Inspect, + assert_err, + pallet_prelude::Weight, + sp_runtime::{DispatchError, DispatchResult}, + traits::fungibles::Inspect, }; // Polkadot @@ -14,21 +14,21 @@ pub use xcm::prelude::{AccountId32 as AccountId32Junction, *}; // Cumulus pub use crate::rococo_network::{ - asset_hub_rococo::{ - genesis::ED as ASSET_HUB_ROCOCO_ED, AssetHubRococoParaPallet as AssetHubRococoPallet, - }, - pop_network::PopNetworkParaPallet as PopNetworkPallet, - rococo::{genesis::ED as ROCOCO_ED, RococoRelayPallet as RococoPallet}, - AssetHubRococoPara as AssetHubRococo, AssetHubRococoParaReceiver as AssetHubRococoReceiver, - AssetHubRococoParaSender as AssetHubRococoSender, PopNetworkPara as PopNetwork, - PopNetworkParaReceiver as PopNetworkReceiver, PopNetworkParaSender as PopNetworkSender, - RococoRelay as Rococo, RococoRelayReceiver as RococoReceiver, - RococoRelaySender as RococoSender, + asset_hub_rococo::{ + genesis::ED as ASSET_HUB_ROCOCO_ED, AssetHubRococoParaPallet as AssetHubRococoPallet, + }, + pop_network::PopNetworkParaPallet as PopNetworkPallet, + rococo::{genesis::ED as ROCOCO_ED, RococoRelayPallet as RococoPallet}, + AssetHubRococoPara as AssetHubRococo, AssetHubRococoParaReceiver as AssetHubRococoReceiver, + AssetHubRococoParaSender as AssetHubRococoSender, PopNetworkPara as PopNetwork, + PopNetworkParaReceiver as PopNetworkReceiver, PopNetworkParaSender as PopNetworkSender, + RococoRelay as Rococo, RococoRelayReceiver as RococoReceiver, + RococoRelaySender as RococoSender, }; pub use asset_test_utils::xcm_helpers; pub use emulated_integration_tests_common::xcm_emulator::{ - assert_expected_events, bx, Chain, Parachain as Para, RelayChain as Relay, Test, TestArgs, - TestContext, TestExt, + assert_expected_events, bx, Chain, Parachain as Para, RelayChain as Relay, Test, TestArgs, + TestContext, TestExt, }; pub use parachains_common::Balance; @@ -43,232 +43,238 @@ pub type ParaToSystemParaTest = Test; #[cfg(test)] mod tests { - use super::*; - - use asset_hub_rococo_runtime::xcm_config::XcmConfig as AssetHubRococoXcmConfig; - use pop_runtime::xcm_config::XcmConfig as PopNetworkXcmConfig; - use rococo_runtime::xcm_config::XcmConfig as RococoXcmConfig; - - fn relay_to_para_sender_assertions(t: RelayToParaTest) { - type RuntimeEvent = ::RuntimeEvent; - Rococo::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts(864_610_000, 8_799))); - assert_expected_events!( - Rococo, - vec![ - // Amount to reserve transfer is transferred to Parachain's Sovereign account - RuntimeEvent::Balances( - pallet_balances::Event::Transfer { from, to, amount } - ) => { - from: *from == t.sender.account_id, - to: *to == Rococo::sovereign_account_id_of( - t.args.dest.clone() - ), - amount: *amount == t.args.amount, - }, - ] - ); - } - - fn system_para_to_para_sender_assertions(t: SystemParaToParaTest) { - type RuntimeEvent = ::RuntimeEvent; - AssetHubRococo::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts( - 864_610_000, - 8_799, - ))); - assert_expected_events!( - AssetHubRococo, - vec![ - // Amount to reserve transfer is transferred to Parachain's Sovereign account - RuntimeEvent::Balances( - pallet_balances::Event::Transfer { from, to, amount } - ) => { - from: *from == t.sender.account_id, - to: *to == AssetHubRococo::sovereign_account_id_of( - t.args.dest.clone() - ), - amount: *amount == t.args.amount, - }, - ] - ); - } - - fn para_receiver_assertions(_: Test) { - type RuntimeEvent = ::RuntimeEvent; - assert_expected_events!( - PopNetwork, - vec![ - RuntimeEvent::Balances(pallet_balances::Event::Deposit { .. }) => {}, - RuntimeEvent::MessageQueue( - pallet_message_queue::Event::Processed { success: true, .. } - ) => {}, - ] - ); - } - - fn para_to_system_para_sender_assertions(t: ParaToSystemParaTest) { - type RuntimeEvent = ::RuntimeEvent; - PopNetwork::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts( - 864_610_000, - 8_799, - ))); - assert_expected_events!( - PopNetwork, - vec![ - // Amount to reserve transfer is transferred to Parachain's Sovereign account - RuntimeEvent::Balances( - pallet_balances::Event::Withdraw { who, amount } - ) => { - who: *who == t.sender.account_id, - amount: *amount == t.args.amount, - }, - ] - ); - } - - fn para_to_system_para_receiver_assertions(t: ParaToSystemParaTest) { - type RuntimeEvent = ::RuntimeEvent; - let sov_pop_net_on_ahr = AssetHubRococo::sovereign_account_id_of( - AssetHubRococo::sibling_location_of(PopNetwork::para_id()), - ); - assert_expected_events!( - AssetHubRococo, - vec![ - // Amount to reserve transfer is withdrawn from Parachain's Sovereign account - RuntimeEvent::Balances( - pallet_balances::Event::Withdraw { who, amount } - ) => { - who: *who == sov_pop_net_on_ahr.clone().into(), - amount: *amount == t.args.amount, - }, - RuntimeEvent::Balances(pallet_balances::Event::Deposit { .. }) => {}, - RuntimeEvent::MessageQueue( - pallet_message_queue::Event::Processed { success: true, .. } - ) => {}, - ] - ); - } - - fn system_para_to_para_assets_sender_assertions(t: SystemParaToParaTest) { - type RuntimeEvent = ::RuntimeEvent; - AssetHubRococo::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts( - 864_610_000, - 8799, - ))); - assert_expected_events!( - AssetHubRococo, - vec![ - // Amount to reserve transfer is transferred to Parachain's Sovereign account - RuntimeEvent::Assets( - pallet_assets::Event::Transferred { asset_id, from, to, amount } - ) => { - asset_id: *asset_id == ASSET_ID, - from: *from == t.sender.account_id, - to: *to == AssetHubRococo::sovereign_account_id_of( - t.args.dest.clone() - ), - amount: *amount == t.args.amount, - }, - ] - ); - } - - fn system_para_to_para_assets_receiver_assertions(_: Test) { - type RuntimeEvent = ::RuntimeEvent; - assert_expected_events!( - PopNetwork, - vec![ - RuntimeEvent::Balances(pallet_balances::Event::Deposit { .. }) => {}, - RuntimeEvent::Assets(pallet_assets::Event::Issued { .. }) => {}, - RuntimeEvent::MessageQueue( - pallet_message_queue::Event::Processed { success: true, .. } - ) => {}, - ] - ); - } - - fn relay_to_para_reserve_transfer_assets(t: RelayToParaTest) -> DispatchResult { - ::XcmPallet::limited_reserve_transfer_assets( - t.signed_origin, - bx!(t.args.dest.into()), - bx!(t.args.beneficiary.into()), - bx!(t.args.assets.into()), - t.args.fee_asset_item, - t.args.weight_limit, - ) - } - - fn system_para_to_para_reserve_transfer_assets(t: SystemParaToParaTest) -> DispatchResult { - ::PolkadotXcm::limited_reserve_transfer_assets( - t.signed_origin, - bx!(t.args.dest.into()), - bx!(t.args.beneficiary.into()), - bx!(t.args.assets.into()), - t.args.fee_asset_item, - t.args.weight_limit, - ) - } - - fn para_to_system_para_reserve_transfer_assets(t: ParaToSystemParaTest) -> DispatchResult { - ::PolkadotXcm::limited_reserve_transfer_assets( - t.signed_origin, - bx!(t.args.dest.into()), - bx!(t.args.beneficiary.into()), - bx!(t.args.assets.into()), - t.args.fee_asset_item, - t.args.weight_limit, - ) - } - - /// Reserve Transfers of native asset from Relay Chain to the System Parachain shouldn't work - #[test] - fn reserve_transfer_native_asset_from_relay_to_system_para_fails() { - let signed_origin = ::RuntimeOrigin::signed(RococoSender::get().into()); - let destination = Rococo::child_location_of(AssetHubRococo::para_id()); - let beneficiary: Location = - AccountId32Junction { network: None, id: AssetHubRococoReceiver::get().into() }.into(); - let amount_to_send: Balance = ROCOCO_ED * 1000; - let assets: Assets = (Here, amount_to_send).into(); - let fee_asset_item = 0; - - // this should fail - Rococo::execute_with(|| { - let result = ::XcmPallet::limited_reserve_transfer_assets( - signed_origin, - bx!(destination.into()), - bx!(beneficiary.into()), - bx!(assets.into()), - fee_asset_item, - WeightLimit::Unlimited, - ); - assert_err!( - result, - DispatchError::Module(sp_runtime::ModuleError { - index: 99, - error: [2, 0, 0, 0], - message: Some("Filtered") - }) - ); - }); - } - - /// Reserve Transfers of native asset from System Parachain to Relay Chain shouldn't work - #[test] - fn reserve_transfer_native_asset_from_system_para_to_relay_fails() { - // Init values for System Parachain - let signed_origin = - ::RuntimeOrigin::signed(AssetHubRococoSender::get().into()); - let destination = AssetHubRococo::parent_location(); - let beneficiary_id = RococoReceiver::get(); - let beneficiary: Location = - AccountId32Junction { network: None, id: beneficiary_id.into() }.into(); - let amount_to_send: Balance = ASSET_HUB_ROCOCO_ED * 1000; - - let assets: Assets = (Parent, amount_to_send).into(); - let fee_asset_item = 0; - - // this should fail - AssetHubRococo::execute_with(|| { - let result = + use super::*; + + use asset_hub_rococo_runtime::xcm_config::XcmConfig as AssetHubRococoXcmConfig; + use pop_runtime::xcm_config::XcmConfig as PopNetworkXcmConfig; + use rococo_runtime::xcm_config::XcmConfig as RococoXcmConfig; + + fn relay_to_para_sender_assertions(t: RelayToParaTest) { + type RuntimeEvent = ::RuntimeEvent; + Rococo::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts(864_610_000, 8_799))); + assert_expected_events!( + Rococo, + vec![ + // Amount to reserve transfer is transferred to Parachain's Sovereign account + RuntimeEvent::Balances( + pallet_balances::Event::Transfer { from, to, amount } + ) => { + from: *from == t.sender.account_id, + to: *to == Rococo::sovereign_account_id_of( + t.args.dest.clone() + ), + amount: *amount == t.args.amount, + }, + ] + ); + } + + fn system_para_to_para_sender_assertions(t: SystemParaToParaTest) { + type RuntimeEvent = ::RuntimeEvent; + AssetHubRococo::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts( + 864_610_000, + 8_799, + ))); + assert_expected_events!( + AssetHubRococo, + vec![ + // Amount to reserve transfer is transferred to Parachain's Sovereign account + RuntimeEvent::Balances( + pallet_balances::Event::Transfer { from, to, amount } + ) => { + from: *from == t.sender.account_id, + to: *to == AssetHubRococo::sovereign_account_id_of( + t.args.dest.clone() + ), + amount: *amount == t.args.amount, + }, + ] + ); + } + + fn para_receiver_assertions(_: Test) { + type RuntimeEvent = ::RuntimeEvent; + assert_expected_events!( + PopNetwork, + vec![ + RuntimeEvent::Balances(pallet_balances::Event::Deposit { .. }) => {}, + RuntimeEvent::MessageQueue( + pallet_message_queue::Event::Processed { success: true, .. } + ) => {}, + ] + ); + } + + fn para_to_system_para_sender_assertions(t: ParaToSystemParaTest) { + type RuntimeEvent = ::RuntimeEvent; + PopNetwork::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts( + 864_610_000, + 8_799, + ))); + assert_expected_events!( + PopNetwork, + vec![ + // Amount to reserve transfer is transferred to Parachain's Sovereign account + RuntimeEvent::Balances( + pallet_balances::Event::Withdraw { who, amount } + ) => { + who: *who == t.sender.account_id, + amount: *amount == t.args.amount, + }, + ] + ); + } + + fn para_to_system_para_receiver_assertions(t: ParaToSystemParaTest) { + type RuntimeEvent = ::RuntimeEvent; + let sov_pop_net_on_ahr = AssetHubRococo::sovereign_account_id_of( + AssetHubRococo::sibling_location_of(PopNetwork::para_id()), + ); + assert_expected_events!( + AssetHubRococo, + vec![ + // Amount to reserve transfer is withdrawn from Parachain's Sovereign account + RuntimeEvent::Balances( + pallet_balances::Event::Withdraw { who, amount } + ) => { + who: *who == sov_pop_net_on_ahr.clone().into(), + amount: *amount == t.args.amount, + }, + RuntimeEvent::Balances(pallet_balances::Event::Deposit { .. }) => {}, + RuntimeEvent::MessageQueue( + pallet_message_queue::Event::Processed { success: true, .. } + ) => {}, + ] + ); + } + + fn system_para_to_para_assets_sender_assertions(t: SystemParaToParaTest) { + type RuntimeEvent = ::RuntimeEvent; + AssetHubRococo::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts( + 864_610_000, + 8799, + ))); + assert_expected_events!( + AssetHubRococo, + vec![ + // Amount to reserve transfer is transferred to Parachain's Sovereign account + RuntimeEvent::Assets( + pallet_assets::Event::Transferred { asset_id, from, to, amount } + ) => { + asset_id: *asset_id == ASSET_ID, + from: *from == t.sender.account_id, + to: *to == AssetHubRococo::sovereign_account_id_of( + t.args.dest.clone() + ), + amount: *amount == t.args.amount, + }, + ] + ); + } + + fn system_para_to_para_assets_receiver_assertions(_: Test) { + type RuntimeEvent = ::RuntimeEvent; + assert_expected_events!( + PopNetwork, + vec![ + RuntimeEvent::Balances(pallet_balances::Event::Deposit { .. }) => {}, + RuntimeEvent::Assets(pallet_assets::Event::Issued { .. }) => {}, + RuntimeEvent::MessageQueue( + pallet_message_queue::Event::Processed { success: true, .. } + ) => {}, + ] + ); + } + + fn relay_to_para_reserve_transfer_assets(t: RelayToParaTest) -> DispatchResult { + ::XcmPallet::limited_reserve_transfer_assets( + t.signed_origin, + bx!(t.args.dest.into()), + bx!(t.args.beneficiary.into()), + bx!(t.args.assets.into()), + t.args.fee_asset_item, + t.args.weight_limit, + ) + } + + fn system_para_to_para_reserve_transfer_assets(t: SystemParaToParaTest) -> DispatchResult { + ::PolkadotXcm::limited_reserve_transfer_assets( + t.signed_origin, + bx!(t.args.dest.into()), + bx!(t.args.beneficiary.into()), + bx!(t.args.assets.into()), + t.args.fee_asset_item, + t.args.weight_limit, + ) + } + + fn para_to_system_para_reserve_transfer_assets(t: ParaToSystemParaTest) -> DispatchResult { + ::PolkadotXcm::limited_reserve_transfer_assets( + t.signed_origin, + bx!(t.args.dest.into()), + bx!(t.args.beneficiary.into()), + bx!(t.args.assets.into()), + t.args.fee_asset_item, + t.args.weight_limit, + ) + } + + /// Reserve Transfers of native asset from Relay Chain to the System Parachain shouldn't work + #[test] + fn reserve_transfer_native_asset_from_relay_to_system_para_fails() { + let signed_origin = ::RuntimeOrigin::signed(RococoSender::get().into()); + let destination = Rococo::child_location_of(AssetHubRococo::para_id()); + let beneficiary: Location = AccountId32Junction { + network: None, + id: AssetHubRococoReceiver::get().into(), + } + .into(); + let amount_to_send: Balance = ROCOCO_ED * 1000; + let assets: Assets = (Here, amount_to_send).into(); + let fee_asset_item = 0; + + // this should fail + Rococo::execute_with(|| { + let result = ::XcmPallet::limited_reserve_transfer_assets( + signed_origin, + bx!(destination.into()), + bx!(beneficiary.into()), + bx!(assets.into()), + fee_asset_item, + WeightLimit::Unlimited, + ); + assert_err!( + result, + DispatchError::Module(sp_runtime::ModuleError { + index: 99, + error: [2, 0, 0, 0], + message: Some("Filtered") + }) + ); + }); + } + + /// Reserve Transfers of native asset from System Parachain to Relay Chain shouldn't work + #[test] + fn reserve_transfer_native_asset_from_system_para_to_relay_fails() { + // Init values for System Parachain + let signed_origin = + ::RuntimeOrigin::signed(AssetHubRococoSender::get().into()); + let destination = AssetHubRococo::parent_location(); + let beneficiary_id = RococoReceiver::get(); + let beneficiary: Location = AccountId32Junction { + network: None, + id: beneficiary_id.into(), + } + .into(); + let amount_to_send: Balance = ASSET_HUB_ROCOCO_ED * 1000; + + let assets: Assets = (Parent, amount_to_send).into(); + let fee_asset_item = 0; + + // this should fail + AssetHubRococo::execute_with(|| { + let result = ::PolkadotXcm::limited_reserve_transfer_assets( signed_origin, bx!(destination.into()), @@ -277,277 +283,295 @@ mod tests { fee_asset_item, WeightLimit::Unlimited, ); - assert_err!( - result, - DispatchError::Module(sp_runtime::ModuleError { - index: 31, - error: [2, 0, 0, 0], - message: Some("Filtered") - }) - ); - }); - } - - /// Reserve Transfers of native asset from Relay to Parachain should work - #[test] - fn reserve_transfer_native_asset_from_relay_to_para() { - // Init values for Relay - let destination = Rococo::child_location_of(PopNetwork::para_id()); - let beneficiary_id = PopNetworkReceiver::get(); - let amount_to_send: Balance = ROCOCO_ED * 1000; - - let test_args = TestContext { - sender: RococoSender::get(), - receiver: PopNetworkReceiver::get(), - args: TestArgs::new_relay(destination, beneficiary_id, amount_to_send), - }; - - let mut test = RelayToParaTest::new(test_args); - - let sender_balance_before = test.sender.balance; - let receiver_balance_before = test.receiver.balance; - - test.set_assertion::(relay_to_para_sender_assertions); - test.set_assertion::(para_receiver_assertions); - test.set_dispatchable::(relay_to_para_reserve_transfer_assets); - test.assert(); - - let delivery_fees = Rococo::execute_with(|| { - xcm_helpers::transfer_assets_delivery_fees::< - ::XcmSender, - >( - test.args.assets.clone(), - 0, - test.args.weight_limit, - test.args.beneficiary, - test.args.dest, - ) - }); - - let sender_balance_after = test.sender.balance; - let receiver_balance_after = test.receiver.balance; - - // Sender's balance is reduced - assert_eq!(sender_balance_before - amount_to_send - delivery_fees, sender_balance_after); - // Receiver's balance is increased - assert!(receiver_balance_after > receiver_balance_before); - // Receiver's balance increased by `amount_to_send - delivery_fees - bought_execution`; - // `delivery_fees` might be paid from transfer or JIT, also `bought_execution` is unknown - // but should be non-zero - assert!(receiver_balance_after < receiver_balance_before + amount_to_send); - } - - /// Reserve Transfers of native asset from System Parachain to Parachain should work - #[test] - fn reserve_transfer_native_asset_from_system_para_to_para() { - // Init values for System Parachain - let destination = AssetHubRococo::sibling_location_of(PopNetwork::para_id()); - let beneficiary_id = PopNetworkReceiver::get(); - let amount_to_send: Balance = ASSET_HUB_ROCOCO_ED * 1000; - let assets = (Parent, amount_to_send).into(); - - let test_args = TestContext { - sender: AssetHubRococoSender::get(), - receiver: PopNetworkReceiver::get(), - args: TestArgs::new_para(destination, beneficiary_id, amount_to_send, assets, None, 0), - }; - - let mut test = SystemParaToParaTest::new(test_args); - - let sender_balance_before = test.sender.balance; - let receiver_balance_before = test.receiver.balance; - - test.set_assertion::(system_para_to_para_sender_assertions); - test.set_assertion::(para_receiver_assertions); - test.set_dispatchable::(system_para_to_para_reserve_transfer_assets); - test.assert(); - - let sender_balance_after = test.sender.balance; - let receiver_balance_after = test.receiver.balance; - - let delivery_fees = AssetHubRococo::execute_with(|| { - xcm_helpers::transfer_assets_delivery_fees::< - ::XcmSender, - >( - test.args.assets.clone(), - 0, - test.args.weight_limit, - test.args.beneficiary, - test.args.dest, - ) - }); - - // Sender's balance is reduced - assert_eq!(sender_balance_before - amount_to_send - delivery_fees, sender_balance_after); - // Receiver's balance is increased - assert!(receiver_balance_after > receiver_balance_before); - // Receiver's balance increased by `amount_to_send - delivery_fees - bought_execution`; - // `delivery_fees` might be paid from transfer or JIT, also `bought_execution` is unknown - // but should be non-zero - assert!(receiver_balance_after < receiver_balance_before + amount_to_send); - } - - /// Reserve Transfers of native asset from Parachain to System Parachain should work - #[test] - fn reserve_transfer_native_asset_from_para_to_system_para() { - // Init values for Pop Network Parachain - let destination = PopNetwork::sibling_location_of(AssetHubRococo::para_id()); - let beneficiary_id = AssetHubRococoReceiver::get(); - let amount_to_send: Balance = ASSET_HUB_ROCOCO_ED * 1000; - let assets = (Parent, amount_to_send).into(); - - let test_args = TestContext { - sender: PopNetworkSender::get(), - receiver: AssetHubRococoReceiver::get(), - args: TestArgs::new_para(destination, beneficiary_id, amount_to_send, assets, None, 0), - }; - - let mut test = ParaToSystemParaTest::new(test_args); - - let sender_balance_before = test.sender.balance; - let receiver_balance_before = test.receiver.balance; - - let pop_net_location_as_seen_by_ahr = - AssetHubRococo::sibling_location_of(PopNetwork::para_id()); - let sov_pop_net_on_ahr = - AssetHubRococo::sovereign_account_id_of(pop_net_location_as_seen_by_ahr); - - // fund the Pop Network's SA on AHR with the native tokens held in reserve - AssetHubRococo::fund_accounts(vec![(sov_pop_net_on_ahr.into(), amount_to_send * 2)]); - - test.set_assertion::(para_to_system_para_sender_assertions); - test.set_assertion::(para_to_system_para_receiver_assertions); - test.set_dispatchable::(para_to_system_para_reserve_transfer_assets); - test.assert(); - - let sender_balance_after = test.sender.balance; - let receiver_balance_after = test.receiver.balance; - - let delivery_fees = PopNetwork::execute_with(|| { - xcm_helpers::transfer_assets_delivery_fees::< - ::XcmSender, - >( - test.args.assets.clone(), - 0, - test.args.weight_limit, - test.args.beneficiary, - test.args.dest, - ) - }); - - // Sender's balance is reduced - assert_eq!(sender_balance_before - amount_to_send - delivery_fees, sender_balance_after); - // Receiver's balance is increased - assert!(receiver_balance_after > receiver_balance_before); - // Receiver's balance increased by `amount_to_send - delivery_fees - bought_execution`; - // `delivery_fees` might be paid from transfer or JIT, also `bought_execution` is unknown - // but should be non-zero - assert!(receiver_balance_after < receiver_balance_before + amount_to_send); - } - - /// Reserve Transfers of a local asset and native asset from System Parachain to Parachain - /// should work - #[test] - fn reserve_transfer_assets_from_system_para_to_para() { - // Force create asset on AssetHubRococo and PopNetwork from Relay Chain - AssetHubRococo::force_create_and_mint_asset( - ASSET_ID, - ASSET_MIN_BALANCE, - false, - AssetHubRococoSender::get(), - Some(Weight::from_parts(1_019_445_000, 200_000)), - ASSET_MIN_BALANCE * 1_000_000, - ); - PopNetwork::force_create_and_mint_asset( - ASSET_ID, - ASSET_MIN_BALANCE, - false, - PopNetworkSender::get(), - None, - 0, - ); - - // Init values for System Parachain - let destination = AssetHubRococo::sibling_location_of(PopNetwork::para_id()); - let beneficiary_id = PopNetworkReceiver::get(); - let fee_amount_to_send = ASSET_HUB_ROCOCO_ED * 1000; - let asset_amount_to_send = ASSET_MIN_BALANCE * 1000; - let assets: Assets = vec![ - (Parent, fee_amount_to_send).into(), - ( - [PalletInstance(ASSETS_PALLET_ID), GeneralIndex(ASSET_ID.into())], - asset_amount_to_send, - ) - .into(), - ] - .into(); - let fee_asset_index = assets - .inner() - .iter() - .position(|r| r == &(Parent, fee_amount_to_send).into()) - .unwrap() as u32; - - let para_test_args = TestContext { - sender: AssetHubRococoSender::get(), - receiver: PopNetworkReceiver::get(), - args: TestArgs::new_para( - destination, - beneficiary_id, - asset_amount_to_send, - assets, - None, - fee_asset_index, - ), - }; - - let mut test = SystemParaToParaTest::new(para_test_args); - - // Create SA-of-Pop Network-on-AHR with ED. - let pop_net_location = AssetHubRococo::sibling_location_of(PopNetwork::para_id()); - let sov_pop_net_on_ahr = AssetHubRococo::sovereign_account_id_of(pop_net_location); - AssetHubRococo::fund_accounts(vec![(sov_pop_net_on_ahr.into(), ROCOCO_ED)]); - - let sender_balance_before = test.sender.balance; - let receiver_balance_before = test.receiver.balance; - - let sender_assets_before = AssetHubRococo::execute_with(|| { - type Assets = ::Assets; - >::balance(ASSET_ID, &AssetHubRococoSender::get()) - }); - let receiver_assets_before = PopNetwork::execute_with(|| { - type Assets = ::Assets; - >::balance(ASSET_ID, &PopNetworkReceiver::get()) - }); - - test.set_assertion::(system_para_to_para_assets_sender_assertions); - test.set_assertion::(system_para_to_para_assets_receiver_assertions); - test.set_dispatchable::(system_para_to_para_reserve_transfer_assets); - test.assert(); - - let sender_balance_after = test.sender.balance; - let receiver_balance_after = test.receiver.balance; - - // Sender's balance is reduced - assert!(sender_balance_after < sender_balance_before); - // Receiver's balance is increased - assert!(receiver_balance_after > receiver_balance_before); - // Receiver's balance increased by `amount_to_send - delivery_fees - bought_execution`; - // `delivery_fees` might be paid from transfer or JIT, also `bought_execution` is unknown - // but should be non-zero - assert!(receiver_balance_after < receiver_balance_before + fee_amount_to_send); - - let sender_assets_after = AssetHubRococo::execute_with(|| { - type Assets = ::Assets; - >::balance(ASSET_ID, &AssetHubRococoSender::get()) - }); - let receiver_assets_after = PopNetwork::execute_with(|| { - type Assets = ::Assets; - >::balance(ASSET_ID, &PopNetworkReceiver::get()) - }); - - // Sender's balance is reduced by exact amount - assert_eq!(sender_assets_before - asset_amount_to_send, sender_assets_after); - // Receiver's balance is increased by exact amount - assert_eq!(receiver_assets_after, receiver_assets_before + asset_amount_to_send); - } + assert_err!( + result, + DispatchError::Module(sp_runtime::ModuleError { + index: 31, + error: [2, 0, 0, 0], + message: Some("Filtered") + }) + ); + }); + } + + /// Reserve Transfers of native asset from Relay to Parachain should work + #[test] + fn reserve_transfer_native_asset_from_relay_to_para() { + // Init values for Relay + let destination = Rococo::child_location_of(PopNetwork::para_id()); + let beneficiary_id = PopNetworkReceiver::get(); + let amount_to_send: Balance = ROCOCO_ED * 1000; + + let test_args = TestContext { + sender: RococoSender::get(), + receiver: PopNetworkReceiver::get(), + args: TestArgs::new_relay(destination, beneficiary_id, amount_to_send), + }; + + let mut test = RelayToParaTest::new(test_args); + + let sender_balance_before = test.sender.balance; + let receiver_balance_before = test.receiver.balance; + + test.set_assertion::(relay_to_para_sender_assertions); + test.set_assertion::(para_receiver_assertions); + test.set_dispatchable::(relay_to_para_reserve_transfer_assets); + test.assert(); + + let delivery_fees = Rococo::execute_with(|| { + xcm_helpers::transfer_assets_delivery_fees::< + ::XcmSender, + >( + test.args.assets.clone(), + 0, + test.args.weight_limit, + test.args.beneficiary, + test.args.dest, + ) + }); + + let sender_balance_after = test.sender.balance; + let receiver_balance_after = test.receiver.balance; + + // Sender's balance is reduced + assert_eq!( + sender_balance_before - amount_to_send - delivery_fees, + sender_balance_after + ); + // Receiver's balance is increased + assert!(receiver_balance_after > receiver_balance_before); + // Receiver's balance increased by `amount_to_send - delivery_fees - bought_execution`; + // `delivery_fees` might be paid from transfer or JIT, also `bought_execution` is unknown + // but should be non-zero + assert!(receiver_balance_after < receiver_balance_before + amount_to_send); + } + + /// Reserve Transfers of native asset from System Parachain to Parachain should work + #[test] + fn reserve_transfer_native_asset_from_system_para_to_para() { + // Init values for System Parachain + let destination = AssetHubRococo::sibling_location_of(PopNetwork::para_id()); + let beneficiary_id = PopNetworkReceiver::get(); + let amount_to_send: Balance = ASSET_HUB_ROCOCO_ED * 1000; + let assets = (Parent, amount_to_send).into(); + + let test_args = TestContext { + sender: AssetHubRococoSender::get(), + receiver: PopNetworkReceiver::get(), + args: TestArgs::new_para(destination, beneficiary_id, amount_to_send, assets, None, 0), + }; + + let mut test = SystemParaToParaTest::new(test_args); + + let sender_balance_before = test.sender.balance; + let receiver_balance_before = test.receiver.balance; + + test.set_assertion::(system_para_to_para_sender_assertions); + test.set_assertion::(para_receiver_assertions); + test.set_dispatchable::(system_para_to_para_reserve_transfer_assets); + test.assert(); + + let sender_balance_after = test.sender.balance; + let receiver_balance_after = test.receiver.balance; + + let delivery_fees = AssetHubRococo::execute_with(|| { + xcm_helpers::transfer_assets_delivery_fees::< + ::XcmSender, + >( + test.args.assets.clone(), + 0, + test.args.weight_limit, + test.args.beneficiary, + test.args.dest, + ) + }); + + // Sender's balance is reduced + assert_eq!( + sender_balance_before - amount_to_send - delivery_fees, + sender_balance_after + ); + // Receiver's balance is increased + assert!(receiver_balance_after > receiver_balance_before); + // Receiver's balance increased by `amount_to_send - delivery_fees - bought_execution`; + // `delivery_fees` might be paid from transfer or JIT, also `bought_execution` is unknown + // but should be non-zero + assert!(receiver_balance_after < receiver_balance_before + amount_to_send); + } + + /// Reserve Transfers of native asset from Parachain to System Parachain should work + #[test] + fn reserve_transfer_native_asset_from_para_to_system_para() { + // Init values for Pop Network Parachain + let destination = PopNetwork::sibling_location_of(AssetHubRococo::para_id()); + let beneficiary_id = AssetHubRococoReceiver::get(); + let amount_to_send: Balance = ASSET_HUB_ROCOCO_ED * 1000; + let assets = (Parent, amount_to_send).into(); + + let test_args = TestContext { + sender: PopNetworkSender::get(), + receiver: AssetHubRococoReceiver::get(), + args: TestArgs::new_para(destination, beneficiary_id, amount_to_send, assets, None, 0), + }; + + let mut test = ParaToSystemParaTest::new(test_args); + + let sender_balance_before = test.sender.balance; + let receiver_balance_before = test.receiver.balance; + + let pop_net_location_as_seen_by_ahr = + AssetHubRococo::sibling_location_of(PopNetwork::para_id()); + let sov_pop_net_on_ahr = + AssetHubRococo::sovereign_account_id_of(pop_net_location_as_seen_by_ahr); + + // fund the Pop Network's SA on AHR with the native tokens held in reserve + AssetHubRococo::fund_accounts(vec![(sov_pop_net_on_ahr.into(), amount_to_send * 2)]); + + test.set_assertion::(para_to_system_para_sender_assertions); + test.set_assertion::(para_to_system_para_receiver_assertions); + test.set_dispatchable::(para_to_system_para_reserve_transfer_assets); + test.assert(); + + let sender_balance_after = test.sender.balance; + let receiver_balance_after = test.receiver.balance; + + let delivery_fees = PopNetwork::execute_with(|| { + xcm_helpers::transfer_assets_delivery_fees::< + ::XcmSender, + >( + test.args.assets.clone(), + 0, + test.args.weight_limit, + test.args.beneficiary, + test.args.dest, + ) + }); + + // Sender's balance is reduced + assert_eq!( + sender_balance_before - amount_to_send - delivery_fees, + sender_balance_after + ); + // Receiver's balance is increased + assert!(receiver_balance_after > receiver_balance_before); + // Receiver's balance increased by `amount_to_send - delivery_fees - bought_execution`; + // `delivery_fees` might be paid from transfer or JIT, also `bought_execution` is unknown + // but should be non-zero + assert!(receiver_balance_after < receiver_balance_before + amount_to_send); + } + + /// Reserve Transfers of a local asset and native asset from System Parachain to Parachain + /// should work + #[test] + fn reserve_transfer_assets_from_system_para_to_para() { + // Force create asset on AssetHubRococo and PopNetwork from Relay Chain + AssetHubRococo::force_create_and_mint_asset( + ASSET_ID, + ASSET_MIN_BALANCE, + false, + AssetHubRococoSender::get(), + Some(Weight::from_parts(1_019_445_000, 200_000)), + ASSET_MIN_BALANCE * 1_000_000, + ); + PopNetwork::force_create_and_mint_asset( + ASSET_ID, + ASSET_MIN_BALANCE, + false, + PopNetworkSender::get(), + None, + 0, + ); + + // Init values for System Parachain + let destination = AssetHubRococo::sibling_location_of(PopNetwork::para_id()); + let beneficiary_id = PopNetworkReceiver::get(); + let fee_amount_to_send = ASSET_HUB_ROCOCO_ED * 1000; + let asset_amount_to_send = ASSET_MIN_BALANCE * 1000; + let assets: Assets = vec![ + (Parent, fee_amount_to_send).into(), + ( + [ + PalletInstance(ASSETS_PALLET_ID), + GeneralIndex(ASSET_ID.into()), + ], + asset_amount_to_send, + ) + .into(), + ] + .into(); + let fee_asset_index = assets + .inner() + .iter() + .position(|r| r == &(Parent, fee_amount_to_send).into()) + .unwrap() as u32; + + let para_test_args = TestContext { + sender: AssetHubRococoSender::get(), + receiver: PopNetworkReceiver::get(), + args: TestArgs::new_para( + destination, + beneficiary_id, + asset_amount_to_send, + assets, + None, + fee_asset_index, + ), + }; + + let mut test = SystemParaToParaTest::new(para_test_args); + + // Create SA-of-Pop Network-on-AHR with ED. + let pop_net_location = AssetHubRococo::sibling_location_of(PopNetwork::para_id()); + let sov_pop_net_on_ahr = AssetHubRococo::sovereign_account_id_of(pop_net_location); + AssetHubRococo::fund_accounts(vec![(sov_pop_net_on_ahr.into(), ROCOCO_ED)]); + + let sender_balance_before = test.sender.balance; + let receiver_balance_before = test.receiver.balance; + + let sender_assets_before = AssetHubRococo::execute_with(|| { + type Assets = ::Assets; + >::balance(ASSET_ID, &AssetHubRococoSender::get()) + }); + let receiver_assets_before = PopNetwork::execute_with(|| { + type Assets = ::Assets; + >::balance(ASSET_ID, &PopNetworkReceiver::get()) + }); + + test.set_assertion::(system_para_to_para_assets_sender_assertions); + test.set_assertion::(system_para_to_para_assets_receiver_assertions); + test.set_dispatchable::(system_para_to_para_reserve_transfer_assets); + test.assert(); + + let sender_balance_after = test.sender.balance; + let receiver_balance_after = test.receiver.balance; + + // Sender's balance is reduced + assert!(sender_balance_after < sender_balance_before); + // Receiver's balance is increased + assert!(receiver_balance_after > receiver_balance_before); + // Receiver's balance increased by `amount_to_send - delivery_fees - bought_execution`; + // `delivery_fees` might be paid from transfer or JIT, also `bought_execution` is unknown + // but should be non-zero + assert!(receiver_balance_after < receiver_balance_before + fee_amount_to_send); + + let sender_assets_after = AssetHubRococo::execute_with(|| { + type Assets = ::Assets; + >::balance(ASSET_ID, &AssetHubRococoSender::get()) + }); + let receiver_assets_after = PopNetwork::execute_with(|| { + type Assets = ::Assets; + >::balance(ASSET_ID, &PopNetworkReceiver::get()) + }); + + // Sender's balance is reduced by exact amount + assert_eq!( + sender_assets_before - asset_amount_to_send, + sender_assets_after + ); + // Receiver's balance is increased by exact amount + assert_eq!( + receiver_assets_after, + receiver_assets_before + asset_amount_to_send + ); + } } diff --git a/emulated-integration-tests/src/rococo_network.rs b/emulated-integration-tests/src/rococo_network.rs index a0d90b3ed..3b9e0cfea 100644 --- a/emulated-integration-tests/src/rococo_network.rs +++ b/emulated-integration-tests/src/rococo_network.rs @@ -3,23 +3,23 @@ use crate::chains::{asset_hub_rococo::AssetHubRococo, pop_network::PopNetwork, r // Cumulus use emulated_integration_tests_common::{ - accounts::{ALICE, BOB}, - xcm_emulator::{decl_test_networks, decl_test_sender_receiver_accounts_parameter_types}, + accounts::{ALICE, BOB}, + xcm_emulator::{decl_test_networks, decl_test_sender_receiver_accounts_parameter_types}, }; decl_test_networks! { - pub struct RococoMockNet { - relay_chain = Rococo, - parachains = vec![ - AssetHubRococo, - PopNetwork, - ], - bridge = () - }, + pub struct RococoMockNet { + relay_chain = Rococo, + parachains = vec![ + AssetHubRococo, + PopNetwork, + ], + bridge = () + }, } decl_test_sender_receiver_accounts_parameter_types! { - RococoRelay { sender: ALICE, receiver: BOB }, - AssetHubRococoPara { sender: ALICE, receiver: BOB }, - PopNetworkPara { sender: ALICE, receiver: BOB} + RococoRelay { sender: ALICE, receiver: BOB }, + AssetHubRococoPara { sender: ALICE, receiver: BOB }, + PopNetworkPara { sender: ALICE, receiver: BOB} } From c5aa916528c7396df6823aff3f9d5f802ef84f83 Mon Sep 17 00:00:00 2001 From: R0GUE Date: Thu, 7 Mar 2024 13:15:59 +0700 Subject: [PATCH 05/23] refactor: moved rococo_network.rs to lib.rs + cleaning up --- Cargo.lock | 932 +++++++++++++++++- Cargo.toml | 14 +- emulated-integration-tests/Cargo.toml | 49 +- .../src/chains/asset_hub_rococo/genesis.rs | 13 +- .../src/chains/asset_hub_rococo/mod.rs | 9 +- emulated-integration-tests/src/chains/mod.rs | 6 +- .../src/chains/pop_network/genesis.rs | 15 +- .../src/chains/pop_network/mod.rs | 10 +- .../src/chains/rococo/genesis.rs | 23 +- .../src/chains/rococo/mod.rs | 5 +- emulated-integration-tests/src/lib.rs | 297 +++--- .../src/rococo_network.rs | 25 - node/src/chain_spec.rs | 175 ++-- node/src/lib.rs | 1 + runtime/src/lib.rs | 2 +- 15 files changed, 1221 insertions(+), 355 deletions(-) delete mode 100644 emulated-integration-tests/src/rococo_network.rs create mode 100644 node/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index 3bb824fb4..9def0c9e3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -594,6 +594,139 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b34d609dfbaf33d6889b2b7106d3ca345eacad44200913df5ba02bfd31d2ba9" +[[package]] +name = "asset-hub-rococo-runtime" +version = "0.11.0" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1#2a91d5abdc56ed27dab36030db5fa3c9c92e60a9" +dependencies = [ + "assets-common", + "bp-asset-hub-rococo", + "bp-asset-hub-westend", + "bp-bridge-hub-rococo", + "bp-bridge-hub-westend", + "cumulus-pallet-aura-ext", + "cumulus-pallet-parachain-system", + "cumulus-pallet-session-benchmarking", + "cumulus-pallet-xcm", + "cumulus-pallet-xcmp-queue", + "cumulus-primitives-aura", + "cumulus-primitives-core", + "cumulus-primitives-utility", + "frame-benchmarking", + "frame-executive", + "frame-support", + "frame-system", + "frame-system-benchmarking", + "frame-system-rpc-runtime-api", + "frame-try-runtime", + "hex-literal", + "log", + "pallet-asset-conversion", + "pallet-asset-conversion-tx-payment", + "pallet-assets", + "pallet-aura", + "pallet-authorship", + "pallet-balances", + "pallet-collator-selection", + "pallet-message-queue", + "pallet-multisig", + "pallet-nft-fractionalization", + "pallet-nfts", + "pallet-nfts-runtime-api", + "pallet-proxy", + "pallet-session", + "pallet-state-trie-migration", + "pallet-timestamp", + "pallet-transaction-payment", + "pallet-transaction-payment-rpc-runtime-api", + "pallet-uniques", + "pallet-utility", + "pallet-xcm", + "pallet-xcm-benchmarks", + "pallet-xcm-bridge-hub-router", + "parachains-common", + "parity-scale-codec", + "polkadot-parachain-primitives", + "polkadot-runtime-common", + "primitive-types", + "rococo-runtime-constants", + "scale-info", + "snowbridge-router-primitives", + "sp-api", + "sp-block-builder", + "sp-consensus-aura", + "sp-core 28.0.0", + "sp-genesis-builder", + "sp-inherents", + "sp-offchain", + "sp-runtime 31.0.1", + "sp-session", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1)", + "sp-storage 19.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1)", + "sp-transaction-pool", + "sp-version", + "sp-weights 27.0.0", + "staging-parachain-info", + "staging-xcm", + "staging-xcm-builder", + "staging-xcm-executor", + "substrate-wasm-builder", + "testnet-parachains-constants", +] + +[[package]] +name = "asset-test-utils" +version = "7.0.0" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1#2a91d5abdc56ed27dab36030db5fa3c9c92e60a9" +dependencies = [ + "cumulus-pallet-parachain-system", + "cumulus-pallet-xcmp-queue", + "cumulus-primitives-core", + "frame-support", + "frame-system", + "pallet-asset-conversion", + "pallet-assets", + "pallet-balances", + "pallet-collator-selection", + "pallet-session", + "pallet-xcm", + "pallet-xcm-bridge-hub-router", + "parachains-common", + "parachains-runtimes-test-utils", + "parity-scale-codec", + "sp-io 30.0.0", + "sp-runtime 31.0.1", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1)", + "staging-parachain-info", + "staging-xcm", + "staging-xcm-builder", + "staging-xcm-executor", + "substrate-wasm-builder", +] + +[[package]] +name = "assets-common" +version = "0.7.0" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1#2a91d5abdc56ed27dab36030db5fa3c9c92e60a9" +dependencies = [ + "cumulus-primitives-core", + "frame-support", + "impl-trait-for-tuples", + "log", + "pallet-asset-conversion", + "pallet-xcm", + "parachains-common", + "parity-scale-codec", + "scale-info", + "sp-api", + "sp-runtime 31.0.1", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1)", + "staging-xcm", + "staging-xcm-builder", + "staging-xcm-executor", + "substrate-wasm-builder", +] + [[package]] name = "async-channel" version = "1.9.0" @@ -1111,6 +1244,203 @@ dependencies = [ "thiserror", ] +[[package]] +name = "bp-asset-hub-rococo" +version = "0.4.0" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1#2a91d5abdc56ed27dab36030db5fa3c9c92e60a9" +dependencies = [ + "bp-xcm-bridge-hub-router", + "frame-support", + "parity-scale-codec", + "scale-info", +] + +[[package]] +name = "bp-asset-hub-westend" +version = "0.3.0" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1#2a91d5abdc56ed27dab36030db5fa3c9c92e60a9" +dependencies = [ + "bp-xcm-bridge-hub-router", + "frame-support", + "parity-scale-codec", + "scale-info", +] + +[[package]] +name = "bp-bridge-hub-cumulus" +version = "0.7.0" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1#2a91d5abdc56ed27dab36030db5fa3c9c92e60a9" +dependencies = [ + "bp-messages", + "bp-polkadot-core", + "bp-runtime", + "frame-support", + "frame-system", + "polkadot-primitives", + "sp-api", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1)", +] + +[[package]] +name = "bp-bridge-hub-rococo" +version = "0.7.0" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1#2a91d5abdc56ed27dab36030db5fa3c9c92e60a9" +dependencies = [ + "bp-bridge-hub-cumulus", + "bp-messages", + "bp-runtime", + "frame-support", + "sp-api", + "sp-runtime 31.0.1", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1)", +] + +[[package]] +name = "bp-bridge-hub-westend" +version = "0.3.0" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1#2a91d5abdc56ed27dab36030db5fa3c9c92e60a9" +dependencies = [ + "bp-bridge-hub-cumulus", + "bp-messages", + "bp-runtime", + "frame-support", + "sp-api", + "sp-runtime 31.0.1", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1)", +] + +[[package]] +name = "bp-header-chain" +version = "0.7.0" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1#2a91d5abdc56ed27dab36030db5fa3c9c92e60a9" +dependencies = [ + "bp-runtime", + "finality-grandpa", + "frame-support", + "parity-scale-codec", + "scale-info", + "serde", + "sp-consensus-grandpa", + "sp-core 28.0.0", + "sp-runtime 31.0.1", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1)", +] + +[[package]] +name = "bp-messages" +version = "0.7.0" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1#2a91d5abdc56ed27dab36030db5fa3c9c92e60a9" +dependencies = [ + "bp-header-chain", + "bp-runtime", + "frame-support", + "parity-scale-codec", + "scale-info", + "serde", + "sp-core 28.0.0", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1)", +] + +[[package]] +name = "bp-parachains" +version = "0.7.0" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1#2a91d5abdc56ed27dab36030db5fa3c9c92e60a9" +dependencies = [ + "bp-header-chain", + "bp-polkadot-core", + "bp-runtime", + "frame-support", + "impl-trait-for-tuples", + "parity-scale-codec", + "scale-info", + "sp-core 28.0.0", + "sp-runtime 31.0.1", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1)", +] + +[[package]] +name = "bp-polkadot-core" +version = "0.7.0" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1#2a91d5abdc56ed27dab36030db5fa3c9c92e60a9" +dependencies = [ + "bp-messages", + "bp-runtime", + "frame-support", + "frame-system", + "parity-scale-codec", + "parity-util-mem", + "scale-info", + "serde", + "sp-core 28.0.0", + "sp-runtime 31.0.1", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1)", +] + +[[package]] +name = "bp-relayers" +version = "0.7.0" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1#2a91d5abdc56ed27dab36030db5fa3c9c92e60a9" +dependencies = [ + "bp-messages", + "bp-runtime", + "frame-support", + "parity-scale-codec", + "scale-info", + "sp-runtime 31.0.1", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1)", +] + +[[package]] +name = "bp-runtime" +version = "0.7.0" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1#2a91d5abdc56ed27dab36030db5fa3c9c92e60a9" +dependencies = [ + "frame-support", + "frame-system", + "hash-db", + "impl-trait-for-tuples", + "log", + "num-traits", + "parity-scale-codec", + "scale-info", + "serde", + "sp-core 28.0.0", + "sp-io 30.0.0", + "sp-runtime 31.0.1", + "sp-state-machine 0.35.0", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1)", + "sp-trie 29.0.0", + "trie-db 0.28.0", +] + +[[package]] +name = "bp-test-utils" +version = "0.7.0" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1#2a91d5abdc56ed27dab36030db5fa3c9c92e60a9" +dependencies = [ + "bp-header-chain", + "bp-parachains", + "bp-polkadot-core", + "bp-runtime", + "ed25519-dalek 2.1.1", + "finality-grandpa", + "parity-scale-codec", + "sp-application-crypto 30.0.0", + "sp-consensus-grandpa", + "sp-core 28.0.0", + "sp-runtime 31.0.1", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1)", + "sp-trie 29.0.0", +] + +[[package]] +name = "bp-xcm-bridge-hub" +version = "0.2.0" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1#2a91d5abdc56ed27dab36030db5fa3c9c92e60a9" +dependencies = [ + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1)", +] + [[package]] name = "bp-xcm-bridge-hub-router" version = "0.6.0" @@ -1122,6 +1452,41 @@ dependencies = [ "sp-runtime 31.0.1", ] +[[package]] +name = "bridge-runtime-common" +version = "0.7.0" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1#2a91d5abdc56ed27dab36030db5fa3c9c92e60a9" +dependencies = [ + "bp-header-chain", + "bp-messages", + "bp-parachains", + "bp-polkadot-core", + "bp-relayers", + "bp-runtime", + "bp-xcm-bridge-hub", + "bp-xcm-bridge-hub-router", + "frame-support", + "frame-system", + "hash-db", + "log", + "pallet-bridge-grandpa", + "pallet-bridge-messages", + "pallet-bridge-parachains", + "pallet-bridge-relayers", + "pallet-transaction-payment", + "pallet-utility", + "parity-scale-codec", + "scale-info", + "sp-api", + "sp-core 28.0.0", + "sp-io 30.0.0", + "sp-runtime 31.0.1", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1)", + "sp-trie 29.0.0", + "staging-xcm", + "staging-xcm-builder", +] + [[package]] name = "bs58" version = "0.4.0" @@ -2926,6 +3291,66 @@ dependencies = [ "zeroize", ] +[[package]] +name = "emulated-integration-tests" +version = "0.1.0" +dependencies = [ + "asset-hub-rococo-runtime", + "asset-test-utils", + "cumulus-primitives-core", + "emulated-integration-tests-common", + "frame-support", + "pallet-assets", + "pallet-balances", + "pallet-message-queue", + "parachains-common", + "parity-scale-codec", + "polkadot-primitives", + "pop-runtime", + "rococo-runtime", + "rococo-runtime-constants", + "sp-authority-discovery", + "sp-consensus-babe", + "sp-consensus-beefy", + "sp-consensus-grandpa", + "sp-core 28.0.0", + "sp-runtime 31.0.1", + "staging-xcm", + "staging-xcm-executor", +] + +[[package]] +name = "emulated-integration-tests-common" +version = "3.0.0" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1#2a91d5abdc56ed27dab36030db5fa3c9c92e60a9" +dependencies = [ + "asset-test-utils", + "bp-messages", + "bridge-runtime-common", + "cumulus-pallet-parachain-system", + "cumulus-pallet-xcmp-queue", + "cumulus-primitives-core", + "frame-support", + "pallet-assets", + "pallet-balances", + "pallet-bridge-messages", + "pallet-message-queue", + "pallet-xcm", + "parachains-common", + "parity-scale-codec", + "paste", + "polkadot-primitives", + "polkadot-runtime-parachains", + "polkadot-service", + "sc-consensus-grandpa", + "sp-authority-discovery", + "sp-consensus-babe", + "sp-core 28.0.0", + "sp-runtime 31.0.1", + "staging-xcm", + "xcm-emulator", +] + [[package]] name = "encode_unicode" version = "0.3.6" @@ -3033,6 +3458,47 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "ethabi-decode" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09d398648d65820a727d6a81e58b962f874473396a047e4c30bafe3240953417" +dependencies = [ + "ethereum-types", + "tiny-keccak", +] + +[[package]] +name = "ethbloom" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c22d4b5885b6aa2fe5e8b9329fb8d232bf739e434e6b87347c63bdd00c120f60" +dependencies = [ + "crunchy", + "fixed-hash", + "impl-codec", + "impl-rlp", + "impl-serde", + "scale-info", + "tiny-keccak", +] + +[[package]] +name = "ethereum-types" +version = "0.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02d215cbf040552efcbe99a38372fe80ab9d00268e20012b79fcd0f073edd8ee" +dependencies = [ + "ethbloom", + "fixed-hash", + "impl-codec", + "impl-rlp", + "impl-serde", + "primitive-types", + "scale-info", + "uint", +] + [[package]] name = "event-listener" version = "2.5.3" @@ -4251,6 +4717,26 @@ dependencies = [ "parity-scale-codec", ] +[[package]] +name = "impl-num-traits" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "951641f13f873bff03d4bf19ae8bec531935ac0ac2cc775f84d7edfdcfed3f17" +dependencies = [ + "integer-sqrt", + "num-traits", + "uint", +] + +[[package]] +name = "impl-rlp" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f28220f89297a075ddc7245cd538076ee98b01f2a9c23a53a4f1105d5a322808" +dependencies = [ + "rlp", +] + [[package]] name = "impl-serde" version = "0.4.0" @@ -5449,6 +5935,15 @@ version = "0.4.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" +[[package]] +name = "lru" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6e8aaa3f231bb4bd57b84b2d5dc3ae7f350265df8aa96492e0bc394a1571909" +dependencies = [ + "hashbrown 0.12.3", +] + [[package]] name = "lru" version = "0.10.1" @@ -6301,6 +6796,21 @@ dependencies = [ "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1)", ] +[[package]] +name = "pallet-asset-conversion-tx-payment" +version = "10.0.0" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1#2a91d5abdc56ed27dab36030db5fa3c9c92e60a9" +dependencies = [ + "frame-support", + "frame-system", + "pallet-asset-conversion", + "pallet-transaction-payment", + "parity-scale-codec", + "scale-info", + "sp-runtime 31.0.1", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1)", +] + [[package]] name = "pallet-asset-rate" version = "7.0.0" @@ -6522,6 +7032,86 @@ dependencies = [ "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1)", ] +[[package]] +name = "pallet-bridge-grandpa" +version = "0.7.0" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1#2a91d5abdc56ed27dab36030db5fa3c9c92e60a9" +dependencies = [ + "bp-header-chain", + "bp-runtime", + "bp-test-utils", + "finality-grandpa", + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "sp-consensus-grandpa", + "sp-runtime 31.0.1", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1)", + "sp-trie 29.0.0", +] + +[[package]] +name = "pallet-bridge-messages" +version = "0.7.0" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1#2a91d5abdc56ed27dab36030db5fa3c9c92e60a9" +dependencies = [ + "bp-messages", + "bp-runtime", + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "num-traits", + "parity-scale-codec", + "scale-info", + "sp-runtime 31.0.1", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1)", +] + +[[package]] +name = "pallet-bridge-parachains" +version = "0.7.0" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1#2a91d5abdc56ed27dab36030db5fa3c9c92e60a9" +dependencies = [ + "bp-header-chain", + "bp-parachains", + "bp-polkadot-core", + "bp-runtime", + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "pallet-bridge-grandpa", + "parity-scale-codec", + "scale-info", + "sp-runtime 31.0.1", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1)", + "sp-trie 29.0.0", +] + +[[package]] +name = "pallet-bridge-relayers" +version = "0.7.0" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1#2a91d5abdc56ed27dab36030db5fa3c9c92e60a9" +dependencies = [ + "bp-messages", + "bp-relayers", + "bp-runtime", + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "pallet-bridge-messages", + "parity-scale-codec", + "scale-info", + "sp-arithmetic 23.0.0", + "sp-runtime 31.0.1", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1)", +] + [[package]] name = "pallet-broker" version = "0.6.0" @@ -7400,24 +7990,39 @@ dependencies = [ "parity-scale-codec", "sp-api", "sp-runtime 31.0.1", - "sp-weights 27.0.0", + "sp-weights 27.0.0", +] + +[[package]] +name = "pallet-treasury" +version = "27.0.0" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1#2a91d5abdc56ed27dab36030db5fa3c9c92e60a9" +dependencies = [ + "docify", + "frame-benchmarking", + "frame-support", + "frame-system", + "impl-trait-for-tuples", + "pallet-balances", + "parity-scale-codec", + "scale-info", + "serde", + "sp-core 28.0.0", + "sp-runtime 31.0.1", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1)", ] [[package]] -name = "pallet-treasury" -version = "27.0.0" +name = "pallet-uniques" +version = "28.0.0" source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1#2a91d5abdc56ed27dab36030db5fa3c9c92e60a9" dependencies = [ - "docify", "frame-benchmarking", "frame-support", "frame-system", - "impl-trait-for-tuples", - "pallet-balances", + "log", "parity-scale-codec", "scale-info", - "serde", - "sp-core 28.0.0", "sp-runtime 31.0.1", "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1)", ] @@ -7510,6 +8115,25 @@ dependencies = [ "staging-xcm-executor", ] +[[package]] +name = "pallet-xcm-bridge-hub-router" +version = "0.5.0" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1#2a91d5abdc56ed27dab36030db5fa3c9c92e60a9" +dependencies = [ + "bp-xcm-bridge-hub-router", + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "sp-core 28.0.0", + "sp-runtime 31.0.1", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1)", + "staging-xcm", + "staging-xcm-builder", +] + [[package]] name = "parachains-common" version = "7.0.0" @@ -7541,6 +8165,42 @@ dependencies = [ "substrate-wasm-builder", ] +[[package]] +name = "parachains-runtimes-test-utils" +version = "7.0.0" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1#2a91d5abdc56ed27dab36030db5fa3c9c92e60a9" +dependencies = [ + "cumulus-pallet-parachain-system", + "cumulus-pallet-xcmp-queue", + "cumulus-primitives-core", + "cumulus-primitives-parachain-inherent", + "cumulus-test-relay-sproof-builder", + "frame-support", + "frame-system", + "pallet-balances", + "pallet-collator-selection", + "pallet-session", + "pallet-xcm", + "parity-scale-codec", + "polkadot-parachain-primitives", + "sp-consensus-aura", + "sp-core 28.0.0", + "sp-io 30.0.0", + "sp-runtime 31.0.1", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1)", + "sp-tracing 16.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1)", + "staging-parachain-info", + "staging-xcm", + "staging-xcm-executor", + "substrate-wasm-builder", +] + +[[package]] +name = "parity-bytes" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16b56e3a2420138bdb970f84dfb9c774aea80fa0e7371549eedec0d80c209c67" + [[package]] name = "parity-db" version = "0.4.13" @@ -7595,6 +8255,35 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aa9777aa91b8ad9dd5aaa04a9b6bcb02c7f1deb952fca5a66034d5e63afc5c6f" +[[package]] +name = "parity-util-mem" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d32c34f4f5ca7f9196001c0aba5a1f9a5a12382c8944b8b0f90233282d1e8f8" +dependencies = [ + "cfg-if", + "ethereum-types", + "hashbrown 0.12.3", + "impl-trait-for-tuples", + "lru 0.8.1", + "parity-util-mem-derive", + "parking_lot 0.12.1", + "primitive-types", + "smallvec", + "winapi", +] + +[[package]] +name = "parity-util-mem-derive" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f557c32c6d268a07c921471619c0295f5efad3a0e76d4f97a05c091a51d110b2" +dependencies = [ + "proc-macro2", + "syn 1.0.109", + "synstructure 0.12.6", +] + [[package]] name = "parity-wasm" version = "0.45.0" @@ -9251,6 +9940,8 @@ checksum = "0b34d9fd68ae0b74a41b21c03c2f62847aa0ffea044eee893b4c140b37e244e2" dependencies = [ "fixed-hash", "impl-codec", + "impl-num-traits", + "impl-rlp", "impl-serde", "scale-info", "uint", @@ -9865,6 +10556,16 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc874b127765f014d792f16763a81245ab80500e2ad921ed4ee9e82481ee08fe" +[[package]] +name = "rlp" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb919243f34364b6bd2fc10ef797edbfa75f33c252e7998527479c6d6b47e1ec" +dependencies = [ + "bytes", + "rustc-hex", +] + [[package]] name = "rocksdb" version = "0.21.0" @@ -11685,6 +12386,15 @@ dependencies = [ "serde_derive", ] +[[package]] +name = "serde-big-array" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd31f59f6fe2b0c055371bb2f16d7f0aa7d8881676c04a55b1596d1a17cd10a4" +dependencies = [ + "serde", +] + [[package]] name = "serde_bytes" version = "0.11.14" @@ -12031,6 +12741,123 @@ dependencies = [ "subtle 2.5.0", ] +[[package]] +name = "snowbridge-amcl" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "460a9ed63cdf03c1b9847e8a12a5f5ba19c4efd5869e4a737e05be25d7c427e5" +dependencies = [ + "parity-scale-codec", + "scale-info", +] + +[[package]] +name = "snowbridge-beacon-primitives" +version = "0.0.0" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1#2a91d5abdc56ed27dab36030db5fa3c9c92e60a9" +dependencies = [ + "byte-slice-cast", + "frame-support", + "frame-system", + "hex", + "parity-scale-codec", + "rlp", + "scale-info", + "serde", + "snowbridge-ethereum", + "snowbridge-milagro-bls", + "sp-core 28.0.0", + "sp-io 30.0.0", + "sp-runtime 31.0.1", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1)", + "ssz_rs", + "ssz_rs_derive", + "static_assertions", +] + +[[package]] +name = "snowbridge-core" +version = "0.0.0" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1#2a91d5abdc56ed27dab36030db5fa3c9c92e60a9" +dependencies = [ + "ethabi-decode", + "frame-support", + "frame-system", + "hex-literal", + "parity-scale-codec", + "polkadot-parachain-primitives", + "scale-info", + "serde", + "snowbridge-beacon-primitives", + "sp-arithmetic 23.0.0", + "sp-core 28.0.0", + "sp-io 30.0.0", + "sp-runtime 31.0.1", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1)", + "staging-xcm", + "staging-xcm-builder", +] + +[[package]] +name = "snowbridge-ethereum" +version = "0.1.0" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1#2a91d5abdc56ed27dab36030db5fa3c9c92e60a9" +dependencies = [ + "ethabi-decode", + "ethbloom", + "ethereum-types", + "hex-literal", + "parity-bytes", + "parity-scale-codec", + "rlp", + "rustc-hex", + "scale-info", + "serde", + "serde-big-array", + "sp-core 28.0.0", + "sp-io 30.0.0", + "sp-runtime 31.0.1", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1)", +] + +[[package]] +name = "snowbridge-milagro-bls" +version = "1.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "026aa8638f690a53e3f7676024b9e913b1cab0111d1b7b92669d40a188f9d7e6" +dependencies = [ + "hex", + "lazy_static", + "parity-scale-codec", + "rand 0.8.5", + "scale-info", + "snowbridge-amcl", + "zeroize", +] + +[[package]] +name = "snowbridge-router-primitives" +version = "0.0.0" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1#2a91d5abdc56ed27dab36030db5fa3c9c92e60a9" +dependencies = [ + "ethabi-decode", + "frame-support", + "frame-system", + "hex-literal", + "log", + "parity-scale-codec", + "scale-info", + "serde", + "snowbridge-core", + "sp-core 28.0.0", + "sp-io 30.0.0", + "sp-runtime 31.0.1", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1)", + "staging-xcm", + "staging-xcm-builder", + "staging-xcm-executor", +] + [[package]] name = "socket2" version = "0.4.10" @@ -12429,7 +13256,7 @@ dependencies = [ [[package]] name = "sp-crypto-ec-utils" version = "0.10.0" -source = "git+https://github.com/paritytech/polkadot-sdk#f1b2189e8312821a9f8a79dc4f0183d314273faa" +source = "git+https://github.com/paritytech/polkadot-sdk#629506ce061db76d31d4f7a81f4a497752b27259" dependencies = [ "ark-bls12-377", "ark-bls12-377-ext", @@ -12503,7 +13330,7 @@ dependencies = [ [[package]] name = "sp-debug-derive" version = "14.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk#f1b2189e8312821a9f8a79dc4f0183d314273faa" +source = "git+https://github.com/paritytech/polkadot-sdk#629506ce061db76d31d4f7a81f4a497752b27259" dependencies = [ "proc-macro2", "quote", @@ -12536,7 +13363,7 @@ dependencies = [ [[package]] name = "sp-externalities" version = "0.25.0" -source = "git+https://github.com/paritytech/polkadot-sdk#f1b2189e8312821a9f8a79dc4f0183d314273faa" +source = "git+https://github.com/paritytech/polkadot-sdk#629506ce061db76d31d4f7a81f4a497752b27259" dependencies = [ "environmental", "parity-scale-codec", @@ -12849,7 +13676,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface" version = "24.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk#f1b2189e8312821a9f8a79dc4f0183d314273faa" +source = "git+https://github.com/paritytech/polkadot-sdk#629506ce061db76d31d4f7a81f4a497752b27259" dependencies = [ "bytes", "impl-trait-for-tuples", @@ -12894,7 +13721,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface-proc-macro" version = "17.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk#f1b2189e8312821a9f8a79dc4f0183d314273faa" +source = "git+https://github.com/paritytech/polkadot-sdk#629506ce061db76d31d4f7a81f4a497752b27259" dependencies = [ "Inflector", "expander 2.0.0", @@ -13014,7 +13841,7 @@ source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot [[package]] name = "sp-std" version = "14.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk#f1b2189e8312821a9f8a79dc4f0183d314273faa" +source = "git+https://github.com/paritytech/polkadot-sdk#629506ce061db76d31d4f7a81f4a497752b27259" [[package]] name = "sp-storage" @@ -13046,7 +13873,7 @@ dependencies = [ [[package]] name = "sp-storage" version = "19.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk#f1b2189e8312821a9f8a79dc4f0183d314273faa" +source = "git+https://github.com/paritytech/polkadot-sdk#629506ce061db76d31d4f7a81f4a497752b27259" dependencies = [ "impl-serde", "parity-scale-codec", @@ -13097,7 +13924,7 @@ dependencies = [ [[package]] name = "sp-tracing" version = "16.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk#f1b2189e8312821a9f8a79dc4f0183d314273faa" +source = "git+https://github.com/paritytech/polkadot-sdk#629506ce061db76d31d4f7a81f4a497752b27259" dependencies = [ "parity-scale-codec", "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk)", @@ -13236,7 +14063,7 @@ dependencies = [ [[package]] name = "sp-wasm-interface" version = "20.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk#f1b2189e8312821a9f8a79dc4f0183d314273faa" +source = "git+https://github.com/paritytech/polkadot-sdk#629506ce061db76d31d4f7a81f4a497752b27259" dependencies = [ "anyhow", "impl-trait-for-tuples", @@ -13325,6 +14152,29 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "ssz_rs" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "057291e5631f280978fa9c8009390663ca4613359fc1318e36a8c24c392f6d1f" +dependencies = [ + "bitvec", + "num-bigint", + "sha2 0.9.9", + "ssz_rs_derive", +] + +[[package]] +name = "ssz_rs_derive" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f07d54c4d01a1713eb363b55ba51595da15f6f1211435b71466460da022aa140" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "stable_deref_trait" version = "1.2.0" @@ -13736,6 +14586,20 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" +[[package]] +name = "testnet-parachains-constants" +version = "1.0.0" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1#2a91d5abdc56ed27dab36030db5fa3c9c92e60a9" +dependencies = [ + "frame-support", + "polkadot-core-primitives", + "rococo-runtime-constants", + "smallvec", + "sp-runtime 31.0.1", + "staging-xcm", + "westend-runtime-constants", +] + [[package]] name = "thiserror" version = "1.0.57" @@ -15450,6 +16314,40 @@ dependencies = [ "time", ] +[[package]] +name = "xcm-emulator" +version = "0.5.0" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1#2a91d5abdc56ed27dab36030db5fa3c9c92e60a9" +dependencies = [ + "cumulus-pallet-parachain-system", + "cumulus-pallet-xcmp-queue", + "cumulus-primitives-core", + "cumulus-primitives-parachain-inherent", + "cumulus-test-relay-sproof-builder", + "frame-support", + "frame-system", + "impl-trait-for-tuples", + "lazy_static", + "log", + "pallet-balances", + "pallet-message-queue", + "parachains-common", + "parity-scale-codec", + "paste", + "polkadot-parachain-primitives", + "polkadot-primitives", + "polkadot-runtime-parachains", + "sp-arithmetic 23.0.0", + "sp-core 28.0.0", + "sp-crypto-hashing", + "sp-io 30.0.0", + "sp-runtime 31.0.1", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1)", + "sp-tracing 16.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1)", + "staging-xcm", + "staging-xcm-executor", +] + [[package]] name = "xcm-procedural" version = "7.0.0" diff --git a/Cargo.toml b/Cargo.toml index b37fdab7a..f9357334c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,8 @@ repository = "https://github.com/r0gue-io/pop-node/" [workspace] members = [ "node", - "runtime", "emulated-integration-tests", + "runtime", + "emulated-integration-tests", "pop-api", ] exclude = [ @@ -84,9 +85,13 @@ pallet-transaction-payment = { git = "https://github.com/paritytech/polkadot-sdk pallet-transaction-payment-rpc = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1" } pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1", default-features = false } sp-api = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1", default-features = false } +sp-authority-discovery = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1", default-features = false } sp-block-builder = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1", default-features = false } sp-blockchain = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1" } sp-consensus-aura = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1", default-features = false } +sp-consensus-babe = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1", default-features = false } +sp-consensus-beefy = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1", default-features = false } +sp-consensus-grandpa = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1", default-features = false } sp-core = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1", default-features = false } sp-keystore = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1" } sp-io = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1", default-features = false } @@ -107,12 +112,16 @@ pallet-xcm = { git = "https://github.com/paritytech/polkadot-sdk", branch = "rel polkadot-cli = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1" } polkadot-parachain-primitives = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1", default-features = false } polkadot-primitives = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1" } -xcm = { package = "staging-xcm", git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1", default-features = false } polkadot-runtime-common = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1", default-features = false } +rococo-runtime-constants = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1" } +rococo-runtime = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1" } +xcm = { package = "staging-xcm", git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1", default-features = false } xcm-builder = { package = "staging-xcm-builder", git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1", default-features = false } xcm-executor = { package = "staging-xcm-executor", git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1", default-features = false } # Cumulus +asset-hub-rococo-runtime = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1", default-features = false } +asset-test-utils = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1", default-features = false } cumulus-pallet-aura-ext = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1", default-features = false } cumulus-pallet-parachain-system = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1", default-features = false, features = ["parameterized-consensus-hook"] } cumulus-pallet-session-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1", default-features = false } @@ -120,6 +129,7 @@ cumulus-pallet-xcm = { git = "https://github.com/paritytech/polkadot-sdk", branc cumulus-pallet-xcmp-queue = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1", default-features = false } cumulus-primitives-core = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1", default-features = false } cumulus-primitives-utility = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1", default-features = false } +emulated-integration-tests-common = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1", default-features = false } pallet-collator-selection = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1", default-features = false } parachains-common = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1", default-features = false } parachain-info = { package = "staging-parachain-info", git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1", default-features = false } diff --git a/emulated-integration-tests/Cargo.toml b/emulated-integration-tests/Cargo.toml index fd7957907..0b56477c2 100644 --- a/emulated-integration-tests/Cargo.toml +++ b/emulated-integration-tests/Cargo.toml @@ -1,6 +1,5 @@ [package] name = "emulated-integration-tests" -version = "0.1.0" authors.workspace = true edition.workspace = true homepage.workspace = true @@ -8,47 +7,41 @@ license.workspace = true repository.workspace = true [dependencies] -codec = { workspace = true } +codec.workspace = true # Substrate -frame-support = { workspace = true } -pallet-assets = { workspace = true } -pallet-balances = { workspace = true } -pallet-message-queue = { workspace = true } -sp-core = { workspace = true } -sp-authority-discovery = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1", default-features = false } -sp-consensus-babe = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1", default-features = false } -sp-consensus-beefy = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1", default-features = false } -sp-consensus-grandpa = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1", default-features = false } -sp-runtime = { workspace = true } +frame-support.workspace = true +pallet-assets.workspace = true +pallet-balances.workspace = true +pallet-message-queue.workspace = true +sp-core.workspace = true +sp-authority-discovery.workspace = true +sp-consensus-babe.workspace = true +sp-consensus-beefy.workspace = true +sp-consensus-grandpa.workspace = true +sp-runtime.workspace = true # Polkadot -polkadot-primitives = { workspace = true } -rococo-runtime-constants = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1" } -rococo-runtime = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1" } -xcm = { workspace = true } -xcm-executor = { workspace = true } +polkadot-primitives.workspace = true +rococo-runtime-constants.workspace = true +rococo-runtime.workspace = true +xcm.workspace = true +xcm-executor.workspace = true # Cumulus -asset-hub-rococo-runtime = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1", default-features = false } -asset-test-utils = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1", default-features = false } -cumulus-primitives-core = { workspace = true } -emulated-integration-tests-common = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1", default-features = false } -parachains-common = { workspace = true } +asset-hub-rococo-runtime.workspace = true +asset-test-utils.workspace = true +cumulus-primitives-core.workspace = true +emulated-integration-tests-common.workspace = true # Local pop-runtime = { path = "../runtime", default-features = false } +pop-node = { path = "../node", default-features = false } [features] default = ["std"] std = [ "asset-hub-rococo-runtime/std", - "asset-test-utils/std", "pop-runtime/std", "rococo-runtime/std", - "rococo-runtime-constants/std", - "sp-authority-discovery/std", - "sp-consensus-babe/std", - "sp-consensus-beefy/std", - "sp-consensus-grandpa/std", ] diff --git a/emulated-integration-tests/src/chains/asset_hub_rococo/genesis.rs b/emulated-integration-tests/src/chains/asset_hub_rococo/genesis.rs index a1874b761..0455fcf7d 100644 --- a/emulated-integration-tests/src/chains/asset_hub_rococo/genesis.rs +++ b/emulated-integration-tests/src/chains/asset_hub_rococo/genesis.rs @@ -1,16 +1,13 @@ -// Substrate -use sp_core::storage::Storage; - -// Cumulus use emulated_integration_tests_common::{ accounts, build_genesis_storage, collators, SAFE_XCM_VERSION, }; -use parachains_common::Balance; +use pop_runtime::Balance; +use sp_core::storage::Storage; -pub const PARA_ID: u32 = 1000; -pub const ED: Balance = rococo_runtime_constants::currency::EXISTENTIAL_DEPOSIT / 10; +pub(crate) const PARA_ID: u32 = 1000; +pub(crate) const ED: Balance = rococo_runtime_constants::currency::EXISTENTIAL_DEPOSIT / 10; -pub fn genesis() -> Storage { +pub(crate) fn genesis() -> Storage { let genesis_config = asset_hub_rococo_runtime::RuntimeGenesisConfig { system: asset_hub_rococo_runtime::SystemConfig::default(), balances: asset_hub_rococo_runtime::BalancesConfig { diff --git a/emulated-integration-tests/src/chains/asset_hub_rococo/mod.rs b/emulated-integration-tests/src/chains/asset_hub_rococo/mod.rs index 6c4eb3a14..f72503285 100644 --- a/emulated-integration-tests/src/chains/asset_hub_rococo/mod.rs +++ b/emulated-integration-tests/src/chains/asset_hub_rococo/mod.rs @@ -1,15 +1,12 @@ -pub mod genesis; +pub(crate) mod genesis; -// Substrate -use frame_support::traits::OnInitialize; - -// Cumulus use crate::chains::rococo::Rococo; use emulated_integration_tests_common::{ impl_accounts_helpers_for_parachain, impl_assert_events_helpers_for_parachain, impl_assets_helpers_for_parachain, impl_foreign_assets_helpers_for_parachain, impl_xcm_helpers_for_parachain, impls::Parachain, xcm_emulator::decl_test_parachains, }; +use frame_support::traits::OnInitialize; // AssetHubRococo Parachain declaration decl_test_parachains! { @@ -29,8 +26,6 @@ decl_test_parachains! { PolkadotXcm: asset_hub_rococo_runtime::PolkadotXcm, Assets: asset_hub_rococo_runtime::Assets, ForeignAssets: asset_hub_rococo_runtime::ForeignAssets, - PoolAssets: asset_hub_rococo_runtime::PoolAssets, - AssetConversion: asset_hub_rococo_runtime::AssetConversion, Balances: asset_hub_rococo_runtime::Balances, } }, diff --git a/emulated-integration-tests/src/chains/mod.rs b/emulated-integration-tests/src/chains/mod.rs index 6fdeae2f2..e9c4a6517 100644 --- a/emulated-integration-tests/src/chains/mod.rs +++ b/emulated-integration-tests/src/chains/mod.rs @@ -1,3 +1,3 @@ -pub mod asset_hub_rococo; -pub mod pop_network; -pub mod rococo; +pub(crate) mod asset_hub_rococo; +pub(crate) mod pop_network; +pub(crate) mod rococo; diff --git a/emulated-integration-tests/src/chains/pop_network/genesis.rs b/emulated-integration-tests/src/chains/pop_network/genesis.rs index b933fba88..aca811b05 100644 --- a/emulated-integration-tests/src/chains/pop_network/genesis.rs +++ b/emulated-integration-tests/src/chains/pop_network/genesis.rs @@ -1,16 +1,11 @@ -// Substrate +use emulated_integration_tests_common::{accounts, build_genesis_storage, collators}; +use pop_node::chain_spec::{PARA_ID, SAFE_XCM_VERSION}; +use pop_runtime::Balance; use sp_core::storage::Storage; -// Cumulus -use emulated_integration_tests_common::{ - accounts, build_genesis_storage, collators, SAFE_XCM_VERSION, -}; -use parachains_common::Balance; +pub(crate) const ED: Balance = pop_runtime::EXISTENTIAL_DEPOSIT; -pub const PARA_ID: u32 = 909; -pub const ED: Balance = rococo_runtime_constants::currency::EXISTENTIAL_DEPOSIT / 10; - -pub fn genesis() -> Storage { +pub(crate) fn genesis() -> Storage { let genesis_config = pop_runtime::RuntimeGenesisConfig { system: pop_runtime::SystemConfig::default(), balances: pop_runtime::BalancesConfig { diff --git a/emulated-integration-tests/src/chains/pop_network/mod.rs b/emulated-integration-tests/src/chains/pop_network/mod.rs index d7378c5fc..861228244 100644 --- a/emulated-integration-tests/src/chains/pop_network/mod.rs +++ b/emulated-integration-tests/src/chains/pop_network/mod.rs @@ -1,15 +1,12 @@ -pub mod genesis; +pub(crate) mod genesis; -// Substrate -use frame_support::traits::OnInitialize; - -// Cumulus use crate::chains::rococo::Rococo; use emulated_integration_tests_common::{ impl_accounts_helpers_for_parachain, impl_assert_events_helpers_for_parachain, impl_assets_helpers_for_parachain, impl_xcm_helpers_for_parachain, impls::Parachain, xcm_emulator::decl_test_parachains, }; +use frame_support::traits::OnInitialize; // PopNetwork Parachain declaration decl_test_parachains! { @@ -29,7 +26,6 @@ decl_test_parachains! { PolkadotXcm: pop_runtime::PolkadotXcm, Assets: pop_runtime::Assets, Balances: pop_runtime::Balances, - Nfts: pop_runtime::Nfts, } }, } @@ -38,6 +34,4 @@ decl_test_parachains! { impl_accounts_helpers_for_parachain!(PopNetwork); impl_assert_events_helpers_for_parachain!(PopNetwork); impl_assets_helpers_for_parachain!(PopNetwork, Rococo); -// For foreign assets: -// impl_foreign_assets_helpers_for_parachain!(PopNetwork, Rococo); impl_xcm_helpers_for_parachain!(PopNetwork); diff --git a/emulated-integration-tests/src/chains/rococo/genesis.rs b/emulated-integration-tests/src/chains/rococo/genesis.rs index 3ec8a3b9a..2160eb8b3 100644 --- a/emulated-integration-tests/src/chains/rococo/genesis.rs +++ b/emulated-integration-tests/src/chains/rococo/genesis.rs @@ -1,22 +1,17 @@ -// Substrate -use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId; -use sp_consensus_babe::AuthorityId as BabeId; -use sp_consensus_beefy::ecdsa_crypto::AuthorityId as BeefyId; -use sp_consensus_grandpa::AuthorityId as GrandpaId; -use sp_core::{sr25519, storage::Storage}; - -// Polkadot -use polkadot_primitives::{AssignmentId, ValidatorId}; - -// Cumulus use emulated_integration_tests_common::{ accounts, build_genesis_storage, get_account_id_from_seed, get_from_seed, get_host_config, validators, }; -use parachains_common::Balance; +use pop_runtime::Balance; +use polkadot_primitives::{AssignmentId, ValidatorId}; use rococo_runtime_constants::currency::UNITS as ROC; +use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId; +use sp_consensus_babe::AuthorityId as BabeId; +use sp_consensus_beefy::ecdsa_crypto::AuthorityId as BeefyId; +use sp_consensus_grandpa::AuthorityId as GrandpaId; +use sp_core::{sr25519, storage::Storage}; -pub const ED: Balance = rococo_runtime_constants::currency::EXISTENTIAL_DEPOSIT; +pub(crate) const ED: Balance = rococo_runtime_constants::currency::EXISTENTIAL_DEPOSIT; const ENDOWMENT: u128 = 1_000_000 * ROC; fn session_keys( @@ -37,7 +32,7 @@ fn session_keys( } } -pub fn genesis() -> Storage { +pub(crate) fn genesis() -> Storage { let genesis_config = rococo_runtime::RuntimeGenesisConfig { system: rococo_runtime::SystemConfig::default(), balances: rococo_runtime::BalancesConfig { diff --git a/emulated-integration-tests/src/chains/rococo/mod.rs b/emulated-integration-tests/src/chains/rococo/mod.rs index 83f809e0d..0569e183c 100644 --- a/emulated-integration-tests/src/chains/rococo/mod.rs +++ b/emulated-integration-tests/src/chains/rococo/mod.rs @@ -1,6 +1,5 @@ -pub mod genesis; +pub(crate) mod genesis; -// Cumulus use emulated_integration_tests_common::{ impl_accounts_helpers_for_relay_chain, impl_assert_events_helpers_for_relay_chain, impl_hrmp_channels_helpers_for_relay_chain, impl_send_transact_helpers_for_relay_chain, @@ -22,8 +21,6 @@ decl_test_relay_chains! { Sudo: rococo_runtime::Sudo, Balances: rococo_runtime::Balances, Hrmp: rococo_runtime::Hrmp, - Identity: rococo_runtime::Identity, - IdentityMigrator: rococo_runtime::IdentityMigrator, } }, } diff --git a/emulated-integration-tests/src/lib.rs b/emulated-integration-tests/src/lib.rs index 4d37828fa..b5b5c4dcb 100644 --- a/emulated-integration-tests/src/lib.rs +++ b/emulated-integration-tests/src/lib.rs @@ -1,66 +1,76 @@ +#[cfg(test)] mod chains; -mod rococo_network; - -// Substrate -pub use frame_support::{ - assert_err, - pallet_prelude::Weight, - sp_runtime::{DispatchError, DispatchResult}, - traits::fungibles::Inspect, -}; - -// Polkadot -pub use xcm::prelude::{AccountId32 as AccountId32Junction, *}; - -// Cumulus -pub use crate::rococo_network::{ - asset_hub_rococo::{ - genesis::ED as ASSET_HUB_ROCOCO_ED, AssetHubRococoParaPallet as AssetHubRococoPallet, - }, - pop_network::PopNetworkParaPallet as PopNetworkPallet, - rococo::{genesis::ED as ROCOCO_ED, RococoRelayPallet as RococoPallet}, - AssetHubRococoPara as AssetHubRococo, AssetHubRococoParaReceiver as AssetHubRococoReceiver, - AssetHubRococoParaSender as AssetHubRococoSender, PopNetworkPara as PopNetwork, - PopNetworkParaReceiver as PopNetworkReceiver, PopNetworkParaSender as PopNetworkSender, - RococoRelay as Rococo, RococoRelayReceiver as RococoReceiver, - RococoRelaySender as RococoSender, -}; -pub use asset_test_utils::xcm_helpers; -pub use emulated_integration_tests_common::xcm_emulator::{ - assert_expected_events, bx, Chain, Parachain as Para, RelayChain as Relay, Test, TestArgs, - TestContext, TestExt, -}; -pub use parachains_common::Balance; - -pub const ASSET_ID: u32 = 1; -pub const ASSET_MIN_BALANCE: u128 = 1000; -// `Assets` pallet index -pub const ASSETS_PALLET_ID: u8 = 50; - -pub type RelayToParaTest = Test; -pub type SystemParaToParaTest = Test; -pub type ParaToSystemParaTest = Test; #[cfg(test)] mod tests { - use super::*; - + use crate::chains::{ + asset_hub_rococo::{ + genesis::ED as ASSET_HUB_ROCOCO_ED, AssetHubRococo, AssetHubRococoParaPallet, + }, + pop_network::{PopNetwork, PopNetworkParaPallet}, + rococo::{genesis::ED as ROCOCO_ED, Rococo, RococoRelayPallet}, + }; use asset_hub_rococo_runtime::xcm_config::XcmConfig as AssetHubRococoXcmConfig; - use pop_runtime::xcm_config::XcmConfig as PopNetworkXcmConfig; + use asset_test_utils::xcm_helpers; + use emulated_integration_tests_common::{ + accounts::{ALICE, BOB}, + xcm_emulator::{ + assert_expected_events, bx, decl_test_networks, + decl_test_sender_receiver_accounts_parameter_types, Chain, Parachain as Para, + RelayChain as Relay, Test, TestArgs, TestContext, TestExt, + }, + }; + use frame_support::{ + assert_err, + pallet_prelude::Weight, + sp_runtime::{DispatchError, DispatchResult}, + traits::fungibles::Inspect, + }; + use pop_runtime::{xcm_config::XcmConfig as PopNetworkXcmConfig, Balance}; use rococo_runtime::xcm_config::XcmConfig as RococoXcmConfig; + use xcm::prelude::{AccountId32 as AccountId32Junction, *}; + + decl_test_networks! { + // `pub` mandatory for the macro + pub struct RococoMockNet { + relay_chain = Rococo, + parachains = vec![ + AssetHubRococo, + PopNetwork, + ], + bridge = () + }, + } + + decl_test_sender_receiver_accounts_parameter_types! { + RococoRelay { sender: ALICE, receiver: BOB }, + AssetHubRococoPara { sender: ALICE, receiver: BOB }, + PopNetworkPara { sender: ALICE, receiver: BOB} + } + + const ASSET_ID: u32 = 1; + const ASSET_MIN_BALANCE: u128 = 1000; + const ASSETS_PALLET_ID: u8 = 50; + + type RelayToParaTest = Test; + type SystemParaToParaTest = Test; + type ParaToSystemParaTest = Test; fn relay_to_para_sender_assertions(t: RelayToParaTest) { - type RuntimeEvent = ::RuntimeEvent; - Rococo::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts(864_610_000, 8_799))); + type RuntimeEvent = ::RuntimeEvent; + RococoRelay::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts( + 864_610_000, + 8_799, + ))); assert_expected_events!( - Rococo, + RococoRelay, vec![ // Amount to reserve transfer is transferred to Parachain's Sovereign account RuntimeEvent::Balances( pallet_balances::Event::Transfer { from, to, amount } ) => { from: *from == t.sender.account_id, - to: *to == Rococo::sovereign_account_id_of( + to: *to == RococoRelay::sovereign_account_id_of( t.args.dest.clone() ), amount: *amount == t.args.amount, @@ -70,20 +80,20 @@ mod tests { } fn system_para_to_para_sender_assertions(t: SystemParaToParaTest) { - type RuntimeEvent = ::RuntimeEvent; - AssetHubRococo::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts( + type RuntimeEvent = ::RuntimeEvent; + AssetHubRococoPara::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts( 864_610_000, 8_799, ))); assert_expected_events!( - AssetHubRococo, + AssetHubRococoPara, vec![ // Amount to reserve transfer is transferred to Parachain's Sovereign account RuntimeEvent::Balances( pallet_balances::Event::Transfer { from, to, amount } ) => { from: *from == t.sender.account_id, - to: *to == AssetHubRococo::sovereign_account_id_of( + to: *to == AssetHubRococoPara::sovereign_account_id_of( t.args.dest.clone() ), amount: *amount == t.args.amount, @@ -93,9 +103,9 @@ mod tests { } fn para_receiver_assertions(_: Test) { - type RuntimeEvent = ::RuntimeEvent; + type RuntimeEvent = ::RuntimeEvent; assert_expected_events!( - PopNetwork, + PopNetworkPara, vec![ RuntimeEvent::Balances(pallet_balances::Event::Deposit { .. }) => {}, RuntimeEvent::MessageQueue( @@ -106,13 +116,13 @@ mod tests { } fn para_to_system_para_sender_assertions(t: ParaToSystemParaTest) { - type RuntimeEvent = ::RuntimeEvent; - PopNetwork::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts( + type RuntimeEvent = ::RuntimeEvent; + PopNetworkPara::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts( 864_610_000, 8_799, ))); assert_expected_events!( - PopNetwork, + PopNetworkPara, vec![ // Amount to reserve transfer is transferred to Parachain's Sovereign account RuntimeEvent::Balances( @@ -126,12 +136,12 @@ mod tests { } fn para_to_system_para_receiver_assertions(t: ParaToSystemParaTest) { - type RuntimeEvent = ::RuntimeEvent; - let sov_pop_net_on_ahr = AssetHubRococo::sovereign_account_id_of( - AssetHubRococo::sibling_location_of(PopNetwork::para_id()), + type RuntimeEvent = ::RuntimeEvent; + let sov_pop_net_on_ahr = AssetHubRococoPara::sovereign_account_id_of( + AssetHubRococoPara::sibling_location_of(PopNetworkPara::para_id()), ); assert_expected_events!( - AssetHubRococo, + AssetHubRococoPara, vec![ // Amount to reserve transfer is withdrawn from Parachain's Sovereign account RuntimeEvent::Balances( @@ -149,13 +159,13 @@ mod tests { } fn system_para_to_para_assets_sender_assertions(t: SystemParaToParaTest) { - type RuntimeEvent = ::RuntimeEvent; - AssetHubRococo::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts( + type RuntimeEvent = ::RuntimeEvent; + AssetHubRococoPara::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts( 864_610_000, 8799, ))); assert_expected_events!( - AssetHubRococo, + AssetHubRococoPara, vec![ // Amount to reserve transfer is transferred to Parachain's Sovereign account RuntimeEvent::Assets( @@ -163,7 +173,7 @@ mod tests { ) => { asset_id: *asset_id == ASSET_ID, from: *from == t.sender.account_id, - to: *to == AssetHubRococo::sovereign_account_id_of( + to: *to == AssetHubRococoPara::sovereign_account_id_of( t.args.dest.clone() ), amount: *amount == t.args.amount, @@ -173,9 +183,9 @@ mod tests { } fn system_para_to_para_assets_receiver_assertions(_: Test) { - type RuntimeEvent = ::RuntimeEvent; + type RuntimeEvent = ::RuntimeEvent; assert_expected_events!( - PopNetwork, + PopNetworkPara, vec![ RuntimeEvent::Balances(pallet_balances::Event::Deposit { .. }) => {}, RuntimeEvent::Assets(pallet_assets::Event::Issued { .. }) => {}, @@ -187,7 +197,7 @@ mod tests { } fn relay_to_para_reserve_transfer_assets(t: RelayToParaTest) -> DispatchResult { - ::XcmPallet::limited_reserve_transfer_assets( + ::XcmPallet::limited_reserve_transfer_assets( t.signed_origin, bx!(t.args.dest.into()), bx!(t.args.beneficiary.into()), @@ -198,7 +208,7 @@ mod tests { } fn system_para_to_para_reserve_transfer_assets(t: SystemParaToParaTest) -> DispatchResult { - ::PolkadotXcm::limited_reserve_transfer_assets( + ::PolkadotXcm::limited_reserve_transfer_assets( t.signed_origin, bx!(t.args.dest.into()), bx!(t.args.beneficiary.into()), @@ -209,7 +219,7 @@ mod tests { } fn para_to_system_para_reserve_transfer_assets(t: ParaToSystemParaTest) -> DispatchResult { - ::PolkadotXcm::limited_reserve_transfer_assets( + ::PolkadotXcm::limited_reserve_transfer_assets( t.signed_origin, bx!(t.args.dest.into()), bx!(t.args.beneficiary.into()), @@ -222,11 +232,12 @@ mod tests { /// Reserve Transfers of native asset from Relay Chain to the System Parachain shouldn't work #[test] fn reserve_transfer_native_asset_from_relay_to_system_para_fails() { - let signed_origin = ::RuntimeOrigin::signed(RococoSender::get().into()); - let destination = Rococo::child_location_of(AssetHubRococo::para_id()); + let signed_origin = + ::RuntimeOrigin::signed(RococoRelaySender::get().into()); + let destination = RococoRelay::child_location_of(AssetHubRococoPara::para_id()); let beneficiary: Location = AccountId32Junction { network: None, - id: AssetHubRococoReceiver::get().into(), + id: AssetHubRococoParaReceiver::get().into(), } .into(); let amount_to_send: Balance = ROCOCO_ED * 1000; @@ -234,15 +245,16 @@ mod tests { let fee_asset_item = 0; // this should fail - Rococo::execute_with(|| { - let result = ::XcmPallet::limited_reserve_transfer_assets( - signed_origin, - bx!(destination.into()), - bx!(beneficiary.into()), - bx!(assets.into()), - fee_asset_item, - WeightLimit::Unlimited, - ); + RococoRelay::execute_with(|| { + let result = + ::XcmPallet::limited_reserve_transfer_assets( + signed_origin, + bx!(destination.into()), + bx!(beneficiary.into()), + bx!(assets.into()), + fee_asset_item, + WeightLimit::Unlimited, + ); assert_err!( result, DispatchError::Module(sp_runtime::ModuleError { @@ -258,10 +270,11 @@ mod tests { #[test] fn reserve_transfer_native_asset_from_system_para_to_relay_fails() { // Init values for System Parachain - let signed_origin = - ::RuntimeOrigin::signed(AssetHubRococoSender::get().into()); - let destination = AssetHubRococo::parent_location(); - let beneficiary_id = RococoReceiver::get(); + let signed_origin = ::RuntimeOrigin::signed( + AssetHubRococoParaSender::get().into(), + ); + let destination = AssetHubRococoPara::parent_location(); + let beneficiary_id = RococoRelayReceiver::get(); let beneficiary: Location = AccountId32Junction { network: None, id: beneficiary_id.into(), @@ -273,9 +286,9 @@ mod tests { let fee_asset_item = 0; // this should fail - AssetHubRococo::execute_with(|| { + AssetHubRococoPara::execute_with(|| { let result = - ::PolkadotXcm::limited_reserve_transfer_assets( + ::PolkadotXcm::limited_reserve_transfer_assets( signed_origin, bx!(destination.into()), bx!(beneficiary.into()), @@ -298,13 +311,13 @@ mod tests { #[test] fn reserve_transfer_native_asset_from_relay_to_para() { // Init values for Relay - let destination = Rococo::child_location_of(PopNetwork::para_id()); - let beneficiary_id = PopNetworkReceiver::get(); + let destination = RococoRelay::child_location_of(PopNetworkPara::para_id()); + let beneficiary_id = PopNetworkParaReceiver::get(); let amount_to_send: Balance = ROCOCO_ED * 1000; let test_args = TestContext { - sender: RococoSender::get(), - receiver: PopNetworkReceiver::get(), + sender: RococoRelaySender::get(), + receiver: PopNetworkParaReceiver::get(), args: TestArgs::new_relay(destination, beneficiary_id, amount_to_send), }; @@ -313,12 +326,12 @@ mod tests { let sender_balance_before = test.sender.balance; let receiver_balance_before = test.receiver.balance; - test.set_assertion::(relay_to_para_sender_assertions); - test.set_assertion::(para_receiver_assertions); - test.set_dispatchable::(relay_to_para_reserve_transfer_assets); + test.set_assertion::(relay_to_para_sender_assertions); + test.set_assertion::(para_receiver_assertions); + test.set_dispatchable::(relay_to_para_reserve_transfer_assets); test.assert(); - let delivery_fees = Rococo::execute_with(|| { + let delivery_fees = RococoRelay::execute_with(|| { xcm_helpers::transfer_assets_delivery_fees::< ::XcmSender, >( @@ -350,14 +363,14 @@ mod tests { #[test] fn reserve_transfer_native_asset_from_system_para_to_para() { // Init values for System Parachain - let destination = AssetHubRococo::sibling_location_of(PopNetwork::para_id()); - let beneficiary_id = PopNetworkReceiver::get(); + let destination = AssetHubRococoPara::sibling_location_of(PopNetworkPara::para_id()); + let beneficiary_id = PopNetworkParaReceiver::get(); let amount_to_send: Balance = ASSET_HUB_ROCOCO_ED * 1000; let assets = (Parent, amount_to_send).into(); let test_args = TestContext { - sender: AssetHubRococoSender::get(), - receiver: PopNetworkReceiver::get(), + sender: AssetHubRococoParaSender::get(), + receiver: PopNetworkParaReceiver::get(), args: TestArgs::new_para(destination, beneficiary_id, amount_to_send, assets, None, 0), }; @@ -366,15 +379,15 @@ mod tests { let sender_balance_before = test.sender.balance; let receiver_balance_before = test.receiver.balance; - test.set_assertion::(system_para_to_para_sender_assertions); - test.set_assertion::(para_receiver_assertions); - test.set_dispatchable::(system_para_to_para_reserve_transfer_assets); + test.set_assertion::(system_para_to_para_sender_assertions); + test.set_assertion::(para_receiver_assertions); + test.set_dispatchable::(system_para_to_para_reserve_transfer_assets); test.assert(); let sender_balance_after = test.sender.balance; let receiver_balance_after = test.receiver.balance; - let delivery_fees = AssetHubRococo::execute_with(|| { + let delivery_fees = AssetHubRococoPara::execute_with(|| { xcm_helpers::transfer_assets_delivery_fees::< ::XcmSender, >( @@ -403,14 +416,14 @@ mod tests { #[test] fn reserve_transfer_native_asset_from_para_to_system_para() { // Init values for Pop Network Parachain - let destination = PopNetwork::sibling_location_of(AssetHubRococo::para_id()); - let beneficiary_id = AssetHubRococoReceiver::get(); + let destination = PopNetworkPara::sibling_location_of(AssetHubRococoPara::para_id()); + let beneficiary_id = AssetHubRococoParaReceiver::get(); let amount_to_send: Balance = ASSET_HUB_ROCOCO_ED * 1000; let assets = (Parent, amount_to_send).into(); let test_args = TestContext { - sender: PopNetworkSender::get(), - receiver: AssetHubRococoReceiver::get(), + sender: PopNetworkParaSender::get(), + receiver: AssetHubRococoParaReceiver::get(), args: TestArgs::new_para(destination, beneficiary_id, amount_to_send, assets, None, 0), }; @@ -420,22 +433,22 @@ mod tests { let receiver_balance_before = test.receiver.balance; let pop_net_location_as_seen_by_ahr = - AssetHubRococo::sibling_location_of(PopNetwork::para_id()); + AssetHubRococoPara::sibling_location_of(PopNetworkPara::para_id()); let sov_pop_net_on_ahr = - AssetHubRococo::sovereign_account_id_of(pop_net_location_as_seen_by_ahr); + AssetHubRococoPara::sovereign_account_id_of(pop_net_location_as_seen_by_ahr); // fund the Pop Network's SA on AHR with the native tokens held in reserve - AssetHubRococo::fund_accounts(vec![(sov_pop_net_on_ahr.into(), amount_to_send * 2)]); + AssetHubRococoPara::fund_accounts(vec![(sov_pop_net_on_ahr.into(), amount_to_send * 2)]); - test.set_assertion::(para_to_system_para_sender_assertions); - test.set_assertion::(para_to_system_para_receiver_assertions); - test.set_dispatchable::(para_to_system_para_reserve_transfer_assets); + test.set_assertion::(para_to_system_para_sender_assertions); + test.set_assertion::(para_to_system_para_receiver_assertions); + test.set_dispatchable::(para_to_system_para_reserve_transfer_assets); test.assert(); let sender_balance_after = test.sender.balance; let receiver_balance_after = test.receiver.balance; - let delivery_fees = PopNetwork::execute_with(|| { + let delivery_fees = PopNetworkPara::execute_with(|| { xcm_helpers::transfer_assets_delivery_fees::< ::XcmSender, >( @@ -464,27 +477,27 @@ mod tests { /// should work #[test] fn reserve_transfer_assets_from_system_para_to_para() { - // Force create asset on AssetHubRococo and PopNetwork from Relay Chain - AssetHubRococo::force_create_and_mint_asset( + // Force create asset on AssetHubRococoPara and PopNetworkPara from Relay Chain + AssetHubRococoPara::force_create_and_mint_asset( ASSET_ID, ASSET_MIN_BALANCE, false, - AssetHubRococoSender::get(), + AssetHubRococoParaSender::get(), Some(Weight::from_parts(1_019_445_000, 200_000)), ASSET_MIN_BALANCE * 1_000_000, ); - PopNetwork::force_create_and_mint_asset( + PopNetworkPara::force_create_and_mint_asset( ASSET_ID, ASSET_MIN_BALANCE, false, - PopNetworkSender::get(), + PopNetworkParaSender::get(), None, 0, ); // Init values for System Parachain - let destination = AssetHubRococo::sibling_location_of(PopNetwork::para_id()); - let beneficiary_id = PopNetworkReceiver::get(); + let destination = AssetHubRococoPara::sibling_location_of(PopNetworkPara::para_id()); + let beneficiary_id = PopNetworkParaReceiver::get(); let fee_amount_to_send = ASSET_HUB_ROCOCO_ED * 1000; let asset_amount_to_send = ASSET_MIN_BALANCE * 1000; let assets: Assets = vec![ @@ -506,8 +519,8 @@ mod tests { .unwrap() as u32; let para_test_args = TestContext { - sender: AssetHubRococoSender::get(), - receiver: PopNetworkReceiver::get(), + sender: AssetHubRococoParaSender::get(), + receiver: PopNetworkParaReceiver::get(), args: TestArgs::new_para( destination, beneficiary_id, @@ -521,25 +534,25 @@ mod tests { let mut test = SystemParaToParaTest::new(para_test_args); // Create SA-of-Pop Network-on-AHR with ED. - let pop_net_location = AssetHubRococo::sibling_location_of(PopNetwork::para_id()); - let sov_pop_net_on_ahr = AssetHubRococo::sovereign_account_id_of(pop_net_location); - AssetHubRococo::fund_accounts(vec![(sov_pop_net_on_ahr.into(), ROCOCO_ED)]); + let pop_net_location = AssetHubRococoPara::sibling_location_of(PopNetworkPara::para_id()); + let sov_pop_net_on_ahr = AssetHubRococoPara::sovereign_account_id_of(pop_net_location); + AssetHubRococoPara::fund_accounts(vec![(sov_pop_net_on_ahr.into(), ROCOCO_ED)]); let sender_balance_before = test.sender.balance; let receiver_balance_before = test.receiver.balance; - let sender_assets_before = AssetHubRococo::execute_with(|| { - type Assets = ::Assets; - >::balance(ASSET_ID, &AssetHubRococoSender::get()) + let sender_assets_before = AssetHubRococoPara::execute_with(|| { + type Assets = ::Assets; + >::balance(ASSET_ID, &AssetHubRococoParaSender::get()) }); - let receiver_assets_before = PopNetwork::execute_with(|| { - type Assets = ::Assets; - >::balance(ASSET_ID, &PopNetworkReceiver::get()) + let receiver_assets_before = PopNetworkPara::execute_with(|| { + type Assets = ::Assets; + >::balance(ASSET_ID, &PopNetworkParaReceiver::get()) }); - test.set_assertion::(system_para_to_para_assets_sender_assertions); - test.set_assertion::(system_para_to_para_assets_receiver_assertions); - test.set_dispatchable::(system_para_to_para_reserve_transfer_assets); + test.set_assertion::(system_para_to_para_assets_sender_assertions); + test.set_assertion::(system_para_to_para_assets_receiver_assertions); + test.set_dispatchable::(system_para_to_para_reserve_transfer_assets); test.assert(); let sender_balance_after = test.sender.balance; @@ -554,13 +567,13 @@ mod tests { // but should be non-zero assert!(receiver_balance_after < receiver_balance_before + fee_amount_to_send); - let sender_assets_after = AssetHubRococo::execute_with(|| { - type Assets = ::Assets; - >::balance(ASSET_ID, &AssetHubRococoSender::get()) + let sender_assets_after = AssetHubRococoPara::execute_with(|| { + type Assets = ::Assets; + >::balance(ASSET_ID, &AssetHubRococoParaSender::get()) }); - let receiver_assets_after = PopNetwork::execute_with(|| { - type Assets = ::Assets; - >::balance(ASSET_ID, &PopNetworkReceiver::get()) + let receiver_assets_after = PopNetworkPara::execute_with(|| { + type Assets = ::Assets; + >::balance(ASSET_ID, &PopNetworkParaReceiver::get()) }); // Sender's balance is reduced by exact amount diff --git a/emulated-integration-tests/src/rococo_network.rs b/emulated-integration-tests/src/rococo_network.rs deleted file mode 100644 index 3b9e0cfea..000000000 --- a/emulated-integration-tests/src/rococo_network.rs +++ /dev/null @@ -1,25 +0,0 @@ -pub use crate::chains::{asset_hub_rococo, pop_network, rococo}; -use crate::chains::{asset_hub_rococo::AssetHubRococo, pop_network::PopNetwork, rococo::Rococo}; - -// Cumulus -use emulated_integration_tests_common::{ - accounts::{ALICE, BOB}, - xcm_emulator::{decl_test_networks, decl_test_sender_receiver_accounts_parameter_types}, -}; - -decl_test_networks! { - pub struct RococoMockNet { - relay_chain = Rococo, - parachains = vec![ - AssetHubRococo, - PopNetwork, - ], - bridge = () - }, -} - -decl_test_sender_receiver_accounts_parameter_types! { - RococoRelay { sender: ALICE, receiver: BOB }, - AssetHubRococoPara { sender: ALICE, receiver: BOB }, - PopNetworkPara { sender: ALICE, receiver: BOB} -} diff --git a/node/src/chain_spec.rs b/node/src/chain_spec.rs index 1eb334b61..f61237a78 100644 --- a/node/src/chain_spec.rs +++ b/node/src/chain_spec.rs @@ -10,7 +10,10 @@ use sp_runtime::traits::{IdentifyAccount, Verify}; pub type ChainSpec = sc_service::GenericChainSpec<(), Extensions>; /// The default XCM version to set in genesis config. -const SAFE_XCM_VERSION: u32 = xcm::prelude::XCM_VERSION; +pub const SAFE_XCM_VERSION: u32 = xcm::prelude::XCM_VERSION; + +/// The para ID of Pop Network. +pub const PARA_ID: u32 = 909; /// Helper function to generate a crypto pair from seed pub fn get_from_seed(seed: &str) -> ::Public { @@ -67,47 +70,47 @@ pub fn development_config() -> ChainSpec { properties.insert("tokenDecimals".into(), 12.into()); properties.insert("ss58Format".into(), 42.into()); - ChainSpec::builder( - pop_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"), - Extensions { - relay_chain: "rococo-local".into(), - // You MUST set this to the correct network! - para_id: 1000, - }, - ) - .with_name("Development") - .with_id("dev") - .with_chain_type(ChainType::Development) - .with_genesis_config_patch(testnet_genesis( - // initial collators. - vec![ - ( - get_account_id_from_seed::("Alice"), - get_collator_keys_from_seed("Alice"), - ), - ( - get_account_id_from_seed::("Bob"), - get_collator_keys_from_seed("Bob"), - ), - ], - vec![ - get_account_id_from_seed::("Alice"), - get_account_id_from_seed::("Bob"), - get_account_id_from_seed::("Charlie"), - get_account_id_from_seed::("Dave"), - get_account_id_from_seed::("Eve"), - get_account_id_from_seed::("Ferdie"), - get_account_id_from_seed::("Alice//stash"), - get_account_id_from_seed::("Bob//stash"), - get_account_id_from_seed::("Charlie//stash"), - get_account_id_from_seed::("Dave//stash"), - get_account_id_from_seed::("Eve//stash"), - get_account_id_from_seed::("Ferdie//stash"), - ], - get_account_id_from_seed::("Alice"), - 1000.into(), - )) - .build() + ChainSpec::builder( + pop_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"), + Extensions { + relay_chain: "rococo-local".into(), + // You MUST set this to the correct network! + para_id: PARA_ID, + }, + ) + .with_name("Development") + .with_id("dev") + .with_chain_type(ChainType::Development) + .with_genesis_config_patch(testnet_genesis( + // initial collators. + vec![ + ( + get_account_id_from_seed::("Alice"), + get_collator_keys_from_seed("Alice"), + ), + ( + get_account_id_from_seed::("Bob"), + get_collator_keys_from_seed("Bob"), + ), + ], + vec![ + get_account_id_from_seed::("Alice"), + get_account_id_from_seed::("Bob"), + get_account_id_from_seed::("Charlie"), + get_account_id_from_seed::("Dave"), + get_account_id_from_seed::("Eve"), + get_account_id_from_seed::("Ferdie"), + get_account_id_from_seed::("Alice//stash"), + get_account_id_from_seed::("Bob//stash"), + get_account_id_from_seed::("Charlie//stash"), + get_account_id_from_seed::("Dave//stash"), + get_account_id_from_seed::("Eve//stash"), + get_account_id_from_seed::("Ferdie//stash"), + ], + get_account_id_from_seed::("Alice"), + 1000.into(), + )) + .build() } pub fn local_testnet_config() -> ChainSpec { @@ -117,50 +120,50 @@ pub fn local_testnet_config() -> ChainSpec { properties.insert("tokenDecimals".into(), 12.into()); properties.insert("ss58Format".into(), 42.into()); - #[allow(deprecated)] - ChainSpec::builder( - pop_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"), - Extensions { - relay_chain: "rococo-local".into(), - // You MUST set this to the correct network! - para_id: 1000, - }, - ) - .with_name("Local Testnet") - .with_id("local_testnet") - .with_chain_type(ChainType::Local) - .with_genesis_config_patch(testnet_genesis( - // initial collators. - vec![ - ( - get_account_id_from_seed::("Alice"), - get_collator_keys_from_seed("Alice"), - ), - ( - get_account_id_from_seed::("Bob"), - get_collator_keys_from_seed("Bob"), - ), - ], - vec![ - get_account_id_from_seed::("Alice"), - get_account_id_from_seed::("Bob"), - get_account_id_from_seed::("Charlie"), - get_account_id_from_seed::("Dave"), - get_account_id_from_seed::("Eve"), - get_account_id_from_seed::("Ferdie"), - get_account_id_from_seed::("Alice//stash"), - get_account_id_from_seed::("Bob//stash"), - get_account_id_from_seed::("Charlie//stash"), - get_account_id_from_seed::("Dave//stash"), - get_account_id_from_seed::("Eve//stash"), - get_account_id_from_seed::("Ferdie//stash"), - ], - get_account_id_from_seed::("Alice"), - 1000.into(), - )) - .with_protocol_id("pop-local") - .with_properties(properties) - .build() + #[allow(deprecated)] + ChainSpec::builder( + pop_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"), + Extensions { + relay_chain: "rococo-local".into(), + // You MUST set this to the correct network! + para_id: PARA_ID, + }, + ) + .with_name("Local Testnet") + .with_id("local_testnet") + .with_chain_type(ChainType::Local) + .with_genesis_config_patch(testnet_genesis( + // initial collators. + vec![ + ( + get_account_id_from_seed::("Alice"), + get_collator_keys_from_seed("Alice"), + ), + ( + get_account_id_from_seed::("Bob"), + get_collator_keys_from_seed("Bob"), + ), + ], + vec![ + get_account_id_from_seed::("Alice"), + get_account_id_from_seed::("Bob"), + get_account_id_from_seed::("Charlie"), + get_account_id_from_seed::("Dave"), + get_account_id_from_seed::("Eve"), + get_account_id_from_seed::("Ferdie"), + get_account_id_from_seed::("Alice//stash"), + get_account_id_from_seed::("Bob//stash"), + get_account_id_from_seed::("Charlie//stash"), + get_account_id_from_seed::("Dave//stash"), + get_account_id_from_seed::("Eve//stash"), + get_account_id_from_seed::("Ferdie//stash"), + ], + get_account_id_from_seed::("Alice"), + 1000.into(), + )) + .with_protocol_id("pop-local") + .with_properties(properties) + .build() } fn testnet_genesis( diff --git a/node/src/lib.rs b/node/src/lib.rs new file mode 100644 index 000000000..514487d1f --- /dev/null +++ b/node/src/lib.rs @@ -0,0 +1 @@ +pub mod chain_spec; diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 7f69e8d52..bbbf67d93 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -77,7 +77,7 @@ pub type Signature = MultiSignature; pub type AccountId = <::Signer as IdentifyAccount>::AccountId; /// Balance of an account. -pub type Balance = u128; +pub type Balance = parachains_common::Balance; /// Index of a transaction in the chain. pub type Nonce = u32; From 7bcaccc58c5e12bc791f1e2d716acf262a1aadf7 Mon Sep 17 00:00:00 2001 From: Peter White Date: Thu, 7 Mar 2024 12:10:45 -0700 Subject: [PATCH 06/23] chore: update toml and comment --- Cargo.lock | 133 ++++++++++++++++++ Cargo.toml | 5 +- emulated-integration-tests/Cargo.toml | 4 +- .../src/chains/rococo/genesis.rs | 2 +- node/src/chain_spec.rs | 6 +- 5 files changed, 141 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9def0c9e3..8b8dbf7e6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -594,6 +594,139 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b34d609dfbaf33d6889b2b7106d3ca345eacad44200913df5ba02bfd31d2ba9" +[[package]] +name = "asset-hub-rococo-runtime" +version = "0.11.0" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1#2a91d5abdc56ed27dab36030db5fa3c9c92e60a9" +dependencies = [ + "assets-common", + "bp-asset-hub-rococo", + "bp-asset-hub-westend", + "bp-bridge-hub-rococo", + "bp-bridge-hub-westend", + "cumulus-pallet-aura-ext", + "cumulus-pallet-parachain-system", + "cumulus-pallet-session-benchmarking", + "cumulus-pallet-xcm", + "cumulus-pallet-xcmp-queue", + "cumulus-primitives-aura", + "cumulus-primitives-core", + "cumulus-primitives-utility", + "frame-benchmarking", + "frame-executive", + "frame-support", + "frame-system", + "frame-system-benchmarking", + "frame-system-rpc-runtime-api", + "frame-try-runtime", + "hex-literal", + "log", + "pallet-asset-conversion", + "pallet-asset-conversion-tx-payment", + "pallet-assets", + "pallet-aura", + "pallet-authorship", + "pallet-balances", + "pallet-collator-selection", + "pallet-message-queue", + "pallet-multisig", + "pallet-nft-fractionalization", + "pallet-nfts", + "pallet-nfts-runtime-api", + "pallet-proxy", + "pallet-session", + "pallet-state-trie-migration", + "pallet-timestamp", + "pallet-transaction-payment", + "pallet-transaction-payment-rpc-runtime-api", + "pallet-uniques", + "pallet-utility", + "pallet-xcm", + "pallet-xcm-benchmarks", + "pallet-xcm-bridge-hub-router", + "parachains-common", + "parity-scale-codec", + "polkadot-parachain-primitives", + "polkadot-runtime-common", + "primitive-types", + "rococo-runtime-constants", + "scale-info", + "snowbridge-router-primitives", + "sp-api", + "sp-block-builder", + "sp-consensus-aura", + "sp-core", + "sp-genesis-builder", + "sp-inherents", + "sp-offchain", + "sp-runtime", + "sp-session", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1)", + "sp-storage 19.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1)", + "sp-transaction-pool", + "sp-version", + "sp-weights", + "staging-parachain-info", + "staging-xcm", + "staging-xcm-builder", + "staging-xcm-executor", + "substrate-wasm-builder", + "testnet-parachains-constants", +] + +[[package]] +name = "asset-test-utils" +version = "7.0.0" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1#2a91d5abdc56ed27dab36030db5fa3c9c92e60a9" +dependencies = [ + "cumulus-pallet-parachain-system", + "cumulus-pallet-xcmp-queue", + "cumulus-primitives-core", + "frame-support", + "frame-system", + "pallet-asset-conversion", + "pallet-assets", + "pallet-balances", + "pallet-collator-selection", + "pallet-session", + "pallet-xcm", + "pallet-xcm-bridge-hub-router", + "parachains-common", + "parachains-runtimes-test-utils", + "parity-scale-codec", + "sp-io", + "sp-runtime", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1)", + "staging-parachain-info", + "staging-xcm", + "staging-xcm-builder", + "staging-xcm-executor", + "substrate-wasm-builder", +] + +[[package]] +name = "assets-common" +version = "0.7.0" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1#2a91d5abdc56ed27dab36030db5fa3c9c92e60a9" +dependencies = [ + "cumulus-primitives-core", + "frame-support", + "impl-trait-for-tuples", + "log", + "pallet-asset-conversion", + "pallet-xcm", + "parachains-common", + "parity-scale-codec", + "scale-info", + "sp-api", + "sp-runtime", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1)", + "staging-xcm", + "staging-xcm-builder", + "staging-xcm-executor", + "substrate-wasm-builder", +] + [[package]] name = "asset-hub-rococo-runtime" version = "0.11.0" diff --git a/Cargo.toml b/Cargo.toml index f9357334c..7a7153fe7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -38,9 +38,8 @@ substrate-wasm-builder = { git = "https://github.com/paritytech/polkadot-sdk", b substrate-build-script-utils = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1" } # Local - -pop-runtime = { path = "./runtime" } -pop-api-primitives = { path = "./pop-api/primitives", default-features = false } +pop-runtime = { path = "./runtime", default-features = false } +pop-node = { path = "./node", default-features = false } # Substrate sc-basic-authorship = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1" } diff --git a/emulated-integration-tests/Cargo.toml b/emulated-integration-tests/Cargo.toml index 0b56477c2..7218963ed 100644 --- a/emulated-integration-tests/Cargo.toml +++ b/emulated-integration-tests/Cargo.toml @@ -35,8 +35,8 @@ cumulus-primitives-core.workspace = true emulated-integration-tests-common.workspace = true # Local -pop-runtime = { path = "../runtime", default-features = false } -pop-node = { path = "../node", default-features = false } +pop-runtime.workspace = true +pop-node.workspace = true [features] default = ["std"] diff --git a/emulated-integration-tests/src/chains/rococo/genesis.rs b/emulated-integration-tests/src/chains/rococo/genesis.rs index 2160eb8b3..ecd63d0ba 100644 --- a/emulated-integration-tests/src/chains/rococo/genesis.rs +++ b/emulated-integration-tests/src/chains/rococo/genesis.rs @@ -2,8 +2,8 @@ use emulated_integration_tests_common::{ accounts, build_genesis_storage, get_account_id_from_seed, get_from_seed, get_host_config, validators, }; -use pop_runtime::Balance; use polkadot_primitives::{AssignmentId, ValidatorId}; +use pop_runtime::Balance; use rococo_runtime_constants::currency::UNITS as ROC; use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId; use sp_consensus_babe::AuthorityId as BabeId; diff --git a/node/src/chain_spec.rs b/node/src/chain_spec.rs index f61237a78..687ab6d95 100644 --- a/node/src/chain_spec.rs +++ b/node/src/chain_spec.rs @@ -12,7 +12,7 @@ pub type ChainSpec = sc_service::GenericChainSpec<(), Extensions>; /// The default XCM version to set in genesis config. pub const SAFE_XCM_VERSION: u32 = xcm::prelude::XCM_VERSION; -/// The para ID of Pop Network. +/// The local para ID of Pop Network. pub const PARA_ID: u32 = 909; /// Helper function to generate a crypto pair from seed @@ -108,7 +108,7 @@ pub fn development_config() -> ChainSpec { get_account_id_from_seed::("Ferdie//stash"), ], get_account_id_from_seed::("Alice"), - 1000.into(), + PARA_ID.into(), )) .build() } @@ -159,7 +159,7 @@ pub fn local_testnet_config() -> ChainSpec { get_account_id_from_seed::("Ferdie//stash"), ], get_account_id_from_seed::("Alice"), - 1000.into(), + PARA_ID.into(), )) .with_protocol_id("pop-local") .with_properties(properties) From 6c87cf691e7d63af002a7e310ff38dee48db8742 Mon Sep 17 00:00:00 2001 From: Peter White Date: Thu, 7 Mar 2024 13:58:37 -0700 Subject: [PATCH 07/23] chore: update .toml --- Cargo.lock | 352 ++++++++++++++++++----------------------------------- Cargo.toml | 1 + 2 files changed, 121 insertions(+), 232 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8b8dbf7e6..5333028b8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -84,9 +84,9 @@ dependencies = [ [[package]] name = "ahash" -version = "0.8.10" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b79b82693f705137f8fb9b37871d99e4f9a7df12b917eed79c3d3954830a60b" +checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" dependencies = [ "cfg-if", "getrandom 0.2.12", @@ -594,139 +594,6 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b34d609dfbaf33d6889b2b7106d3ca345eacad44200913df5ba02bfd31d2ba9" -[[package]] -name = "asset-hub-rococo-runtime" -version = "0.11.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1#2a91d5abdc56ed27dab36030db5fa3c9c92e60a9" -dependencies = [ - "assets-common", - "bp-asset-hub-rococo", - "bp-asset-hub-westend", - "bp-bridge-hub-rococo", - "bp-bridge-hub-westend", - "cumulus-pallet-aura-ext", - "cumulus-pallet-parachain-system", - "cumulus-pallet-session-benchmarking", - "cumulus-pallet-xcm", - "cumulus-pallet-xcmp-queue", - "cumulus-primitives-aura", - "cumulus-primitives-core", - "cumulus-primitives-utility", - "frame-benchmarking", - "frame-executive", - "frame-support", - "frame-system", - "frame-system-benchmarking", - "frame-system-rpc-runtime-api", - "frame-try-runtime", - "hex-literal", - "log", - "pallet-asset-conversion", - "pallet-asset-conversion-tx-payment", - "pallet-assets", - "pallet-aura", - "pallet-authorship", - "pallet-balances", - "pallet-collator-selection", - "pallet-message-queue", - "pallet-multisig", - "pallet-nft-fractionalization", - "pallet-nfts", - "pallet-nfts-runtime-api", - "pallet-proxy", - "pallet-session", - "pallet-state-trie-migration", - "pallet-timestamp", - "pallet-transaction-payment", - "pallet-transaction-payment-rpc-runtime-api", - "pallet-uniques", - "pallet-utility", - "pallet-xcm", - "pallet-xcm-benchmarks", - "pallet-xcm-bridge-hub-router", - "parachains-common", - "parity-scale-codec", - "polkadot-parachain-primitives", - "polkadot-runtime-common", - "primitive-types", - "rococo-runtime-constants", - "scale-info", - "snowbridge-router-primitives", - "sp-api", - "sp-block-builder", - "sp-consensus-aura", - "sp-core", - "sp-genesis-builder", - "sp-inherents", - "sp-offchain", - "sp-runtime", - "sp-session", - "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1)", - "sp-storage 19.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1)", - "sp-transaction-pool", - "sp-version", - "sp-weights", - "staging-parachain-info", - "staging-xcm", - "staging-xcm-builder", - "staging-xcm-executor", - "substrate-wasm-builder", - "testnet-parachains-constants", -] - -[[package]] -name = "asset-test-utils" -version = "7.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1#2a91d5abdc56ed27dab36030db5fa3c9c92e60a9" -dependencies = [ - "cumulus-pallet-parachain-system", - "cumulus-pallet-xcmp-queue", - "cumulus-primitives-core", - "frame-support", - "frame-system", - "pallet-asset-conversion", - "pallet-assets", - "pallet-balances", - "pallet-collator-selection", - "pallet-session", - "pallet-xcm", - "pallet-xcm-bridge-hub-router", - "parachains-common", - "parachains-runtimes-test-utils", - "parity-scale-codec", - "sp-io", - "sp-runtime", - "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1)", - "staging-parachain-info", - "staging-xcm", - "staging-xcm-builder", - "staging-xcm-executor", - "substrate-wasm-builder", -] - -[[package]] -name = "assets-common" -version = "0.7.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1#2a91d5abdc56ed27dab36030db5fa3c9c92e60a9" -dependencies = [ - "cumulus-primitives-core", - "frame-support", - "impl-trait-for-tuples", - "log", - "pallet-asset-conversion", - "pallet-xcm", - "parachains-common", - "parity-scale-codec", - "scale-info", - "sp-api", - "sp-runtime", - "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1)", - "staging-xcm", - "staging-xcm-builder", - "staging-xcm-executor", - "substrate-wasm-builder", -] - [[package]] name = "asset-hub-rococo-runtime" version = "0.11.0" @@ -1646,9 +1513,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.15.3" +version = "3.15.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ea184aa71bb362a1157c896979544cc23974e08fd265f29ea96b59f0b4a555b" +checksum = "7ff69b9dd49fd426c69a0db9fc04dd934cdb6645ff000864d98f7e2af8830eaa" [[package]] name = "byte-slice-cast" @@ -1735,10 +1602,11 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.88" +version = "1.0.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02f341c093d19155a6e41631ce5971aac4e9a868262212153124c15fa22d1cdc" +checksum = "8cd6604a82acf3039f1144f54b8eb34e91ffba622051189e71b781822d5ee1f5" dependencies = [ + "jobserver", "libc", ] @@ -1808,9 +1676,9 @@ dependencies = [ [[package]] name = "chrono" -version = "0.4.34" +version = "0.4.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bc015644b92d5890fab7489e49d21f879d5c990186827d42ec511919404f38b" +checksum = "8eaf5903dcbc0a39312feb77df2ff4c76387d591b9fc7b04a238dcf8bb62639a" dependencies = [ "android-tzdata", "iana-time-zone", @@ -1875,9 +1743,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.1" +version = "4.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c918d541ef2913577a0f9566e9ce27cb35b6df072075769e0b26cb5a554520da" +checksum = "b230ab84b0ffdf890d5a10abdbc8b83ae1c4918275daea1ab8801f71536b2651" dependencies = [ "clap_builder", "clap_derive", @@ -1885,9 +1753,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.1" +version = "4.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f3e7391dad68afb0c2ede1bf619f579a3dc9c2ec67f089baa397123a2f3d1eb" +checksum = "ae129e2e766ae0ec03484e609954119f123cc1fe650337e155d03b022f24f7b4" dependencies = [ "anstream", "anstyle", @@ -2025,9 +1893,9 @@ checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" [[package]] name = "const-random" -version = "0.1.17" +version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aaf16c9c2c612020bcfd042e170f6e32de9b9d75adb5277cdbbd2e2c8c8299a" +checksum = "87e00182fe74b066627d63b85fd550ac2998d4b0bd86bfed477a0ae4c7c71359" dependencies = [ "const-random-macro", ] @@ -2962,9 +2830,9 @@ dependencies = [ [[package]] name = "cxx" -version = "1.0.118" +version = "1.0.119" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2673ca5ae28334544ec2a6b18ebe666c42a2650abfb48abbd532ed409a44be2b" +checksum = "635179be18797d7e10edb9cd06c859580237750c7351f39ed9b298bfc17544ad" dependencies = [ "cc", "cxxbridge-flags", @@ -2974,9 +2842,9 @@ dependencies = [ [[package]] name = "cxx-build" -version = "1.0.118" +version = "1.0.119" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9df46fe0eb43066a332586114174c449a62c25689f85a08f28fdcc8e12c380b9" +checksum = "9324397d262f63ef77eb795d900c0d682a34a43ac0932bec049ed73055d52f63" dependencies = [ "cc", "codespan-reporting", @@ -2989,15 +2857,15 @@ dependencies = [ [[package]] name = "cxxbridge-flags" -version = "1.0.118" +version = "1.0.119" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "886acf875df67811c11cd015506b3392b9e1820b1627af1a6f4e93ccdfc74d11" +checksum = "a87ff7342ffaa54b7c61618e0ce2bbcf827eba6d55b923b83d82551acbbecfe5" [[package]] name = "cxxbridge-macro" -version = "1.0.118" +version = "1.0.119" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d151cc139c3080e07f448f93a1284577ab2283d2a44acd902c6fba9ec20b6de" +checksum = "70b5b86cf65fa0626d85720619d80b288013477a91a0389fa8bc716bf4903ad1" dependencies = [ "proc-macro2", "quote", @@ -3426,7 +3294,7 @@ dependencies = [ [[package]] name = "emulated-integration-tests" -version = "0.1.0" +version = "0.0.0" dependencies = [ "asset-hub-rococo-runtime", "asset-test-utils", @@ -3436,9 +3304,9 @@ dependencies = [ "pallet-assets", "pallet-balances", "pallet-message-queue", - "parachains-common", "parity-scale-codec", "polkadot-primitives", + "pop-node", "pop-runtime", "rococo-runtime", "rococo-runtime-constants", @@ -3558,9 +3426,9 @@ dependencies = [ [[package]] name = "env_logger" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c012a26a7f605efc424dd53697843a72be7dc86ad2d01f7814337794a12231d" +checksum = "38b35839ba51819680ba087cd351788c9a3c476841207e0b8cee0b04722343b9" dependencies = [ "anstream", "anstyle", @@ -3714,12 +3582,13 @@ dependencies = [ [[package]] name = "expander" -version = "2.0.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f86a749cf851891866c10515ef6c299b5c69661465e9c3bbe7e07a2b77fb0f7" +checksum = "00e83c02035136f1592a47964ea60c05a50e4ed8b5892cfac197063850898d4d" dependencies = [ "blake2 0.10.6", "fs-err", + "prettier-please", "proc-macro2", "quote", "syn 2.0.52", @@ -4123,7 +3992,7 @@ dependencies = [ "Inflector", "cfg-expr", "derive-syn-parse", - "expander 2.0.0", + "expander 2.1.0", "frame-support-procedural-tools", "itertools 0.10.5", "macro_magic", @@ -4455,11 +4324,11 @@ dependencies = [ [[package]] name = "ghash" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d930750de5717d2dd0b8c0d42c076c0e884c81a73e6cab859bbd2339c71e3e40" +checksum = "f0d8a4362ccb29cb0b265253fb0a2728f592895ee6854fd9bc13f2ffda266ff1" dependencies = [ - "opaque-debug 0.3.0", + "opaque-debug 0.3.1", "polyval", ] @@ -4560,7 +4429,7 @@ version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" dependencies = [ - "ahash 0.8.10", + "ahash 0.8.11", ] [[package]] @@ -4569,7 +4438,7 @@ version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" dependencies = [ - "ahash 0.8.10", + "ahash 0.8.11", "allocator-api2", "serde", ] @@ -4678,9 +4547,9 @@ dependencies = [ [[package]] name = "http" -version = "0.2.11" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8947b1a6fad4393052c7ba1f4cd97bed3e953a95c79c92ad9b051a04611d9fbb" +checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" dependencies = [ "bytes", "fnv", @@ -5252,11 +5121,20 @@ version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" +[[package]] +name = "jobserver" +version = "0.1.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab46a6e9526ddef3ae7f787c06f0f2600639ba80ea3eade3d8e670a2230f51d6" +dependencies = [ + "libc", +] + [[package]] name = "js-sys" -version = "0.3.68" +version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "406cda4b368d531c842222cf9d2600a9a4acce8d29423695379c6868a143a9ee" +checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" dependencies = [ "wasm-bindgen", ] @@ -5497,12 +5375,12 @@ checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" [[package]] name = "libloading" -version = "0.8.1" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c571b676ddfc9a8c12f1f3d3085a7b163966a8fd8098a90640953ce5f6170161" +checksum = "0c2a198fb6b0eada2a8df47933734e6d35d350665a33a3593d7164fa52c75c19" dependencies = [ "cfg-if", - "windows-sys 0.48.0", + "windows-targets 0.52.4", ] [[package]] @@ -6318,9 +6196,9 @@ dependencies = [ [[package]] name = "mio" -version = "0.8.10" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f3d0b296e374a4e6f3c7b0a1f5a51d748a0d34c85e7dc48fc3fa9a87657fe09" +checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" dependencies = [ "libc", "wasi 0.11.0+wasi-snapshot-preview1", @@ -6853,9 +6731,9 @@ checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" [[package]] name = "opaque-debug" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" +checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" [[package]] name = "openssl-probe" @@ -6892,7 +6770,7 @@ version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eedb646674596266dc9bb2b5c7eea7c36b32ecc7777eba0d510196972d72c4fd" dependencies = [ - "expander 2.0.0", + "expander 2.1.0", "indexmap 2.2.5", "itertools 0.11.0", "petgraph", @@ -8539,9 +8417,9 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pest" -version = "2.7.7" +version = "2.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "219c0dcc30b6a27553f9cc242972b67f75b60eb0db71f0b5462f38b058c41546" +checksum = "56f8023d0fb78c8e03784ea1c7f3fa36e68a723138990b8d5a47d916b651e7a8" dependencies = [ "memchr", "thiserror", @@ -8550,9 +8428,9 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.7.7" +version = "2.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22e1288dbd7786462961e69bfd4df7848c1e37e8b74303dbdab82c3a9cdd2809" +checksum = "b0d24f72393fd16ab6ac5738bc33cdb6a9aa73f8b902e8fe29cf4e67d7dd1026" dependencies = [ "pest", "pest_generator", @@ -8560,9 +8438,9 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.7.7" +version = "2.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1381c29a877c6d34b8c176e734f35d7f7f5b3adaefe940cb4d1bb7af94678e2e" +checksum = "fdc17e2a6c7d0a492f0158d7a4bd66cc17280308bbaff78d5bef566dca35ab80" dependencies = [ "pest", "pest_meta", @@ -8573,9 +8451,9 @@ dependencies = [ [[package]] name = "pest_meta" -version = "2.7.7" +version = "2.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0934d6907f148c22a3acbda520c7eed243ad7487a30f51f6ce52b58b7077a8a" +checksum = "934cd7631c050f4674352a6e835d5f6711ffbfb9345c2fc0107155ac495ae293" dependencies = [ "once_cell", "pest", @@ -8594,18 +8472,18 @@ dependencies = [ [[package]] name = "pin-project" -version = "1.1.4" +version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0302c4a0442c456bd56f841aee5c3bfd17967563f6fadc9ceb9f9c23cf3807e0" +checksum = "b6bf43b791c5b9e34c3d182969b4abb522f9343702850a2e57f460d00d09b4b3" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.1.4" +version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "266c042b60c9c76b8d53061e52b2e0d1116abc57cefc8c5cd671619a56ac3690" +checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", @@ -9835,19 +9713,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8159bd90725d2df49889a078b54f4f79e87f1f8a8444194cdca81d38f5393abf" dependencies = [ "cpufeatures", - "opaque-debug 0.3.0", + "opaque-debug 0.3.1", "universal-hash", ] [[package]] name = "polyval" -version = "0.6.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d52cff9d1d4dee5fe6d03729099f4a310a41179e0a10dbf542039873f2e826fb" +checksum = "9d1fe60d06143b2430aa532c94cfe9e29783047f06c0d7fd359a9a51b729fa25" dependencies = [ "cfg-if", "cpufeatures", - "opaque-debug 0.3.0", + "opaque-debug 0.3.1", "universal-hash", ] @@ -9941,7 +9819,7 @@ dependencies = [ "cumulus-primitives-core", "cumulus-primitives-utility", "enumflags2", - "env_logger 0.11.2", + "env_logger 0.11.3", "frame-benchmarking", "frame-executive", "frame-support", @@ -10045,11 +9923,21 @@ dependencies = [ "termtree", ] +[[package]] +name = "prettier-please" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22020dfcf177fcc7bf5deaf7440af371400c67c0de14c399938d8ed4fb4645d3" +dependencies = [ + "proc-macro2", + "syn 2.0.52", +] + [[package]] name = "prettyplease" -version = "0.1.25" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8646e95016a7a6c4adea95bafa8a16baab64b583356217f2c85db4a39d9a86" +checksum = "f28f53e8b192565862cf99343194579a022eb9c7dd3a8d03134734803c7b3125" dependencies = [ "proc-macro2", "syn 1.0.109", @@ -10238,7 +10126,7 @@ dependencies = [ "log", "multimap", "petgraph", - "prettyplease 0.1.25", + "prettyplease 0.1.11", "prost 0.11.9", "prost-types", "regex", @@ -10572,7 +10460,7 @@ checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.4.5", + "regex-automata 0.4.6", "regex-syntax 0.8.2", ] @@ -10587,9 +10475,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bb987efffd3c6d0d8f5f89510bb458559eab11e4f869acb20bf845e016259cd" +checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" dependencies = [ "aho-corasick", "memchr", @@ -11440,7 +11328,7 @@ name = "sc-consensus-grandpa" version = "0.19.0" source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1#2a91d5abdc56ed27dab36030db5fa3c9c92e60a9" dependencies = [ - "ahash 0.8.10", + "ahash 0.8.11", "array-bytes 6.2.2", "async-trait", "dyn-clone", @@ -11718,7 +11606,7 @@ name = "sc-network-gossip" version = "0.34.0" source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1#2a91d5abdc56ed27dab36030db5fa3c9c92e60a9" dependencies = [ - "ahash 0.8.10", + "ahash 0.8.11", "futures", "futures-timer", "libp2p", @@ -12297,7 +12185,7 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "772575a524feeb803e5b0fcbc6dd9f367e579488197c94c6e4023aad2305774d" dependencies = [ - "ahash 0.8.10", + "ahash 0.8.11", "cfg-if", "hashbrown 0.13.2", ] @@ -12578,7 +12466,7 @@ dependencies = [ "cfg-if", "cpufeatures", "digest 0.9.0", - "opaque-debug 0.3.0", + "opaque-debug 0.3.1", ] [[package]] @@ -12614,7 +12502,7 @@ dependencies = [ "cfg-if", "cpufeatures", "digest 0.9.0", - "opaque-debug 0.3.0", + "opaque-debug 0.3.1", ] [[package]] @@ -13056,7 +12944,7 @@ source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot dependencies = [ "Inflector", "blake2 0.10.6", - "expander 2.0.0", + "expander 2.1.0", "proc-macro-crate 3.1.0", "proc-macro2", "quote", @@ -13844,7 +13732,7 @@ version = "17.0.0" source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1#2a91d5abdc56ed27dab36030db5fa3c9c92e60a9" dependencies = [ "Inflector", - "expander 2.0.0", + "expander 2.1.0", "proc-macro-crate 3.1.0", "proc-macro2", "quote", @@ -13857,7 +13745,7 @@ version = "17.0.0" source = "git+https://github.com/paritytech/polkadot-sdk#629506ce061db76d31d4f7a81f4a497752b27259" dependencies = [ "Inflector", - "expander 2.0.0", + "expander 2.1.0", "proc-macro-crate 3.1.0", "proc-macro2", "quote", @@ -14096,7 +13984,7 @@ version = "22.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "48e4eeb7ef23f79eba8609db79ef9cef242f994f1f87a3c0387b4b5f177fda74" dependencies = [ - "ahash 0.8.10", + "ahash 0.8.11", "hash-db", "hashbrown 0.13.2", "lazy_static", @@ -14119,7 +14007,7 @@ name = "sp-trie" version = "29.0.0" source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1#2a91d5abdc56ed27dab36030db5fa3c9c92e60a9" dependencies = [ - "ahash 0.8.10", + "ahash 0.8.11", "hash-db", "lazy_static", "memory-db", @@ -14491,13 +14379,13 @@ dependencies = [ [[package]] name = "substrate-bip39" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e620c7098893ba667438b47169c00aacdd9e7c10e042250ce2b60b087ec97328" +checksum = "6a7590dc041b9bc2825e52ce5af8416c73dbe9d0654402bfd4b4941938b94d8f" dependencies = [ "hmac 0.11.0", "pbkdf2 0.8.0", - "schnorrkel 0.9.1", + "schnorrkel 0.11.4", "sha2 0.9.9", "zeroize", ] @@ -15164,7 +15052,7 @@ name = "tracing-gum-proc-macro" version = "5.0.0" source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1#2a91d5abdc56ed27dab36030db5fa3c9c92e60a9" dependencies = [ - "expander 2.0.0", + "expander 2.1.0", "proc-macro-crate 3.1.0", "proc-macro2", "quote", @@ -15520,9 +15408,9 @@ checksum = "f3c4517f54858c779bbcbf228f4fca63d121bf85fbecb2dc578cdf4a39395690" [[package]] name = "walkdir" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" dependencies = [ "same-file", "winapi-util", @@ -15560,9 +15448,9 @@ dependencies = [ [[package]] name = "wasm-bindgen" -version = "0.2.91" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1e124130aee3fb58c5bdd6b639a0509486b0338acaaae0c84a5124b0f588b7f" +checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -15570,9 +15458,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.91" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9e7e1900c352b609c8488ad12639a311045f40a35491fb69ba8c12f758af70b" +checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" dependencies = [ "bumpalo", "log", @@ -15585,9 +15473,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.41" +version = "0.4.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "877b9c3f61ceea0e56331985743b13f3d25c406a7098d45180fb5f09bc19ed97" +checksum = "76bc14366121efc8dbb487ab05bcc9d346b3b5ec0eaa76e46594cabbe51762c0" dependencies = [ "cfg-if", "js-sys", @@ -15597,9 +15485,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.91" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b30af9e2d358182b5c7449424f017eba305ed32a7010509ede96cdc4696c46ed" +checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -15607,9 +15495,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.91" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "642f325be6301eb8107a83d12a8ac6c1e1c54345a7ef1a9261962dfefda09e66" +checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", @@ -15620,9 +15508,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.91" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f186bd2dcf04330886ce82d6f33dd75a7bfcf69ecf5763b89fcde53b6ac9838" +checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" [[package]] name = "wasm-instrument" @@ -15935,9 +15823,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.68" +version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96565907687f7aceb35bc5fc03770a8a0471d82e479f25832f54a0e3f4b28446" +checksum = "77afa9a11836342370f4817622a2f0f418b134426d91a82dfb48f532d2ec13ef" dependencies = [ "js-sys", "wasm-bindgen", diff --git a/Cargo.toml b/Cargo.toml index 7a7153fe7..e11c7d8d1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -40,6 +40,7 @@ substrate-build-script-utils = { git = "https://github.com/paritytech/polkadot-s # Local pop-runtime = { path = "./runtime", default-features = false } pop-node = { path = "./node", default-features = false } +pop-api-primitives = { path = "./pop-api/primitives", default-features = false } # Substrate sc-basic-authorship = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1" } From 65bdefddeca6db31a89434296958dbb65f3cf747 Mon Sep 17 00:00:00 2001 From: Peter White Date: Thu, 7 Mar 2024 14:00:14 -0700 Subject: [PATCH 08/23] style: cargo fmt --- .../src/chains/asset_hub_rococo/genesis.rs | 86 +- .../src/chains/asset_hub_rococo/mod.rs | 44 +- .../src/chains/pop_network/genesis.rs | 84 +- .../src/chains/pop_network/mod.rs | 42 +- .../src/chains/rococo/genesis.rs | 117 +- .../src/chains/rococo/mod.rs | 36 +- emulated-integration-tests/src/lib.rs | 1115 ++++++++--------- node/src/chain_spec.rs | 170 +-- 8 files changed, 829 insertions(+), 865 deletions(-) diff --git a/emulated-integration-tests/src/chains/asset_hub_rococo/genesis.rs b/emulated-integration-tests/src/chains/asset_hub_rococo/genesis.rs index 0455fcf7d..f21f7a606 100644 --- a/emulated-integration-tests/src/chains/asset_hub_rococo/genesis.rs +++ b/emulated-integration-tests/src/chains/asset_hub_rococo/genesis.rs @@ -1,5 +1,5 @@ use emulated_integration_tests_common::{ - accounts, build_genesis_storage, collators, SAFE_XCM_VERSION, + accounts, build_genesis_storage, collators, SAFE_XCM_VERSION, }; use pop_runtime::Balance; use sp_core::storage::Storage; @@ -8,49 +8,45 @@ pub(crate) const PARA_ID: u32 = 1000; pub(crate) const ED: Balance = rococo_runtime_constants::currency::EXISTENTIAL_DEPOSIT / 10; pub(crate) fn genesis() -> Storage { - let genesis_config = asset_hub_rococo_runtime::RuntimeGenesisConfig { - system: asset_hub_rococo_runtime::SystemConfig::default(), - balances: asset_hub_rococo_runtime::BalancesConfig { - balances: accounts::init_balances() - .iter() - .cloned() - .map(|k| (k, ED * 4096 * 4096)) - .collect(), - }, - parachain_info: asset_hub_rococo_runtime::ParachainInfoConfig { - parachain_id: PARA_ID.into(), - ..Default::default() - }, - collator_selection: asset_hub_rococo_runtime::CollatorSelectionConfig { - invulnerables: collators::invulnerables() - .iter() - .cloned() - .map(|(acc, _)| acc) - .collect(), - candidacy_bond: ED * 16, - ..Default::default() - }, - session: asset_hub_rococo_runtime::SessionConfig { - keys: collators::invulnerables() - .into_iter() - .map(|(acc, aura)| { - ( - acc.clone(), // account id - acc, // validator id - asset_hub_rococo_runtime::SessionKeys { aura }, // session keys - ) - }) - .collect(), - }, - polkadot_xcm: asset_hub_rococo_runtime::PolkadotXcmConfig { - safe_xcm_version: Some(SAFE_XCM_VERSION), - ..Default::default() - }, - ..Default::default() - }; + let genesis_config = asset_hub_rococo_runtime::RuntimeGenesisConfig { + system: asset_hub_rococo_runtime::SystemConfig::default(), + balances: asset_hub_rococo_runtime::BalancesConfig { + balances: accounts::init_balances() + .iter() + .cloned() + .map(|k| (k, ED * 4096 * 4096)) + .collect(), + }, + parachain_info: asset_hub_rococo_runtime::ParachainInfoConfig { + parachain_id: PARA_ID.into(), + ..Default::default() + }, + collator_selection: asset_hub_rococo_runtime::CollatorSelectionConfig { + invulnerables: collators::invulnerables().iter().cloned().map(|(acc, _)| acc).collect(), + candidacy_bond: ED * 16, + ..Default::default() + }, + session: asset_hub_rococo_runtime::SessionConfig { + keys: collators::invulnerables() + .into_iter() + .map(|(acc, aura)| { + ( + acc.clone(), // account id + acc, // validator id + asset_hub_rococo_runtime::SessionKeys { aura }, // session keys + ) + }) + .collect(), + }, + polkadot_xcm: asset_hub_rococo_runtime::PolkadotXcmConfig { + safe_xcm_version: Some(SAFE_XCM_VERSION), + ..Default::default() + }, + ..Default::default() + }; - build_genesis_storage( - &genesis_config, - asset_hub_rococo_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"), - ) + build_genesis_storage( + &genesis_config, + asset_hub_rococo_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"), + ) } diff --git a/emulated-integration-tests/src/chains/asset_hub_rococo/mod.rs b/emulated-integration-tests/src/chains/asset_hub_rococo/mod.rs index f72503285..4f119eaaa 100644 --- a/emulated-integration-tests/src/chains/asset_hub_rococo/mod.rs +++ b/emulated-integration-tests/src/chains/asset_hub_rococo/mod.rs @@ -2,33 +2,33 @@ pub(crate) mod genesis; use crate::chains::rococo::Rococo; use emulated_integration_tests_common::{ - impl_accounts_helpers_for_parachain, impl_assert_events_helpers_for_parachain, - impl_assets_helpers_for_parachain, impl_foreign_assets_helpers_for_parachain, - impl_xcm_helpers_for_parachain, impls::Parachain, xcm_emulator::decl_test_parachains, + impl_accounts_helpers_for_parachain, impl_assert_events_helpers_for_parachain, + impl_assets_helpers_for_parachain, impl_foreign_assets_helpers_for_parachain, + impl_xcm_helpers_for_parachain, impls::Parachain, xcm_emulator::decl_test_parachains, }; use frame_support::traits::OnInitialize; // AssetHubRococo Parachain declaration decl_test_parachains! { - pub struct AssetHubRococo { - genesis = genesis::genesis(), - on_init = { - asset_hub_rococo_runtime::AuraExt::on_initialize(1); - }, - runtime = asset_hub_rococo_runtime, - core = { - XcmpMessageHandler: asset_hub_rococo_runtime::XcmpQueue, - LocationToAccountId: asset_hub_rococo_runtime::xcm_config::LocationToAccountId, - ParachainInfo: asset_hub_rococo_runtime::ParachainInfo, - MessageOrigin: cumulus_primitives_core::AggregateMessageOrigin, - }, - pallets = { - PolkadotXcm: asset_hub_rococo_runtime::PolkadotXcm, - Assets: asset_hub_rococo_runtime::Assets, - ForeignAssets: asset_hub_rococo_runtime::ForeignAssets, - Balances: asset_hub_rococo_runtime::Balances, - } - }, + pub struct AssetHubRococo { + genesis = genesis::genesis(), + on_init = { + asset_hub_rococo_runtime::AuraExt::on_initialize(1); + }, + runtime = asset_hub_rococo_runtime, + core = { + XcmpMessageHandler: asset_hub_rococo_runtime::XcmpQueue, + LocationToAccountId: asset_hub_rococo_runtime::xcm_config::LocationToAccountId, + ParachainInfo: asset_hub_rococo_runtime::ParachainInfo, + MessageOrigin: cumulus_primitives_core::AggregateMessageOrigin, + }, + pallets = { + PolkadotXcm: asset_hub_rococo_runtime::PolkadotXcm, + Assets: asset_hub_rococo_runtime::Assets, + ForeignAssets: asset_hub_rococo_runtime::ForeignAssets, + Balances: asset_hub_rococo_runtime::Balances, + } + }, } // AssetHubRococo implementation diff --git a/emulated-integration-tests/src/chains/pop_network/genesis.rs b/emulated-integration-tests/src/chains/pop_network/genesis.rs index aca811b05..073226821 100644 --- a/emulated-integration-tests/src/chains/pop_network/genesis.rs +++ b/emulated-integration-tests/src/chains/pop_network/genesis.rs @@ -6,49 +6,45 @@ use sp_core::storage::Storage; pub(crate) const ED: Balance = pop_runtime::EXISTENTIAL_DEPOSIT; pub(crate) fn genesis() -> Storage { - let genesis_config = pop_runtime::RuntimeGenesisConfig { - system: pop_runtime::SystemConfig::default(), - balances: pop_runtime::BalancesConfig { - balances: accounts::init_balances() - .iter() - .cloned() - .map(|k| (k, ED * 4096 * 4096)) - .collect(), - }, - parachain_info: pop_runtime::ParachainInfoConfig { - parachain_id: PARA_ID.into(), - ..Default::default() - }, - collator_selection: pop_runtime::CollatorSelectionConfig { - invulnerables: collators::invulnerables() - .iter() - .cloned() - .map(|(acc, _)| acc) - .collect(), - candidacy_bond: ED * 16, - ..Default::default() - }, - session: pop_runtime::SessionConfig { - keys: collators::invulnerables() - .into_iter() - .map(|(acc, aura)| { - ( - acc.clone(), // account id - acc, // validator id - pop_runtime::SessionKeys { aura }, // session keys - ) - }) - .collect(), - }, - polkadot_xcm: pop_runtime::PolkadotXcmConfig { - safe_xcm_version: Some(SAFE_XCM_VERSION), - ..Default::default() - }, - ..Default::default() - }; + let genesis_config = pop_runtime::RuntimeGenesisConfig { + system: pop_runtime::SystemConfig::default(), + balances: pop_runtime::BalancesConfig { + balances: accounts::init_balances() + .iter() + .cloned() + .map(|k| (k, ED * 4096 * 4096)) + .collect(), + }, + parachain_info: pop_runtime::ParachainInfoConfig { + parachain_id: PARA_ID.into(), + ..Default::default() + }, + collator_selection: pop_runtime::CollatorSelectionConfig { + invulnerables: collators::invulnerables().iter().cloned().map(|(acc, _)| acc).collect(), + candidacy_bond: ED * 16, + ..Default::default() + }, + session: pop_runtime::SessionConfig { + keys: collators::invulnerables() + .into_iter() + .map(|(acc, aura)| { + ( + acc.clone(), // account id + acc, // validator id + pop_runtime::SessionKeys { aura }, // session keys + ) + }) + .collect(), + }, + polkadot_xcm: pop_runtime::PolkadotXcmConfig { + safe_xcm_version: Some(SAFE_XCM_VERSION), + ..Default::default() + }, + ..Default::default() + }; - build_genesis_storage( - &genesis_config, - pop_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"), - ) + build_genesis_storage( + &genesis_config, + pop_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"), + ) } diff --git a/emulated-integration-tests/src/chains/pop_network/mod.rs b/emulated-integration-tests/src/chains/pop_network/mod.rs index 861228244..19a35877e 100644 --- a/emulated-integration-tests/src/chains/pop_network/mod.rs +++ b/emulated-integration-tests/src/chains/pop_network/mod.rs @@ -2,32 +2,32 @@ pub(crate) mod genesis; use crate::chains::rococo::Rococo; use emulated_integration_tests_common::{ - impl_accounts_helpers_for_parachain, impl_assert_events_helpers_for_parachain, - impl_assets_helpers_for_parachain, impl_xcm_helpers_for_parachain, impls::Parachain, - xcm_emulator::decl_test_parachains, + impl_accounts_helpers_for_parachain, impl_assert_events_helpers_for_parachain, + impl_assets_helpers_for_parachain, impl_xcm_helpers_for_parachain, impls::Parachain, + xcm_emulator::decl_test_parachains, }; use frame_support::traits::OnInitialize; // PopNetwork Parachain declaration decl_test_parachains! { - pub struct PopNetwork { - genesis = genesis::genesis(), - on_init = { - pop_runtime::AuraExt::on_initialize(1); - }, - runtime = pop_runtime, - core = { - XcmpMessageHandler: pop_runtime::XcmpQueue, - LocationToAccountId: pop_runtime::xcm_config::LocationToAccountId, - ParachainInfo: pop_runtime::ParachainInfo, - MessageOrigin: cumulus_primitives_core::AggregateMessageOrigin, - }, - pallets = { - PolkadotXcm: pop_runtime::PolkadotXcm, - Assets: pop_runtime::Assets, - Balances: pop_runtime::Balances, - } - }, + pub struct PopNetwork { + genesis = genesis::genesis(), + on_init = { + pop_runtime::AuraExt::on_initialize(1); + }, + runtime = pop_runtime, + core = { + XcmpMessageHandler: pop_runtime::XcmpQueue, + LocationToAccountId: pop_runtime::xcm_config::LocationToAccountId, + ParachainInfo: pop_runtime::ParachainInfo, + MessageOrigin: cumulus_primitives_core::AggregateMessageOrigin, + }, + pallets = { + PolkadotXcm: pop_runtime::PolkadotXcm, + Assets: pop_runtime::Assets, + Balances: pop_runtime::Balances, + } + }, } // PopNetwork implementation diff --git a/emulated-integration-tests/src/chains/rococo/genesis.rs b/emulated-integration-tests/src/chains/rococo/genesis.rs index ecd63d0ba..70c185d7f 100644 --- a/emulated-integration-tests/src/chains/rococo/genesis.rs +++ b/emulated-integration-tests/src/chains/rococo/genesis.rs @@ -1,6 +1,6 @@ use emulated_integration_tests_common::{ - accounts, build_genesis_storage, get_account_id_from_seed, get_from_seed, get_host_config, - validators, + accounts, build_genesis_storage, get_account_id_from_seed, get_from_seed, get_host_config, + validators, }; use polkadot_primitives::{AssignmentId, ValidatorId}; use pop_runtime::Balance; @@ -15,68 +15,63 @@ pub(crate) const ED: Balance = rococo_runtime_constants::currency::EXISTENTIAL_D const ENDOWMENT: u128 = 1_000_000 * ROC; fn session_keys( - babe: BabeId, - grandpa: GrandpaId, - para_validator: ValidatorId, - para_assignment: AssignmentId, - authority_discovery: AuthorityDiscoveryId, - beefy: BeefyId, + babe: BabeId, + grandpa: GrandpaId, + para_validator: ValidatorId, + para_assignment: AssignmentId, + authority_discovery: AuthorityDiscoveryId, + beefy: BeefyId, ) -> rococo_runtime::SessionKeys { - rococo_runtime::SessionKeys { - babe, - grandpa, - para_validator, - para_assignment, - authority_discovery, - beefy, - } + rococo_runtime::SessionKeys { + babe, + grandpa, + para_validator, + para_assignment, + authority_discovery, + beefy, + } } pub(crate) fn genesis() -> Storage { - let genesis_config = rococo_runtime::RuntimeGenesisConfig { - system: rococo_runtime::SystemConfig::default(), - balances: rococo_runtime::BalancesConfig { - balances: accounts::init_balances() - .iter() - .map(|k| (k.clone(), ENDOWMENT)) - .collect(), - }, - session: rococo_runtime::SessionConfig { - keys: validators::initial_authorities() - .iter() - .map(|x| { - ( - x.0.clone(), - x.0.clone(), - session_keys( - x.2.clone(), - x.3.clone(), - x.4.clone(), - x.5.clone(), - x.6.clone(), - get_from_seed::("Alice"), - ), - ) - }) - .collect::>(), - }, - babe: rococo_runtime::BabeConfig { - authorities: Default::default(), - epoch_config: Some(rococo_runtime::BABE_GENESIS_EPOCH_CONFIG), - ..Default::default() - }, - sudo: rococo_runtime::SudoConfig { - key: Some(get_account_id_from_seed::("Alice")), - }, - configuration: rococo_runtime::ConfigurationConfig { - config: get_host_config(), - }, - registrar: rococo_runtime::RegistrarConfig { - next_free_para_id: polkadot_primitives::LOWEST_PUBLIC_ID, - ..Default::default() - }, - ..Default::default() - }; + let genesis_config = rococo_runtime::RuntimeGenesisConfig { + system: rococo_runtime::SystemConfig::default(), + balances: rococo_runtime::BalancesConfig { + balances: accounts::init_balances().iter().map(|k| (k.clone(), ENDOWMENT)).collect(), + }, + session: rococo_runtime::SessionConfig { + keys: validators::initial_authorities() + .iter() + .map(|x| { + ( + x.0.clone(), + x.0.clone(), + session_keys( + x.2.clone(), + x.3.clone(), + x.4.clone(), + x.5.clone(), + x.6.clone(), + get_from_seed::("Alice"), + ), + ) + }) + .collect::>(), + }, + babe: rococo_runtime::BabeConfig { + authorities: Default::default(), + epoch_config: Some(rococo_runtime::BABE_GENESIS_EPOCH_CONFIG), + ..Default::default() + }, + sudo: rococo_runtime::SudoConfig { + key: Some(get_account_id_from_seed::("Alice")), + }, + configuration: rococo_runtime::ConfigurationConfig { config: get_host_config() }, + registrar: rococo_runtime::RegistrarConfig { + next_free_para_id: polkadot_primitives::LOWEST_PUBLIC_ID, + ..Default::default() + }, + ..Default::default() + }; - build_genesis_storage(&genesis_config, rococo_runtime::WASM_BINARY.unwrap()) + build_genesis_storage(&genesis_config, rococo_runtime::WASM_BINARY.unwrap()) } diff --git a/emulated-integration-tests/src/chains/rococo/mod.rs b/emulated-integration-tests/src/chains/rococo/mod.rs index 0569e183c..71d6f1ef8 100644 --- a/emulated-integration-tests/src/chains/rococo/mod.rs +++ b/emulated-integration-tests/src/chains/rococo/mod.rs @@ -1,28 +1,28 @@ pub(crate) mod genesis; use emulated_integration_tests_common::{ - impl_accounts_helpers_for_relay_chain, impl_assert_events_helpers_for_relay_chain, - impl_hrmp_channels_helpers_for_relay_chain, impl_send_transact_helpers_for_relay_chain, - xcm_emulator::decl_test_relay_chains, + impl_accounts_helpers_for_relay_chain, impl_assert_events_helpers_for_relay_chain, + impl_hrmp_channels_helpers_for_relay_chain, impl_send_transact_helpers_for_relay_chain, + xcm_emulator::decl_test_relay_chains, }; // Rococo declaration decl_test_relay_chains! { - #[api_version(10)] - pub struct Rococo { - genesis = genesis::genesis(), - on_init = (), - runtime = rococo_runtime, - core = { - SovereignAccountOf: rococo_runtime::xcm_config::LocationConverter, - }, - pallets = { - XcmPallet: rococo_runtime::XcmPallet, - Sudo: rococo_runtime::Sudo, - Balances: rococo_runtime::Balances, - Hrmp: rococo_runtime::Hrmp, - } - }, + #[api_version(10)] + pub struct Rococo { + genesis = genesis::genesis(), + on_init = (), + runtime = rococo_runtime, + core = { + SovereignAccountOf: rococo_runtime::xcm_config::LocationConverter, + }, + pallets = { + XcmPallet: rococo_runtime::XcmPallet, + Sudo: rococo_runtime::Sudo, + Balances: rococo_runtime::Balances, + Hrmp: rococo_runtime::Hrmp, + } + }, } // Rococo implementation diff --git a/emulated-integration-tests/src/lib.rs b/emulated-integration-tests/src/lib.rs index b5b5c4dcb..5aaf41a84 100644 --- a/emulated-integration-tests/src/lib.rs +++ b/emulated-integration-tests/src/lib.rs @@ -3,201 +3,212 @@ mod chains; #[cfg(test)] mod tests { - use crate::chains::{ - asset_hub_rococo::{ - genesis::ED as ASSET_HUB_ROCOCO_ED, AssetHubRococo, AssetHubRococoParaPallet, - }, - pop_network::{PopNetwork, PopNetworkParaPallet}, - rococo::{genesis::ED as ROCOCO_ED, Rococo, RococoRelayPallet}, - }; - use asset_hub_rococo_runtime::xcm_config::XcmConfig as AssetHubRococoXcmConfig; - use asset_test_utils::xcm_helpers; - use emulated_integration_tests_common::{ - accounts::{ALICE, BOB}, - xcm_emulator::{ - assert_expected_events, bx, decl_test_networks, - decl_test_sender_receiver_accounts_parameter_types, Chain, Parachain as Para, - RelayChain as Relay, Test, TestArgs, TestContext, TestExt, - }, - }; - use frame_support::{ - assert_err, - pallet_prelude::Weight, - sp_runtime::{DispatchError, DispatchResult}, - traits::fungibles::Inspect, - }; - use pop_runtime::{xcm_config::XcmConfig as PopNetworkXcmConfig, Balance}; - use rococo_runtime::xcm_config::XcmConfig as RococoXcmConfig; - use xcm::prelude::{AccountId32 as AccountId32Junction, *}; - - decl_test_networks! { - // `pub` mandatory for the macro - pub struct RococoMockNet { - relay_chain = Rococo, - parachains = vec![ - AssetHubRococo, - PopNetwork, - ], - bridge = () - }, - } - - decl_test_sender_receiver_accounts_parameter_types! { - RococoRelay { sender: ALICE, receiver: BOB }, - AssetHubRococoPara { sender: ALICE, receiver: BOB }, - PopNetworkPara { sender: ALICE, receiver: BOB} - } - - const ASSET_ID: u32 = 1; - const ASSET_MIN_BALANCE: u128 = 1000; - const ASSETS_PALLET_ID: u8 = 50; - - type RelayToParaTest = Test; - type SystemParaToParaTest = Test; - type ParaToSystemParaTest = Test; - - fn relay_to_para_sender_assertions(t: RelayToParaTest) { - type RuntimeEvent = ::RuntimeEvent; - RococoRelay::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts( - 864_610_000, - 8_799, - ))); - assert_expected_events!( - RococoRelay, - vec![ - // Amount to reserve transfer is transferred to Parachain's Sovereign account - RuntimeEvent::Balances( - pallet_balances::Event::Transfer { from, to, amount } - ) => { - from: *from == t.sender.account_id, - to: *to == RococoRelay::sovereign_account_id_of( - t.args.dest.clone() - ), - amount: *amount == t.args.amount, - }, - ] - ); - } - - fn system_para_to_para_sender_assertions(t: SystemParaToParaTest) { - type RuntimeEvent = ::RuntimeEvent; - AssetHubRococoPara::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts( - 864_610_000, - 8_799, - ))); - assert_expected_events!( - AssetHubRococoPara, - vec![ - // Amount to reserve transfer is transferred to Parachain's Sovereign account - RuntimeEvent::Balances( - pallet_balances::Event::Transfer { from, to, amount } - ) => { - from: *from == t.sender.account_id, - to: *to == AssetHubRococoPara::sovereign_account_id_of( - t.args.dest.clone() - ), - amount: *amount == t.args.amount, - }, - ] - ); - } - - fn para_receiver_assertions(_: Test) { - type RuntimeEvent = ::RuntimeEvent; - assert_expected_events!( - PopNetworkPara, - vec![ - RuntimeEvent::Balances(pallet_balances::Event::Deposit { .. }) => {}, - RuntimeEvent::MessageQueue( - pallet_message_queue::Event::Processed { success: true, .. } - ) => {}, - ] - ); - } - - fn para_to_system_para_sender_assertions(t: ParaToSystemParaTest) { - type RuntimeEvent = ::RuntimeEvent; - PopNetworkPara::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts( - 864_610_000, - 8_799, - ))); - assert_expected_events!( - PopNetworkPara, - vec![ - // Amount to reserve transfer is transferred to Parachain's Sovereign account - RuntimeEvent::Balances( - pallet_balances::Event::Withdraw { who, amount } - ) => { - who: *who == t.sender.account_id, - amount: *amount == t.args.amount, - }, - ] - ); - } - - fn para_to_system_para_receiver_assertions(t: ParaToSystemParaTest) { - type RuntimeEvent = ::RuntimeEvent; - let sov_pop_net_on_ahr = AssetHubRococoPara::sovereign_account_id_of( - AssetHubRococoPara::sibling_location_of(PopNetworkPara::para_id()), - ); - assert_expected_events!( - AssetHubRococoPara, - vec![ - // Amount to reserve transfer is withdrawn from Parachain's Sovereign account - RuntimeEvent::Balances( - pallet_balances::Event::Withdraw { who, amount } - ) => { - who: *who == sov_pop_net_on_ahr.clone().into(), - amount: *amount == t.args.amount, - }, - RuntimeEvent::Balances(pallet_balances::Event::Deposit { .. }) => {}, - RuntimeEvent::MessageQueue( - pallet_message_queue::Event::Processed { success: true, .. } - ) => {}, - ] - ); - } - - fn system_para_to_para_assets_sender_assertions(t: SystemParaToParaTest) { - type RuntimeEvent = ::RuntimeEvent; - AssetHubRococoPara::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts( - 864_610_000, - 8799, - ))); - assert_expected_events!( - AssetHubRococoPara, - vec![ - // Amount to reserve transfer is transferred to Parachain's Sovereign account - RuntimeEvent::Assets( - pallet_assets::Event::Transferred { asset_id, from, to, amount } - ) => { - asset_id: *asset_id == ASSET_ID, - from: *from == t.sender.account_id, - to: *to == AssetHubRococoPara::sovereign_account_id_of( - t.args.dest.clone() - ), - amount: *amount == t.args.amount, - }, - ] - ); - } - - fn system_para_to_para_assets_receiver_assertions(_: Test) { - type RuntimeEvent = ::RuntimeEvent; - assert_expected_events!( - PopNetworkPara, - vec![ - RuntimeEvent::Balances(pallet_balances::Event::Deposit { .. }) => {}, - RuntimeEvent::Assets(pallet_assets::Event::Issued { .. }) => {}, - RuntimeEvent::MessageQueue( - pallet_message_queue::Event::Processed { success: true, .. } - ) => {}, - ] - ); - } - - fn relay_to_para_reserve_transfer_assets(t: RelayToParaTest) -> DispatchResult { - ::XcmPallet::limited_reserve_transfer_assets( + use crate::chains::{ + asset_hub_rococo::{ + genesis::ED as ASSET_HUB_ROCOCO_ED, AssetHubRococo, AssetHubRococoParaPallet, + }, + pop_network::{PopNetwork, PopNetworkParaPallet}, + rococo::{genesis::ED as ROCOCO_ED, Rococo, RococoRelayPallet}, + }; + use asset_hub_rococo_runtime::xcm_config::XcmConfig as AssetHubRococoXcmConfig; + use asset_test_utils::xcm_helpers; + use emulated_integration_tests_common::{ + accounts::{ALICE, BOB}, + xcm_emulator::{ + assert_expected_events, bx, decl_test_networks, + decl_test_sender_receiver_accounts_parameter_types, Chain, Parachain as Para, + RelayChain as Relay, Test, TestArgs, TestContext, TestExt, + }, + }; + use frame_support::{ + assert_err, + pallet_prelude::Weight, + sp_runtime::{DispatchError, DispatchResult}, + traits::fungibles::Inspect, + }; + use pop_runtime::{xcm_config::XcmConfig as PopNetworkXcmConfig, Balance}; + use rococo_runtime::xcm_config::XcmConfig as RococoXcmConfig; + use xcm::prelude::{AccountId32 as AccountId32Junction, *}; + + decl_test_networks! { + // `pub` mandatory for the macro + pub struct RococoMockNet { + relay_chain = Rococo, + parachains = vec![ + AssetHubRococo, + PopNetwork, + ], + bridge = () + }, + } + + decl_test_sender_receiver_accounts_parameter_types! { + RococoRelay { sender: ALICE, receiver: BOB }, + AssetHubRococoPara { sender: ALICE, receiver: BOB }, + PopNetworkPara { sender: ALICE, receiver: BOB} + } + + const ASSET_ID: u32 = 1; + const ASSET_MIN_BALANCE: u128 = 1000; + const ASSETS_PALLET_ID: u8 = 50; + + type RelayToParaTest = Test; + type SystemParaToParaTest = Test; + type ParaToSystemParaTest = Test; + + fn relay_to_para_sender_assertions(t: RelayToParaTest) { + type RuntimeEvent = ::RuntimeEvent; + RococoRelay::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts( + 864_610_000, + 8_799, + ))); + assert_expected_events!( + RococoRelay, + vec![ + // Amount to reserve transfer is transferred to Parachain's Sovereign account + RuntimeEvent::Balances( + pallet_balances::Event::Transfer { from, to, amount } + ) => { + from: *from == t.sender.account_id, + to: *to == RococoRelay::sovereign_account_id_of( + t.args.dest.clone() + ), + amount: *amount == t.args.amount, + }, + ] + ); + } + + fn system_para_to_para_sender_assertions(t: SystemParaToParaTest) { + type RuntimeEvent = ::RuntimeEvent; + AssetHubRococoPara::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts( + 864_610_000, + 8_799, + ))); + assert_expected_events!( + AssetHubRococoPara, + vec![ + // Amount to reserve transfer is transferred to Parachain's Sovereign account + RuntimeEvent::Balances( + pallet_balances::Event::Transfer { from, to, amount } + ) => { + from: *from == t.sender.account_id, + to: *to == AssetHubRococoPara::sovereign_account_id_of( + t.args.dest.clone() + ), + amount: *amount == t.args.amount, + }, + ] + ); + } + + fn para_receiver_assertions(_: Test) { + type RuntimeEvent = ::RuntimeEvent; + assert_expected_events!( + PopNetworkPara, + vec![ + RuntimeEvent::Balances(pallet_balances::Event::Deposit { .. }) => {}, + RuntimeEvent::MessageQueue( + pallet_message_queue::Event::Processed { success: true, .. } + ) => {}, + ] + ); + } + + fn para_to_system_para_sender_assertions(t: ParaToSystemParaTest) { + type RuntimeEvent = ::RuntimeEvent; + PopNetworkPara::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts( + 864_610_000, + 8_799, + ))); + assert_expected_events!( + PopNetworkPara, + vec![ + // Amount to reserve transfer is transferred to Parachain's Sovereign account + RuntimeEvent::Balances( + pallet_balances::Event::Withdraw { who, amount } + ) => { + who: *who == t.sender.account_id, + amount: *amount == t.args.amount, + }, + ] + ); + } + + fn para_to_system_para_receiver_assertions(t: ParaToSystemParaTest) { + type RuntimeEvent = ::RuntimeEvent; + let sov_pop_net_on_ahr = AssetHubRococoPara::sovereign_account_id_of( + AssetHubRococoPara::sibling_location_of(PopNetworkPara::para_id()), + ); + assert_expected_events!( + AssetHubRococoPara, + vec![ + // Amount to reserve transfer is withdrawn from Parachain's Sovereign account + RuntimeEvent::Balances( + pallet_balances::Event::Withdraw { who, amount } + ) => { + who: *who == sov_pop_net_on_ahr.clone().into(), + amount: *amount == t.args.amount, + }, + RuntimeEvent::Balances(pallet_balances::Event::Deposit { .. }) => {}, + RuntimeEvent::MessageQueue( + pallet_message_queue::Event::Processed { success: true, .. } + ) => {}, + ] + ); + } + + fn system_para_to_para_assets_sender_assertions(t: SystemParaToParaTest) { + type RuntimeEvent = ::RuntimeEvent; + AssetHubRococoPara::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts( + 864_610_000, + 8799, + ))); + assert_expected_events!( + AssetHubRococoPara, + vec![ + // Amount to reserve transfer is transferred to Parachain's Sovereign account + RuntimeEvent::Assets( + pallet_assets::Event::Transferred { asset_id, from, to, amount } + ) => { + asset_id: *asset_id == ASSET_ID, + from: *from == t.sender.account_id, + to: *to == AssetHubRococoPara::sovereign_account_id_of( + t.args.dest.clone() + ), + amount: *amount == t.args.amount, + }, + ] + ); + } + + fn system_para_to_para_assets_receiver_assertions(_: Test) { + type RuntimeEvent = ::RuntimeEvent; + assert_expected_events!( + PopNetworkPara, + vec![ + RuntimeEvent::Balances(pallet_balances::Event::Deposit { .. }) => {}, + RuntimeEvent::Assets(pallet_assets::Event::Issued { .. }) => {}, + RuntimeEvent::MessageQueue( + pallet_message_queue::Event::Processed { success: true, .. } + ) => {}, + ] + ); + } + + fn relay_to_para_reserve_transfer_assets(t: RelayToParaTest) -> DispatchResult { + ::XcmPallet::limited_reserve_transfer_assets( + t.signed_origin, + bx!(t.args.dest.into()), + bx!(t.args.beneficiary.into()), + bx!(t.args.assets.into()), + t.args.fee_asset_item, + t.args.weight_limit, + ) + } + + fn system_para_to_para_reserve_transfer_assets(t: SystemParaToParaTest) -> DispatchResult { + ::PolkadotXcm::limited_reserve_transfer_assets( t.signed_origin, bx!(t.args.dest.into()), bx!(t.args.beneficiary.into()), @@ -205,89 +216,73 @@ mod tests { t.args.fee_asset_item, t.args.weight_limit, ) - } - - fn system_para_to_para_reserve_transfer_assets(t: SystemParaToParaTest) -> DispatchResult { - ::PolkadotXcm::limited_reserve_transfer_assets( - t.signed_origin, - bx!(t.args.dest.into()), - bx!(t.args.beneficiary.into()), - bx!(t.args.assets.into()), - t.args.fee_asset_item, - t.args.weight_limit, - ) - } - - fn para_to_system_para_reserve_transfer_assets(t: ParaToSystemParaTest) -> DispatchResult { - ::PolkadotXcm::limited_reserve_transfer_assets( - t.signed_origin, - bx!(t.args.dest.into()), - bx!(t.args.beneficiary.into()), - bx!(t.args.assets.into()), - t.args.fee_asset_item, - t.args.weight_limit, - ) - } - - /// Reserve Transfers of native asset from Relay Chain to the System Parachain shouldn't work - #[test] - fn reserve_transfer_native_asset_from_relay_to_system_para_fails() { - let signed_origin = - ::RuntimeOrigin::signed(RococoRelaySender::get().into()); - let destination = RococoRelay::child_location_of(AssetHubRococoPara::para_id()); - let beneficiary: Location = AccountId32Junction { - network: None, - id: AssetHubRococoParaReceiver::get().into(), - } - .into(); - let amount_to_send: Balance = ROCOCO_ED * 1000; - let assets: Assets = (Here, amount_to_send).into(); - let fee_asset_item = 0; - - // this should fail - RococoRelay::execute_with(|| { - let result = - ::XcmPallet::limited_reserve_transfer_assets( - signed_origin, - bx!(destination.into()), - bx!(beneficiary.into()), - bx!(assets.into()), - fee_asset_item, - WeightLimit::Unlimited, - ); - assert_err!( - result, - DispatchError::Module(sp_runtime::ModuleError { - index: 99, - error: [2, 0, 0, 0], - message: Some("Filtered") - }) - ); - }); - } - - /// Reserve Transfers of native asset from System Parachain to Relay Chain shouldn't work - #[test] - fn reserve_transfer_native_asset_from_system_para_to_relay_fails() { - // Init values for System Parachain - let signed_origin = ::RuntimeOrigin::signed( - AssetHubRococoParaSender::get().into(), - ); - let destination = AssetHubRococoPara::parent_location(); - let beneficiary_id = RococoRelayReceiver::get(); - let beneficiary: Location = AccountId32Junction { - network: None, - id: beneficiary_id.into(), - } - .into(); - let amount_to_send: Balance = ASSET_HUB_ROCOCO_ED * 1000; - - let assets: Assets = (Parent, amount_to_send).into(); - let fee_asset_item = 0; - - // this should fail - AssetHubRococoPara::execute_with(|| { - let result = + } + + fn para_to_system_para_reserve_transfer_assets(t: ParaToSystemParaTest) -> DispatchResult { + ::PolkadotXcm::limited_reserve_transfer_assets( + t.signed_origin, + bx!(t.args.dest.into()), + bx!(t.args.beneficiary.into()), + bx!(t.args.assets.into()), + t.args.fee_asset_item, + t.args.weight_limit, + ) + } + + /// Reserve Transfers of native asset from Relay Chain to the System Parachain shouldn't work + #[test] + fn reserve_transfer_native_asset_from_relay_to_system_para_fails() { + let signed_origin = + ::RuntimeOrigin::signed(RococoRelaySender::get().into()); + let destination = RococoRelay::child_location_of(AssetHubRococoPara::para_id()); + let beneficiary: Location = + AccountId32Junction { network: None, id: AssetHubRococoParaReceiver::get().into() } + .into(); + let amount_to_send: Balance = ROCOCO_ED * 1000; + let assets: Assets = (Here, amount_to_send).into(); + let fee_asset_item = 0; + + // this should fail + RococoRelay::execute_with(|| { + let result = + ::XcmPallet::limited_reserve_transfer_assets( + signed_origin, + bx!(destination.into()), + bx!(beneficiary.into()), + bx!(assets.into()), + fee_asset_item, + WeightLimit::Unlimited, + ); + assert_err!( + result, + DispatchError::Module(sp_runtime::ModuleError { + index: 99, + error: [2, 0, 0, 0], + message: Some("Filtered") + }) + ); + }); + } + + /// Reserve Transfers of native asset from System Parachain to Relay Chain shouldn't work + #[test] + fn reserve_transfer_native_asset_from_system_para_to_relay_fails() { + // Init values for System Parachain + let signed_origin = ::RuntimeOrigin::signed( + AssetHubRococoParaSender::get().into(), + ); + let destination = AssetHubRococoPara::parent_location(); + let beneficiary_id = RococoRelayReceiver::get(); + let beneficiary: Location = + AccountId32Junction { network: None, id: beneficiary_id.into() }.into(); + let amount_to_send: Balance = ASSET_HUB_ROCOCO_ED * 1000; + + let assets: Assets = (Parent, amount_to_send).into(); + let fee_asset_item = 0; + + // this should fail + AssetHubRococoPara::execute_with(|| { + let result = ::PolkadotXcm::limited_reserve_transfer_assets( signed_origin, bx!(destination.into()), @@ -296,295 +291,277 @@ mod tests { fee_asset_item, WeightLimit::Unlimited, ); - assert_err!( - result, - DispatchError::Module(sp_runtime::ModuleError { - index: 31, - error: [2, 0, 0, 0], - message: Some("Filtered") - }) - ); - }); - } - - /// Reserve Transfers of native asset from Relay to Parachain should work - #[test] - fn reserve_transfer_native_asset_from_relay_to_para() { - // Init values for Relay - let destination = RococoRelay::child_location_of(PopNetworkPara::para_id()); - let beneficiary_id = PopNetworkParaReceiver::get(); - let amount_to_send: Balance = ROCOCO_ED * 1000; - - let test_args = TestContext { - sender: RococoRelaySender::get(), - receiver: PopNetworkParaReceiver::get(), - args: TestArgs::new_relay(destination, beneficiary_id, amount_to_send), - }; - - let mut test = RelayToParaTest::new(test_args); - - let sender_balance_before = test.sender.balance; - let receiver_balance_before = test.receiver.balance; - - test.set_assertion::(relay_to_para_sender_assertions); - test.set_assertion::(para_receiver_assertions); - test.set_dispatchable::(relay_to_para_reserve_transfer_assets); - test.assert(); - - let delivery_fees = RococoRelay::execute_with(|| { - xcm_helpers::transfer_assets_delivery_fees::< - ::XcmSender, - >( - test.args.assets.clone(), - 0, - test.args.weight_limit, - test.args.beneficiary, - test.args.dest, - ) - }); - - let sender_balance_after = test.sender.balance; - let receiver_balance_after = test.receiver.balance; - - // Sender's balance is reduced - assert_eq!( - sender_balance_before - amount_to_send - delivery_fees, - sender_balance_after - ); - // Receiver's balance is increased - assert!(receiver_balance_after > receiver_balance_before); - // Receiver's balance increased by `amount_to_send - delivery_fees - bought_execution`; - // `delivery_fees` might be paid from transfer or JIT, also `bought_execution` is unknown - // but should be non-zero - assert!(receiver_balance_after < receiver_balance_before + amount_to_send); - } - - /// Reserve Transfers of native asset from System Parachain to Parachain should work - #[test] - fn reserve_transfer_native_asset_from_system_para_to_para() { - // Init values for System Parachain - let destination = AssetHubRococoPara::sibling_location_of(PopNetworkPara::para_id()); - let beneficiary_id = PopNetworkParaReceiver::get(); - let amount_to_send: Balance = ASSET_HUB_ROCOCO_ED * 1000; - let assets = (Parent, amount_to_send).into(); - - let test_args = TestContext { - sender: AssetHubRococoParaSender::get(), - receiver: PopNetworkParaReceiver::get(), - args: TestArgs::new_para(destination, beneficiary_id, amount_to_send, assets, None, 0), - }; - - let mut test = SystemParaToParaTest::new(test_args); - - let sender_balance_before = test.sender.balance; - let receiver_balance_before = test.receiver.balance; - - test.set_assertion::(system_para_to_para_sender_assertions); - test.set_assertion::(para_receiver_assertions); - test.set_dispatchable::(system_para_to_para_reserve_transfer_assets); - test.assert(); - - let sender_balance_after = test.sender.balance; - let receiver_balance_after = test.receiver.balance; - - let delivery_fees = AssetHubRococoPara::execute_with(|| { - xcm_helpers::transfer_assets_delivery_fees::< - ::XcmSender, - >( - test.args.assets.clone(), - 0, - test.args.weight_limit, - test.args.beneficiary, - test.args.dest, - ) - }); - - // Sender's balance is reduced - assert_eq!( - sender_balance_before - amount_to_send - delivery_fees, - sender_balance_after - ); - // Receiver's balance is increased - assert!(receiver_balance_after > receiver_balance_before); - // Receiver's balance increased by `amount_to_send - delivery_fees - bought_execution`; - // `delivery_fees` might be paid from transfer or JIT, also `bought_execution` is unknown - // but should be non-zero - assert!(receiver_balance_after < receiver_balance_before + amount_to_send); - } - - /// Reserve Transfers of native asset from Parachain to System Parachain should work - #[test] - fn reserve_transfer_native_asset_from_para_to_system_para() { - // Init values for Pop Network Parachain - let destination = PopNetworkPara::sibling_location_of(AssetHubRococoPara::para_id()); - let beneficiary_id = AssetHubRococoParaReceiver::get(); - let amount_to_send: Balance = ASSET_HUB_ROCOCO_ED * 1000; - let assets = (Parent, amount_to_send).into(); - - let test_args = TestContext { - sender: PopNetworkParaSender::get(), - receiver: AssetHubRococoParaReceiver::get(), - args: TestArgs::new_para(destination, beneficiary_id, amount_to_send, assets, None, 0), - }; - - let mut test = ParaToSystemParaTest::new(test_args); - - let sender_balance_before = test.sender.balance; - let receiver_balance_before = test.receiver.balance; - - let pop_net_location_as_seen_by_ahr = - AssetHubRococoPara::sibling_location_of(PopNetworkPara::para_id()); - let sov_pop_net_on_ahr = - AssetHubRococoPara::sovereign_account_id_of(pop_net_location_as_seen_by_ahr); - - // fund the Pop Network's SA on AHR with the native tokens held in reserve - AssetHubRococoPara::fund_accounts(vec![(sov_pop_net_on_ahr.into(), amount_to_send * 2)]); - - test.set_assertion::(para_to_system_para_sender_assertions); - test.set_assertion::(para_to_system_para_receiver_assertions); - test.set_dispatchable::(para_to_system_para_reserve_transfer_assets); - test.assert(); - - let sender_balance_after = test.sender.balance; - let receiver_balance_after = test.receiver.balance; - - let delivery_fees = PopNetworkPara::execute_with(|| { - xcm_helpers::transfer_assets_delivery_fees::< - ::XcmSender, - >( - test.args.assets.clone(), - 0, - test.args.weight_limit, - test.args.beneficiary, - test.args.dest, - ) - }); - - // Sender's balance is reduced - assert_eq!( - sender_balance_before - amount_to_send - delivery_fees, - sender_balance_after - ); - // Receiver's balance is increased - assert!(receiver_balance_after > receiver_balance_before); - // Receiver's balance increased by `amount_to_send - delivery_fees - bought_execution`; - // `delivery_fees` might be paid from transfer or JIT, also `bought_execution` is unknown - // but should be non-zero - assert!(receiver_balance_after < receiver_balance_before + amount_to_send); - } - - /// Reserve Transfers of a local asset and native asset from System Parachain to Parachain - /// should work - #[test] - fn reserve_transfer_assets_from_system_para_to_para() { - // Force create asset on AssetHubRococoPara and PopNetworkPara from Relay Chain - AssetHubRococoPara::force_create_and_mint_asset( - ASSET_ID, - ASSET_MIN_BALANCE, - false, - AssetHubRococoParaSender::get(), - Some(Weight::from_parts(1_019_445_000, 200_000)), - ASSET_MIN_BALANCE * 1_000_000, - ); - PopNetworkPara::force_create_and_mint_asset( - ASSET_ID, - ASSET_MIN_BALANCE, - false, - PopNetworkParaSender::get(), - None, - 0, - ); - - // Init values for System Parachain - let destination = AssetHubRococoPara::sibling_location_of(PopNetworkPara::para_id()); - let beneficiary_id = PopNetworkParaReceiver::get(); - let fee_amount_to_send = ASSET_HUB_ROCOCO_ED * 1000; - let asset_amount_to_send = ASSET_MIN_BALANCE * 1000; - let assets: Assets = vec![ - (Parent, fee_amount_to_send).into(), - ( - [ - PalletInstance(ASSETS_PALLET_ID), - GeneralIndex(ASSET_ID.into()), - ], - asset_amount_to_send, - ) - .into(), - ] - .into(); - let fee_asset_index = assets - .inner() - .iter() - .position(|r| r == &(Parent, fee_amount_to_send).into()) - .unwrap() as u32; - - let para_test_args = TestContext { - sender: AssetHubRococoParaSender::get(), - receiver: PopNetworkParaReceiver::get(), - args: TestArgs::new_para( - destination, - beneficiary_id, - asset_amount_to_send, - assets, - None, - fee_asset_index, - ), - }; - - let mut test = SystemParaToParaTest::new(para_test_args); - - // Create SA-of-Pop Network-on-AHR with ED. - let pop_net_location = AssetHubRococoPara::sibling_location_of(PopNetworkPara::para_id()); - let sov_pop_net_on_ahr = AssetHubRococoPara::sovereign_account_id_of(pop_net_location); - AssetHubRococoPara::fund_accounts(vec![(sov_pop_net_on_ahr.into(), ROCOCO_ED)]); - - let sender_balance_before = test.sender.balance; - let receiver_balance_before = test.receiver.balance; - - let sender_assets_before = AssetHubRococoPara::execute_with(|| { - type Assets = ::Assets; - >::balance(ASSET_ID, &AssetHubRococoParaSender::get()) - }); - let receiver_assets_before = PopNetworkPara::execute_with(|| { - type Assets = ::Assets; - >::balance(ASSET_ID, &PopNetworkParaReceiver::get()) - }); - - test.set_assertion::(system_para_to_para_assets_sender_assertions); - test.set_assertion::(system_para_to_para_assets_receiver_assertions); - test.set_dispatchable::(system_para_to_para_reserve_transfer_assets); - test.assert(); - - let sender_balance_after = test.sender.balance; - let receiver_balance_after = test.receiver.balance; - - // Sender's balance is reduced - assert!(sender_balance_after < sender_balance_before); - // Receiver's balance is increased - assert!(receiver_balance_after > receiver_balance_before); - // Receiver's balance increased by `amount_to_send - delivery_fees - bought_execution`; - // `delivery_fees` might be paid from transfer or JIT, also `bought_execution` is unknown - // but should be non-zero - assert!(receiver_balance_after < receiver_balance_before + fee_amount_to_send); - - let sender_assets_after = AssetHubRococoPara::execute_with(|| { - type Assets = ::Assets; - >::balance(ASSET_ID, &AssetHubRococoParaSender::get()) - }); - let receiver_assets_after = PopNetworkPara::execute_with(|| { - type Assets = ::Assets; - >::balance(ASSET_ID, &PopNetworkParaReceiver::get()) - }); - - // Sender's balance is reduced by exact amount - assert_eq!( - sender_assets_before - asset_amount_to_send, - sender_assets_after - ); - // Receiver's balance is increased by exact amount - assert_eq!( - receiver_assets_after, - receiver_assets_before + asset_amount_to_send - ); - } + assert_err!( + result, + DispatchError::Module(sp_runtime::ModuleError { + index: 31, + error: [2, 0, 0, 0], + message: Some("Filtered") + }) + ); + }); + } + + /// Reserve Transfers of native asset from Relay to Parachain should work + #[test] + fn reserve_transfer_native_asset_from_relay_to_para() { + // Init values for Relay + let destination = RococoRelay::child_location_of(PopNetworkPara::para_id()); + let beneficiary_id = PopNetworkParaReceiver::get(); + let amount_to_send: Balance = ROCOCO_ED * 1000; + + let test_args = TestContext { + sender: RococoRelaySender::get(), + receiver: PopNetworkParaReceiver::get(), + args: TestArgs::new_relay(destination, beneficiary_id, amount_to_send), + }; + + let mut test = RelayToParaTest::new(test_args); + + let sender_balance_before = test.sender.balance; + let receiver_balance_before = test.receiver.balance; + + test.set_assertion::(relay_to_para_sender_assertions); + test.set_assertion::(para_receiver_assertions); + test.set_dispatchable::(relay_to_para_reserve_transfer_assets); + test.assert(); + + let delivery_fees = RococoRelay::execute_with(|| { + xcm_helpers::transfer_assets_delivery_fees::< + ::XcmSender, + >( + test.args.assets.clone(), + 0, + test.args.weight_limit, + test.args.beneficiary, + test.args.dest, + ) + }); + + let sender_balance_after = test.sender.balance; + let receiver_balance_after = test.receiver.balance; + + // Sender's balance is reduced + assert_eq!(sender_balance_before - amount_to_send - delivery_fees, sender_balance_after); + // Receiver's balance is increased + assert!(receiver_balance_after > receiver_balance_before); + // Receiver's balance increased by `amount_to_send - delivery_fees - bought_execution`; + // `delivery_fees` might be paid from transfer or JIT, also `bought_execution` is unknown + // but should be non-zero + assert!(receiver_balance_after < receiver_balance_before + amount_to_send); + } + + /// Reserve Transfers of native asset from System Parachain to Parachain should work + #[test] + fn reserve_transfer_native_asset_from_system_para_to_para() { + // Init values for System Parachain + let destination = AssetHubRococoPara::sibling_location_of(PopNetworkPara::para_id()); + let beneficiary_id = PopNetworkParaReceiver::get(); + let amount_to_send: Balance = ASSET_HUB_ROCOCO_ED * 1000; + let assets = (Parent, amount_to_send).into(); + + let test_args = TestContext { + sender: AssetHubRococoParaSender::get(), + receiver: PopNetworkParaReceiver::get(), + args: TestArgs::new_para(destination, beneficiary_id, amount_to_send, assets, None, 0), + }; + + let mut test = SystemParaToParaTest::new(test_args); + + let sender_balance_before = test.sender.balance; + let receiver_balance_before = test.receiver.balance; + + test.set_assertion::(system_para_to_para_sender_assertions); + test.set_assertion::(para_receiver_assertions); + test.set_dispatchable::(system_para_to_para_reserve_transfer_assets); + test.assert(); + + let sender_balance_after = test.sender.balance; + let receiver_balance_after = test.receiver.balance; + + let delivery_fees = AssetHubRococoPara::execute_with(|| { + xcm_helpers::transfer_assets_delivery_fees::< + ::XcmSender, + >( + test.args.assets.clone(), + 0, + test.args.weight_limit, + test.args.beneficiary, + test.args.dest, + ) + }); + + // Sender's balance is reduced + assert_eq!(sender_balance_before - amount_to_send - delivery_fees, sender_balance_after); + // Receiver's balance is increased + assert!(receiver_balance_after > receiver_balance_before); + // Receiver's balance increased by `amount_to_send - delivery_fees - bought_execution`; + // `delivery_fees` might be paid from transfer or JIT, also `bought_execution` is unknown + // but should be non-zero + assert!(receiver_balance_after < receiver_balance_before + amount_to_send); + } + + /// Reserve Transfers of native asset from Parachain to System Parachain should work + #[test] + fn reserve_transfer_native_asset_from_para_to_system_para() { + // Init values for Pop Network Parachain + let destination = PopNetworkPara::sibling_location_of(AssetHubRococoPara::para_id()); + let beneficiary_id = AssetHubRococoParaReceiver::get(); + let amount_to_send: Balance = ASSET_HUB_ROCOCO_ED * 1000; + let assets = (Parent, amount_to_send).into(); + + let test_args = TestContext { + sender: PopNetworkParaSender::get(), + receiver: AssetHubRococoParaReceiver::get(), + args: TestArgs::new_para(destination, beneficiary_id, amount_to_send, assets, None, 0), + }; + + let mut test = ParaToSystemParaTest::new(test_args); + + let sender_balance_before = test.sender.balance; + let receiver_balance_before = test.receiver.balance; + + let pop_net_location_as_seen_by_ahr = + AssetHubRococoPara::sibling_location_of(PopNetworkPara::para_id()); + let sov_pop_net_on_ahr = + AssetHubRococoPara::sovereign_account_id_of(pop_net_location_as_seen_by_ahr); + + // fund the Pop Network's SA on AHR with the native tokens held in reserve + AssetHubRococoPara::fund_accounts(vec![(sov_pop_net_on_ahr.into(), amount_to_send * 2)]); + + test.set_assertion::(para_to_system_para_sender_assertions); + test.set_assertion::(para_to_system_para_receiver_assertions); + test.set_dispatchable::(para_to_system_para_reserve_transfer_assets); + test.assert(); + + let sender_balance_after = test.sender.balance; + let receiver_balance_after = test.receiver.balance; + + let delivery_fees = PopNetworkPara::execute_with(|| { + xcm_helpers::transfer_assets_delivery_fees::< + ::XcmSender, + >( + test.args.assets.clone(), + 0, + test.args.weight_limit, + test.args.beneficiary, + test.args.dest, + ) + }); + + // Sender's balance is reduced + assert_eq!(sender_balance_before - amount_to_send - delivery_fees, sender_balance_after); + // Receiver's balance is increased + assert!(receiver_balance_after > receiver_balance_before); + // Receiver's balance increased by `amount_to_send - delivery_fees - bought_execution`; + // `delivery_fees` might be paid from transfer or JIT, also `bought_execution` is unknown + // but should be non-zero + assert!(receiver_balance_after < receiver_balance_before + amount_to_send); + } + + /// Reserve Transfers of a local asset and native asset from System Parachain to Parachain + /// should work + #[test] + fn reserve_transfer_assets_from_system_para_to_para() { + // Force create asset on AssetHubRococoPara and PopNetworkPara from Relay Chain + AssetHubRococoPara::force_create_and_mint_asset( + ASSET_ID, + ASSET_MIN_BALANCE, + false, + AssetHubRococoParaSender::get(), + Some(Weight::from_parts(1_019_445_000, 200_000)), + ASSET_MIN_BALANCE * 1_000_000, + ); + PopNetworkPara::force_create_and_mint_asset( + ASSET_ID, + ASSET_MIN_BALANCE, + false, + PopNetworkParaSender::get(), + None, + 0, + ); + + // Init values for System Parachain + let destination = AssetHubRococoPara::sibling_location_of(PopNetworkPara::para_id()); + let beneficiary_id = PopNetworkParaReceiver::get(); + let fee_amount_to_send = ASSET_HUB_ROCOCO_ED * 1000; + let asset_amount_to_send = ASSET_MIN_BALANCE * 1000; + let assets: Assets = vec![ + (Parent, fee_amount_to_send).into(), + ( + [PalletInstance(ASSETS_PALLET_ID), GeneralIndex(ASSET_ID.into())], + asset_amount_to_send, + ) + .into(), + ] + .into(); + let fee_asset_index = assets + .inner() + .iter() + .position(|r| r == &(Parent, fee_amount_to_send).into()) + .unwrap() as u32; + + let para_test_args = TestContext { + sender: AssetHubRococoParaSender::get(), + receiver: PopNetworkParaReceiver::get(), + args: TestArgs::new_para( + destination, + beneficiary_id, + asset_amount_to_send, + assets, + None, + fee_asset_index, + ), + }; + + let mut test = SystemParaToParaTest::new(para_test_args); + + // Create SA-of-Pop Network-on-AHR with ED. + let pop_net_location = AssetHubRococoPara::sibling_location_of(PopNetworkPara::para_id()); + let sov_pop_net_on_ahr = AssetHubRococoPara::sovereign_account_id_of(pop_net_location); + AssetHubRococoPara::fund_accounts(vec![(sov_pop_net_on_ahr.into(), ROCOCO_ED)]); + + let sender_balance_before = test.sender.balance; + let receiver_balance_before = test.receiver.balance; + + let sender_assets_before = AssetHubRococoPara::execute_with(|| { + type Assets = ::Assets; + >::balance(ASSET_ID, &AssetHubRococoParaSender::get()) + }); + let receiver_assets_before = PopNetworkPara::execute_with(|| { + type Assets = ::Assets; + >::balance(ASSET_ID, &PopNetworkParaReceiver::get()) + }); + + test.set_assertion::(system_para_to_para_assets_sender_assertions); + test.set_assertion::(system_para_to_para_assets_receiver_assertions); + test.set_dispatchable::(system_para_to_para_reserve_transfer_assets); + test.assert(); + + let sender_balance_after = test.sender.balance; + let receiver_balance_after = test.receiver.balance; + + // Sender's balance is reduced + assert!(sender_balance_after < sender_balance_before); + // Receiver's balance is increased + assert!(receiver_balance_after > receiver_balance_before); + // Receiver's balance increased by `amount_to_send - delivery_fees - bought_execution`; + // `delivery_fees` might be paid from transfer or JIT, also `bought_execution` is unknown + // but should be non-zero + assert!(receiver_balance_after < receiver_balance_before + fee_amount_to_send); + + let sender_assets_after = AssetHubRococoPara::execute_with(|| { + type Assets = ::Assets; + >::balance(ASSET_ID, &AssetHubRococoParaSender::get()) + }); + let receiver_assets_after = PopNetworkPara::execute_with(|| { + type Assets = ::Assets; + >::balance(ASSET_ID, &PopNetworkParaReceiver::get()) + }); + + // Sender's balance is reduced by exact amount + assert_eq!(sender_assets_before - asset_amount_to_send, sender_assets_after); + // Receiver's balance is increased by exact amount + assert_eq!(receiver_assets_after, receiver_assets_before + asset_amount_to_send); + } } diff --git a/node/src/chain_spec.rs b/node/src/chain_spec.rs index 687ab6d95..680ebc877 100644 --- a/node/src/chain_spec.rs +++ b/node/src/chain_spec.rs @@ -70,47 +70,47 @@ pub fn development_config() -> ChainSpec { properties.insert("tokenDecimals".into(), 12.into()); properties.insert("ss58Format".into(), 42.into()); - ChainSpec::builder( - pop_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"), - Extensions { - relay_chain: "rococo-local".into(), - // You MUST set this to the correct network! - para_id: PARA_ID, - }, - ) - .with_name("Development") - .with_id("dev") - .with_chain_type(ChainType::Development) - .with_genesis_config_patch(testnet_genesis( - // initial collators. - vec![ - ( - get_account_id_from_seed::("Alice"), - get_collator_keys_from_seed("Alice"), - ), - ( - get_account_id_from_seed::("Bob"), - get_collator_keys_from_seed("Bob"), - ), - ], - vec![ - get_account_id_from_seed::("Alice"), - get_account_id_from_seed::("Bob"), - get_account_id_from_seed::("Charlie"), - get_account_id_from_seed::("Dave"), - get_account_id_from_seed::("Eve"), - get_account_id_from_seed::("Ferdie"), - get_account_id_from_seed::("Alice//stash"), - get_account_id_from_seed::("Bob//stash"), - get_account_id_from_seed::("Charlie//stash"), - get_account_id_from_seed::("Dave//stash"), - get_account_id_from_seed::("Eve//stash"), - get_account_id_from_seed::("Ferdie//stash"), - ], - get_account_id_from_seed::("Alice"), - PARA_ID.into(), - )) - .build() + ChainSpec::builder( + pop_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"), + Extensions { + relay_chain: "rococo-local".into(), + // You MUST set this to the correct network! + para_id: PARA_ID, + }, + ) + .with_name("Development") + .with_id("dev") + .with_chain_type(ChainType::Development) + .with_genesis_config_patch(testnet_genesis( + // initial collators. + vec![ + ( + get_account_id_from_seed::("Alice"), + get_collator_keys_from_seed("Alice"), + ), + ( + get_account_id_from_seed::("Bob"), + get_collator_keys_from_seed("Bob"), + ), + ], + vec![ + get_account_id_from_seed::("Alice"), + get_account_id_from_seed::("Bob"), + get_account_id_from_seed::("Charlie"), + get_account_id_from_seed::("Dave"), + get_account_id_from_seed::("Eve"), + get_account_id_from_seed::("Ferdie"), + get_account_id_from_seed::("Alice//stash"), + get_account_id_from_seed::("Bob//stash"), + get_account_id_from_seed::("Charlie//stash"), + get_account_id_from_seed::("Dave//stash"), + get_account_id_from_seed::("Eve//stash"), + get_account_id_from_seed::("Ferdie//stash"), + ], + get_account_id_from_seed::("Alice"), + PARA_ID.into(), + )) + .build() } pub fn local_testnet_config() -> ChainSpec { @@ -120,50 +120,50 @@ pub fn local_testnet_config() -> ChainSpec { properties.insert("tokenDecimals".into(), 12.into()); properties.insert("ss58Format".into(), 42.into()); - #[allow(deprecated)] - ChainSpec::builder( - pop_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"), - Extensions { - relay_chain: "rococo-local".into(), - // You MUST set this to the correct network! - para_id: PARA_ID, - }, - ) - .with_name("Local Testnet") - .with_id("local_testnet") - .with_chain_type(ChainType::Local) - .with_genesis_config_patch(testnet_genesis( - // initial collators. - vec![ - ( - get_account_id_from_seed::("Alice"), - get_collator_keys_from_seed("Alice"), - ), - ( - get_account_id_from_seed::("Bob"), - get_collator_keys_from_seed("Bob"), - ), - ], - vec![ - get_account_id_from_seed::("Alice"), - get_account_id_from_seed::("Bob"), - get_account_id_from_seed::("Charlie"), - get_account_id_from_seed::("Dave"), - get_account_id_from_seed::("Eve"), - get_account_id_from_seed::("Ferdie"), - get_account_id_from_seed::("Alice//stash"), - get_account_id_from_seed::("Bob//stash"), - get_account_id_from_seed::("Charlie//stash"), - get_account_id_from_seed::("Dave//stash"), - get_account_id_from_seed::("Eve//stash"), - get_account_id_from_seed::("Ferdie//stash"), - ], - get_account_id_from_seed::("Alice"), - PARA_ID.into(), - )) - .with_protocol_id("pop-local") - .with_properties(properties) - .build() + #[allow(deprecated)] + ChainSpec::builder( + pop_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"), + Extensions { + relay_chain: "rococo-local".into(), + // You MUST set this to the correct network! + para_id: PARA_ID, + }, + ) + .with_name("Local Testnet") + .with_id("local_testnet") + .with_chain_type(ChainType::Local) + .with_genesis_config_patch(testnet_genesis( + // initial collators. + vec![ + ( + get_account_id_from_seed::("Alice"), + get_collator_keys_from_seed("Alice"), + ), + ( + get_account_id_from_seed::("Bob"), + get_collator_keys_from_seed("Bob"), + ), + ], + vec![ + get_account_id_from_seed::("Alice"), + get_account_id_from_seed::("Bob"), + get_account_id_from_seed::("Charlie"), + get_account_id_from_seed::("Dave"), + get_account_id_from_seed::("Eve"), + get_account_id_from_seed::("Ferdie"), + get_account_id_from_seed::("Alice//stash"), + get_account_id_from_seed::("Bob//stash"), + get_account_id_from_seed::("Charlie//stash"), + get_account_id_from_seed::("Dave//stash"), + get_account_id_from_seed::("Eve//stash"), + get_account_id_from_seed::("Ferdie//stash"), + ], + get_account_id_from_seed::("Alice"), + PARA_ID.into(), + )) + .with_protocol_id("pop-local") + .with_properties(properties) + .build() } fn testnet_genesis( From 2149756bc89aa54769b543acea1f204c5aa7375a Mon Sep 17 00:00:00 2001 From: Peter White Date: Thu, 7 Mar 2024 16:48:15 -0700 Subject: [PATCH 09/23] style: remove trailing space --- Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e11c7d8d1..5c652c588 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,8 +11,8 @@ repository = "https://github.com/r0gue-io/pop-node/" [workspace] members = [ "node", - "runtime", - "emulated-integration-tests", + "runtime", + "emulated-integration-tests", "pop-api", ] exclude = [ From 048ca5081ca6e566bd7666d275ae77236f0bd9b3 Mon Sep 17 00:00:00 2001 From: Peter White Date: Thu, 7 Mar 2024 17:17:45 -0700 Subject: [PATCH 10/23] fix: add deps std feature --- emulated-integration-tests/Cargo.toml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/emulated-integration-tests/Cargo.toml b/emulated-integration-tests/Cargo.toml index 7218963ed..767c1ee7c 100644 --- a/emulated-integration-tests/Cargo.toml +++ b/emulated-integration-tests/Cargo.toml @@ -42,6 +42,18 @@ pop-node.workspace = true default = ["std"] std = [ "asset-hub-rococo-runtime/std", + "cumulus-primitives-core/std", + "frame-support/std", + "pallet-assets/std", + "pallet-balances/std", + "pallet-message-queue/std", + "polkadot-primitives/std", "pop-runtime/std", + "rococo-runtime-constants/std", "rococo-runtime/std", + "sp-authority-discovery/std", + "sp-core/std", + "sp-runtime/std", + "xcm-executor/std", + "xcm/std", ] From 138b63c36a20641a96d172cd13856f26b6139814 Mon Sep 17 00:00:00 2001 From: Peter White Date: Thu, 7 Mar 2024 17:49:04 -0700 Subject: [PATCH 11/23] chore: update .toml to use default-features = false --- Cargo.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 5c652c588..cc331837c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -111,10 +111,10 @@ sp-version = { git = "https://github.com/paritytech/polkadot-sdk", branch = "rel pallet-xcm = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1", default-features = false } polkadot-cli = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1" } polkadot-parachain-primitives = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1", default-features = false } -polkadot-primitives = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1" } +polkadot-primitives = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1", default-features = false } polkadot-runtime-common = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1", default-features = false } -rococo-runtime-constants = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1" } -rococo-runtime = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1" } +rococo-runtime-constants = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1", default-features = false } +rococo-runtime = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1", default-features = false } xcm = { package = "staging-xcm", git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1", default-features = false } xcm-builder = { package = "staging-xcm-builder", git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1", default-features = false } xcm-executor = { package = "staging-xcm-executor", git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1", default-features = false } From f604c52874a8bad51190bb277c73dac96196a1cf Mon Sep 17 00:00:00 2001 From: Peter White Date: Thu, 7 Mar 2024 18:12:27 -0700 Subject: [PATCH 12/23] chore: use std features --- emulated-integration-tests/Cargo.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/emulated-integration-tests/Cargo.toml b/emulated-integration-tests/Cargo.toml index 767c1ee7c..e1d27dce3 100644 --- a/emulated-integration-tests/Cargo.toml +++ b/emulated-integration-tests/Cargo.toml @@ -52,6 +52,9 @@ std = [ "rococo-runtime-constants/std", "rococo-runtime/std", "sp-authority-discovery/std", + "sp-consensus-babe/std", + "sp-consensus-beefy/std", + "sp-consensus-grandpa/std", "sp-core/std", "sp-runtime/std", "xcm-executor/std", From 7195832ca76036cff933a53252a47b6f5733aa24 Mon Sep 17 00:00:00 2001 From: Peter White Date: Thu, 7 Mar 2024 19:04:45 -0700 Subject: [PATCH 13/23] chore: add try-runtime and runtime-benchmark features --- emulated-integration-tests/Cargo.toml | 42 +++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/emulated-integration-tests/Cargo.toml b/emulated-integration-tests/Cargo.toml index e1d27dce3..c5392b9c3 100644 --- a/emulated-integration-tests/Cargo.toml +++ b/emulated-integration-tests/Cargo.toml @@ -60,3 +60,45 @@ std = [ "xcm-executor/std", "xcm/std", ] + +runtime-benchmarks = [ + "asset-hub-rococo-runtime/std", + "cumulus-primitives-core/std", + "frame-support/std", + "pallet-assets/std", + "pallet-balances/std", + "pallet-message-queue/std", + "polkadot-primitives/std", + "pop-runtime/std", + "rococo-runtime-constants/std", + "rococo-runtime/std", + "sp-authority-discovery/std", + "sp-consensus-babe/std", + "sp-consensus-beefy/std", + "sp-consensus-grandpa/std", + "sp-core/std", + "sp-runtime/std", + "xcm-executor/std", + "xcm/std", +] + +try-runtime = [ + "asset-hub-rococo-runtime/std", + "cumulus-primitives-core/std", + "frame-support/std", + "pallet-assets/std", + "pallet-balances/std", + "pallet-message-queue/std", + "polkadot-primitives/std", + "pop-runtime/std", + "rococo-runtime-constants/std", + "rococo-runtime/std", + "sp-authority-discovery/std", + "sp-consensus-babe/std", + "sp-consensus-beefy/std", + "sp-consensus-grandpa/std", + "sp-core/std", + "sp-runtime/std", + "xcm-executor/std", + "xcm/std", +] \ No newline at end of file From ce82d026dfaa3522a0092af21a0aad4537c9e11c Mon Sep 17 00:00:00 2001 From: Frank Bell Date: Fri, 8 Mar 2024 20:01:46 +0000 Subject: [PATCH 14/23] fix(deps): fix features --- emulated-integration-tests/Cargo.toml | 53 +++++++++------------------ 1 file changed, 18 insertions(+), 35 deletions(-) diff --git a/emulated-integration-tests/Cargo.toml b/emulated-integration-tests/Cargo.toml index c5392b9c3..f126796e1 100644 --- a/emulated-integration-tests/Cargo.toml +++ b/emulated-integration-tests/Cargo.toml @@ -62,43 +62,26 @@ std = [ ] runtime-benchmarks = [ - "asset-hub-rococo-runtime/std", - "cumulus-primitives-core/std", - "frame-support/std", - "pallet-assets/std", - "pallet-balances/std", - "pallet-message-queue/std", - "polkadot-primitives/std", - "pop-runtime/std", - "rococo-runtime-constants/std", - "rococo-runtime/std", - "sp-authority-discovery/std", - "sp-consensus-babe/std", - "sp-consensus-beefy/std", - "sp-consensus-grandpa/std", - "sp-core/std", - "sp-runtime/std", - "xcm-executor/std", - "xcm/std", + "asset-hub-rococo-runtime/runtime-benchmarks", + "cumulus-primitives-core/runtime-benchmarks", + "frame-support/runtime-benchmarks", + "pallet-assets/runtime-benchmarks", + "pallet-balances/runtime-benchmarks", + "pallet-message-queue/runtime-benchmarks", + "polkadot-primitives/runtime-benchmarks", + "pop-runtime/runtime-benchmarks", + "rococo-runtime/runtime-benchmarks", + "sp-runtime/runtime-benchmarks", + "xcm-executor/runtime-benchmarks", ] try-runtime = [ - "asset-hub-rococo-runtime/std", - "cumulus-primitives-core/std", - "frame-support/std", - "pallet-assets/std", + "asset-hub-rococo-runtime/try-runtime", + "frame-support/try-runtime", + "pallet-assets/try-runtime", "pallet-balances/std", - "pallet-message-queue/std", - "polkadot-primitives/std", - "pop-runtime/std", - "rococo-runtime-constants/std", - "rococo-runtime/std", - "sp-authority-discovery/std", - "sp-consensus-babe/std", - "sp-consensus-beefy/std", - "sp-consensus-grandpa/std", - "sp-core/std", - "sp-runtime/std", - "xcm-executor/std", - "xcm/std", + "pallet-message-queue/try-runtime", + "pop-runtime/try-runtime", + "rococo-runtime/try-runtime", + "sp-runtime/try-runtime", ] \ No newline at end of file From 329ac0c0faad2d983488a217d1c8be3c80e74261 Mon Sep 17 00:00:00 2001 From: Frank Bell Date: Fri, 8 Mar 2024 20:27:49 +0000 Subject: [PATCH 15/23] refactor(deps): copy constants to tests to avoid unnecessary compilation --- Cargo.lock | 1 - Cargo.toml | 1 - emulated-integration-tests/Cargo.toml | 1 - emulated-integration-tests/src/chains/pop_network/genesis.rs | 3 ++- 4 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5333028b8..5ce7cb44a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3306,7 +3306,6 @@ dependencies = [ "pallet-message-queue", "parity-scale-codec", "polkadot-primitives", - "pop-node", "pop-runtime", "rococo-runtime", "rococo-runtime-constants", diff --git a/Cargo.toml b/Cargo.toml index cc331837c..57d643318 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -39,7 +39,6 @@ substrate-build-script-utils = { git = "https://github.com/paritytech/polkadot-s # Local pop-runtime = { path = "./runtime", default-features = false } -pop-node = { path = "./node", default-features = false } pop-api-primitives = { path = "./pop-api/primitives", default-features = false } # Substrate diff --git a/emulated-integration-tests/Cargo.toml b/emulated-integration-tests/Cargo.toml index f126796e1..af53ab461 100644 --- a/emulated-integration-tests/Cargo.toml +++ b/emulated-integration-tests/Cargo.toml @@ -36,7 +36,6 @@ emulated-integration-tests-common.workspace = true # Local pop-runtime.workspace = true -pop-node.workspace = true [features] default = ["std"] diff --git a/emulated-integration-tests/src/chains/pop_network/genesis.rs b/emulated-integration-tests/src/chains/pop_network/genesis.rs index 073226821..0e5debab5 100644 --- a/emulated-integration-tests/src/chains/pop_network/genesis.rs +++ b/emulated-integration-tests/src/chains/pop_network/genesis.rs @@ -1,9 +1,10 @@ use emulated_integration_tests_common::{accounts, build_genesis_storage, collators}; -use pop_node::chain_spec::{PARA_ID, SAFE_XCM_VERSION}; use pop_runtime::Balance; use sp_core::storage::Storage; pub(crate) const ED: Balance = pop_runtime::EXISTENTIAL_DEPOSIT; +pub const PARA_ID: u32 = 909; +pub const SAFE_XCM_VERSION: u32 = xcm::prelude::XCM_VERSION; pub(crate) fn genesis() -> Storage { let genesis_config = pop_runtime::RuntimeGenesisConfig { From 81c049038b86a2fca4193a3a858d1a723fbf9b12 Mon Sep 17 00:00:00 2001 From: Frank Bell Date: Fri, 8 Mar 2024 21:52:53 +0000 Subject: [PATCH 16/23] fix(integration-test): move para_id out of reserved range --- emulated-integration-tests/src/chains/pop_network/genesis.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/emulated-integration-tests/src/chains/pop_network/genesis.rs b/emulated-integration-tests/src/chains/pop_network/genesis.rs index 0e5debab5..eb160501b 100644 --- a/emulated-integration-tests/src/chains/pop_network/genesis.rs +++ b/emulated-integration-tests/src/chains/pop_network/genesis.rs @@ -3,7 +3,7 @@ use pop_runtime::Balance; use sp_core::storage::Storage; pub(crate) const ED: Balance = pop_runtime::EXISTENTIAL_DEPOSIT; -pub const PARA_ID: u32 = 909; +pub const PARA_ID: u32 = 9090; pub const SAFE_XCM_VERSION: u32 = xcm::prelude::XCM_VERSION; pub(crate) fn genesis() -> Storage { From 6c8f72a36b59d5545eaa19969add1633c0dcec65 Mon Sep 17 00:00:00 2001 From: Frank Bell Date: Fri, 8 Mar 2024 21:55:07 +0000 Subject: [PATCH 17/23] test: remove irrelevant tests --- emulated-integration-tests/src/lib.rs | 230 +------------------------- 1 file changed, 2 insertions(+), 228 deletions(-) diff --git a/emulated-integration-tests/src/lib.rs b/emulated-integration-tests/src/lib.rs index 5aaf41a84..2aac0f069 100644 --- a/emulated-integration-tests/src/lib.rs +++ b/emulated-integration-tests/src/lib.rs @@ -20,15 +20,10 @@ mod tests { RelayChain as Relay, Test, TestArgs, TestContext, TestExt, }, }; - use frame_support::{ - assert_err, - pallet_prelude::Weight, - sp_runtime::{DispatchError, DispatchResult}, - traits::fungibles::Inspect, - }; + use frame_support::{pallet_prelude::Weight, sp_runtime::DispatchResult}; use pop_runtime::{xcm_config::XcmConfig as PopNetworkXcmConfig, Balance}; use rococo_runtime::xcm_config::XcmConfig as RococoXcmConfig; - use xcm::prelude::{AccountId32 as AccountId32Junction, *}; + use xcm::prelude::*; decl_test_networks! { // `pub` mandatory for the macro @@ -48,10 +43,6 @@ mod tests { PopNetworkPara { sender: ALICE, receiver: BOB} } - const ASSET_ID: u32 = 1; - const ASSET_MIN_BALANCE: u128 = 1000; - const ASSETS_PALLET_ID: u8 = 50; - type RelayToParaTest = Test; type SystemParaToParaTest = Test; type ParaToSystemParaTest = Test; @@ -158,44 +149,6 @@ mod tests { ); } - fn system_para_to_para_assets_sender_assertions(t: SystemParaToParaTest) { - type RuntimeEvent = ::RuntimeEvent; - AssetHubRococoPara::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts( - 864_610_000, - 8799, - ))); - assert_expected_events!( - AssetHubRococoPara, - vec![ - // Amount to reserve transfer is transferred to Parachain's Sovereign account - RuntimeEvent::Assets( - pallet_assets::Event::Transferred { asset_id, from, to, amount } - ) => { - asset_id: *asset_id == ASSET_ID, - from: *from == t.sender.account_id, - to: *to == AssetHubRococoPara::sovereign_account_id_of( - t.args.dest.clone() - ), - amount: *amount == t.args.amount, - }, - ] - ); - } - - fn system_para_to_para_assets_receiver_assertions(_: Test) { - type RuntimeEvent = ::RuntimeEvent; - assert_expected_events!( - PopNetworkPara, - vec![ - RuntimeEvent::Balances(pallet_balances::Event::Deposit { .. }) => {}, - RuntimeEvent::Assets(pallet_assets::Event::Issued { .. }) => {}, - RuntimeEvent::MessageQueue( - pallet_message_queue::Event::Processed { success: true, .. } - ) => {}, - ] - ); - } - fn relay_to_para_reserve_transfer_assets(t: RelayToParaTest) -> DispatchResult { ::XcmPallet::limited_reserve_transfer_assets( t.signed_origin, @@ -229,79 +182,6 @@ mod tests { ) } - /// Reserve Transfers of native asset from Relay Chain to the System Parachain shouldn't work - #[test] - fn reserve_transfer_native_asset_from_relay_to_system_para_fails() { - let signed_origin = - ::RuntimeOrigin::signed(RococoRelaySender::get().into()); - let destination = RococoRelay::child_location_of(AssetHubRococoPara::para_id()); - let beneficiary: Location = - AccountId32Junction { network: None, id: AssetHubRococoParaReceiver::get().into() } - .into(); - let amount_to_send: Balance = ROCOCO_ED * 1000; - let assets: Assets = (Here, amount_to_send).into(); - let fee_asset_item = 0; - - // this should fail - RococoRelay::execute_with(|| { - let result = - ::XcmPallet::limited_reserve_transfer_assets( - signed_origin, - bx!(destination.into()), - bx!(beneficiary.into()), - bx!(assets.into()), - fee_asset_item, - WeightLimit::Unlimited, - ); - assert_err!( - result, - DispatchError::Module(sp_runtime::ModuleError { - index: 99, - error: [2, 0, 0, 0], - message: Some("Filtered") - }) - ); - }); - } - - /// Reserve Transfers of native asset from System Parachain to Relay Chain shouldn't work - #[test] - fn reserve_transfer_native_asset_from_system_para_to_relay_fails() { - // Init values for System Parachain - let signed_origin = ::RuntimeOrigin::signed( - AssetHubRococoParaSender::get().into(), - ); - let destination = AssetHubRococoPara::parent_location(); - let beneficiary_id = RococoRelayReceiver::get(); - let beneficiary: Location = - AccountId32Junction { network: None, id: beneficiary_id.into() }.into(); - let amount_to_send: Balance = ASSET_HUB_ROCOCO_ED * 1000; - - let assets: Assets = (Parent, amount_to_send).into(); - let fee_asset_item = 0; - - // this should fail - AssetHubRococoPara::execute_with(|| { - let result = - ::PolkadotXcm::limited_reserve_transfer_assets( - signed_origin, - bx!(destination.into()), - bx!(beneficiary.into()), - bx!(assets.into()), - fee_asset_item, - WeightLimit::Unlimited, - ); - assert_err!( - result, - DispatchError::Module(sp_runtime::ModuleError { - index: 31, - error: [2, 0, 0, 0], - message: Some("Filtered") - }) - ); - }); - } - /// Reserve Transfers of native asset from Relay to Parachain should work #[test] fn reserve_transfer_native_asset_from_relay_to_para() { @@ -458,110 +338,4 @@ mod tests { // but should be non-zero assert!(receiver_balance_after < receiver_balance_before + amount_to_send); } - - /// Reserve Transfers of a local asset and native asset from System Parachain to Parachain - /// should work - #[test] - fn reserve_transfer_assets_from_system_para_to_para() { - // Force create asset on AssetHubRococoPara and PopNetworkPara from Relay Chain - AssetHubRococoPara::force_create_and_mint_asset( - ASSET_ID, - ASSET_MIN_BALANCE, - false, - AssetHubRococoParaSender::get(), - Some(Weight::from_parts(1_019_445_000, 200_000)), - ASSET_MIN_BALANCE * 1_000_000, - ); - PopNetworkPara::force_create_and_mint_asset( - ASSET_ID, - ASSET_MIN_BALANCE, - false, - PopNetworkParaSender::get(), - None, - 0, - ); - - // Init values for System Parachain - let destination = AssetHubRococoPara::sibling_location_of(PopNetworkPara::para_id()); - let beneficiary_id = PopNetworkParaReceiver::get(); - let fee_amount_to_send = ASSET_HUB_ROCOCO_ED * 1000; - let asset_amount_to_send = ASSET_MIN_BALANCE * 1000; - let assets: Assets = vec![ - (Parent, fee_amount_to_send).into(), - ( - [PalletInstance(ASSETS_PALLET_ID), GeneralIndex(ASSET_ID.into())], - asset_amount_to_send, - ) - .into(), - ] - .into(); - let fee_asset_index = assets - .inner() - .iter() - .position(|r| r == &(Parent, fee_amount_to_send).into()) - .unwrap() as u32; - - let para_test_args = TestContext { - sender: AssetHubRococoParaSender::get(), - receiver: PopNetworkParaReceiver::get(), - args: TestArgs::new_para( - destination, - beneficiary_id, - asset_amount_to_send, - assets, - None, - fee_asset_index, - ), - }; - - let mut test = SystemParaToParaTest::new(para_test_args); - - // Create SA-of-Pop Network-on-AHR with ED. - let pop_net_location = AssetHubRococoPara::sibling_location_of(PopNetworkPara::para_id()); - let sov_pop_net_on_ahr = AssetHubRococoPara::sovereign_account_id_of(pop_net_location); - AssetHubRococoPara::fund_accounts(vec![(sov_pop_net_on_ahr.into(), ROCOCO_ED)]); - - let sender_balance_before = test.sender.balance; - let receiver_balance_before = test.receiver.balance; - - let sender_assets_before = AssetHubRococoPara::execute_with(|| { - type Assets = ::Assets; - >::balance(ASSET_ID, &AssetHubRococoParaSender::get()) - }); - let receiver_assets_before = PopNetworkPara::execute_with(|| { - type Assets = ::Assets; - >::balance(ASSET_ID, &PopNetworkParaReceiver::get()) - }); - - test.set_assertion::(system_para_to_para_assets_sender_assertions); - test.set_assertion::(system_para_to_para_assets_receiver_assertions); - test.set_dispatchable::(system_para_to_para_reserve_transfer_assets); - test.assert(); - - let sender_balance_after = test.sender.balance; - let receiver_balance_after = test.receiver.balance; - - // Sender's balance is reduced - assert!(sender_balance_after < sender_balance_before); - // Receiver's balance is increased - assert!(receiver_balance_after > receiver_balance_before); - // Receiver's balance increased by `amount_to_send - delivery_fees - bought_execution`; - // `delivery_fees` might be paid from transfer or JIT, also `bought_execution` is unknown - // but should be non-zero - assert!(receiver_balance_after < receiver_balance_before + fee_amount_to_send); - - let sender_assets_after = AssetHubRococoPara::execute_with(|| { - type Assets = ::Assets; - >::balance(ASSET_ID, &AssetHubRococoParaSender::get()) - }); - let receiver_assets_after = PopNetworkPara::execute_with(|| { - type Assets = ::Assets; - >::balance(ASSET_ID, &PopNetworkParaReceiver::get()) - }); - - // Sender's balance is reduced by exact amount - assert_eq!(sender_assets_before - asset_amount_to_send, sender_assets_after); - // Receiver's balance is increased by exact amount - assert_eq!(receiver_assets_after, receiver_assets_before + asset_amount_to_send); - } } From ec28e165e7dcac0f33e8ac941d55aadafaff9258 Mon Sep 17 00:00:00 2001 From: Frank Bell Date: Fri, 8 Mar 2024 23:17:24 +0000 Subject: [PATCH 18/23] test(xcm): reserve transfer to relay --- Cargo.lock | 51 ++++++++-- Cargo.toml | 1 + emulated-integration-tests/Cargo.toml | 3 + emulated-integration-tests/src/lib.rs | 136 ++++++++++++++++++++++++++ 4 files changed, 184 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5ce7cb44a..64a677ff9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3317,6 +3317,7 @@ dependencies = [ "sp-runtime 31.0.1", "staging-xcm", "staging-xcm-executor", + "tracing-subscriber 0.3.18", ] [[package]] @@ -6076,6 +6077,15 @@ dependencies = [ "regex-automata 0.1.10", ] +[[package]] +name = "matchers" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" +dependencies = [ + "regex-automata 0.1.10", +] + [[package]] name = "matches" version = "0.1.10" @@ -12007,8 +12017,8 @@ dependencies = [ "sp-tracing 16.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1)", "thiserror", "tracing", - "tracing-log", - "tracing-subscriber", + "tracing-log 0.1.4", + "tracing-subscriber 0.2.25", ] [[package]] @@ -13926,7 +13936,7 @@ dependencies = [ "sp-std 8.0.0", "tracing", "tracing-core", - "tracing-subscriber", + "tracing-subscriber 0.2.25", ] [[package]] @@ -13938,7 +13948,7 @@ dependencies = [ "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.1)", "tracing", "tracing-core", - "tracing-subscriber", + "tracing-subscriber 0.2.25", ] [[package]] @@ -13950,7 +13960,7 @@ dependencies = [ "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk)", "tracing", "tracing-core", - "tracing-subscriber", + "tracing-subscriber 0.2.25", ] [[package]] @@ -15069,6 +15079,17 @@ dependencies = [ "tracing-core", ] +[[package]] +name = "tracing-log" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" +dependencies = [ + "log", + "once_cell", + "tracing-core", +] + [[package]] name = "tracing-serde" version = "0.1.3" @@ -15088,7 +15109,7 @@ dependencies = [ "ansi_term", "chrono", "lazy_static", - "matchers", + "matchers 0.0.1", "parking_lot 0.11.2", "regex", "serde", @@ -15098,10 +15119,26 @@ dependencies = [ "thread_local", "tracing", "tracing-core", - "tracing-log", + "tracing-log 0.1.4", "tracing-serde", ] +[[package]] +name = "tracing-subscriber" +version = "0.3.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" +dependencies = [ + "matchers 0.1.0", + "once_cell", + "regex", + "sharded-slab", + "thread_local", + "tracing", + "tracing-core", + "tracing-log 0.2.0", +] + [[package]] name = "trie-db" version = "0.27.1" diff --git a/Cargo.toml b/Cargo.toml index 57d643318..d2eebbacb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,6 +32,7 @@ clap = { version = "4.4.18", features = ["derive"] } jsonrpsee = { version = "0.20.3", features = ["server"] } futures = "0.3.28" serde_json = "1.0.111" +tracing-subscriber = { version = "0.3", default-features = false } # Build substrate-wasm-builder = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1" } diff --git a/emulated-integration-tests/Cargo.toml b/emulated-integration-tests/Cargo.toml index af53ab461..26381307a 100644 --- a/emulated-integration-tests/Cargo.toml +++ b/emulated-integration-tests/Cargo.toml @@ -37,6 +37,9 @@ emulated-integration-tests-common.workspace = true # Local pop-runtime.workspace = true +[dev-dependencies] +tracing-subscriber = { workspace = true, features = ["env-filter", "fmt", "std", "tracing-log"] } + [features] default = ["std"] std = [ diff --git a/emulated-integration-tests/src/lib.rs b/emulated-integration-tests/src/lib.rs index 2aac0f069..21ba2985e 100644 --- a/emulated-integration-tests/src/lib.rs +++ b/emulated-integration-tests/src/lib.rs @@ -46,6 +46,7 @@ mod tests { type RelayToParaTest = Test; type SystemParaToParaTest = Test; type ParaToSystemParaTest = Test; + type ParaToRelayTest = Test; fn relay_to_para_sender_assertions(t: RelayToParaTest) { type RuntimeEvent = ::RuntimeEvent; @@ -126,6 +127,26 @@ mod tests { ); } + fn para_to_relay_sender_assertions(t: ParaToRelayTest) { + type RuntimeEvent = ::RuntimeEvent; + PopNetworkPara::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts( + 864_610_000, + 8_799, + ))); + assert_expected_events!( + PopNetworkPara, + vec![ + // Amount to reserve transfer is transferred to Parachain's Sovereign account + RuntimeEvent::Balances( + pallet_balances::Event::Withdraw { who, amount } + ) => { + who: *who == t.sender.account_id, + amount: *amount == t.args.amount, + }, + ] + ); + } + fn para_to_system_para_receiver_assertions(t: ParaToSystemParaTest) { type RuntimeEvent = ::RuntimeEvent; let sov_pop_net_on_ahr = AssetHubRococoPara::sovereign_account_id_of( @@ -149,6 +170,29 @@ mod tests { ); } + fn para_to_relay_receiver_assertions(t: ParaToRelayTest) { + type RuntimeEvent = ::RuntimeEvent; + let sov_pop_net_on_relay = RococoRelay::sovereign_account_id_of( + RococoRelay::child_location_of(PopNetworkPara::para_id()), + ); + assert_expected_events!( + RococoRelay, + vec![ + // Amount to reserve transfer is withdrawn from Parachain's Sovereign account + RuntimeEvent::Balances( + pallet_balances::Event::Withdraw { who, amount } + ) => { + who: *who == sov_pop_net_on_relay.clone().into(), + amount: *amount == t.args.amount, + }, + RuntimeEvent::Balances(pallet_balances::Event::Deposit { .. }) => {}, + RuntimeEvent::MessageQueue( + pallet_message_queue::Event::Processed { success: true, .. } + ) => {}, + ] + ); + } + fn relay_to_para_reserve_transfer_assets(t: RelayToParaTest) -> DispatchResult { ::XcmPallet::limited_reserve_transfer_assets( t.signed_origin, @@ -182,6 +226,17 @@ mod tests { ) } + fn para_to_relay_reserve_transfer_assets(t: ParaToRelayTest) -> DispatchResult { + ::PolkadotXcm::limited_reserve_transfer_assets( + t.signed_origin, + bx!(t.args.dest.into()), + bx!(t.args.beneficiary.into()), + bx!(t.args.assets.into()), + t.args.fee_asset_item, + t.args.weight_limit, + ) + } + /// Reserve Transfers of native asset from Relay to Parachain should work #[test] fn reserve_transfer_native_asset_from_relay_to_para() { @@ -231,6 +286,72 @@ mod tests { assert!(receiver_balance_after < receiver_balance_before + amount_to_send); } + /// Reserve Transfers of native asset from Parachain to Relay should work + #[test] + fn reserve_transfer_native_asset_from_para_to_relay() { + // Setup: reserve transfer from relay to Pop, so that sovereign account accurate for return transfer + let amount_to_send: Balance = ROCOCO_ED * 1000; + { + let destination = RococoRelay::child_location_of(PopNetworkPara::para_id()); + let beneficiary_id = PopNetworkParaReceiver::get(); + + let test_args = TestContext { + sender: RococoRelaySender::get(), + receiver: PopNetworkParaReceiver::get(), + args: TestArgs::new_relay(destination, beneficiary_id, amount_to_send), + }; + + let mut test = RelayToParaTest::new(test_args); + test.set_dispatchable::(relay_to_para_reserve_transfer_assets); + test.assert(); + } + + // Init values for Pop Network Parachain + let destination = PopNetworkPara::parent_location(); + let beneficiary_id = RococoRelayReceiver::get(); + let assets = (Parent, amount_to_send).into(); + + let test_args = TestContext { + sender: PopNetworkParaSender::get(), + receiver: RococoRelayReceiver::get(), + args: TestArgs::new_para(destination, beneficiary_id, amount_to_send, assets, None, 0), + }; + + let mut test = ParaToRelayTest::new(test_args); + + let sender_balance_before = test.sender.balance; + let receiver_balance_before = test.receiver.balance; + + test.set_assertion::(para_to_relay_sender_assertions); + test.set_assertion::(para_to_relay_receiver_assertions); + test.set_dispatchable::(para_to_relay_reserve_transfer_assets); + test.assert(); + + let sender_balance_after = test.sender.balance; + let receiver_balance_after = test.receiver.balance; + + let delivery_fees = PopNetworkPara::execute_with(|| { + xcm_helpers::transfer_assets_delivery_fees::< + ::XcmSender, + >( + test.args.assets.clone(), + 0, + test.args.weight_limit, + test.args.beneficiary, + test.args.dest, + ) + }); + + // Sender's balance is reduced + assert_eq!(sender_balance_before - amount_to_send - delivery_fees, sender_balance_after); + // Receiver's balance is increased + assert!(receiver_balance_after > receiver_balance_before); + // Receiver's balance increased by `amount_to_send - delivery_fees - bought_execution`; + // `delivery_fees` might be paid from transfer or JIT, also `bought_execution` is unknown + // but should be non-zero + assert!(receiver_balance_after < receiver_balance_before + amount_to_send); + } + /// Reserve Transfers of native asset from System Parachain to Parachain should work #[test] fn reserve_transfer_native_asset_from_system_para_to_para() { @@ -338,4 +459,19 @@ mod tests { // but should be non-zero assert!(receiver_balance_after < receiver_balance_before + amount_to_send); } + + #[allow(dead_code)] + static INIT: std::sync::Once = std::sync::Once::new(); + // Used during debugging by calling this function as first statement in test + #[allow(dead_code)] + fn init_tracing() { + INIT.call_once(|| { + // Add test tracing (from sp_tracing::init_for_tests()) but filtering for xcm logs only + let _ = tracing_subscriber::fmt() + .with_max_level(tracing_subscriber::filter::LevelFilter::TRACE) + .with_env_filter("xcm=trace,system::events=trace,evm=trace") // Comment out this line to see all traces + .with_test_writer() + .init(); + }); + } } From 2d1519c8f3a81ba651a6e68db77f90c7d192edd1 Mon Sep 17 00:00:00 2001 From: Frank Bell Date: Fri, 8 Mar 2024 23:18:07 +0000 Subject: [PATCH 19/23] feat(xcm): reserve transfers to relay/asset hub --- runtime/src/xcm_config.rs | 55 +++++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 22 deletions(-) diff --git a/runtime/src/xcm_config.rs b/runtime/src/xcm_config.rs index 9dd08dc7f..35e452160 100644 --- a/runtime/src/xcm_config.rs +++ b/runtime/src/xcm_config.rs @@ -2,9 +2,11 @@ use super::{ AccountId, AllPalletsWithSystem, Balances, ParachainInfo, ParachainSystem, PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, WeightToFee, XcmpQueue, }; +use core::marker::PhantomData; use frame_support::{ parameter_types, traits::{ConstU32, Contains, Everything, Nothing}, + traits::{ContainsPair, Get}, weights::Weight, }; use frame_system::EnsureRoot; @@ -16,16 +18,16 @@ use xcm::latest::prelude::*; use xcm_builder::CurrencyAdapter; use xcm_builder::{ AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowTopLevelPaidExecutionFrom, - DenyReserveTransferToRelayChain, DenyThenTry, EnsureXcmOrigin, FixedWeightBounds, - FrameTransactionalProcessor, IsConcrete, NativeAsset, ParentIsPreset, RelayChainAsNative, - SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative, - SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId, - UsingComponents, WithComputedOrigin, WithUniqueTopic, + EnsureXcmOrigin, FixedWeightBounds, FrameTransactionalProcessor, IsConcrete, NativeAsset, + ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, + SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, + TrailingSetTopicAsId, UsingComponents, WithComputedOrigin, WithUniqueTopic, }; use xcm_executor::XcmExecutor; parameter_types! { pub const RelayLocation: Location = Location::parent(); + pub AssetHub: Location = Location::new(1, [Parachain(1000)]); pub const RelayNetwork: Option = None; pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into(); pub UniversalLocation: InteriorLocation = Parachain(ParachainInfo::parachain_id().into()).into(); @@ -93,23 +95,31 @@ impl Contains for ParentOrParentsExecutivePlurality { } } -pub type Barrier = TrailingSetTopicAsId< - DenyThenTry< - DenyReserveTransferToRelayChain, +pub type Barrier = TrailingSetTopicAsId<( + TakeWeightCredit, + WithComputedOrigin< ( - TakeWeightCredit, - WithComputedOrigin< - ( - AllowTopLevelPaidExecutionFrom, - AllowExplicitUnpaidExecutionFrom, - // ^^^ Parent and its exec plurality get free execution - ), - UniversalLocation, - ConstU32<8>, - >, + AllowTopLevelPaidExecutionFrom, + AllowExplicitUnpaidExecutionFrom, + // ^^^ Parent and its exec plurality get free execution ), + UniversalLocation, + ConstU32<8>, >, ->; +)>; + +/// Asset filter that allows native/relay asset if coming from a certain location. +// Borrowed from https://github.com/paritytech/polkadot-sdk/blob/ea458d0b95d819d31683a8a09ca7973ae10b49be/cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs#L239 for now +pub struct NativeAssetFrom(PhantomData); +impl> ContainsPair for NativeAssetFrom { + fn contains(asset: &Asset, origin: &Location) -> bool { + let loc = T::get(); + &loc == origin + && matches!(asset, Asset { id: AssetId(asset_loc), fun: Fungible(_a) } + if *asset_loc == Location::from(Parent)) + } +} +pub type TrustedReserves = (NativeAsset, NativeAssetFrom); pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { @@ -118,7 +128,7 @@ impl xcm_executor::Config for XcmConfig { // How to withdraw and deposit an asset. type AssetTransactor = LocalAssetTransactor; type OriginConverter = XcmOriginToTransactDispatchOrigin; - type IsReserve = NativeAsset; + type IsReserve = TrustedReserves; type IsTeleporter = (); // Teleporting is disabled. type UniversalLocation = UniversalLocation; type Barrier = Barrier; @@ -163,8 +173,9 @@ impl pallet_xcm::Config for Runtime { // ^ Disable dispatchable execute on the XCM pallet. // Needs to be `Everything` for local testing. type XcmExecutor = XcmExecutor; - type XcmTeleportFilter = Everything; - type XcmReserveTransferFilter = Nothing; + type XcmTeleportFilter = Nothing; + // TODO: add filter to only allow reserve transfers of native to relay/asset hub + type XcmReserveTransferFilter = Everything; type Weigher = FixedWeightBounds; type UniversalLocation = UniversalLocation; type RuntimeOrigin = RuntimeOrigin; From 688b47dc408bf8f4a1c1ee969d98d3ed24089003 Mon Sep 17 00:00:00 2001 From: Frank Bell Date: Fri, 8 Mar 2024 23:20:55 +0000 Subject: [PATCH 20/23] refactor(integration-tests): simplify crate name --- Cargo.lock | 56 +++++++++---------- Cargo.toml | 2 +- .../Cargo.toml | 2 +- .../src/chains/asset_hub_rococo/genesis.rs | 0 .../src/chains/asset_hub_rococo/mod.rs | 0 .../src/chains/mod.rs | 0 .../src/chains/pop_network/genesis.rs | 0 .../src/chains/pop_network/mod.rs | 0 .../src/chains/rococo/genesis.rs | 0 .../src/chains/rococo/mod.rs | 0 .../src/lib.rs | 0 11 files changed, 30 insertions(+), 30 deletions(-) rename {emulated-integration-tests => integration-tests}/Cargo.toml (98%) rename {emulated-integration-tests => integration-tests}/src/chains/asset_hub_rococo/genesis.rs (100%) rename {emulated-integration-tests => integration-tests}/src/chains/asset_hub_rococo/mod.rs (100%) rename {emulated-integration-tests => integration-tests}/src/chains/mod.rs (100%) rename {emulated-integration-tests => integration-tests}/src/chains/pop_network/genesis.rs (100%) rename {emulated-integration-tests => integration-tests}/src/chains/pop_network/mod.rs (100%) rename {emulated-integration-tests => integration-tests}/src/chains/rococo/genesis.rs (100%) rename {emulated-integration-tests => integration-tests}/src/chains/rococo/mod.rs (100%) rename {emulated-integration-tests => integration-tests}/src/lib.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index 64a677ff9..ec2879dd7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3292,34 +3292,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "emulated-integration-tests" -version = "0.0.0" -dependencies = [ - "asset-hub-rococo-runtime", - "asset-test-utils", - "cumulus-primitives-core", - "emulated-integration-tests-common", - "frame-support", - "pallet-assets", - "pallet-balances", - "pallet-message-queue", - "parity-scale-codec", - "polkadot-primitives", - "pop-runtime", - "rococo-runtime", - "rococo-runtime-constants", - "sp-authority-discovery", - "sp-consensus-babe", - "sp-consensus-beefy", - "sp-consensus-grandpa", - "sp-core 28.0.0", - "sp-runtime 31.0.1", - "staging-xcm", - "staging-xcm-executor", - "tracing-subscriber 0.3.18", -] - [[package]] name = "emulated-integration-tests-common" version = "3.0.0" @@ -5042,6 +5014,34 @@ dependencies = [ "num-traits", ] +[[package]] +name = "integration-tests" +version = "0.0.0" +dependencies = [ + "asset-hub-rococo-runtime", + "asset-test-utils", + "cumulus-primitives-core", + "emulated-integration-tests-common", + "frame-support", + "pallet-assets", + "pallet-balances", + "pallet-message-queue", + "parity-scale-codec", + "polkadot-primitives", + "pop-runtime", + "rococo-runtime", + "rococo-runtime-constants", + "sp-authority-discovery", + "sp-consensus-babe", + "sp-consensus-beefy", + "sp-consensus-grandpa", + "sp-core 28.0.0", + "sp-runtime 31.0.1", + "staging-xcm", + "staging-xcm-executor", + "tracing-subscriber 0.3.18", +] + [[package]] name = "io-lifetimes" version = "1.0.11" diff --git a/Cargo.toml b/Cargo.toml index d2eebbacb..5459c8c70 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ repository = "https://github.com/r0gue-io/pop-node/" members = [ "node", "runtime", - "emulated-integration-tests", + "integration-tests", "pop-api", ] exclude = [ diff --git a/emulated-integration-tests/Cargo.toml b/integration-tests/Cargo.toml similarity index 98% rename from emulated-integration-tests/Cargo.toml rename to integration-tests/Cargo.toml index 26381307a..adf2f7e74 100644 --- a/emulated-integration-tests/Cargo.toml +++ b/integration-tests/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "emulated-integration-tests" +name = "integration-tests" authors.workspace = true edition.workspace = true homepage.workspace = true diff --git a/emulated-integration-tests/src/chains/asset_hub_rococo/genesis.rs b/integration-tests/src/chains/asset_hub_rococo/genesis.rs similarity index 100% rename from emulated-integration-tests/src/chains/asset_hub_rococo/genesis.rs rename to integration-tests/src/chains/asset_hub_rococo/genesis.rs diff --git a/emulated-integration-tests/src/chains/asset_hub_rococo/mod.rs b/integration-tests/src/chains/asset_hub_rococo/mod.rs similarity index 100% rename from emulated-integration-tests/src/chains/asset_hub_rococo/mod.rs rename to integration-tests/src/chains/asset_hub_rococo/mod.rs diff --git a/emulated-integration-tests/src/chains/mod.rs b/integration-tests/src/chains/mod.rs similarity index 100% rename from emulated-integration-tests/src/chains/mod.rs rename to integration-tests/src/chains/mod.rs diff --git a/emulated-integration-tests/src/chains/pop_network/genesis.rs b/integration-tests/src/chains/pop_network/genesis.rs similarity index 100% rename from emulated-integration-tests/src/chains/pop_network/genesis.rs rename to integration-tests/src/chains/pop_network/genesis.rs diff --git a/emulated-integration-tests/src/chains/pop_network/mod.rs b/integration-tests/src/chains/pop_network/mod.rs similarity index 100% rename from emulated-integration-tests/src/chains/pop_network/mod.rs rename to integration-tests/src/chains/pop_network/mod.rs diff --git a/emulated-integration-tests/src/chains/rococo/genesis.rs b/integration-tests/src/chains/rococo/genesis.rs similarity index 100% rename from emulated-integration-tests/src/chains/rococo/genesis.rs rename to integration-tests/src/chains/rococo/genesis.rs diff --git a/emulated-integration-tests/src/chains/rococo/mod.rs b/integration-tests/src/chains/rococo/mod.rs similarity index 100% rename from emulated-integration-tests/src/chains/rococo/mod.rs rename to integration-tests/src/chains/rococo/mod.rs diff --git a/emulated-integration-tests/src/lib.rs b/integration-tests/src/lib.rs similarity index 100% rename from emulated-integration-tests/src/lib.rs rename to integration-tests/src/lib.rs From 9f8de7a67db23ffe808f4ff8952c3a6f72c62e6a Mon Sep 17 00:00:00 2001 From: Frank Bell Date: Fri, 8 Mar 2024 23:55:08 +0000 Subject: [PATCH 21/23] fix: update pop para id --- networks/rococo.toml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/networks/rococo.toml b/networks/rococo.toml index ab7421fec..8316c9d1b 100644 --- a/networks/rococo.toml +++ b/networks/rococo.toml @@ -6,20 +6,20 @@ node_spawn_timeout = 300 chain = "rococo-local" default_command = "./bin/polkadot" - [[relaychain.nodes]] - name = "alice" - validator = true +[[relaychain.nodes]] +name = "alice" +validator = true - [[relaychain.nodes]] - name = "bob" - validator = true +[[relaychain.nodes]] +name = "bob" +validator = true [[parachains]] -id = 909 +id = 9090 default_command = "./target/release/pop-node" - [[parachains.collators]] - name = "pop" - command = "./target/release/pop-node" - port = 9944 - args = ["-lruntime::contracts=debug", "-lpopapi::extension=debug"] \ No newline at end of file +[[parachains.collators]] +name = "pop" +command = "./target/release/pop-node" +port = 9944 +args = ["-lruntime::contracts=debug", "-lpopapi::extension=debug"] \ No newline at end of file From 8f9f06673375fee341728a4ed5f625e669d1721b Mon Sep 17 00:00:00 2001 From: Frank Bell Date: Sat, 9 Mar 2024 00:11:00 +0000 Subject: [PATCH 22/23] fix: reduce visibility, address clippy warning --- integration-tests/src/chains/pop_network/genesis.rs | 4 ++-- node/src/chain_spec.rs | 4 ++-- node/src/lib.rs | 1 - runtime/src/lib.rs | 1 + 4 files changed, 5 insertions(+), 5 deletions(-) delete mode 100644 node/src/lib.rs diff --git a/integration-tests/src/chains/pop_network/genesis.rs b/integration-tests/src/chains/pop_network/genesis.rs index eb160501b..51978a97d 100644 --- a/integration-tests/src/chains/pop_network/genesis.rs +++ b/integration-tests/src/chains/pop_network/genesis.rs @@ -3,8 +3,8 @@ use pop_runtime::Balance; use sp_core::storage::Storage; pub(crate) const ED: Balance = pop_runtime::EXISTENTIAL_DEPOSIT; -pub const PARA_ID: u32 = 9090; -pub const SAFE_XCM_VERSION: u32 = xcm::prelude::XCM_VERSION; +const PARA_ID: u32 = 9090; +const SAFE_XCM_VERSION: u32 = xcm::prelude::XCM_VERSION; pub(crate) fn genesis() -> Storage { let genesis_config = pop_runtime::RuntimeGenesisConfig { diff --git a/node/src/chain_spec.rs b/node/src/chain_spec.rs index 680ebc877..f087db585 100644 --- a/node/src/chain_spec.rs +++ b/node/src/chain_spec.rs @@ -10,10 +10,10 @@ use sp_runtime::traits::{IdentifyAccount, Verify}; pub type ChainSpec = sc_service::GenericChainSpec<(), Extensions>; /// The default XCM version to set in genesis config. -pub const SAFE_XCM_VERSION: u32 = xcm::prelude::XCM_VERSION; +const SAFE_XCM_VERSION: u32 = xcm::prelude::XCM_VERSION; /// The local para ID of Pop Network. -pub const PARA_ID: u32 = 909; +const PARA_ID: u32 = 9090; /// Helper function to generate a crypto pair from seed pub fn get_from_seed(seed: &str) -> ::Public { diff --git a/node/src/lib.rs b/node/src/lib.rs deleted file mode 100644 index 514487d1f..000000000 --- a/node/src/lib.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod chain_spec; diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index bbbf67d93..748f45c31 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -188,6 +188,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("pop"), impl_name: create_runtime_str!("pop"), authoring_version: 1, + #[allow(clippy::zero_prefixed_literal)] spec_version: 00_01_00, impl_version: 0, apis: RUNTIME_API_VERSIONS, From 7b34f7867ed8a1ac6829d5bb261bc72a7c391599 Mon Sep 17 00:00:00 2001 From: Frank Bell Date: Sat, 9 Mar 2024 09:40:00 +0000 Subject: [PATCH 23/23] refactor: uplift network declaration --- integration-tests/src/lib.rs | 41 ++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/integration-tests/src/lib.rs b/integration-tests/src/lib.rs index 21ba2985e..98acbbf19 100644 --- a/integration-tests/src/lib.rs +++ b/integration-tests/src/lib.rs @@ -1,23 +1,36 @@ +use chains::{asset_hub_rococo::AssetHubRococo, pop_network::PopNetwork, rococo::Rococo}; +use emulated_integration_tests_common::xcm_emulator::decl_test_networks; + #[cfg(test)] mod chains; +decl_test_networks! { + // `pub` mandatory for the macro + pub struct RococoMockNet { + relay_chain = Rococo, + parachains = vec![ + AssetHubRococo, + PopNetwork, + ], + bridge = () + }, +} + #[cfg(test)] mod tests { + use super::*; use crate::chains::{ - asset_hub_rococo::{ - genesis::ED as ASSET_HUB_ROCOCO_ED, AssetHubRococo, AssetHubRococoParaPallet, - }, - pop_network::{PopNetwork, PopNetworkParaPallet}, - rococo::{genesis::ED as ROCOCO_ED, Rococo, RococoRelayPallet}, + asset_hub_rococo::{genesis::ED as ASSET_HUB_ROCOCO_ED, AssetHubRococoParaPallet}, + pop_network::PopNetworkParaPallet, + rococo::{genesis::ED as ROCOCO_ED, RococoRelayPallet}, }; use asset_hub_rococo_runtime::xcm_config::XcmConfig as AssetHubRococoXcmConfig; use asset_test_utils::xcm_helpers; use emulated_integration_tests_common::{ accounts::{ALICE, BOB}, xcm_emulator::{ - assert_expected_events, bx, decl_test_networks, - decl_test_sender_receiver_accounts_parameter_types, Chain, Parachain as Para, - RelayChain as Relay, Test, TestArgs, TestContext, TestExt, + assert_expected_events, bx, decl_test_sender_receiver_accounts_parameter_types, Chain, + Parachain as Para, RelayChain as Relay, Test, TestArgs, TestContext, TestExt, }, }; use frame_support::{pallet_prelude::Weight, sp_runtime::DispatchResult}; @@ -25,18 +38,6 @@ mod tests { use rococo_runtime::xcm_config::XcmConfig as RococoXcmConfig; use xcm::prelude::*; - decl_test_networks! { - // `pub` mandatory for the macro - pub struct RococoMockNet { - relay_chain = Rococo, - parachains = vec![ - AssetHubRococo, - PopNetwork, - ], - bridge = () - }, - } - decl_test_sender_receiver_accounts_parameter_types! { RococoRelay { sender: ALICE, receiver: BOB }, AssetHubRococoPara { sender: ALICE, receiver: BOB },