Skip to content

Commit 04ca1fe

Browse files
authored
style: update name conventions for indexer and governance (#171)
1 parent b5fabfa commit 04ca1fe

14 files changed

+156
-168
lines changed

contracts/Curation.sol

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ pragma experimental ABIEncoderV2;
33

44
/*
55
* @title Curation contract
6-
* @notice Allows Curators to signal Subgraphs that are relevant for indexers and earn fees from the Query Market.
6+
* @notice Allows Curators to signal Subgraphs that are relevant for indexers and earn fees from the Query Market
77
*/
88

99
import "./Governed.sol";
@@ -12,6 +12,7 @@ import "./bancor/BancorFormula.sol";
1212
import "./bytes/BytesLib.sol";
1313
import "@openzeppelin/contracts/math/SafeMath.sol";
1414

15+
1516
contract Curation is Governed, BancorFormula {
1617
using BytesLib for bytes;
1718
using SafeMath for uint256;
@@ -102,7 +103,7 @@ contract Curation is Governed, BancorFormula {
102103
*/
103104
function setDefaultReserveRatio(uint256 _defaultReserveRatio)
104105
external
105-
onlyGovernance
106+
onlyGovernor
106107
{
107108
_setDefaultReserveRatio(_defaultReserveRatio);
108109
}
@@ -127,7 +128,7 @@ contract Curation is Governed, BancorFormula {
127128
* @notice Update the distributor address to `_distributor`
128129
* @param _distributor <address> - Address of the party doing fee distributions
129130
*/
130-
function setDistributor(address _distributor) external onlyGovernance {
131+
function setDistributor(address _distributor) external onlyGovernor {
131132
_setDistributor(_distributor);
132133
}
133134

@@ -147,7 +148,7 @@ contract Curation is Governed, BancorFormula {
147148
*/
148149
function setMinimumCurationStake(uint256 _minimumCurationStake)
149150
external
150-
onlyGovernance
151+
onlyGovernor
151152
{
152153
_setMinimumCurationStake(_minimumCurationStake);
153154
}
@@ -205,7 +206,10 @@ contract Curation is Governed, BancorFormula {
205206
function unstake(bytes32 _subgraphID, uint256 _shares) external {
206207
address curator = msg.sender;
207208
Subgraph storage subgraph = subgraphs[_subgraphID];
208-
SubgraphCurator storage subgraphCurator = subgraphCurators[_subgraphID][curator];
209+
210+
211+
SubgraphCurator storage subgraphCurator
212+
= subgraphCurators[_subgraphID][curator];
209213

210214
require(_shares > 0, "Cannot unstake zero shares");
211215
require(
@@ -260,20 +264,20 @@ contract Curation is Governed, BancorFormula {
260264
}
261265

262266
/**
263-
* @dev Check if any Graph tokens are staked for a particular subgraph
264-
* @param _subgraphID <uint256> Subgraph ID to check if tokens are staked
265-
* @return <bool> True if the subgraph is curated
266-
*/
267+
* @dev Check if any Graph tokens are staked for a particular subgraph
268+
* @param _subgraphID <uint256> Subgraph ID to check if tokens are staked
269+
* @return <bool> True if the subgraph is curated
270+
*/
267271
function isSubgraphCurated(bytes32 _subgraphID) public view returns (bool) {
268272
return subgraphs[_subgraphID].totalTokens > 0;
269273
}
270274

271275
/**
272-
* @dev Calculate number of subgraph shares that can be bought with a number of tokens
273-
* @param _subgraphID <bytes32> Subgraph ID from where to buy shares
274-
* @param _tokens <uint256> Amount of tokens used to buy shares
275-
* @return <uint256> Amount of shares that can be bought
276-
*/
276+
* @dev Calculate number of subgraph shares that can be bought with a number of tokens
277+
* @param _subgraphID <bytes32> Subgraph ID from where to buy shares
278+
* @param _tokens <uint256> Amount of tokens used to buy shares
279+
* @return <uint256> Amount of shares that can be bought
280+
*/
277281
function subgraphTokensToShares(bytes32 _subgraphID, uint256 _tokens)
278282
public
279283
view
@@ -293,16 +297,15 @@ contract Curation is Governed, BancorFormula {
293297
subgraph.totalTokens,
294298
uint32(subgraph.reserveRatio),
295299
_tokens
296-
) +
297-
shares;
300+
) + shares;
298301
}
299302

300303
/**
301-
* @dev Calculate number of tokens to get when selling subgraph shares
302-
* @param _subgraphID <bytes32> Subgraph ID from where to sell shares
303-
* @param _shares <uint256> Amount of shares to sell
304-
* @return <uint256> Amount of tokens to get after selling shares
305-
*/
304+
* @dev Calculate number of tokens to get when selling subgraph shares
305+
* @param _subgraphID <bytes32> Subgraph ID from where to sell shares
306+
* @param _shares <uint256> Amount of shares to sell
307+
* @return <uint256> Amount of tokens to get after selling shares
308+
*/
306309
function subgraphSharesToTokens(bytes32 _subgraphID, uint256 _shares)
307310
public
308311
view
@@ -375,7 +378,10 @@ contract Curation is Governed, BancorFormula {
375378
{
376379
uint256 tokens = _amount;
377380
Subgraph storage subgraph = subgraphs[_subgraphID];
378-
SubgraphCurator storage subgraphCurator = subgraphCurators[_subgraphID][_curator];
381+
382+
383+
SubgraphCurator storage subgraphCurator
384+
= subgraphCurators[_subgraphID][_curator];
379385

380386
// If this subgraph hasn't been curated before then initialize the curve
381387
// Sets the initial slope for the curve, controlled by minimumCurationStake

contracts/DisputeManager.sol

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import "./Staking.sol";
1212
import "./bytes/BytesLib.sol";
1313
import "@openzeppelin/contracts/cryptography/ECDSA.sol";
1414

15+
1516
contract DisputeManager is Governed {
1617
using BytesLib for bytes;
1718
using ECDSA for bytes32;
@@ -220,7 +221,7 @@ contract DisputeManager is Governed {
220221
* @notice Update the arbitrator to `_arbitrator`
221222
* @param _arbitrator <address> - The address of the arbitration contract or party
222223
*/
223-
function setArbitrator(address _arbitrator) external onlyGovernance {
224+
function setArbitrator(address _arbitrator) external onlyGovernor {
224225
_setArbitrator(_arbitrator);
225226
}
226227

@@ -242,10 +243,7 @@ contract DisputeManager is Governed {
242243
* @notice Update the minimum deposit to `_minimumDeposit` Graph Tokens
243244
* @param _minimumDeposit <uint256> - The minimum deposit in Graph Tokens
244245
*/
245-
function setMinimumDeposit(uint256 _minimumDeposit)
246-
external
247-
onlyGovernance
248-
{
246+
function setMinimumDeposit(uint256 _minimumDeposit) external onlyGovernor {
249247
minimumDeposit = _minimumDeposit;
250248
}
251249

@@ -256,7 +254,7 @@ contract DisputeManager is Governed {
256254
*/
257255
function setSlashingPercentage(uint256 _slashingPercentage)
258256
external
259-
onlyGovernance
257+
onlyGovernor
260258
{
261259
// Must be within 0% to 100% (inclusive)
262260
require(
@@ -328,7 +326,7 @@ contract DisputeManager is Governed {
328326

329327
// Have staking slash the index node and reward the fisherman
330328
// Give the fisherman a reward equal to the slashingPercentage of the indexer's stake
331-
uint256 stake = staking.getIndexingNodeStake(
329+
uint256 stake = staking.getIndexNodeStake(
332330
dispute.subgraphID,
333331
dispute.indexNode
334332
);
@@ -433,7 +431,7 @@ contract DisputeManager is Governed {
433431
address indexNode = disputeID.recover(_sig);
434432

435433
// Get staked amount on the served subgraph by indexer
436-
uint256 stake = staking.getIndexingNodeStake(_subgraphID, indexNode);
434+
uint256 stake = staking.getIndexNodeStake(_subgraphID, indexNode);
437435

438436
// This also validates that indexer node exists
439437
require(

contracts/EpochManager.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ contract EpochManager is Governed {
5353
* @notice Set epoch length to `_epochLength` blocks
5454
* @param _epochLength Epoch length in blocks
5555
*/
56-
function setEpochLength(uint256 _epochLength) external onlyGovernance {
56+
function setEpochLength(uint256 _epochLength) external onlyGovernor {
5757
require(_epochLength > 0, "Epoch length cannot be 0");
5858
require(
5959
_epochLength != epochLength,

contracts/Governed.sol

Lines changed: 14 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,22 @@
11
pragma solidity ^0.6.4;
2+
pragma experimental ABIEncoderV2;
23

3-
contract Governed {
4-
/*
5-
* @title Graph Contract Governance contract
6-
*
7-
* @author Bryant Eisenbach
8-
* @author Reuven Etzion
9-
*
10-
* @notice Contract Specification:
11-
*
12-
* There are several parameters throughout this mechanism design which are set via a
13-
* governance process. In the v1 specification, governance will consist of a small committee
14-
* which enacts changes to the protocol via a multi-sig contract.
15-
*
16-
* Requirements ("Governed" contract):
17-
* req 01 Multisig contract will own this contract
18-
* req 02 Verify the Governed contracts can upgrade themselves to a new `governor`
19-
* (GovA owns contracts 1-5 and can transfer ownership of 1-5 to GovB)
20-
* ...
21-
* Version 2
22-
* req 01 (V2) Change Mutli-sig to use a voting mechanism
23-
* - Majority of votes after N% of votes cast will trigger proposed actions
24-
*/
254

5+
/*
6+
* @title Graph Governance contract
7+
* @notice All contracts that will be owned by a Governor entity should extend this contract
8+
*/
9+
10+
contract Governed {
2611
address public governor;
2712

2813
event GovernanceTransferred(address indexed _from, address indexed _to);
2914

15+
modifier onlyGovernor {
16+
require(msg.sender == governor, "Only Governor can call");
17+
_;
18+
}
19+
3020
/**
3121
* @dev All `Governed` contracts are constructed using an address for the `governor`
3222
* @param _governor <address> Address of initial `governor` of the contract
@@ -35,18 +25,13 @@ contract Governed {
3525
governor = _governor;
3626
}
3727

38-
modifier onlyGovernance {
39-
require(msg.sender == governor, "Only Governor can call");
40-
_;
41-
}
42-
4328
/**
4429
* @dev The current `governor` can assign a new `governor`
4530
* @param _newGovernor <address> Address of new `governor`
4631
*/
47-
function transferGovernance(address _newGovernor)
32+
function transferOwnership(address _newGovernor)
4833
public
49-
onlyGovernance
34+
onlyGovernor
5035
returns (bool)
5136
{
5237
governor = _newGovernor;

contracts/GraphToken.sol

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import "./Governed.sol";
1010
import "@openzeppelin/contracts/token/ERC20/ERC20Burnable.sol";
1111
import "@openzeppelin/contracts/token/ERC20/ERC20Detailed.sol";
1212

13+
1314
// @imp 08 target _to of transfer(_to, _amount, _data) in Token must implement this interface
1415
// NOTE: This is based off of ERC777TokensRecipient interface, but does not fully implement it
1516
interface TokenReceiver {
@@ -20,6 +21,7 @@ interface TokenReceiver {
2021
) external returns (bool);
2122
}
2223

24+
2325
contract GraphToken is Governed, ERC20Detailed, ERC20Burnable {
2426
mapping(address => bool) private _minters;
2527

@@ -52,11 +54,11 @@ contract GraphToken is Governed, ERC20Detailed, ERC20Burnable {
5254
_mint(_governor, _initialSupply);
5355
}
5456

55-
function addMinter(address _account) external onlyGovernance {
57+
function addMinter(address _account) external onlyGovernor {
5658
_addMinter(_account);
5759
}
5860

59-
function removeMinter(address _account) external onlyGovernance {
61+
function removeMinter(address _account) external onlyGovernor {
6062
_removeMinter(_account);
6163
}
6264

contracts/RewardsManager.sol

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ pragma experimental ABIEncoderV2;
33

44
import "./Governed.sol";
55

6+
67
contract RewardsManager is Governed {
78
/*
89
* @title Graph Protocol Reward Manager contract
@@ -65,7 +66,7 @@ contract RewardsManager is Governed {
6566
*/
6667
function updateCuratorRewardRate(uint256 _newCuratorRewardRate)
6768
public
68-
onlyGovernance
69+
onlyGovernor
6970
returns (bool success)
7071
{
7172
revert();
@@ -77,7 +78,7 @@ contract RewardsManager is Governed {
7778
*/
7879
function updateTargetParticipationRate(uint256 _newTargetParticipationRate)
7980
public
80-
onlyGovernance
81+
onlyGovernor
8182
returns (bool success)
8283
{
8384
revert();
@@ -89,7 +90,7 @@ contract RewardsManager is Governed {
8990
*/
9091
function updateYearlyInflationRate(uint256 _newYearlyInflationRate)
9192
public
92-
onlyGovernance
93+
onlyGovernor
9394
returns (bool success)
9495
{
9596
revert();
@@ -104,7 +105,7 @@ contract RewardsManager is Governed {
104105
*/
105106
function mintRewardTokens(address _account, uint256 _value)
106107
public
107-
onlyGovernance
108+
onlyGovernor
108109
returns (bool success)
109110
{
110111
revert();

contracts/ServiceRegistry.sol

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ pragma experimental ABIEncoderV2;
33

44
import "./Governed.sol";
55

6+
67
contract ServiceRegistry is Governed {
78
/*
89
* @title Graph Protocol Service Registry contract
@@ -46,7 +47,7 @@ contract ServiceRegistry is Governed {
4647
*/
4748
function setBootstrapIndexerURL(address _indexer, string calldata _url)
4849
external
49-
onlyGovernance
50+
onlyGovernor
5051
{
5152
bytes memory url = bytes(_url);
5253
bootstrapIndexerURLs[_indexer] = url;

0 commit comments

Comments
 (0)