make fee calculations correct based on nanoseconds
Signed-off-by: Uncle Stinky <uncle.stinky@ghostchain.io>
This commit is contained in:
parent
ffa65dc0a7
commit
99ac2f1f08
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "casper-runtime-constants"
|
||||
version = "0.4.0"
|
||||
version = "0.4.1"
|
||||
authors.workspace = true
|
||||
edition.workspace = true
|
||||
homepage.workspace = true
|
||||
|
||||
@ -39,7 +39,7 @@ pub mod time {
|
||||
|
||||
// 1 in 4 blocks (on average, not counting collisions) woll be primary babe
|
||||
// blocks.The choice of is done on accordance to the slot duration and expected
|
||||
// target block tim, for safely resisting network delays of maximum two
|
||||
// target block time, for safely resisting network delays of maximum two
|
||||
// seconds.
|
||||
pub const PRIMARY_PROBABILITY: (u64, u64) = (1, 4);
|
||||
}
|
||||
@ -69,7 +69,7 @@ pub mod fee {
|
||||
type Balance = Balance;
|
||||
|
||||
fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {
|
||||
let fee_per_nanosecond: Balance = 10 * super::currency::FTSO;
|
||||
let fee_per_nanosecond: Balance = (10 * super::currency::FTSO) / 1_000;
|
||||
|
||||
smallvec![WeightToFeeCoefficient {
|
||||
degree: 1,
|
||||
@ -84,7 +84,7 @@ pub mod fee {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::{
|
||||
currency::{CSPR, STNK, STRH},
|
||||
currency::{CSPR, STRH},
|
||||
fee::WeightToFee,
|
||||
};
|
||||
use crate::weights::ExtrinsicBaseWeight;
|
||||
@ -94,8 +94,8 @@ mod tests {
|
||||
#[test]
|
||||
fn full_block_fee_is_correct() {
|
||||
let full_block = WeightToFee::weight_to_fee(&MAXIMUM_BLOCK_WEIGHT);
|
||||
assert!(full_block >= 50 * CSPR);
|
||||
assert!(full_block <= 70 * CSPR);
|
||||
assert!(full_block >= 30 * CSPR);
|
||||
assert!(full_block <= 50 * CSPR);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -103,7 +103,7 @@ mod tests {
|
||||
let x = WeightToFee::weight_to_fee(&ExtrinsicBaseWeight::get());
|
||||
|
||||
let lower_bound = STRH / 2;
|
||||
let upper_bound = (3 * STRH) / 2;
|
||||
let upper_bound = 6 * STRH;
|
||||
|
||||
assert!(x >= lower_bound);
|
||||
assert!(x <= upper_bound);
|
||||
|
||||
@ -7,15 +7,15 @@
|
||||
|
||||
// Ghost Network is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Ghost Network. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
|
||||
//! DATE: 2024-07-30 (Y/M/D)
|
||||
//! HOSTNAME: `ghostown`, CPU: `Intel(R) Core(TM) i3-2310M CPU @ 2.10GHz`
|
||||
//! DATE: 2026-08-31 (Y/M/D)
|
||||
//! HOSTNAME: `LAPTOP-IOUQRLAP`, CPU: `AMD Ryzen 7 2700U with Radeon Vega Mobile Gfx`
|
||||
//!
|
||||
//! SHORT-NAME: `block`, LONG-NAME: `BlockExecution`, RUNTIME: `Development`
|
||||
//! WARMUPS: `10`, REPEAT: `100`
|
||||
@ -37,43 +37,43 @@ use sp_core::parameter_types;
|
||||
use sp_weights::{constants::WEIGHT_REF_TIME_PER_NANOS, Weight};
|
||||
|
||||
parameter_types! {
|
||||
/// Time to execute an empty block.
|
||||
/// Calculated by multiplying the *Average* with `1.0` and adding `0`.
|
||||
///
|
||||
/// Stats nanoseconds:
|
||||
/// Min, Max: 64_363_191, 66_078_314
|
||||
/// Average: 64_551_214
|
||||
/// Median: 64_500_078
|
||||
/// Std-Dev: 229678.99
|
||||
///
|
||||
/// Percentiles nanoseconds:
|
||||
/// 99th: 65_668_012
|
||||
/// 95th: 64_888_421
|
||||
/// 75th: 64_563_448
|
||||
pub const BlockExecutionWeight: Weight =
|
||||
Weight::from_parts(WEIGHT_REF_TIME_PER_NANOS.saturating_mul(64_551_214), 0);
|
||||
/// Time to execute an empty block.
|
||||
/// Calculated by multiplying the *Average* with `1.0` and adding `0`.
|
||||
///
|
||||
/// Stats nanoseconds:
|
||||
/// Min, Max: 553_400, 1_996_400
|
||||
/// Average: 771_526
|
||||
/// Median: 680_500
|
||||
/// Std-Dev: 248209.17
|
||||
///
|
||||
/// Percentiles nanoseconds:
|
||||
/// 99th: 1_652_700
|
||||
/// 95th: 1_212_900
|
||||
/// 75th: 849_300
|
||||
pub const BlockExecutionWeight: Weight =
|
||||
Weight::from_parts(WEIGHT_REF_TIME_PER_NANOS.saturating_mul(771_526), 0);
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test_weights {
|
||||
use sp_weights::constants;
|
||||
use sp_weights::constants;
|
||||
|
||||
/// Checks that the weight exists and is sane.
|
||||
// NOTE: If this test fails but you are sure that the generated values are fine,
|
||||
// you can delete it.
|
||||
#[test]
|
||||
fn sane() {
|
||||
let w = super::BlockExecutionWeight::get();
|
||||
/// Checks that the weight exists and is sane.
|
||||
// NOTE: If this test fails but you are sure that the generated values are fine,
|
||||
// you can delete it.
|
||||
#[test]
|
||||
fn sane() {
|
||||
let w = super::BlockExecutionWeight::get();
|
||||
|
||||
// At least 100 µs.
|
||||
assert!(
|
||||
w.ref_time() >= 100u64 * constants::WEIGHT_REF_TIME_PER_MICROS,
|
||||
"Weight should be at least 100 µs."
|
||||
);
|
||||
// At most 50 ms.
|
||||
assert!(
|
||||
w.ref_time() <= 50u64 * constants::WEIGHT_REF_TIME_PER_MILLIS,
|
||||
"Weight should be at most 50 ms."
|
||||
);
|
||||
}
|
||||
// At least 100 µs.
|
||||
assert!(
|
||||
w.ref_time() >= 100u64 * constants::WEIGHT_REF_TIME_PER_MICROS,
|
||||
"Weight should be at least 100 µs."
|
||||
);
|
||||
// At most 50 ms.
|
||||
assert!(
|
||||
w.ref_time() <= 50u64 * constants::WEIGHT_REF_TIME_PER_MILLIS,
|
||||
"Weight should be at most 50 ms."
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user