diff --git a/operator/Cargo.lock b/operator/Cargo.lock index f5f58bb0..e95ea0df 100644 --- a/operator/Cargo.lock +++ b/operator/Cargo.lock @@ -1609,6 +1609,7 @@ dependencies = [ "pallet-evm", "pallet-evm-chain-id", "pallet-grandpa", + "pallet-identity", "pallet-im-online", "pallet-mmr", "pallet-multisig", diff --git a/operator/Cargo.toml b/operator/Cargo.toml index 866f9970..4f8c8453 100644 --- a/operator/Cargo.toml +++ b/operator/Cargo.toml @@ -86,6 +86,7 @@ pallet-authorship = { git = "https://github.com/paritytech/polkadot-sdk", branch pallet-babe = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2409", default-features = false } pallet-balances = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2409", default-features = false } pallet-grandpa = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2409", default-features = false } +pallet-identity = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2409", default-features = false } pallet-im-online = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2409", default-features = false } pallet-multisig = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2409", default-features = false } pallet-offences = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2409", default-features = false } diff --git a/operator/runtime/Cargo.toml b/operator/runtime/Cargo.toml index f5d8d509..1b31db07 100644 --- a/operator/runtime/Cargo.toml +++ b/operator/runtime/Cargo.toml @@ -27,6 +27,7 @@ pallet-authorship.workspace = true pallet-babe.workspace = true pallet-balances.workspace = true pallet-grandpa.workspace = true +pallet-identity.workspace = true pallet-im-online.workspace = true pallet-multisig.workspace = true pallet-offences.workspace = true @@ -100,6 +101,7 @@ std = [ "pallet-balances/std", "pallet-im-online/std", "pallet-grandpa/std", + "pallet-identity/std", "pallet-multisig/std", "pallet-mmr/std", "pallet-offences/std", @@ -153,6 +155,7 @@ runtime-benchmarks = [ "pallet-balances/runtime-benchmarks", "pallet-im-online/runtime-benchmarks", "pallet-grandpa/runtime-benchmarks", + "pallet-identity/runtime-benchmarks", "pallet-multisig/runtime-benchmarks", "pallet-offences/runtime-benchmarks", "pallet-preimage/runtime-benchmarks", @@ -179,6 +182,7 @@ try-runtime = [ "pallet-babe/try-runtime", "pallet-balances/try-runtime", "pallet-grandpa/try-runtime", + "pallet-identity/try-runtime", "pallet-im-online/try-runtime", "pallet-multisig/try-runtime", "pallet-offences/try-runtime", diff --git a/operator/runtime/src/benchmarks.rs b/operator/runtime/src/benchmarks.rs index 8b457edd..1803158c 100644 --- a/operator/runtime/src/benchmarks.rs +++ b/operator/runtime/src/benchmarks.rs @@ -27,6 +27,7 @@ frame_benchmarking::define_benchmarks!( [frame_benchmarking, BaselineBench::] [frame_system, SystemBench::] [pallet_balances, Balances] + [pallet_identity, Identity] [pallet_im_online, ImOnline] [pallet_multisig, Multisig] [pallet_preimage, Preimage] diff --git a/operator/runtime/src/configs/mod.rs b/operator/runtime/src/configs/mod.rs index 18914305..d0153482 100644 --- a/operator/runtime/src/configs/mod.rs +++ b/operator/runtime/src/configs/mod.rs @@ -28,14 +28,14 @@ use super::{ deposit, AccountId, Babe, Balance, Balances, BeefyMmrLeaf, Block, BlockNumber, EvmChainId, Hash, Historical, ImOnline, Nonce, Offences, OriginCaller, PalletInfo, Preimage, Runtime, RuntimeCall, RuntimeEvent, RuntimeFreezeReason, RuntimeHoldReason, RuntimeOrigin, RuntimeTask, - Session, SessionKeys, System, Timestamp, ValidatorSet, EXISTENTIAL_DEPOSIT, SLOT_DURATION, - STORAGE_BYTE_FEE, SUPPLY_FACTOR, UNIT, VERSION, + Session, SessionKeys, Signature, System, Timestamp, ValidatorSet, EXISTENTIAL_DEPOSIT, + SLOT_DURATION, STORAGE_BYTE_FEE, SUPPLY_FACTOR, UNIT, VERSION, }; // Substrate and Polkadot dependencies use codec::{Decode, Encode}; use datahaven_runtime_common::{ gas::WEIGHT_PER_GAS, - time::{EpochDurationInBlocks, MILLISECS_PER_BLOCK, MINUTES}, + time::{EpochDurationInBlocks, DAYS, MILLISECS_PER_BLOCK, MINUTES}, }; use frame_support::{ derive_impl, @@ -357,6 +357,49 @@ impl pallet_sudo::Config for Runtime { type WeightInfo = pallet_sudo::weights::SubstrateWeight; } +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; +} + +type IdentityForceOrigin = EnsureRoot; +type IdentityRegistrarOrigin = EnsureRoot; +// TODO: Add governance origin when available +// type IdentityForceOrigin = +// EitherOfDiverse, governance::custom_origins::GeneralAdmin>; +// type IdentityRegistrarOrigin = +// EitherOfDiverse, governance::custom_origins::GeneralAdmin>; + +impl pallet_identity::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type Currency = Balances; + // Add one item in storage and take 258 bytes + type BasicDeposit = ConstU128<{ deposit(1, 258) }>; + // Does not add any item to the storage but takes 1 bytes + type ByteDeposit = ConstU128<{ deposit(0, 1) }>; + // Add one item in storage and take 53 bytes + type SubAccountDeposit = ConstU128<{ deposit(1, 53) }>; + type MaxSubAccounts = MaxSubAccounts; + type IdentityInformation = pallet_identity::legacy::IdentityInfo; + type MaxRegistrars = MaxRegistrars; + type Slashed = (); + // TODO: Slashed funds should be sent to the treasury (when added to the runtime) + // type Slashed = Treasury; + type ForceOrigin = IdentityForceOrigin; + type RegistrarOrigin = IdentityRegistrarOrigin; + type OffchainSignature = Signature; + type SigningPublicKey = ::Signer; + type UsernameAuthorityOrigin = EnsureRoot; + type PendingUsernameExpiration = PendingUsernameExpiration; + type MaxSuffixLength = MaxSuffixLength; + type MaxUsernameLength = MaxUsernameLength; + type WeightInfo = (); +} + parameter_types! { pub const BeefySetIdSessionEntries: u32 = BondingDuration::get() * SessionsPerEra::get(); } diff --git a/operator/runtime/src/lib.rs b/operator/runtime/src/lib.rs index 97f07c6b..895f86c9 100644 --- a/operator/runtime/src/lib.rs +++ b/operator/runtime/src/lib.rs @@ -268,6 +268,9 @@ mod runtime { #[runtime::pallet_index(22)] pub type Preimage = pallet_preimage; + #[runtime::pallet_index(23)] + pub type Identity = pallet_identity; + #[runtime::pallet_index(24)] pub type Multisig = pallet_multisig;