Skip to content

Commit 6bc2c26

Browse files
authored
disputes: style update (#167)
1 parent 0653567 commit 6bc2c26

File tree

2 files changed

+35
-35
lines changed

2 files changed

+35
-35
lines changed

contracts/DisputeManager.sol

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ contract DisputeManager is Governed {
2222
bytes32 subgraphID;
2323
address indexNode;
2424
address fisherman;
25-
uint256 depositAmount;
25+
uint256 deposit;
2626
}
2727

2828
// -- Attestation --
@@ -107,23 +107,23 @@ contract DisputeManager is Governed {
107107
bytes32 indexed subgraphID,
108108
address indexed indexNode,
109109
address indexed fisherman,
110-
uint256 amount
110+
uint256 deposit
111111
);
112112

113113
event DisputeRejected(
114114
bytes32 disputeID,
115115
bytes32 indexed subgraphID,
116116
address indexed indexNode,
117117
address indexed fisherman,
118-
uint256 amount
118+
uint256 deposit
119119
);
120120

121121
event DisputeIgnored(
122122
bytes32 disputeID,
123123
bytes32 indexed subgraphID,
124124
address indexed indexNode,
125125
address indexed fisherman,
126-
uint256 amount
126+
uint256 deposit
127127
);
128128

129129
modifier onlyArbitrator {
@@ -269,26 +269,26 @@ contract DisputeManager is Governed {
269269
);
270270

271271
// Decode subgraphID
272-
bytes32 _subgraphID = _data.slice(0, 32).toBytes32(0);
272+
bytes32 subgraphID = _data.slice(0, 32).toBytes32(0);
273273

274274
// Decode attestation
275-
bytes memory _attestation = _data.slice(32, ATTESTATION_SIZE_BYTES);
275+
bytes memory attestation = _data.slice(32, ATTESTATION_SIZE_BYTES);
276276
require(
277-
_attestation.length == ATTESTATION_SIZE_BYTES,
277+
attestation.length == ATTESTATION_SIZE_BYTES,
278278
"Signature must be 192 bytes long"
279279
);
280280

281281
// Decode attestation signature
282-
bytes memory _sig = _data.slice(
282+
bytes memory sig = _data.slice(
283283
32 + ATTESTATION_SIZE_BYTES,
284284
SIGNATURE_SIZE_BYTES
285285
);
286286
require(
287-
_sig.length == SIGNATURE_SIZE_BYTES,
287+
sig.length == SIGNATURE_SIZE_BYTES,
288288
"Signature must be 65 bytes long"
289289
);
290290

291-
createDispute(_attestation, _sig, _subgraphID, _from, _value);
291+
createDispute(attestation, sig, subgraphID, _from, _value);
292292

293293
return true;
294294
}
@@ -308,22 +308,22 @@ contract DisputeManager is Governed {
308308

309309
// Have staking slash the index node and reward the fisherman
310310
// Give the fisherman a reward equal to the slashingPercent of the indexer's stake
311-
uint256 _stake = staking.getIndexingNodeStake(
311+
uint256 stake = staking.getIndexingNodeStake(
312312
dispute.subgraphID,
313313
dispute.indexNode
314314
);
315-
uint256 _reward = getRewardForStake(_stake);
316-
assert(_reward <= _stake); // sanity check on fixed-point math
315+
uint256 reward = getRewardForStake(stake);
316+
assert(reward <= stake); // sanity check on fixed-point math
317317
staking.slash(
318318
dispute.subgraphID,
319319
dispute.indexNode,
320-
_reward,
320+
reward,
321321
dispute.fisherman
322322
);
323323

324324
// Give the fisherman their deposit back
325325
require(
326-
token.transfer(dispute.fisherman, dispute.depositAmount),
326+
token.transfer(dispute.fisherman, dispute.deposit),
327327
"Error sending dispute deposit"
328328
);
329329

@@ -333,7 +333,7 @@ contract DisputeManager is Governed {
333333
dispute.subgraphID,
334334
dispute.indexNode,
335335
dispute.fisherman,
336-
_reward
336+
reward
337337
);
338338
}
339339

@@ -351,14 +351,14 @@ contract DisputeManager is Governed {
351351
delete disputes[_disputeID]; // Re-entrancy protection
352352

353353
// Burn the fisherman's deposit
354-
token.burn(dispute.depositAmount);
354+
token.burn(dispute.deposit);
355355

356356
emit DisputeRejected(
357357
_disputeID,
358358
dispute.subgraphID,
359359
dispute.indexNode,
360360
dispute.fisherman,
361-
dispute.depositAmount
361+
dispute.deposit
362362
);
363363
}
364364

@@ -377,7 +377,7 @@ contract DisputeManager is Governed {
377377

378378
// Return deposit to the fisherman
379379
require(
380-
token.transfer(dispute.fisherman, dispute.depositAmount),
380+
token.transfer(dispute.fisherman, dispute.deposit),
381381
"Error sending dispute deposit"
382382
);
383383

@@ -386,7 +386,7 @@ contract DisputeManager is Governed {
386386
dispute.subgraphID,
387387
dispute.indexNode,
388388
dispute.fisherman,
389-
dispute.depositAmount
389+
dispute.deposit
390390
);
391391
}
392392

@@ -397,53 +397,53 @@ contract DisputeManager is Governed {
397397
* @param _subgraphID <bytes32> - subgraphID that Attestation message
398398
* contains (in request raw object at CID)
399399
* @param _fisherman <address> - Creator of dispute
400-
* @param _amount <uint256> - Amount of tokens staked
400+
* @param _deposit <uint256> - Amount of tokens staked as deposit
401401
*/
402402
function createDispute(
403403
bytes memory _attestation,
404404
bytes memory _sig,
405405
bytes32 _subgraphID,
406406
address _fisherman,
407-
uint256 _amount
407+
uint256 _deposit
408408
) private {
409409
// Obtain the hash of the fully-encoded message, per EIP-712 encoding
410-
bytes32 _disputeID = getDisputeID(_attestation);
410+
bytes32 disputeID = getDisputeID(_attestation);
411411

412412
// Obtain the signer of the fully-encoded EIP-712 message hash
413413
// Note: The signer of the attestation is the indexNode that served it
414-
address _indexNode = _disputeID.recover(_sig);
414+
address indexNode = disputeID.recover(_sig);
415415

416416
// Get staked amount on the served subgraph by indexer
417-
uint256 _stake = staking.getIndexingNodeStake(_subgraphID, _indexNode);
417+
uint256 stake = staking.getIndexingNodeStake(_subgraphID, indexNode);
418418

419419
// This also validates that indexer node exists
420420
require(
421-
_stake > 0,
421+
stake > 0,
422422
"Dispute has no stake on the subgraph by the indexer node"
423423
);
424424

425425
// Ensure that fisherman has posted at least that amount
426426
require(
427-
_amount >= getRewardForStake(_stake),
427+
_deposit >= getRewardForStake(stake),
428428
"Dispute deposit under minimum required"
429429
);
430430

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

434434
// Store dispute
435-
disputes[_disputeID] = Dispute(
435+
disputes[disputeID] = Dispute(
436436
_subgraphID,
437-
_indexNode,
437+
indexNode,
438438
_fisherman,
439-
_amount
439+
_deposit
440440
);
441441

442442
// Log event that new dispute was created against IndexNode
443443
emit DisputeCreated(
444-
_disputeID,
444+
disputeID,
445445
_subgraphID,
446-
_indexNode,
446+
indexNode,
447447
_fisherman,
448448
_attestation
449449
);

test/disputes.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ contract(
452452
subgraphID: this.subgraphId,
453453
indexNode: indexNode,
454454
fisherman: fisherman,
455-
amount: this.tokensForFisherman,
455+
deposit: this.tokensForFisherman,
456456
},
457457
)
458458
})
@@ -507,7 +507,7 @@ contract(
507507
subgraphID: this.subgraphId,
508508
indexNode: indexNode,
509509
fisherman: fisherman,
510-
amount: this.tokensForFisherman,
510+
deposit: this.tokensForFisherman,
511511
},
512512
)
513513
})

0 commit comments

Comments
 (0)