mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-10 13:09:24 +00:00
add fast-epoch feature
This commit is contained in:
1
Cargo.lock
generated
1
Cargo.lock
generated
@@ -7823,6 +7823,7 @@ dependencies = [
|
||||
"serai-coins-pallet",
|
||||
"serai-dex-pallet",
|
||||
"serai-emissions-primitives",
|
||||
"serai-genesis-liquidity-primitives",
|
||||
"serai-primitives",
|
||||
"serai-validator-sets-pallet",
|
||||
"serai-validator-sets-primitives",
|
||||
|
||||
@@ -37,7 +37,8 @@ validator-sets-pallet = { package = "serai-validator-sets-pallet", path = "../..
|
||||
dex-pallet = { package = "serai-dex-pallet", path = "../../dex/pallet", default-features = false }
|
||||
|
||||
serai-primitives = { path = "../../primitives", default-features = false }
|
||||
serai-validator-sets-primitives = { path = "../../validator-sets/primitives", default-features = false }
|
||||
validator-sets-primitives = { package = "serai-validator-sets-primitives", path = "../../validator-sets/primitives", default-features = false }
|
||||
genesis-liquidity-primitives = { package = "serai-genesis-liquidity-primitives", path = "../../genesis-liquidity/primitives", default-features = false }
|
||||
emissions-primitives = { package = "serai-emissions-primitives", path = "../primitives", default-features = false }
|
||||
|
||||
[features]
|
||||
@@ -60,6 +61,8 @@ std = [
|
||||
|
||||
"serai-primitives/std",
|
||||
"emissions-primitives/std",
|
||||
"genesis-liquidity-primitives/std",
|
||||
]
|
||||
fast-epoch = ["genesis-liquidity-primitives/fast-epoch"]
|
||||
|
||||
default = ["std"]
|
||||
@@ -18,7 +18,8 @@ pub mod pallet {
|
||||
use pallet_babe::{Pallet as Babe, Config as BabeConfig};
|
||||
|
||||
use serai_primitives::{NetworkId, NETWORKS, *};
|
||||
use serai_validator_sets_primitives::MAX_KEY_SHARES_PER_SET;
|
||||
use validator_sets_primitives::MAX_KEY_SHARES_PER_SET;
|
||||
use genesis_liquidity_primitives::GENESIS_PERIOD_BLOCKS;
|
||||
use emissions_primitives::*;
|
||||
|
||||
#[pallet::config]
|
||||
@@ -116,7 +117,7 @@ pub mod pallet {
|
||||
|
||||
// emissions start only after genesis period and happens once per epoch
|
||||
// so we don't do anything before that time.
|
||||
if !(n >= BLOCKS_PER_MONTH.into() && T::ShouldEndSession::should_end_session(n)) {
|
||||
if !(n >= GENESIS_PERIOD_BLOCKS.into() && T::ShouldEndSession::should_end_session(n)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -262,7 +263,7 @@ pub mod pallet {
|
||||
}
|
||||
|
||||
fn initial_period(n: BlockNumberFor<T>) -> bool {
|
||||
n >= BLOCKS_PER_MONTH.into() && n < (3 * BLOCKS_PER_MONTH).into()
|
||||
n >= GENESIS_PERIOD_BLOCKS.into() && n < (3 * GENESIS_PERIOD_BLOCKS).into()
|
||||
}
|
||||
|
||||
/// Returns true if any of the external networks haven't reached economic security yet.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
/// Amount of blocks in 30 days for 6s per block.
|
||||
pub const BLOCKS_PER_MONTH: u32 = 10 * 60 * 24 * 30;
|
||||
const BLOCKS_PER_MONTH: u32 = 10 * 60 * 24 * 30;
|
||||
|
||||
/// INITIAL_REWARD = 100,000 SRI / BLOCKS_PER_DAY for 60 days
|
||||
pub const INITIAL_REWARD_PER_BLOCK: u64 = 100_000 * 10u64.pow(8) / ((BLOCKS_PER_MONTH as u64) / 30);
|
||||
|
||||
@@ -56,6 +56,6 @@ std = [
|
||||
"genesis-liquidity-primitives/std",
|
||||
"validator-sets-primitives/std",
|
||||
]
|
||||
fast-epoch = []
|
||||
fast-epoch = ["genesis-liquidity-primitives/fast-epoch"]
|
||||
|
||||
default = ["std"]
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -42,4 +42,5 @@ std = [
|
||||
|
||||
"sp-std/std"
|
||||
]
|
||||
fast-epoch = []
|
||||
default = ["std"]
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -128,7 +128,7 @@ std = [
|
||||
"pallet-transaction-payment-rpc-runtime-api/std",
|
||||
]
|
||||
|
||||
fast-epoch = ["genesis-liquidity-pallet/fast-epoch"]
|
||||
fast-epoch = ["genesis-liquidity-pallet/fast-epoch", "emissions-pallet/fast-epoch"]
|
||||
|
||||
runtime-benchmarks = [
|
||||
"sp-runtime/runtime-benchmarks",
|
||||
|
||||
Reference in New Issue
Block a user