Skip to content

Commit c193e48

Browse files
committed
fix: removed the unused _alreadyTransferred parameter
1 parent f30d327 commit c193e48

File tree

8 files changed

+24
-68
lines changed

8 files changed

+24
-68
lines changed

contracts/src/arbitration/KlerosCoreBase.sol

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -463,21 +463,16 @@ abstract contract KlerosCoreBase is IArbitratorV2, Initializable, UUPSProxiable
463463
/// @param _newStake The new stake.
464464
/// Note that the existing delayed stake will be nullified as non-relevant.
465465
function setStake(uint96 _courtID, uint256 _newStake) external virtual whenNotPaused {
466-
_setStake(msg.sender, _courtID, _newStake, false, OnError.Revert);
466+
_setStake(msg.sender, _courtID, _newStake, OnError.Revert);
467467
}
468468

469469
/// @dev Sets the stake of a specified account in a court, typically to apply a delayed stake or unstake inactive jurors.
470470
/// @param _account The account whose stake is being set.
471471
/// @param _courtID The ID of the court.
472472
/// @param _newStake The new stake.
473-
function setStakeBySortitionModule(
474-
address _account,
475-
uint96 _courtID,
476-
uint256 _newStake,
477-
bool /*_alreadyTransferred*/
478-
) external {
473+
function setStakeBySortitionModule(address _account, uint96 _courtID, uint256 _newStake) external {
479474
if (msg.sender != address(sortitionModule)) revert SortitionModuleOnly();
480-
_setStake(_account, _courtID, _newStake, false, OnError.Return); // alreadyTransferred is unused and DEPRECATED.
475+
_setStake(_account, _courtID, _newStake, OnError.Return);
481476
}
482477

483478
/// @dev Transfers PNK to the juror by SortitionModule.
@@ -1078,13 +1073,7 @@ abstract contract KlerosCoreBase is IArbitratorV2, Initializable, UUPSProxiable
10781073
/// @param _newStake The new stake.
10791074
/// @param _onError Whether to revert or return false on error.
10801075
/// @return Whether the stake was successfully set or not.
1081-
function _setStake(
1082-
address _account,
1083-
uint96 _courtID,
1084-
uint256 _newStake,
1085-
bool /*_alreadyTransferred*/,
1086-
OnError _onError
1087-
) internal returns (bool) {
1076+
function _setStake(address _account, uint96 _courtID, uint256 _newStake, OnError _onError) internal returns (bool) {
10881077
if (_courtID == FORKING_COURT || _courtID >= courts.length) {
10891078
_stakingFailed(_onError, StakingResult.CannotStakeInThisCourt); // Staking directly into the forking court is not allowed.
10901079
return false;
@@ -1096,8 +1085,7 @@ abstract contract KlerosCoreBase is IArbitratorV2, Initializable, UUPSProxiable
10961085
(uint256 pnkDeposit, uint256 pnkWithdrawal, StakingResult stakingResult) = sortitionModule.setStake(
10971086
_account,
10981087
_courtID,
1099-
_newStake,
1100-
false // Unused parameter.
1088+
_newStake
11011089
);
11021090
if (stakingResult != StakingResult.Successful && stakingResult != StakingResult.Delayed) {
11031091
_stakingFailed(_onError, stakingResult);

contracts/src/arbitration/KlerosCoreNeo.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ contract KlerosCoreNeo is KlerosCoreBase {
105105
/// Note that the existing delayed stake will be nullified as non-relevant.
106106
function setStake(uint96 _courtID, uint256 _newStake) external override whenNotPaused {
107107
if (jurorNft.balanceOf(msg.sender) == 0) revert NotEligibleForStaking();
108-
super._setStake(msg.sender, _courtID, _newStake, false, OnError.Revert);
108+
super._setStake(msg.sender, _courtID, _newStake, OnError.Revert);
109109
}
110110

111111
// ************************************* //

contracts/src/arbitration/SortitionModuleBase.sol

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -241,12 +241,7 @@ abstract contract SortitionModuleBase is ISortitionModule, Initializable, UUPSPr
241241

242242
for (uint256 i = delayedStakeReadIndex; i < newDelayedStakeReadIndex; i++) {
243243
DelayedStake storage delayedStake = delayedStakes[i];
244-
core.setStakeBySortitionModule(
245-
delayedStake.account,
246-
delayedStake.courtID,
247-
delayedStake.stake,
248-
false // Unused parameter.
249-
);
244+
core.setStakeBySortitionModule(delayedStake.account, delayedStake.courtID, delayedStake.stake);
250245
delete delayedStakes[i];
251246
}
252247
delayedStakeReadIndex = newDelayedStakeReadIndex;
@@ -279,19 +274,17 @@ abstract contract SortitionModuleBase is ISortitionModule, Initializable, UUPSPr
279274
function setStake(
280275
address _account,
281276
uint96 _courtID,
282-
uint256 _newStake,
283-
bool /*_alreadyTransferred*/
277+
uint256 _newStake
284278
) external override onlyByCore returns (uint256 pnkDeposit, uint256 pnkWithdrawal, StakingResult stakingResult) {
285-
(pnkDeposit, pnkWithdrawal, stakingResult) = _setStake(_account, _courtID, _newStake, false); // The last parameter is unused.
279+
(pnkDeposit, pnkWithdrawal, stakingResult) = _setStake(_account, _courtID, _newStake);
286280
}
287281

288282
/// @dev Sets the specified juror's stake in a court.
289283
/// Note: no state changes should be made when returning stakingResult != Successful, otherwise delayed stakes might break invariants.
290284
function _setStake(
291285
address _account,
292286
uint96 _courtID,
293-
uint256 _newStake,
294-
bool /*_alreadyTransferred*/
287+
uint256 _newStake
295288
) internal virtual returns (uint256 pnkDeposit, uint256 pnkWithdrawal, StakingResult stakingResult) {
296289
Juror storage juror = jurors[_account];
297290
uint256 currentStake = stakeOf(_account, _courtID);
@@ -414,7 +407,7 @@ abstract contract SortitionModuleBase is ISortitionModule, Initializable, UUPSPr
414407
function setJurorInactive(address _account) external override onlyByCore {
415408
uint96[] memory courtIDs = getJurorCourtIDs(_account);
416409
for (uint256 j = courtIDs.length; j > 0; j--) {
417-
core.setStakeBySortitionModule(_account, courtIDs[j - 1], 0, false);
410+
core.setStakeBySortitionModule(_account, courtIDs[j - 1], 0);
418411
}
419412
}
420413

contracts/src/arbitration/SortitionModuleNeo.sol

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,7 @@ contract SortitionModuleNeo is SortitionModuleBase {
8787
function _setStake(
8888
address _account,
8989
uint96 _courtID,
90-
uint256 _newStake,
91-
bool /*_alreadyTransferred*/
90+
uint256 _newStake
9291
) internal override onlyByCore returns (uint256 pnkDeposit, uint256 pnkWithdrawal, StakingResult stakingResult) {
9392
uint256 currentStake = stakeOf(_account, _courtID);
9493
bool stakeIncrease = _newStake > currentStake;
@@ -109,11 +108,6 @@ contract SortitionModuleNeo is SortitionModuleBase {
109108
totalStaked -= stakeChange;
110109
}
111110
}
112-
(pnkDeposit, pnkWithdrawal, stakingResult) = super._setStake(
113-
_account,
114-
_courtID,
115-
_newStake,
116-
false // This parameter is not used
117-
);
111+
(pnkDeposit, pnkWithdrawal, stakingResult) = super._setStake(_account, _courtID, _newStake);
118112
}
119113
}

contracts/src/arbitration/interfaces/ISortitionModule.sol

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ interface ISortitionModule {
1717
function setStake(
1818
address _account,
1919
uint96 _courtID,
20-
uint256 _newStake,
21-
bool _alreadyTransferred
20+
uint256 _newStake
2221
) external returns (uint256 pnkDeposit, uint256 pnkWithdrawal, StakingResult stakingResult);
2322

2423
function setJurorInactive(address _account) external;

contracts/src/arbitration/university/KlerosCoreUniversity.sol

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -456,22 +456,16 @@ contract KlerosCoreUniversity is IArbitratorV2, UUPSProxiable, Initializable {
456456
/// @param _newStake The new stake.
457457
/// Note that the existing delayed stake will be nullified as non-relevant.
458458
function setStake(uint96 _courtID, uint256 _newStake) external {
459-
_setStake(msg.sender, _courtID, _newStake, false, OnError.Revert);
459+
_setStake(msg.sender, _courtID, _newStake, OnError.Revert);
460460
}
461461

462462
/// @dev Sets the stake of a specified account in a court, typically to apply a delayed stake or unstake inactive jurors.
463463
/// @param _account The account whose stake is being set.
464464
/// @param _courtID The ID of the court.
465465
/// @param _newStake The new stake.
466-
/// @param _alreadyTransferred Whether the PNKs have already been transferred to the contract.
467-
function setStakeBySortitionModule(
468-
address _account,
469-
uint96 _courtID,
470-
uint256 _newStake,
471-
bool _alreadyTransferred
472-
) external {
466+
function setStakeBySortitionModule(address _account, uint96 _courtID, uint256 _newStake) external {
473467
if (msg.sender != address(sortitionModule)) revert SortitionModuleOnly();
474-
_setStake(_account, _courtID, _newStake, _alreadyTransferred, OnError.Return);
468+
_setStake(_account, _courtID, _newStake, OnError.Return);
475469
}
476470

477471
/// @inheritdoc IArbitratorV2
@@ -1042,16 +1036,9 @@ contract KlerosCoreUniversity is IArbitratorV2, UUPSProxiable, Initializable {
10421036
/// @param _account The account to set the stake for.
10431037
/// @param _courtID The ID of the court to set the stake for.
10441038
/// @param _newStake The new stake.
1045-
/// @param _alreadyTransferred Whether the PNKs were already transferred to/from the staking contract.
10461039
/// @param _onError Whether to revert or return false on error.
10471040
/// @return Whether the stake was successfully set or not.
1048-
function _setStake(
1049-
address _account,
1050-
uint96 _courtID,
1051-
uint256 _newStake,
1052-
bool _alreadyTransferred,
1053-
OnError _onError
1054-
) internal returns (bool) {
1041+
function _setStake(address _account, uint96 _courtID, uint256 _newStake, OnError _onError) internal returns (bool) {
10551042
if (_courtID == FORKING_COURT || _courtID > courts.length) {
10561043
_stakingFailed(_onError, StakingResult.CannotStakeInThisCourt); // Staking directly into the forking court is not allowed.
10571044
return false;
@@ -1063,8 +1050,7 @@ contract KlerosCoreUniversity is IArbitratorV2, UUPSProxiable, Initializable {
10631050
(uint256 pnkDeposit, uint256 pnkWithdrawal, StakingResult stakingResult) = sortitionModule.setStake(
10641051
_account,
10651052
_courtID,
1066-
_newStake,
1067-
_alreadyTransferred
1053+
_newStake
10681054
);
10691055
if (stakingResult != StakingResult.Successful) {
10701056
_stakingFailed(_onError, stakingResult);

contracts/src/arbitration/university/SortitionModuleUniversity.sol

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -135,15 +135,13 @@ contract SortitionModuleUniversity is ISortitionModuleUniversity, UUPSProxiable,
135135
/// @param _account The address of the juror.
136136
/// @param _courtID The ID of the court.
137137
/// @param _newStake The new stake.
138-
/// @param _alreadyTransferred True if the tokens were already transferred from juror. Only relevant for delayed stakes.
139138
/// @return pnkDeposit The amount of PNK to be deposited.
140139
/// @return pnkWithdrawal The amount of PNK to be withdrawn.
141140
/// @return stakingResult The result of the staking operation.
142141
function setStake(
143142
address _account,
144143
uint96 _courtID,
145-
uint256 _newStake,
146-
bool _alreadyTransferred
144+
uint256 _newStake
147145
) external override onlyByCore returns (uint256 pnkDeposit, uint256 pnkWithdrawal, StakingResult stakingResult) {
148146
Juror storage juror = jurors[_account];
149147
uint256 currentStake = _stakeOf(_account, _courtID);
@@ -154,11 +152,9 @@ contract SortitionModuleUniversity is ISortitionModuleUniversity, UUPSProxiable,
154152
}
155153

156154
if (_newStake >= currentStake) {
157-
if (!_alreadyTransferred) {
158-
pnkDeposit = _increaseStake(juror, _courtID, _newStake, currentStake);
159-
}
155+
pnkDeposit = _increaseStake(juror, _courtID, _newStake, currentStake);
160156
} else {
161-
pnkWithdrawal += _decreaseStake(juror, _courtID, _newStake, currentStake);
157+
pnkWithdrawal = _decreaseStake(juror, _courtID, _newStake, currentStake);
162158
}
163159

164160
bool finished = false;
@@ -257,7 +253,7 @@ contract SortitionModuleUniversity is ISortitionModuleUniversity, UUPSProxiable,
257253
function setJurorInactive(address _account) external override onlyByCore {
258254
uint96[] memory courtIDs = getJurorCourtIDs(_account);
259255
for (uint256 j = courtIDs.length; j > 0; j--) {
260-
core.setStakeBySortitionModule(_account, courtIDs[j - 1], 0, false);
256+
core.setStakeBySortitionModule(_account, courtIDs[j - 1], 0);
261257
}
262258
}
263259

contracts/test/foundry/KlerosCore.t.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1240,7 +1240,7 @@ contract KlerosCoreTest is Test {
12401240
// Note that functionality of this function was checked during delayed stakes execution
12411241
vm.expectRevert(KlerosCoreBase.SortitionModuleOnly.selector);
12421242
vm.prank(governor);
1243-
core.setStakeBySortitionModule(staker1, GENERAL_COURT, 1000, false);
1243+
core.setStakeBySortitionModule(staker1, GENERAL_COURT, 1000);
12441244
}
12451245

12461246
function test_setStake_snapshotProxyCheck() public {

0 commit comments

Comments
 (0)