Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade runtime v1.4.0 #164

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
4,219 changes: 2,398 additions & 1,821 deletions Cargo.lock

Large diffs are not rendered by default.

343 changes: 178 additions & 165 deletions Cargo.toml

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions chain-spec-generator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ fn main() -> Result<(), String> {
),
(
"bridge-hub-paseo-local",
Box::new(|| system_parachains_specs::bridge_hub_paseo_local_testnet_config())
Box::new(system_parachains_specs::bridge_hub_paseo_local_testnet_config)
as Box<_>,
),
(
Expand All @@ -56,7 +56,7 @@ fn main() -> Result<(), String> {
),
(
"coretime-paseo-local",
Box::new(|| system_parachains_specs::coretime_paseo_local_testnet_config()) as Box<_>,
Box::new(system_parachains_specs::coretime_paseo_local_testnet_config) as Box<_>,
),
(
"coretime-paseo-tot",
Expand Down
9 changes: 3 additions & 6 deletions chain-spec-generator/src/system_parachains_specs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.

use sc_chain_spec::{ChainSpec, ChainSpecExtension, ChainSpecGroup, ChainType};
use sc_network::config::MultiaddrWithPeerId;
use serde::{Deserialize, Serialize};
use std::str::FromStr;

/// Generic extensions for Parachain ChainSpecs.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, ChainSpecGroup, ChainSpecExtension)]
Expand Down Expand Up @@ -50,12 +52,7 @@ pub fn asset_hub_paseo_local_testnet_config() -> Result<Box<dyn ChainSpec>, Stri
.with_name("Asset Hub Paseo Local")
.with_id("asset-hub-paseo-local")
.with_chain_type(ChainType::Local)
.with_protocol_id("ah-pas")
.with_genesis_config_patch(
asset_hub_paseo_runtime::genesis_config_presets::asset_hub_paseo_local_testnet_genesis(
1000.into(),
),
)
.with_genesis_config_preset_name("local_testnet")
.with_properties(properties)
.build(),
))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use emulated_integration_tests_common::{
SAFE_XCM_VERSION,
};
use frame_support::sp_runtime::traits::AccountIdConversion;
use parachains_common::{AccountId, AuraId, Balance};
use parachains_common::{AccountId, AssetHubPolkadotAuraId, Balance};
use polkadot_parachain_primitives::primitives::Sibling;
use sp_core::sr25519;
use xcm::prelude::*;
Expand Down Expand Up @@ -51,15 +51,15 @@ frame_support::parameter_types! {
pub PenpalBSiblingSovereignAccount: AccountId = Sibling::from(penpal_emulated_chain::PARA_ID_B).into_account_truncating();
}

fn invulnerables_asset_hub_paseo() -> Vec<(AccountId, AuraId)> {
fn invulnerables_asset_hub_paseo() -> Vec<(AccountId, AssetHubPolkadotAuraId)> {
vec![
(
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_from_seed::<AuraId>("Alice"),
get_from_seed::<AssetHubPolkadotAuraId>("Alice"),
),
(
get_account_id_from_seed::<sr25519::Public>("Bob"),
get_from_seed::<AuraId>("Bob"),
get_from_seed::<AssetHubPolkadotAuraId>("Bob"),
),
]
}
Expand Down Expand Up @@ -98,6 +98,7 @@ pub fn genesis() -> Storage {
)
})
.collect(),
..Default::default()
},
polkadot_xcm: asset_hub_paseo_runtime::PolkadotXcmConfig {
safe_xcm_version: Some(SAFE_XCM_VERSION),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ publish = false
sp-core = { workspace = true, default-features = true }
frame-support = { workspace = true, default-features = true }

# Bridges
bp-messages = { workspace = true }
xcm = { workspace = true }

# Cumulus
parachains-common = { workspace = true, default-features = true }
bridge-hub-common = { workspace = true, default-features = true }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use emulated_integration_tests_common::{
accounts, build_genesis_storage, collators, get_account_id_from_seed, SAFE_XCM_VERSION,
};
use parachains_common::Balance;
use xcm::latest::prelude::*;

pub const ASSET_HUB_PARA_ID: u32 = 1000;
pub const PARA_ID: u32 = 1002;
Expand Down Expand Up @@ -52,6 +53,7 @@ pub fn genesis() -> Storage {
)
})
.collect(),
..Default::default()
},
polkadot_xcm: bridge_hub_paseo_runtime::PolkadotXcmConfig {
safe_xcm_version: Some(SAFE_XCM_VERSION),
Expand All @@ -70,6 +72,17 @@ pub fn genesis() -> Storage {
asset_hub_para_id: ASSET_HUB_PARA_ID.into(),
..Default::default()
},
xcm_over_bridge_hub_kusama: bridge_hub_paseo_runtime::XcmOverBridgeHubKusamaConfig {
opened_bridges: vec![
// open PAH -> KAH bridge
(
Location::new(1, [Parachain(1000)]),
Junctions::from([Kusama.into(), Parachain(1000)]),
Some(bp_messages::LegacyLaneId([0, 0, 0, 1])),
),
],
..Default::default()
},
..Default::default()
};

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[package]
name = "collectives-paseo-emulated-chain"
version = "0.0.0"
authors.workspace = true
edition.workspace = true
license = "Apache-2.0"
description = "Collectives Paseo emulated chain used for integration tests"
publish = false

[dependencies]

# Substrate
sp-core = { workspace = true, default-features = true }
frame-support = { workspace = true, default-features = true }

# Cumulus
parachains-common = { workspace = true, default-features = true }
cumulus-primitives-core = { workspace = true, default-features = true }
emulated-integration-tests-common = { workspace = true }

# Runtimes
collectives-paseo-runtime = { workspace = true }
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
// 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 = 1001;
pub const ED: Balance = collectives_paseo_runtime::ExistentialDeposit::get();

pub fn genesis() -> Storage {
let genesis_config = collectives_paseo_runtime::RuntimeGenesisConfig {
system: collectives_paseo_runtime::SystemConfig::default(),
balances: collectives_paseo_runtime::BalancesConfig {
balances: accounts::init_balances().iter().cloned().map(|k| (k, ED * 4096)).collect(),
},
parachain_info: collectives_paseo_runtime::ParachainInfoConfig {
parachain_id: PARA_ID.into(),
..Default::default()
},
collator_selection: collectives_paseo_runtime::CollatorSelectionConfig {
invulnerables: collators::invulnerables().iter().cloned().map(|(acc, _)| acc).collect(),
candidacy_bond: ED * 16,
..Default::default()
},
session: collectives_paseo_runtime::SessionConfig {
keys: collators::invulnerables()
.into_iter()
.map(|(acc, aura)| {
(
acc.clone(), // account id
acc, // validator id
collectives_paseo_runtime::SessionKeys { aura }, // session keys
)
})
.collect(),
..Default::default()
},
polkadot_xcm: collectives_paseo_runtime::PolkadotXcmConfig {
safe_xcm_version: Some(SAFE_XCM_VERSION),
..Default::default()
},
..Default::default()
};

build_genesis_storage(
&genesis_config,
collectives_paseo_runtime::WASM_BINARY
.expect("WASM binary was not built, please build it!"),
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// 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 emulated_integration_tests_common::{
impl_accounts_helpers_for_parachain, impl_assert_events_helpers_for_parachain,
impls::Parachain, xcm_emulator::decl_test_parachains,
};

// CollectivesPolkadot Parachain declaration
decl_test_parachains! {
pub struct CollectivesPaseo {
genesis = genesis::genesis(),
on_init = {
collectives_paseo_runtime::AuraExt::on_initialize(1);
},
runtime = collectives_paseo_runtime,
core = {
XcmpMessageHandler: collectives_paseo_runtime::XcmpQueue,
LocationToAccountId: collectives_paseo_runtime::xcm_config::LocationToAccountId,
ParachainInfo: collectives_paseo_runtime::ParachainInfo,
MessageOrigin: cumulus_primitives_core::AggregateMessageOrigin,
},
pallets = {
PolkadotXcm: collectives_paseo_runtime::PolkadotXcm,
Balances: collectives_paseo_runtime::Balances,
FellowshipTreasury: collectives_paseo_runtime::FellowshipTreasury,
AssetRate: collectives_paseo_runtime::AssetRate,
}
},
}

// CollectivesPolkadot implementation
impl_accounts_helpers_for_parachain!(CollectivesPaseo);
impl_assert_events_helpers_for_parachain!(CollectivesPaseo);
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ pub fn genesis() -> Storage {
)
})
.collect(),
..Default::default()
},
polkadot_xcm: coretime_paseo_runtime::PolkadotXcmConfig {
safe_xcm_version: Some(SAFE_XCM_VERSION),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ parachains-common = { workspace = true, default-features = true }
cumulus-primitives-core = { workspace = true, default-features = true }
emulated-integration-tests-common = { workspace = true }

# Runtimes
paseo-runtime-constants = { workspace = true, default-features = true }

# Local
people-paseo-runtime = { workspace = true, default-features = true }
paseo-emulated-chain = { workspace = true, default-features = true }
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,21 @@ use sp_core::storage::Storage;

// Cumulus
use cumulus_primitives_core::ParaId;
use emulated_integration_tests_common::{build_genesis_storage, collators, SAFE_XCM_VERSION};
use emulated_integration_tests_common::{
accounts, build_genesis_storage, collators, SAFE_XCM_VERSION,
};
use parachains_common::Balance;
use paseo_runtime_constants::currency::UNITS as PAS;

const ENDOWMENT: u128 = 1_000 * PAS;
pub const PARA_ID: u32 = 1004;
pub const ED: Balance = people_paseo_runtime::ExistentialDeposit::get();

pub fn genesis() -> Storage {
let genesis_config = people_paseo_runtime::RuntimeGenesisConfig {
balances: people_paseo_runtime::BalancesConfig {
balances: accounts::init_balances().iter().cloned().map(|k| (k, ENDOWMENT)).collect(),
},
system: people_paseo_runtime::SystemConfig::default(),
parachain_info: people_paseo_runtime::ParachainInfoConfig {
parachain_id: ParaId::from(PARA_ID),
Expand All @@ -47,6 +54,7 @@ pub fn genesis() -> Storage {
)
})
.collect(),
..Default::default()
},
polkadot_xcm: people_paseo_runtime::PolkadotXcmConfig {
safe_xcm_version: Some(SAFE_XCM_VERSION),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@ use emulated_integration_tests_common::{
accounts, build_genesis_storage, collators, get_account_id_from_seed, SAFE_XCM_VERSION,
};
use parachains_common::{AccountId, Balance};
use penpal_runtime::xcm_config::{LocalReservableFromAssetHub, RelayLocation};
use penpal_runtime::xcm_config::{LocalReservableFromAssetHub, RelayLocation, UsdtFromAssetHub};

// Penpal
pub const PARA_ID_A: u32 = 2000;
pub const PARA_ID_B: u32 = 2001;
pub const ED: Balance = penpal_runtime::ExistentialDeposit::get();
pub const USDT_ED: Balance = 70_000;

parameter_types! {
pub PenpalSudoAccount: AccountId = get_account_id_from_seed::<sr25519::Public>("Alice");
Expand Down Expand Up @@ -60,13 +61,32 @@ pub fn genesis(para_id: u32) -> Storage {
)
})
.collect(),
..Default::default()
},
polkadot_xcm: penpal_runtime::PolkadotXcmConfig {
safe_xcm_version: Some(SAFE_XCM_VERSION),
..Default::default()
},
sudo: penpal_runtime::SudoConfig {
key: Some(get_account_id_from_seed::<sr25519::Public>("Alice")),
sudo: penpal_runtime::SudoConfig { key: Some(PenpalSudoAccount::get()) },
assets: penpal_runtime::AssetsConfig {
assets: vec![(
penpal_runtime::xcm_config::TELEPORTABLE_ASSET_ID,
PenpalAssetOwner::get(),
false,
ED,
)],
..Default::default()
},
foreign_assets: penpal_runtime::ForeignAssetsConfig {
assets: vec![
// Relay Native asset representation
(RelayLocation::get(), PenpalAssetOwner::get(), true, ED),
// Sufficient AssetHub asset representation
(LocalReservableFromAssetHub::get(), PenpalAssetOwner::get(), true, ED),
// USDT from AssetHub
(UsdtFromAssetHub::get(), PenpalAssetOwner::get(), true, USDT_ED),
],
..Default::default()
},
..Default::default()
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ decl_test_parachains! {
PolkadotXcm: penpal_runtime::PolkadotXcm,
Assets: penpal_runtime::Assets,
ForeignAssets: penpal_runtime::ForeignAssets,
AssetConversion: penpal_runtime::AssetConversion,
Balances: penpal_runtime::Balances,
}
},
Expand All @@ -82,6 +83,7 @@ decl_test_parachains! {
PolkadotXcm: penpal_runtime::PolkadotXcm,
Assets: penpal_runtime::Assets,
ForeignAssets: penpal_runtime::ForeignAssets,
AssetConversion: penpal_runtime::AssetConversion,
Balances: penpal_runtime::Balances,
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ pub fn genesis() -> Storage {
)
})
.collect::<Vec<_>>(),
..Default::default()
},
staking: paseo_runtime::StakingConfig {
validator_count: validators::initial_authorities().len() as u32,
Expand Down
1 change: 0 additions & 1 deletion integration-tests/emulated/helpers/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ pub use xcm_emulator::Chain;
/// TODO: when bumping to polkadot-sdk v1.8.0,
/// remove this crate altogether and get the macros from `emulated-integration-tests-common`.
/// TODO: backport this macros to paseo-sdk

#[macro_export]
macro_rules! test_relay_is_trusted_teleporter {
( $sender_relay:ty, $sender_xcm_config:ty, vec![$( $receiver_para:ty ),+], ($assets:expr, $amount:expr) ) => {
Expand Down
Loading