Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/Identity benchmarks #231

Merged
merged 6 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pallets/funding/src/instantiator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ impl<
for UserToPLMCBalance { account, plmc_amount } in correct_funds {
self.execute(|| {
let reserved = <T as Config>::NativeCurrency::balance_on_hold(&reserve_type, &account);
assert_eq!(reserved, plmc_amount, "account {account} has unexpected reserved plmc balance");
assert_eq!(reserved, plmc_amount, "account has unexpected reserved plmc balance");
});
}
}
Expand Down Expand Up @@ -261,7 +261,7 @@ impl<
for UserToPLMCBalance { account, plmc_amount } in correct_funds {
self.execute(|| {
let free = <T as Config>::NativeCurrency::balance(&account);
assert_eq!(free, plmc_amount, "account {account} has unexpected free plmc balance");
assert_eq!(free, plmc_amount, "account has unexpected free plmc balance");
});
}
}
Expand Down
4 changes: 2 additions & 2 deletions runtimes/polimec/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use frame_support::{
},
weights::{ConstantMultiplier, Weight},
};
use frame_system::{EnsureNever, EnsureRoot, EnsureRootWithSuccess, EnsureSigned};
use frame_system::{EnsureRoot, EnsureRootWithSuccess, EnsureSigned};
use pallet_democracy::GetElectorate;

use parachains_common::{
Expand Down Expand Up @@ -892,7 +892,7 @@ impl pallet_identity::Config for Runtime {
type SigningPublicKey = <Signature as Verify>::Signer;
type Slashed = Treasury;
type SubAccountDeposit = SubAccountDeposit;
type UsernameAuthorityOrigin = EnsureNever<AccountId>;
type UsernameAuthorityOrigin = UsernameAuthorityOrigin;
type WeightInfo = pallet_identity::weights::SubstrateWeight<Runtime>;
}

Expand Down
4 changes: 2 additions & 2 deletions runtimes/politest/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use frame_support::{
},
weights::{ConstantMultiplier, Weight},
};
use frame_system::{EnsureNever, EnsureRoot, EnsureRootWithSuccess, EnsureSigned};
use frame_system::{EnsureRoot, EnsureRootWithSuccess, EnsureSigned};
use pallet_democracy::GetElectorate;
use pallet_funding::DaysToBlocks;

Expand Down Expand Up @@ -924,7 +924,7 @@ impl pallet_identity::Config for Runtime {
type SigningPublicKey = <Signature as Verify>::Signer;
type Slashed = Treasury;
type SubAccountDeposit = SubAccountDeposit;
type UsernameAuthorityOrigin = EnsureNever<AccountId>;
type UsernameAuthorityOrigin = UsernameAuthorityOrigin;
type WeightInfo = pallet_identity::weights::SubstrateWeight<Runtime>;
}

Expand Down
26 changes: 22 additions & 4 deletions runtimes/shared-configuration/src/identity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,45 @@

use crate::{deposit, Balance, PLMC};
use frame_support::parameter_types;
use parachains_common::AccountId;

parameter_types! {
/// The basic deposit to create an identity.
pub const BasicDeposit: Balance = 20 * PLMC;
/// Deposit for each additional field.
pub const ByteDeposit: Balance = deposit(0, 1);

/// The number of blocks within which a username grant must be accepted.
pub const PendingUsernameExpiration: u32 = 0;
/// The deposit needed to create a sub-account.
/// We do not allow sub-accounts so can be 0.
/// Should be set to a non-zero value if sub-accounts are allowed.
pub const SubAccountDeposit: Balance = 0;
/// Max number of sub-accounts that can be created.
/// We do not allow sub-accounts so set to 0.
pub const MaxSubAccounts: u32 = 0;
/// Max number of additional fields that can be created.
pub const MaxAdditionalFields: u32 = 100;
/// Max number of registrars that can be set.
pub const MaxRegistrars: u32 = 3;
}

#[cfg(not(feature = "runtime-benchmarks"))]
parameter_types! {
/// Max number of sub-accounts that can be created.
/// We do not allow sub-accounts so set to 0.
pub const MaxSubAccounts: u32 = 0;
/// Max length of username suffix.
pub const MaxSuffixLength: u32 = 0;
/// Max length of username.
pub const MaxUsernameLength: u32 = 0;
}

#[cfg(feature = "runtime-benchmarks")]
parameter_types! {
pub const MaxSubAccounts: u32 = 1;
pub const MaxSuffixLength: u32 = 24;
pub const MaxUsernameLength: u32 = 32;
}

#[cfg(not(feature = "runtime-benchmarks"))]
pub type UsernameAuthorityOrigin = frame_system::EnsureNever<AccountId>;

#[cfg(feature = "runtime-benchmarks")]
pub type UsernameAuthorityOrigin = frame_system::EnsureRoot<AccountId>;