Skip to content

Commit 2a8b626

Browse files
authored
disputes: rename event names and indexer language (#192)
* disputes: rename event names and replace language for indexer * disputes: update rewardPercentage to fishermanRewardPercetange
1 parent f8a3669 commit 2a8b626

File tree

6 files changed

+104
-105
lines changed

6 files changed

+104
-105
lines changed

contracts/DisputeManager.sol

Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ contract DisputeManager is Governed {
1616
// Disputes contain info neccessary for the Arbitrator to verify and resolve
1717
struct Dispute {
1818
bytes32 subgraphID;
19-
address indexNode;
19+
address indexer;
2020
address fisherman;
2121
uint256 deposit;
2222
}
2323

2424
// -- Attestation --
2525

26-
// Attestation sent from IndexNode in response to a request
26+
// Attestation sent from indexer in response to a request
2727
struct Attestation {
2828
bytes32 requestCID;
2929
bytes32 responseCID;
@@ -68,11 +68,11 @@ contract DisputeManager is Governed {
6868
// Minimum deposit required to create a Dispute
6969
uint256 public minimumDeposit;
7070

71-
// Percentage of index node slashed funds to assign as a reward to fisherman in successful dispute
71+
// Percentage of indexer slashed funds to assign as a reward to fisherman in successful dispute
7272
// Parts per million. (Allows for 4 decimal points, 999,999 = 99.9999%)
73-
uint256 public rewardPercentage;
73+
uint256 public fishermanRewardPercentage;
7474

75-
// Percentage of index node stake to slash on disputes
75+
// Percentage of indexer stake to slash on disputes
7676
// Parts per million. (Allows for 4 decimal points, 999,999 = 99.9999%)
7777
uint256 public slashingPercentage;
7878

@@ -85,53 +85,53 @@ contract DisputeManager is Governed {
8585
// -- Events --
8686

8787
/**
88-
* @dev Emitted when `disputeID` is created for `subgraphID` and `indexNode` by `fisherman`.
88+
* @dev Emitted when `disputeID` is created for `subgraphID` and `indexer` by `fisherman`.
8989
* The event emits the amount `tokens` deposited by the fisherman and `attestation` submitted.
9090
*/
9191
event DisputeCreated(
9292
bytes32 disputeID,
9393
bytes32 indexed subgraphID,
94-
address indexed indexNode,
94+
address indexed indexer,
9595
address indexed fisherman,
9696
uint256 tokens,
9797
bytes attestation
9898
);
9999

100100
/**
101-
* @dev Emitted when arbitrator accepts a `disputeID` for `subgraphID` and `indexNode`
101+
* @dev Emitted when arbitrator accepts a `disputeID` for `subgraphID` and `indexer`
102102
* created by `fisherman`.
103103
* The event emits the amount `tokens` transferred to the fisherman, the deposit plus reward.
104104
*/
105105
event DisputeAccepted(
106106
bytes32 disputeID,
107107
bytes32 indexed subgraphID,
108-
address indexed indexNode,
108+
address indexed indexer,
109109
address indexed fisherman,
110110
uint256 tokens
111111
);
112112

113113
/**
114-
* @dev Emitted when arbitrator rejects a `disputeID` for `subgraphID` and `indexNode`
114+
* @dev Emitted when arbitrator rejects a `disputeID` for `subgraphID` and `indexer`
115115
* created by `fisherman`.
116116
* The event emits the amount `tokens` burned from the fisherman deposit.
117117
*/
118118
event DisputeRejected(
119119
bytes32 disputeID,
120120
bytes32 indexed subgraphID,
121-
address indexed indexNode,
121+
address indexed indexer,
122122
address indexed fisherman,
123123
uint256 tokens
124124
);
125125

126126
/**
127-
* @dev Emitted when arbitrator draw a `disputeID` for `subgraphID` and `indexNode`
127+
* @dev Emitted when arbitrator draw a `disputeID` for `subgraphID` and `indexer`
128128
* created by `fisherman`.
129129
* The event emits the amount `tokens` used as deposit and returned to the fisherman.
130130
*/
131-
event DisputeIgnored(
131+
event DisputeDrawn(
132132
bytes32 disputeID,
133133
bytes32 indexed subgraphID,
134-
address indexed indexNode,
134+
address indexed indexer,
135135
address indexed fisherman,
136136
uint256 tokens
137137
);
@@ -148,23 +148,23 @@ contract DisputeManager is Governed {
148148
* @param _arbitrator Arbitrator role
149149
* @param _staking Address of the staking contract used for slashing
150150
* @param _minimumDeposit Minimum deposit required to create a Dispute
151-
* @param _rewardPercentage Percent of slashed funds the fisherman gets (in PPM)
152-
* @param _slashingPercentage Percentage of index node stake slashed after a dispute
151+
* @param _fishermanRewardPercentage Percent of slashed funds the fisherman gets (in PPM)
152+
* @param _slashingPercentage Percentage of indexer stake slashed after a dispute
153153
*/
154154
constructor(
155155
address _governor,
156156
address _arbitrator,
157157
address _token,
158158
address _staking,
159159
uint256 _minimumDeposit,
160-
uint256 _rewardPercentage,
160+
uint256 _fishermanRewardPercentage,
161161
uint256 _slashingPercentage
162162
) public Governed(_governor) {
163163
arbitrator = _arbitrator;
164164
token = GraphToken(_token);
165165
staking = Staking(_staking);
166166
minimumDeposit = _minimumDeposit;
167-
rewardPercentage = _rewardPercentage;
167+
fishermanRewardPercentage = _fishermanRewardPercentage;
168168
slashingPercentage = _slashingPercentage;
169169

170170
// EIP-712 domain separator
@@ -190,24 +190,24 @@ contract DisputeManager is Governed {
190190
}
191191

192192
/**
193-
* @dev Get the fisherman reward for a given index node stake
194-
* @notice Return the fisherman reward based on the `_indexNode` stake
195-
* @param _indexNode IndexNode to be slashed
196-
* @return Reward calculated as percentage of the index node slashed funds
193+
* @dev Get the fisherman reward for a given indexer stake
194+
* @notice Return the fisherman reward based on the `_indexer` stake
195+
* @param _indexer Indexer to be slashed
196+
* @return Reward calculated as percentage of the indexer slashed funds
197197
*/
198-
function getTokensToReward(address _indexNode) public view returns (uint256) {
199-
uint256 value = getTokensToSlash(_indexNode);
200-
return rewardPercentage.mul(value).div(MAX_PPM); // rewardPercentage is in PPM
198+
function getTokensToReward(address _indexer) public view returns (uint256) {
199+
uint256 value = getTokensToSlash(_indexer);
200+
return fishermanRewardPercentage.mul(value).div(MAX_PPM);
201201
}
202202

203203
/**
204-
* @dev Get the amount of tokens to slash for an index node based on the stake
205-
* @param _indexNode Address of the index node
204+
* @dev Get the amount of tokens to slash for an indexer based on the stake
205+
* @param _indexer Address of the indexer
206206
* @return Amount of tokens to slash
207207
*/
208-
function getTokensToSlash(address _indexNode) public view returns (uint256) {
209-
uint256 tokens = staking.getIndexNodeStakeTokens(_indexNode); // slashable tokens
210-
return slashingPercentage.mul(tokens).div(MAX_PPM); // slashingPercentage is in PPM
208+
function getTokensToSlash(address _indexer) public view returns (uint256) {
209+
uint256 tokens = staking.getIndexNodeStakeTokens(_indexer); // slashable tokens
210+
return slashingPercentage.mul(tokens).div(MAX_PPM);
211211
}
212212

213213
/**
@@ -252,16 +252,16 @@ contract DisputeManager is Governed {
252252
/**
253253
* @dev Set the percent reward that the fisherman gets when slashing occurs
254254
* @notice Update the reward percentage to `_percentage`
255-
* @param _percentage Reward as a percentage of index node stake
255+
* @param _percentage Reward as a percentage of indexer stake
256256
*/
257-
function setRewardPercentage(uint256 _percentage) external onlyGovernor {
257+
function setFishermanRewardPercentage(uint256 _percentage) external onlyGovernor {
258258
// Must be within 0% to 100% (inclusive)
259259
require(_percentage <= MAX_PPM, "Reward percentage must be below or equal to MAX_PPM");
260-
rewardPercentage = _percentage;
260+
fishermanRewardPercentage = _percentage;
261261
}
262262

263263
/**
264-
* @dev Set the percentage used for slashing index nodes
264+
* @dev Set the percentage used for slashing indexers
265265
* @param _percentage Percentage used for slashing
266266
*/
267267
function setSlashingPercentage(uint256 _percentage) external onlyGovernor {
@@ -312,11 +312,11 @@ contract DisputeManager is Governed {
312312
// Resolve dispute
313313
delete disputes[_disputeID]; // Re-entrancy protection
314314

315-
// Have staking contract slash the index node and reward the fisherman
316-
// Give the fisherman a reward equal to the rewardPercentage of the index node slashed amount
317-
uint256 tokensToReward = getTokensToReward(dispute.indexNode);
318-
uint256 tokensToSlash = getTokensToSlash(dispute.indexNode);
319-
staking.slash(dispute.indexNode, tokensToSlash, tokensToReward, dispute.fisherman);
315+
// Have staking contract slash the indexer and reward the fisherman
316+
// Give the fisherman a reward equal to the fishermanRewardPercentage of slashed amount
317+
uint256 tokensToReward = getTokensToReward(dispute.indexer);
318+
uint256 tokensToSlash = getTokensToSlash(dispute.indexer);
319+
staking.slash(dispute.indexer, tokensToSlash, tokensToReward, dispute.fisherman);
320320

321321
// Give the fisherman their deposit back
322322
require(
@@ -327,7 +327,7 @@ contract DisputeManager is Governed {
327327
emit DisputeAccepted(
328328
_disputeID,
329329
dispute.subgraphID,
330-
dispute.indexNode,
330+
dispute.indexer,
331331
dispute.fisherman,
332332
dispute.deposit.add(tokensToReward)
333333
);
@@ -352,18 +352,18 @@ contract DisputeManager is Governed {
352352
emit DisputeRejected(
353353
_disputeID,
354354
dispute.subgraphID,
355-
dispute.indexNode,
355+
dispute.indexer,
356356
dispute.fisherman,
357357
dispute.deposit
358358
);
359359
}
360360

361361
/**
362-
* @dev The arbitrator can disregard a dispute
362+
* @dev The arbitrator can draw dispute
363363
* @notice Ignore a dispute with ID `_disputeID`
364364
* @param _disputeID ID of the dispute to be disregarded
365365
*/
366-
function ignoreDispute(bytes32 _disputeID) external onlyArbitrator {
366+
function drawDispute(bytes32 _disputeID) external onlyArbitrator {
367367
require(isDisputeCreated(_disputeID), "Dispute does not exist");
368368

369369
Dispute memory dispute = disputes[_disputeID];
@@ -377,10 +377,10 @@ contract DisputeManager is Governed {
377377
"Error sending dispute deposit"
378378
);
379379

380-
emit DisputeIgnored(
380+
emit DisputeDrawn(
381381
_disputeID,
382382
dispute.subgraphID,
383-
dispute.indexNode,
383+
dispute.indexer,
384384
dispute.fisherman,
385385
dispute.deposit
386386
);
@@ -400,34 +400,34 @@ contract DisputeManager is Governed {
400400
Attestation memory attestation = _parseAttestation(_attestationData);
401401

402402
// Get attestation signer
403-
address indexNode = _recoverAttestationSigner(attestation);
403+
address indexer = _recoverAttestationSigner(attestation);
404404

405405
// Create a disputeID
406406
bytes32 disputeID = keccak256(
407407
abi.encodePacked(
408408
attestation.requestCID,
409409
attestation.responseCID,
410410
attestation.subgraphID,
411-
indexNode
411+
indexer
412412
)
413413
);
414414

415-
// This also validates that index node exists
416-
require(staking.hasStake(indexNode), "Dispute has no stake by the index node");
415+
// This also validates that indexer exists
416+
require(staking.hasStake(indexer), "Dispute has no stake by the indexer");
417417

418418
// Ensure that fisherman has staked at least the minimum amount
419419
require(_deposit >= minimumDeposit, "Dispute deposit under minimum required");
420420

421-
// A fisherman can only open one dispute for a given index node / subgraphID at a time
421+
// A fisherman can only open one dispute for a given indexer / subgraphID at a time
422422
require(!isDisputeCreated(disputeID), "Dispute already created"); // Must be empty
423423

424424
// Store dispute
425-
disputes[disputeID] = Dispute(attestation.subgraphID, indexNode, _fisherman, _deposit);
425+
disputes[disputeID] = Dispute(attestation.subgraphID, indexer, _fisherman, _deposit);
426426

427427
emit DisputeCreated(
428428
disputeID,
429429
attestation.subgraphID,
430-
indexNode,
430+
indexer,
431431
_fisherman,
432432
_deposit,
433433
_attestationData

migrations/2_deploy_contracts.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ module.exports = async (deployer, network, accounts) => {
5050
graphToken.address,
5151
staking.address,
5252
config.dispute.minimumDeposit,
53-
config.dispute.rewardPercentage,
53+
config.dispute.fishermanRewardPercentage,
5454
config.dispute.slashingPercentage,
5555
)
5656
const serviceRegistry = await deployer.deploy(ServiceRegistry, governor)

migrations/deploy.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ module.exports = {
1111
},
1212
dispute: {
1313
minimumDeposit: new BN('100').mul(TOKEN_UNIT),
14-
rewardPercentage: 1000, // in basis points
14+
fishermanRewardPercentage: 1000, // in basis points
1515
slashingPercentage: 1000, // in basis points
1616
},
1717
epochs: {

0 commit comments

Comments
 (0)