@@ -7,7 +7,7 @@ import {ISortitionModule} from "./interfaces/ISortitionModule.sol";
77import {IDisputeKit} from "./interfaces/IDisputeKit.sol " ;
88import {Initializable} from "../proxy/Initializable.sol " ;
99import {UUPSProxiable} from "../proxy/UUPSProxiable.sol " ;
10- import {RNG } from "../rng/RNG .sol " ;
10+ import {IRNG } from "../rng/IRNG .sol " ;
1111import "../libraries/Constants.sol " ;
1212
1313/// @title SortitionModuleBase
@@ -50,11 +50,9 @@ abstract contract SortitionModuleBase is ISortitionModule, Initializable, UUPSPr
5050 uint256 public minStakingTime; // The time after which the phase can be switched to Drawing if there are open disputes.
5151 uint256 public maxDrawingTime; // The time after which the phase can be switched back to Staking.
5252 uint256 public lastPhaseChange; // The last time the phase was changed.
53- uint256 public randomNumberRequestBlock; // Number of the block when RNG request was made.
5453 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.
5655 uint256 public randomNumber; // Random number returned by RNG.
57- uint256 public rngLookahead; // Minimal block distance between requesting and obtaining a random number.
5856 uint256 public delayedStakeWriteIndex; // The index of the last `delayedStake` item that was written to the array. 0 index is skipped.
5957 uint256 public delayedStakeReadIndex; // The index of the next `delayedStake` item that should be processed. Starts at 1 because 0 index is skipped.
6058 mapping (bytes32 treeHash = > SortitionSumTree) sortitionSumTrees; // The mapping trees by keys.
@@ -104,16 +102,14 @@ abstract contract SortitionModuleBase is ISortitionModule, Initializable, UUPSPr
104102 KlerosCore _core ,
105103 uint256 _minStakingTime ,
106104 uint256 _maxDrawingTime ,
107- RNG _rng ,
108- uint256 _rngLookahead
105+ IRNG _rng
109106 ) internal onlyInitializing {
110107 governor = _governor;
111108 core = _core;
112109 minStakingTime = _minStakingTime;
113110 maxDrawingTime = _maxDrawingTime;
114111 lastPhaseChange = block .timestamp ;
115112 rng = _rng;
116- rngLookahead = _rngLookahead;
117113 delayedStakeReadIndex = 1 ;
118114 }
119115
@@ -153,15 +149,12 @@ abstract contract SortitionModuleBase is ISortitionModule, Initializable, UUPSPr
153149 maxDrawingTime = _maxDrawingTime;
154150 }
155151
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 {
160155 rng = _rng;
161- rngLookahead = _rngLookahead;
162156 if (phase == Phase.generating) {
163- rng.requestRandomness (block .number + rngLookahead);
164- randomNumberRequestBlock = block .number ;
157+ rng.requestRandomness ();
165158 }
166159 }
167160
@@ -176,11 +169,10 @@ abstract contract SortitionModuleBase is ISortitionModule, Initializable, UUPSPr
176169 "The minimum staking time has not passed yet. "
177170 );
178171 require (disputesWithoutJurors > 0 , "There are no disputes that need jurors. " );
179- rng.requestRandomness (block .number + rngLookahead);
180- randomNumberRequestBlock = block .number ;
172+ rng.requestRandomness ();
181173 phase = Phase.generating;
182174 } else if (phase == Phase.generating) {
183- randomNumber = rng.receiveRandomness (randomNumberRequestBlock + rngLookahead );
175+ randomNumber = rng.receiveRandomness ();
184176 require (randomNumber != 0 , "Random number is not ready yet " );
185177 phase = Phase.drawing;
186178 } else if (phase == Phase.drawing) {
0 commit comments