@@ -464,16 +464,16 @@ abstract contract KlerosCoreBase is IArbitratorV2, Initializable, UUPSProxiable
464464 /// @param _newStake The new stake.
465465 /// Note that the existing delayed stake will be nullified as non-relevant.
466466 function setStake (uint96 _courtID , uint256 _newStake ) external virtual whenNotPaused {
467- _setStake (msg .sender , _courtID, _newStake, OnError.Revert);
467+ _setStake (msg .sender , _courtID, _newStake, false , OnError.Revert);
468468 }
469469
470- /// @dev Sets the stake of a specified account in a court, typically to apply a delayed stake or unstake inactive jurors.
470+ /// @dev Sets the stake of a specified account in a court without delaying stake changes , typically to apply a delayed stake or unstake inactive jurors.
471471 /// @param _account The account whose stake is being set.
472472 /// @param _courtID The ID of the court.
473473 /// @param _newStake The new stake.
474474 function setStakeBySortitionModule (address _account , uint96 _courtID , uint256 _newStake ) external {
475475 if (msg .sender != address (sortitionModule)) revert SortitionModuleOnly ();
476- _setStake (_account, _courtID, _newStake, OnError.Return);
476+ _setStake (_account, _courtID, _newStake, true , OnError.Return);
477477 }
478478
479479 /// @dev Transfers PNK to the juror by SortitionModule.
@@ -796,10 +796,10 @@ abstract contract KlerosCoreBase is IArbitratorV2, Initializable, UUPSProxiable
796796
797797 if (pnkBalance == 0 || ! disputeKit.isVoteActive (_params.disputeID, _params.round, _params.repartition)) {
798798 // The juror is inactive or their balance is can't cover penalties anymore, unstake them from all courts.
799- sortitionModule.setJurorInactive (account);
799+ sortitionModule.unstakeByCoreFromAllCourts (account);
800800 } else if (newCourtStake < courts[penalizedInCourtID].minStake) {
801801 // The juror's balance fell below the court minStake, unstake them from the court.
802- sortitionModule.setStake (account, penalizedInCourtID, 0 , 0 , 0 );
802+ sortitionModule.unstakeByCore (account, penalizedInCourtID);
803803 }
804804
805805 if (_params.repartition == _params.numberOfVotesInRound - 1 && _params.coherentCount == 0 ) {
@@ -1138,9 +1138,16 @@ abstract contract KlerosCoreBase is IArbitratorV2, Initializable, UUPSProxiable
11381138 /// @param _account The account to set the stake for.
11391139 /// @param _courtID The ID of the court to set the stake for.
11401140 /// @param _newStake The new stake.
1141+ /// @param _noDelay True if the stake change should not be delayed.
11411142 /// @param _onError Whether to revert or return false on error.
11421143 /// @return Whether the stake was successfully set or not.
1143- function _setStake (address _account , uint96 _courtID , uint256 _newStake , OnError _onError ) internal returns (bool ) {
1144+ function _setStake (
1145+ address _account ,
1146+ uint96 _courtID ,
1147+ uint256 _newStake ,
1148+ bool _noDelay ,
1149+ OnError _onError
1150+ ) internal returns (bool ) {
11441151 if (_courtID == FORKING_COURT || _courtID >= courts.length ) {
11451152 _stakingFailed (_onError, StakingResult.CannotStakeInThisCourt); // Staking directly into the forking court is not allowed.
11461153 return false ;
@@ -1152,7 +1159,8 @@ abstract contract KlerosCoreBase is IArbitratorV2, Initializable, UUPSProxiable
11521159 (uint256 pnkDeposit , uint256 pnkWithdrawal , StakingResult stakingResult ) = sortitionModule.validateStake (
11531160 _account,
11541161 _courtID,
1155- _newStake
1162+ _newStake,
1163+ _noDelay
11561164 );
11571165 if (stakingResult != StakingResult.Successful && stakingResult != StakingResult.Delayed) {
11581166 _stakingFailed (_onError, stakingResult);
0 commit comments