rustfmt common runtime and fix typos
Signed-off-by: Uncle Stretch <uncle.stretch@ghostchain.io>
This commit is contained in:
parent
8d69e5c87e
commit
24a6f803c5
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "ghost-runtime-common"
|
||||
version = "0.4.2"
|
||||
version = "0.4.3"
|
||||
authors.workspace = true
|
||||
edition.workspace = true
|
||||
homepage.workspace = true
|
||||
|
@ -1,11 +1,13 @@
|
||||
use primitives::{AccountId, Balance};
|
||||
use pallet_treasury::ArgumentsFactory;
|
||||
use sp_core::crypto::FromEntropy;
|
||||
use frame_support::traits::tokens::{Pay, PaymentStatus};
|
||||
use pallet_treasury::ArgumentsFactory;
|
||||
use primitives::{AccountId, Balance};
|
||||
use sp_core::crypto::FromEntropy;
|
||||
|
||||
pub struct BenchmarkTreasuryHelper;
|
||||
impl ArgumentsFactory<(), AccountId> for BenchmarkTreasuryHelper {
|
||||
fn create_asset_kind(_seed: u32) -> () { () }
|
||||
fn create_asset_kind(_seed: u32) -> () {
|
||||
()
|
||||
}
|
||||
fn create_beneficiary(seed: [u8; 32]) -> AccountId {
|
||||
AccountId::from_entropy(&mut seed.as_slice()).unwrap()
|
||||
}
|
||||
@ -19,8 +21,16 @@ impl Pay for BenchmarkTreasuryPaymaster {
|
||||
type AssetKind = ();
|
||||
type Error = ();
|
||||
|
||||
fn pay(_: &Self::Beneficiary, _: Self::AssetKind, _: Self::Balance) -> Result<Self::Id, Self::Error> { Ok(()) }
|
||||
fn check_payment(_: Self::Id) -> PaymentStatus { PaymentStatus::Success }
|
||||
fn pay(
|
||||
_: &Self::Beneficiary,
|
||||
_: Self::AssetKind,
|
||||
_: Self::Balance,
|
||||
) -> Result<Self::Id, Self::Error> {
|
||||
Ok(())
|
||||
}
|
||||
fn check_payment(_: Self::Id) -> PaymentStatus {
|
||||
PaymentStatus::Success
|
||||
}
|
||||
fn ensure_successful(_: &Self::Beneficiary, _: Self::AssetKind, _: Self::Balance) {}
|
||||
fn ensure_concluded(_: Self::Id) {}
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ mod tests {
|
||||
parameter_types,
|
||||
traits::{
|
||||
tokens::{PayFromAccount, UnityAssetBalanceConversion},
|
||||
ConstU32, FindAuthor
|
||||
ConstU32, FindAuthor,
|
||||
},
|
||||
weights::Weight,
|
||||
PalletId,
|
||||
@ -65,7 +65,7 @@ mod tests {
|
||||
use sp_core::{ConstU64, H256};
|
||||
use sp_runtime::{
|
||||
traits::{BlakeTwo256, IdentityLookup},
|
||||
Perbill, BuildStorage,
|
||||
BuildStorage, Perbill,
|
||||
};
|
||||
|
||||
type Block = frame_system::mocking::MockingBlock<Test>;
|
||||
@ -172,7 +172,10 @@ mod tests {
|
||||
|
||||
pub struct OneAuthor;
|
||||
impl FindAuthor<AccountId> for OneAuthor {
|
||||
fn find_author<'a, I>(_: I) -> Option<AccountId> where I: 'a {
|
||||
fn find_author<'a, I>(_: I) -> Option<AccountId>
|
||||
where
|
||||
I: 'a,
|
||||
{
|
||||
Some(TEST_ACCOUNT)
|
||||
}
|
||||
}
|
||||
@ -185,7 +188,9 @@ mod tests {
|
||||
}
|
||||
|
||||
pub fn new_test_ext() -> sp_io::TestExternalities {
|
||||
let mut t = frame_system::GenesisConfig::default().build_storage::<Test>().unwrap();
|
||||
let mut t = frame_system::GenesisConfig::default()
|
||||
.build_storage::<Test>()
|
||||
.unwrap();
|
||||
// We use default for brevity, but you can configure as desired if needed.
|
||||
pallet_balances::GenesisConfig::<Test>::default()
|
||||
.assimilate_storage(&mut t)
|
||||
@ -196,8 +201,14 @@ mod tests {
|
||||
#[test]
|
||||
fn test_fees_and_tips_split() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let fee = <paller_balances::Pallet<Test> as frame_support::traits::fungible::Balanced<AccountId>>::issue(10);
|
||||
let tip = <paller_balances::Pallet<Test> as frame_support::traits::fungible::Balanced<AccountId>>::issue(20);
|
||||
let fee =
|
||||
<paller_balances::Pallet<Test> as frame_support::traits::fungible::Balanced<
|
||||
AccountId,
|
||||
>>::issue(10);
|
||||
let tip =
|
||||
<paller_balances::Pallet<Test> as frame_support::traits::fungible::Balanced<
|
||||
AccountId,
|
||||
>>::issue(20);
|
||||
|
||||
assert_eq!(Balances::free_balance(Treasury::account_id()), 0);
|
||||
assert_eq!(Balances::free_balance(TEST_ACCOUNT), 0);
|
||||
@ -242,11 +253,23 @@ mod tests {
|
||||
#[test]
|
||||
fn era_payout_should_give_sensible_results() {
|
||||
assert_eq!(
|
||||
era_payout(75, 100, Perquintill::from_percent(10), Perquintill::one(), 0, ),
|
||||
era_payout(
|
||||
75,
|
||||
100,
|
||||
Perquintill::from_percent(10),
|
||||
Perquintill::one(),
|
||||
0,
|
||||
),
|
||||
(10, 0)
|
||||
);
|
||||
assert_eq!(
|
||||
era_payout(80, 100, Perquintill::from_percent(10), Perquintill::one(), 0, ),
|
||||
era_payout(
|
||||
80,
|
||||
100,
|
||||
Perquintill::from_percent(10),
|
||||
Perquintill::one(),
|
||||
0,
|
||||
),
|
||||
(6, 4)
|
||||
);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
pub mod impls;
|
||||
pub mod elections;
|
||||
pub mod impls;
|
||||
|
||||
#[cfg(feature = "try-runtime")]
|
||||
pub mod elections;
|
||||
@ -10,7 +10,8 @@ pub mod elections;
|
||||
pub mod benchmarking;
|
||||
|
||||
use frame_support::{
|
||||
parameter_types, traits::ConstU32,
|
||||
parameter_types,
|
||||
traits::ConstU32,
|
||||
weights::{constants::WEIGHT_REF_TIME_PER_SECOND, Weight},
|
||||
};
|
||||
use frame_system::limits;
|
||||
@ -92,8 +93,8 @@ macro_rules! impl_runtime_weights {
|
||||
use frame_system::limits;
|
||||
use pallet_transaction_payment::{Multiplier, TargetedFeeAdjustment};
|
||||
pub use runtime_common::{
|
||||
impl_elections_weights, AVERAGE_ON_INITIALIZE_RATIO,
|
||||
MAXIMUM_BLOCK_WEIGHT, NORMAL_DISPATCH_RATIO,
|
||||
impl_elections_weights, AVERAGE_ON_INITIALIZE_RATIO, MAXIMUM_BLOCK_WEIGHT,
|
||||
NORMAL_DISPATCH_RATIO,
|
||||
};
|
||||
use sp_runtime::{FixedPointNumber, Perquintill};
|
||||
|
||||
@ -101,8 +102,7 @@ macro_rules! impl_runtime_weights {
|
||||
|
||||
// Expose the weight from the runtime constants module.
|
||||
pub use $runtime::weights::{
|
||||
BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight,
|
||||
ParityDbWeight,
|
||||
BlockExecutionWeight, ExtrinsicBaseWeight, ParityDbWeight, RocksDbWeight,
|
||||
};
|
||||
|
||||
parameter_types! {
|
||||
@ -129,7 +129,6 @@ macro_rules! impl_runtime_weights {
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/// The type used for currency conversion.
|
||||
///
|
||||
/// This must be only be used as long as the balance type is `u128`.
|
||||
|
@ -4,7 +4,7 @@ use frame_support::{
|
||||
};
|
||||
use pallet_fast_unstake::{Pallet as FastUnstake, *};
|
||||
use pallet_staking::*;
|
||||
use sp_std::{collections::btree_set::BTreeSet, prelude:*};
|
||||
use sp_std::{collections::btree_set::BTreeSet, prelude::*};
|
||||
|
||||
/// Register all inactive nominators for fast unstake, and progress until they
|
||||
/// have all benn processed.
|
||||
@ -16,7 +16,9 @@ where
|
||||
let mut unstaked_err = 0;
|
||||
let mut unstaked_slashed = 0;
|
||||
|
||||
let all_stakers = Ledger::<T>::iter().map(|(ctrl, l)| (ctrl, l.stash)).collect::<BTreeSet<_>>();
|
||||
let all_stakers = Ledger::<T>::iter()
|
||||
.map(|(ctrl, l)| (ctrl, l.stash))
|
||||
.collect::<BTreeSet<_>>();
|
||||
let mut all_exposed = BTreeSet::new();
|
||||
ErasStakers::<T>::iter().for_each(|(_, val, expo)| {
|
||||
all_exposed.insert(val);
|
||||
@ -70,15 +72,16 @@ where
|
||||
maybe_fast_unstake_event
|
||||
})
|
||||
.for_each(|e: pallet_fast_unstake::Event<T>| match e {
|
||||
pallet_fast_unstake::Event<T>::Unstaked { result, .. } =>
|
||||
pallet_fast_unstake::Event::<T>::Unstaked { result, .. } => {
|
||||
if result.is_ok() {
|
||||
unstaked_ok += 1;
|
||||
} else {
|
||||
unstaked_err += 1;
|
||||
},
|
||||
}
|
||||
}
|
||||
pallet_fast_unstake::Event::<T>::Slashed { .. } => unstaked_slashed += 1,
|
||||
pallet_fast_unstake::Event::<T>::InternalError { .. } => unreachable!(),
|
||||
_ => {},
|
||||
_ => {}
|
||||
});
|
||||
|
||||
if now % 100u32.into() == sp_runtime::traits::Zero::zero() {
|
||||
|
Loading…
Reference in New Issue
Block a user