Skip to content

Commit

Permalink
wip manta genesis
Browse files Browse the repository at this point in the history
Signed-off-by: Adam Reif <Garandor@manta.network>
  • Loading branch information
Adam Reif authored and Adam Reif committed Dec 28, 2022
1 parent d9b078c commit 082a605
Show file tree
Hide file tree
Showing 2 changed files with 148 additions and 2 deletions.
146 changes: 146 additions & 0 deletions node/src/chain_specs/manta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,15 @@
use super::*;
use crate::command::MANTA_PARACHAIN_ID;
use calamari_runtime::staking::NORMAL_COLLATOR_MINIMUM_STAKE;
use manta_runtime::{opaque::SessionKeys, GenesisConfig, ParachainStakingConfig};
use session_key_primitives::util::unchecked_account_id;
/// Manta Protocol Identifier
pub const MANTA_PROTOCOL_ID: &str = "manta";

/// Polkadot Relaychain Local Network Identifier
pub const POLKADOT_RELAYCHAIN: &str = "polkadot";

/// Polkadot Relaychain Local Network Identifier
pub const POLKADOT_RELAYCHAIN_LOCAL_NET: &str = "polkadot-local";

Expand Down Expand Up @@ -222,3 +226,145 @@ pub fn manta_testnet_config() -> Result<MantaChainSpec, String> {
pub fn manta_config() -> Result<MantaChainSpec, String> {
MantaChainSpec::from_json_bytes(&include_bytes!("../../../genesis/manta-genesis.json")[..])
}

struct Collator{
acc: AccountId,
nodeid: String,
keys: SessionKeys
};

fn manta_mainnet_genesis(genesis_collators: Collator) -> GenesisConfig {
const TOTAL_ISSUANCE : Balance = 1_000_000_000 * MANTA; // TODO
const INITIAL_CONTROLLER_BALANCE : Balance = 100 * MANTA; // TODO
const INITIAL_COLLATOR_BALANCE : Balance = 100 * MANTA; // TODO
let root_key = hex![""].into(); // MULTISIG // TODO
let endowments = vec![
(hex![""].into(), INITIAL_CONTROLLER_BALANCE), // CONTROLLER 1 // TODO
(hex![""].into(), INITIAL_CONTROLLER_BALANCE), // CONTROLLER 2 // TODO
(hex![""].into(), INITIAL_CONTROLLER_BALANCE), // CONTROLLER 3 // TODO
(hex!["0619e4018531059b677d70b476b72431d3e88fe71d2c27bba5d945975e824956"].into(), INITIAL_COLLATOR_BALANCE), // COLLATOR 1
(hex!["0202d1760e33f60f977fcff88b611cb95e66d0b3b74c12ac6c8037b8b9764a31"].into(), INITIAL_COLLATOR_BALANCE), // COLLATOR 2
(hex!["4ece9156edd66af83b0c6afe17878844d873a08fd05bd9dbc17f9712814e9952"].into(), INITIAL_COLLATOR_BALANCE), // COLLATOR 3
(hex!["7a5cef43508640b6839c37a41272dec83dda4df28503bd87436c197d213f692c"].into(), INITIAL_COLLATOR_BALANCE), // COLLATOR 4
(hex!["4039a894994d326e32801a0fc19a267383b6231e74bc9c3fd1021d949d849406"].into(), INITIAL_COLLATOR_BALANCE), // COLLATOR 5
(root_key, TOTAL_ISSUANCE - 3 * INITIAL_CONTROLLER_BALANCE - 5 * INITIAL_COLLATOR_BALANCE)
];
assert!(NORMAL_COLLATOR_MINIMUM_STAKE < INITIAL_COLLATOR_BALANCE);

GenesisConfig {
system: manta_runtime::SystemConfig {
code: manta_runtime::WASM_BINARY
.expect("WASM binary was not build, please build it!")
.to_vec(),
},
balances: manta_runtime::BalancesConfig {
balances: endowments,
},
// empty aura authorities, collators registered with parachain staking instead
aura: Default::default(),
sudo: manta_runtime::SudoConfig {
key: Some(root_key),
},
parachain_staking: ParachainStakingConfig {
candidates: genesis_collators
.iter()
.map(|collator| {
(
collator.acc.clone(),
manta_runtime::staking::NORMAL_COLLATOR_MINIMUM_STAKE,
)
})
.collect(),
vec![],
// set to 0 inflation at genesis
inflation_config: manta_runtime::staking::inflation_config::<manta_runtime::Runtime>(),
},
parachain_info: manta_runtime::ParachainInfoConfig {
parachain_id: MANTA_PARACHAIN_ID.into(),
},
collator_selection: manta_runtime::CollatorSelectionConfig {
invulnerables: vec![],
candidacy_bond: 0 * MANTA,
..Default::default()
},
session: manta_runtime::SessionConfig {
keys: genesis_collators
.iter()
.map(|collator| {
(
collator.acc.clone(), // account id
collator.acc.clone(), // validator id
collator.keys.clone(), // collator session keys
)
})
.collect(),
},
parachain_system: Default::default(),
polkadot_xcm: calamari_runtime::PolkadotXcmConfig {
safe_xcm_version: Some(SAFE_XCM_VERSION),
},
}
}

pub fn manta_mainnet_config() -> MantaChainSpec {
let genesis_collators: Vec<Collator> = vec![
Collator{ // c1: dfWh1oFWNxrmrHdiGdVpQQD6Pp3SmY5NrNsAGNRCxgaqJuZif
hex!["0619e4018531059b677d70b476b72431d3e88fe71d2c27bba5d945975e824956"].into(),
"12D3KooWSNwD7tJkqKGdMfCVTJbbzrGFTGbXoeMFZCTwEytpFCM4",
SessionKeys::new((
hex!["dfYBquhamT9Tm8vZy2aNZsLA8ti9TS1DH2Sb5CrdqEGkYxkS2"].unchecked_into(),
hex!["dfakwcBogWNbwGEbKVAwoKPf2U4Hf6vz9szfVhhdiQwtg2rEL"].unchecked_into()
));
},
Collator{ // c2: dfWbekcVeiw3kzPEw6SiDafzrNM8eWAHTM2ideHQF6jWgS85f
hex!["0202d1760e33f60f977fcff88b611cb95e66d0b3b74c12ac6c8037b8b9764a31"].into(),
"12D3KooWSyPTkVytQwurRBt73wPQDTgypw88bdhsE4Rb6RnQvCJ9",
SessionKeys::new((
hex!["dfZgfiDzgdPNwREcJ9hqobyufda6EH2C4p6vDrzeMDvbJwpdm"].unchecked_into(),
hex!["dfYCSjotLLwrHFhkskh7R6HE5ibUDVNTaZ5DqMH2rNseViATG"].unchecked_into()
));
},
Collator{ // c3: dfYLLvDCZ847eDqvGAf9h9eGmaGi7RgdfAyvfqVqUBFzsEipm
hex!["4ece9156edd66af83b0c6afe17878844d873a08fd05bd9dbc17f9712814e9952"].into(),
"12D3KooWJwHqCEjTF46eAUDspKKwxa15TMfs7x8DNr3Gs71Qr64j",
SessionKeys::new((
hex!["dfaaoKuam626pYJGb4enxS8NmEGvsWcHADFptCm4RVAWmsLEG"].unchecked_into(),
hex!["dfauRtpMasGNxTTa5kBjR4LcqGmGrnA53vd3UP9NqF6WctyZ3"].unchecked_into()
));
},
Collator{ // c4: dfZKTGZS2A7YJmiunthXUNkongd1VMMdrhn7cPxzG2HYxHant
hex!["7a5cef43508640b6839c37a41272dec83dda4df28503bd87436c197d213f692c"].into(),
"12D3KooWAgZYhwfUo7brgZK2TvArK6XNUtZnzk1cSNfyD9kX1rDE",
SessionKeys::new((
hex!["dfaEWJu9HfkmHyR2aQac3ZRCnBqsgFS6qncpGRYC2jpv2W1uS"].unchecked_into(),
hex!["dfaMX2rcfXj3aYaMp49iWVrRgkxRj7eeYRnGPTAbUVBXTNQnq"].unchecked_into()
));
},
Collator{ // c5: dfY1E1gYvTvJqnwpSnLfYEHpHEdSNW69dcJQRRKKW1UN7ts9s
hex!["4039a894994d326e32801a0fc19a267383b6231e74bc9c3fd1021d949d849406"].into(),
"12D3KooWNHVexSGRVeLb7rt7tYS5Y3k5Up9amQn1GyTDCi7L9LLf",
SessionKeys::new((
hex!["dfXFU5LYyQj5vzHeaHbVfhyenuibJJPGSpPonKCPNw6qsUwSm"].unchecked_into(),
hex!["dfas8jnCTfPXtVvwAu15PtX6WAc3rw4iacCHeuj7qniepWtJE"].unchecked_into()
));
},
];

MantaChainSpec::from_genesis(
"Manta Parachain",
"manta",
ChainType::Live,
move || { manta_mainnet_genesis(genesis_collators.clone()) },
genesis_collators.map(|collator|{
collator.nodeid.into()
}).collect(),
None,
Some(MANTA_PROTOCOL_ID),
None,
Some(manta_properties()),
Extensions {
relay_chain: POLKADOT_RELAYCHAIN.into(),
para_id: MANTA_PARACHAIN_ID,
},
)
}
4 changes: 2 additions & 2 deletions runtime/manta/src/staking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
use crate::{currency::MANTA, Balance};
use pallet_parachain_staking::{BalanceOf, InflationInfo};

pub const NORMAL_COLLATOR_MINIMUM_STAKE: Balance = 4_000 * MANTA;
pub const EARLY_COLLATOR_MINIMUM_STAKE: Balance = 4_000 * MANTA;
pub const NORMAL_COLLATOR_MINIMUM_STAKE: Balance = 50 * MANTA;
pub const EARLY_COLLATOR_MINIMUM_STAKE: Balance = 50 * MANTA;
pub const MIN_BOND_TO_BE_CONSIDERED_COLLATOR: Balance = NORMAL_COLLATOR_MINIMUM_STAKE;

pub fn inflation_config<T: frame_system::Config + pallet_parachain_staking::Config>(
Expand Down

0 comments on commit 082a605

Please sign in to comment.