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: prepare mainnet runtime for registration #238

Merged
merged 8 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
contents: write
strategy:
matrix:
runtime: [ "devnet", "testnet" ]
runtime: [ "devnet", "testnet", "mainnet" ]
steps:
- name: Checkout sources
uses: actions/checkout@v4
Expand Down
76 changes: 76 additions & 0 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ members = [
"node",
"primitives",
"runtime/devnet",
"runtime/mainnet",
"runtime/testnet",
]

Expand Down Expand Up @@ -54,6 +55,7 @@ substrate-wasm-builder = "23.0.0"
pop-primitives = { path = "./primitives", default-features = false }
pop-runtime-common = { path = "runtime/common", default-features = false }
pop-runtime-devnet = { path = "runtime/devnet", default-features = true } # default-features=true required for `-p pop-node` builds
pop-runtime-mainnet = { path = "runtime/mainnet", 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

# Substrate
Expand Down
40 changes: 40 additions & 0 deletions networks/mainnet.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# pop up parachain -f ./tests/networks/pop.toml

[relaychain]
chain = "paseo-local"

[relaychain.runtime_genesis_patch.balances]
balances = [
# Pop sovereign account
["5Ec4AhPKXY9B4ayGshkz2wFMh7N8gP7XKfAvtt1cigpG9FkJ", 60000000000000000],
]

[[relaychain.nodes]]
name = "alice"
rpc_port = 8833
validator = true

[[relaychain.nodes]]
name = "bob"
validator = true

[[parachains]]
id = 4001
chain = "mainnet"
default_command = "./target/release/pop-node"

[parachains.genesis_overrides.balances]
balances = [
# Dev accounts
["5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY", 10000000000000000],
["5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty", 10000000000000000],
["5FLSigC9HGRKVhB9FiEo4Y3koPsNmBmLJbpXg2mp1hXcS59Y", 10000000000000000],
["5DAAnrj7VHTznn2AWBemMuyBwZWs6FNFjdyVXUeYum3PTXFy", 10000000000000000],
["5HGjWAeFDfFCWPsjFQdVV2Msvz2XtMktvgocEZcCj68kUMaw", 10000000000000000],
["5CiPPseXPECbkjWCa6MnjNokrgYjMqmKndv2rSnekmSK2DjL", 10000000000000000],
]

[[parachains.collators]]
name = "pop"
rpc_port = 9944
args = ["-lruntime::contracts=debug", "-lpopapi::extension=debug"]
3 changes: 3 additions & 0 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ serde_json.workspace = true
# Local
pop-runtime-common.workspace = true
pop-runtime-devnet.workspace = true
pop-runtime-mainnet.workspace = true
pop-runtime-testnet.workspace = true

# Substrate
Expand Down Expand Up @@ -89,13 +90,15 @@ runtime-benchmarks = [
"polkadot-primitives/runtime-benchmarks",
"pop-runtime-common/runtime-benchmarks",
"pop-runtime-devnet/runtime-benchmarks",
"pop-runtime-mainnet/runtime-benchmarks",
"pop-runtime-testnet/runtime-benchmarks",
"sc-service/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
]
try-runtime = [
"polkadot-cli/try-runtime",
"pop-runtime-devnet/try-runtime",
"pop-runtime-mainnet/try-runtime",
"pop-runtime-testnet/try-runtime",
"sp-runtime/try-runtime",
]
97 changes: 96 additions & 1 deletion node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,16 @@ pub type DevnetChainSpec = sc_service::GenericChainSpec<Extensions>;
/// Specialized `ChainSpec` for the testnet parachain runtime.
pub type TestnetChainSpec = sc_service::GenericChainSpec<Extensions>;

/// Specialized `ChainSpec` for the live parachain runtime.
pub type MainnetChainSpec = sc_service::GenericChainSpec<Extensions>;
evilrobot-01 marked this conversation as resolved.
Show resolved Hide resolved

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

pub(crate) enum Relay {
Paseo,
PaseoLocal,
Polkadot,
}

/// Helper function to generate a crypto pair from seed
Expand Down Expand Up @@ -74,24 +78,37 @@ pub fn pop_devnet_session_keys(keys: AuraId) -> pop_runtime_devnet::SessionKeys
pub fn pop_testnet_session_keys(keys: AuraId) -> pop_runtime_testnet::SessionKeys {
pop_runtime_testnet::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_mainnet_session_keys(keys: AuraId) -> pop_runtime_mainnet::SessionKeys {
pop_runtime_mainnet::SessionKeys { aura: keys }
}

fn configure_for_relay(
relay: Relay,
properties: &mut sc_chain_spec::Properties,
) -> (Extensions, u32) {
properties.insert("ss58Format".into(), 42.into());
let para_id;

match relay {
Relay::Paseo | Relay::PaseoLocal => {
para_id = 4001;
properties.insert("ss58Format".into(), 42.into());
properties.insert("tokenSymbol".into(), "PAS".into());
properties.insert("tokenDecimals".into(), 10.into());

let relay_chain =
if let Relay::Paseo = relay { "paseo".into() } else { "paseo-local".into() };
(Extensions { relay_chain, para_id }, para_id)
},
Relay::Polkadot => {
para_id = 3395;
properties.insert("ss58Format".into(), 0.into());
properties.insert("tokenSymbol".into(), "DOT".into());
properties.insert("tokenDecimals".into(), 10.into());
(Extensions { relay_chain: "polkadot".into(), para_id }, para_id)
},
}
}

Expand Down Expand Up @@ -173,6 +190,84 @@ pub fn testnet_config(relay: Relay) -> TestnetChainSpec {
.build()
}

pub fn mainnet_config(relay: Relay) -> MainnetChainSpec {
let mut properties = sc_chain_spec::Properties::new();
let (extensions, para_id) = configure_for_relay(relay, &mut properties);

let collator_0_account_id: AccountId =
AccountId::from_ss58check("15B6eUkXgoLA3dWruCRYWeBGNC8SCwuqiMtMTM1Zh2auSg3w").unwrap();
let collator_0_aura_id: AuraId =
AuraId::from_ss58check("15B6eUkXgoLA3dWruCRYWeBGNC8SCwuqiMtMTM1Zh2auSg3w").unwrap();

// Multisig account for sudo, generated from the following signatories:
peterwht marked this conversation as resolved.
Show resolved Hide resolved
// - 15VPagCVayS6XvT5RogPYop3BJTJzwqR2mCGR1kVn3w58ygg
// - 142zako1kfvrpQ7pJKYR8iGUD58i4wjb78FUsmJ9WcXmkM5z
// - 15k9niqckMg338cFBoz9vWFGwnCtwPBquKvqJEfHApijZkDz
// - 14G3CUFnZUBnHZUhahexSZ6AgemaW9zMHBnGccy3df7actf4
// - Threshold 2
let sudo_account_id: AccountId =
AccountId::from_ss58check("15NMV2JX1NeMwarQiiZvuJ8ixUcvayFDcu1F9Wz1HNpSc8gP").unwrap();

#[allow(deprecated)]
MainnetChainSpec::builder(
pop_runtime_mainnet::WASM_BINARY.expect("WASM binary was not built, please build it!"),
extensions,
)
.with_name("Pop Network")
.with_id("pop")
.with_chain_type(ChainType::Live)
.with_genesis_config_patch(mainnet_genesis(
// initial collators.
vec![
// POP COLLATOR 0
(collator_0_account_id, collator_0_aura_id),
],
sudo_account_id,
para_id.into(),
))
.with_protocol_id("pop")
.with_properties(properties)
.build()
}

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

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

fn testnet_genesis(
invulnerables: Vec<(AccountId, AuraId)>,
root: AccountId,
Expand Down
Loading
Loading