@@ -242,25 +242,25 @@ contract DisputeKitSybilResistant is BaseDisputeKit, IEvidence {
242
242
returns (address drawnAddress )
243
243
{
244
244
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 );
252
245
253
246
Dispute storage dispute = disputes[coreDisputeIDToLocal[_coreDisputeID]];
254
247
Round storage round = dispute.rounds[dispute.rounds.length - 1 ];
255
248
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
+
256
256
// TODO: Handle the situation when no one has staked yet.
257
257
258
258
// While it still has children
259
- while ((K * treeIndex) + 1 < nodesLength ) {
259
+ while ((K * treeIndex) + 1 < nodes. length ) {
260
260
for (uint256 i = 1 ; i <= K; i++ ) {
261
261
// Loop over children.
262
262
uint256 nodeIndex = (K * treeIndex) + i;
263
- uint256 nodeValue = core. getSortitionSumTreeNode (key, nodeIndex) ;
263
+ uint256 nodeValue = nodes[ nodeIndex] ;
264
264
265
265
if (currentDrawnNumber >= nodeValue) {
266
266
// Go to the next child.
0 commit comments