@@ -479,12 +479,10 @@ contract DisputeManager is DisputeManagerV1Storage, GraphUpgradeable, IDisputeMa
479
479
_fisherman,
480
480
_deposit,
481
481
0 , // no related dispute,
482
- DisputeType.QueryDispute
482
+ DisputeType.QueryDispute,
483
+ IDisputeManager.DisputeStatus.Pending
483
484
);
484
485
485
- // store the dispute status
486
- disputeStatus[disputeID] = IDisputeManager.DisputeStatus.Pending;
487
-
488
486
emit QueryDisputeCreated (
489
487
disputeID,
490
488
indexer,
@@ -549,17 +547,24 @@ contract DisputeManager is DisputeManagerV1Storage, GraphUpgradeable, IDisputeMa
549
547
_fisherman,
550
548
_deposit,
551
549
0 ,
552
- DisputeType.IndexingDispute
550
+ DisputeType.IndexingDispute,
551
+ IDisputeManager.DisputeStatus.Pending
553
552
);
554
553
555
- // store dispute status
556
- disputeStatus[disputeID] = IDisputeManager.DisputeStatus.Pending;
557
-
558
554
emit IndexingDisputeCreated (disputeID, alloc.indexer, _fisherman, _deposit, _allocationID);
559
555
560
556
return disputeID;
561
557
}
562
558
559
+ modifier onlyPendingDispute (bytes32 _disputeID ) {
560
+ require (isDisputeCreated (_disputeID), "Dispute does not exist " );
561
+ require (
562
+ disputes[_disputeID].status == IDisputeManager.DisputeStatus.Pending,
563
+ "Dispute must be pending "
564
+ );
565
+ _;
566
+ }
567
+
563
568
/**
564
569
* @dev The arbitrator accepts a dispute as being valid.
565
570
* This function will revert if the indexer is not slashable, whether because it does not have
@@ -568,11 +573,16 @@ contract DisputeManager is DisputeManagerV1Storage, GraphUpgradeable, IDisputeMa
568
573
* @notice Accept a dispute with ID `_disputeID`
569
574
* @param _disputeID ID of the dispute to be accepted
570
575
*/
571
- function acceptDispute (bytes32 _disputeID ) external override onlyArbitrator {
572
- Dispute memory dispute = _resolveDispute (_disputeID);
576
+ function acceptDispute (bytes32 _disputeID )
577
+ external
578
+ override
579
+ onlyArbitrator
580
+ onlyPendingDispute (_disputeID)
581
+ {
582
+ Dispute storage dispute = disputes[_disputeID];
573
583
574
- // store dispute status
575
- disputeStatus[_disputeID] = IDisputeManager.DisputeStatus.Accepted;
584
+ // store the dispute status
585
+ dispute.status = IDisputeManager.DisputeStatus.Accepted;
576
586
577
587
// Slash
578
588
(, uint256 tokensToReward ) = _slashIndexer (
@@ -584,8 +594,9 @@ contract DisputeManager is DisputeManagerV1Storage, GraphUpgradeable, IDisputeMa
584
594
// Give the fisherman their deposit back
585
595
TokenUtils.pushTokens (graphToken (), dispute.fisherman, dispute.deposit);
586
596
587
- // Resolve the conflicting dispute if any
588
- _resolveDisputeInConflict (dispute);
597
+ if (_isDisputeInConflict (dispute)) {
598
+ rejectDispute (dispute.relatedDisputeID);
599
+ }
589
600
590
601
emit DisputeAccepted (
591
602
_disputeID,
@@ -600,11 +611,16 @@ contract DisputeManager is DisputeManagerV1Storage, GraphUpgradeable, IDisputeMa
600
611
* @notice Reject a dispute with ID `_disputeID`
601
612
* @param _disputeID ID of the dispute to be rejected
602
613
*/
603
- function rejectDispute (bytes32 _disputeID ) external override onlyArbitrator {
604
- Dispute memory dispute = _resolveDispute (_disputeID);
614
+ function rejectDispute (bytes32 _disputeID )
615
+ public
616
+ override
617
+ onlyArbitrator
618
+ onlyPendingDispute (_disputeID)
619
+ {
620
+ Dispute storage dispute = disputes[_disputeID];
605
621
606
622
// store dispute status
607
- disputeStatus[_disputeID] = IDisputeManager.DisputeStatus.Rejected;
623
+ dispute.status = IDisputeManager.DisputeStatus.Rejected;
608
624
609
625
// Handle conflicting dispute if any
610
626
require (
@@ -623,17 +639,24 @@ contract DisputeManager is DisputeManagerV1Storage, GraphUpgradeable, IDisputeMa
623
639
* @notice Ignore a dispute with ID `_disputeID`
624
640
* @param _disputeID ID of the dispute to be disregarded
625
641
*/
626
- function drawDispute (bytes32 _disputeID ) external override onlyArbitrator {
627
- Dispute memory dispute = _resolveDispute (_disputeID);
642
+ function drawDispute (bytes32 _disputeID )
643
+ public
644
+ override
645
+ onlyArbitrator
646
+ onlyPendingDispute (_disputeID)
647
+ {
648
+ Dispute storage dispute = disputes[_disputeID];
628
649
629
650
// store dispute status
630
- disputeStatus[_disputeID] = IDisputeManager.DisputeStatus.Drawn;
651
+ dispute.status = IDisputeManager.DisputeStatus.Drawn;
631
652
632
653
// Return deposit to the fisherman
633
654
TokenUtils.pushTokens (graphToken (), dispute.fisherman, dispute.deposit);
634
655
635
656
// Resolve the conflicting dispute if any
636
- _resolveDisputeInConflict (dispute);
657
+ if (_isDisputeInConflict (dispute)) {
658
+ drawDispute (dispute.relatedDisputeID);
659
+ }
637
660
638
661
emit DisputeDrawn (_disputeID, dispute.indexer, dispute.fisherman, dispute.deposit);
639
662
}
@@ -643,39 +666,42 @@ contract DisputeManager is DisputeManagerV1Storage, GraphUpgradeable, IDisputeMa
643
666
* @param _disputeID ID of the dispute to resolve
644
667
* @return Dispute
645
668
*/
646
- function _resolveDispute (bytes32 _disputeID ) private returns (Dispute memory ) {
647
- require (isDisputeCreated (_disputeID), "Dispute does not exist " );
669
+ // function _resolveDispute(bytes32 _disputeID) private returns (Dispute memory) {
670
+ // require(isDisputeCreated(_disputeID), "Dispute does not exist");
648
671
649
- Dispute memory dispute = disputes[_disputeID];
672
+ // Dispute memory dispute = disputes[_disputeID];
650
673
651
- // Resolve dispute
652
- delete disputes[_disputeID]; // Re-entrancy
674
+ // // Resolve dispute
675
+ // delete disputes[_disputeID]; // Re-entrancy
653
676
654
- return dispute;
655
- }
677
+ // return dispute;
678
+ // }
656
679
657
680
/**
658
681
* @dev Returns whether the dispute is for a conflicting attestation or not.
659
682
* @param _dispute Dispute
660
683
* @return True conflicting attestation dispute
661
684
*/
662
- function _isDisputeInConflict (Dispute memory _dispute ) private pure returns (bool ) {
663
- return _dispute.relatedDisputeID != 0 ;
685
+ function _isDisputeInConflict (Dispute memory _dispute ) private view returns (bool ) {
686
+ bytes32 relatedID = _dispute.relatedDisputeID;
687
+ return
688
+ relatedID != 0 && disputes[relatedID].status == IDisputeManager.DisputeStatus.Pending;
664
689
}
665
690
666
691
/**
667
692
* @dev Resolve the conflicting dispute if there is any for the one passed to this function.
668
693
* @param _dispute Dispute
669
694
* @return True if resolved
670
695
*/
671
- function _resolveDisputeInConflict (Dispute memory _dispute ) private returns (bool ) {
672
- if (_isDisputeInConflict (_dispute)) {
673
- bytes32 relatedDisputeID = _dispute.relatedDisputeID;
674
- delete disputes[relatedDisputeID];
675
- return true ;
676
- }
677
- return false ;
678
- }
696
+ // function _resolveDisputeInConflict(Dispute memory _dispute) private returns (bool) {
697
+ // if (_isDisputeInConflict(_dispute)) {
698
+ // bytes32 relatedDisputeID = _dispute.relatedDisputeID;
699
+ // Dispute storage relatedDispute = disputes[relatedDisputeID];
700
+ // delete disputes[relatedDisputeID];
701
+ // return true;
702
+ // }
703
+ // return false;
704
+ // }
679
705
680
706
/**
681
707
* @dev Pull deposit from submitter account.
0 commit comments