Skip to content

Commit

Permalink
Merge pull request #52 from r0gue-io/frank/feat-separate-runtimes
Browse files Browse the repository at this point in the history
refactor: separate runtimes
  • Loading branch information
al3mart authored Mar 27, 2024
2 parents e585fb4 + 587e52e commit 6293ce8
Show file tree
Hide file tree
Showing 10 changed files with 246 additions and 272 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ edition = "2021"
homepage = "https://r0gue.io"
license = "Unlicense"
repository = "https://github.com/r0gue-io/pop-node/"
description = "Pop Network makes it easy for smart contract developers to use the Power of Polkadot."

[workspace]
members = [
Expand Down
25 changes: 13 additions & 12 deletions integration-tests/src/chains/pop_network/genesis.rs
Original file line number Diff line number Diff line change
@@ -1,37 +1,38 @@
use emulated_integration_tests_common::{build_genesis_storage, collators};
use pop_runtime_common::Balance;
use pop_runtime_devnet as runtime;
use sp_core::storage::Storage;

pub(crate) const ED: Balance = pop_runtime_devnet::EXISTENTIAL_DEPOSIT;
pub(crate) const ED: Balance = runtime::EXISTENTIAL_DEPOSIT;
const PARA_ID: u32 = 9090;
const SAFE_XCM_VERSION: u32 = xcm::prelude::XCM_VERSION;

pub(crate) fn genesis() -> Storage {
let genesis_config = pop_runtime_devnet::RuntimeGenesisConfig {
system: pop_runtime_devnet::SystemConfig::default(),
balances: pop_runtime_devnet::BalancesConfig { ..Default::default() },
parachain_info: pop_runtime_devnet::ParachainInfoConfig {
let genesis_config = runtime::RuntimeGenesisConfig {
system: runtime::SystemConfig::default(),
balances: runtime::BalancesConfig { ..Default::default() },
parachain_info: runtime::ParachainInfoConfig {
parachain_id: PARA_ID.into(),
..Default::default()
},
collator_selection: pop_runtime_devnet::CollatorSelectionConfig {
collator_selection: runtime::CollatorSelectionConfig {
invulnerables: collators::invulnerables().iter().cloned().map(|(acc, _)| acc).collect(),
candidacy_bond: ED * 16,
..Default::default()
},
session: pop_runtime_devnet::SessionConfig {
session: runtime::SessionConfig {
keys: collators::invulnerables()
.into_iter()
.map(|(acc, aura)| {
(
acc.clone(), // account id
acc, // validator id
pop_runtime_devnet::SessionKeys { aura }, // session keys
acc.clone(), // account id
acc, // validator id
runtime::SessionKeys { aura }, // session keys
)
})
.collect(),
},
polkadot_xcm: pop_runtime_devnet::PolkadotXcmConfig {
polkadot_xcm: runtime::PolkadotXcmConfig {
safe_xcm_version: Some(SAFE_XCM_VERSION),
..Default::default()
},
Expand All @@ -40,6 +41,6 @@ pub(crate) fn genesis() -> Storage {

build_genesis_storage(
&genesis_config,
pop_runtime_devnet::WASM_BINARY.expect("WASM binary was not built, please build it!"),
runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"),
)
}
7 changes: 4 additions & 3 deletions integration-tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use frame_support::{
};
use polkadot_runtime_parachains::assigner_on_demand;
use pop_runtime_common::Balance;
use pop_runtime_devnet as pop_runtime;
use pop_runtime_devnet::xcm_config::XcmConfig as PopNetworkXcmConfig;
use rococo_runtime::xcm_config::XcmConfig as RococoXcmConfig;
use sp_core::Encode;
Expand Down Expand Up @@ -488,15 +489,15 @@ fn place_coretime_spot_order_from_para_to_relay() {
let beneficiary: sp_runtime::AccountId32 = [1u8; 32].into();

// Setup: reserve transfer from relay to Pop, so that sovereign account accurate for return transfer
let amount_to_send: Balance = pop_runtime_devnet::UNIT * 1000;
let amount_to_send: Balance = pop_runtime::UNIT * 1000;
fund_pop_from_relay(RococoRelaySender::get(), amount_to_send, beneficiary.clone());

let message = {
let assets: Asset = (Here, 10 * pop_runtime_devnet::UNIT).into();
let assets: Asset = (Here, 10 * pop_runtime::UNIT).into();
let beneficiary = AccountId32 { id: beneficiary.clone().into(), network: None }.into();
let spot_order = <RococoRelay as Chain>::RuntimeCall::OnDemandAssignmentProvider(
assigner_on_demand::Call::<<RococoRelay as Chain>::Runtime>::place_order_keep_alive {
max_amount: 1 * pop_runtime_devnet::UNIT,
max_amount: 1 * pop_runtime::UNIT,
para_id: AssetHubRococoPara::para_id().into(),
},
);
Expand Down
148 changes: 74 additions & 74 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,101 +1,101 @@
[package]
name = "pop-node"
version = "0.1.0"
authors = { workspace = true }
description = "A new Cumulus FRAME-based Substrate Node, ready for hacking together a parachain."
authors.workspace = true
description.workspace = true
license = "Unlicense"
homepage = { workspace = true }
homepage.workspace = true
repository.workspace = true
edition.workspace = true
build = "build.rs"
publish = false

[dependencies]
clap = { workspace = true }
log = { workspace = true }
codec = { workspace = true }
serde = { workspace = true }
jsonrpsee = { workspace = true }
futures = { workspace = true }
serde_json = { workspace = true }
clap.workspace = true
log.workspace = true
codec.workspace = true
serde.workspace = true
jsonrpsee.workspace = true
futures.workspace = true
serde_json.workspace = true

# Local
pop-runtime-devnet = { workspace = true }
pop-runtime-testnet = { workspace = true }
pop-runtime-common = { workspace = true }
pop-runtime-devnet.workspace = true
pop-runtime-testnet.workspace = true
pop-runtime-common.workspace = true

# Substrate
frame-benchmarking = { workspace = true }
frame-benchmarking-cli = { workspace = true }
pallet-transaction-payment-rpc = { workspace = true }
sc-basic-authorship = { workspace = true }
sc-chain-spec = { workspace = true }
sc-cli = { workspace = true }
sc-client-api = { workspace = true }
sc-offchain = { workspace = true }
sc-consensus = { workspace = true }
sc-executor = { workspace = true }
sc-network = { workspace = true }
sc-network-sync = { workspace = true }
sc-rpc = { workspace = true }
sc-service = { workspace = true }
sc-sysinfo = { workspace = true }
sc-telemetry = { workspace = true }
sc-tracing = { workspace = true }
sc-transaction-pool = { workspace = true }
sc-transaction-pool-api = { workspace = true }
sp-api = { workspace = true }
sp-block-builder = { workspace = true }
sp-blockchain = { workspace = true }
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 }
frame-benchmarking.workspace = true
frame-benchmarking-cli.workspace = true
pallet-transaction-payment-rpc.workspace = true
sc-basic-authorship.workspace = true
sc-chain-spec.workspace = true
sc-cli.workspace = true
sc-client-api.workspace = true
sc-offchain.workspace = true
sc-consensus.workspace = true
sc-executor.workspace = true
sc-network.workspace = true
sc-network-sync.workspace = true
sc-rpc.workspace = true
sc-service.workspace = true
sc-sysinfo.workspace = true
sc-telemetry.workspace = true
sc-tracing.workspace = true
sc-transaction-pool.workspace = true
sc-transaction-pool-api.workspace = true
sp-api.workspace = true
sp-block-builder.workspace = true
sp-blockchain.workspace = true
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

# Polkadot
polkadot-cli = { workspace = true }
polkadot-primitives = { workspace = true }
xcm = { workspace = true }
polkadot-cli.workspace = true
polkadot-primitives.workspace = true
xcm.workspace = true

# Cumulus
cumulus-client-cli = { workspace = true }
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 }
cumulus-relay-chain-interface = { workspace = true }
color-print = { workspace = true }
cumulus-client-cli.workspace = true
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
cumulus-relay-chain-interface.workspace = true
color-print.workspace = true

[build-dependencies]
substrate-build-script-utils = { workspace = true }
substrate-build-script-utils.workspace = true

[features]
default = []
runtime-benchmarks = [
"cumulus-primitives-core/runtime-benchmarks",
"frame-benchmarking-cli/runtime-benchmarks",
"frame-benchmarking/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",
"cumulus-primitives-core/runtime-benchmarks",
"frame-benchmarking-cli/runtime-benchmarks",
"frame-benchmarking/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-devnet/try-runtime",
"pop-runtime-testnet/try-runtime",
"polkadot-cli/try-runtime",
"sp-runtime/try-runtime",
"pop-runtime-devnet/try-runtime",
"pop-runtime-testnet/try-runtime",
"polkadot-cli/try-runtime",
"sp-runtime/try-runtime",
]
34 changes: 8 additions & 26 deletions node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ pub type TestnetChainSpec =
/// The default XCM version to set in genesis config.
const SAFE_XCM_VERSION: u32 = xcm::prelude::XCM_VERSION;
pub(crate) enum Relay {
ROCOCO,
PASEO,
ROCOCOLOCAL,
PASEOLOCAL,
Rococo,
Paseo,
RococoLocal,
PaseoLocal,
}

/// Helper function to generate a crypto pair from seed
Expand Down Expand Up @@ -86,29 +86,29 @@ fn configure_for_relay(

match relay {
// Test relay chains
Relay::ROCOCO => {
Relay::Rococo => {
para_id = 4385;
properties.insert("tokenSymbol".into(), "ROC".into());
properties.insert("tokenDecimals".into(), 12.into());

(Extensions { relay_chain: "rococo".into(), para_id }, para_id)
},
Relay::PASEO => {
Relay::Paseo => {
para_id = 4001;
properties.insert("tokenSymbol".into(), "PAS".into());
properties.insert("tokenDecimals".into(), 10.into());

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

(Extensions { relay_chain: "rococo-local".into(), para_id }, para_id)
},
Relay::PASEOLOCAL => {
Relay::PaseoLocal => {
para_id = 4001;
properties.insert("tokenSymbol".into(), "PAS".into());
properties.insert("tokenDecimals".into(), 10.into());
Expand Down Expand Up @@ -142,20 +142,6 @@ pub fn development_config(relay: Relay) -> DevnetChainSpec {
get_collator_keys_from_seed("Bob"),
),
],
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"),
],
get_account_id_from_seed::<sr25519::Public>("Alice"),
para_id.into(),
))
Expand Down Expand Up @@ -238,16 +224,12 @@ fn testnet_genesis(

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<_>>(),
},
"parachainInfo": {
"parachainId": id,
},
Expand Down
Loading

0 comments on commit 6293ce8

Please sign in to comment.