Skip to content

Commit

Permalink
TUR and OAK runtime config changes (#278)
Browse files Browse the repository at this point in the history
Co-authored-by: irsal <[email protected]>
Co-authored-by: Irsal McGinnis <[email protected]>
  • Loading branch information
3 people committed Sep 16, 2022
1 parent 0a36d47 commit ea297ce
Show file tree
Hide file tree
Showing 10 changed files with 503 additions and 221 deletions.
16 changes: 16 additions & 0 deletions distribution/oak_alloc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[
["66MGxr9zcyJ6ka6FBQmT1VSvMqARKfwBT7589Fikii1Ci5sg", 100000000000000],
["67He8TSn5ayD2p2ZS9WDQtuVuW7Z8RXXvBx5NyszGwcEGpzS", 20010000000000000],
["6Azd1ebort6eZUDfg9f4A75fmD1JCV6ysHaFnTEqEPEuGpbP", 20010000000000000],
["6AQf3NV66CTNSsFuY1ehA1zJySYQybQwvC5Yq8ufqcZVQ3iN", 20010000000000000],
["66AJHj124JZnpKnWFoJGx41uSVqjyUz6tmVPfZWnhemBe8wG", 20010000000000000],
["69Eyxo3gFpZpcRrtx5NAFBDMcoiVQrdg7so1M9w4FWiTBLej", 10000000000000],
["67D6ecyNhnAzZqgRbxr3MdGnxB9Bw8VadMhjpLAYB3wf5Pq6", 10000000000000],
["6AxoUZEKEbaGVHsBkuJ6mvVgeMEixoroGiD1b3sBkroBqDXE", 10000000000000],
["69pKU2QpgtMBT9NsaN1diyJQ8qcvrJy8KJk5aWeAXfMGjb5F", 10000000000000],
["67ppUQ3mGfaWDEr5VQRz4QgvNzXiGLmGjwwEcnvbJofSQyMN", 10000000000000],
["68Tn1mgDo1dvctJLZCWaYJWLSWgu4GYtL5jgrrmzidAgpoJG", 10000000000000],
["67Za6G2i3BGkcTtYzU2hUzHrmy6quwWzyEMJB98oRv3GwDmb", 10000000000000],
["67nmVh57G9yo7sqiGLjgNNqtUd7H2CSESTyQgp5272aMibwS", 10000000000000],
["6871Utgdq5ycWnTzm7VEwQfg4zM81JqYv8EDzKPu3fdzsXK8", 10000000000000]
]
458 changes: 291 additions & 167 deletions distribution/oak_vesting.json

Large diffs are not rendered by default.

11 changes: 7 additions & 4 deletions node/src/chain_spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@ where
AccountPublic::from(get_public_from_seed::<TPublic>(seed)).into_account()
}

pub fn inflation_config(blocks_per_round: u32) -> InflationInfo<Balance> {
pub fn inflation_config(
blocks_per_round: u32,
annual_inflation_percentage: u32,
) -> InflationInfo<Balance> {
fn to_round_inflation(annual: Range<Perbill>, blocks_per_round: u32) -> Range<Perbill> {
use pallet_parachain_staking::inflation::{
perbill_annual_to_perbill_round, BLOCKS_PER_YEAR,
Expand All @@ -99,9 +102,9 @@ pub fn inflation_config(blocks_per_round: u32) -> InflationInfo<Balance> {
}

let annual = Range {
min: Perbill::from_percent(5),
ideal: Perbill::from_percent(5),
max: Perbill::from_percent(5),
min: Perbill::from_percent(annual_inflation_percentage),
ideal: Perbill::from_percent(annual_inflation_percentage),
max: Perbill::from_percent(annual_inflation_percentage),
};

InflationInfo {
Expand Down
2 changes: 1 addition & 1 deletion node/src/chain_spec/neumann.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ fn testnet_genesis(
.map(|(acc, _)| (acc, neumann_runtime::MinCollatorStk::get()))
.collect(),
delegations: vec![],
inflation_config: inflation_config(neumann_runtime::DefaultBlocksPerRound::get()),
inflation_config: inflation_config(neumann_runtime::DefaultBlocksPerRound::get(), 5),
},
// no need to pass anything to aura, in fact it will panic if we do. Session will take care
// of this.
Expand Down
173 changes: 158 additions & 15 deletions node/src/chain_spec/oak.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ const TOKEN_SYMBOL: &str = "OAK";
const SS_58_FORMAT: u32 = 51;
static RELAY_CHAIN: &str = "rococo-local";
static STAGING_RELAY_CHAIN: &str = "rococo";
const REGISTERED_PARA_ID: u32 = 2114;
static LIVE_RELAY_CHAIN: &str = "polkadot";
const REGISTERED_PARA_ID: u32 = 2090;
const REGISTERED_STAGING_PARA_ID: u32 = 4103;

/// The default XCM version to set in genesis config.
Expand Down Expand Up @@ -112,11 +113,10 @@ pub fn oak_staging() -> ChainSpec {
"oak-staging",
ChainType::Live,
move || {
let allocation_json =
&include_bytes!("../../../distribution/oak_staging_alloc.json")[..];
let allocation_json = &include_bytes!("../../../distribution/oak_alloc.json")[..];
let initial_allocation: Vec<(AccountId, Balance)> =
serde_json::from_slice(allocation_json).unwrap();
const ALLOC_TOKENS_TOTAL: u128 = DOLLAR * 1_000_000_000;
const ALLOC_TOKENS_TOTAL: u128 = 80_230_000_000_000_000;
validate_allocation(
initial_allocation.clone(),
ALLOC_TOKENS_TOTAL,
Expand All @@ -127,9 +127,9 @@ pub fn oak_staging() -> ChainSpec {
let initial_vesting: Vec<(u64, Vec<(AccountId, Balance)>)> =
serde_json::from_slice(vesting_json).unwrap();

let vested_tokens = 9_419_999_999_999_999_919;
let vest_starting_time: u64 = 1651431600;
let vest_ending_time: u64 = 1743534000;
let vested_tokens = 7_599_999_950_000_000_000;
let vest_starting_time: u64 = 1672603200;
let vest_ending_time: u64 = 1796155200;
validate_vesting(
initial_vesting.clone(),
vested_tokens,
Expand All @@ -142,25 +142,35 @@ pub fn oak_staging() -> ChainSpec {
// initial collators.
vec![
(
// SS58 prefix substrate: 5EvKT4iWQ5gDnRhkS3d254RVCfaQJSyXHj5mA4kQTsCjWchW
hex!["7e4f4efde71551c83714fb3062724067e7bb6ebc3bf942813321f1583e187572"]
// SS58 prefix 51: 67He8TSn5ayD2p2ZS9WDQtuVuW7Z8RXXvBx5NyszGwcEGpzS
hex!["325603af5d8d4e284646556835df92977d48c8100eaf92e110d4b75d4650a73c"]
.into(),
hex!["7e4f4efde71551c83714fb3062724067e7bb6ebc3bf942813321f1583e187572"]
hex!["325603af5d8d4e284646556835df92977d48c8100eaf92e110d4b75d4650a73c"]
.unchecked_into(),
),
(
// SS58 prefix substrate: 5F4Dx9TD16awU7FeGD3Me5VDrEsL5MDPEcbNBvUgLQFawxyW
hex!["8456c30af083c2b2d767d6950e8ee654d4eff5e69cdd9f75db5bcbf2d7b0d801"]
// SS58 prefix 51: 6Azd1ebort6eZUDfg9f4A75fmD1JCV6ysHaFnTEqEPEuGpbP
hex!["d64c03d1ab36318a0d7da660670c83928261fc2a3464f92218ff5d42561e9a40"]
.into(),
hex!["8456c30af083c2b2d767d6950e8ee654d4eff5e69cdd9f75db5bcbf2d7b0d801"]
hex!["d64c03d1ab36318a0d7da660670c83928261fc2a3464f92218ff5d42561e9a40"]
.unchecked_into(),
),
],
// 5C571x5GLRQwfA3aRtVcxZzD7JnzNb3JbtZEvJWfQozWE54K
hex!["004df6aeb14c73ef5cd2c57d9028afc402c4f101a8917bbb6cd19407c8bf8307"].into(),
initial_allocation,
REGISTERED_STAGING_PARA_ID.into(),
vec![],
vec![
b"AutomationTime".to_vec(),
b"Balances".to_vec(),
b"Bounties".to_vec(),
b"Currencies".to_vec(),
b"Democracy".to_vec(),
b"ParachainStaking".to_vec(),
b"PolkadotXcm".to_vec(),
b"Treasury".to_vec(),
b"XTokens".to_vec(),
],
initial_vesting,
vec![
// 5C571x5GLRQwfA3aRtVcxZzD7JnzNb3JbtZEvJWfQozWE54K
Expand Down Expand Up @@ -190,6 +200,139 @@ pub fn oak_staging() -> ChainSpec {
)
}

pub fn oak_live() -> ChainSpec {
// Give your base currency a unit name and decimal places
let mut properties = sc_chain_spec::Properties::new();
properties.insert("tokenSymbol".into(), TOKEN_SYMBOL.into());
properties.insert("tokenDecimals".into(), TOKEN_DECIMALS.into());
properties.insert("ss58Format".into(), SS_58_FORMAT.into());

ChainSpec::from_genesis(
// Name
"OAK Network",
// ID
"oak",
ChainType::Live,
move || {
let allocation_json = &include_bytes!("../../../distribution/oak_alloc.json")[..];
let initial_allocation: Vec<(AccountId, Balance)> =
serde_json::from_slice(allocation_json).unwrap();
const ALLOC_TOKENS_TOTAL: u128 = 80_230_000_000_000_000;
validate_allocation(
initial_allocation.clone(),
ALLOC_TOKENS_TOTAL,
EXISTENTIAL_DEPOSIT,
);

let vesting_json = &include_bytes!("../../../distribution/oak_vesting.json")[..];
let initial_vesting: Vec<(u64, Vec<(AccountId, Balance)>)> =
serde_json::from_slice(vesting_json).unwrap();

let vested_tokens = 7_599_999_950_000_000_000;
let vest_starting_time: u64 = 1672603200;
let vest_ending_time: u64 = 1796155200;
validate_vesting(
initial_vesting.clone(),
vested_tokens,
EXISTENTIAL_DEPOSIT,
vest_starting_time,
vest_ending_time,
);

testnet_genesis(
// initial collators.
vec![
(
// SS58 prefix 51: 67He8TSn5ayD2p2ZS9WDQtuVuW7Z8RXXvBx5NyszGwcEGpzS
hex!["325603af5d8d4e284646556835df92977d48c8100eaf92e110d4b75d4650a73c"]
.into(),
hex!["325603af5d8d4e284646556835df92977d48c8100eaf92e110d4b75d4650a73c"]
.unchecked_into(),
),
(
// SS58 prefix 51: 6Azd1ebort6eZUDfg9f4A75fmD1JCV6ysHaFnTEqEPEuGpbP
hex!["d64c03d1ab36318a0d7da660670c83928261fc2a3464f92218ff5d42561e9a40"]
.into(),
hex!["d64c03d1ab36318a0d7da660670c83928261fc2a3464f92218ff5d42561e9a40"]
.unchecked_into(),
),
(
// SS58 prefix 51: 6AQf3NV66CTNSsFuY1ehA1zJySYQybQwvC5Yq8ufqcZVQ3iN
hex!["bc6480f3f236dcd444809ace67e5a64bd35d7757b46d051bf300264bfc1eea55"]
.into(),
hex!["bc6480f3f236dcd444809ace67e5a64bd35d7757b46d051bf300264bfc1eea55"]
.unchecked_into(),
),
(
// SS58 prefix 51: 66AJHj124JZnpKnWFoJGx41uSVqjyUz6tmVPfZWnhemBe8wG
hex!["00804668906bbe7934ba89ef18c17c62c2dc175ca8df33621f2413e677c7144f"]
.into(),
hex!["00804668906bbe7934ba89ef18c17c62c2dc175ca8df33621f2413e677c7144f"]
.unchecked_into(),
),
],
// 66MGxr9zcyJ6ka6FBQmT1VSvMqARKfwBT7589Fikii1Ci5sg
hex!["08df8338e854d8d589dedd4305c11e589cbef994e5dd00c7bb8fb7d277705b06"].into(),
initial_allocation,
REGISTERED_PARA_ID.into(),
vec![
b"AutomationTime".to_vec(),
b"Balances".to_vec(),
b"Bounties".to_vec(),
b"Currencies".to_vec(),
b"Democracy".to_vec(),
b"ParachainStaking".to_vec(),
b"PolkadotXcm".to_vec(),
b"Treasury".to_vec(),
b"XTokens".to_vec(),
],
initial_vesting,
vec![
// 69pKU2QpgtMBT9NsaN1diyJQ8qcvrJy8KJk5aWeAXfMGjb5F
hex!["a23443cef4fe4e7ee3f61c8248505312fa81121f2a8bd64099390b40d7a05206"].into(),
// 69Eyxo3gFpZpcRrtx5NAFBDMcoiVQrdg7so1M9w4FWiTBLej
hex!["88c782a383f0cfa5fbc36c9734dfc7cb6319137b48cc69cc662c84b6e687a106"].into(),
// 67D6ecyNhnAzZqgRbxr3MdGnxB9Bw8VadMhjpLAYB3wf5Pq6
hex!["2edf0fd8948ea642f135b314b1358c77ec6d0a4af83220b6ea18136e5ce36277"].into(),
// 6AxoUZEKEbaGVHsBkuJ6mvVgeMEixoroGiD1b3sBkroBqDXE
hex!["d4e8bfb1c924dd64e33ecfbb35d90061bb83b2dde667e58588780068f9fc1471"].into(),
// 67nmVh57G9yo7sqiGLjgNNqtUd7H2CSESTyQgp5272aMibwS
hex!["488ced7d199b4386081a52505962128da5a3f54f4665db3d78b6e9f9e89eea4d"].into(),
],
vec![
// 69pKU2QpgtMBT9NsaN1diyJQ8qcvrJy8KJk5aWeAXfMGjb5F
hex!["a23443cef4fe4e7ee3f61c8248505312fa81121f2a8bd64099390b40d7a05206"].into(),
// 67ppUQ3mGfaWDEr5VQRz4QgvNzXiGLmGjwwEcnvbJofSQyMN
hex!["4a1d713c2f41e10db31b83a45a3a98b64088330190eac7fcef4623694fbac55e"].into(),
// 6871Utgdq5ycWnTzm7VEwQfg4zM81JqYv8EDzKPu3fdzsXK8
hex!["56766d3f856f2ca399ae575689a7340c2532351948f355c21bc06b170569da35"].into(),
// 68Tn1mgDo1dvctJLZCWaYJWLSWgu4GYtL5jgrrmzidAgpoJG
hex!["664d3e87b905d7e3fba4f459673af256166313c498972fb8cbba6e3697d7fe3b"].into(),
// 67Za6G2i3BGkcTtYzU2hUzHrmy6quwWzyEMJB98oRv3GwDmb
hex!["3e7c592124e2cde1808eeaa4c6799cb680506046bfc7b0304d9305bd3bd50b11"].into(),
// 67nmVh57G9yo7sqiGLjgNNqtUd7H2CSESTyQgp5272aMibwS
hex!["488ced7d199b4386081a52505962128da5a3f54f4665db3d78b6e9f9e89eea4d"].into(),
],
vec![],
)
},
// Bootnodes
Vec::new(),
// Telemetry
TelemetryEndpoints::new(vec![(TELEMETRY_URL.into(), 0)]).ok(),
// Protocol ID
Some("oak"),
None,
// Properties
Some(properties),
// Extensions
Extensions {
relay_chain: LIVE_RELAY_CHAIN.into(), // You MUST set this to the correct network!
para_id: REGISTERED_PARA_ID,
},
)
}

fn testnet_genesis(
invulnerables: Vec<(AccountId, AuraId)>,
root_key: AccountId,
Expand Down Expand Up @@ -231,7 +374,7 @@ fn testnet_genesis(
.map(|(acc, _)| (acc, candidate_stake))
.collect(),
delegations: vec![],
inflation_config: inflation_config(oak_runtime::DefaultBlocksPerRound::get()),
inflation_config: inflation_config(oak_runtime::DefaultBlocksPerRound::get(), 0),
},
// no need to pass anything to aura, in fact it will panic if we do. Session will take care
// of this.
Expand Down
2 changes: 1 addition & 1 deletion node/src/chain_spec/turing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ fn testnet_genesis(
.map(|(acc, _)| (acc, candidate_stake))
.collect(),
delegations: vec![],
inflation_config: inflation_config(turing_runtime::DefaultBlocksPerRound::get()),
inflation_config: inflation_config(turing_runtime::DefaultBlocksPerRound::get(), 5),
},
// no need to pass anything to aura, in fact it will panic if we do. Session will take care
// of this.
Expand Down
2 changes: 2 additions & 0 deletions node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ fn load_spec(id: &str) -> std::result::Result<Box<dyn ChainSpec>, String> {
"oak-dev" => Box::new(chain_spec::oak::oak_development_config()),
#[cfg(feature = "oak-node")]
"oak-staging" => Box::new(chain_spec::oak::oak_staging()),
#[cfg(feature = "oak-node")]
"oak" => Box::new(chain_spec::oak::oak_live()),
path => {
let path = std::path::PathBuf::from(path);
let chain_spec = Box::new(chain_spec::DummyChainSpec::from_json_file(path.clone())?)
Expand Down
8 changes: 8 additions & 0 deletions pallets/valve/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,11 @@ pub trait Shutdown {
/// Forwards restart message to implementer
fn restart();
}

impl Shutdown for () {
fn is_shutdown() -> bool {
true
}
fn shutdown() {}
fn restart() {}
}
Loading

0 comments on commit ea297ce

Please sign in to comment.