From 63282b096011ae42331f025b682955e03108fff2 Mon Sep 17 00:00:00 2001 From: Fahrrader Date: Wed, 28 Dec 2022 17:02:56 +0000 Subject: [PATCH] refactor(collator-selection): shuffle pallets + add benchmarks to bench --- --- a/Makefile +++ b/Makefile @@ -143,4 +143,4 @@ .PHONY: bench # Disabled: bench-scheduler, bench-rmrk-core, bench-rmrk-equip -bench: bench-evm-migration bench-unique bench-structure bench-fungible bench-refungible bench-nonfungible bench-foreign-assets +bench: bench-evm-migration bench-unique bench-structure bench-fungible bench-refungible bench-nonfungible bench-foreign-assets bench-collator-selection bench-identity --- a/runtime/common/construct_runtime/mod.rs +++ b/runtime/common/construct_runtime/mod.rs @@ -32,20 +32,17 @@ ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Config, Storage, Inherent, Event, ValidateUnsigned} = 20, ParachainInfo: parachain_info::{Pallet, Storage, Config} = 21, - #[runtimes(opal)] - Authorship: pallet_authorship::{Pallet, Call, Storage} = 22, + Aura: pallet_aura::{Pallet, Config} = 22, + AuraExt: cumulus_pallet_aura_ext::{Pallet, Config} = 23, #[runtimes(opal)] - CollatorSelection: pallet_collator_selection::{Pallet, Call, Storage, Event, Config} = 23, + Authorship: pallet_authorship::{Pallet, Call, Storage} = 24, #[runtimes(opal)] - Session: pallet_session::{Pallet, Call, Storage, Event, Config} = 24, + CollatorSelection: pallet_collator_selection::{Pallet, Call, Storage, Event, Config} = 25, - Aura: pallet_aura::{Pallet, Config} = 25, - AuraExt: cumulus_pallet_aura_ext::{Pallet, Config} = 26, - #[runtimes(opal)] - Identity: pallet_identity::{Pallet, Call, Storage, Event} = 27, + Session: pallet_session::{Pallet, Call, Storage, Event, Config} = 26, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event} = 30, RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Storage} = 31, @@ -59,6 +56,9 @@ Tokens: orml_tokens = 39, // Contracts: pallet_contracts::{Pallet, Call, Storage, Event} = 38, + #[runtimes(opal)] + Identity: pallet_identity::{Pallet, Call, Storage, Event} = 40, + // XCM helpers. XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event} = 50, PolkadotXcm: pallet_xcm::{Pallet, Call, Event, Origin} = 51, --- a/runtime/common/data_management.rs +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2019-2022 Unique Network (Gibraltar) Ltd. -// This file is part of Unique Network. - -// Unique Network is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Unique Network is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Unique Network. If not, see . - -use scale_info::TypeInfo; -use codec::{Encode, Decode}; -use up_common::types::AccountId; -use crate::RuntimeCall; - -use sp_runtime::{ - traits::{DispatchInfoOf, SignedExtension}, - transaction_validity::{ - TransactionValidity, ValidTransaction, InvalidTransaction, TransactionValidityError, - }, -}; - -#[derive(Debug, Encode, Decode, PartialEq, Eq, Clone, TypeInfo)] -pub struct FilterIdentity; - -impl SignedExtension for FilterIdentity { - type AccountId = AccountId; - type Call = RuntimeCall; - type AdditionalSigned = (); - type Pre = (); - - const IDENTIFIER: &'static str = "FilterIdentity"; - - fn additional_signed(&self) -> Result { - Ok(()) - } - - fn pre_dispatch( - self, - who: &Self::AccountId, - call: &Self::Call, - info: &DispatchInfoOf, - len: usize, - ) -> Result { - self.validate(who, call, info, len).map(|_| ()) - } - - fn validate( - &self, - _who: &Self::AccountId, - call: &Self::Call, - _info: &DispatchInfoOf, - _len: usize, - ) -> TransactionValidity { - match call { - #[cfg(feature = "collator-selection")] - RuntimeCall::Identity(_) => Err(TransactionValidityError::Invalid(InvalidTransaction::Call)), - _ => Ok(ValidTransaction::default()), - } - } -} --- /dev/null +++ b/runtime/common/identity.rs @@ -0,0 +1,67 @@ +// Copyright 2019-2022 Unique Network (Gibraltar) Ltd. +// This file is part of Unique Network. + +// Unique Network is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Unique Network is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Unique Network. If not, see . + +use scale_info::TypeInfo; +use codec::{Encode, Decode}; +use up_common::types::AccountId; +use crate::RuntimeCall; + +use sp_runtime::{ + traits::{DispatchInfoOf, SignedExtension}, + transaction_validity::{ + TransactionValidity, ValidTransaction, InvalidTransaction, TransactionValidityError, + }, +}; + +#[derive(Debug, Encode, Decode, PartialEq, Eq, Clone, TypeInfo)] +pub struct DisableIdentityCalls; + +impl SignedExtension for DisableIdentityCalls { + type AccountId = AccountId; + type Call = RuntimeCall; + type AdditionalSigned = (); + type Pre = (); + + const IDENTIFIER: &'static str = "DisableIdentityCalls"; + + fn additional_signed(&self) -> Result { + Ok(()) + } + + fn pre_dispatch( + self, + who: &Self::AccountId, + call: &Self::Call, + info: &DispatchInfoOf, + len: usize, + ) -> Result { + self.validate(who, call, info, len).map(|_| ()) + } + + fn validate( + &self, + _who: &Self::AccountId, + call: &Self::Call, + _info: &DispatchInfoOf, + _len: usize, + ) -> TransactionValidity { + match call { + #[cfg(feature = "collator-selection")] + RuntimeCall::Identity(_) => Err(TransactionValidityError::Invalid(InvalidTransaction::Call)), + _ => Ok(ValidTransaction::default()), + } + } +} --- a/runtime/common/mod.rs +++ b/runtime/common/mod.rs @@ -16,9 +16,9 @@ pub mod config; pub mod construct_runtime; -pub mod data_management; pub mod dispatch; pub mod ethereum; +pub mod identity; pub mod instance; pub mod maintenance; pub mod runtime_apis; @@ -97,7 +97,7 @@ frame_system::CheckNonce, frame_system::CheckWeight, maintenance::CheckMaintenance, - data_management::FilterIdentity, + identity::DisableIdentityCalls, ChargeTransactionPayment, //pallet_contract_helpers::ContractHelpersExtension, pallet_ethereum::FakeTransactionFinalizer, --- a/tests/src/.outdated/substrate/substrate-api.ts +++ b/tests/src/.outdated/substrate/substrate-api.ts @@ -41,7 +41,7 @@ extrinsic: {}, payload: {}, }, - FilterIdentity: { + DisableIdentityCalls: { extrinsic: {}, payload: {}, }, --- a/tests/src/util/playgrounds/unique.dev.ts +++ b/tests/src/util/playgrounds/unique.dev.ts @@ -93,7 +93,7 @@ extrinsic: {}, payload: {}, }, - FilterIdentity: { + DisableIdentityCalls: { extrinsic: {}, payload: {}, }, -- gitstuff