@@ -5,7 +5,6 @@ import "./Governed.sol";
5
5
import "./GraphToken.sol " ;
6
6
import "./Staking.sol " ;
7
7
8
-
9
8
/*
10
9
* @title DisputeManager
11
10
* @dev Provides a way to align the incentives of participants ensuring that query results are trustful.
@@ -23,6 +22,13 @@ contract DisputeManager is Governed {
23
22
24
23
// -- Attestation --
25
24
25
+ // Receipt content sent from indexer in response to request
26
+ struct Receipt {
27
+ bytes32 requestCID;
28
+ bytes32 responseCID;
29
+ bytes32 subgraphID;
30
+ }
31
+
26
32
// Attestation sent from indexer in response to a request
27
33
struct Attestation {
28
34
bytes32 requestCID;
@@ -215,14 +221,19 @@ contract DisputeManager is Governed {
215
221
* @param _receipt Receipt returned by indexer and submitted by fisherman
216
222
* @return Message hash used to sign the receipt
217
223
*/
218
- function encodeHashReceipt (bytes memory _receipt ) public view returns (bytes32 ) {
224
+ function encodeHashReceipt (Receipt memory _receipt ) public view returns (bytes32 ) {
219
225
return
220
226
keccak256 (
221
227
abi.encodePacked (
222
228
"\x19\x01 " , // EIP-191 encoding pad, EIP-712 version 1
223
229
DOMAIN_SEPARATOR,
224
230
keccak256 (
225
- abi.encode (RECEIPT_TYPE_HASH, _receipt) // EIP 712-encoded message hash
231
+ abi.encode (
232
+ RECEIPT_TYPE_HASH,
233
+ _receipt.requestCID,
234
+ _receipt.responseCID,
235
+ _receipt.subgraphID
236
+ ) // EIP 712-encoded message hash
226
237
)
227
238
)
228
239
);
@@ -292,11 +303,15 @@ contract DisputeManager is Governed {
292
303
{
293
304
address fisherman = msg .sender ;
294
305
306
+ // Ensure that fisherman has staked at least the minimum amount
307
+ require (_deposit >= minimumDeposit, "Dispute deposit is under minimum required " );
308
+
295
309
// Transfer tokens to deposit from fisherman to this contract
296
310
require (
297
311
token.transferFrom (fisherman, address (this ), _deposit),
298
312
"Cannot transfer tokens to deposit "
299
313
);
314
+
300
315
// Create a dispute using the received attestation and deposit
301
316
_createDispute (fisherman, _deposit, _attestationData);
302
317
}
@@ -424,9 +439,6 @@ contract DisputeManager is Governed {
424
439
// This also validates that indexer exists
425
440
require (staking.hasStake (indexer), "Dispute has no stake by the indexer " );
426
441
427
- // Ensure that fisherman has staked at least the minimum amount
428
- require (_deposit >= minimumDeposit, "Dispute deposit is under minimum required " );
429
-
430
442
// A fisherman can only open one dispute for a given indexer / subgraphID at a time
431
443
require (! isDisputeCreated (disputeID), "Dispute already created " ); // Must be empty
432
444
@@ -450,7 +462,7 @@ contract DisputeManager is Governed {
450
462
*/
451
463
function _recoverAttestationSigner (Attestation memory _attestation ) private view returns (address ) {
452
464
// Obtain the hash of the fully-encoded message, per EIP-712 encoding
453
- bytes memory receipt = abi.encode (
465
+ Receipt memory receipt = Receipt (
454
466
_attestation.requestCID,
455
467
_attestation.responseCID,
456
468
_attestation.subgraphID
0 commit comments