@@ -7,7 +7,7 @@ import {ISortitionModule} from "./interfaces/ISortitionModule.sol";
7
7
import {IDisputeKit} from "./interfaces/IDisputeKit.sol " ;
8
8
import {Initializable} from "../proxy/Initializable.sol " ;
9
9
import {UUPSProxiable} from "../proxy/UUPSProxiable.sol " ;
10
- import {RNG } from "../rng/RNG .sol " ;
10
+ import {IRNG } from "../rng/IRNG .sol " ;
11
11
import "../libraries/Constants.sol " ;
12
12
13
13
/// @title SortitionModuleBase
@@ -50,11 +50,9 @@ abstract contract SortitionModuleBase is ISortitionModule, Initializable, UUPSPr
50
50
uint256 public minStakingTime; // The time after which the phase can be switched to Drawing if there are open disputes.
51
51
uint256 public maxDrawingTime; // The time after which the phase can be switched back to Staking.
52
52
uint256 public lastPhaseChange; // The last time the phase was changed.
53
- uint256 public randomNumberRequestBlock; // Number of the block when RNG request was made.
54
53
uint256 public disputesWithoutJurors; // The number of disputes that have not finished drawing jurors.
55
- RNG public rng; // The random number generator.
54
+ IRNG public rng; // The random number generator.
56
55
uint256 public randomNumber; // Random number returned by RNG.
57
- uint256 public rngLookahead; // Minimal block distance between requesting and obtaining a random number.
58
56
uint256 public delayedStakeWriteIndex; // The index of the last `delayedStake` item that was written to the array. 0 index is skipped.
59
57
uint256 public delayedStakeReadIndex; // The index of the next `delayedStake` item that should be processed. Starts at 1 because 0 index is skipped.
60
58
mapping (bytes32 treeHash = > SortitionSumTree) sortitionSumTrees; // The mapping trees by keys.
@@ -104,16 +102,14 @@ abstract contract SortitionModuleBase is ISortitionModule, Initializable, UUPSPr
104
102
KlerosCore _core ,
105
103
uint256 _minStakingTime ,
106
104
uint256 _maxDrawingTime ,
107
- RNG _rng ,
108
- uint256 _rngLookahead
105
+ IRNG _rng
109
106
) internal onlyInitializing {
110
107
governor = _governor;
111
108
core = _core;
112
109
minStakingTime = _minStakingTime;
113
110
maxDrawingTime = _maxDrawingTime;
114
111
lastPhaseChange = block .timestamp ;
115
112
rng = _rng;
116
- rngLookahead = _rngLookahead;
117
113
delayedStakeReadIndex = 1 ;
118
114
}
119
115
@@ -153,15 +149,12 @@ abstract contract SortitionModuleBase is ISortitionModule, Initializable, UUPSPr
153
149
maxDrawingTime = _maxDrawingTime;
154
150
}
155
151
156
- /// @dev Changes the `_rng` and `_rngLookahead` storage variables.
157
- /// @param _rng The new value for the `RNGenerator` storage variable.
158
- /// @param _rngLookahead The new value for the `rngLookahead` storage variable.
159
- function changeRandomNumberGenerator (RNG _rng , uint256 _rngLookahead ) external onlyByGovernor {
152
+ /// @dev Changes the `rng` storage variable.
153
+ /// @param _rng The new random number generator.
154
+ function changeRandomNumberGenerator (IRNG _rng ) external onlyByGovernor {
160
155
rng = _rng;
161
- rngLookahead = _rngLookahead;
162
156
if (phase == Phase.generating) {
163
- rng.requestRandomness (block .number + rngLookahead);
164
- randomNumberRequestBlock = block .number ;
157
+ rng.requestRandomness ();
165
158
}
166
159
}
167
160
@@ -176,11 +169,10 @@ abstract contract SortitionModuleBase is ISortitionModule, Initializable, UUPSPr
176
169
"The minimum staking time has not passed yet. "
177
170
);
178
171
require (disputesWithoutJurors > 0 , "There are no disputes that need jurors. " );
179
- rng.requestRandomness (block .number + rngLookahead);
180
- randomNumberRequestBlock = block .number ;
172
+ rng.requestRandomness ();
181
173
phase = Phase.generating;
182
174
} else if (phase == Phase.generating) {
183
- randomNumber = rng.receiveRandomness (randomNumberRequestBlock + rngLookahead );
175
+ randomNumber = rng.receiveRandomness ();
184
176
require (randomNumber != 0 , "Random number is not ready yet " );
185
177
phase = Phase.drawing;
186
178
} else if (phase == Phase.drawing) {
0 commit comments