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]
name = "casper-runtime"
version = "3.5.28"
version = "3.5.29"
build = "build.rs"
description = "Runtime of the Casper Network"
edition.workspace = true

View File

@ -10,15 +10,15 @@ pub mod currency {
/// 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
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
(items as Balance) * 200 * STRH + (bytes as Balance) * 1000 * STNK
}
}
@ -86,7 +86,7 @@ pub mod fee {
#[cfg(test)]
mod tests {
use super::{
currency::{STNK, STRH, CSPR},
currency::{CSPR, STNK, STRH},
fee::WeightToFee,
};
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};
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: 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;
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."
);
}
}

View File

@ -37,43 +37,43 @@ 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);
/// 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;
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();
/// 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."
);
}
// 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."
);
}
}

View File

@ -1,9 +1,9 @@
pub mod block_weights;
pub mod extrinsic_weights;
pub mod rocksdb_weights;
pub mod paritydb_weights;
pub mod rocksdb_weights;
pub use block_weights::BlockExecutionWeight;
pub use extrinsic_weights::ExtrinsicBaseWeight;
pub use rocksdb_weights::constants::RocksDbWeight;
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`.
pub mod constants {
use frame_support::weights::constants;
use sp_core::parameter_types;
use sp_weights::RuntimeDbWeight;
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,
};
}
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;
#[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."
);
}
}
/// 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."
);
}
}
}

View File

@ -36,47 +36,47 @@
/// 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;
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,
};
}
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;
#[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."
);
}
}
/// 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."
);
}
}
}

View File

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

View File

@ -2,25 +2,34 @@ use super::*;
use frame_support::{
parameter_types,
traits::{
EitherOf, EitherOfDiverse, MapSuccess, OriginTrait, TryWithMorphedArg,
tokens::pay::PayFromAccount,
tokens::pay::PayFromAccount, EitherOf, EitherOfDiverse, MapSuccess, OriginTrait,
TryWithMorphedArg,
},
};
use frame_system::EnsureRootWithSuccess;
use pallet_ranked_collective::EnsureOfRank;
use sp_core::{ConstU128, ConstU32};
use sp_runtime::traits::{ConstU16, TakeFirst};
use pallet_ranked_collective::EnsureOfRank;
use crate::{
AccountId,
Balance,
Balances,
Preimage,
Runtime,
// weights,
RuntimeCall, RuntimeEvent, Scheduler, DAYS, CSPR, AccountId, Balance,
TreasuryAccount, Balances, Preimage, Runtime,
RuntimeCall,
RuntimeEvent,
Scheduler,
TreasuryAccount,
CSPR,
DAYS,
};
mod origins;
pub use origins::{
pallet_cult_origins, Geniuses, Degens, Zombies, Skeletons, Ghosts,
EnsureCanRetainAt, EnsureCanPromoteTo, EnsureCult, ToVoice, CultTreasurySpender,
pallet_cult_origins, CultTreasurySpender, Degens, EnsureCanPromoteTo, EnsureCanRetainAt,
EnsureCult, Geniuses, Ghosts, Skeletons, ToVoice, Zombies,
};
mod tracks;
@ -45,14 +54,10 @@ parameter_types! {
impl pallet_whitelist::Config for Runtime {
type RuntimeCall = RuntimeCall;
type RuntimeEvent = RuntimeEvent;
type WhitelistOrigin = EitherOfDiverse<
EnsureRootWithSuccess<Self::AccountId, ConstU16<65535>>,
Skeletons,
>;
type DispatchWhitelistedOrigin = EitherOf<
EnsureRootWithSuccess<Self::AccountId, ConstU16<65535>>,
Geniuses,
>;
type WhitelistOrigin =
EitherOfDiverse<EnsureRootWithSuccess<Self::AccountId, ConstU16<65535>>, Skeletons>;
type DispatchWhitelistedOrigin =
EitherOf<EnsureRootWithSuccess<Self::AccountId, ConstU16<65535>>, Geniuses>;
type Preimages = Preimage;
type WeightInfo = weights::pallet_whitelist::WeightInfo<Runtime>;
}
@ -81,7 +86,7 @@ impl pallet_referenda::Config<CultReferendaInstance> for Runtime {
(AccountId, u16),
>,
TakeFirst,
>
>,
>;
type CancelOrigin = Skeletons;
type KillOrigin = Ghosts;
@ -135,10 +140,13 @@ impl pallet_core_fellowship::Config<CultCoreInstance> for Runtime {
type Members = pallet_ranked_collective::Pallet<Runtime, CultCollectiveInstance>;
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 ApproveOrigin = EitherOf<EnsureRootWithSuccess<Self::AccountId, ConstU16<65535>>, EnsureCanRetainAt>;
type PromoteOrigin = EitherOf<EnsureRootWithSuccess<Self::AccountId, ConstU16<65535>>, EnsureCanPromoteTo>;
type ApproveOrigin =
EitherOf<EnsureRootWithSuccess<Self::AccountId, ConstU16<65535>>, EnsureCanRetainAt>;
type PromoteOrigin =
EitherOf<EnsureRootWithSuccess<Self::AccountId, ConstU16<65535>>, EnsureCanPromoteTo>;
type EvidenceSize = ConstU32<65536>;
}

View File

@ -5,8 +5,8 @@ pub use pallet_cult_origins::*;
#[frame_support::pallet]
pub mod pallet_cult_origins {
use crate::{Balance, CSPR};
use super::ranks;
use crate::{Balance, CSPR};
use frame_support::pallet_prelude::*;
use pallet_ranked_collective::Rank;

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 sp_runtime::{traits::Convert, Perbill};
@ -255,7 +255,6 @@ const TRACKS_DATA: [(u16, pallet_referenda::TrackInfo<Balance, BlockNumber>); 15
min_support: RETAIN_MIN_SUPPORT,
},
),
(
constants::PROMOTE_TO_GENIUSES,
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!
let root: Self::RuntimeOrigin = frame_system::RawOrigin::Root.into();
if &root == id {
return Ok(tracks::GHOSTS)
return Ok(tracks::GHOSTS);
}
}

View File

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

View File

@ -1,8 +1,5 @@
use super::*;
use frame_support::{
dispatch::DispatchResultWithPostInfo,
traits::PrivilegeCmp,
};
use frame_support::{dispatch::DispatchResultWithPostInfo, traits::PrivilegeCmp};
use pallet_alliance::{ProposalIndex, ProposalProvider};
use sp_runtime::DispatchError;
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.
/// Adapter from collective pallet to alliance proposal provider trait.
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
T: pallet_collective::Config<I> + frame_system::Config,
I: 'static,
@ -25,7 +23,12 @@ where
proposal: Box<ProposalOf<T, I>>,
length_bound: u32,
) -> 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(
@ -61,7 +64,7 @@ pub struct EqualOrGreatestRootCmp;
impl PrivilegeCmp<OriginCaller> for EqualOrGreatestRootCmp {
fn cmp_privilege(left: &OriginCaller, right: &OriginCaller) -> Option<Ordering> {
if left == right {
return Some(Ordering::Equal)
return Some(Ordering::Equal);
}
match (left, right) {

File diff suppressed because it is too large Load Diff