Skip to content

Commit 871fd60

Browse files
zmalatraxjaybuidl
authored andcommitted
feat(proxy): make KlerosCore upgradeable
1 parent f06cc90 commit 871fd60

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

contracts/src/arbitration/KlerosCore.sol

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@ import {IArbitrableV2, IArbitratorV2} from "./interfaces/IArbitratorV2.sol";
1212
import "./interfaces/IDisputeKit.sol";
1313
import "./interfaces/ISortitionModule.sol";
1414
import "../libraries/SafeERC20.sol";
15+
import "../proxy/UUPSProxiable.sol";
16+
import "../proxy/Initializable.sol";
1517

1618
/// @title KlerosCore
1719
/// Core arbitrator contract for Kleros v2.
1820
/// Note that this contract trusts the PNK token, the dispute kit and the sortition module contracts.
19-
contract KlerosCore is IArbitratorV2 {
21+
contract KlerosCore is IArbitratorV2, UUPSProxiable, Initializable {
2022
using SafeERC20 for IERC20;
2123

2224
// ************************************* //
@@ -200,7 +202,12 @@ contract KlerosCore is IArbitratorV2 {
200202
// * Constructor * //
201203
// ************************************* //
202204

203-
/// @dev Constructor
205+
/// @dev Constructor, initializing the implementation to reduce attack surface.
206+
constructor() {
207+
_disableInitializers();
208+
}
209+
210+
/// @dev Initializer (constructor equivalent for upgradable contracts).
204211
/// @param _governor The governor's address.
205212
/// @param _pinakion The address of the token contract.
206213
/// @param _jurorProsecutionModule The address of the juror prosecution module.
@@ -210,7 +217,7 @@ contract KlerosCore is IArbitratorV2 {
210217
/// @param _timesPerPeriod The `timesPerPeriod` property value of the general court.
211218
/// @param _sortitionExtraData The extra data for sortition module.
212219
/// @param _sortitionModuleAddress The sortition module responsible for sortition of the jurors.
213-
constructor(
220+
function initialize(
214221
address _governor,
215222
IERC20 _pinakion,
216223
address _jurorProsecutionModule,
@@ -220,7 +227,7 @@ contract KlerosCore is IArbitratorV2 {
220227
uint256[4] memory _timesPerPeriod,
221228
bytes memory _sortitionExtraData,
222229
ISortitionModule _sortitionModuleAddress
223-
) {
230+
) external initializer {
224231
governor = _governor;
225232
pinakion = _pinakion;
226233
jurorProsecutionModule = _jurorProsecutionModule;
@@ -277,6 +284,13 @@ contract KlerosCore is IArbitratorV2 {
277284
// * Governance * //
278285
// ************************************* //
279286

287+
/* @dev Access Control to perform implementation upgrades (UUPS Proxiable)
288+
* @dev Only the governor can perform upgrades (`onlyByGovernor`)
289+
*/
290+
function _authorizeUpgrade(address) internal view override {
291+
onlyByGovernor();
292+
}
293+
280294
/// @dev Allows the governor to call anything on behalf of the contract.
281295
/// @param _destination The destination of the call.
282296
/// @param _amount The value sent with the call.

0 commit comments

Comments
 (0)