Skip to content

Commit

Permalink
Integrate new xcm-emulator (#1324)
Browse files Browse the repository at this point in the history
* Integrate new xcm-emulator environment

* Utilize new xcm-emulator interfaces

* Spawn relay-para network using patched xcm-emulator

* Use proper collator genesis config

* Fix Rococo tests

* Finalize Battery Station XCM tests

* Finalize Zeitgeist XCM tests
  • Loading branch information
sea212 authored Apr 29, 2024
1 parent c5c31de commit de0fad9
Show file tree
Hide file tree
Showing 24 changed files with 1,239 additions and 817 deletions.
112 changes: 94 additions & 18 deletions Cargo.lock

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

11 changes: 10 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ substrate-frame-rpc-system = { git = "https://github.com/paritytech/polkadot-sdk
substrate-prometheus-endpoint = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
substrate-wasm-builder = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
try-runtime-cli = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
xcm-simulator = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }

# Substrate (wasm)
frame-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false }
Expand All @@ -186,6 +185,7 @@ pallet-contracts-primitives = { git = "https://github.com/paritytech/polkadot-sd
pallet-democracy = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false }
pallet-grandpa = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false }
pallet-identity = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false }
pallet-im-online = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false }
pallet-insecure-randomness-collective-flip = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false }
pallet-membership = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false }
pallet-multisig = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false }
Expand All @@ -203,8 +203,11 @@ parity-scale-codec = { version = "3.6.9", default-features = false }
scale-info = { version = "2.11.1", default-features = false }
sp-api = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false }
sp-arithmetic = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false }
sp-authority-discovery = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false }
sp-block-builder = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false }
sp-consensus-aura = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false }
sp-consensus-babe = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false }
sp-consensus-beefy = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false }
sp-consensus-grandpa = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false }
sp-core = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false }
sp-debug-derive = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false }
Expand All @@ -222,6 +225,7 @@ substrate-fixed = { git = "https://github.com/encointer/substrate-fixed", defaul
polkadot-cli = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
polkadot-service = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
polkadot-test-service = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
xcm-emulator = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }

# Polkadot / XCM (wasm)
pallet-message-queue = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false }
Expand All @@ -231,6 +235,7 @@ polkadot-primitives = { git = "https://github.com/paritytech/polkadot-sdk", bran
polkadot-runtime = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false }
polkadot-runtime-parachains = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false }
rococo-runtime = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false }
rococo-runtime-constants = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false }
xcm = { package = "staging-xcm", git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false }
xcm-builder = { package = "staging-xcm-builder", git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false }
xcm-executor = { package = "staging-xcm-executor", git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false }
Expand Down Expand Up @@ -352,6 +357,10 @@ panic = "unwind"
# Commits:
# - cb803be8cdc52d020890308a2076d752a8c4ce5c
pallet-assets = { git = "https://github.com/zeitgeistpm/polkadot-sdk", branch = "zeitgeist-polkadot-v1.1.0" }
# xcm-emulator incompatible block number type fixed
# Commits:
# -
xcm-emulator = { git = "https://github.com/zeitgeistpm/polkadot-sdk", branch = "release-polkadot-v1.1.0-xcm-emulator-type-fix" }

[patch."https://github.com/galacticcouncil/HydraDX-node"]
# Ensure same Substrate dependencies are used everywhere
Expand Down
7 changes: 6 additions & 1 deletion runtime/battery-station/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,13 @@ zrml-swaps-runtime-api = { workspace = true }

[dev-dependencies]
env_logger = { workspace = true }
pallet-im-online = { workspace = true, features = ["default"] }
sp-authority-discovery = { workspace = true, features = ["default"] }
sp-consensus-babe = { workspace = true, features = ["default"] }
sp-consensus-beefy = { workspace = true, features = ["default"] }
sp-io = { workspace = true, features = ["default"] }
test-case = { workspace = true }
xcm-simulator = { workspace = true }
xcm-emulator = { workspace = true }

[features]
default = ["std"]
Expand Down Expand Up @@ -333,6 +337,7 @@ std = [
# Zeitgeist

"zeitgeist-primitives/std",
"zrml-asset-router/std",
"zrml-authorized/std",
"zrml-court/std",
"zrml-hybrid-router/std",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
// Copyright 2024 Forecasting Technologies LTD.
//
// This file is part of Zeitgeist.
//
// Zeitgeist is free software: you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the
// Free Software Foundation, either version 3 of the License, or (at
// your option) any later version.
//
// Zeitgeist is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Zeitgeist. If not, see <https://www.gnu.org/licenses/>.

use crate::{
integration_tests::xcm::setup::{
accounts, ztg, BTC_ID, FOREIGN_PARENT_ID, FOREIGN_SIBLING_ID, FOREIGN_ZTG_ID,
},
parachain_params::MinCandidateStk,
parameters::ZeitgeistTreasuryAccount,
Asset,
};
use nimbus_primitives::NimbusId;
use sp_core::storage::Storage;
use sp_runtime::BuildStorage;

const ENDOWMENT: u128 = ztg(1_000_000);
const SAFE_XCM_VERSION: u32 = 2;

pub(crate) fn genesis(parachain_id: u32) -> Storage {
let genesis_config = crate::RuntimeGenesisConfig {
author_mapping: crate::AuthorMappingConfig {
mappings: vec![(
accounts::get_from_seed::<NimbusId>(accounts::ALICE),
accounts::alice(),
)],
},
balances: crate::BalancesConfig {
balances: accounts::init_balances().iter().map(|k| (k.clone(), ENDOWMENT)).collect(),
},
parachain_info: crate::ParachainInfoConfig {
parachain_id: parachain_id.into(),
..Default::default()
},
parachain_staking: crate::ParachainStakingConfig {
candidates: vec![(accounts::alice(), MinCandidateStk::get())],
..Default::default()
},
polkadot_xcm: crate::PolkadotXcmConfig {
safe_xcm_version: Some(SAFE_XCM_VERSION),
..Default::default()
},
system: crate::SystemConfig {
code: crate::WASM_BINARY.unwrap().to_vec(),
..Default::default()
},
tokens: crate::TokensConfig {
balances: accounts::init_balances()
.iter()
.chain(vec![(ZeitgeistTreasuryAccount::get())].iter())
.map(|k| {
vec![
(k.clone(), Asset::from(FOREIGN_PARENT_ID).try_into().unwrap(), ENDOWMENT),
(k.clone(), Asset::from(FOREIGN_SIBLING_ID).try_into().unwrap(), ENDOWMENT),
(k.clone(), Asset::from(FOREIGN_ZTG_ID).try_into().unwrap(), ENDOWMENT),
(k.clone(), Asset::from(BTC_ID).try_into().unwrap(), ENDOWMENT),
]
})
.flatten()
.collect::<Vec<_>>(),
},
..Default::default()
};

genesis_config.build_storage().unwrap()
}
19 changes: 19 additions & 0 deletions runtime/battery-station/src/integration_tests/xcm/genesis/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright 2024 Forecasting Technologies LTD.
//
// This file is part of Zeitgeist.
//
// Zeitgeist is free software: you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the
// Free Software Foundation, either version 3 of the License, or (at
// your option) any later version.
//
// Zeitgeist is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Zeitgeist. If not, see <https://www.gnu.org/licenses/>.

pub(super) mod battery_station;
pub(super) mod rococo;
Loading

0 comments on commit de0fad9

Please sign in to comment.