add fast-epoch feature

This commit is contained in:
akildemir
2024-05-05 11:49:37 +03:00
parent 3ed6bd3b76
commit 1d5a53dad4
9 changed files with 20 additions and 16 deletions

View File

@@ -56,6 +56,6 @@ std = [
"genesis-liquidity-primitives/std",
"validator-sets-primitives/std",
]
fast-epoch = []
fast-epoch = ["genesis-liquidity-primitives/fast-epoch"]
default = ["std"]

View File

@@ -94,14 +94,8 @@ pub mod pallet {
#[pallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
fn on_finalize(n: BlockNumberFor<T>) {
#[cfg(feature = "fast-epoch")]
let final_block = 25u32;
#[cfg(not(feature = "fast-epoch"))]
let final_block = BLOCKS_PER_MONTH;
// Distribute the genesis sri to pools after a month
if n == final_block.into() {
if n == GENESIS_PERIOD_BLOCKS.into() {
// mint the SRI
Coins::<T>::mint(
GENESIS_LIQUIDITY_ACCOUNT.into(),
@@ -261,7 +255,7 @@ pub mod pallet {
}
fn genesis_ended() -> bool {
<frame_system::Pallet<T>>::block_number() >= BLOCKS_PER_MONTH.into()
<frame_system::Pallet<T>>::block_number() >= GENESIS_PERIOD_BLOCKS.into()
}
}

View File

@@ -42,4 +42,5 @@ std = [
"sp-std/std"
]
fast-epoch = []
default = ["std"]

View File

@@ -19,7 +19,11 @@ use serai_primitives::*;
use validator_sets_primitives::ValidatorSet;
// amount of blocks in 30 days for 6s per block.
pub const BLOCKS_PER_MONTH: u32 = 10 * 60 * 24 * 30;
#[cfg(not(feature = "fast-epoch"))]
pub const GENESIS_PERIOD_BLOCKS: u32 = 10 * 60 * 24 * 30;
#[cfg(feature = "fast-epoch")]
pub const GENESIS_PERIOD_BLOCKS: u32 = 25;
/// 180 days of blocks
pub const GENESIS_SRI_TRICKLE_FEED: u64 = 10 * 60 * 24 * 180;