rustfmt casper runtime and fix typos

Signed-off-by: Uncle Stretch <uncle.stretch@ghostchain.io>
This commit is contained in:
Uncle Stretch 2025-07-29 14:51:15 +03:00
parent 48ff511685
commit 8d69e5c87e
Signed by: str3tch
GPG Key ID: 84F3190747EE79AA
14 changed files with 897 additions and 830 deletions

View File

@ -1,6 +1,6 @@
[package] [package]
name = "casper-runtime" name = "casper-runtime"
version = "3.5.28" version = "3.5.29"
build = "build.rs" build = "build.rs"
description = "Runtime of the Casper Network" description = "Runtime of the Casper Network"
edition.workspace = true edition.workspace = true

View File

@ -10,15 +10,15 @@ pub mod currency {
/// Constant values used within runtime. /// Constant values used within runtime.
pub const FTSO: Balance = 1_000_000_000; // 10^9 pub const FTSO: Balance = 1_000_000_000; // 10^9
pub const STNK: Balance = 1_000 * FTSO; // 10^12 pub const STNK: Balance = 1_000 * FTSO; // 10^12
pub const STRH: Balance = 1_000 * STNK; // 10^15 pub const STRH: Balance = 1_000 * STNK; // 10^15
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 = STNK;
pub const fn deposit(items: u32, bytes: u32) -> Balance { pub const fn deposit(items: u32, bytes: u32) -> Balance {
(items as Balance) * 200 * STRH + (bytes as Balance) * 1000 * STNK (items as Balance) * 200 * STRH + (bytes as Balance) * 1000 * STNK
} }
} }
@ -86,7 +86,7 @@ pub mod fee {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::{ use super::{
currency::{STNK, STRH, CSPR}, currency::{CSPR, STNK, STRH},
fee::WeightToFee, fee::WeightToFee,
}; };
use crate::weights::ExtrinsicBaseWeight; use crate::weights::ExtrinsicBaseWeight;

View File

@ -37,43 +37,43 @@ use sp_core::parameter_types;
use sp_weights::{constants::WEIGHT_REF_TIME_PER_NANOS, Weight}; use sp_weights::{constants::WEIGHT_REF_TIME_PER_NANOS, Weight};
parameter_types! { parameter_types! {
/// Time to execute an empty block. /// Time to execute an empty block.
/// Calculated by multiplying the *Average* with `1.0` and adding `0`. /// Calculated by multiplying the *Average* with `1.0` and adding `0`.
/// ///
/// Stats nanoseconds: /// Stats nanoseconds:
/// Min, Max: 64_363_191, 66_078_314 /// Min, Max: 64_363_191, 66_078_314
/// Average: 64_551_214 /// Average: 64_551_214
/// Median: 64_500_078 /// Median: 64_500_078
/// Std-Dev: 229678.99 /// Std-Dev: 229678.99
/// ///
/// Percentiles nanoseconds: /// Percentiles nanoseconds:
/// 99th: 65_668_012 /// 99th: 65_668_012
/// 95th: 64_888_421 /// 95th: 64_888_421
/// 75th: 64_563_448 /// 75th: 64_563_448
pub const BlockExecutionWeight: Weight = pub const BlockExecutionWeight: Weight =
Weight::from_parts(WEIGHT_REF_TIME_PER_NANOS.saturating_mul(64_551_214), 0); Weight::from_parts(WEIGHT_REF_TIME_PER_NANOS.saturating_mul(64_551_214), 0);
} }
#[cfg(test)] #[cfg(test)]
mod test_weights { mod test_weights {
use sp_weights::constants; use sp_weights::constants;
/// Checks that the weight exists and is sane. /// Checks that the weight exists and is sane.
// NOTE: If this test fails but you are sure that the generated values are fine, // NOTE: If this test fails but you are sure that the generated values are fine,
// you can delete it. // you can delete it.
#[test] #[test]
fn sane() { fn sane() {
let w = super::BlockExecutionWeight::get(); let w = super::BlockExecutionWeight::get();
// At least 100 µs. // At least 100 µs.
assert!( assert!(
w.ref_time() >= 100u64 * constants::WEIGHT_REF_TIME_PER_MICROS, w.ref_time() >= 100u64 * constants::WEIGHT_REF_TIME_PER_MICROS,
"Weight should be at least 100 µs." "Weight should be at least 100 µs."
); );
// At most 50 ms. // At most 50 ms.
assert!( assert!(
w.ref_time() <= 50u64 * constants::WEIGHT_REF_TIME_PER_MILLIS, w.ref_time() <= 50u64 * constants::WEIGHT_REF_TIME_PER_MILLIS,
"Weight should be at most 50 ms." "Weight should be at most 50 ms."
); );
} }
} }

View File

@ -37,43 +37,43 @@ use sp_core::parameter_types;
use sp_weights::{constants::WEIGHT_REF_TIME_PER_NANOS, Weight}; use sp_weights::{constants::WEIGHT_REF_TIME_PER_NANOS, Weight};
parameter_types! { parameter_types! {
/// Time to execute a NO-OP extrinsic, for example `System::remark`. /// Time to execute a NO-OP extrinsic, for example `System::remark`.
/// Calculated by multiplying the *Average* with `1.0` and adding `0`. /// Calculated by multiplying the *Average* with `1.0` and adding `0`.
/// ///
/// Stats nanoseconds: /// Stats nanoseconds:
/// Min, Max: 402_868, 1_292_427 /// Min, Max: 402_868, 1_292_427
/// Average: 565_926 /// Average: 565_926
/// Median: 414_626 /// Median: 414_626
/// Std-Dev: 283192.19 /// Std-Dev: 283192.19
/// ///
/// Percentiles nanoseconds: /// Percentiles nanoseconds:
/// 99th: 1_251_123 /// 99th: 1_251_123
/// 95th: 1_196_903 /// 95th: 1_196_903
/// 75th: 491_329 /// 75th: 491_329
pub const ExtrinsicBaseWeight: Weight = pub const ExtrinsicBaseWeight: Weight =
Weight::from_parts(WEIGHT_REF_TIME_PER_NANOS.saturating_mul(565_926), 0); Weight::from_parts(WEIGHT_REF_TIME_PER_NANOS.saturating_mul(565_926), 0);
} }
#[cfg(test)] #[cfg(test)]
mod test_weights { mod test_weights {
use sp_weights::constants; use sp_weights::constants;
/// Checks that the weight exists and is sane. /// Checks that the weight exists and is sane.
// NOTE: If this test fails but you are sure that the generated values are fine, // NOTE: If this test fails but you are sure that the generated values are fine,
// you can delete it. // you can delete it.
#[test] #[test]
fn sane() { fn sane() {
let w = super::ExtrinsicBaseWeight::get(); let w = super::ExtrinsicBaseWeight::get();
// At least 10 µs. // At least 10 µs.
assert!( assert!(
w.ref_time() >= 10u64 * constants::WEIGHT_REF_TIME_PER_MICROS, w.ref_time() >= 10u64 * constants::WEIGHT_REF_TIME_PER_MICROS,
"Weight should be at least 10 µs." "Weight should be at least 10 µs."
); );
// At most 1 ms. // At most 1 ms.
assert!( assert!(
w.ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS, w.ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS,
"Weight should be at most 1 ms." "Weight should be at most 1 ms."
); );
} }
} }

View File

@ -1,9 +1,9 @@
pub mod block_weights; pub mod block_weights;
pub mod extrinsic_weights; pub mod extrinsic_weights;
pub mod rocksdb_weights;
pub mod paritydb_weights; pub mod paritydb_weights;
pub mod rocksdb_weights;
pub use block_weights::BlockExecutionWeight; pub use block_weights::BlockExecutionWeight;
pub use extrinsic_weights::ExtrinsicBaseWeight; pub use extrinsic_weights::ExtrinsicBaseWeight;
pub use rocksdb_weights::constants::RocksDbWeight;
pub use paritydb_weights::constants::ParityDbWeight; pub use paritydb_weights::constants::ParityDbWeight;
pub use rocksdb_weights::constants::RocksDbWeight;

View File

@ -37,47 +37,47 @@
/// Storage DB weights for the `Development` runtime and `ParityDb`. /// Storage DB weights for the `Development` runtime and `ParityDb`.
pub mod constants { pub mod constants {
use frame_support::weights::constants; use frame_support::weights::constants;
use sp_core::parameter_types; use sp_core::parameter_types;
use sp_weights::RuntimeDbWeight; use sp_weights::RuntimeDbWeight;
parameter_types! { parameter_types! {
/// `ParityDB` can be enabled with a feature flag, but is still experimental. These weights /// `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. /// are available for brave runtime engineers who may want to try this out as default.
pub const ParityDbWeight: RuntimeDbWeight = RuntimeDbWeight { pub const ParityDbWeight: RuntimeDbWeight = RuntimeDbWeight {
read: 40_820 * constants::WEIGHT_REF_TIME_PER_NANOS, read: 40_820 * constants::WEIGHT_REF_TIME_PER_NANOS,
write: 293_659 * constants::WEIGHT_REF_TIME_PER_NANOS, write: 293_659 * constants::WEIGHT_REF_TIME_PER_NANOS,
}; };
} }
#[cfg(test)] #[cfg(test)]
mod test_db_weights { mod test_db_weights {
use super::constants::ParityDbWeight as W; use super::constants::ParityDbWeight as W;
use sp_weights::constants; use sp_weights::constants;
/// Checks that all weights exist and have sane values. /// Checks that all weights exist and have sane values.
// NOTE: If this test fails but you are sure that the generated values are fine, // NOTE: If this test fails but you are sure that the generated values are fine,
// you can delete it. // you can delete it.
#[test] #[test]
fn bound() { fn bound() {
// At least 1 µs. // At least 1 µs.
assert!( assert!(
W::get().reads(1).ref_time() >= constants::WEIGHT_REF_TIME_PER_MICROS, W::get().reads(1).ref_time() >= constants::WEIGHT_REF_TIME_PER_MICROS,
"Read weight should be at least 1 µs." "Read weight should be at least 1 µs."
); );
assert!( assert!(
W::get().writes(1).ref_time() >= constants::WEIGHT_REF_TIME_PER_MICROS, W::get().writes(1).ref_time() >= constants::WEIGHT_REF_TIME_PER_MICROS,
"Write weight should be at least 1 µs." "Write weight should be at least 1 µs."
); );
// At most 1 ms. // At most 1 ms.
assert!( assert!(
W::get().reads(1).ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS, W::get().reads(1).ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS,
"Read weight should be at most 1 ms." "Read weight should be at most 1 ms."
); );
assert!( assert!(
W::get().writes(1).ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS, W::get().writes(1).ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS,
"Write weight should be at most 1 ms." "Write weight should be at most 1 ms."
); );
} }
} }
} }

View File

@ -36,47 +36,47 @@
/// Storage DB weights for the `Development` runtime and `RocksDb`. /// Storage DB weights for the `Development` runtime and `RocksDb`.
pub mod constants { pub mod constants {
use frame_support::weights::constants; use frame_support::weights::constants;
use sp_core::parameter_types; use sp_core::parameter_types;
use sp_weights::RuntimeDbWeight; use sp_weights::RuntimeDbWeight;
parameter_types! { parameter_types! {
/// By default, Substrate uses `RocksDB`, so this will be the weight used throughout /// By default, Substrate uses `RocksDB`, so this will be the weight used throughout
/// the runtime. /// the runtime.
pub const RocksDbWeight: RuntimeDbWeight = RuntimeDbWeight { pub const RocksDbWeight: RuntimeDbWeight = RuntimeDbWeight {
read: 31_627 * constants::WEIGHT_REF_TIME_PER_NANOS, read: 31_627 * constants::WEIGHT_REF_TIME_PER_NANOS,
write: 412_279 * constants::WEIGHT_REF_TIME_PER_NANOS, write: 412_279 * constants::WEIGHT_REF_TIME_PER_NANOS,
}; };
} }
#[cfg(test)] #[cfg(test)]
mod test_db_weights { mod test_db_weights {
use super::constants::RocksDbWeight as W; use super::constants::RocksDbWeight as W;
use sp_weights::constants; use sp_weights::constants;
/// Checks that all weights exist and have sane values. /// Checks that all weights exist and have sane values.
// NOTE: If this test fails but you are sure that the generated values are fine, // NOTE: If this test fails but you are sure that the generated values are fine,
// you can delete it. // you can delete it.
#[test] #[test]
fn bound() { fn bound() {
// At least 1 µs. // At least 1 µs.
assert!( assert!(
W::get().reads(1).ref_time() >= constants::WEIGHT_REF_TIME_PER_MICROS, W::get().reads(1).ref_time() >= constants::WEIGHT_REF_TIME_PER_MICROS,
"Read weight should be at least 1 µs." "Read weight should be at least 1 µs."
); );
assert!( assert!(
W::get().writes(1).ref_time() >= constants::WEIGHT_REF_TIME_PER_MICROS, W::get().writes(1).ref_time() >= constants::WEIGHT_REF_TIME_PER_MICROS,
"Write weight should be at least 1 µs." "Write weight should be at least 1 µs."
); );
// At most 1 ms. // At most 1 ms.
assert!( assert!(
W::get().reads(1).ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS, W::get().reads(1).ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS,
"Read weight should be at most 1 ms." "Read weight should be at most 1 ms."
); );
assert!( assert!(
W::get().writes(1).ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS, W::get().writes(1).ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS,
"Write weight should be at most 1 ms." "Write weight should be at most 1 ms."
); );
} }
} }
} }

View File

@ -1,4 +1,3 @@
//! Autogenerated bag thresholds. //! Autogenerated bag thresholds.
//! //!
//! Generated on 2024-06-30T17:36:29.986756974+00:00 //! Generated on 2024-06-30T17:36:29.986756974+00:00
@ -19,204 +18,204 @@ pub const CONSTANT_RATIO: f64 = 1.1717610304252650;
/// Upper thresholds delimiting the bag list. /// Upper thresholds delimiting the bag list.
pub const THRESHOLDS: [u64; 200] = [ pub const THRESHOLDS: [u64; 200] = [
368_934, 368_934,
432_302, 432_302,
506_555, 506_555,
593_561, 593_561,
695_512, 695_512,
814_974, 814_974,
954_955, 954_955,
1_118_979, 1_118_979,
1_311_176, 1_311_176,
1_536_385, 1_536_385,
1_800_276, 1_800_276,
2_109_493, 2_109_493,
2_471_822, 2_471_822,
2_896_385, 2_896_385,
3_393_871, 3_393_871,
3_976_806, 3_976_806,
4_659_866, 4_659_866,
5_460_249, 5_460_249,
6_398_107, 6_398_107,
7_497_052, 7_497_052,
8_784_753, 8_784_753,
10_293_631, 10_293_631,
12_061_676, 12_061_676,
14_133_402, 14_133_402,
16_560_970, 16_560_970,
19_405_499, 19_405_499,
22_738_608, 22_738_608,
26_644_215, 26_644_215,
31_220_653, 31_220_653,
36_583_145, 36_583_145,
42_866_704, 42_866_704,
50_229_533, 50_229_533,
58_857_009, 58_857_009,
68_966_350, 68_966_350,
80_812_081, 80_812_081,
94_692_447, 94_692_447,
110_956_919, 110_956_919,
130_014_994, 130_014_994,
152_346_503, 152_346_503,
178_513_695, 178_513_695,
209_175_391, 209_175_391,
245_103_572, 245_103_572,
287_202_814, 287_202_814,
336_533_065, 336_533_065,
394_336_331, 394_336_331,
462_067_946, 462_067_946,
541_433_213, 541_433_213,
634_430_340, 634_430_340,
743_400_749, 743_400_749,
871_088_028, 871_088_028,
1_020_707_005, 1_020_707_005,
1_196_024_692, 1_196_024_692,
1_401_455_126, 1_401_455_126,
1_642_170_503, 1_642_170_503,
1_924_231_401, 1_924_231_401,
2_254_739_369, 2_254_739_369,
2_642_015_726, 2_642_015_726,
3_095_811_069, 3_095_811_069,
3_627_550_768, 3_627_550_768,
4_250_622_626, 4_250_622_626,
4_980_713_948, 4_980_713_948,
5_836_206_508, 5_836_206_508,
6_838_639_352, 6_838_639_352,
8_013_251_094, 8_013_251_094,
9_389_615_359, 9_389_615_359,
11_002_385_368, 11_002_385_368,
12_892_166_416, 12_892_166_416,
15_106_538_204, 15_106_538_204,
17_701_252_772, 17_701_252_772,
20_741_638_188, 20_741_638_188,
24_304_243_336, 24_304_243_336,
28_478_765_215, 28_478_765_215,
33_370_307_274, 33_370_307_274,
39_102_025_637, 39_102_025_637,
45_818_229_852, 45_818_229_852,
53_688_016_224, 53_688_016_224,
62_909_525_212, 62_909_525_212,
73_714_930_086, 73_714_930_086,
86_376_282_435, 86_376_282_435,
101_212_361_710, 101_212_361_710,
118_596_701_249, 118_596_701_249,
138_966_992_861, 138_966_992_861,
162_836_106_750, 162_836_106_750,
190_805_004_236, 190_805_004_236,
223_577_868_374, 223_577_868_374,
261_979_833_426, 261_979_833_426,
306_977_759_566, 306_977_759_566,
359_704_575_867, 359_704_575_867,
421_487_804_467, 421_487_804_467,
493_882_984_074, 493_882_984_074,
578_712_834_328, 578_712_834_328,
678_113_147_073, 678_113_147_073,
794_586_559_959, 794_586_559_959,
931_065_566_260, 931_065_566_260,
1_090_986_347_314, 1_090_986_347_314,
1_278_375_286_509, 1_278_375_286_509,
1_497_950_342_990, 1_497_950_342_990,
1_755_239_837_428, 1_755_239_837_428,
2_056_721_640_548, 2_056_721_640_548,
2_409_986_268_826, 2_409_986_268_826,
2_823_927_993_670, 2_823_927_993_670,
3_308_968_775_710, 3_308_968_775_710,
3_877_320_662_271, 3_877_320_662_271,
4_543_293_254_512, 4_543_293_254_512,
5_323_653_985_431, 5_323_653_985_431,
6_238_050_279_596, 6_238_050_279_596,
7_309_504_223_464, 7_309_504_223_464,
8_564_992_200_784, 8_564_992_200_784,
10_036_124_086_775, 10_036_124_086_775,
11_759_939_101_395, 11_759_939_101_395,
13_779_838_359_189, 13_779_838_359_189,
16_146_677_594_857, 16_146_677_594_857,
18_920_047_576_494, 18_920_047_576_494,
22_169_774_443_928, 22_169_774_443_928,
25_977_677_746_713, 25_977_677_746_713,
30_439_630_444_544, 30_439_630_444_544,
35_667_972_735_463, 35_667_972_735_463,
41_794_340_485_686, 41_794_340_485_686,
48_972_979_473_452, 48_972_979_473_452,
57_384_628_890_807, 57_384_628_890_807,
67_241_071_879_663, 67_241_071_879_663,
78_790_467_672_613, 78_790_467_672_613,
92_323_599_587_750, 92_323_599_587_750,
108_181_196_185_512, 108_181_196_185_512,
126_762_509_914_973, 126_762_509_914_973,
148_535_369_237_262, 148_535_369_237_262,
174_047_957_312_051, 174_047_957_312_051,
203_942_613_803_381, 203_942_613_803_381,
238_972_007_297_872, 238_972_007_297_872,
280_018_085_514_148, 280_018_085_514_148,
328_114_280_419_768, 328_114_280_419_768,
384_471_527_321_912, 384_471_527_321_912,
450_508_753_023_899, 450_508_753_023_899,
527_888_600_658_885, 527_888_600_658_885,
618_559_290_657_806, 618_559_290_657_806,
724_803_671_800_312, 724_803_671_800_312,
849_296_697_324_749, 849_296_697_324_749,
995_172_773_194_022, 995_172_773_194_022,
1_166_104_674_168_996, 1_166_104_674_168_996,
1_366_396_014_587_981, 1_366_396_014_587_981,
1_601_089_602_022_588, 1_601_089_602_022_588,
1_876_094_401_869_165, 1_876_094_401_869_165,
2_198_334_309_509_284, 2_198_334_309_509_284,
2_575_922_475_729_812, 2_575_922_475_729_812,
3_018_365_574_456_765, 3_018_365_574_456_765,
3_536_803_155_725_606, 3_536_803_155_725_606,
4_144_288_110_164_365, 4_144_288_110_164_365,
4_856_115_306_345_371, 4_856_115_306_345_371,
5_690_206_675_227_153, 5_690_206_675_227_153,
6_667_562_437_096_890, 6_667_562_437_096_890,
7_812_789_831_717_443, 7_812_789_831_717_443,
9_154_722_663_709_264, 9_154_722_663_709_264,
10_727_147_261_685_494, 10_727_147_261_685_494,
12_569_653_128_876_154, 12_569_653_128_876_154,
14_728_629_702_380_078, 14_728_629_702_380_078,
17_258_434_316_813_044, 17_258_434_316_813_044,
20_222_760_778_595_608, 20_222_760_778_595_608,
23_696_243_007_970_824, 23_696_243_007_970_824,
27_766_334_124_227_376, 27_766_334_124_227_376,
32_535_508_284_536_868, 32_535_508_284_536_868,
38_123_840_712_898_664, 38_123_840_712_898_664,
44_672_030_877_514_808, 44_672_030_877_514_808,
52_344_944_932_226_008, 52_344_944_932_226_008,
61_335_766_611_338_904, 61_335_766_611_338_904,
71_870_861_086_426_040, 71_870_861_086_426_040,
84_215_474_244_181_664, 84_215_474_244_181_664,
98_680_410_878_114_672, 98_680_410_878_114_672,
115_629_859_933_328_176, 115_629_859_933_328_176,
135_490_563_823_405_696, 135_490_563_823_405_696,
158_762_562_678_613_984, 158_762_562_678_613_984,
186_031_784_037_248_448, 186_031_784_037_248_448,
217_984_794_955_336_608, 217_984_794_955_336_608,
255_426_087_953_905_344, 255_426_087_953_905_344,
299_298_336_018_362_496, 299_298_336_018_362_496,
350_706_126_617_443_648, 350_706_126_617_443_648,
410_943_772_301_709_248, 410_943_772_301_709_248,
481_527_898_079_096_320, 481_527_898_079_096_320,
564_235_626_031_673_920, 564_235_626_031_673_920,
661_149_318_561_518_720, 661_149_318_561_518_720,
774_709_006_782_606_976, 774_709_006_782_606_976,
907_773_824_067_321_216, 907_773_824_067_321_216,
1_063_693_991_482_207_616, 1_063_693_991_482_207_616,
1_246_395_167_516_354_560, 1_246_395_167_516_354_560,
1_460_477_285_806_034_432, 1_460_477_285_806_034_432,
1_711_330_369_328_773_120, 1_711_330_369_328_773_120,
2_005_270_236_962_732_544, 2_005_270_236_962_732_544,
2_349_697_519_144_566_784, 2_349_697_519_144_566_784,
2_753_283_986_220_526_592, 2_753_283_986_220_526_592,
3_226_190_880_747_145_216, 3_226_190_880_747_145_216,
3_780_324_750_772_868_096, 3_780_324_750_772_868_096,
4_429_637_225_307_749_376, 4_429_637_225_307_749_376,
5_190_476_279_536_719_872, 5_190_476_279_536_719_872,
6_081_997_833_707_842_560, 6_081_997_833_707_842_560,
7_126_648_048_669_730_816, 7_126_648_048_669_730_816,
8_350_728_460_987_448_320, 8_350_728_460_987_448_320,
9_785_058_186_248_239_104, 9_785_058_186_248_239_104,
11_465_749_863_089_412_096, 11_465_749_863_089_412_096,
13_435_118_874_171_990_016, 13_435_118_874_171_990_016,
15_742_748_735_885_697_024, 15_742_748_735_885_697_024,
18_446_744_073_709_551_615, 18_446_744_073_709_551_615,
]; ];

View File

@ -2,25 +2,34 @@ use super::*;
use frame_support::{ use frame_support::{
parameter_types, parameter_types,
traits::{ traits::{
EitherOf, EitherOfDiverse, MapSuccess, OriginTrait, TryWithMorphedArg, tokens::pay::PayFromAccount, EitherOf, EitherOfDiverse, MapSuccess, OriginTrait,
tokens::pay::PayFromAccount, TryWithMorphedArg,
}, },
}; };
use frame_system::EnsureRootWithSuccess; use frame_system::EnsureRootWithSuccess;
use pallet_ranked_collective::EnsureOfRank;
use sp_core::{ConstU128, ConstU32}; use sp_core::{ConstU128, ConstU32};
use sp_runtime::traits::{ConstU16, TakeFirst}; use sp_runtime::traits::{ConstU16, TakeFirst};
use pallet_ranked_collective::EnsureOfRank;
use crate::{ use crate::{
// weights, AccountId,
RuntimeCall, RuntimeEvent, Scheduler, DAYS, CSPR, AccountId, Balance, Balance,
TreasuryAccount, Balances, Preimage, Runtime, Balances,
Preimage,
Runtime,
// weights,
RuntimeCall,
RuntimeEvent,
Scheduler,
TreasuryAccount,
CSPR,
DAYS,
}; };
mod origins; mod origins;
pub use origins::{ pub use origins::{
pallet_cult_origins, Geniuses, Degens, Zombies, Skeletons, Ghosts, pallet_cult_origins, CultTreasurySpender, Degens, EnsureCanPromoteTo, EnsureCanRetainAt,
EnsureCanRetainAt, EnsureCanPromoteTo, EnsureCult, ToVoice, CultTreasurySpender, EnsureCult, Geniuses, Ghosts, Skeletons, ToVoice, Zombies,
}; };
mod tracks; mod tracks;
@ -45,14 +54,10 @@ parameter_types! {
impl pallet_whitelist::Config for Runtime { impl pallet_whitelist::Config for Runtime {
type RuntimeCall = RuntimeCall; type RuntimeCall = RuntimeCall;
type RuntimeEvent = RuntimeEvent; type RuntimeEvent = RuntimeEvent;
type WhitelistOrigin = EitherOfDiverse< type WhitelistOrigin =
EnsureRootWithSuccess<Self::AccountId, ConstU16<65535>>, EitherOfDiverse<EnsureRootWithSuccess<Self::AccountId, ConstU16<65535>>, Skeletons>;
Skeletons, type DispatchWhitelistedOrigin =
>; EitherOf<EnsureRootWithSuccess<Self::AccountId, ConstU16<65535>>, Geniuses>;
type DispatchWhitelistedOrigin = EitherOf<
EnsureRootWithSuccess<Self::AccountId, ConstU16<65535>>,
Geniuses,
>;
type Preimages = Preimage; type Preimages = Preimage;
type WeightInfo = weights::pallet_whitelist::WeightInfo<Runtime>; type WeightInfo = weights::pallet_whitelist::WeightInfo<Runtime>;
} }
@ -71,7 +76,7 @@ impl pallet_referenda::Config<CultReferendaInstance> for Runtime {
type Scheduler = Scheduler; type Scheduler = Scheduler;
type Currency = Balances; type Currency = Balances;
type SubmitOrigin = EitherOf< type SubmitOrigin = EitherOf<
pallet_ranked_collective::EnsureMember<Runtime, CultCollectiveInstance, 3>, pallet_ranked_collective::EnsureMember<Runtime, CultCollectiveInstance, 3>,
MapSuccess< MapSuccess<
TryWithMorphedArg< TryWithMorphedArg<
RuntimeOrigin, RuntimeOrigin,
@ -81,7 +86,7 @@ impl pallet_referenda::Config<CultReferendaInstance> for Runtime {
(AccountId, u16), (AccountId, u16),
>, >,
TakeFirst, TakeFirst,
> >,
>; >;
type CancelOrigin = Skeletons; type CancelOrigin = Skeletons;
type KillOrigin = Ghosts; type KillOrigin = Ghosts;
@ -100,7 +105,7 @@ pub type CultCollectiveInstance = pallet_ranked_collective::Instance1;
impl pallet_ranked_collective::Config<CultCollectiveInstance> for Runtime { impl pallet_ranked_collective::Config<CultCollectiveInstance> for Runtime {
type WeightInfo = weights::pallet_ranked_collective::WeightInfo<Runtime>; type WeightInfo = weights::pallet_ranked_collective::WeightInfo<Runtime>;
type RuntimeEvent = RuntimeEvent; type RuntimeEvent = RuntimeEvent;
#[cfg(not(feature = "runtime-benchmarks"))] #[cfg(not(feature = "runtime-benchmarks"))]
type PromoteOrigin = frame_system::EnsureNever<pallet_ranked_collective::Rank>; type PromoteOrigin = frame_system::EnsureNever<pallet_ranked_collective::Rank>;
#[cfg(feature = "runtime-benchmarks")] #[cfg(feature = "runtime-benchmarks")]
@ -123,7 +128,7 @@ impl pallet_ranked_collective::Config<CultCollectiveInstance> for Runtime {
type MinRankOfClass = tracks::MinRankOfClass; type MinRankOfClass = tracks::MinRankOfClass;
type MemberSwappedHandler = (crate::CultCore, crate::CultSalary); type MemberSwappedHandler = (crate::CultCore, crate::CultSalary);
type VoteWeight = pallet_ranked_collective::Geometric; type VoteWeight = pallet_ranked_collective::Geometric;
#[cfg(feature = "runtime-benchmarks")] #[cfg(feature = "runtime-benchmarks")]
type BenchmarkSetup = (crate::CultCore, crate::CultSalary); type BenchmarkSetup = (crate::CultCore, crate::CultSalary);
} }
@ -135,10 +140,13 @@ impl pallet_core_fellowship::Config<CultCoreInstance> for Runtime {
type Members = pallet_ranked_collective::Pallet<Runtime, CultCollectiveInstance>; type Members = pallet_ranked_collective::Pallet<Runtime, CultCollectiveInstance>;
type Balance = Balance; type Balance = Balance;
type ParamsOrigin = EitherOf<EnsureRootWithSuccess<Self::AccountId, ConstU16<65535>>, Skeletons>; type ParamsOrigin =
EitherOf<EnsureRootWithSuccess<Self::AccountId, ConstU16<65535>>, Skeletons>;
type InductOrigin = EitherOf<EnsureRootWithSuccess<Self::AccountId, ConstU16<65535>>, Zombies>; type InductOrigin = EitherOf<EnsureRootWithSuccess<Self::AccountId, ConstU16<65535>>, Zombies>;
type ApproveOrigin = EitherOf<EnsureRootWithSuccess<Self::AccountId, ConstU16<65535>>, EnsureCanRetainAt>; type ApproveOrigin =
type PromoteOrigin = EitherOf<EnsureRootWithSuccess<Self::AccountId, ConstU16<65535>>, EnsureCanPromoteTo>; EitherOf<EnsureRootWithSuccess<Self::AccountId, ConstU16<65535>>, EnsureCanRetainAt>;
type PromoteOrigin =
EitherOf<EnsureRootWithSuccess<Self::AccountId, ConstU16<65535>>, EnsureCanPromoteTo>;
type EvidenceSize = ConstU32<65536>; type EvidenceSize = ConstU32<65536>;
} }

View File

@ -5,8 +5,8 @@ pub use pallet_cult_origins::*;
#[frame_support::pallet] #[frame_support::pallet]
pub mod pallet_cult_origins { pub mod pallet_cult_origins {
use crate::{Balance, CSPR};
use super::ranks; use super::ranks;
use crate::{Balance, CSPR};
use frame_support::pallet_prelude::*; use frame_support::pallet_prelude::*;
use pallet_ranked_collective::Rank; use pallet_ranked_collective::Rank;
@ -114,7 +114,7 @@ pub mod pallet_cult_origins {
} }
#[cfg(feature = "runtime-benchmarks")] #[cfg(feature = "runtime-benchmarks")]
fn try_successful_origin() -> Result<O, ()> { fn try_successful_origin() -> Result<O, ()> {
// By convention the more privileged origins go later, // By convention the more privileged origins go later,
// so for greatest chance of success, we want the last one. // so for greatest chance of success, we want the last one.
let _result: Result<O, ()> = Err(()); let _result: Result<O, ()> = Err(());
$( $(

View File

@ -1,4 +1,4 @@
use crate::{Balance, BlockNumber, RuntimeOrigin, DAYS, CSPR, HOURS, MINUTES}; use crate::{Balance, BlockNumber, RuntimeOrigin, CSPR, DAYS, HOURS, MINUTES};
use pallet_ranked_collective::Rank; use pallet_ranked_collective::Rank;
use sp_runtime::{traits::Convert, Perbill}; use sp_runtime::{traits::Convert, Perbill};
@ -255,7 +255,6 @@ const TRACKS_DATA: [(u16, pallet_referenda::TrackInfo<Balance, BlockNumber>); 15
min_support: RETAIN_MIN_SUPPORT, min_support: RETAIN_MIN_SUPPORT,
}, },
), ),
( (
constants::PROMOTE_TO_GENIUSES, constants::PROMOTE_TO_GENIUSES,
pallet_referenda::TrackInfo { pallet_referenda::TrackInfo {
@ -347,7 +346,7 @@ impl pallet_referenda::TracksInfo<Balance, BlockNumber> for TracksInfo {
// It is important that this is NOT availiable in production! // It is important that this is NOT availiable in production!
let root: Self::RuntimeOrigin = frame_system::RawOrigin::Root.into(); let root: Self::RuntimeOrigin = frame_system::RawOrigin::Root.into();
if &root == id { if &root == id {
return Ok(tracks::GHOSTS) return Ok(tracks::GHOSTS);
} }
} }

View File

@ -3,24 +3,24 @@ use pallet_staking::Forcing;
use sp_staking::StakerStatus; use sp_staking::StakerStatus;
use crate::{opaque::SessionKeys, BABE_GENESIS_EPOCH_CONFIG}; use crate::{opaque::SessionKeys, BABE_GENESIS_EPOCH_CONFIG};
use primitives::{AccountId, AccountPublic};
use casper_runtime_constants::currency::CSPR; use casper_runtime_constants::currency::CSPR;
use primitives::{AccountId, AccountPublic};
use ghost_slow_clap::sr25519::AuthorityId as SlowClapId;
use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId; use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId;
use babe_primitives::AuthorityId as BabeId; use babe_primitives::AuthorityId as BabeId;
use ghost_slow_clap::sr25519::AuthorityId as SlowClapId;
use grandpa_primitives::AuthorityId as GrandpaId; use grandpa_primitives::AuthorityId as GrandpaId;
use sp_core::{sr25519, Pair, Public};
use sp_runtime::{traits::IdentifyAccount, Perbill};
#[cfg(not(feature = "std"))] #[cfg(not(feature = "std"))]
use sp_std::alloc::format; use sp_std::alloc::format;
use sp_std::vec::Vec;
use sp_std::prelude::*; use sp_std::prelude::*;
use sp_core::{sr25519, Pair, Public}; use sp_std::vec::Vec;
use sp_runtime::{Perbill, traits::IdentifyAccount};
#[derive(Encode, Clone)] #[derive(Encode, Clone)]
struct PreparedNetworkData { struct PreparedNetworkData {
chain_name: Vec<u8>, chain_name: Vec<u8>,
default_endpoint: Vec<u8>, default_endpoint: Vec<u8>,
finality_delay: Option<u64>, finality_delay: Option<u64>,
release_delay: Option<u64>, release_delay: Option<u64>,
@ -84,40 +84,69 @@ fn casper_testnet_accounts() -> Vec<AccountId> {
fn casper_testnet_evm_accounts() -> Vec<(AccountId, u128, u8)> { fn casper_testnet_evm_accounts() -> Vec<(AccountId, u128, u8)> {
vec![ vec![
// 01c928771aea942a1e7ac06adf2b73dfbc9a25d9eaa516e3673116af7f345198 // 01c928771aea942a1e7ac06adf2b73dfbc9a25d9eaa516e3673116af7f345198
(get_account_id_from_seed::<sr25519::Public>("1A69d2D5568D1878023EeB121a73d33B9116A760"), 1337 * CSPR, 1), (
get_account_id_from_seed::<sr25519::Public>("1A69d2D5568D1878023EeB121a73d33B9116A760"),
1337 * CSPR,
1,
),
// b19a435901872f817185f7234a1484eae837613f9d10cf21927a23c2d8cb9139 // b19a435901872f817185f7234a1484eae837613f9d10cf21927a23c2d8cb9139
(get_account_id_from_seed::<sr25519::Public>("2f86cfBED3fbc1eCf2989B9aE5fc019a837A9C12"), 1337 * CSPR, 2), (
get_account_id_from_seed::<sr25519::Public>("2f86cfBED3fbc1eCf2989B9aE5fc019a837A9C12"),
1337 * CSPR,
2,
),
// d3baf57b74d65719b2dc33f5a464176022d0cc5edbca002234229f3e733875fc // d3baf57b74d65719b2dc33f5a464176022d0cc5edbca002234229f3e733875fc
(get_account_id_from_seed::<sr25519::Public>("e83f67361Ac74D42A48E2DAfb6706eb047D8218D"), 69 * CSPR, 3), (
get_account_id_from_seed::<sr25519::Public>("e83f67361Ac74D42A48E2DAfb6706eb047D8218D"),
69 * CSPR,
3,
),
// c4683d566436af6b58b4a59c8f501319226e85b21869bf93d5eeb4596d4791d4 // c4683d566436af6b58b4a59c8f501319226e85b21869bf93d5eeb4596d4791d4
(get_account_id_from_seed::<sr25519::Public>("827ee4ad9b259b6fa1390ed60921508c78befd63"), 69 * CSPR, 4), (
get_account_id_from_seed::<sr25519::Public>("827ee4ad9b259b6fa1390ed60921508c78befd63"),
69 * CSPR,
4,
),
] ]
} }
fn casper_testnet_evm_networks() -> Vec<(u32, Vec<u8>)> { fn casper_testnet_evm_networks() -> Vec<(u32, Vec<u8>)> {
vec![ vec![
(1, PreparedNetworkData { (
chain_name: "ethereum-mainnet".into(), 1,
default_endpoint: "https://nd-422-757-666.p2pify.com/0a9d79d93fb2f4a4b1e04695da2b77a7/".into(), PreparedNetworkData {
finality_delay: Some(40), chain_name: "ethereum-mainnet".into(),
release_delay: Some(80), default_endpoint:
network_type: Default::default(), "https://nd-422-757-666.p2pify.com/0a9d79d93fb2f4a4b1e04695da2b77a7/".into(),
gatekeeper: "0x4d224452801aced8b2f0aebe155379bb5d594381".into(), finality_delay: Some(40),
topic_name: "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef".into(), release_delay: Some(80),
incoming_fee: 0, network_type: Default::default(),
outgoing_fee: 0, gatekeeper: "0x4d224452801aced8b2f0aebe155379bb5d594381".into(),
}.encode()), topic_name: "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"
(56, PreparedNetworkData { .into(),
chain_name: "bnb-mainnet".into(), incoming_fee: 0,
default_endpoint: "https://bsc-mainnet.core.chainstack.com/35848e183f3e3303c8cfeacbea831cab/".into(), outgoing_fee: 0,
finality_delay: Some(20), }
release_delay: Some(40), .encode(),
network_type: Default::default(), ),
gatekeeper: "0x0E09FaBB73Bd3Ade0a17ECC321fD13a19e81cE82".into(), (
topic_name: "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef".into(), 56,
incoming_fee: 0, PreparedNetworkData {
outgoing_fee: 0, chain_name: "bnb-mainnet".into(),
}.encode()) default_endpoint:
"https://bsc-mainnet.core.chainstack.com/35848e183f3e3303c8cfeacbea831cab/"
.into(),
finality_delay: Some(20),
release_delay: Some(40),
network_type: Default::default(),
gatekeeper: "0x0E09FaBB73Bd3Ade0a17ECC321fD13a19e81cE82".into(),
topic_name: "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"
.into(),
incoming_fee: 0,
outgoing_fee: 0,
}
.encode(),
),
] ]
} }
@ -127,7 +156,12 @@ fn casper_session_keys(
authority_discovery: AuthorityDiscoveryId, authority_discovery: AuthorityDiscoveryId,
slow_clap: SlowClapId, slow_clap: SlowClapId,
) -> SessionKeys { ) -> SessionKeys {
SessionKeys { babe, grandpa, authority_discovery, slow_clap } SessionKeys {
babe,
grandpa,
authority_discovery,
slow_clap,
}
} }
fn testnet_config_genesis( fn testnet_config_genesis(
@ -143,8 +177,7 @@ fn testnet_config_genesis(
ghost_accounts: Option<Vec<(AccountId, u128, u8)>>, ghost_accounts: Option<Vec<(AccountId, u128, u8)>>,
evm_networks: Option<Vec<(u32, Vec<u8>)>>, evm_networks: Option<Vec<(u32, Vec<u8>)>>,
) -> serde_json::Value { ) -> serde_json::Value {
let endowed_accounts: Vec<AccountId> = let endowed_accounts: Vec<AccountId> = endowed_accounts.unwrap_or_else(casper_testnet_accounts);
endowed_accounts.unwrap_or_else(casper_testnet_accounts);
let ghost_accounts: Vec<(AccountId, u128, u8)> = let ghost_accounts: Vec<(AccountId, u128, u8)> =
ghost_accounts.unwrap_or_else(casper_testnet_evm_accounts); ghost_accounts.unwrap_or_else(casper_testnet_evm_accounts);
@ -218,7 +251,9 @@ fn testnet_config_genesis(
fn casper_development_config_genesis() -> serde_json::Value { fn casper_development_config_genesis() -> serde_json::Value {
testnet_config_genesis( testnet_config_genesis(
vec![get_authority_keys_from_seed("Alice")], vec![get_authority_keys_from_seed("Alice")],
None, None, None, None,
None,
None,
) )
} }
@ -226,10 +261,12 @@ fn casper_development_config_genesis() -> serde_json::Value {
fn casper_local_config_genesis() -> serde_json::Value { fn casper_local_config_genesis() -> serde_json::Value {
testnet_config_genesis( testnet_config_genesis(
vec![ vec![
get_authority_keys_from_seed("Alice"), get_authority_keys_from_seed("Alice"),
get_authority_keys_from_seed("Bob"), get_authority_keys_from_seed("Bob"),
], ],
None, None, None, None,
None,
None,
) )
} }
@ -240,15 +277,17 @@ pub fn get_preset(id: &sp_genesis_builder::PresetId) -> Option<sp_std::vec::Vec<
Ok("local_testnet") => casper_local_config_genesis(), Ok("local_testnet") => casper_local_config_genesis(),
_ => return None, _ => return None,
}; };
Some(serde_json::to_string(&patch) Some(
.expect("serialization to json is expected to work; qed") serde_json::to_string(&patch)
.into_bytes()) .expect("serialization to json is expected to work; qed")
.into_bytes(),
)
} }
/// Returns a list of identifiers for available builtin `RuntimeGenesisConfig` presets. /// Returns a list of identifiers for available builtin `RuntimeGenesisConfig` presets.
pub fn preset_names() -> Vec<sp_genesis_builder::PresetId> { pub fn preset_names() -> Vec<sp_genesis_builder::PresetId> {
Vec::from([ Vec::from([
sp_genesis_builder::PresetId::from("local_testnet"), sp_genesis_builder::PresetId::from("local_testnet"),
sp_genesis_builder::PresetId::from("development"), sp_genesis_builder::PresetId::from("development"),
]) ])
} }

View File

@ -1,8 +1,5 @@
use super::*; use super::*;
use frame_support::{ use frame_support::{dispatch::DispatchResultWithPostInfo, traits::PrivilegeCmp};
dispatch::DispatchResultWithPostInfo,
traits::PrivilegeCmp,
};
use pallet_alliance::{ProposalIndex, ProposalProvider}; use pallet_alliance::{ProposalIndex, ProposalProvider};
use sp_runtime::DispatchError; use sp_runtime::DispatchError;
use sp_std::{cmp::Ordering, marker::PhantomData}; use sp_std::{cmp::Ordering, marker::PhantomData};
@ -14,7 +11,8 @@ type HashOf<T> = <T as frame_system::Config>::Hash;
/// Proposal provider for alliance pallet. /// Proposal provider for alliance pallet.
/// Adapter from collective pallet to alliance proposal provider trait. /// Adapter from collective pallet to alliance proposal provider trait.
pub struct AllianceProposalProvider<T, I = ()>(PhantomData<(T, I)>); pub struct AllianceProposalProvider<T, I = ()>(PhantomData<(T, I)>);
impl <T, I> ProposalProvider<AccountIdOf<T>, HashOf<T>, ProposalOf<T, I>> for AllianceProposalProvider<T, I> impl<T, I> ProposalProvider<AccountIdOf<T>, HashOf<T>, ProposalOf<T, I>>
for AllianceProposalProvider<T, I>
where where
T: pallet_collective::Config<I> + frame_system::Config, T: pallet_collective::Config<I> + frame_system::Config,
I: 'static, I: 'static,
@ -25,7 +23,12 @@ where
proposal: Box<ProposalOf<T, I>>, proposal: Box<ProposalOf<T, I>>,
length_bound: u32, length_bound: u32,
) -> Result<(u32, u32), DispatchError> { ) -> Result<(u32, u32), DispatchError> {
pallet_collective::Pallet::<T, I>::do_propose_proposed(who, threshold, proposal, length_bound) pallet_collective::Pallet::<T, I>::do_propose_proposed(
who,
threshold,
proposal,
length_bound,
)
} }
fn vote_proposal( fn vote_proposal(
@ -61,7 +64,7 @@ pub struct EqualOrGreatestRootCmp;
impl PrivilegeCmp<OriginCaller> for EqualOrGreatestRootCmp { impl PrivilegeCmp<OriginCaller> for EqualOrGreatestRootCmp {
fn cmp_privilege(left: &OriginCaller, right: &OriginCaller) -> Option<Ordering> { fn cmp_privilege(left: &OriginCaller, right: &OriginCaller) -> Option<Ordering> {
if left == right { if left == right {
return Some(Ordering::Equal) return Some(Ordering::Equal);
} }
match (left, right) { match (left, right) {

File diff suppressed because it is too large Load Diff