Skip to content

Commit

Permalink
feat(mainnet): continue preparing mainnet runtime. (#239)
Browse files Browse the repository at this point in the history
Co-authored-by: Alejandro Martinez Andres <11448715+al3mart@users.noreply.github.com>
  • Loading branch information
peterwht and al3mart authored Aug 28, 2024
1 parent c7e2026 commit 62eb992
Show file tree
Hide file tree
Showing 21 changed files with 210 additions and 699 deletions.
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.

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

Expand Down Expand Up @@ -53,7 +53,7 @@ substrate-wasm-builder = "23.0.0"

# Local
pop-primitives = { path = "./primitives", default-features = false }
pop-runtime = { path = "runtime/live", default-features = true } # default-features=true required for `-p pop-node` builds
pop-runtime = { path = "runtime/mainnet", default-features = true } # default-features=true required for `-p pop-node` builds
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-testnet = { path = "runtime/testnet", default-features = true } # default-features=true required for `-p pop-node` builds
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"]
44 changes: 20 additions & 24 deletions node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub type DevnetChainSpec = sc_service::GenericChainSpec<Extensions>;
pub type TestnetChainSpec = sc_service::GenericChainSpec<Extensions>;

/// Specialized `ChainSpec` for the live parachain runtime.
pub type LiveChainSpec = sc_service::GenericChainSpec<Extensions>;
pub type MainnetChainSpec = sc_service::GenericChainSpec<Extensions>;

/// The default XCM version to set in genesis config.
const SAFE_XCM_VERSION: u32 = xcm::prelude::XCM_VERSION;
Expand Down Expand Up @@ -81,20 +81,20 @@ pub fn pop_testnet_session_keys(keys: AuraId) -> pop_runtime_testnet::SessionKey
/// 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_live_session_keys(keys: AuraId) -> pop_runtime::SessionKeys {
pub fn pop_mainnet_session_keys(keys: AuraId) -> pop_runtime::SessionKeys {
pop_runtime::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());

Expand All @@ -103,7 +103,8 @@ fn configure_for_relay(
(Extensions { relay_chain, para_id }, para_id)
},
Relay::Polkadot => {
para_id = 3456;
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 @@ -189,42 +190,37 @@ pub fn testnet_config(relay: Relay) -> TestnetChainSpec {
.build()
}

pub fn live_config(relay: Relay) -> LiveChainSpec {
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("5Gn9dVgCNUYtC5JVMBheQQv2x6Lpg5sAMcQVRupG1s3tP2gR").unwrap();
AccountId::from_ss58check("15B6eUkXgoLA3dWruCRYWeBGNC8SCwuqiMtMTM1Zh2auSg3w").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 collator_2_account_id: AccountId =
AccountId::from_ss58check("5GMqrQuWpyyBBK7LAWXR5psWvKc1QMqtiyasjp23VNKZWgh6").unwrap();
let collator_2_aura_id: AuraId =
AuraId::from_ss58check("5GMqrQuWpyyBBK7LAWXR5psWvKc1QMqtiyasjp23VNKZWgh6").unwrap();
AuraId::from_ss58check("15B6eUkXgoLA3dWruCRYWeBGNC8SCwuqiMtMTM1Zh2auSg3w").unwrap();

// Multisig account for sudo, generated from the following signatories:
// - 15VPagCVayS6XvT5RogPYop3BJTJzwqR2mCGR1kVn3w58ygg
// - 142zako1kfvrpQ7pJKYR8iGUD58i4wjb78FUsmJ9WcXmkM5z
// - 15k9niqckMg338cFBoz9vWFGwnCtwPBquKvqJEfHApijZkDz
// - 14G3CUFnZUBnHZUhahexSZ6AgemaW9zMHBnGccy3df7actf4
// - Threshold 2
let sudo_account_id: AccountId =
AccountId::from_ss58check("5FPL3ZLqUk6MyBoZrQZ1Co29WAteX6T6N68TZ6jitHvhpyuD").unwrap();
AccountId::from_ss58check("15NMV2JX1NeMwarQiiZvuJ8ixUcvayFDcu1F9Wz1HNpSc8gP").unwrap();

#[allow(deprecated)]
LiveChainSpec::builder(
MainnetChainSpec::builder(
pop_runtime::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(live_genesis(
.with_genesis_config_patch(mainnet_genesis(
// initial collators.
vec![
// POP COLLATOR 0
(collator_0_account_id, collator_0_aura_id),
// POP COLLATOR 1
(collator_1_account_id, collator_1_aura_id),
// POP COLLATOR 2
(collator_2_account_id, collator_2_aura_id),
],
sudo_account_id,
para_id.into(),
Expand All @@ -234,7 +230,7 @@ pub fn live_config(relay: Relay) -> LiveChainSpec {
.build()
}

fn live_genesis(
fn mainnet_genesis(
invulnerables: Vec<(AccountId, AuraId)>,
root: AccountId,
id: ParaId,
Expand All @@ -260,7 +256,7 @@ fn live_genesis(
(
acc.clone(), // account id
acc, // validator id
pop_live_session_keys(aura), // session keys
pop_mainnet_session_keys(aura), // session keys
)
})
.collect::<Vec<_>>(),
Expand Down
18 changes: 9 additions & 9 deletions node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use crate::{
enum Runtime {
Devnet,
Testnet,
Live,
Mainnet,
}

trait RuntimeResolver {
Expand All @@ -36,8 +36,8 @@ fn runtime(id: &str) -> Runtime {
Runtime::Devnet
} else if id.starts_with("test") || id.ends_with("testnet") {
Runtime::Testnet
} else if id.eq("pop") || id.ends_with("live") {
Runtime::Live
} else if id.eq("pop") || id.ends_with("live") || id.ends_with("mainnet") {
Runtime::Mainnet
} else {
log::warn!(
"No specific runtime was recognized for ChainSpec's Id: '{}', so Runtime::Devnet will \
Expand Down Expand Up @@ -75,15 +75,15 @@ fn load_spec(id: &str) -> std::result::Result<Box<dyn ChainSpec>, String> {
"dev" | "devnet" | "dev-paseo" =>
Box::new(chain_spec::development_config(Relay::PaseoLocal)),
"test" | "testnet" | "pop-paseo" => Box::new(chain_spec::testnet_config(Relay::Paseo)),
"pop-network" | "pop" | "pop-polkadot" =>
Box::new(chain_spec::live_config(Relay::Polkadot)),
"pop-network" | "pop" | "pop-polkadot" | "mainnet" =>
Box::new(chain_spec::mainnet_config(Relay::Polkadot)),
"" | "local" => Box::new(chain_spec::development_config(Relay::PaseoLocal)),
path => {
let path: PathBuf = path.into();
match path.runtime() {
Runtime::Devnet => Box::new(chain_spec::DevnetChainSpec::from_json_file(path)?),
Runtime::Testnet => Box::new(chain_spec::TestnetChainSpec::from_json_file(path)?),
Runtime::Live => Box::new(chain_spec::LiveChainSpec::from_json_file(path)?),
Runtime::Mainnet => Box::new(chain_spec::MainnetChainSpec::from_json_file(path)?),
}
},
})
Expand Down Expand Up @@ -181,7 +181,7 @@ macro_rules! construct_async_run {
{ $( $code )* }.map(|v| (v, task_manager))
})
}
Runtime::Live => {
Runtime::Mainnet => {
runner.async_run(|$config| {
let $components = new_partial::<pop_runtime::RuntimeApi>(
&$config
Expand All @@ -205,7 +205,7 @@ macro_rules! construct_benchmark_partials {
let $partials = new_partial::<pop_runtime_testnet::RuntimeApi>(&$config)?;
$code
},
Runtime::Live => {
Runtime::Mainnet => {
let $partials = new_partial::<pop_runtime::RuntimeApi>(&$config)?;
$code
},
Expand Down Expand Up @@ -381,7 +381,7 @@ pub fn run() -> Result<()> {
.map(|r| r.0)
.map_err(Into::into)
},
Runtime::Live => {
Runtime::Mainnet => {
sp_core::crypto::set_default_ss58_version(
pop_runtime::SS58Prefix::get().into(),
);
Expand Down
Loading

0 comments on commit 62eb992

Please sign in to comment.