Skip to content

Commit 7d3fb7b

Browse files
authored
misc: upgradeable curation and staking contracts (#244)
Upgradeability to both the Staking and Curation contract. Also implements security improvements. - add proxy delegate call contract - prepare curation and staking contract to be used in the context of a proxy - add a function for the new governor to need to accept the role - assign governor to the contract creator by default - make bancor formula to use initialize to support being used from upgradeable contracts - proxy contract for staking upgrades - add governed contract test - remove setToken() function from Curation The deploy script is now aware of the contracts deployed with a delegatecall proxy to make them upgradeable: - this script deploys a contract with a Proxy when the attribute __proxy: true is set in the graph.config.yml - all the parameters that would be passed in the constructor are used to initialize the Implementation. By convention the `acceptProxy` function is used. - the deploy script updates the addresses.json file indicating the proxy address and the implementation address. - improve the CLI consistency - support deploy single contracts, this is useful when we want to deploy a fix and then upgrade
1 parent 977ff9c commit 7d3fb7b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+1793
-3131
lines changed

.soliumignore

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
node_modules
2+
23
contracts/abdk-libraries-solidity
34
contracts/bancor
45
contracts/ens
56
contracts/erc1056
67
contracts/openzeppelin
7-
contracts/IGraphToken.sol
8-
contracts/MultiSigWallet.sol
9-
contracts/Staking.sol
8+
9+
contracts/staking/Staking.sol
10+
contracts/token/IGraphToken.sol
11+
contracts/upgrades/GraphProxy.sol
12+
1013
contracts/connext/IndexerMultiAssetInterpreter.sol
1114
contracts/connext/IndexerSingleAssetInterpreter.sol
1215
contracts/connext/IndexerWithdrawInterpreter.sol
1316
contracts/connext/Proxy.sol
14-
contracts/connext/MinimumViableMultisig.sol
17+
contracts/connext/MinimumViableMultisig.sol

buidler.config.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Wallet } from 'ethers'
33
import { task, usePlugin } from '@nomiclabs/buidler/config'
44

55
import { cliOpts } from './scripts/cli/constants'
6+
import { loadEnv } from './scripts/cli/env'
67
import { migrate } from './scripts/cli/commands/migrate'
78
import { verify } from './scripts/cli/commands/verify'
89

@@ -41,14 +42,14 @@ task('migrate', 'Migrate contracts')
4142
.addFlag('force', cliOpts.force.description)
4243
.setAction(async (taskArgs, bre) => {
4344
const accounts = await bre.ethers.getSigners()
44-
await migrate(accounts[0] as Wallet, taskArgs.addressBook, taskArgs.graphConfig, taskArgs.force)
45+
await migrate(await loadEnv(accounts[0] as Wallet, taskArgs), taskArgs)
4546
})
4647

4748
task('verify', 'Verify contracts in Etherscan')
4849
.addParam('addressBook', cliOpts.addressBook.description, cliOpts.addressBook.default)
4950
.setAction(async (taskArgs, bre) => {
5051
const accounts = await bre.ethers.getSigners()
51-
await verify(accounts[0] as Wallet, taskArgs.addressBook)
52+
await verify(await loadEnv(accounts[0] as Wallet, taskArgs))
5253
})
5354

5455
// Config - Go to https://buidler.dev/config/ to learn more
@@ -130,6 +131,15 @@ const config = {
130131
mnemonic: getAccountMnemonic(),
131132
},
132133
},
134+
mainnet: {
135+
chainId: 1,
136+
url: getInfuraProviderURL('mainnet'),
137+
gas: 'auto',
138+
gasPrice: 'auto',
139+
accounts: {
140+
mnemonic: getAccountMnemonic(),
141+
},
142+
},
133143
},
134144
etherscan: {
135145
url: 'https://api-kovan.etherscan.io/api',

contracts/DisputeManager.sol

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

44
import "@openzeppelin/contracts/math/SafeMath.sol";
55

6-
import "./Governed.sol";
7-
import "./IGraphToken.sol";
8-
import "./IStaking.sol";
6+
import "./governance/Governed.sol";
7+
import "./staking/IStaking.sol";
8+
import "./token/IGraphToken.sol";
99

1010
/*
1111
* @title DisputeManager
@@ -150,7 +150,6 @@ contract DisputeManager is Governed {
150150

151151
/**
152152
* @dev Contract Constructor
153-
* @param _governor Owner address of this contract
154153
* @param _token Address of the Graph Protocol token
155154
* @param _arbitrator Arbitrator role
156155
* @param _staking Address of the staking contract used for slashing
@@ -159,14 +158,13 @@ contract DisputeManager is Governed {
159158
* @param _slashingPercentage Percentage of indexer stake slashed after a dispute
160159
*/
161160
constructor(
162-
address _governor,
163161
address _arbitrator,
164162
address _token,
165163
address _staking,
166164
uint256 _minimumDeposit,
167165
uint256 _fishermanRewardPercentage,
168166
uint256 _slashingPercentage
169-
) public Governed(_governor) {
167+
) public {
170168
arbitrator = _arbitrator;
171169
token = IGraphToken(_token);
172170
staking = IStaking(_staking);

contracts/EpochManager.sol

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ pragma solidity ^0.6.4;
22

33
import "@openzeppelin/contracts/math/SafeMath.sol";
44

5-
import "./Governed.sol";
5+
import "./governance/Governed.sol";
66

77
/**
88
* @title EpochManager contract
@@ -30,10 +30,9 @@ contract EpochManager is Governed {
3030

3131
/**
3232
* @dev Contract Constructor
33-
* @param _governor Owner address of this contract
3433
* @param _epochLength Epoch length in blocks
3534
*/
36-
constructor(address _governor, uint256 _epochLength) public Governed(_governor) {
35+
constructor(uint256 _epochLength) public {
3736
require(_epochLength > 0, "Epoch length cannot be 0");
3837

3938
lastLengthUpdateEpoch = 0;

contracts/GNS.sol

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
pragma solidity ^0.6.4;
22
pragma experimental ABIEncoderV2;
33

4-
import "./Governed.sol";
54
import "./erc1056/IEthereumDIDRegistry.sol";
5+
import "./governance/Governed.sol";
66

77
/**
88
* @title GNS
@@ -62,10 +62,9 @@ contract GNS is Governed {
6262

6363
/**
6464
* @dev Contract Constructor.
65-
* @param _governor Owner address of this contract
6665
* @param _didRegistry Address of the Ethereum DID registry
6766
*/
68-
constructor(address _governor, address _didRegistry) public Governed(_governor) {
67+
constructor(address _didRegistry) public {
6968
erc1056Registry = IEthereumDIDRegistry(_didRegistry);
7069
}
7170

contracts/Governed.sol

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)