fix weights calculations
Signed-off-by: Uncle Stinky <uncle.stinky@ghostchain.io>
This commit is contained in:
parent
98de9373dd
commit
613b09ac6a
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "casper-runtime-constants"
|
name = "casper-runtime-constants"
|
||||||
version = "0.4.1"
|
version = "0.4.2"
|
||||||
authors.workspace = true
|
authors.workspace = true
|
||||||
edition.workspace = true
|
edition.workspace = true
|
||||||
homepage.workspace = true
|
homepage.workspace = true
|
||||||
|
|||||||
@ -15,10 +15,10 @@ pub mod currency {
|
|||||||
pub const CSPR: Balance = 1_000 * STRH; // 10^18
|
pub const CSPR: Balance = 1_000 * STRH; // 10^18
|
||||||
|
|
||||||
/// The existential deposit.
|
/// 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 {
|
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;
|
type Balance = Balance;
|
||||||
|
|
||||||
fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {
|
fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {
|
||||||
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 {
|
smallvec![WeightToFeeCoefficient {
|
||||||
degree: 1,
|
degree: 1,
|
||||||
@ -84,7 +84,7 @@ pub mod fee {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::{
|
use super::{
|
||||||
currency::{CSPR, STRH},
|
currency::{CSPR, STNK},
|
||||||
fee::WeightToFee,
|
fee::WeightToFee,
|
||||||
};
|
};
|
||||||
use crate::weights::ExtrinsicBaseWeight;
|
use crate::weights::ExtrinsicBaseWeight;
|
||||||
@ -94,18 +94,22 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn full_block_fee_is_correct() {
|
fn full_block_fee_is_correct() {
|
||||||
let full_block = WeightToFee::weight_to_fee(&MAXIMUM_BLOCK_WEIGHT);
|
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]
|
#[test]
|
||||||
fn extrinsic_base_fee_is_correct() {
|
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 lower_bound = 100 * STNK;
|
||||||
let upper_bound = 6 * STRH;
|
let upper_bound = 300 * STNK;
|
||||||
|
|
||||||
assert!(x >= lower_bound);
|
assert!(ext_weight >= lower_bound);
|
||||||
assert!(x <= upper_bound);
|
assert!(ext_weight <= upper_bound);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user