Skip to content

Commit f06cc90

Browse files
zmalatraxjaybuidl
authored andcommitted
feat(proxy): make SortitionModule upgradeable
1 parent dd0f9b3 commit f06cc90

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

contracts/src/arbitration/SortitionModule.sol

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@ import "./KlerosCore.sol";
1414
import "./interfaces/ISortitionModule.sol";
1515
import "./interfaces/IDisputeKit.sol";
1616
import "../rng/RNG.sol";
17+
import "../proxy/UUPSProxiable.sol";
18+
import "../proxy/Initializable.sol";
1719

1820
/// @title SortitionModule
1921
/// @dev A factory of trees that keeps track of staked values for sortition.
20-
contract SortitionModule is ISortitionModule {
22+
contract SortitionModule is ISortitionModule, UUPSProxiable, Initializable {
2123
// ************************************* //
2224
// * Enums / Structs * //
2325
// ************************************* //
@@ -79,20 +81,25 @@ contract SortitionModule is ISortitionModule {
7981
// * Constructor * //
8082
// ************************************* //
8183

82-
/// @dev Constructor.
84+
/// @dev Constructor, initializing the implementation to reduce attack surface.
85+
constructor() {
86+
_disableInitializers();
87+
}
88+
89+
/// @dev Initializer (constructor equivalent for upgradable contracts).
8390
/// @param _core The KlerosCore.
8491
/// @param _minStakingTime Minimal time to stake
8592
/// @param _maxDrawingTime Time after which the drawing phase can be switched
8693
/// @param _rng The random number generator.
8794
/// @param _rngLookahead Lookahead value for rng.
88-
constructor(
95+
function initialize(
8996
address _governor,
9097
KlerosCore _core,
9198
uint256 _minStakingTime,
9299
uint256 _maxDrawingTime,
93100
RNG _rng,
94101
uint256 _rngLookahead
95-
) {
102+
) external reinitializer(1) {
96103
governor = _governor;
97104
core = _core;
98105
minStakingTime = _minStakingTime;
@@ -106,6 +113,13 @@ contract SortitionModule is ISortitionModule {
106113
// * Governance * //
107114
// ************************************* //
108115

116+
/**
117+
* @dev Access Control to perform implementation upgrades (UUPS Proxiable)
118+
* @dev Only the governor can perform upgrades (`onlyByGovernor`)
119+
*/
120+
121+
function _authorizeUpgrade(address) internal view override onlyByGovernor {}
122+
109123
/// @dev Changes the `minStakingTime` storage variable.
110124
/// @param _minStakingTime The new value for the `minStakingTime` storage variable.
111125
function changeMinStakingTime(uint256 _minStakingTime) external onlyByGovernor {

0 commit comments

Comments
 (0)