@@ -81,6 +81,7 @@ contract KlerosCore is IArbitrator {
81
81
// ************************************* //
82
82
83
83
uint256 public constant FORKING_COURT = 0 ; // Index of the default court.
84
+ uint256 public constant NULL_DISPUTE_KIT = 0 ; // Null pattern to indicate a top-level DK which has no parent.
84
85
uint256 public constant DISPUTE_KIT_CLASSIC_INDEX = 1 ; // Index of the default DK. 0 index is skipped.
85
86
uint256 public constant MAX_STAKE_PATHS = 4 ; // The maximum number of stake paths a juror can have.
86
87
uint256 public constant MIN_JURORS = 3 ; // The global default minimum number of jurors in a dispute.
@@ -164,8 +165,8 @@ contract KlerosCore is IArbitrator {
164
165
pinakion = _pinakion;
165
166
jurorProsecutionModule = _jurorProsecutionModule;
166
167
167
- // Create an empty element so 0 index is not used .
168
- disputeKitNodes.push ();
168
+ disputeKitNodes. push (); // NULL_DISPUTE_KIT: an empty element at index 0 to indicate when a node has no parent .
169
+ disputeKitNodes.push (DisputeKitNode ({parent: 0 , disputeKit: _disputeKit}) );
169
170
170
171
// Create the Forking court.
171
172
Court storage court = courts.push ();
@@ -177,10 +178,8 @@ contract KlerosCore is IArbitrator {
177
178
court.feeForJuror = _feeForJuror;
178
179
court.jurorsForCourtJump = _jurorsForCourtJump;
179
180
court.timesPerPeriod = _timesPerPeriod;
180
-
181
- disputeKitNodes.push (DisputeKitNode ({parent: 0 , disputeKit: _disputeKit}));
182
-
183
181
court.supportedDisputeKits[DISPUTE_KIT_CLASSIC_INDEX] = true ;
182
+
184
183
sortitionSumTrees.createTree (bytes32 (0 ), _sortitionSumTreeK);
185
184
}
186
185
@@ -232,7 +231,7 @@ contract KlerosCore is IArbitrator {
232
231
require (_parent < disputeKitNodes.length , "Parent doesn't exist " );
233
232
234
233
// Create new tree, which root should be supported by Forking court.
235
- if (_parent == 0 ) {
234
+ if (_parent == NULL_DISPUTE_KIT ) {
236
235
courts[FORKING_COURT].supportedDisputeKits[disputeKitNodes.length ] = true ;
237
236
}
238
237
disputeKitNodes.push (DisputeKitNode ({parent: _parent, disputeKit: _disputeKitAddress}));
@@ -249,7 +248,7 @@ contract KlerosCore is IArbitrator {
249
248
require (_newParent != _disputeKitID, "Invalid Parent " );
250
249
251
250
// Create new tree, which root should be supported by Forking court.
252
- if (_newParent == 0 ) {
251
+ if (_newParent == NULL_DISPUTE_KIT ) {
253
252
courts[FORKING_COURT].supportedDisputeKits[_disputeKitID] = true ;
254
253
}
255
254
disputeKitNodes[_disputeKitID].parent = _newParent;
@@ -372,7 +371,7 @@ contract KlerosCore is IArbitrator {
372
371
subcourt.supportedDisputeKits[_disputeKitIDs[i]] = true ;
373
372
} else {
374
373
require (
375
- ! (_subcourtID == FORKING_COURT && disputeKitNodes[_disputeKitIDs[i]].parent == 0 ),
374
+ ! (_subcourtID == FORKING_COURT && disputeKitNodes[_disputeKitIDs[i]].parent == NULL_DISPUTE_KIT ),
376
375
"Can't remove root DK support from the forking court "
377
376
);
378
377
subcourt.supportedDisputeKits[_disputeKitIDs[i]] = false ;
@@ -977,9 +976,15 @@ contract KlerosCore is IArbitrator {
977
976
minJurors := mload (add (_extraData, 0x40 ))
978
977
disputeKitID := mload (add (_extraData, 0x60 ))
979
978
}
980
- if (subcourtID >= courts.length ) subcourtID = uint96 (FORKING_COURT);
981
- if (minJurors == 0 ) minJurors = MIN_JURORS;
982
- if (disputeKitID == 0 || disputeKitID >= disputeKitNodes.length ) disputeKitID = DISPUTE_KIT_CLASSIC_INDEX; // 0 index is not used.
979
+ if (subcourtID >= courts.length ) {
980
+ subcourtID = uint96 (FORKING_COURT);
981
+ }
982
+ if (minJurors == 0 ) {
983
+ minJurors = MIN_JURORS;
984
+ }
985
+ if (disputeKitID == NULL_DISPUTE_KIT || disputeKitID >= disputeKitNodes.length ) {
986
+ disputeKitID = DISPUTE_KIT_CLASSIC_INDEX; // 0 index is not used.
987
+ }
983
988
} else {
984
989
subcourtID = uint96 (FORKING_COURT);
985
990
minJurors = MIN_JURORS;
0 commit comments