@@ -242,25 +242,25 @@ contract DisputeKitSybilResistant is BaseDisputeKit, IEvidence {
242242 returns (address drawnAddress )
243243 {
244244 require (phase == Phase.drawing, "Should be in drawing phase " );
245- bytes32 key = bytes32 (core.getSubcourtID (_coreDisputeID)); // Get the ID of the tree.
246- uint256 drawnNumber = getRandomNumber ();
247-
248- uint256 K = core.getSortitionSumTreeK (key);
249- uint256 nodesLength = core.getSortitionSumTreeNodesLength (key);
250- uint256 treeIndex = 0 ;
251- uint256 currentDrawnNumber = drawnNumber % core.getSortitionSumTreeNode (key, 0 );
252245
253246 Dispute storage dispute = disputes[coreDisputeIDToLocal[_coreDisputeID]];
254247 Round storage round = dispute.rounds[dispute.rounds.length - 1 ];
255248
249+ bytes32 key = bytes32 (core.getSubcourtID (_coreDisputeID)); // Get the ID of the tree.
250+ uint256 drawnNumber = uint256 (keccak256 (abi.encode (getRandomNumber (), _coreDisputeID, round.votes.length )));
251+
252+ (uint256 K , , uint256 [] memory nodes ) = core.getSortitionSumTree (key);
253+ uint256 treeIndex = 0 ;
254+ uint256 currentDrawnNumber = drawnNumber % nodes[0 ];
255+
256256 // TODO: Handle the situation when no one has staked yet.
257257
258258 // While it still has children
259- while ((K * treeIndex) + 1 < nodesLength ) {
259+ while ((K * treeIndex) + 1 < nodes. length ) {
260260 for (uint256 i = 1 ; i <= K; i++ ) {
261261 // Loop over children.
262262 uint256 nodeIndex = (K * treeIndex) + i;
263- uint256 nodeValue = core. getSortitionSumTreeNode (key, nodeIndex) ;
263+ uint256 nodeValue = nodes[ nodeIndex] ;
264264
265265 if (currentDrawnNumber >= nodeValue) {
266266 // Go to the next child.
0 commit comments