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

Kusama People Chain #217

Merged
merged 23 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/integration-tests-matrix.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,9 @@
{
"name": "bridge-hub-polkadot",
"package": "bridge-hub-polkadot-integration-tests"
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also this needs to be added to the runtimes-matrix.json - for running tests/check-migrations...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed here: #245

{
"name": "people-kusama",
"package": "people-kusama-integration-tests"
}
]
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Refund any leases that are not migrated to Coretime (have holes in them/have not yet started) ([polkadot-fellows/runtimes#206](https://github.com/polkadot-fellows/runtimes/pull/206))
- Enable Elastic Scaling node side feature for Kusama ([polkadot-fellows/runtimes#205](https://github.com/polkadot-fellows/runtimes/pull/205))
- Cancel Parachain Auctions ([polkadot-fellows/runtimes#215](https://github.com/polkadot-fellows/runtimes/pull/215))
- Add Kusama People Chain ([polkadot-fellows/runtimes#217](https://github.com/polkadot-fellows/runtimes/pull/217))

### Changed

Expand Down
101 changes: 101 additions & 0 deletions Cargo.lock

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

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@ members = [
"system-parachains/constants",
"system-parachains/encointer",
"system-parachains/gluttons/glutton-kusama",
"system-parachains/people/people-kusama",
"integration-tests/emulated/chains/relays/kusama",
"integration-tests/emulated/chains/relays/polkadot",
"integration-tests/emulated/chains/parachains/assets/asset-hub-kusama",
"integration-tests/emulated/chains/parachains/assets/asset-hub-polkadot",
"integration-tests/emulated/chains/parachains/bridges/bridge-hub-kusama",
"integration-tests/emulated/chains/parachains/bridges/bridge-hub-polkadot",
"integration-tests/emulated/chains/parachains/collectives/collectives-polkadot",
"integration-tests/emulated/chains/parachains/people/people-kusama",
"integration-tests/emulated/chains/parachains/testing/penpal",
"integration-tests/emulated/helpers",
"integration-tests/emulated/networks/kusama-system",
Expand All @@ -42,6 +44,7 @@ members = [
"integration-tests/emulated/tests/assets/asset-hub-polkadot",
"integration-tests/emulated/tests/bridges/bridge-hub-kusama",
"integration-tests/emulated/tests/bridges/bridge-hub-polkadot",
"integration-tests/emulated/tests/people/people-kusama",
]

[profile.release]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[package]
name = "people-kusama-emulated-chain"
authors.workspace = true
edition.workspace = true
version.workspace = true
license = "Apache-2.0"
description = "People Kusama emulated chain used for integration tests"
publish = false

[dependencies]

# Substrate
sp-core = { version = "29.0.0" }
frame-support = { version = "29.0.0" }

# Cumulus
parachains-common = { version = "8.0.0" }
cumulus-primitives-core = { version = "0.8.0" }
emulated-integration-tests-common = { version = "4.0.0" }

# Local
people-kusama-runtime = { path = "../../../../../../system-parachains/people/people-kusama" }
kusama-emulated-chain = { path = "../../../relays/kusama" }
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// 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 cumulus_primitives_core::ParaId;
use emulated_integration_tests_common::{build_genesis_storage, collators, SAFE_XCM_VERSION};
use parachains_common::Balance;

pub const PARA_ID: u32 = 1004;
pub const ED: Balance = people_kusama_runtime::ExistentialDeposit::get();

pub fn genesis() -> Storage {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can the genesis storage not be produced by the runtime?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure, @NachoPal ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general it should be possible to do: RuntimeGenesis::default().build() to populate externality storage with the genesis values.
But as i see we have this copy&pasted in all runtimes, so maybe can keep this for a future follow-up to clean them all.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's some refactoring and improvement from @michalkucharczyk in polkadot-sdk on genesis config, maybe he has an opinion on how this can be done best with minimal copy+pasta.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not very familiar with this part of code. But if I understand correctly this function is later used for some integration tests. So it is not strictly runtime function, just a testing helper?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When it comes to duplication: If the set of customized fields in genesis config is the same for every runtime/test then we could use single json patch and use GenesisBuilder runtime API to build the storage. But this approach would also require that serialization format is exactly the same for every runtime (e.g. SessionKeys).

However json-patch approach may slow down execution of the tests (this concern was raised by @NachoPal if I recall correctly) - as we need to execute a runtime call to get the state.

let genesis_config = people_kusama_runtime::RuntimeGenesisConfig {
system: people_kusama_runtime::SystemConfig::default(),
parachain_info: people_kusama_runtime::ParachainInfoConfig {
parachain_id: ParaId::from(PARA_ID),
..Default::default()
},
collator_selection: people_kusama_runtime::CollatorSelectionConfig {
invulnerables: collators::invulnerables().iter().cloned().map(|(acc, _)| acc).collect(),
candidacy_bond: ED * 16,
..Default::default()
},
session: people_kusama_runtime::SessionConfig {
keys: collators::invulnerables()
.into_iter()
.map(|(acc, aura)| {
(
acc.clone(), // account id
acc, // validator id
people_kusama_runtime::SessionKeys { aura }, // session keys
)
})
.collect(),
},
polkadot_xcm: people_kusama_runtime::PolkadotXcmConfig {
safe_xcm_version: Some(SAFE_XCM_VERSION),
..Default::default()
},
..Default::default()
};

build_genesis_storage(
&genesis_config,
people_kusama_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,
};

// PeopleKusama Parachain declaration
decl_test_parachains! {
pub struct PeopleKusama {
genesis = genesis::genesis(),
on_init = {
people_kusama_runtime::AuraExt::on_initialize(1);
},
runtime = people_kusama_runtime,
core = {
XcmpMessageHandler: people_kusama_runtime::XcmpQueue,
LocationToAccountId: people_kusama_runtime::xcm_config::LocationToAccountId,
ParachainInfo: people_kusama_runtime::ParachainInfo,
MessageOrigin: cumulus_primitives_core::AggregateMessageOrigin,
},
pallets = {
PolkadotXcm: people_kusama_runtime::PolkadotXcm,
Balances: people_kusama_runtime::Balances,
Identity: people_kusama_runtime::Identity,
IdentityMigrator: people_kusama_runtime::IdentityMigrator,
}
},
}

// PeopleKusama implementation
impl_accounts_helpers_for_parachain!(PeopleKusama);
impl_assert_events_helpers_for_parachain!(PeopleKusama);
1 change: 1 addition & 0 deletions integration-tests/emulated/chains/relays/kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ decl_test_relay_chains! {
Balances: kusama_runtime::Balances,
Hrmp: kusama_runtime::Hrmp,
Identity: kusama_runtime::Identity,
IdentityMigrator: kusama_runtime::IdentityMigrator,
}
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ asset-hub-kusama-emulated-chain = { path = "../../chains/parachains/assets/asset
bridge-hub-kusama-emulated-chain = { path = "../../chains/parachains/bridges/bridge-hub-kusama" }
kusama-emulated-chain = { path = "../../chains/relays/kusama" }
penpal-emulated-chain = { path = "../../chains/parachains/testing/penpal" }
people-kusama-emulated-chain = { path = "../../chains/parachains/people/people-kusama" }
6 changes: 5 additions & 1 deletion integration-tests/emulated/networks/kusama-system/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ pub use asset_hub_kusama_emulated_chain;
pub use bridge_hub_kusama_emulated_chain;
pub use kusama_emulated_chain;
pub use penpal_emulated_chain;
pub use people_kusama_emulated_chain;

use asset_hub_kusama_emulated_chain::AssetHubKusama;
use bridge_hub_kusama_emulated_chain::BridgeHubKusama;
use kusama_emulated_chain::Kusama;
use penpal_emulated_chain::{PenpalA, PenpalB};
use people_kusama_emulated_chain::PeopleKusama;

// Cumulus
use emulated_integration_tests_common::{
Expand All @@ -37,6 +39,7 @@ decl_test_networks! {
BridgeHubKusama,
PenpalA,
PenpalB,
PeopleKusama,
],
bridge = ()
},
Expand All @@ -47,5 +50,6 @@ decl_test_sender_receiver_accounts_parameter_types! {
AssetHubKusamaPara { sender: ALICE, receiver: BOB },
BridgeHubKusamaPara { sender: ALICE, receiver: BOB },
PenpalAPara { sender: ALICE, receiver: BOB },
PenpalBPara { sender: ALICE, receiver: BOB }
PenpalBPara { sender: ALICE, receiver: BOB },
PeopleKusamaPara { sender: ALICE, receiver: BOB }
}
35 changes: 35 additions & 0 deletions integration-tests/emulated/tests/people/people-kusama/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[package]
name = "people-kusama-integration-tests"
version.workspace = true
authors.workspace = true
edition.workspace = true
license = "Apache-2.0"
description = "People Kusama runtime integration tests with xcm-emulator"
publish = false

[dependencies]
codec = { package = "parity-scale-codec", version = "3.6.9" }

# Substrate
sp-runtime = { version = "32.0.0" }
frame-support = { version = "29.0.0" }
pallet-balances = { version = "29.0.0" }
pallet-message-queue = { version = "32.0.0" }
pallet-identity = { version = "29.0.0" }

# Polkadot
polkadot-runtime-common = { version = "8.0.1" }
xcm = { package = "staging-xcm", version = "8.0.1" }
xcm-executor = { package = "staging-xcm-executor", default-features = false, version = "8.0.1" }

# Cumulus
parachains-common = { version = "8.0.0" }
emulated-integration-tests-common = { version = "4.0.0" }
asset-test-utils = { version = "8.0.1" }
cumulus-pallet-parachain-system = { features = ["parameterized-consensus-hook"], version = "0.8.1" }

# Local
kusama-runtime-constants = { path = "../../../../../relay/kusama/constants" }
kusama-runtime = { package = "staging-kusama-runtime", path = "../../../../../relay/kusama" }
people-kusama-runtime = { path = "../../../../../system-parachains/people/people-kusama" }
kusama-system-emulated-network = { path = "../../../networks/kusama-system" }
Loading
Loading