Skip to content

Commit

Permalink
Relaxed decommission mode (#1155)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dinonard authored Jan 29, 2024
1 parent f9391d3 commit dc191dc
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 34 deletions.
11 changes: 1 addition & 10 deletions pallets/dapps-staking/src/pallet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,6 @@ pub mod pallet {
NominationTransferToSameContract,
/// Decommission is in progress so this call is not allowed.
DecommissionInProgress,
/// Pallet decommission hasn't been started yet so this call is not allowed.
DecommissionNotStarted,
}

#[pallet::hooks]
Expand Down Expand Up @@ -925,10 +923,6 @@ pub mod pallet {
contract_id: T::SmartContract,
) -> DispatchResultWithPostInfo {
Self::ensure_pallet_enabled()?;
ensure!(
DecommissionStarted::<T>::get(),
Error::<T>::DecommissionNotStarted
);
ensure_signed(origin)?;

Self::internal_claim_staker_for(staker, contract_id)
Expand All @@ -944,10 +938,7 @@ pub mod pallet {
reward_destination: RewardDestination,
) -> DispatchResultWithPostInfo {
Self::ensure_pallet_enabled()?;
ensure!(
DecommissionStarted::<T>::get(),
Error::<T>::DecommissionNotStarted
);

ensure_signed(origin)?;

Self::internal_set_reward_destination_for(staker, reward_destination)
Expand Down
24 changes: 0 additions & 24 deletions pallets/dapps-staking/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2485,18 +2485,6 @@ fn claim_staker_for_works() {
// Advance to next era so we can claim rewards for it
advance_to_era(DappsStaking::current_era() + 1);

// Claiming for another staker is not possible unless decommission has started
assert_noop!(
DappsStaking::claim_staker_for(
RuntimeOrigin::signed(claimer),
staker,
smart_contract.clone()
),
Error::<TestRuntime>::DecommissionNotStarted
);

// Enable decommission mode & claim the reward
assert_ok!(DappsStaking::decommission(RuntimeOrigin::root()));
assert_ok!(DappsStaking::claim_staker_for(
RuntimeOrigin::signed(claimer),
staker,
Expand Down Expand Up @@ -2524,18 +2512,6 @@ fn set_reward_destination_for_works() {
assert_register(developer, &smart_contract);
assert_bond_and_stake(staker, &smart_contract, 17);

// Claiming for another staker is not possible unless decommission has started
assert_noop!(
DappsStaking::set_reward_destination_for(
RuntimeOrigin::signed(caller),
staker,
RewardDestination::StakeBalance
),
Error::<TestRuntime>::DecommissionNotStarted
);

// Enable decommission mode and set the reward destination
assert_ok!(DappsStaking::decommission(RuntimeOrigin::root()));
assert_ok!(DappsStaking::set_reward_destination_for(
RuntimeOrigin::signed(caller),
staker,
Expand Down

0 comments on commit dc191dc

Please sign in to comment.