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
before · 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;2526#[cfg(feature = "unique-scheduler")]27pub mod scheduler;2829pub mod sponsoring;30#[allow(missing_docs)]31pub mod weights;3233#[cfg(test)]34pub mod tests;3536use frame_support::{37	traits::{Currency, Imbalance, OnUnbalanced},38	weights::Weight,39};40use sp_runtime::{41	generic, impl_opaque_keys,42	traits::{BlakeTwo256, BlockNumberProvider},43};44use sp_std::vec::Vec;45#[cfg(feature = "std")]46use sp_version::NativeVersion;47use up_common::types::{AccountId, BlockNumber};4849use crate::{50	AllPalletsWithSystem, Aura, Balances, InherentDataExt, Runtime, RuntimeCall, Signature,51	Treasury,52};5354#[macro_export]55macro_rules! unsupported {56	() => {57		pallet_common::unsupported!($crate::Runtime)58	};59}6061/// The address format for describing accounts.62pub type Address = sp_runtime::MultiAddress<AccountId, ()>;63/// A Block signed with a Justification64pub type SignedBlock = generic::SignedBlock<Block>;65/// Frontier wrapped extrinsic66pub type UncheckedExtrinsic =67	fp_self_contained::UncheckedExtrinsic<Address, RuntimeCall, Signature, SignedExtra>;68/// Header type.69pub type Header = generic::Header<BlockNumber, BlakeTwo256>;70/// Block type.71pub type Block = generic::Block<Header, UncheckedExtrinsic>;72/// BlockId type as expected by this runtime.73pub type BlockId = generic::BlockId<Block>;7475impl_opaque_keys! {76	pub struct SessionKeys {77		pub aura: Aura,78	}79}8081/// The version information used to identify this runtime when compiled natively.82#[cfg(feature = "std")]83pub fn native_version() -> NativeVersion {84	NativeVersion {85		runtime_version: crate::VERSION,86		can_author_with: Default::default(),87	}88}8990pub type ChargeTransactionPayment = pallet_charge_transaction::ChargeTransactionPayment<Runtime>;9192pub type SignedExtra = (93	frame_system::CheckSpecVersion<Runtime>,94	frame_system::CheckTxVersion<Runtime>,95	frame_system::CheckGenesis<Runtime>,96	frame_system::CheckEra<Runtime>,97	frame_system::CheckNonce<Runtime>,98	frame_system::CheckWeight<Runtime>,99	maintenance::CheckMaintenance,100	identity::DisableIdentityCalls,101	ChargeTransactionPayment,102	//pallet_contract_helpers::ContractHelpersExtension<Runtime>,103	pallet_ethereum::FakeTransactionFinalizer<Runtime>,104);105106/// Executive: handles dispatch to the various modules.107pub type Executive = frame_executive::Executive<108	Runtime,109	Block,110	frame_system::ChainContext<Runtime>,111	Runtime,112	AllPalletsWithSystem,113	AuraToCollatorSelection,114>;115116type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;117118pub struct DealWithFees;119impl OnUnbalanced<NegativeImbalance> for DealWithFees {120	fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item = NegativeImbalance>) {121		if let Some(fees) = fees_then_tips.next() {122			// for fees, 100% to treasury123			let mut split = fees.ration(100, 0);124			if let Some(tips) = fees_then_tips.next() {125				// for tips, if any, 100% to treasury126				tips.ration_merge_into(100, 0, &mut split);127			}128			Treasury::on_unbalanced(split.0);129			// Author::on_unbalanced(split.1);130		}131	}132}133134pub struct RelayChainBlockNumberProvider<T>(sp_std::marker::PhantomData<T>);135136impl<T: cumulus_pallet_parachain_system::Config> BlockNumberProvider137	for RelayChainBlockNumberProvider<T>138{139	type BlockNumber = BlockNumber;140141	fn current_block_number() -> Self::BlockNumber {142		cumulus_pallet_parachain_system::Pallet::<T>::validation_data()143			.map(|d| d.relay_parent_number)144			.unwrap_or_default()145	}146	#[cfg(feature = "runtime-benchmarks")]147	fn set_block_number(block: Self::BlockNumber) {148		cumulus_pallet_parachain_system::RelaychainDataProvider::<T>::set_block_number(block)149	}150}151152pub(crate) struct CheckInherents;153154impl cumulus_pallet_parachain_system::CheckInherents<Block> for CheckInherents {155	fn check_inherents(156		block: &Block,157		relay_state_proof: &cumulus_pallet_parachain_system::RelayChainStateProof,158	) -> sp_inherents::CheckInherentsResult {159		let relay_chain_slot = relay_state_proof160			.read_slot()161			.expect("Could not read the relay chain slot from the proof");162163		let inherent_data =164			cumulus_primitives_timestamp::InherentDataProvider::from_relay_chain_slot_and_duration(165				relay_chain_slot,166				sp_std::time::Duration::from_secs(6),167			)168			.create_inherent_data()169			.expect("Could not create the timestamp inherent data");170171		inherent_data.check_extrinsics(block)172	}173}174175#[derive(parity_scale_codec::Encode, parity_scale_codec::Decode)]176pub enum XCMPMessage<XAccountId, XBalance> {177	/// Transfer tokens to the given account from the Parachain account.178	TransferToken(XAccountId, XBalance),179}180181pub struct AuraToCollatorSelection;182impl frame_support::traits::OnRuntimeUpgrade for AuraToCollatorSelection {183	fn on_runtime_upgrade() -> Weight {184		#[cfg(feature = "collator-selection")]185		{186			use frame_support::{storage::migration, BoundedVec};187			use pallet_session::SessionManager;188			use sp_runtime::{traits::OpaqueKeys, RuntimeAppPublic};189190			use crate::config::pallets::MaxCollators;191192			let mut weight = <Runtime as frame_system::Config>::DbWeight::get().reads(1);193194			let version = migration::get_storage_value::<()>(195				b"AuraToCollatorSelection",196				b"StorageVersion",197				&[],198			);199200			let should_upgrade = version.is_none();201202			if should_upgrade {203				log::info!(204					target: "runtime::aura_to_collator_selection",205					"Running migration of Aura authorities to Collator Selection invulnerables"206				);207208				let invulnerables = pallet_aura::Pallet::<Runtime>::authorities()209					.iter()210					.cloned()211					.filter_map(|authority_id| {212						weight.saturating_accrue(<Runtime as frame_system::Config>::DbWeight::get().reads_writes(1, 1));213						let vec = authority_id.to_raw_vec();214						let slice = vec.as_slice();215						let array: Option<[u8; 32]> = match slice.try_into() {216							Ok(a) => Some(a),217							Err(_) => {218								log::error!("Failed to convert an Aura authority to a Collator Selection invulnerable: {:?}", authority_id);219								None220							},221						};222						array.map(|a| (AccountId::from(a), authority_id))223					})224					.collect::<Vec<_>>();225226				let bounded_invulnerables = BoundedVec::<_, MaxCollators>::try_from(227					invulnerables228						.iter()229						.cloned()230						.map(|(acc, _)| acc)231						.collect::<Vec<_>>(),232				)233				.expect("Existing collators/invulnerables are more than MaxCollators");234235				<pallet_collator_selection::Invulnerables<Runtime>>::put(bounded_invulnerables);236237				let keys = invulnerables238					.into_iter()239					.map(|(acc, aura)| {240						(241							acc.clone(),          // account id242							acc,                  // validator id243							SessionKeys { aura }, // session keys244						)245					})246					.collect::<Vec<_>>();247248				for (account, val, keys) in keys.iter() {249					for id in <Runtime as pallet_session::Config>::Keys::key_ids() {250						<pallet_session::KeyOwner<Runtime>>::insert((*id, keys.get_raw(*id)), val)251					}252					<pallet_session::NextKeys<Runtime>>::insert(val, keys);253					// todo exercise caution, the following is taken from genesis254					if frame_system::Pallet::<Runtime>::inc_consumers_without_limit(account)255						.is_err()256					{257						log::warn!(258							"We have entered an error with incrementing consumers without limit during the migration"259						);260						// This will leak a provider reference, however it only happens once (at261						// genesis) so it's really not a big deal and we assume that the user wants to262						// do this since it's the only way a non-endowed account can contain a session263						// key.264						frame_system::Pallet::<Runtime>::inc_providers(account);265					}266				}267268				let initial_validators_0 =269					<Runtime as pallet_session::Config>::SessionManager::new_session(0)270						.unwrap_or_else(|| {271							frame_support::print(272								"No initial validator provided by `SessionManager`, use \273							session config keys to generate initial validator set.",274							);275							keys.iter().map(|x| x.1.clone()).collect()276						});277				/*assert!(278					!initial_validators_0.is_empty(),279					"Empty validator set for session 0 in (pseudo) genesis block!"280				);*/281282				let initial_validators_1 =283					<Runtime as pallet_session::Config>::SessionManager::new_session(1)284						.unwrap_or_else(|| initial_validators_0.clone());285				/*assert!(286					!initial_validators_1.is_empty(),287					"Empty validator set for session 1 in (pseudo) genesis block!"288				);*/289290				let queued_keys: Vec<_> = initial_validators_1291					.iter()292					.cloned()293					.map(|v| {294						(295							v.clone(),296							<pallet_session::NextKeys<Runtime>>::get(&v)297								.expect("Validator in session 1 missing keys!"),298						)299					})300					.collect();301302				// Tell everyone about the genesis session keys -- Aura must've already initialized it303				//<Runtime as pallet_session::Config>::SessionHandler::on_genesis_session::<<Runtime as pallet_session::Config>::Keys>(&queued_keys);304305				<pallet_session::Validators<Runtime>>::put(initial_validators_0);306				<pallet_session::QueuedKeys<Runtime>>::put(queued_keys);307308				<Runtime as pallet_session::Config>::SessionManager::start_session(0);309310				log::info!(311					target: "runtime::aura_to_collator_selection",312					"Migration of Aura authorities to Collator Selection invulnerables is complete."313				);314315				migration::put_storage_value::<()>(316					b"AuraToCollatorSelection",317					b"StorageVersion",318					&[],319					(),320				);321322				weight += <Runtime as frame_system::Config>::DbWeight::get().writes(1)323			} else {324				log::info!(325					target: "runtime::aura_to_collator_selection",326					"The storage migration has already been flagged as complete. No migration needs to be done.",327				);328			}329330			weight331		}332333		#[cfg(not(feature = "collator-selection"))]334		{335			Weight::zero()336		}337	}338}
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