Skip to content

Commit d310d61

Browse files
authored
refactor: rename Subgraph to SubgraphDeployment (#214)
* refactor: rename everything Subgraph to SubgraphDeployment in contracts * refactor: rename concepts in Curation contract to make it clearer * refactor: dispute use attestation with subgraphDeploymentID
1 parent 59c34f5 commit d310d61

File tree

14 files changed

+428
-455
lines changed

14 files changed

+428
-455
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ dist/
88
# Coverage tests
99
coverage/
1010

11+
# Buidler cache
12+
cached/
13+
14+
# Others
1115
.privkey.txt
1216
.infurakey.txt
1317
.DS_Store

contracts/Curation.sol

Lines changed: 141 additions & 119 deletions
Large diffs are not rendered by default.

contracts/DisputeManager.sol

Lines changed: 34 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ contract DisputeManager is Governed {
1414

1515
// Disputes contain info neccessary for the Arbitrator to verify and resolve
1616
struct Dispute {
17-
bytes32 subgraphID;
17+
bytes32 subgraphDeploymentID;
1818
address indexer;
1919
address fisherman;
2020
uint256 deposit;
@@ -26,14 +26,14 @@ contract DisputeManager is Governed {
2626
struct Receipt {
2727
bytes32 requestCID;
2828
bytes32 responseCID;
29-
bytes32 subgraphID;
29+
bytes32 subgraphDeploymentID;
3030
}
3131

3232
// Attestation sent from indexer in response to a request
3333
struct Attestation {
3434
bytes32 requestCID;
3535
bytes32 responseCID;
36-
bytes32 subgraphID;
36+
bytes32 subgraphDeploymentID;
3737
uint8 v;
3838
bytes32 r;
3939
bytes32 s;
@@ -51,7 +51,7 @@ contract DisputeManager is Governed {
5151
bytes32 private constant DOMAIN_VERSION_HASH = keccak256("0");
5252
bytes32 private constant DOMAIN_SALT = 0xa070ffb1cd7409649bf77822cce74495468e06dbfaef09556838bf188679b9c2;
5353
bytes32 private constant RECEIPT_TYPE_HASH = keccak256(
54-
"Receipt(bytes32 requestCID,bytes32 responseCID,bytes32 subgraphID)"
54+
"Receipt(bytes32 requestCID,bytes32 responseCID,bytes32 subgraphDeploymentID)"
5555
);
5656

5757
// 100% in parts per million
@@ -88,52 +88,53 @@ contract DisputeManager is Governed {
8888
// -- Events --
8989

9090
/**
91-
* @dev Emitted when `disputeID` is created for `subgraphID` and `indexer` by `fisherman`.
91+
* @dev Emitted when `disputeID` is created for `subgraphDeploymentID` and `indexer`
92+
* by `fisherman`.
9293
* The event emits the amount `tokens` deposited by the fisherman and `attestation` submitted.
9394
*/
9495
event DisputeCreated(
9596
bytes32 disputeID,
96-
bytes32 indexed subgraphID,
97+
bytes32 indexed subgraphDeploymentID,
9798
address indexed indexer,
9899
address indexed fisherman,
99100
uint256 tokens,
100101
bytes attestation
101102
);
102103

103104
/**
104-
* @dev Emitted when arbitrator accepts a `disputeID` for `subgraphID` and `indexer`
105+
* @dev Emitted when arbitrator accepts a `disputeID` for `subgraphDeploymentID` and `indexer`
105106
* created by `fisherman`.
106107
* The event emits the amount `tokens` transferred to the fisherman, the deposit plus reward.
107108
*/
108109
event DisputeAccepted(
109110
bytes32 disputeID,
110-
bytes32 indexed subgraphID,
111+
bytes32 indexed subgraphDeploymentID,
111112
address indexed indexer,
112113
address indexed fisherman,
113114
uint256 tokens
114115
);
115116

116117
/**
117-
* @dev Emitted when arbitrator rejects a `disputeID` for `subgraphID` and `indexer`
118+
* @dev Emitted when arbitrator rejects a `disputeID` for `subgraphDeploymentID` and `indexer`
118119
* created by `fisherman`.
119120
* The event emits the amount `tokens` burned from the fisherman deposit.
120121
*/
121122
event DisputeRejected(
122123
bytes32 disputeID,
123-
bytes32 indexed subgraphID,
124+
bytes32 indexed subgraphDeploymentID,
124125
address indexed indexer,
125126
address indexed fisherman,
126127
uint256 tokens
127128
);
128129

129130
/**
130-
* @dev Emitted when arbitrator draw a `disputeID` for `subgraphID` and `indexer`
131+
* @dev Emitted when arbitrator draw a `disputeID` for `subgraphDeploymentID` and `indexer`
131132
* created by `fisherman`.
132133
* The event emits the amount `tokens` used as deposit and returned to the fisherman.
133134
*/
134135
event DisputeDrawn(
135136
bytes32 disputeID,
136-
bytes32 indexed subgraphID,
137+
bytes32 indexed subgraphDeploymentID,
137138
address indexed indexer,
138139
address indexed fisherman,
139140
uint256 tokens
@@ -232,7 +233,7 @@ contract DisputeManager is Governed {
232233
RECEIPT_TYPE_HASH,
233234
_receipt.requestCID,
234235
_receipt.responseCID,
235-
_receipt.subgraphID
236+
_receipt.subgraphDeploymentID
236237
) // EIP 712-encoded message hash
237238
)
238239
)
@@ -345,7 +346,7 @@ contract DisputeManager is Governed {
345346

346347
emit DisputeAccepted(
347348
_disputeID,
348-
dispute.subgraphID,
349+
dispute.subgraphDeploymentID,
349350
dispute.indexer,
350351
dispute.fisherman,
351352
dispute.deposit.add(tokensToReward)
@@ -370,7 +371,7 @@ contract DisputeManager is Governed {
370371

371372
emit DisputeRejected(
372373
_disputeID,
373-
dispute.subgraphID,
374+
dispute.subgraphDeploymentID,
374375
dispute.indexer,
375376
dispute.fisherman,
376377
dispute.deposit
@@ -398,7 +399,7 @@ contract DisputeManager is Governed {
398399

399400
emit DisputeDrawn(
400401
_disputeID,
401-
dispute.subgraphID,
402+
dispute.subgraphDeploymentID,
402403
dispute.indexer,
403404
dispute.fisherman,
404405
dispute.deposit
@@ -422,32 +423,40 @@ contract DisputeManager is Governed {
422423
address channelID = _recoverAttestationSigner(attestation);
423424

424425
// Get the indexer that created the channel and signed the attestation
425-
(address indexer, bytes32 subgraphID) = staking.channels(channelID);
426+
(address indexer, bytes32 subgraphDeploymentID) = staking.channels(channelID);
426427
require(indexer != address(0), "Indexer cannot be found for the attestation");
427-
require(subgraphID == attestation.subgraphID, "Channel and attestation subgraph must match");
428+
require(
429+
subgraphDeploymentID == attestation.subgraphDeploymentID,
430+
"Channel and attestation subgraphDeploymentID must match"
431+
);
428432

429433
// Create a disputeID
430434
bytes32 disputeID = keccak256(
431435
abi.encodePacked(
432436
attestation.requestCID,
433437
attestation.responseCID,
434-
attestation.subgraphID,
438+
attestation.subgraphDeploymentID,
435439
indexer
436440
)
437441
);
438442

439443
// This also validates that indexer exists
440444
require(staking.hasStake(indexer), "Dispute has no stake by the indexer");
441445

442-
// A fisherman can only open one dispute for a given indexer / subgraphID at a time
446+
// A fisherman can only open one dispute for a (indexer, subgraphDeploymentID) at a time
443447
require(!isDisputeCreated(disputeID), "Dispute already created"); // Must be empty
444448

445449
// Store dispute
446-
disputes[disputeID] = Dispute(attestation.subgraphID, indexer, _fisherman, _deposit);
450+
disputes[disputeID] = Dispute(
451+
attestation.subgraphDeploymentID,
452+
indexer,
453+
_fisherman,
454+
_deposit
455+
);
447456

448457
emit DisputeCreated(
449458
disputeID,
450-
attestation.subgraphID,
459+
attestation.subgraphDeploymentID,
451460
indexer,
452461
_fisherman,
453462
_deposit,
@@ -465,7 +474,7 @@ contract DisputeManager is Governed {
465474
Receipt memory receipt = Receipt(
466475
_attestation.requestCID,
467476
_attestation.responseCID,
468-
_attestation.subgraphID
477+
_attestation.subgraphDeploymentID
469478
);
470479
bytes32 messageHash = encodeHashReceipt(receipt);
471480

@@ -492,7 +501,7 @@ contract DisputeManager is Governed {
492501
*/
493502
function _parseAttestation(bytes memory _data) private pure returns (Attestation memory) {
494503
// Decode receipt
495-
(bytes32 requestCID, bytes32 responseCID, bytes32 subgraphID) = abi.decode(
504+
(bytes32 requestCID, bytes32 responseCID, bytes32 subgraphDeploymentID) = abi.decode(
496505
_data, (bytes32, bytes32, bytes32)
497506
);
498507

@@ -502,7 +511,7 @@ contract DisputeManager is Governed {
502511
bytes32 r = _toBytes32(_data, RECEIPT_SIZE_BYTES + 1);
503512
bytes32 s = _toBytes32(_data, RECEIPT_SIZE_BYTES + 33);
504513

505-
return Attestation(requestCID, responseCID, subgraphID, v, r, s);
514+
return Attestation(requestCID, responseCID, subgraphDeploymentID, v, r, s);
506515
}
507516

508517
/**

contracts/GNS.sol

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@ pragma experimental ABIEncoderV2;
33

44
import "./Governed.sol";
55

6-
76
/**
87
* @title GNS
98
* @dev The Graph Name System contract provides a decentralized namings system for subgraphs
10-
* used in the scope of the Graph Network. It translate subgraph names into subgraphID regarded as
11-
* versions.
9+
* used in the scope of the Graph Network. It translate subgraph names into
10+
* subgraphDeploymentID regarded as versions.
1211
*/
1312
contract GNS is Governed {
1413
// -- Types --
@@ -17,7 +16,7 @@ contract GNS is Governed {
1716

1817
struct Record {
1918
address owner;
20-
bytes32 subgraphID;
19+
bytes32 subgraphDeploymentID;
2120
RecordType nameSystem;
2221
}
2322

@@ -28,10 +27,15 @@ contract GNS is Governed {
2827
// -- Events --
2928

3029
/**
31-
* @dev Emitted when `owner` publish a `subgraphID` version under subgraph `name`.
30+
* @dev Emitted when `owner` publish a `subgraphDeploymentID` version under subgraph `name`.
3231
* The event also attach `metadataHash` with extra information.
3332
*/
34-
event SubgraphPublished(string name, address owner, bytes32 subgraphID, bytes32 metadataHash);
33+
event SubgraphPublished(
34+
string name,
35+
address owner,
36+
bytes32 subgraphDeploymentID,
37+
bytes32 metadataHash
38+
);
3539

3640
/**
3741
* @dev Emitted when subgraph `nameHash` is unpublished by its owner.
@@ -49,20 +53,20 @@ contract GNS is Governed {
4953
}
5054

5155
/**
52-
* @dev Contract Constructor
56+
* @dev Contract Constructor.
5357
* @param _governor Owner address of this contract
5458
*/
5559
constructor(address _governor) public Governed(_governor) {}
5660

5761
/**
58-
* @dev Publish a version using `subgraphID` under a subgraph name.
62+
* @dev Publish a version using `subgraphDeploymentID` under a subgraph..
5963
* @param _name Name of the subgraph
60-
* @param _subgraphID Subgraph ID to link to the subgraph name
64+
* @param _subgraphDeploymentID SubgraphDeployment to link to the subgraph
6165
* @param _metadataHash IPFS hash linked to the metadata
6266
*/
6367
function publish(
6468
string calldata _name,
65-
bytes32 _subgraphID,
69+
bytes32 _subgraphDeploymentID,
6670
bytes32 _metadataHash
6771
) external {
6872
address owner = msg.sender;
@@ -72,8 +76,8 @@ contract GNS is Governed {
7276
"GNS: Record reserved, only record owner can publish"
7377
);
7478

75-
records[nameHash] = Record(owner, _subgraphID, RecordType.GNS);
76-
emit SubgraphPublished(_name, owner, _subgraphID, _metadataHash);
79+
records[nameHash] = Record(owner, _subgraphDeploymentID, RecordType.GNS);
80+
emit SubgraphPublished(_name, owner, _subgraphDeploymentID, _metadataHash);
7781
}
7882

7983
/**

0 commit comments

Comments
 (0)