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

feat: separate runtimes #46

Merged
merged 24 commits into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
736eae4
feat(pop-network): ready for testnet
al3mart Mar 22, 2024
5bd7c95
fix(pop-network): address feedback
al3mart Mar 23, 2024
c785630
chore(pop-network): fmt
al3mart Mar 23, 2024
188f2aa
chore(pop-network): rebase & conflicts
al3mart Mar 23, 2024
35c9476
chore(pop-network): update cargo lock
al3mart Mar 23, 2024
90206a9
chore(pop-network): runtime descriptions and FilteredCalls
al3mart Mar 25, 2024
0a375be
chroe(pop-network): complete relay naming
al3mart Mar 25, 2024
5311bec
chore(pop-network): feature-gate async backing
al3mart Mar 25, 2024
5134708
typo(pop-network): wrong feature name
al3mart Mar 25, 2024
bc708a8
chore(pop-network): relay_chain_slot_time is always 6000
al3mart Mar 25, 2024
c1516ad
chrose(pop-network): paseo feature works properly
al3mart Mar 26, 2024
f60d7a3
chore(pop-network): fmt
al3mart Mar 26, 2024
343b88e
fix(pop-network): rococo genesis doesn't depend on pop-runtime
al3mart Mar 26, 2024
c415908
fix(pop-network): Make CI happy
al3mart Mar 26, 2024
c196eeb
fix(pop-network): missing contruct_benchmark_partials
al3mart Mar 26, 2024
a1b3e23
chrone(pop-network): fix fmt
al3mart Mar 26, 2024
e585fb4
chore(pop-network): typo
al3mart Mar 26, 2024
e29df66
refactor(integration-tests): simplify runtime imports
evilrobot-01 Mar 26, 2024
cfef5f8
refactor(node): fix clippy warnings
evilrobot-01 Mar 26, 2024
40c21b1
fix(chain-spec): remove endowments
evilrobot-01 Mar 26, 2024
3ead157
refactor: remove unnecessary default runtime
evilrobot-01 Mar 26, 2024
494a569
refactor: simplify manifests
evilrobot-01 Mar 26, 2024
587e52e
docs(runtime): remove old link
evilrobot-01 Mar 26, 2024
6293ce8
Merge pull request #52 from r0gue-io/frank/feat-separate-runtimes
al3mart Mar 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ repository = "https://github.com/r0gue-io/pop-node/"
[workspace]
members = [
"node",
"runtime",
"runtime/devnet",
"runtime/testnet",
"integration-tests",
"primitives",
]
Expand Down Expand Up @@ -39,7 +40,9 @@ 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", default-features = true } # default-features=true required for `-p pop-node` builds
pop-runtime-devnet = { path = "runtime/devnet", default-features = true } # default-features=true required for `-p pop-node` builds
pop-runtime-testnet = { path = "runtime/testnet", default-features = true } # default-features=true required for `-p pop-node` builds
pop-runtime-common = { path = "runtime/common", default-features = false }
pop-primitives = { path = "./primitives", default-features = false }

# Substrate
Expand Down Expand Up @@ -143,4 +146,4 @@ cumulus-client-collator = { git = "https://github.com/paritytech/polkadot-sdk",
cumulus-client-consensus-aura = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1" }
cumulus-client-consensus-common = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1" }
cumulus-client-consensus-proposer = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1" }
cumulus-client-service = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1" }
cumulus-client-service = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1" }
15 changes: 10 additions & 5 deletions integration-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ cumulus-primitives-core.workspace = true
emulated-integration-tests-common.workspace = true

# Local
pop-runtime.workspace = true
pop-runtime-devnet.workspace = true
pop-runtime-testnet.workspace = true
evilrobot-01 marked this conversation as resolved.
Show resolved Hide resolved
pop-runtime-common.workspace = true

[features]
default = ["std"]
Expand All @@ -52,7 +54,8 @@ std = [
"pallet-xcm/std",
"polkadot-primitives/std",
"polkadot-runtime-parachains/std",
"pop-runtime/std",
"pop-runtime-devnet/std",
"pop-runtime-testnet/std",
"rococo-runtime-constants/std",
"rococo-runtime/std",
"sp-authority-discovery/std",
Expand All @@ -73,7 +76,8 @@ runtime-benchmarks = [
"pallet-balances/runtime-benchmarks",
"pallet-message-queue/runtime-benchmarks",
"polkadot-primitives/runtime-benchmarks",
"pop-runtime/runtime-benchmarks",
"pop-runtime-devnet/runtime-benchmarks",
"pop-runtime-testnet/runtime-benchmarks",
"rococo-runtime/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"xcm-executor/runtime-benchmarks",
Expand All @@ -85,7 +89,8 @@ try-runtime = [
"pallet-assets/try-runtime",
"pallet-balances/std",
"pallet-message-queue/try-runtime",
"pop-runtime/try-runtime",
"pop-runtime-devnet/try-runtime",
"pop-runtime-testnet/try-runtime",
"rococo-runtime/try-runtime",
"sp-runtime/try-runtime",
]
]
14 changes: 11 additions & 3 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ futures = { workspace = true }
serde_json = { workspace = true }

# Local
pop-runtime = { workspace = true }
pop-runtime-devnet = { workspace = true }
evilrobot-01 marked this conversation as resolved.
Show resolved Hide resolved
pop-runtime-testnet = { workspace = true }
pop-runtime-common = { workspace = true }

# Substrate
frame-benchmarking = { workspace = true }
Expand Down Expand Up @@ -49,8 +51,11 @@ sp-consensus-aura = { workspace = true }
sp-core = { workspace = true }
sp-keystore = { workspace = true }
sp-io = { workspace = true }
sp-offchain = { workspace = true }
sp-runtime = { workspace = true }
sp-session = { workspace = true }
sp-timestamp = { workspace = true }
sp-transaction-pool = { workspace = true }
substrate-frame-rpc-system = { workspace = true }
substrate-prometheus-endpoint = { workspace = true }

Expand All @@ -65,6 +70,7 @@ cumulus-client-collator = { workspace = true }
cumulus-client-consensus-aura = { workspace = true }
cumulus-client-consensus-common = { workspace = true }
cumulus-client-consensus-proposer = { workspace = true }
cumulus-primitives-aura = { workspace = true }
cumulus-client-service = { workspace = true }
cumulus-primitives-core = { workspace = true }
cumulus-primitives-parachain-inherent = { workspace = true }
Expand All @@ -80,14 +86,16 @@ runtime-benchmarks = [
"cumulus-primitives-core/runtime-benchmarks",
"frame-benchmarking-cli/runtime-benchmarks",
"frame-benchmarking/runtime-benchmarks",
"pop-runtime/runtime-benchmarks",
"pop-runtime-devnet/runtime-benchmarks",
"pop-runtime-testnet/runtime-benchmarks",
"polkadot-cli/runtime-benchmarks",
"polkadot-primitives/runtime-benchmarks",
"sc-service/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
]
try-runtime = [
"pop-runtime/try-runtime",
"pop-runtime-devnet/try-runtime",
"pop-runtime-testnet/try-runtime",
"polkadot-cli/try-runtime",
"sp-runtime/try-runtime",
]
73 changes: 73 additions & 0 deletions node/chain_specs/pop-paseo.plain.json

Large diffs are not rendered by default.

73 changes: 73 additions & 0 deletions node/chain_specs/pop-paseo.raw.json

Large diffs are not rendered by default.

73 changes: 73 additions & 0 deletions node/chain_specs/pop-rococo.plain.json
evilrobot-01 marked this conversation as resolved.
Show resolved Hide resolved

Large diffs are not rendered by default.

74 changes: 74 additions & 0 deletions node/chain_specs/pop-rococo.raw.json

Large diffs are not rendered by default.

198 changes: 139 additions & 59 deletions node/src/chain_spec.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
use cumulus_primitives_core::ParaId;
use pop_runtime::{AccountId, AuraId, Signature, EXISTENTIAL_DEPOSIT};
use pop_runtime_common::{AccountId, AuraId, Signature};
use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup};
use sc_service::ChainType;
use serde::{Deserialize, Serialize};
use sp_core::{sr25519, Pair, Public};
use sp_core::{crypto::Ss58Codec, sr25519, Pair, Public};
use sp_runtime::traits::{IdentifyAccount, Verify};

/// Specialized `ChainSpec` for the normal parachain runtime.
pub type ChainSpec = sc_service::GenericChainSpec<(), Extensions>;
/// Specialized `ChainSpec` for the development parachain runtime.
pub type DevnetChainSpec =
sc_service::GenericChainSpec<pop_runtime_devnet::RuntimeGenesisConfig, Extensions>;

/// Specialized `ChainSpec` for the testnet parachain runtime.
pub type TestnetChainSpec =
sc_service::GenericChainSpec<pop_runtime_testnet::RuntimeGenesisConfig, Extensions>;

/// The default XCM version to set in genesis config.
const SAFE_XCM_VERSION: u32 = xcm::prelude::XCM_VERSION;

/// The local para ID of Pop Network.
const PARA_ID: u32 = 9090;
pub(crate) enum Relay {
ROC,
evilrobot-01 marked this conversation as resolved.
Show resolved Hide resolved
PAS,
ROCLOCAL,
PASLOCAL,
}

/// Helper function to generate a crypto pair from seed
pub fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public {
Expand Down Expand Up @@ -59,29 +67,67 @@ where
/// Generate the session keys from individual elements.
///
/// The input must be a tuple of individual keys (a single arg for now since we have just one key).
pub fn pop_session_keys(keys: AuraId) -> pop_runtime::SessionKeys {
pop_runtime::SessionKeys { aura: keys }
pub fn pop_devnet_session_keys(keys: AuraId) -> pop_runtime_devnet::SessionKeys {
pop_runtime_devnet::SessionKeys { aura: keys }
}
/// Generate the session keys from individual elements.
///
/// The input must be a tuple of individual keys (a single arg for now since we have just one key).
pub fn pop_testnet_session_keys(keys: AuraId) -> pop_runtime_testnet::SessionKeys {
pop_runtime_testnet::SessionKeys { aura: keys }
}

pub fn development_config() -> ChainSpec {
// Give your base currency a unit name and decimal places
let mut properties = sc_chain_spec::Properties::new();
properties.insert("tokenSymbol".into(), "UNIT".into());
properties.insert("tokenDecimals".into(), 12.into());
fn configure_for_relay(
relay: Relay,
properties: &mut sc_chain_spec::Properties,
) -> (Extensions, u32) {
properties.insert("tokenSymbol".into(), "POP".into());
al3mart marked this conversation as resolved.
Show resolved Hide resolved
properties.insert("ss58Format".into(), 42.into());
let para_id;

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,
match relay {
// Test relay chains
Relay::ROC => {
para_id = 4385;
properties.insert("tokenDecimals".into(), 12.into());

(Extensions { relay_chain: "rococo".into(), para_id }, para_id)
},
Relay::PAS => {
para_id = 4001;
properties.insert("tokenDecimals".into(), 10.into());
evilrobot-01 marked this conversation as resolved.
Show resolved Hide resolved

(Extensions { relay_chain: "paseo".into(), para_id }, para_id)
},
// Local relay chains
Relay::ROCLOCAL => {
para_id = 4385;
properties.insert("tokenDecimals".into(), 12.into());

(Extensions { relay_chain: "rococo-local".into(), para_id }, para_id)
},
Relay::PASLOCAL => {
para_id = 4001;
properties.insert("tokenDecimals".into(), 10.into());

(Extensions { relay_chain: "paseo-local".into(), para_id }, para_id)
},
}
}

pub fn development_config(relay: Relay) -> DevnetChainSpec {
// Give your base currency a unit name and decimal places
let mut properties = sc_chain_spec::Properties::new();
let (extensions, para_id) = configure_for_relay(relay, &mut properties);

DevnetChainSpec::builder(
pop_runtime_devnet::WASM_BINARY.expect("WASM binary was not built, please build it!"),
extensions,
)
.with_name("Pop Network Development")
.with_id("pop-dev")
.with_chain_type(ChainType::Development)
.with_genesis_config_patch(testnet_genesis(
.with_genesis_config_patch(devnet_genesis(
// initial collators.
vec![
(
Expand All @@ -108,60 +154,54 @@ pub fn development_config() -> ChainSpec {
get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),
],
get_account_id_from_seed::<sr25519::Public>("Alice"),
PARA_ID.into(),
para_id.into(),
))
.build()
}

pub fn local_testnet_config() -> ChainSpec {
pub fn testnet_config(relay: Relay) -> TestnetChainSpec {
// Give your base currency a unit name and decimal places
let mut properties = sc_chain_spec::Properties::new();
properties.insert("tokenSymbol".into(), "UNIT".into());
properties.insert("tokenDecimals".into(), 12.into());
properties.insert("ss58Format".into(), 42.into());
let (extensions, para_id) = configure_for_relay(relay, &mut properties);

let collator_0_account_id: AccountId =
AccountId::from_ss58check("5Gn9dVgCNUYtC5JVMBheQQv2x6Lpg5sAMcQVRupG1s3tP2gR").unwrap();
let collator_0_aura_id: AuraId =
AuraId::from_ss58check("5Gn9dVgCNUYtC5JVMBheQQv2x6Lpg5sAMcQVRupG1s3tP2gR").unwrap();
let collator_1_account_id: AccountId =
AccountId::from_ss58check("5FyVvcSvSXCkBwvBEHkUh1VWGGrwaR3zbYBkU3Rc5DqV75S4").unwrap();
let collator_1_aura_id: AuraId =
AuraId::from_ss58check("5FyVvcSvSXCkBwvBEHkUh1VWGGrwaR3zbYBkU3Rc5DqV75S4").unwrap();
let sudo_account_id: AccountId =
AccountId::from_ss58check("5FPL3ZLqUk6MyBoZrQZ1Co29WAteX6T6N68TZ6jitHvhpyuD").unwrap();

#[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,
},
TestnetChainSpec::builder(
pop_runtime_devnet::WASM_BINARY.expect("WASM binary was not built, please build it!"),
extensions,
)
.with_name("Pop Network Local Testnet")
.with_id("pop-local")
.with_name("Pop Network Testnet")
.with_id("pop-testnet")
.with_chain_type(ChainType::Local)
.with_genesis_config_patch(testnet_genesis(
// initial collators.
vec![
(
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_collator_keys_from_seed("Alice"),
),
(
get_account_id_from_seed::<sr25519::Public>("Bob"),
get_collator_keys_from_seed("Bob"),
),
// POP COLLATOR 0
(collator_0_account_id.clone(), collator_0_aura_id),
// POP COLLATOR 1
(collator_1_account_id.clone(), collator_1_aura_id),
],
vec![
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_account_id_from_seed::<sr25519::Public>("Bob"),
get_account_id_from_seed::<sr25519::Public>("Charlie"),
get_account_id_from_seed::<sr25519::Public>("Dave"),
get_account_id_from_seed::<sr25519::Public>("Eve"),
get_account_id_from_seed::<sr25519::Public>("Ferdie"),
get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
get_account_id_from_seed::<sr25519::Public>("Charlie//stash"),
get_account_id_from_seed::<sr25519::Public>("Dave//stash"),
get_account_id_from_seed::<sr25519::Public>("Eve//stash"),
get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),
// Collator stashes
collator_0_account_id,
collator_1_account_id,
// SUDO account
sudo_account_id.clone(),
],
get_account_id_from_seed::<sr25519::Public>("Alice"),
PARA_ID.into(),
sudo_account_id,
para_id.into(),
))
.with_protocol_id("pop-local")
.with_protocol_id("pop-tesnet")
.with_properties(properties)
.build()
}
Expand All @@ -172,6 +212,46 @@ fn testnet_genesis(
root: AccountId,
id: ParaId,
) -> serde_json::Value {
use pop_runtime_testnet::EXISTENTIAL_DEPOSIT;

serde_json::json!({
"balances": {
"balances": endowed_accounts.iter().cloned().map(|k| (k, 1u64 << 60)).collect::<Vec<_>>(),
},
"parachainInfo": {
"parachainId": id,
},
"collatorSelection": {
"invulnerables": invulnerables.iter().cloned().map(|(acc, _)| acc).collect::<Vec<_>>(),
"candidacyBond": EXISTENTIAL_DEPOSIT * 16,
},
"session": {
"keys": invulnerables
.into_iter()
.map(|(acc, aura)| {
(
acc.clone(), // account id
acc, // validator id
pop_testnet_session_keys(aura), // session keys
)
})
.collect::<Vec<_>>(),
},
"polkadotXcm": {
"safeXcmVersion": Some(SAFE_XCM_VERSION),
},
"sudo": { "key": Some(root) }
})
}

fn devnet_genesis(
invulnerables: Vec<(AccountId, AuraId)>,
endowed_accounts: Vec<AccountId>,
root: AccountId,
id: ParaId,
) -> serde_json::Value {
use pop_runtime_devnet::EXISTENTIAL_DEPOSIT;

serde_json::json!({
"balances": {
"balances": endowed_accounts.iter().cloned().map(|k| (k, 1u64 << 60)).collect::<Vec<_>>(),
Expand All @@ -190,7 +270,7 @@ fn testnet_genesis(
(
acc.clone(), // account id
acc, // validator id
pop_session_keys(aura), // session keys
pop_devnet_session_keys(aura), // session keys
)
})
.collect::<Vec<_>>(),
Expand Down
Loading
Loading