Skip to content

Commit 780e00a

Browse files
committed
feat: extra event StakeDelayedExecutionFailed for possible UX improvements
1 parent ca59e71 commit 780e00a

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

contracts/hardhat.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const config: HardhatUserConfig = {
3232
viaIR: process.env.VIA_IR !== "false", // Defaults to true
3333
optimizer: {
3434
enabled: true,
35-
runs: 1000,
35+
runs: 800, // Constrained by the size of the KlerosCore contract
3636
},
3737
outputSelection: {
3838
"*": {

contracts/src/arbitration/KlerosCore.sol

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -613,9 +613,10 @@ contract KlerosCore is IArbitratorV2, Initializable, UUPSProxiable {
613613
/// @param _account The account whose stake is being set.
614614
/// @param _courtID The ID of the court.
615615
/// @param _newStake The new stake.
616-
function setStakeBySortitionModule(address _account, uint96 _courtID, uint256 _newStake) external {
616+
/// @return True if the stake was set successfully.
617+
function setStakeBySortitionModule(address _account, uint96 _courtID, uint256 _newStake) external returns (bool) {
617618
if (msg.sender != address(sortitionModule)) revert SortitionModuleOnly();
618-
_setStake(_account, _courtID, _newStake, true, OnError.Return);
619+
return _setStake(_account, _courtID, _newStake, true, OnError.Return);
619620
}
620621

621622
/// @notice Transfers PNK to the juror by SortitionModule.

contracts/src/arbitration/SortitionModule.sol

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ contract SortitionModule is ISortitionModule, Initializable, UUPSProxiable {
7474
/// @param _amount The amount of tokens staked in the court.
7575
event StakeDelayed(address indexed _address, uint96 indexed _courtID, uint256 _amount);
7676

77+
/// @notice Emitted when a juror's stake is delayed execution fails.
78+
/// @param _address The address of the juror.
79+
/// @param _courtID The ID of the court.
80+
/// @param _amount The amount of tokens staked in the court.
81+
event StakeDelayedExecutionFailed(address indexed _address, uint96 indexed _courtID, uint256 _amount);
82+
7783
/// @notice Emitted when a juror's stake is locked.
7884
/// @param _address The address of the juror.
7985
/// @param _relativeAmount The amount of tokens locked.
@@ -235,7 +241,9 @@ contract SortitionModule is ISortitionModule, Initializable, UUPSProxiable {
235241

236242
for (uint256 i = delayedStakeReadIndex; i < newDelayedStakeReadIndex; i++) {
237243
DelayedStake storage delayedStake = delayedStakes[i];
238-
core.setStakeBySortitionModule(delayedStake.account, delayedStake.courtID, delayedStake.stake);
244+
if (!core.setStakeBySortitionModule(delayedStake.account, delayedStake.courtID, delayedStake.stake)) {
245+
emit StakeDelayedExecutionFailed(delayedStake.account, delayedStake.courtID, delayedStake.stake);
246+
}
239247
delete delayedStakes[i];
240248
}
241249
delayedStakeReadIndex = newDelayedStakeReadIndex;

contracts/src/arbitration/university/KlerosCoreUniversity.sol

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -462,9 +462,10 @@ contract KlerosCoreUniversity is IArbitratorV2, UUPSProxiable, Initializable {
462462
/// @param _account The account whose stake is being set.
463463
/// @param _courtID The ID of the court.
464464
/// @param _newStake The new stake.
465-
function setStakeBySortitionModule(address _account, uint96 _courtID, uint256 _newStake) external {
465+
/// @return True if the stake was set successfully.
466+
function setStakeBySortitionModule(address _account, uint96 _courtID, uint256 _newStake) external returns (bool) {
466467
if (msg.sender != address(sortitionModule)) revert SortitionModuleOnly();
467-
_setStake(_account, _courtID, _newStake, true, OnError.Return);
468+
return _setStake(_account, _courtID, _newStake, true, OnError.Return);
468469
}
469470

470471
/// @notice Transfers PNK to the juror by SortitionModule.

0 commit comments

Comments
 (0)