Browse Source

runtime: reduce validator stake unbonding period to 1 day

Mokhtar Naamani 4 years ago
parent
commit
21529850cf
2 changed files with 38 additions and 1 deletions
  1. 37 0
      runtime/src/constantine.rs
  2. 1 1
      runtime/src/lib.rs

+ 37 - 0
runtime/src/constantine.rs

@@ -0,0 +1,37 @@
+// Clippy linter warning
+#![allow(clippy::redundant_closure_call)] // disable it because of the substrate lib design
+
+use rstd::prelude::*;
+use srml_support::{debug, decl_event, decl_module, decl_storage, traits::Get};
+
+pub trait Trait: system::Trait {
+    type Event: From<Event> + Into<<Self as system::Trait>::Event>;
+    type TheValue: Get<u32>;
+}
+
+decl_storage! {
+    trait Store for Module<T: Trait> as Constantine {
+        // compiler error: "use of undeclared type or module `T`"
+        // pub InitialValue get(initial_value): u32 = T::TheValue::get();
+        pub InitialValue get(initial_value) build(|_: &GenesisConfig| T::TheValue::get()): u32;
+    }
+}
+
+decl_event! {
+    pub enum Event {
+        TheValueIs(u32),
+    }
+}
+
+decl_module! {
+    pub struct Module<T: Trait> for enum Call where origin: T::Origin {
+        const TheValue: u32 = T::TheValue::get();
+
+        fn deposit_event() = default;
+
+        fn on_initialize(_now: T::BlockNumber) {
+            debug::print!("T::TheValue::get() ==> {:?}", T::TheValue::get());
+            Self::deposit_event(Event::TheValueIs(T::TheValue::get()));
+        }
+    }
+}

+ 1 - 1
runtime/src/lib.rs

@@ -368,7 +368,7 @@ srml_staking_reward_curve::build! {
 
 parameter_types! {
     pub const SessionsPerEra: sr_staking_primitives::SessionIndex = 6;
-    pub const BondingDuration: staking::EraIndex = 24 * 28;
+    pub const BondingDuration: staking::EraIndex = 24;
     pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE;
 }