Skip to content

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
nanocryk committed Oct 30, 2023
1 parent c570d15 commit 238b5ee
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 17 deletions.
18 changes: 9 additions & 9 deletions pallets/inflation-rewards/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

//! # Inflation Rewards Pallet
//!
//! This pallet handle native token inflation and rewards dsitribution.
//! This pallet handle native token inflation and rewards distribution.
#![cfg_attr(not(feature = "std"), no_std)]

Expand All @@ -38,7 +38,10 @@ use {
},
},
frame_system::pallet_prelude::*,
sp_runtime::{traits::Get, Perbill},
sp_runtime::{
traits::{Get, Saturating},
Perbill,
},
tp_core::{BlockNumber, ParaId},
tp_traits::{AuthorNotingHook, DistributeRewards, GetCurrentContainerChains},
};
Expand Down Expand Up @@ -66,8 +69,9 @@ pub mod pallet {
let not_distributed_rewards =
if let Some(chains_to_reward) = ChainsToReward::<T>::take() {
// Collect and sum all undistributed rewards
let rewards_not_distributed: BalanceOf<T> = chains_to_reward.rewards_per_chain
* (chains_to_reward.para_ids.len() as u32).into();
let rewards_not_distributed: BalanceOf<T> = chains_to_reward
.rewards_per_chain
.saturating_mul((chains_to_reward.para_ids.len() as u32).into());
T::Currency::withdraw(
&T::PendingRewardsAccount::get(),
rewards_not_distributed,
Expand All @@ -80,10 +84,9 @@ pub mod pallet {
CreditOf::<T>::zero()
};

// Get the number of chains at this block
// Get the number of chains at this block (tanssi + container chain blocks)
weight += T::DbWeight::get().reads_writes(1, 1);
let registered_para_ids = T::ContainerChains::current_container_chains();

let number_of_chains: BalanceOf<T> =
((registered_para_ids.len() as u32).saturating_add(1)).into();

Expand Down Expand Up @@ -138,9 +141,6 @@ pub mod pallet {
/// Inflation rate per relay block (proportion of the total issuance)
type InflationRate: Get<Perbill>;

/// The maximum number of block authors
type MaxAuthors: Get<u32>;

/// What to do with the new supply not dedicated to staking
type OnUnbalanced: OnUnbalanced<CreditOf<Self>>;

Expand Down
2 changes: 1 addition & 1 deletion pallets/invulnerables/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ use super::*;

#[allow(unused)]
use crate::Pallet as InvulnerablesPallet;
use sp_runtime::traits::AtLeast32BitUnsigned;
use {
frame_benchmarking::{account, impl_benchmark_test_suite, v2::*, BenchmarkError},
frame_support::{
Expand All @@ -31,6 +30,7 @@ use {
},
frame_system::{EventRecord, RawOrigin},
pallet_session::{self as session, SessionManager},
sp_runtime::traits::AtLeast32BitUnsigned,
sp_std::prelude::*,
tp_traits::DistributeRewards,
};
Expand Down
3 changes: 1 addition & 2 deletions pallets/invulnerables/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,7 @@ pub struct InvulnerableRewardDistribution<Runtime, Currency, Fallback>(
PhantomData<(Runtime, Currency, Fallback)>,
);

use frame_support::pallet_prelude::Weight;
use sp_runtime::traits::Get;
use {frame_support::pallet_prelude::Weight, sp_runtime::traits::Get};

type CreditOf<Runtime, Currency> =
frame_support::traits::fungible::Credit<<Runtime as frame_system::Config>::AccountId, Currency>;
Expand Down
1 change: 0 additions & 1 deletion pallets/pooled-staking/src/pools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,6 @@ impl<T: Config> ManualRewards<T> {
/// AutoCompounding shares. This can lead to some rounding, which will be
/// absorbed in the ManualRewards distribution, which simply consist of
/// transfering the funds to the candidate account.
#[allow(dead_code)]
#[frame_support::transactional]
pub fn distribute_rewards<T: Config>(
candidate: &Candidate<T>,
Expand Down
3 changes: 1 addition & 2 deletions runtime/dancebox/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1135,8 +1135,7 @@ parameter_types! {
pub const RewardsPortion: Perbill = Perbill::from_percent(70);
}

use nimbus_primitives::SlotBeacon;
use tp_traits::GetContainerChainAuthor;
use {nimbus_primitives::SlotBeacon, tp_traits::GetContainerChainAuthor};

pub struct GetSelfChainBlockAuthor;
impl Get<AccountId32> for GetSelfChainBlockAuthor {
Expand Down
6 changes: 4 additions & 2 deletions runtime/dancebox/tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,10 @@ pub fn set_parachain_inherent_data() {
}

pub fn set_parachain_inherent_data_random_seed(random_seed: [u8; 32]) {
use cumulus_primitives_core::relay_chain::well_known_keys;
use cumulus_test_relay_sproof_builder::RelayStateSproofBuilder;
use {
cumulus_primitives_core::relay_chain::well_known_keys,
cumulus_test_relay_sproof_builder::RelayStateSproofBuilder,
};

let (relay_parent_storage_root, relay_chain_state) = {
let mut sproof = RelayStateSproofBuilder::default();
Expand Down

0 comments on commit 238b5ee

Please sign in to comment.