git.delta.rocks / unique-network / refs/commits / 716fee23155e

difftreelog

chore remove unique-scheduler leftovers

Yaroslav Bolyukin2023-10-04parent: #13e91d3.patch.diff
in: master

10 files changed

modifiedCargo.tomldiffbeforeafterboth
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,5 @@
 [workspace]
 default-members = ['client/*', 'node/*', 'runtime/opal']
-exclude = ['pallets/scheduler-v2']
 members = [
 	'client/*',
 	'crates/*',
@@ -54,7 +53,6 @@
 pallet-structure = { default-features = false, path = "pallets/structure" }
 pallet-test-utils = { default-features = false, path = "test-pallets/utils" }
 pallet-unique = { path = "pallets/unique", default-features = false }
-# pallet-unique-scheduler-v2 = { path = "pallets/scheduler-v2", default-features = false }
 precompile-utils-macro = { path = "runtime/common/ethereum/precompiles/utils/macro" }
 struct-versioning = { path = "crates/struct-versioning" }
 uc-rpc = { path = "client/rpc" }
modifiedMakefilediffbeforeafterboth
--- a/Makefile
+++ b/Makefile
@@ -128,10 +128,6 @@
 bench-structure:
 	make _bench PALLET=structure
 
-.PHONY: bench-scheduler
-bench-scheduler:
-	make _bench PALLET=unique-scheduler-v2 PALLET_DIR=scheduler-v2
-
 .PHONY: bench-foreign-assets
 bench-foreign-assets:
 	make _bench PALLET=foreign-assets
@@ -157,7 +153,6 @@
 	make _bench PALLET=xcm OUTPUT=./runtime/common/weights/xcm.rs TEMPLATE="--template=.maintain/external-weight-template.hbs"
 
 .PHONY: bench
-# Disabled: bench-scheduler
 bench: bench-app-promotion bench-common bench-evm-migration bench-unique bench-structure bench-fungible bench-refungible bench-nonfungible bench-configuration bench-foreign-assets bench-maintenance bench-xcm bench-collator-selection bench-identity
 
 .PHONY: check
modifiedruntime/common/config/pallets/mod.rsdiffbeforeafterboth
--- a/runtime/common/config/pallets/mod.rs
+++ b/runtime/common/config/pallets/mod.rs
@@ -40,9 +40,6 @@
 	Balances, Runtime, RuntimeCall, RuntimeEvent, DECIMALS, TOKEN_SYMBOL, VERSION,
 };
 
-#[cfg(feature = "unique-scheduler")]
-pub mod scheduler;
-
 #[cfg(feature = "foreign-assets")]
 pub mod foreign_asset;
 
deletedruntime/common/config/pallets/scheduler.rsdiffbeforeafterboth
--- a/runtime/common/config/pallets/scheduler.rs
+++ /dev/null
@@ -1,88 +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 <http://www.gnu.org/licenses/>.
-
-use core::cmp::Ordering;
-
-use frame_support::{
-	parameter_types,
-	traits::{EnsureOrigin, PrivilegeCmp},
-	weights::Weight,
-};
-use frame_system::{EnsureRoot, RawOrigin};
-use pallet_unique_scheduler_v2::ScheduledEnsureOriginSuccess;
-use parity_scale_codec::Decode;
-use sp_runtime::Perbill;
-use up_common::types::AccountId;
-
-use crate::{
-	runtime_common::{config::substrate::RuntimeBlockWeights, scheduler::SchedulerPaymentExecutor},
-	OriginCaller, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin,
-};
-
-parameter_types! {
-	pub MaximumSchedulerWeight: Weight = Perbill::from_percent(50) *
-		RuntimeBlockWeights::get().max_block;
-	pub const MaxScheduledPerBlock: u32 = 50;
-
-	pub const NoPreimagePostponement: Option<u32> = Some(10);
-	pub const Preimage: Option<u32> = Some(10);
-}
-
-pub struct EnsureSignedOrRoot<AccountId>(sp_std::marker::PhantomData<AccountId>);
-impl<O: Into<Result<RawOrigin<AccountId>, O>> + From<RawOrigin<AccountId>>, AccountId: Decode>
-	EnsureOrigin<O> for EnsureSignedOrRoot<AccountId>
-{
-	type Success = ScheduledEnsureOriginSuccess<AccountId>;
-	fn try_origin(o: O) -> Result<Self::Success, O> {
-		o.into().and_then(|o| match o {
-			RawOrigin::Root => Ok(ScheduledEnsureOriginSuccess::Root),
-			RawOrigin::Signed(who) => Ok(ScheduledEnsureOriginSuccess::Signed(who)),
-			r => Err(O::from(r)),
-		})
-	}
-}
-
-pub struct EqualOrRootOnly;
-impl PrivilegeCmp<OriginCaller> for EqualOrRootOnly {
-	fn cmp_privilege(left: &OriginCaller, right: &OriginCaller) -> Option<Ordering> {
-		use RawOrigin::*;
-
-		let left = left.clone().try_into().ok()?;
-		let right = right.clone().try_into().ok()?;
-
-		match (left, right) {
-			(Root, Root) => Some(Ordering::Equal),
-			(Root, _) => Some(Ordering::Greater),
-			(_, Root) => Some(Ordering::Less),
-			lr @ _ => (lr.0 == lr.1).then(|| Ordering::Equal),
-		}
-	}
-}
-
-impl pallet_unique_scheduler_v2::Config for Runtime {
-	type RuntimeEvent = RuntimeEvent;
-	type RuntimeOrigin = RuntimeOrigin;
-	type PalletsOrigin = OriginCaller;
-	type RuntimeCall = RuntimeCall;
-	type MaximumWeight = MaximumSchedulerWeight;
-	type ScheduleOrigin = EnsureSignedOrRoot<AccountId>;
-	type OriginPrivilegeCmp = EqualOrRootOnly;
-	type MaxScheduledPerBlock = MaxScheduledPerBlock;
-	type WeightInfo = ();
-	type Preimages = ();
-	type CallExecutor = SchedulerPaymentExecutor;
-	type PrioritySetOrigin = EnsureRoot<AccountId>;
-}
modifiedruntime/common/maintenance.rsdiffbeforeafterboth
--- a/runtime/common/maintenance.rs
+++ b/runtime/common/maintenance.rs
@@ -67,9 +67,6 @@
 				| RuntimeCall::Structure(_)
 				| RuntimeCall::Unique(_) => Err(TransactionValidityError::Invalid(InvalidTransaction::Call)),
 
-				#[cfg(feature = "unique-scheduler")]
-				RuntimeCall::Scheduler(_) => Err(TransactionValidityError::Invalid(InvalidTransaction::Call)),
-
 				#[cfg(feature = "app-promotion")]
 				RuntimeCall::AppPromotion(_) => {
 					Err(TransactionValidityError::Invalid(InvalidTransaction::Call))
modifiedruntime/common/mod.rsdiffbeforeafterboth
after · runtime/common/mod.rs
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617pub mod config;18pub mod construct_runtime;19pub mod dispatch;20pub mod ethereum;21pub mod identity;22pub mod instance;23pub mod maintenance;24pub mod runtime_apis;2526pub mod sponsoring;27#[allow(missing_docs)]28pub mod weights;2930#[cfg(test)]31pub mod tests;3233use frame_support::{34	traits::{Currency, Imbalance, OnUnbalanced},35	weights::Weight,36};37use sp_runtime::{38	generic, impl_opaque_keys,39	traits::{BlakeTwo256, BlockNumberProvider},40};41use sp_std::vec::Vec;42#[cfg(feature = "std")]43use sp_version::NativeVersion;44use up_common::types::{AccountId, BlockNumber};4546use crate::{47	AllPalletsWithSystem, Aura, Balances, InherentDataExt, Runtime, RuntimeCall, Signature,48	Treasury,49};5051#[macro_export]52macro_rules! unsupported {53	() => {54		pallet_common::unsupported!($crate::Runtime)55	};56}5758/// The address format for describing accounts.59pub type Address = sp_runtime::MultiAddress<AccountId, ()>;60/// A Block signed with a Justification61pub type SignedBlock = generic::SignedBlock<Block>;62/// Frontier wrapped extrinsic63pub type UncheckedExtrinsic =64	fp_self_contained::UncheckedExtrinsic<Address, RuntimeCall, Signature, SignedExtra>;65/// Header type.66pub type Header = generic::Header<BlockNumber, BlakeTwo256>;67/// Block type.68pub type Block = generic::Block<Header, UncheckedExtrinsic>;69/// BlockId type as expected by this runtime.70pub type BlockId = generic::BlockId<Block>;7172impl_opaque_keys! {73	pub struct SessionKeys {74		pub aura: Aura,75	}76}7778/// The version information used to identify this runtime when compiled natively.79#[cfg(feature = "std")]80pub fn native_version() -> NativeVersion {81	NativeVersion {82		runtime_version: crate::VERSION,83		can_author_with: Default::default(),84	}85}8687pub type ChargeTransactionPayment = pallet_charge_transaction::ChargeTransactionPayment<Runtime>;8889pub type SignedExtra = (90	frame_system::CheckSpecVersion<Runtime>,91	frame_system::CheckTxVersion<Runtime>,92	frame_system::CheckGenesis<Runtime>,93	frame_system::CheckEra<Runtime>,94	frame_system::CheckNonce<Runtime>,95	frame_system::CheckWeight<Runtime>,96	maintenance::CheckMaintenance,97	identity::DisableIdentityCalls,98	ChargeTransactionPayment,99	//pallet_contract_helpers::ContractHelpersExtension<Runtime>,100	pallet_ethereum::FakeTransactionFinalizer<Runtime>,101);102103/// Executive: handles dispatch to the various modules.104pub type Executive = frame_executive::Executive<105	Runtime,106	Block,107	frame_system::ChainContext<Runtime>,108	Runtime,109	AllPalletsWithSystem,110	AuraToCollatorSelection,111>;112113type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;114115pub struct DealWithFees;116impl OnUnbalanced<NegativeImbalance> for DealWithFees {117	fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item = NegativeImbalance>) {118		if let Some(fees) = fees_then_tips.next() {119			// for fees, 100% to treasury120			let mut split = fees.ration(100, 0);121			if let Some(tips) = fees_then_tips.next() {122				// for tips, if any, 100% to treasury123				tips.ration_merge_into(100, 0, &mut split);124			}125			Treasury::on_unbalanced(split.0);126			// Author::on_unbalanced(split.1);127		}128	}129}130131pub struct RelayChainBlockNumberProvider<T>(sp_std::marker::PhantomData<T>);132133impl<T: cumulus_pallet_parachain_system::Config> BlockNumberProvider134	for RelayChainBlockNumberProvider<T>135{136	type BlockNumber = BlockNumber;137138	fn current_block_number() -> Self::BlockNumber {139		cumulus_pallet_parachain_system::Pallet::<T>::validation_data()140			.map(|d| d.relay_parent_number)141			.unwrap_or_default()142	}143	#[cfg(feature = "runtime-benchmarks")]144	fn set_block_number(block: Self::BlockNumber) {145		cumulus_pallet_parachain_system::RelaychainDataProvider::<T>::set_block_number(block)146	}147}148149pub(crate) struct CheckInherents;150151impl cumulus_pallet_parachain_system::CheckInherents<Block> for CheckInherents {152	fn check_inherents(153		block: &Block,154		relay_state_proof: &cumulus_pallet_parachain_system::RelayChainStateProof,155	) -> sp_inherents::CheckInherentsResult {156		let relay_chain_slot = relay_state_proof157			.read_slot()158			.expect("Could not read the relay chain slot from the proof");159160		let inherent_data =161			cumulus_primitives_timestamp::InherentDataProvider::from_relay_chain_slot_and_duration(162				relay_chain_slot,163				sp_std::time::Duration::from_secs(6),164			)165			.create_inherent_data()166			.expect("Could not create the timestamp inherent data");167168		inherent_data.check_extrinsics(block)169	}170}171172#[derive(parity_scale_codec::Encode, parity_scale_codec::Decode)]173pub enum XCMPMessage<XAccountId, XBalance> {174	/// Transfer tokens to the given account from the Parachain account.175	TransferToken(XAccountId, XBalance),176}177178pub struct AuraToCollatorSelection;179impl frame_support::traits::OnRuntimeUpgrade for AuraToCollatorSelection {180	fn on_runtime_upgrade() -> Weight {181		#[cfg(feature = "collator-selection")]182		{183			use frame_support::{storage::migration, BoundedVec};184			use pallet_session::SessionManager;185			use sp_runtime::{traits::OpaqueKeys, RuntimeAppPublic};186187			use crate::config::pallets::MaxCollators;188189			let mut weight = <Runtime as frame_system::Config>::DbWeight::get().reads(1);190191			let version = migration::get_storage_value::<()>(192				b"AuraToCollatorSelection",193				b"StorageVersion",194				&[],195			);196197			let should_upgrade = version.is_none();198199			if should_upgrade {200				log::info!(201					target: "runtime::aura_to_collator_selection",202					"Running migration of Aura authorities to Collator Selection invulnerables"203				);204205				let invulnerables = pallet_aura::Pallet::<Runtime>::authorities()206					.iter()207					.cloned()208					.filter_map(|authority_id| {209						weight.saturating_accrue(<Runtime as frame_system::Config>::DbWeight::get().reads_writes(1, 1));210						let vec = authority_id.to_raw_vec();211						let slice = vec.as_slice();212						let array: Option<[u8; 32]> = match slice.try_into() {213							Ok(a) => Some(a),214							Err(_) => {215								log::error!("Failed to convert an Aura authority to a Collator Selection invulnerable: {:?}", authority_id);216								None217							},218						};219						array.map(|a| (AccountId::from(a), authority_id))220					})221					.collect::<Vec<_>>();222223				let bounded_invulnerables = BoundedVec::<_, MaxCollators>::try_from(224					invulnerables225						.iter()226						.cloned()227						.map(|(acc, _)| acc)228						.collect::<Vec<_>>(),229				)230				.expect("Existing collators/invulnerables are more than MaxCollators");231232				<pallet_collator_selection::Invulnerables<Runtime>>::put(bounded_invulnerables);233234				let keys = invulnerables235					.into_iter()236					.map(|(acc, aura)| {237						(238							acc.clone(),          // account id239							acc,                  // validator id240							SessionKeys { aura }, // session keys241						)242					})243					.collect::<Vec<_>>();244245				for (account, val, keys) in keys.iter() {246					for id in <Runtime as pallet_session::Config>::Keys::key_ids() {247						<pallet_session::KeyOwner<Runtime>>::insert((*id, keys.get_raw(*id)), val)248					}249					<pallet_session::NextKeys<Runtime>>::insert(val, keys);250					// todo exercise caution, the following is taken from genesis251					if frame_system::Pallet::<Runtime>::inc_consumers_without_limit(account)252						.is_err()253					{254						log::warn!(255							"We have entered an error with incrementing consumers without limit during the migration"256						);257						// This will leak a provider reference, however it only happens once (at258						// genesis) so it's really not a big deal and we assume that the user wants to259						// do this since it's the only way a non-endowed account can contain a session260						// key.261						frame_system::Pallet::<Runtime>::inc_providers(account);262					}263				}264265				let initial_validators_0 =266					<Runtime as pallet_session::Config>::SessionManager::new_session(0)267						.unwrap_or_else(|| {268							frame_support::print(269								"No initial validator provided by `SessionManager`, use \270							session config keys to generate initial validator set.",271							);272							keys.iter().map(|x| x.1.clone()).collect()273						});274				/*assert!(275					!initial_validators_0.is_empty(),276					"Empty validator set for session 0 in (pseudo) genesis block!"277				);*/278279				let initial_validators_1 =280					<Runtime as pallet_session::Config>::SessionManager::new_session(1)281						.unwrap_or_else(|| initial_validators_0.clone());282				/*assert!(283					!initial_validators_1.is_empty(),284					"Empty validator set for session 1 in (pseudo) genesis block!"285				);*/286287				let queued_keys: Vec<_> = initial_validators_1288					.iter()289					.cloned()290					.map(|v| {291						(292							v.clone(),293							<pallet_session::NextKeys<Runtime>>::get(&v)294								.expect("Validator in session 1 missing keys!"),295						)296					})297					.collect();298299				// Tell everyone about the genesis session keys -- Aura must've already initialized it300				//<Runtime as pallet_session::Config>::SessionHandler::on_genesis_session::<<Runtime as pallet_session::Config>::Keys>(&queued_keys);301302				<pallet_session::Validators<Runtime>>::put(initial_validators_0);303				<pallet_session::QueuedKeys<Runtime>>::put(queued_keys);304305				<Runtime as pallet_session::Config>::SessionManager::start_session(0);306307				log::info!(308					target: "runtime::aura_to_collator_selection",309					"Migration of Aura authorities to Collator Selection invulnerables is complete."310				);311312				migration::put_storage_value::<()>(313					b"AuraToCollatorSelection",314					b"StorageVersion",315					&[],316					(),317				);318319				weight += <Runtime as frame_system::Config>::DbWeight::get().writes(1)320			} else {321				log::info!(322					target: "runtime::aura_to_collator_selection",323					"The storage migration has already been flagged as complete. No migration needs to be done.",324				);325			}326327			weight328		}329330		#[cfg(not(feature = "collator-selection"))]331		{332			Weight::zero()333		}334	}335}
modifiedruntime/common/runtime_apis.rsdiffbeforeafterboth
--- a/runtime/common/runtime_apis.rs
+++ b/runtime/common/runtime_apis.rs
@@ -548,9 +548,6 @@
 					#[cfg(feature = "refungible")]
 					list_benchmark!(list, extra, pallet_refungible, Refungible);
 
-					#[cfg(feature = "unique-scheduler")]
-					list_benchmark!(list, extra, pallet_unique_scheduler_v2, Scheduler);
-
 					#[cfg(feature = "collator-selection")]
 					list_benchmark!(list, extra, pallet_collator_selection, CollatorSelection);
 
@@ -613,9 +610,6 @@
 
 					#[cfg(feature = "refungible")]
 					add_benchmark!(params, batches, pallet_refungible, Refungible);
-
-					#[cfg(feature = "unique-scheduler")]
-					add_benchmark!(params, batches, pallet_unique_scheduler_v2, Scheduler);
 
 					#[cfg(feature = "collator-selection")]
 					add_benchmark!(params, batches, pallet_collator_selection, CollatorSelection);
modifiedruntime/opal/Cargo.tomldiffbeforeafterboth
--- a/runtime/opal/Cargo.toml
+++ b/runtime/opal/Cargo.toml
@@ -229,7 +229,6 @@
 preimage = []
 refungible = []
 session-test-timings = []
-unique-scheduler = []
 
 ################################################################################
 # local dependencies
modifiedruntime/quartz/Cargo.tomldiffbeforeafterboth
--- a/runtime/quartz/Cargo.toml
+++ b/runtime/quartz/Cargo.toml
@@ -221,7 +221,6 @@
 preimage = []
 refungible = []
 session-test-timings = []
-unique-scheduler = []
 
 ################################################################################
 # local dependencies
modifiedruntime/unique/Cargo.tomldiffbeforeafterboth
--- a/runtime/unique/Cargo.toml
+++ b/runtime/unique/Cargo.toml
@@ -224,7 +224,6 @@
 preimage = []
 refungible = []
 session-test-timings = []
-unique-scheduler = []
 
 ################################################################################
 # local dependencies