From 4c87b0ed6a6ef8d392528d77ca0b96998bea4555 Mon Sep 17 00:00:00 2001 From: 1xstj <106580853+1xstj@users.noreply.github.com> Date: Fri, 5 Jan 2024 19:16:03 +0000 Subject: [PATCH] feat: Prep testnet launch runtime (#405) --- Cargo.lock | 28 ++++----- Cargo.toml | 2 +- node/src/chainspec/testnet.rs | 101 ++++++++++++++---------------- node/src/command.rs | 2 +- node/src/distributions/develop.rs | 1 + node/src/distributions/testnet.rs | 1 + node/src/testnet_fixtures.rs | 40 +++++------- primitives/src/lib.rs | 2 +- runtime/mainnet/src/lib.rs | 21 ++++--- runtime/testnet/src/lib.rs | 23 ++++--- 10 files changed, 111 insertions(+), 110 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5c20c15da..5e2df0be5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7510,7 +7510,7 @@ checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" [[package]] name = "pallet-airdrop-claims" -version = "0.5.0" +version = "0.6.0" dependencies = [ "frame-support", "frame-system", @@ -7695,7 +7695,7 @@ dependencies = [ [[package]] name = "pallet-dkg" -version = "0.5.0" +version = "0.6.0" dependencies = [ "frame-benchmarking", "frame-support", @@ -8314,7 +8314,7 @@ dependencies = [ [[package]] name = "pallet-jobs" -version = "0.5.0" +version = "0.6.0" dependencies = [ "ethereum", "ethers", @@ -8355,7 +8355,7 @@ dependencies = [ [[package]] name = "pallet-jobs-rpc" -version = "0.5.0" +version = "0.6.0" dependencies = [ "jsonrpsee", "pallet-jobs-rpc-runtime-api", @@ -8371,7 +8371,7 @@ dependencies = [ [[package]] name = "pallet-jobs-rpc-runtime-api" -version = "0.5.0" +version = "0.6.0" dependencies = [ "parity-scale-codec 3.6.9", "sp-api", @@ -8450,7 +8450,7 @@ dependencies = [ [[package]] name = "pallet-roles" -version = "0.5.0" +version = "0.6.0" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -8586,7 +8586,7 @@ dependencies = [ [[package]] name = "pallet-transaction-pause" -version = "0.5.0" +version = "0.6.0" dependencies = [ "frame-support", "frame-system", @@ -8694,7 +8694,7 @@ dependencies = [ [[package]] name = "pallet-zksaas" -version = "0.5.0" +version = "0.6.0" dependencies = [ "ark-bn254 0.4.0", "ark-crypto-primitives 0.4.0", @@ -14419,7 +14419,7 @@ dependencies = [ [[package]] name = "tangle" -version = "0.5.0" +version = "0.6.0" dependencies = [ "clap 4.4.11", "fc-api", @@ -14521,7 +14521,7 @@ dependencies = [ [[package]] name = "tangle-crypto-primitives" -version = "0.5.0" +version = "0.6.0" dependencies = [ "parity-scale-codec 3.6.9", "scale-info", @@ -14530,7 +14530,7 @@ dependencies = [ [[package]] name = "tangle-primitives" -version = "0.5.0" +version = "0.6.0" dependencies = [ "ark-bn254 0.4.0", "ark-crypto-primitives 0.4.0", @@ -14579,7 +14579,7 @@ dependencies = [ [[package]] name = "tangle-runtime" -version = "0.5.0" +version = "0.6.0" dependencies = [ "evm-tracer", "fp-account", @@ -14678,7 +14678,7 @@ dependencies = [ [[package]] name = "tangle-testnet-runtime" -version = "0.5.0" +version = "0.6.0" dependencies = [ "evm-tracer", "fp-account", @@ -14783,7 +14783,7 @@ dependencies = [ [[package]] name = "tangle-voter" -version = "0.5.0" +version = "0.6.0" dependencies = [ "anyhow", "clap 4.4.11", diff --git a/Cargo.toml b/Cargo.toml index 807763c15..89358f578 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [workspace.package] -version = "0.5.0" +version = "0.6.0" authors = ["Webb Technologies Inc."] edition = "2021" license = "Unlicense" diff --git a/node/src/chainspec/testnet.rs b/node/src/chainspec/testnet.rs index 9af1c3f11..334aa7aeb 100644 --- a/node/src/chainspec/testnet.rs +++ b/node/src/chainspec/testnet.rs @@ -15,10 +15,7 @@ #![allow(clippy::type_complexity)] -use crate::{ - distributions::{combine_distributions, develop, testnet}, - testnet_fixtures::{get_bootnodes, get_initial_authorities, get_testnet_root_key}, -}; +use crate::testnet_fixtures::{get_bootnodes, get_initial_authorities, get_testnet_root_key}; use core::marker::PhantomData; use hex_literal::hex; use pallet_airdrop_claims::{MultiAddress, StatementKind}; @@ -45,6 +42,9 @@ use webb_consensus_types::network_config::{Network, NetworkConfig}; /// Specialized `ChainSpec`. This is a specialization of the general Substrate ChainSpec type. pub type ChainSpec = sc_service::GenericChainSpec; +pub const ENDOWMENT: Balance = 10_000_000 * UNIT; +pub const STASH: Balance = ENDOWMENT / 10; + /// Generate a crypto pair from seed. pub fn get_from_seed(seed: &str) -> ::Public { TPublic::Pair::from_string(&format!("//{seed}"), None) @@ -117,19 +117,16 @@ pub fn local_testnet_config(chain_id: u64) -> Result { get_account_id_from_seed::("Alice"), // Pre-funded accounts vec![ - get_account_id_from_seed::("Alice"), - get_account_id_from_seed::("Bob"), - get_account_id_from_seed::("Charlie"), - get_account_id_from_seed::("Dave"), - get_account_id_from_seed::("Eve"), + (get_account_id_from_seed::("Alice"), ENDOWMENT), + (get_account_id_from_seed::("Bob"), ENDOWMENT), + (get_account_id_from_seed::("Charlie"), ENDOWMENT), + (get_account_id_from_seed::("Dave"), ENDOWMENT), + (get_account_id_from_seed::("Eve"), ENDOWMENT), ], chain_id, - combine_distributions(vec![ - develop::get_evm_balance_distribution(), - testnet::get_evm_balance_distribution(), - ]), - testnet::get_substrate_balance_distribution(), - develop::get_local_claims(), + Default::default(), + Default::default(), + Default::default(), true, ) }, @@ -171,39 +168,37 @@ pub fn tangle_testnet_config(chain_id: u64) -> Result { get_testnet_root_key(), // Pre-funded accounts vec![ - get_testnet_root_key(), - hex!["4e85271af1330e5e9384bd3ac5bdc04c0f8ef5a8cc29c1a8ae483d674164745c"].into(), - hex!["804808fb75d16340dc250871138a1a6f1dfa3cab9cc1fbd6f42960f1c39a950d"].into(), - hex!["587c2ef00ec0a1b98af4c655763acd76ece690fccbb255f01663660bc274960d"].into(), - hex!["cc195602a63bbdcf2ef4773c86fdbfefe042cb9aa8e3059d02e59a062d9c3138"].into(), - hex!["a24f729f085de51eebaeaeca97d6d499761b8f6daeca9b99d754a06ef8bcec3f"].into(), - hex!["368ea402dbd9c9888ae999d6a799cf36e08673ee53c001dfb4529c149fc2c13b"].into(), - hex!["2c7f3cc085da9175414d1a9d40aa3aa161c8584a9ca62a938684dfbe90ae9d74"].into(), - hex!["0a55e5245382700f35d16a5ea6d60a56c36c435bef7204353b8c36871f347857"].into(), - hex!["e0948453e7acbc6ac937e124eb01580191e99f4262d588d4524994deb6134349"].into(), - hex!["6c73e5ee9f8614e7c9f23fd8f7257d12e061e75fcbeb3b50ed70eb87ba91f500"].into(), - hex!["541dc9dd9cd9b47ff19c77c3b14fab50ab0774e19abe438719cd09e4f4861166"].into(), - hex!["607e948bad733780eda6c0bd9b084243276332823ca8481fc20cd01e1a2ef36f"].into(), - hex!["b2c09cb1b78c3afd2b1ea4316dfb1be9065e070db948477248e4f3e0f1a2d850"].into(), - hex!["fc156f082d789f94149f8b52b191672fbf202ef1b92b487c3cec9bca2d1fbe72"].into(), - hex!["0e87759b6eeb6891743900cba17b8b5f31b2fa9c28536d9bcf76468d6e455b23"].into(), - hex!["48cea44ac6dd245572272dc6d4d33908586fb80886bf3207344388eac279cc25"].into(), - hex!["fa2c711c82661a761cf200421b9a5ef3257aa977a3a33acad0722d7d6993f03b"].into(), - hex!["daf7985bfa22b5060a4eb212fbeddb7c47f7c29db5a356ed9500b34d2944eb3d"].into(), - hex!["4ec0389ae623884a68234fd84d85af833633668aa382007e6515020e8cc29532"].into(), - hex!["48bb70f924e7362ee55817a6628a79e522a08a31735b0129e47ac435215d6c4e"].into(), - hex!["d6a033ee1790ef28fffe1b1ffec19b8921690632d073d955b9057e701eced352"].into(), - hex!["14ecdcc058ee431166402eefb682c276cc16a5d1083409b28076fda4c4d5352f"].into(), - hex!["400d597fe03f1031a9b4e1983b7c42eeed29ef3f9da6715667d06b367bdb897f"].into(), - hex!["668cf048845804f31759decbec11cb41bf316b1901d2142a35ad3a8eb7420326"].into(), + (get_testnet_root_key(), ENDOWMENT * 5), // 50 Million + ( + hex!["6c99e8e4ae3fe7e3328d7e9d85eb98e86bdc6410695797349fa536ebb9bb0a4a"] + .into(), + ENDOWMENT, + ), + ( + hex!["444dbfd0220eb1a993a7a2b9e1530aee1d17388ba3db34a0ee2b8ff971bfd073"] + .into(), + ENDOWMENT, + ), + ( + hex!["2c4e648b0fbbb88ff6b92b208273eb144383b2b19edc992e91448a4371d4d97d"] + .into(), + ENDOWMENT, + ), + ( + hex!["c884c8eb280327221a3ae6a45fe6c8805f09bcfc11b409c8e2daa621c0d99608"] + .into(), + ENDOWMENT, + ), + ( + hex!["483e0b8d6801c51115fd4b124c91e2d5dcd642b30335f6c5a1738ea18f66c251"] + .into(), + ENDOWMENT, + ), ], chain_id, - combine_distributions(vec![ - develop::get_evm_balance_distribution(), - testnet::get_evm_balance_distribution(), - ]), - testnet::get_substrate_balance_distribution(), - vec![], + Default::default(), + Default::default(), + Default::default(), true, ) }, @@ -229,29 +224,26 @@ fn testnet_genesis( initial_authorities: Vec<(AccountId, BabeId, GrandpaId, ImOnlineId, RoleKeyId)>, _initial_nominators: Vec, root_key: AccountId, - endowed_accounts: Vec, + endowed_accounts: Vec<(AccountId, Balance)>, chain_id: u64, genesis_evm_distribution: Vec<(H160, fp_evm::GenesisAccount)>, genesis_substrate_distribution: Vec<(AccountId, Balance)>, claims: Vec<(MultiAddress, Balance)>, _enable_println: bool, ) -> RuntimeGenesisConfig { - const ENDOWMENT: Balance = 10_000_000 * UNIT; - const STASH: Balance = ENDOWMENT / 100; - // stakers: all validators and nominators. let _rng = rand::thread_rng(); // stakers: all validators and nominators. let stakers = initial_authorities .iter() - .map(|x| (x.0.clone(), x.0.clone(), UNIT, StakerStatus::Validator)) + .map(|x| (x.0.clone(), x.0.clone(), STASH, StakerStatus::Validator)) .collect(); let num_endowed_accounts = endowed_accounts.len(); let claims_list: Vec<(MultiAddress, Balance, Option)> = endowed_accounts .iter() - .map(|x| (MultiAddress::Native(x.clone()), ENDOWMENT, Some(StatementKind::Regular))) + .map(|x| (MultiAddress::Native(x.0.clone()), ENDOWMENT, Some(StatementKind::Regular))) .chain(claims.clone().into_iter().map(|(a, b)| (a, b, Some(StatementKind::Regular)))) .collect(); @@ -263,7 +255,7 @@ fn testnet_genesis( .map(|x| { let mut bounded_vec = BoundedVec::new(); bounded_vec.try_push((ENDOWMENT, ENDOWMENT, 0)).unwrap(); - (MultiAddress::Native(x.clone()), bounded_vec) + (MultiAddress::Native(x.0.clone()), bounded_vec) }) .chain(claims.into_iter().map(|(a, b)| { let mut bounded_vec = BoundedVec::new(); @@ -284,7 +276,6 @@ fn testnet_genesis( balances: endowed_accounts .iter() .cloned() - .map(|k| (k, ENDOWMENT)) .chain(genesis_substrate_distribution.iter().cloned().map(|(k, v)| (k, v))) .collect(), }, @@ -317,7 +308,7 @@ fn testnet_genesis( .iter() .take((num_endowed_accounts + 1) / 2) .cloned() - .map(|member| (member, STASH)) + .map(|member| (member.0, STASH)) .collect(), }, treasury: Default::default(), diff --git a/node/src/command.rs b/node/src/command.rs index 9e0173295..447b7f9b0 100644 --- a/node/src/command.rs +++ b/node/src/command.rs @@ -48,7 +48,7 @@ impl IdentifyChain for T { impl SubstrateCli for Cli { fn impl_name() -> String { - "Tangle Substrate Node".into() + "Tangle Node".into() } fn impl_version() -> String { diff --git a/node/src/distributions/develop.rs b/node/src/distributions/develop.rs index f498661d7..20eac9682 100644 --- a/node/src/distributions/develop.rs +++ b/node/src/distributions/develop.rs @@ -1,3 +1,4 @@ +#![allow(dead_code)] // This file is part of Tangle. // Copyright (C) 2022-2024 Webb Technologies Inc. // diff --git a/node/src/distributions/testnet.rs b/node/src/distributions/testnet.rs index 8a87895f0..d4cabaa10 100644 --- a/node/src/distributions/testnet.rs +++ b/node/src/distributions/testnet.rs @@ -1,3 +1,4 @@ +#![allow(dead_code)] // This file is part of Tangle. // Copyright (C) 2022-2024 Webb Technologies Inc. // diff --git a/node/src/testnet_fixtures.rs b/node/src/testnet_fixtures.rs index 6df1b666f..3d61d9451 100644 --- a/node/src/testnet_fixtures.rs +++ b/node/src/testnet_fixtures.rs @@ -25,37 +25,35 @@ use tangle_testnet_runtime::AccountId; /// Testnet root key pub fn get_testnet_root_key() -> AccountId { - // Standalone sudo key: 5CDZpRSZ14TmXorHTsTeksY7223FzsaLXPbpTPBUV6NaZSr1 - hex!["06c225d97d596c57e620aba15e1a8a69c7b334ffdab175788c6553f7dd181a56"].into() + hex!["9c2c928c3b9ac62c6dc4caaf5777c16ce28984dedc92687ef427f8f4f6d61d2f"].into() } /// Standalone alpha bootnodes pub fn get_bootnodes() -> Vec { vec![ - "/ip4/3.22.222.30/tcp/30333/p2p/12D3KooWRdvZ3PRteq8DC78Z3z5ZiehipKrKhHDRpgvCjc8XSeQx" + "/ip4/3.22.222.30/tcp/40333/p2p/12D3KooWRdvZ3PRteq8DC78Z3z5ZiehipKrKhHDRpgvCjc8XSeQx" .parse() .unwrap(), - "/ip4/18.119.14.21/tcp/30333/p2p/12D3KooWJP5NbEjEK1YihofJm3MMSJWrbRWjeEkRf3LtKvkj6mr9" + "/ip4/18.119.14.21/tcp/40333/p2p/12D3KooWJP5NbEjEK1YihofJm3MMSJWrbRWjeEkRf3LtKvkj6mr9" .parse() .unwrap(), - "/ip4/18.188.183.185/tcp/30333/p2p/12D3KooWDL3KiR6CpnEbgUgheje1cMGQtwH4euxGMPQBkwU5cZdu" + "/ip4/18.188.183.185/tcp/40333/p2p/12D3KooWDL3KiR6CpnEbgUgheje1cMGQtwH4euxGMPQBkwU5cZdu" .parse() .unwrap(), - "/ip4/3.137.213.159/tcp/30333/p2p/12D3KooWS4aniCJTz2RiNfNUka8TTa3gXak63FJgdAgfAWLCnsAi" + "/ip4/3.137.213.159/tcp/40333/p2p/12D3KooWS4aniCJTz2RiNfNUka8TTa3gXak63FJgdAgfAWLCnsAi" .parse() .unwrap(), - "/ip4/3.144.191.66/tcp/30333/p2p/12D3KooWM8RYTbVygshTJAbiM5YqvTwWPbZrF8iQ9WS96nEE2Ebr" + "/ip4/3.144.191.66/tcp/40333/p2p/12D3KooWM8RYTbVygshTJAbiM5YqvTwWPbZrF8iQ9WS96nEE2Ebr" .parse() .unwrap(), ] } -/// Standalone initial authorities +/// Tangle testnet authorities pub fn get_initial_authorities() -> Vec<(AccountId, BabeId, GrandpaId, ImOnlineId, RoleKeyId)> { vec![ - // standalone 1 + // tangle-testnet 1 ( - // hex!["d4c197403bae729fd0f219a0925c4f9274d432c7bfce5f94f2e0dae605dde407"].into(), hex!["6c99e8e4ae3fe7e3328d7e9d85eb98e86bdc6410695797349fa536ebb9bb0a4a"].into(), hex!["d8a00a2454cd7455c040e363e6e76f4abd9e4d3876253964d9f40a66ad79694b"] .unchecked_into(), @@ -63,12 +61,11 @@ pub fn get_initial_authorities() -> Vec<(AccountId, BabeId, GrandpaId, ImOnlineI .unchecked_into(), hex!["0297bc051d94b25787482e60fa4eba19f15af30fa244240ae4439d219ee00e78"] .unchecked_into(), - hex!["000000000000000000000000000000000000000000000000000000000000000000"] + hex!["02a1af3c93d94e9b658a9aaa994bfa3fc156c9d38c60872d3dd33f63cd7aa12a6b"] .unchecked_into(), ), - // standalone 2 + // tangle-testnet 2 ( - // hex!["48a705897c103ddeda7e38bdadb42dc4c429e1b542287dfb07a9837982e04d14"].into(), hex!["444dbfd0220eb1a993a7a2b9e1530aee1d17388ba3db34a0ee2b8ff971bfd073"].into(), hex!["f02ee9baa32c490cf06eabe3580a90be704618f04636b321ee599c8912392c7a"] .unchecked_into(), @@ -76,12 +73,11 @@ pub fn get_initial_authorities() -> Vec<(AccountId, BabeId, GrandpaId, ImOnlineI .unchecked_into(), hex!["de6d5010678fd2175fe70c857d3eba80838e3735b1051f4aed98671800ec483f"] .unchecked_into(), - hex!["000000000000000000000000000000000000000000000000000000000000000000"] + hex!["0305c8dd5a251ed604350f50a993edc9baa66fb72b56091346316dd94052a068fa"] .unchecked_into(), ), - // standalone 3 + // tangle-testnet 3 ( - // hex!["e2629eedccc6887f78d62d4ed15becd1b791ba0c38a5c72ccd416367097d7c3c"].into(), hex!["2c4e648b0fbbb88ff6b92b208273eb144383b2b19edc992e91448a4371d4d97d"].into(), hex!["a41b35f75e5509ce96e62bc27bb9a1b5587cc3d596f8afa867962b0e03230513"] .unchecked_into(), @@ -89,12 +85,11 @@ pub fn get_initial_authorities() -> Vec<(AccountId, BabeId, GrandpaId, ImOnlineI .unchecked_into(), hex!["8472336050c4e4a51ac69865a4a31c6dd0e5c2f79555d8646cafb3bd8f12d75c"] .unchecked_into(), - hex!["000000000000000000000000000000000000000000000000000000000000000000"] + hex!["02825faaf113b15b28dfdfe52eeee66554fe2892825e146d20ac49dd7c37d6e793"] .unchecked_into(), ), - // standalone 4 + // tangle-testnet 4 ( - // hex!["3281b9311756ee35e8bd53bc05e38af78ea4211c72db0ffcd8dd317785fa1327"].into(), hex!["c884c8eb280327221a3ae6a45fe6c8805f09bcfc11b409c8e2daa621c0d99608"].into(), hex!["06e0a0d39503a101ca9c36f84b3ccf53015ee625a546bc570e550af963d13164"] .unchecked_into(), @@ -102,12 +97,11 @@ pub fn get_initial_authorities() -> Vec<(AccountId, BabeId, GrandpaId, ImOnlineI .unchecked_into(), hex!["029cb182ddb9c5560aaa299f7b445e575007b8295bd85a80a7b2eb7baa3e2b7c"] .unchecked_into(), - hex!["000000000000000000000000000000000000000000000000000000000000000000"] + hex!["02745849fbb4cf0f1f9f310cf67740431fd4cd1b4292bb1a3efeb93956e612e75f"] .unchecked_into(), ), - // standalone 5 + // tangle-testnet 5 ( - // hex!["34d06ae4117b82a936b81d5219a438fa7b4093a6b67ebb0899686fb4e3b79b55"].into(), hex!["483e0b8d6801c51115fd4b124c91e2d5dcd642b30335f6c5a1738ea18f66c251"].into(), hex!["ce80df4851003f6ffd4ee88d9be85966f1de8b2e494c009dbf336177485f023f"] .unchecked_into(), @@ -115,7 +109,7 @@ pub fn get_initial_authorities() -> Vec<(AccountId, BabeId, GrandpaId, ImOnlineI .unchecked_into(), hex!["1ea007d87f91f96c31b1062548eb77c40d47a43f1c84c36caa8586fc7c359729"] .unchecked_into(), - hex!["000000000000000000000000000000000000000000000000000000000000000000"] + hex!["03dd29b916c41662207e2e5b7dd7c5c7054681bef8897bd4f0634b9075463159ca"] .unchecked_into(), ), ] diff --git a/primitives/src/lib.rs b/primitives/src/lib.rs index 1d6e59ae4..68b24974b 100644 --- a/primitives/src/lib.rs +++ b/primitives/src/lib.rs @@ -61,7 +61,7 @@ pub mod time { // NOTE: Currently it is not possible to change the epoch duration after the chain has started. // Attempting to do so will brick block production. - pub const EPOCH_DURATION_IN_BLOCKS: BlockNumber = 10 * MINUTES; + pub const EPOCH_DURATION_IN_BLOCKS: BlockNumber = 4 * HOURS; pub const EPOCH_DURATION_IN_SLOTS: u64 = { const SLOT_FILL_RATE: f64 = MILLISECS_PER_BLOCK as f64 / SLOT_DURATION as f64; diff --git a/runtime/mainnet/src/lib.rs b/runtime/mainnet/src/lib.rs index 4582bc05a..914f52eac 100644 --- a/runtime/mainnet/src/lib.rs +++ b/runtime/mainnet/src/lib.rs @@ -397,12 +397,16 @@ impl pallet_session::historical::Config for Runtime { type FullIdentificationOf = pallet_staking::ExposureOf; } +// Staking reward curve, more details at +// https://docs.rs/pallet-staking-reward-curve/latest/pallet_staking_reward_curve/macro.build.html +// We are aiming for a max inflation of 5%, when 60% of tokens are staked +// In practical sense, our reward rate will fluctuate between 2.5%-5% since the staked token count +// varies pallet_staking_reward_curve::build! { const REWARD_CURVE: PiecewiseLinear<'static> = curve!( - min_inflation: 0_040_000, - max_inflation: 0_050_000, - // 60% of total issuance at a yearly inflation rate of 5% - ideal_stake: 0_600_000, + min_inflation: 0_025_000, // min inflation of 2.5% + max_inflation: 0_050_000, // max inflation of 5% (acheived only at ideal stake) + ideal_stake: 0_600_000, // ideal stake (60% of total supply) falloff: 0_050_000, max_piece_count: 40, test_precision: 0_005_000, @@ -410,9 +414,12 @@ pallet_staking_reward_curve::build! { } parameter_types! { - pub const SessionsPerEra: sp_staking::SessionIndex = 1; - pub const BondingDuration: sp_staking::EraIndex = 24 * 28; - pub const SlashDeferDuration: sp_staking::EraIndex = 24 * 7; // 1/4 the bonding duration. + // Six sessions in an era (24 hours). + pub const SessionsPerEra: sp_staking::SessionIndex = 6; + // 28 eras for unbonding (28 days). + pub const BondingDuration: sp_staking::EraIndex = 28; + // 28 eras for slash defer duration (28 days). + pub const SlashDeferDuration: sp_staking::EraIndex = 28; pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE; pub const MaxNominatorRewardedPerValidator: u32 = 256; pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(17); diff --git a/runtime/testnet/src/lib.rs b/runtime/testnet/src/lib.rs index 815eaa1c3..c2d053dac 100644 --- a/runtime/testnet/src/lib.rs +++ b/runtime/testnet/src/lib.rs @@ -157,7 +157,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("tangle-testnet"), impl_name: create_runtime_str!("tangle-testnet"), authoring_version: 1, - spec_version: 1000, // v1.0.00 + spec_version: 600, // v0.6.00 impl_version: 1, apis: RUNTIME_API_VERSIONS, transaction_version: 1, @@ -413,12 +413,16 @@ impl pallet_session::historical::Config for Runtime { type FullIdentificationOf = pallet_staking::ExposureOf; } +// Staking reward curve, more details at +// https://docs.rs/pallet-staking-reward-curve/latest/pallet_staking_reward_curve/macro.build.html +// We are aiming for a max inflation of 5%, when 60% of tokens are staked +// In practical sense, our reward rate will fluctuate between 2.5%-5% since the staked token count +// varies pallet_staking_reward_curve::build! { const REWARD_CURVE: PiecewiseLinear<'static> = curve!( - min_inflation: 0_040_000, - max_inflation: 0_050_000, - // 60% of total issuance at a yearly inflation rate of 5% - ideal_stake: 0_600_000, + min_inflation: 0_025_000, // min inflation of 2.5% + max_inflation: 0_050_000, // max inflation of 5% (acheived only at ideal stake) + ideal_stake: 0_600_000, // ideal stake (60% of total supply) falloff: 0_050_000, max_piece_count: 40, test_precision: 0_005_000, @@ -426,9 +430,12 @@ pallet_staking_reward_curve::build! { } parameter_types! { - pub const SessionsPerEra: sp_staking::SessionIndex = 1; - pub const BondingDuration: sp_staking::EraIndex = 24 * 28; - pub const SlashDeferDuration: sp_staking::EraIndex = 24 * 7; // 1/4 the bonding duration. + // Six sessions in an era (24 hours). + pub const SessionsPerEra: sp_staking::SessionIndex = 6; + // 28 eras for unbonding (28 days). + pub const BondingDuration: sp_staking::EraIndex = 28; + // 28 eras for slash defer duration (28 days). + pub const SlashDeferDuration: sp_staking::EraIndex = 28; pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE; pub const MaxNominatorRewardedPerValidator: u32 = 256; pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(17);