git.delta.rocks / unique-network / refs/commits / 3ce5f80a2a4f

difftreelog

refactor(collator-selection) rename revoke to release + update tx + cargo fmt

Fahrrader2022-12-27parent: #8de2dcb.patch.diff
in: master

13 files changed

modifiedpallets/collator-selection/src/lib.rsdiffbeforeafterboth
--- a/pallets/collator-selection/src/lib.rs
+++ b/pallets/collator-selection/src/lib.rs
@@ -217,7 +217,7 @@
 			let bounded_invulnerables =
 				BoundedVec::<_, T::MaxCollators>::try_from(self.invulnerables.clone())
 					.expect("genesis invulnerables are more than T::MaxCollators");
-			
+
 			<Invulnerables<T>>::put(bounded_invulnerables);
 		}
 	}
@@ -284,6 +284,7 @@
 	#[pallet::call]
 	impl<T: Config> Pallet<T> {
 		/// Add a collator to the list of invulnerable (fixed) collators.
+		#[pallet::call_index(0)]
 		#[pallet::weight(T::WeightInfo::set_invulnerables(1u32))] // todo:collator weight
 		pub fn add_invulnerable(
 			origin: OriginFor<T>,
@@ -313,6 +314,7 @@
 		}
 
 		/// Remove a collator from the list of invulnerable (fixed) collators.
+		#[pallet::call_index(1)]
 		#[pallet::weight(T::WeightInfo::set_invulnerables(1))] // todo:collator weight
 		pub fn remove_invulnerable(
 			origin: OriginFor<T>,
@@ -341,6 +343,7 @@
 		/// (a) already have registered session keys and (b) be able to reserve the `LicenseBond`.
 		///
 		/// This call is not available to `Invulnerable` collators.
+		#[pallet::call_index(2)]
 		#[pallet::weight(T::WeightInfo::register_as_candidate(T::MaxCollators::get()))] // todo:collator weight
 		pub fn get_license(origin: OriginFor<T>) -> DispatchResultWithPostInfo {
 			// register_as_candidate
@@ -373,6 +376,7 @@
 		/// The account must already hold a license, and cannot offboard immediately during a session.
 		///
 		/// This call is not available to `Invulnerable` collators.
+		#[pallet::call_index(3)]
 		#[pallet::weight(T::WeightInfo::register_as_candidate(T::MaxCollators::get()))] // todo:collator weight
 		pub fn onboard(origin: OriginFor<T>) -> DispatchResultWithPostInfo {
 			// register_as_candidate
@@ -418,6 +422,7 @@
 
 		/// Deregister `origin` as a collator candidate. Note that the collator can only leave on
 		/// session change. The license to `onboard` later at any other time will remain.
+		#[pallet::call_index(4)]
 		#[pallet::weight(T::WeightInfo::leave_intent(T::MaxCollators::get()))] // todo:collator weight
 		pub fn offboard(origin: OriginFor<T>) -> DispatchResultWithPostInfo {
 			// leave_intent
@@ -430,6 +435,7 @@
 		/// Forfeit `origin`'s own license. The `LicenseBond` will be unreserved immediately.
 		///
 		/// This call is not available to `Invulnerable` collators.
+		#[pallet::call_index(5)]
 		#[pallet::weight(T::WeightInfo::leave_intent(T::MaxCollators::get()))] // todo:collator weight
 		pub fn release_license(origin: OriginFor<T>) -> DispatchResultWithPostInfo {
 			// leave_intent
@@ -445,8 +451,9 @@
 		/// The `LicenseBond` will be unreserved and returned immediately.
 		///
 		/// This call is, of course, not applicable to `Invulnerable` collators.
+		#[pallet::call_index(6)]
 		#[pallet::weight(T::WeightInfo::leave_intent(T::MaxCollators::get()))] // todo:collator weight
-		pub fn force_revoke_license(
+		pub fn force_release_license(
 			origin: OriginFor<T>,
 			who: T::AccountId,
 		) -> DispatchResultWithPostInfo {
modifiedpallets/collator-selection/src/mock.rsdiffbeforeafterboth
282 })282 })
283 .collect::<Vec<_>>();283 .collect::<Vec<_>>();
284 let collator_selection = collator_selection::GenesisConfig::<Test> {284 let collator_selection = collator_selection::GenesisConfig::<Test> { invulnerables };
285 invulnerables,
286 };
287 let session = pallet_session::GenesisConfig::<Test> { keys };285 let session = pallet_session::GenesisConfig::<Test> { keys };
288 pallet_balances::GenesisConfig::<Test> { balances }286 pallet_balances::GenesisConfig::<Test> { balances }
modifiedpallets/collator-selection/src/tests.rsdiffbeforeafterboth
--- a/pallets/collator-selection/src/tests.rs
+++ b/pallets/collator-selection/src/tests.rs
@@ -380,7 +380,7 @@
 }
 
 #[test]
-fn force_revoke_license() {
+fn force_release_license() {
 	new_test_ext().execute_with(|| {
 		// obtain a license to collate and reserve the bond.
 		assert_ok!(CollatorSelection::get_license(RuntimeOrigin::signed(3)));
@@ -388,12 +388,12 @@
 
 		// cannot execute the operation as non-root
 		assert_noop!(
-			CollatorSelection::force_revoke_license(RuntimeOrigin::signed(3), 3),
+			CollatorSelection::force_release_license(RuntimeOrigin::signed(3), 3),
 			BadOrigin
 		);
 
 		// release the license and get the bond back.
-		assert_ok!(CollatorSelection::force_revoke_license(
+		assert_ok!(CollatorSelection::force_release_license(
 			RuntimeOrigin::signed(RootAccount::get()),
 			3
 		));
@@ -404,7 +404,7 @@
 		assert_eq!(Balances::free_balance(3), 90);
 
 		// can release license even if onboarded.
-		assert_ok!(CollatorSelection::force_revoke_license(
+		assert_ok!(CollatorSelection::force_release_license(
 			RuntimeOrigin::signed(RootAccount::get()),
 			3
 		));
@@ -532,9 +532,7 @@
 		.unwrap();
 	let invulnerables = vec![1, 1];
 
-	let collator_selection = collator_selection::GenesisConfig::<Test> {
-		invulnerables,
-	};
+	let collator_selection = collator_selection::GenesisConfig::<Test> { invulnerables };
 	// collator selection must be initialized before session.
 	collator_selection.assimilate_storage(&mut t).unwrap();
 }
modifiedpallets/configuration/src/lib.rsdiffbeforeafterboth
--- a/pallets/configuration/src/lib.rs
+++ b/pallets/configuration/src/lib.rs
@@ -201,6 +201,7 @@
 			Ok(())
 		}
 
+		#[pallet::call_index(4)]
 		#[pallet::weight(T::DbWeight::get().writes(1))]
 		pub fn set_collator_selection_desired_collators(
 			origin: OriginFor<T>,
@@ -216,10 +217,13 @@
 			} else {
 				<CollatorSelectionDesiredCollatorsOverride<T>>::kill();
 			}
-			Self::deposit_event(Event::NewDesiredCollators { desired_collators: max });
+			Self::deposit_event(Event::NewDesiredCollators {
+				desired_collators: max,
+			});
 			Ok(())
 		}
 
+		#[pallet::call_index(5)]
 		#[pallet::weight(T::DbWeight::get().writes(1))]
 		pub fn set_collator_selection_license_bond(
 			origin: OriginFor<T>,
@@ -235,6 +239,7 @@
 			Ok(())
 		}
 
+		#[pallet::call_index(6)]
 		#[pallet::weight(T::DbWeight::get().writes(1))]
 		pub fn set_collator_selection_kick_threshold(
 			origin: OriginFor<T>,
@@ -246,7 +251,9 @@
 			} else {
 				<CollatorSelectionKickThresholdOverride<T>>::kill();
 			}
-			Self::deposit_event(Event::NewCollatorKickThreshold { length_in_blocks: threshold });
+			Self::deposit_event(Event::NewCollatorKickThreshold {
+				length_in_blocks: threshold,
+			});
 			Ok(())
 		}
 	}
modifiedruntime/common/data_management.rsdiffbeforeafterboth
--- a/runtime/common/data_management.rs
+++ b/runtime/common/data_management.rs
@@ -58,10 +58,10 @@
 		_info: &DispatchInfoOf<Self::Call>,
 		_len: usize,
 	) -> TransactionValidity {
-        match call {
-            #[cfg(feature = "collator-selection")]
-            RuntimeCall::Identity(_) => Err(TransactionValidityError::Invalid(InvalidTransaction::Call)),
-            _ => Ok(ValidTransaction::default()),
-        }
+		match call {
+			#[cfg(feature = "collator-selection")]
+			RuntimeCall::Identity(_) => Err(TransactionValidityError::Invalid(InvalidTransaction::Call)),
+			_ => Ok(ValidTransaction::default()),
+		}
 	}
 }
modifiedruntime/common/mod.rsdiffbeforeafterboth
--- a/runtime/common/mod.rs
+++ b/runtime/common/mod.rs
@@ -16,11 +16,11 @@
 
 pub mod config;
 pub mod construct_runtime;
+pub mod data_management;
 pub mod dispatch;
 pub mod ethereum;
 pub mod instance;
 pub mod maintenance;
-pub mod data_management;
 pub mod runtime_apis;
 pub mod xcm;
 
modifiedruntime/common/tests/mod.rsdiffbeforeafterboth
--- a/runtime/common/tests/mod.rs
+++ b/runtime/common/tests/mod.rs
@@ -63,9 +63,7 @@
 		.collect::<Vec<_>>();
 
 	let cfg = GenesisConfig {
-		collator_selection: CollatorSelectionConfig {
-			invulnerables,
-		},
+		collator_selection: CollatorSelectionConfig { invulnerables },
 		session: SessionConfig { keys },
 		parachain_info: ParachainInfoConfig {
 			parachain_id: para_id.into(),
modifiedtests/src/collatorSelection.seqtest.tsdiffbeforeafterboth
--- a/tests/src/collatorSelection.seqtest.ts
+++ b/tests/src/collatorSelection.seqtest.ts
@@ -209,7 +209,7 @@
         expect(await helper.collatorSelection.hasLicense(account.address)).to.be.equal(licenseBond);
 
         // force-releasing a license un-reserves the license bond cost as well
-        await helper.getSudo().collatorSelection.forceRevokeLicense(superuser, account.address);
+        await helper.getSudo().collatorSelection.forceReleaseLicense(superuser, account.address);
         expect(await helper.collatorSelection.hasLicense(account.address)).to.be.equal(previousBalance.reserved);
 
         const balance = await helper.balance.getSubstrateFull(account.address);
@@ -243,7 +243,7 @@
       itSub('Cannot force revoke a license as non-sudo', async ({helper}) => {
         const account = crowd.pop()!;
         await helper.collatorSelection.obtainLicense(account);
-        await expect(helper.collatorSelection.forceRevokeLicense(superuser, account.address))
+        await expect(helper.collatorSelection.forceReleaseLicense(superuser, account.address))
           .to.be.rejectedWith(/BadOrigin/);
       });
     });
@@ -459,7 +459,7 @@
       const candidates = await helper.collatorSelection.getCandidates();
       let nonce = await helper.chain.getNonce(superuser.address);
       await Promise.all(candidates.map(candidate =>
-        helper.getSudo().executeExtrinsic(superuser, 'api.tx.collatorSelection.forceRevokeLicense', [candidate], true, {nonce: nonce++})));
+        helper.getSudo().executeExtrinsic(superuser, 'api.tx.collatorSelection.forceReleaseLicense', [candidate], true, {nonce: nonce++})));
     });
   });
 });
\ No newline at end of file
modifiedtests/src/interfaces/augment-api-tx.tsdiffbeforeafterboth
--- a/tests/src/interfaces/augment-api-tx.ts
+++ b/tests/src/interfaces/augment-api-tx.ts
@@ -237,7 +237,7 @@
        * 
        * This call is, of course, not applicable to `Invulnerable` collators.
        **/
-      forceRevokeLicense: AugmentedSubmittable<(who: AccountId32 | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [AccountId32]>;
+      forceReleaseLicense: AugmentedSubmittable<(who: AccountId32 | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [AccountId32]>;
       /**
        * Purchase a license on block collation for this account.
        * It does not make it a collator candidate, use `onboard` afterward. The account must
modifiedtests/src/interfaces/default/types.tsdiffbeforeafterboth
--- a/tests/src/interfaces/default/types.ts
+++ b/tests/src/interfaces/default/types.ts
@@ -1243,11 +1243,11 @@
   readonly isOnboard: boolean;
   readonly isOffboard: boolean;
   readonly isReleaseLicense: boolean;
-  readonly isForceRevokeLicense: boolean;
-  readonly asForceRevokeLicense: {
+  readonly isForceReleaseLicense: boolean;
+  readonly asForceReleaseLicense: {
     readonly who: AccountId32;
   } & Struct;
-  readonly type: 'AddInvulnerable' | 'RemoveInvulnerable' | 'GetLicense' | 'Onboard' | 'Offboard' | 'ReleaseLicense' | 'ForceRevokeLicense';
+  readonly type: 'AddInvulnerable' | 'RemoveInvulnerable' | 'GetLicense' | 'Onboard' | 'Offboard' | 'ReleaseLicense' | 'ForceReleaseLicense';
 }
 
 /** @name PalletCollatorSelectionError */
modifiedtests/src/interfaces/lookup.tsdiffbeforeafterboth
--- a/tests/src/interfaces/lookup.ts
+++ b/tests/src/interfaces/lookup.ts
@@ -1692,7 +1692,7 @@
       onboard: 'Null',
       offboard: 'Null',
       release_license: 'Null',
-      force_revoke_license: {
+      force_release_license: {
         who: 'AccountId32'
       }
     }
modifiedtests/src/interfaces/types-lookup.tsdiffbeforeafterboth
--- a/tests/src/interfaces/types-lookup.ts
+++ b/tests/src/interfaces/types-lookup.ts
@@ -1867,11 +1867,11 @@
     readonly isOnboard: boolean;
     readonly isOffboard: boolean;
     readonly isReleaseLicense: boolean;
-    readonly isForceRevokeLicense: boolean;
-    readonly asForceRevokeLicense: {
+    readonly isForceReleaseLicense: boolean;
+    readonly asForceReleaseLicense: {
       readonly who: AccountId32;
     } & Struct;
-    readonly type: 'AddInvulnerable' | 'RemoveInvulnerable' | 'GetLicense' | 'Onboard' | 'Offboard' | 'ReleaseLicense' | 'ForceRevokeLicense';
+    readonly type: 'AddInvulnerable' | 'RemoveInvulnerable' | 'GetLicense' | 'Onboard' | 'Offboard' | 'ReleaseLicense' | 'ForceReleaseLicense';
   }
 
   /** @name PalletCollatorSelectionError (185) */
modifiedtests/src/util/playgrounds/unique.tsdiffbeforeafterboth
--- a/tests/src/util/playgrounds/unique.ts
+++ b/tests/src/util/playgrounds/unique.ts
@@ -2772,8 +2772,8 @@
     return this.helper.executeExtrinsic(signer, 'api.tx.collatorSelection.releaseLicense', []);
   }
 
-  forceRevokeLicense(signer: TSigner, released: string) {
-    return this.helper.executeExtrinsic(signer, 'api.tx.collatorSelection.forceRevokeLicense', [released]);
+  forceReleaseLicense(signer: TSigner, released: string) {
+    return this.helper.executeExtrinsic(signer, 'api.tx.collatorSelection.forceReleaseLicense', [released]);
   }
 
   async hasLicense(address: string): Promise<bigint> {