Skip to content

Commit

Permalink
Add Identity Pallet to Runtime and Configuration (#750)
Browse files Browse the repository at this point in the history
* pallet_identity as dep

* added pallet identity

* merge main

* Review #750 (#755)

* add treasury module to identity configuration; use default idendity weights; use parameter_types macro instead of Const

* improve comments

* fmt

* increase e2e timeout

---------

Co-authored-by: magecnion <magecnion@gmail.com>
  • Loading branch information
asiniscalchi and magecnion authored Sep 3, 2024
1 parent 9ffd116 commit 8324424
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 1 deletion.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ pallet-session = { git = "https://github.com/paritytech/polkadot-sdk", branch =
pallet-sudo = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.11.0", default-features = false }
pallet-multisig = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.11.0", default-features = false }
pallet-timestamp = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.11.0", default-features = false }
pallet-identity = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.11.0", default-features = false }
pallet-elections-phragmen = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.11.0", default-features = false }
pallet-treasury = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.11.0", default-features = false }
pallet-collective = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.11.0", default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion e2e-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"fmt-check": "prettier ./tests --check",
"fmt": "prettier ./tests --write",
"build": "./compile_contracts.sh",
"test": "mocha -r ts-node/register -t 270000 'tests/**/*.ts'",
"test": "mocha -r ts-node/register -t 600000 'tests/**/*.ts'",
"test-sql": "FRONTIER_BACKEND_TYPE='sql' mocha -r ts-node/register 'tests/**/*.ts'"
},
"author": "",
Expand Down
4 changes: 4 additions & 0 deletions runtime/laos/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ pallet-balances = { workspace = true , features = ["insecure_zero_ed"] }
pallet-message-queue = { workspace = true }
pallet-multisig = { workspace = true }
pallet-session = { workspace = true }
pallet-identity = { workspace = true }
pallet-sudo = { workspace = true }
pallet-treasury = { workspace = true }
pallet-preimage = { workspace = true }
Expand Down Expand Up @@ -155,6 +156,7 @@ std = [
"pallet-asset-metadata-extender/std",
"pallet-multisig/std",
"pallet-timestamp/std",
"pallet-identity/std",
"pallet-transaction-payment-rpc-runtime-api/std",
"pallet-vesting/std",
"pallet-precompiles-benchmark/std",
Expand Down Expand Up @@ -216,6 +218,7 @@ runtime-benchmarks = [
"frame-system-benchmarking/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"pallet-assets/runtime-benchmarks",
"pallet-identity/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
"pallet-collective/runtime-benchmarks",
"pallet-preimage/runtime-benchmarks",
Expand Down Expand Up @@ -258,6 +261,7 @@ try-runtime = [
"pallet-aura/try-runtime",
"pallet-authorship/try-runtime",
"pallet-balances/try-runtime",
"pallet-identity/try-runtime",
"pallet-session/try-runtime",
"pallet-sudo/try-runtime",
"pallet-collective/try-runtime",
Expand Down
48 changes: 48 additions & 0 deletions runtime/laos/src/configs/identity.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
use crate::{
currency::calculate_deposit, AccountId, Balance, Balances, Runtime, RuntimeEvent, Signature,
Treasury,
};
use frame_support::parameter_types;
use frame_system::EnsureRoot;
use parachains_common::DAYS;

parameter_types! {
pub const MaxSubAccounts: u32 = 100;
pub const MaxAdditionalFields: u32 = 100;
pub const MaxRegistrars: u32 = 20;
pub const PendingUsernameExpiration: u32 = 7 * DAYS;
pub const MaxSuffixLength: u32 = 7;
pub const MaxUsernameLength: u32 = 32;
pub const BasicDeposit: Balance = calculate_deposit(1, 258);
pub const ByteDeposit: Balance = calculate_deposit(0, 1);
pub const SubAccountDeposit: Balance = calculate_deposit(0, 53);
}

type IdentityForceOrigin = EnsureRoot<AccountId>;
type IdentityRegistrarOrigin = EnsureRoot<AccountId>;

impl pallet_identity::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type Currency = Balances;
// Add one item in storage and take 258 bytes
type BasicDeposit = BasicDeposit;
// Does not add any item to the storage but takes 1 bytes
type ByteDeposit = ByteDeposit;
// Add one item in storage and take 53 bytes
type SubAccountDeposit = SubAccountDeposit;
type MaxSubAccounts = MaxSubAccounts;
type IdentityInformation = pallet_identity::legacy::IdentityInfo<MaxAdditionalFields>;
type MaxRegistrars = MaxRegistrars;
type Slashed = Treasury;
type ForceOrigin = IdentityForceOrigin;
type RegistrarOrigin = IdentityRegistrarOrigin;
type OffchainSignature = Signature;
type SigningPublicKey = <Signature as sp_runtime::traits::Verify>::Signer;
type UsernameAuthorityOrigin = EnsureRoot<AccountId>;
type PendingUsernameExpiration = PendingUsernameExpiration;
type MaxSuffixLength = MaxSuffixLength;
type MaxUsernameLength = MaxUsernameLength;
type WeightInfo = pallet_identity::weights::SubstrateWeight<Runtime>; // TODO is not recommended use default weights but currently there is a function within the
// benchmarks pallet code that cause a panic because it uses `Sr25519` signature type: https://github.com/paritytech/polkadot-sdk/blob/master/substrate/frame/identity/src/benchmarking.rs#L608
// whereas our runtime uses `Ecdsa` signature type
}
1 change: 1 addition & 0 deletions runtime/laos/src/configs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ mod cumulus_xcmp_queue;
mod election_phragmen;
mod ethereum;
pub(crate) mod evm;
mod identity;
pub(crate) mod laos_evolution;
mod multisig;
pub(crate) mod parachain_staking;
Expand Down
1 change: 1 addition & 0 deletions runtime/laos/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ construct_runtime!(
Utility: pallet_utility = 5,
Multisig: pallet_multisig = 6,
Proxy: pallet_proxy = 7,
Identity: pallet_identity = 8,

// Monetary stuff.
Balances: pallet_balances = 10,
Expand Down

0 comments on commit 8324424

Please sign in to comment.