@@ -7,7 +7,9 @@ import "@openzeppelin/contracts/math/SafeMath.sol";
7
7
import "@openzeppelin/contracts/cryptography/ECDSA.sol " ;
8
8
9
9
import "../governance/Managed.sol " ;
10
+ import "../upgrades/GraphUpgradeable.sol " ;
10
11
12
+ import "./DisputeManagerStorage.sol " ;
11
13
import "./IDisputeManager.sol " ;
12
14
13
15
/*
@@ -33,21 +35,9 @@ import "./IDisputeManager.sol";
33
35
* Disputes can only be accepted, rejected or drawn by the arbitrator role that can be delegated
34
36
* to a EOA or DAO.
35
37
*/
36
- contract DisputeManager is Managed , IDisputeManager {
38
+ contract DisputeManager is DisputeManagerV1Storage , GraphUpgradeable , IDisputeManager {
37
39
using SafeMath for uint256 ;
38
40
39
- uint256 private constant ATTESTATION_SIZE_BYTES = 161 ;
40
- uint256 private constant RECEIPT_SIZE_BYTES = 96 ;
41
-
42
- uint256 private constant SIG_R_LENGTH = 32 ;
43
- uint256 private constant SIG_S_LENGTH = 32 ;
44
- uint256 private constant SIG_R_OFFSET = RECEIPT_SIZE_BYTES;
45
- uint256 private constant SIG_S_OFFSET = RECEIPT_SIZE_BYTES + SIG_R_LENGTH;
46
- uint256 private constant SIG_V_OFFSET = RECEIPT_SIZE_BYTES + SIG_R_LENGTH + SIG_S_LENGTH;
47
-
48
- uint256 private constant UINT8_BYTE_LENGTH = 1 ;
49
- uint256 private constant BYTES32_BYTE_LENGTH = 32 ;
50
-
51
41
// -- EIP-712 --
52
42
53
43
bytes32 private constant DOMAIN_TYPE_HASH = keccak256 (
@@ -63,30 +53,19 @@ contract DisputeManager is Managed, IDisputeManager {
63
53
64
54
// -- Constants --
65
55
66
- // 100% in parts per million
67
- uint256 private constant MAX_PPM = 1000000 ;
68
-
69
- // -- State --
70
-
71
- bytes32 private DOMAIN_SEPARATOR;
72
-
73
- // The arbitrator is solely in control of arbitrating disputes
74
- address public arbitrator;
75
-
76
- // Minimum deposit required to create a Dispute
77
- uint256 public minimumDeposit;
56
+ uint256 private constant ATTESTATION_SIZE_BYTES = 161 ;
57
+ uint256 private constant RECEIPT_SIZE_BYTES = 96 ;
78
58
79
- // Percentage of indexer slashed funds to assign as a reward to fisherman in successful dispute
80
- // Parts per million. (Allows for 4 decimal points, 999,999 = 99.9999%)
81
- uint32 public fishermanRewardPercentage;
59
+ uint256 private constant SIG_R_LENGTH = 32 ;
60
+ uint256 private constant SIG_S_LENGTH = 32 ;
61
+ uint256 private constant SIG_R_OFFSET = RECEIPT_SIZE_BYTES;
62
+ uint256 private constant SIG_S_OFFSET = RECEIPT_SIZE_BYTES + SIG_R_LENGTH;
63
+ uint256 private constant SIG_V_OFFSET = RECEIPT_SIZE_BYTES + SIG_R_LENGTH + SIG_S_LENGTH;
82
64
83
- // Percentage of indexer stake to slash on disputes
84
- // Parts per million. (Allows for 4 decimal points, 999,999 = 99.9999%)
85
- uint32 public slashingPercentage;
65
+ uint256 private constant UINT8_BYTE_LENGTH = 1 ;
66
+ uint256 private constant BYTES32_BYTE_LENGTH = 32 ;
86
67
87
- // Disputes created : disputeID => Dispute
88
- // disputeID - check creation functions to see how disputeID is built
89
- mapping (bytes32 => Dispute) public disputes;
68
+ uint256 private constant MAX_PPM = 1000000 ; // 100% in parts per million
90
69
91
70
// -- Events --
92
71
@@ -166,19 +145,19 @@ contract DisputeManager is Managed, IDisputeManager {
166
145
}
167
146
168
147
/**
169
- * @dev Contract Constructor
148
+ * @dev Initialize this contract.
170
149
* @param _arbitrator Arbitrator role
171
150
* @param _minimumDeposit Minimum deposit required to create a Dispute
172
- * @param _fishermanRewardPercentage Percent of slashed funds for fisherman (basis points )
173
- * @param _slashingPercentage Percentage of indexer stake slashed (basis points )
151
+ * @param _fishermanRewardPercentage Percent of slashed funds for fisherman (ppm )
152
+ * @param _slashingPercentage Percentage of indexer stake slashed (ppm )
174
153
*/
175
- constructor (
154
+ function initialize (
176
155
address _controller ,
177
156
address _arbitrator ,
178
157
uint256 _minimumDeposit ,
179
158
uint32 _fishermanRewardPercentage ,
180
159
uint32 _slashingPercentage
181
- ) {
160
+ ) external onlyImpl {
182
161
Managed._initialize (_controller);
183
162
184
163
// Settings
@@ -575,7 +554,7 @@ contract DisputeManager is Managed, IDisputeManager {
575
554
* @param _disputeID ID of the dispute to be accepted
576
555
*/
577
556
function acceptDispute (bytes32 _disputeID ) external override onlyArbitrator {
578
- Dispute memory dispute = _resolveDispute (_disputeID);
557
+ Dispute memory dispute = _resolveDispute (_disputeID);
579
558
580
559
// Slash
581
560
uint256 tokensToReward = _slashIndexer (dispute.indexer, dispute.fisherman);
@@ -605,7 +584,7 @@ contract DisputeManager is Managed, IDisputeManager {
605
584
* @param _disputeID ID of the dispute to be rejected
606
585
*/
607
586
function rejectDispute (bytes32 _disputeID ) external override onlyArbitrator {
608
- Dispute memory dispute = _resolveDispute (_disputeID);
587
+ Dispute memory dispute = _resolveDispute (_disputeID);
609
588
610
589
// Handle conflicting dispute if any
611
590
require (
@@ -627,7 +606,7 @@ contract DisputeManager is Managed, IDisputeManager {
627
606
* @param _disputeID ID of the dispute to be disregarded
628
607
*/
629
608
function drawDispute (bytes32 _disputeID ) external override onlyArbitrator {
630
- Dispute memory dispute = _resolveDispute (_disputeID);
609
+ Dispute memory dispute = _resolveDispute (_disputeID);
631
610
632
611
// Return deposit to the fisherman
633
612
if (dispute.deposit > 0 ) {
0 commit comments