From 98de9373dd4656f506fdc3dea70611b0fe7afc7f Mon Sep 17 00:00:00 2001 From: Uncle Stinky Date: Wed, 2 Sep 2026 03:11:15 +0300 Subject: [PATCH] make runtime more legit for real use case; make genesis file cleaner Signed-off-by: Uncle Stinky --- runtime/casper/Cargo.toml | 2 +- runtime/casper/src/genesis_config_presets.rs | 41 +++++++++++++------- runtime/casper/src/lib.rs | 26 ++++++------- 3 files changed, 41 insertions(+), 28 deletions(-) diff --git a/runtime/casper/Cargo.toml b/runtime/casper/Cargo.toml index 8a2c452..cb290b6 100644 --- a/runtime/casper/Cargo.toml +++ b/runtime/casper/Cargo.toml @@ -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 diff --git a/runtime/casper/src/genesis_config_presets.rs b/runtime/casper/src/genesis_config_presets.rs index 90d752a..096a0a7 100644 --- a/runtime/casper/src/genesis_config_presets.rs +++ b/runtime/casper/src/genesis_config_presets.rs @@ -221,8 +221,8 @@ fn casper_testnet_networks() -> Vec> { .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>, initial_claims: Vec>, ) -> 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::>(), }, "session": { @@ -258,25 +259,39 @@ pub fn testnet_config_genesis( .collect::>(), }, "staking": { - "validatorCount": initial_authorities.len() as u32, - "minimumValidatorCount": 4, - "invulnerables": initial_authorities - .iter() - .map(|x| x.stash.clone()) - .collect::>(), + // "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::::Validator, )) .collect::>(), }, "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 }, diff --git a/runtime/casper/src/lib.rs b/runtime/casper/src/lib.rs index 4377076..00f81e4 100644 --- a/runtime/casper/src/lib.rs +++ b/runtime/casper/src/lib.rs @@ -242,8 +242,8 @@ impl pallet_babe::Config for Runtime { type DisabledValidators = Session; type WeightInfo = weights::pallet_babe::WeightInfo; - type MaxAuthorities = MaxAuthorities; - type MaxNominators = MaxNominators; + type MaxAuthorities = MaxActiveValidators; + type MaxNominators = MaxElectingVoters; type KeyOwnerProof = >::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; - type MaxAuthorities = MaxAuthorities; - type MaxNominators = MaxNominators; + type MaxAuthorities = MaxActiveValidators; + type MaxNominators = MaxElectingVoters; type MaxSetIdSessionEntries = MaxSetIdSessionEntries; type KeyOwnerProof = >::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| { ::WeightInfo::submit_unsigned( active,