diff --git a/contracts/hardhat.config.ts b/contracts/hardhat.config.ts index 41a4fb63e..21a62a310 100644 --- a/contracts/hardhat.config.ts +++ b/contracts/hardhat.config.ts @@ -32,7 +32,7 @@ const config: HardhatUserConfig = { viaIR: process.env.VIA_IR !== "false", // Defaults to true optimizer: { enabled: true, - runs: 1000, + runs: 800, // Constrained by the size of the KlerosCore contract }, outputSelection: { "*": { diff --git a/contracts/src/arbitration/KlerosCore.sol b/contracts/src/arbitration/KlerosCore.sol index cd0741a65..deb46afd8 100644 --- a/contracts/src/arbitration/KlerosCore.sol +++ b/contracts/src/arbitration/KlerosCore.sol @@ -613,9 +613,10 @@ contract KlerosCore is IArbitratorV2, Initializable, UUPSProxiable { /// @param _account The account whose stake is being set. /// @param _courtID The ID of the court. /// @param _newStake The new stake. - function setStakeBySortitionModule(address _account, uint96 _courtID, uint256 _newStake) external { + /// @return True if the stake was set successfully. + function setStakeBySortitionModule(address _account, uint96 _courtID, uint256 _newStake) external returns (bool) { if (msg.sender != address(sortitionModule)) revert SortitionModuleOnly(); - _setStake(_account, _courtID, _newStake, true, OnError.Return); + return _setStake(_account, _courtID, _newStake, true, OnError.Return); } /// @notice Transfers PNK to the juror by SortitionModule. diff --git a/contracts/src/arbitration/SortitionModule.sol b/contracts/src/arbitration/SortitionModule.sol index 125c44c3a..8a73ac76e 100644 --- a/contracts/src/arbitration/SortitionModule.sol +++ b/contracts/src/arbitration/SortitionModule.sol @@ -74,6 +74,12 @@ contract SortitionModule is ISortitionModule, Initializable, UUPSProxiable { /// @param _amount The amount of tokens staked in the court. event StakeDelayed(address indexed _address, uint96 indexed _courtID, uint256 _amount); + /// @notice Emitted when a juror's stake is delayed execution fails. + /// @param _address The address of the juror. + /// @param _courtID The ID of the court. + /// @param _amount The amount of tokens staked in the court. + event StakeDelayedExecutionFailed(address indexed _address, uint96 indexed _courtID, uint256 _amount); + /// @notice Emitted when a juror's stake is locked. /// @param _address The address of the juror. /// @param _relativeAmount The amount of tokens locked. @@ -235,7 +241,9 @@ contract SortitionModule is ISortitionModule, Initializable, UUPSProxiable { for (uint256 i = delayedStakeReadIndex; i < newDelayedStakeReadIndex; i++) { DelayedStake storage delayedStake = delayedStakes[i]; - core.setStakeBySortitionModule(delayedStake.account, delayedStake.courtID, delayedStake.stake); + if (!core.setStakeBySortitionModule(delayedStake.account, delayedStake.courtID, delayedStake.stake)) { + emit StakeDelayedExecutionFailed(delayedStake.account, delayedStake.courtID, delayedStake.stake); + } delete delayedStakes[i]; } delayedStakeReadIndex = newDelayedStakeReadIndex; diff --git a/contracts/src/arbitration/university/KlerosCoreUniversity.sol b/contracts/src/arbitration/university/KlerosCoreUniversity.sol index 43a63d9f9..39f4414a4 100644 --- a/contracts/src/arbitration/university/KlerosCoreUniversity.sol +++ b/contracts/src/arbitration/university/KlerosCoreUniversity.sol @@ -462,9 +462,10 @@ contract KlerosCoreUniversity is IArbitratorV2, UUPSProxiable, Initializable { /// @param _account The account whose stake is being set. /// @param _courtID The ID of the court. /// @param _newStake The new stake. - function setStakeBySortitionModule(address _account, uint96 _courtID, uint256 _newStake) external { + /// @return True if the stake was set successfully. + function setStakeBySortitionModule(address _account, uint96 _courtID, uint256 _newStake) external returns (bool) { if (msg.sender != address(sortitionModule)) revert SortitionModuleOnly(); - _setStake(_account, _courtID, _newStake, true, OnError.Return); + return _setStake(_account, _courtID, _newStake, true, OnError.Return); } /// @notice Transfers PNK to the juror by SortitionModule.