make runtime more legit for real use case; make genesis file cleaner

Signed-off-by: Uncle Stinky <uncle.stinky@ghostchain.io>
This commit is contained in:
Uncle Stinky 2026-09-02 03:11:15 +03:00
parent 882ec7ec0d
commit 98de9373dd
Signed by: st1nky
GPG Key ID: 016064BD97603B40
3 changed files with 41 additions and 28 deletions

View File

@ -1,6 +1,6 @@
[package]
name = "casper-runtime"
version = "4.0.1"
version = "4.0.2"
build = "build.rs"
description = "Runtime of the Casper Network"
edition.workspace = true

View File

@ -221,8 +221,8 @@ fn casper_testnet_networks() -> Vec<NetworkInitiation<NetworkId, Balance>> {
.with_finality_delay(69)
.with_rate_limit_delay(5_000)
.with_block_deviation(420)
.with_incoming_fee(69_000_000u32)
.with_outgoing_fee(69_000_000u32)
.with_incoming_share(69_000_000u32)
.with_outgoing_share(69_000_000u32)
.build()
)
.build()
@ -235,8 +235,9 @@ pub fn testnet_config_genesis(
initial_networks: Vec<NetworkInitiation<NetworkId, Balance>>,
initial_claims: Vec<NetworkClaim<NetworkId, Balance>>,
) -> serde_json::Value {
const ENDOWMENT: u128 = 31 * CSPR;
const STASH: u128 = 69 * CSPR;
const ENDOWMENT: u128 = 31 * CSPR;
const STASH_BOND: u128 = 68 * CSPR;
const STASH_FEES: u128 = 1 * CSPR;
let sudo = initial_authorities.first().map(|x| x.account.clone()).unwrap();
@ -246,7 +247,7 @@ pub fn testnet_config_genesis(
.iter()
.map(|x| (x.account.clone(), x.balance))
.chain(initial_authorities.iter().map(|x| (x.account.clone(), ENDOWMENT)))
.chain(initial_authorities.iter().map(|x| (x.stash.clone(), STASH)))
.chain(initial_authorities.iter().map(|x| (x.stash.clone(), STASH_BOND + STASH_FEES)))
.collect::<Vec<_>>(),
},
"session": {
@ -258,25 +259,39 @@ pub fn testnet_config_genesis(
.collect::<Vec<_>>(),
},
"staking": {
"validatorCount": initial_authorities.len() as u32,
"minimumValidatorCount": 4,
"invulnerables": initial_authorities
.iter()
.map(|x| x.stash.clone())
.collect::<Vec<_>>(),
// "minNominatorBond": 42 * CSPR,
// "minValidatorBond": 6900 * STRH,
// "maxNominatorsCount": 3000u32,
// "maxValidatorsCount": 500u32,
"minimumValidatorCount": if cfg!(feature = "runtime-benchmarks") {
1u32
} else {
4u32
},
// "validatorCount": 50u32,
"forceEra": Forcing::NotForcing,
"slashRewardFraction": Perbill::from_percent(10),
// "slashRewardFraction": Perbill::from_percent(10),
"stakers": initial_authorities
.iter()
.map(|x| (
x.stash.clone(),
x.stash.clone(),
STASH,
STASH_BOND,
StakerStatus::<AccountId>::Validator,
))
.collect::<Vec<_>>(),
},
"babe": { "epochConfig": Some(crate::BABE_GENESIS_EPOCH_CONFIG) },
// "ghostNominationPools": {
// "minJoinBond": 10 * STNK,
// "minCreateBond": 20 * CSPR,
// "maxPools": 256u32,
// "maxMembersPerPool": 1024u32,
// "maxMembers": 20000u32,
// "globalMaxCommission": Perbill::from_percent(15),
// },
"ghostSudo": { "key": sudo },
"ghostNetworks": { "networks": initial_networks },
"ghostGovernance": { "networkClaims": initial_claims },

View File

@ -242,8 +242,8 @@ impl pallet_babe::Config for Runtime {
type DisabledValidators = Session;
type WeightInfo = weights::pallet_babe::WeightInfo<Runtime>;
type MaxAuthorities = MaxAuthorities;
type MaxNominators = MaxNominators;
type MaxAuthorities = MaxActiveValidators;
type MaxNominators = MaxElectingVoters;
type KeyOwnerProof =
<Historical as KeyOwnerProofSystem<(KeyTypeId, pallet_babe::AuthorityId)>>::Proof;
@ -343,9 +343,9 @@ parameter_types! {
// 4 hour session, 1 hour unsigned phase, 32 ofchain executions.
pub OffchainRepeat: BlockNumber = UnsignedPhase::get() / 32;
pub const MaxElectingVoters: u32 = 5_000;
pub const MaxElectableTargets: u32 = 1500;
pub const MaxActiveValidators: u32 = 1_000;
pub const MaxElectingVoters: u32 = 3_000;
pub const MaxElectableTargets: u32 = 400;
pub const MaxActiveValidators: u32 = 300;
// ... and all of the validators as electable targets. Whilist this is the
// case, we cannot and shall increase the size of the validator intentions.
@ -553,8 +553,6 @@ parameter_types! {
pub const DataDepositPerByte: Balance = 1 * STRH;
pub const MaxApprovals: u32 = 10;
pub const MaxAuthorities: u32 = 1_500;
pub const MaxNominators: u32 = 10_000;
}
#[cfg(not(feature = "runtime-benchmarks"))]
@ -648,7 +646,7 @@ impl pallet_offences::Config for Runtime {
}
impl pallet_authority_discovery::Config for Runtime {
type MaxAuthorities = MaxAuthorities;
type MaxAuthorities = MaxActiveValidators;
}
parameter_types! {
@ -665,8 +663,8 @@ impl pallet_grandpa::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type WeightInfo = weights::pallet_grandpa::WeightInfo<Runtime>;
type MaxAuthorities = MaxAuthorities;
type MaxNominators = MaxNominators;
type MaxAuthorities = MaxActiveValidators;
type MaxNominators = MaxElectingVoters;
type MaxSetIdSessionEntries = MaxSetIdSessionEntries;
type KeyOwnerProof = <Historical as KeyOwnerProofSystem<(KeyTypeId, GrandpaId)>>::Proof;
@ -1540,11 +1538,11 @@ mod test_fees {
fn nominator_limit() {
use pallet_election_provider_multi_phase::WeightInfo;
// starting point of the nominators.
let target_voters: u32 = 50_000;
let target_voters: u32 = 3_000;
// assuming we want around 5k candidates and 1k active validators. (March 31, 2021)
let all_targets: u32 = 5_000;
let desired: u32 = 1_000;
// assuming we want around 3k candidates and 300 active validators.
let all_targets: u32 = 400;
let desired: u32 = 300;
let weight_with = |active| {
<Runtime as pallet_election_provider_multi_phase::Config>::WeightInfo::submit_unsigned(
active,