From 613b09ac6aec01cbdd2b97a08023cf5e5477341f Mon Sep 17 00:00:00 2001 From: Uncle Stinky Date: Wed, 2 Sep 2026 03:13:11 +0300 Subject: [PATCH] fix weights calculations Signed-off-by: Uncle Stinky --- runtime/casper/constants/Cargo.toml | 2 +- runtime/casper/constants/src/lib.rs | 26 +++++++++++++++----------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/runtime/casper/constants/Cargo.toml b/runtime/casper/constants/Cargo.toml index afbf7e7..b1fdd3b 100644 --- a/runtime/casper/constants/Cargo.toml +++ b/runtime/casper/constants/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "casper-runtime-constants" -version = "0.4.1" +version = "0.4.2" authors.workspace = true edition.workspace = true homepage.workspace = true diff --git a/runtime/casper/constants/src/lib.rs b/runtime/casper/constants/src/lib.rs index d6b2149..a84a8e7 100644 --- a/runtime/casper/constants/src/lib.rs +++ b/runtime/casper/constants/src/lib.rs @@ -15,10 +15,10 @@ pub mod currency { pub const CSPR: Balance = 1_000 * STRH; // 10^18 /// The existential deposit. - pub const EXISTENTIAL_DEPOSIT: Balance = STNK; + pub const EXISTENTIAL_DEPOSIT: Balance = 500 * STNK; pub const fn deposit(items: u32, bytes: u32) -> Balance { - (items as Balance) * 20 * STRH + (bytes as Balance) * 200 * STNK + (items as Balance) * 2 * STRH + (bytes as Balance) * 200 * STNK } } @@ -69,7 +69,7 @@ pub mod fee { type Balance = Balance; fn polynomial() -> WeightToFeeCoefficients { - let fee_per_nanosecond: Balance = (10 * super::currency::FTSO) / 1_000; + let fee_per_nanosecond: Balance = (424 * super::currency::FTSO) / 1_200_000; smallvec![WeightToFeeCoefficient { degree: 1, @@ -84,7 +84,7 @@ pub mod fee { #[cfg(test)] mod tests { use super::{ - currency::{CSPR, STRH}, + currency::{CSPR, STNK}, fee::WeightToFee, }; use crate::weights::ExtrinsicBaseWeight; @@ -94,18 +94,22 @@ mod tests { #[test] fn full_block_fee_is_correct() { let full_block = WeightToFee::weight_to_fee(&MAXIMUM_BLOCK_WEIGHT); - assert!(full_block >= 30 * CSPR); - assert!(full_block <= 50 * CSPR); + + let lower_bound = 1 * CSPR; + let upper_bound = 2 * CSPR; + + assert!(full_block >= lower_bound); + assert!(full_block <= upper_bound); } #[test] fn extrinsic_base_fee_is_correct() { - let x = WeightToFee::weight_to_fee(&ExtrinsicBaseWeight::get()); + let ext_weight = WeightToFee::weight_to_fee(&ExtrinsicBaseWeight::get()); - let lower_bound = STRH / 2; - let upper_bound = 6 * STRH; + let lower_bound = 100 * STNK; + let upper_bound = 300 * STNK; - assert!(x >= lower_bound); - assert!(x <= upper_bound); + assert!(ext_weight >= lower_bound); + assert!(ext_weight <= upper_bound); } }