applause based on the external expousre

Signed-off-by: Uncle Stinky <uncle.stinky@ghostchain.io>
This commit is contained in:
Uncle Stinky
2025-11-21 13:46:22 +03:00
parent 0bb46482b2
commit 6a2b5a34d2
4 changed files with 144 additions and 57 deletions

View File

@@ -9,7 +9,7 @@ use pallet_session::historical as pallet_session_historical;
use sp_runtime::{
curve::PiecewiseLinear,
testing::{TestXt, UintAuthorityId},
traits::ConvertInto,
traits::{AtLeast32BitUnsigned, ConvertInto},
Permill,
};
use sp_staking::{
@@ -20,7 +20,7 @@ use sp_staking::{
use sp_runtime::BuildStorage;
use crate as slow_clap;
use crate::Config;
use crate::{ApplauseListener, Config, EraIndex};
type Block = frame_system::mocking::MockBlock<Runtime>;
@@ -174,6 +174,32 @@ impl pallet_balances::Config for Runtime {
type WeightInfo = ();
}
type Balance = u64;
pub struct TestSomeCoolTrait;
impl ApplauseListener<Balance> for TestSomeCoolTrait
where
Balance: AtLeast32BitUnsigned + From<u64>,
{
fn get_current_era() -> EraIndex {
1
}
fn get_threshold_amount(_era: EraIndex) -> Balance {
666_666_667u64.into()
}
fn get_validator_total_exposure(_era: EraIndex, index: usize) -> Balance {
match index {
0 => 500_000_000u64,
1 => 300_000_000u64,
2 => 200_000_000u64,
_ => 0,
}
.into()
}
}
impl Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type AuthorityId = UintAuthorityId;
@@ -184,6 +210,7 @@ impl Config for Runtime {
type BlockNumberProvider = System;
type ReportUnresponsiveness = OffenceHandler;
type DisabledValidators = Session;
type ApplauseListener = TestSomeCoolTrait;
type MaxAuthorities = ConstU32<5>;
type ApplauseThreshold = ConstU32<50>;