mirror of
https://git.ghostchain.io/proxmio/ghost-node.git
synced 2025-12-27 11:19:57 +00:00
inital commit, which is clearly not initial
Signed-off-by: Uncle Stretch <uncle.stretch@ghostchain.io>
This commit is contained in:
110
runtime/casper/constants/src/lib.rs
Executable file
110
runtime/casper/constants/src/lib.rs
Executable file
@@ -0,0 +1,110 @@
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
pub mod weights;
|
||||
|
||||
pub use self::currency::CSPR;
|
||||
|
||||
/// Monetary constants.
|
||||
pub mod currency {
|
||||
use primitives::Balance;
|
||||
|
||||
/// Constant values used within runtime.
|
||||
pub const FTSO: Balance = 1_000_000_000; // 10^9
|
||||
pub const STNK: Balance = 1_000 * FTSO; // 10^12
|
||||
pub const STRH: Balance = 1_000 * STNK; // 10^15
|
||||
pub const CSPR: Balance = 1_000 * STRH; // 10^18
|
||||
|
||||
/// The existential deposit.
|
||||
pub const EXISTENTIAL_DEPOSIT: Balance = STNK;
|
||||
|
||||
pub const fn deposit(items: u32, bytes: u32) -> Balance {
|
||||
(items as Balance) * 200 * STRH + (bytes as Balance) * 1000 * STNK
|
||||
}
|
||||
}
|
||||
|
||||
/// Time and blocks.
|
||||
pub mod time {
|
||||
use primitives::{BlockNumber, Moment};
|
||||
use runtime_common::prod_or_fast;
|
||||
|
||||
pub const MILLISECS_PER_BLOCK: Moment = 6_000;
|
||||
pub const SLOT_DURATION: Moment = MILLISECS_PER_BLOCK;
|
||||
pub const EPOCH_DURATION_IN_SLOTS: BlockNumber = prod_or_fast!(4 * HOURS, 1 * MINUTES);
|
||||
|
||||
// These time units are defined in number of blocks.
|
||||
pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber);
|
||||
pub const HOURS: BlockNumber = MINUTES * 60;
|
||||
pub const DAYS: BlockNumber = HOURS * 24;
|
||||
pub const WEEKS: BlockNumber = DAYS * 7;
|
||||
|
||||
// 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
|
||||
// seconds.
|
||||
pub const PRIMARY_PROBABILITY: (u64, u64) = (1, 4);
|
||||
}
|
||||
|
||||
/// Fee-related.
|
||||
pub mod fee {
|
||||
use crate::weights::ExtrinsicBaseWeight;
|
||||
use frame_support::weights::{
|
||||
WeightToFeeCoefficient, WeightToFeeCoefficients, WeightToFeePolynomial,
|
||||
};
|
||||
use primitives::Balance;
|
||||
use smallvec::smallvec;
|
||||
pub use sp_runtime::Perbill;
|
||||
|
||||
/// The block saturation level. Fees will be updates based on this value.
|
||||
pub const TARGET_BLOCK_FULLNESS: Perbill = Perbill::from_percent(25);
|
||||
|
||||
/// Handles converting a weight scalar to a fee value, based on the scale
|
||||
/// and granularity of the node's balance type.
|
||||
///
|
||||
/// This should typically create a mapping between the following ranges:
|
||||
/// - [0, `MAXIMUM_BLOCK_WEIGHT`]
|
||||
/// - [Balance::min, Balance::max]
|
||||
///
|
||||
/// Yet, it can be used for any other sort of change to weight-fee.
|
||||
pub struct WeightToFee;
|
||||
impl WeightToFeePolynomial for WeightToFee {
|
||||
type Balance = Balance;
|
||||
|
||||
fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {
|
||||
let p = super::currency::STRH;
|
||||
let q = 100 * Balance::from(ExtrinsicBaseWeight::get().ref_time());
|
||||
|
||||
smallvec![WeightToFeeCoefficient {
|
||||
degree: 1,
|
||||
negative: false,
|
||||
coeff_frac: Perbill::from_rational(p % q, q),
|
||||
coeff_integer: p / q,
|
||||
}]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::{
|
||||
currency::{STNK, STRH, CSPR},
|
||||
fee::WeightToFee,
|
||||
};
|
||||
use crate::weights::ExtrinsicBaseWeight;
|
||||
use frame_support::weights::WeightToFee as WeightToFeeT;
|
||||
use runtime_common::MAXIMUM_BLOCK_WEIGHT;
|
||||
|
||||
#[test]
|
||||
fn full_block_fee_is_correct() {
|
||||
let full_block = WeightToFee::weight_to_fee(&MAXIMUM_BLOCK_WEIGHT);
|
||||
assert!(full_block >= 10 * CSPR);
|
||||
assert!(full_block <= 100 * CSPR);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn extrinsic_base_fee_is_correct() {
|
||||
println!("Base: {}", ExtrinsicBaseWeight::get());
|
||||
let x = WeightToFee::weight_to_fee(&ExtrinsicBaseWeight::get());
|
||||
let y = STNK / 10;
|
||||
assert!(x.max(y) - x.min(y) < STRH);
|
||||
}
|
||||
}
|
||||
79
runtime/casper/constants/src/weights/block_weights.rs
Normal file
79
runtime/casper/constants/src/weights/block_weights.rs
Normal file
@@ -0,0 +1,79 @@
|
||||
// This file is part of Ghost Network.
|
||||
|
||||
// Ghost Network is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// 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
|
||||
// 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`
|
||||
//!
|
||||
//! SHORT-NAME: `block`, LONG-NAME: `BlockExecution`, RUNTIME: `Development`
|
||||
//! WARMUPS: `10`, REPEAT: `100`
|
||||
//! WEIGHT-PATH: `./runtime/casper/constants/src/weights/`
|
||||
//! WEIGHT-METRIC: `Average`, WEIGHT-MUL: `1.0`, WEIGHT-ADD: `0`
|
||||
|
||||
// Executed Command:
|
||||
// ./target/release/ghost
|
||||
// benchmark
|
||||
// overhead
|
||||
// --chain=casper-dev
|
||||
// --wasm-execution=compiled
|
||||
// --weight-path=./runtime/casper/constants/src/weights/
|
||||
// --header=./file_header.txt
|
||||
// --warmup=10
|
||||
// --repeat=100
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test_weights {
|
||||
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();
|
||||
|
||||
// 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."
|
||||
);
|
||||
}
|
||||
}
|
||||
79
runtime/casper/constants/src/weights/extrinsic_weights.rs
Normal file
79
runtime/casper/constants/src/weights/extrinsic_weights.rs
Normal file
@@ -0,0 +1,79 @@
|
||||
// This file is part of Ghost Network.
|
||||
|
||||
// Ghost Network is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// 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
|
||||
// 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`
|
||||
//!
|
||||
//! SHORT-NAME: `extrinsic`, LONG-NAME: `ExtrinsicBase`, RUNTIME: `Development`
|
||||
//! WARMUPS: `10`, REPEAT: `100`
|
||||
//! WEIGHT-PATH: `./runtime/casper/constants/src/weights/`
|
||||
//! WEIGHT-METRIC: `Average`, WEIGHT-MUL: `1.0`, WEIGHT-ADD: `0`
|
||||
|
||||
// Executed Command:
|
||||
// ./target/release/ghost
|
||||
// benchmark
|
||||
// overhead
|
||||
// --chain=casper-dev
|
||||
// --wasm-execution=compiled
|
||||
// --weight-path=./runtime/casper/constants/src/weights/
|
||||
// --header=./file_header.txt
|
||||
// --warmup=10
|
||||
// --repeat=100
|
||||
|
||||
use sp_core::parameter_types;
|
||||
use sp_weights::{constants::WEIGHT_REF_TIME_PER_NANOS, Weight};
|
||||
|
||||
parameter_types! {
|
||||
/// Time to execute a NO-OP extrinsic, for example `System::remark`.
|
||||
/// Calculated by multiplying the *Average* with `1.0` and adding `0`.
|
||||
///
|
||||
/// Stats nanoseconds:
|
||||
/// Min, Max: 402_868, 1_292_427
|
||||
/// Average: 565_926
|
||||
/// Median: 414_626
|
||||
/// Std-Dev: 283192.19
|
||||
///
|
||||
/// Percentiles nanoseconds:
|
||||
/// 99th: 1_251_123
|
||||
/// 95th: 1_196_903
|
||||
/// 75th: 491_329
|
||||
pub const ExtrinsicBaseWeight: Weight =
|
||||
Weight::from_parts(WEIGHT_REF_TIME_PER_NANOS.saturating_mul(565_926), 0);
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test_weights {
|
||||
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::ExtrinsicBaseWeight::get();
|
||||
|
||||
// At least 10 µs.
|
||||
assert!(
|
||||
w.ref_time() >= 10u64 * constants::WEIGHT_REF_TIME_PER_MICROS,
|
||||
"Weight should be at least 10 µs."
|
||||
);
|
||||
// At most 1 ms.
|
||||
assert!(
|
||||
w.ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS,
|
||||
"Weight should be at most 1 ms."
|
||||
);
|
||||
}
|
||||
}
|
||||
9
runtime/casper/constants/src/weights/mod.rs
Normal file
9
runtime/casper/constants/src/weights/mod.rs
Normal file
@@ -0,0 +1,9 @@
|
||||
pub mod block_weights;
|
||||
pub mod extrinsic_weights;
|
||||
pub mod rocksdb_weights;
|
||||
pub mod paritydb_weights;
|
||||
|
||||
pub use block_weights::BlockExecutionWeight;
|
||||
pub use extrinsic_weights::ExtrinsicBaseWeight;
|
||||
pub use rocksdb_weights::constants::RocksDbWeight;
|
||||
pub use paritydb_weights::constants::ParityDbWeight;
|
||||
83
runtime/casper/constants/src/weights/paritydb_weights.rs
Normal file
83
runtime/casper/constants/src/weights/paritydb_weights.rs
Normal file
@@ -0,0 +1,83 @@
|
||||
// This file is part of Ghost Network.
|
||||
|
||||
// Ghost Network is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// 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
|
||||
// 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`
|
||||
//!
|
||||
//! DATABASE: `ParityDb`, RUNTIME: `Development`
|
||||
//! BLOCK-NUM: `BlockId::Number(0)`
|
||||
//! SKIP-WRITE: `false`, SKIP-READ: `false`, WARMUPS: `1`
|
||||
//! STATE-VERSION: `V0`, STATE-CACHE-SIZE: ``
|
||||
//! WEIGHT-PATH: `./runtime/casper/constants/src/weights/`
|
||||
//! METRIC: `Average`, WEIGHT-MUL: `1.1`, WEIGHT-ADD: `0`
|
||||
|
||||
// Executed Command:
|
||||
// ./target/release/ghost
|
||||
// benchmark
|
||||
// storage
|
||||
// --chain=casper-dev
|
||||
// --state-version=0
|
||||
// --mul=1.1
|
||||
// --database=paritydb
|
||||
// --weight-path=./runtime/casper/constants/src/weights/
|
||||
// --header=./file_header.txt
|
||||
|
||||
/// Storage DB weights for the `Development` runtime and `ParityDb`.
|
||||
pub mod constants {
|
||||
use frame_support::weights::constants;
|
||||
use sp_core::parameter_types;
|
||||
use sp_weights::RuntimeDbWeight;
|
||||
|
||||
parameter_types! {
|
||||
/// `ParityDB` can be enabled with a feature flag, but is still experimental. These weights
|
||||
/// are available for brave runtime engineers who may want to try this out as default.
|
||||
pub const ParityDbWeight: RuntimeDbWeight = RuntimeDbWeight {
|
||||
read: 40_820 * constants::WEIGHT_REF_TIME_PER_NANOS,
|
||||
write: 293_659 * constants::WEIGHT_REF_TIME_PER_NANOS,
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test_db_weights {
|
||||
use super::constants::ParityDbWeight as W;
|
||||
use sp_weights::constants;
|
||||
|
||||
/// Checks that all weights exist and have sane values.
|
||||
// NOTE: If this test fails but you are sure that the generated values are fine,
|
||||
// you can delete it.
|
||||
#[test]
|
||||
fn bound() {
|
||||
// At least 1 µs.
|
||||
assert!(
|
||||
W::get().reads(1).ref_time() >= constants::WEIGHT_REF_TIME_PER_MICROS,
|
||||
"Read weight should be at least 1 µs."
|
||||
);
|
||||
assert!(
|
||||
W::get().writes(1).ref_time() >= constants::WEIGHT_REF_TIME_PER_MICROS,
|
||||
"Write weight should be at least 1 µs."
|
||||
);
|
||||
// At most 1 ms.
|
||||
assert!(
|
||||
W::get().reads(1).ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS,
|
||||
"Read weight should be at most 1 ms."
|
||||
);
|
||||
assert!(
|
||||
W::get().writes(1).ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS,
|
||||
"Write weight should be at most 1 ms."
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
82
runtime/casper/constants/src/weights/rocksdb_weights.rs
Normal file
82
runtime/casper/constants/src/weights/rocksdb_weights.rs
Normal file
@@ -0,0 +1,82 @@
|
||||
// This file is part of Ghost Network.
|
||||
|
||||
// Ghost Network is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// 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
|
||||
// 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`
|
||||
//!
|
||||
//! DATABASE: `RocksDb`, RUNTIME: `Development`
|
||||
//! BLOCK-NUM: `BlockId::Number(0)`
|
||||
//! SKIP-WRITE: `false`, SKIP-READ: `false`, WARMUPS: `1`
|
||||
//! STATE-VERSION: `V0`, STATE-CACHE-SIZE: ``
|
||||
//! WEIGHT-PATH: `./runtime/casper/constants/src/weights/`
|
||||
//! METRIC: `Average`, WEIGHT-MUL: `1.1`, WEIGHT-ADD: `0`
|
||||
|
||||
// Executed Command:
|
||||
// ./target/release/ghost
|
||||
// benchmark
|
||||
// storage
|
||||
// --chain=casper-dev
|
||||
// --state-version=0
|
||||
// --mul=1.1
|
||||
// --weight-path=./runtime/casper/constants/src/weights/
|
||||
// --header=./file_header.txt
|
||||
|
||||
/// Storage DB weights for the `Development` runtime and `RocksDb`.
|
||||
pub mod constants {
|
||||
use frame_support::weights::constants;
|
||||
use sp_core::parameter_types;
|
||||
use sp_weights::RuntimeDbWeight;
|
||||
|
||||
parameter_types! {
|
||||
/// By default, Substrate uses `RocksDB`, so this will be the weight used throughout
|
||||
/// the runtime.
|
||||
pub const RocksDbWeight: RuntimeDbWeight = RuntimeDbWeight {
|
||||
read: 31_627 * constants::WEIGHT_REF_TIME_PER_NANOS,
|
||||
write: 412_279 * constants::WEIGHT_REF_TIME_PER_NANOS,
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test_db_weights {
|
||||
use super::constants::RocksDbWeight as W;
|
||||
use sp_weights::constants;
|
||||
|
||||
/// Checks that all weights exist and have sane values.
|
||||
// NOTE: If this test fails but you are sure that the generated values are fine,
|
||||
// you can delete it.
|
||||
#[test]
|
||||
fn bound() {
|
||||
// At least 1 µs.
|
||||
assert!(
|
||||
W::get().reads(1).ref_time() >= constants::WEIGHT_REF_TIME_PER_MICROS,
|
||||
"Read weight should be at least 1 µs."
|
||||
);
|
||||
assert!(
|
||||
W::get().writes(1).ref_time() >= constants::WEIGHT_REF_TIME_PER_MICROS,
|
||||
"Write weight should be at least 1 µs."
|
||||
);
|
||||
// At most 1 ms.
|
||||
assert!(
|
||||
W::get().reads(1).ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS,
|
||||
"Read weight should be at most 1 ms."
|
||||
);
|
||||
assert!(
|
||||
W::get().writes(1).ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS,
|
||||
"Write weight should be at most 1 ms."
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user