Skip to content

Commit

Permalink
add wrapper for session manager
Browse files Browse the repository at this point in the history
  • Loading branch information
dmoka committed Dec 3, 2024
1 parent 8ccc36a commit 5c31e58
Showing 1 changed file with 30 additions and 3 deletions.
33 changes: 30 additions & 3 deletions runtime/basilisk/src/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

use super::*;
use crate::governance::{origins::GeneralAdmin, TechCommitteeMajority, TechnicalCollective, TreasuryAccount};
use sp_io::transaction_index::index;

use pallet_transaction_multi_payment::{DepositAll, TransferFees};
use pallet_transaction_payment::{Multiplier, TargetedFeeAdjustment};
Expand Down Expand Up @@ -540,12 +541,36 @@ impl pallet_collator_rewards::Config for Runtime {
type RewardPerCollator = RewardPerCollator;
type RewardCurrencyId = NativeAssetId;
type ExcludedCollators = ExcludedCollators;
// We wrap the ` SessionManager` implementation of `CollatorSelection` to get the collatrs that
// we hand out rewards to.
type SessionManager = CollatorSelection;

type SessionManager = RotatingCollatorManager;
type MaxCandidates = MaxInvulnerables;
}

pub struct RotatingCollatorManager;
impl SessionManager<AccountId> for RotatingCollatorManager {
fn new_session(new_index: SessionIndex) -> Option<Vec<AccountId>> {
// We wrap the ` SessionManager` implementation of `CollatorSelection` to get the collators that
// we hand out rewards to,
// then we rotate the collators to have a regular distribution for block production

let mut collators = CollatorSelection::new_session(new_index)?;

if !collators.is_empty() {
collators.rotate_left(1);
}

Some(collators)
}

fn end_session(end_index: SessionIndex) {
CollatorSelection::end_session(end_index)
}

fn start_session(start_index: SessionIndex) {
CollatorSelection::start_session(start_index)
}
}

parameter_types! {
pub const BasicDeposit: Balance = 5 * DOLLARS;
pub const ByteDeposit: Balance = DOLLARS / 10;
Expand Down Expand Up @@ -614,6 +639,8 @@ use frame_system::EnsureSigned;

#[cfg(not(feature = "runtime-benchmarks"))]
use frame_system::EnsureSignedBy;
use pallet_session::SessionManager;
use sp_staking::SessionIndex;

impl pallet_state_trie_migration::Config for Runtime {
type ControlOrigin = EnsureRoot<Self::AccountId>;
Expand Down

0 comments on commit 5c31e58

Please sign in to comment.