Skip to content

Commit

Permalink
Merge pull request #7 from logion-network/feature/prepare-migration
Browse files Browse the repository at this point in the history
Prepare migration
  • Loading branch information
benoitdevos authored Apr 4, 2024
2 parents 6189b6f + d753a67 commit 96d738a
Show file tree
Hide file tree
Showing 20 changed files with 2,678 additions and 478 deletions.
794 changes: 484 additions & 310 deletions Cargo.lock

Large diffs are not rendered by default.

Binary file added docs/inclusion_fees.ods
Binary file not shown.
10 changes: 7 additions & 3 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ build = "build.rs"
clap = { version = "4.5.1", features = ["derive"] }
log = { version = "0.4.20", default-features = true }
codec = { package = "parity-scale-codec", version = "3.0.0" }
serde = { version = "1.0.193", features = ["derive"], default-features = true }
serde = { version = "1.0.197", features = ["derive"], default-features = true }
jsonrpsee = { version = "0.22", features = ["server"] }
futures = "0.3.28"
serde_json = { version = "1.0.114", default-features = true }
futures = { version = "0.3.21", features = ["thread-pool"]}
serde_json = { version = "1.0.114", features = ["arbitrary_precision"] }
bs58 = "0.5.0"

# Local
logion-runtime = { path = "../runtime" }
Expand Down Expand Up @@ -70,6 +71,9 @@ cumulus-primitives-parachain-inherent = { git = "https://github.com/paritytech/p
cumulus-relay-chain-interface = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.8.0" }
color-print = "0.3.4"

# Logion
pallet-lo-authority-list = { git = "https://github.com/logion-network/logion-pallets", default-features = false, tag = "v0.2.1" }

[build-dependencies]
substrate-build-script-utils = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.8.0" }

Expand Down
189 changes: 88 additions & 101 deletions node/src/chain_spec.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
use cumulus_primitives_core::ParaId;
use logion_runtime::{AccountId, AuraId, Signature, EXISTENTIAL_DEPOSIT, Balance, LGNT, SS58Prefix};
use pallet_lo_authority_list::GenesisHostData;
use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup};
use sc_service::ChainType;
use serde::{Deserialize, Serialize};
use sp_core::{sr25519, Pair, Public};
use sp_core::{sr25519, Pair, Public, OpaquePeerId};
use sp_runtime::traits::{IdentifyAccount, Verify};
use std::str::FromStr;

Expand Down Expand Up @@ -61,102 +62,6 @@ pub fn template_session_keys(keys: AuraId) -> logion_runtime::SessionKeys {
logion_runtime::SessionKeys { aura: keys }
}

pub fn logion_config() -> ChainSpec {
const ROOT_PUBLIC_SR25519: &str = "5GzrECvUzFng58zzFvqVJvpE2MRnjU9vgh4iJMhqrLBSRRAv";

const NODE01_PUBLIC_SR25519: &str = "5DjzFDhFidvGCuuy6i8Lsi4XyruYjxTTkJKb1o7XzVdMNPVb";
const NODE02_PUBLIC_SR25519: &str = "5DoD9n61SssFiWQDTD7bz1eX3KCxZJ6trVj2GsDwMi2PqP85";
const NODE03_PUBLIC_SR25519: &str = "5CJTSSJ4v1RAauZpeqTeddyui4wESZZqPor33wum9aKuQXZC";
const NODE04_PUBLIC_SR25519: &str = "5EF6NVgMfRRFMRnNEByNJsQJfD1fokamB9kq2J7SLRVraJrg";
const NODE05_PUBLIC_SR25519: &str = "5G7Gtz7iLn3z5PkqfweQJp5jJdV3u8ix7qWcGS4bs38EH1W3";
const NODE06_PUBLIC_SR25519: &str = "5EZRCd7FybQKthaD2XuV21RAdU5LqPoveiSdrz9Z6JCstoSH";
const NODE07_PUBLIC_SR25519: &str = "5DqwojnfMTfZvERe9SJr3e1ApfaAY8Lye8Tch6WfnmxkfJfw";
const NODE08_PUBLIC_SR25519: &str = "5GRie9PZxqzAmPoJAgiLjzgxzFi7LW2ez1TNzzWdUN6yh8Jd";
const NODE09_PUBLIC_SR25519: &str = "5CSsbWDRbV5eYuWZsSrFcfkrEnGAjhbmyGJjjpRkjQ7s5dCd";
const NODE10_PUBLIC_SR25519: &str = "5FYe8QZfCUZVh6BeuAziATXNcowbZuSngqrguGahscdbhhnz";
const NODE11_PUBLIC_SR25519: &str = "5DRbgvZC3LEeJmRe893Q3UEwP2H1DPv5x8ofFgcxihCLu3oL";
const NODE12_PUBLIC_SR25519: &str = "5F6h3kuXnhpwkVzDKRd65jrSu53UecKNRdHcgCGFiAbAPWMt";

ChainSpec::builder(
logion_runtime::WASM_BINARY
.expect("WASM binary was not built, please build it!"),
Extensions {
relay_chain: "polkadot".into(),
para_id: main_para_id(),
},
)
.with_name("logion network")
.with_id("logion")
.with_protocol_id("logion")
.with_chain_type(ChainType::Live)
.with_genesis_config_patch(build_genesis_config(
vec![
(
AccountId::from_str(NODE01_PUBLIC_SR25519).unwrap(),
AuraId::from(sr25519::Public::from_str(NODE01_PUBLIC_SR25519).unwrap()),
),
(
AccountId::from_str(NODE02_PUBLIC_SR25519).unwrap(),
AuraId::from(sr25519::Public::from_str(NODE02_PUBLIC_SR25519).unwrap()),
),
(
AccountId::from_str(NODE03_PUBLIC_SR25519).unwrap(),
AuraId::from(sr25519::Public::from_str(NODE03_PUBLIC_SR25519).unwrap()),
),
(
AccountId::from_str(NODE04_PUBLIC_SR25519).unwrap(),
AuraId::from(sr25519::Public::from_str(NODE04_PUBLIC_SR25519).unwrap()),
),
(
AccountId::from_str(NODE05_PUBLIC_SR25519).unwrap(),
AuraId::from(sr25519::Public::from_str(NODE05_PUBLIC_SR25519).unwrap()),
),
(
AccountId::from_str(NODE06_PUBLIC_SR25519).unwrap(),
AuraId::from(sr25519::Public::from_str(NODE06_PUBLIC_SR25519).unwrap()),
),
(
AccountId::from_str(NODE07_PUBLIC_SR25519).unwrap(),
AuraId::from(sr25519::Public::from_str(NODE07_PUBLIC_SR25519).unwrap()),
),
(
AccountId::from_str(NODE08_PUBLIC_SR25519).unwrap(),
AuraId::from(sr25519::Public::from_str(NODE08_PUBLIC_SR25519).unwrap()),
),
(
AccountId::from_str(NODE09_PUBLIC_SR25519).unwrap(),
AuraId::from(sr25519::Public::from_str(NODE09_PUBLIC_SR25519).unwrap()),
),
(
AccountId::from_str(NODE10_PUBLIC_SR25519).unwrap(),
AuraId::from(sr25519::Public::from_str(NODE10_PUBLIC_SR25519).unwrap()),
),
(
AccountId::from_str(NODE11_PUBLIC_SR25519).unwrap(),
AuraId::from(sr25519::Public::from_str(NODE11_PUBLIC_SR25519).unwrap()),
),
(
AccountId::from_str(NODE12_PUBLIC_SR25519).unwrap(),
AuraId::from(sr25519::Public::from_str(NODE12_PUBLIC_SR25519).unwrap()),
),
],
vec![
(
AccountId::from_str(ROOT_PUBLIC_SR25519).unwrap(),
1_000_000_000 * LGNT,
),
],
main_para_id().into(),
AccountId::from_str(ROOT_PUBLIC_SR25519).unwrap(),
))
.with_properties(default_properties("LGNT"))
.build()
}

fn main_para_id() -> u32 {
3341
}

const DEFAULT_TEST_BALANCE: Balance = 1 << 60;

pub fn development_config() -> ChainSpec {
Expand All @@ -172,7 +77,7 @@ pub fn development_config() -> ChainSpec {
.with_id("local_logion")
.with_protocol_id("logion")
.with_chain_type(ChainType::Development)
.with_genesis_config_patch(build_genesis_config(
.with_genesis_config_patch(logion_genesis(
// initial collators.
vec![
(
Expand Down Expand Up @@ -232,6 +137,32 @@ pub fn development_config() -> ChainSpec {
],
test_parachain_id(),
get_account_id_from_seed::<sr25519::Public>("Alice"),
vec![ // Initial set of Logion Legal Officers
(
get_account_id_from_seed::<sr25519::Public>("Alice"),
GenesisHostData {
node_id: Some(OpaquePeerId(bs58::decode("12D3KooWBmAwcd4PJNJvfV89HwE48nwkRmAgo8Vy3uQEyNNHBox2").into_vec().unwrap())),
base_url: None,
region: "Europe".into(),
}
),
(
get_account_id_from_seed::<sr25519::Public>("Bob"),
GenesisHostData {
node_id: Some(OpaquePeerId(bs58::decode("12D3KooWQYV9dGMFoRzNStwpXztXaBUjtPqi6aU76ZgUriHhKust").into_vec().unwrap())),
base_url: None,
region: "Europe".into(),
}
),
(
get_account_id_from_seed::<sr25519::Public>("Charlie"),
GenesisHostData {
node_id: Some(OpaquePeerId(bs58::decode("12D3KooWJvyP3VJYymTqG7eH4PM5rN4T2agk5cdNCfNymAqwqcvZ").into_vec().unwrap())),
base_url: None,
region: "Europe".into(),
}
),
],
))
.with_properties(default_properties("LGNT"))
.build()
Expand Down Expand Up @@ -259,7 +190,7 @@ fn testnet_config(name: &str, id: &str, symbol: &str, root_ref: &str) -> ChainSp
.with_name(name)
.with_id(id)
.with_chain_type(ChainType::Live)
.with_genesis_config_patch(build_genesis_config(
.with_genesis_config_patch(logion_genesis(
// initial collators.
vec![
(
Expand Down Expand Up @@ -331,6 +262,32 @@ fn testnet_config(name: &str, id: &str, symbol: &str, root_ref: &str) -> ChainSp
],
test_parachain_id(),
AccountId::from_str(&root).unwrap(),
vec![ // Initial set of Logion Legal Officers
(
get_account_id_from_seed::<sr25519::Public>("Alice"),
GenesisHostData {
node_id: Some(OpaquePeerId(bs58::decode("12D3KooWBmAwcd4PJNJvfV89HwE48nwkRmAgo8Vy3uQEyNNHBox2").into_vec().unwrap())),
base_url: None,
region: "Europe".into(),
}
),
(
get_account_id_from_seed::<sr25519::Public>("Bob"),
GenesisHostData {
node_id: Some(OpaquePeerId(bs58::decode("12D3KooWQYV9dGMFoRzNStwpXztXaBUjtPqi6aU76ZgUriHhKust").into_vec().unwrap())),
base_url: None,
region: "Europe".into(),
}
),
(
get_account_id_from_seed::<sr25519::Public>("Charlie"),
GenesisHostData {
node_id: Some(OpaquePeerId(bs58::decode("12D3KooWJvyP3VJYymTqG7eH4PM5rN4T2agk5cdNCfNymAqwqcvZ").into_vec().unwrap())),
base_url: None,
region: "Europe".into(),
}
),
],
))
.with_protocol_id(id)
.with_properties(default_properties(symbol))
Expand Down Expand Up @@ -359,7 +316,7 @@ pub fn local_config() -> ChainSpec {
.with_id("local_logion")
.with_protocol_id("logion")
.with_chain_type(ChainType::Local)
.with_genesis_config_patch(build_genesis_config(
.with_genesis_config_patch(logion_genesis(
// initial collators.
vec![
(
Expand Down Expand Up @@ -419,16 +376,43 @@ pub fn local_config() -> ChainSpec {
],
test_parachain_id(),
get_account_id_from_seed::<sr25519::Public>("Alice"),
vec![ // Initial set of Logion Legal Officers
(
get_account_id_from_seed::<sr25519::Public>("Alice"),
GenesisHostData {
node_id: Some(OpaquePeerId(bs58::decode("12D3KooWBmAwcd4PJNJvfV89HwE48nwkRmAgo8Vy3uQEyNNHBox2").into_vec().unwrap())),
base_url: None,
region: "Europe".into(),
}
),
(
get_account_id_from_seed::<sr25519::Public>("Bob"),
GenesisHostData {
node_id: Some(OpaquePeerId(bs58::decode("12D3KooWQYV9dGMFoRzNStwpXztXaBUjtPqi6aU76ZgUriHhKust").into_vec().unwrap())),
base_url: None,
region: "Europe".into(),
}
),
(
get_account_id_from_seed::<sr25519::Public>("Charlie"),
GenesisHostData {
node_id: Some(OpaquePeerId(bs58::decode("12D3KooWJvyP3VJYymTqG7eH4PM5rN4T2agk5cdNCfNymAqwqcvZ").into_vec().unwrap())),
base_url: None,
region: "Europe".into(),
}
),
],
))
.with_properties(default_properties("LGNT"))
.build()
}

fn build_genesis_config(
fn logion_genesis(
invulnerables: Vec<(AccountId, AuraId)>,
endowed_accounts: Vec<(AccountId, Balance)>,
id: ParaId,
root_key: AccountId,
legal_officers: Vec<(AccountId, GenesisHostData)>,
) -> serde_json::Value {
serde_json::json!({
"balances": {
Expand Down Expand Up @@ -459,6 +443,9 @@ fn build_genesis_config(
"sudo": {
"key": Some(root_key),
},
"loAuthorityList": {
"legalOfficers": legal_officers,
},
})
}

Expand Down
1 change: 0 additions & 1 deletion node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ fn load_spec(id: &str) -> std::result::Result<Box<dyn ChainSpec>, String> {
"dev" => Box::new(chain_spec::development_config()),
"logion-dev" => Box::new(chain_spec::logion_dev_config()),
"logion-test" => Box::new(chain_spec::logion_test_config()),
"logion" => Box::new(chain_spec::logion_config()),
"" | "local" => Box::new(chain_spec::local_config()),
path => Box::new(chain_spec::ChainSpec::from_json_file(std::path::PathBuf::from(path))?),
})
Expand Down
Loading

0 comments on commit 96d738a

Please sign in to comment.