Skip to content

Commit 5272f4a

Browse files
authored
Rework graph config files (#572)
* feat: rework graph config files - add hardhat task to update config files with on chain data - support using one config file per network Signed-off-by: Tomás Migone <[email protected]>
1 parent e6a459b commit 5272f4a

File tree

10 files changed

+360
-31
lines changed

10 files changed

+360
-31
lines changed

.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ MNEMONIC=
22
ETHERSCAN_API_KEY=
33
INFURA_KEY=
44
ADDRESS_BOOK="addresses.json"
5-
GRAPH_CONFIG=""graph.config.yml""
5+
GRAPH_CONFIG=""config/graph.mainnet.yml""
66
PROVIDER_URL="http://localhost:8545"

DEPLOYMENT.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ To deploy using your own wallet add the HD Wallet Config to the `hardhat.config.
4949

5050
### Configuration
5151

52-
A configuration file called `graph.config.yml` contains the parameters needed to deploy the contracts. Please edit these params as you see fit.
52+
A configuration file called `graph.<networkName>.yml` located in the `config` folder contains the parameters needed to deploy the contracts. Please edit these params as you see fit.
5353

5454
You can use a different set of configuration options by specifying the file location in the command line:
5555

5656
```
57-
yarn deploy -- --graph-config another-graph.config.yml
57+
yarn deploy -- --graph-config another-graph.mainnet.yml
5858
```
5959

6060
Rules:
@@ -67,7 +67,7 @@ Rules:
6767

6868
Example:
6969

70-
[https://github.com/graphprotocol/contracts/blob/master/graph.config.yml](https://github.com/graphprotocol/contracts/blob/master/graph.config.yml)
70+
[https://github.com/graphprotocol/contracts/blob/master/config/graph.mainnet.yml](https://github.com/graphprotocol/contracts/blob/master/config/graph.mainnet.yml)
7171

7272
### Address book
7373

cli/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ MNEMONIC=
1111
ETHERSCAN_API_KEY=
1212
INFURA_KEY=
1313
ADDRESS_BOOK="addresses.json"
14-
GRAPH_CONFIG=""graph.config.yml""
14+
GRAPH_CONFIG=""config/graph.mainnet.yml""
1515
PROVIDER_URL="http://localhost:8545"
1616
```
1717

cli/config.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,13 @@ function parseAddressBookRef(addressBook: AddressBook, value: string, cli: CLIEn
4242
}
4343

4444
// eslint-disable-next-line @typescript-eslint/no-explicit-any
45-
export function readConfig(path: string): any {
45+
export function readConfig(path: string, retainMetadata = false): any {
4646
const file = fs.readFileSync(path, 'utf8')
47-
return YAML.parse(file)
47+
return retainMetadata ? YAML.parseDocument(file) : YAML.parse(file)
48+
}
49+
50+
export function writeConfig(path: string, data: string): void {
51+
fs.writeFileSync(path, data)
4852
}
4953

5054
export function loadCallParams(

cli/contracts.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { BancorFormula } from '../build/types/BancorFormula'
1818
import { IENS } from '../build/types/IENS'
1919
import { IEthereumDIDRegistry } from '../build/types/IEthereumDIDRegistry'
2020
import { GraphGovernance } from '../build/types/GraphGovernance'
21+
import { AllocationExchange } from '../build/types/AllocationExchange'
2122

2223
export interface NetworkContracts {
2324
EpochManager: EpochManager
@@ -34,6 +35,7 @@ export interface NetworkContracts {
3435
IENS: IENS
3536
IEthereumDIDRegistry: IEthereumDIDRegistry
3637
GraphGovernance: GraphGovernance
38+
AllocationExchange: AllocationExchange
3739
}
3840

3941
export const loadContracts = (

cli/defaults.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export const local = {
55
mnemonic: 'myth like bonus scare over problem client lizard pioneer submit female collect',
66
providerUrl: 'http://localhost:8545',
77
addressBookPath: './addresses.json',
8-
graphConfigPath: './graph.config.yml',
8+
graphConfigPath: './config/graph.mainnet.yml',
99
accountNumber: '0',
1010
}
1111

graph.config.yml renamed to config/graph.mainnet.yml

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
general:
22
arbitrator: &arbitrator "0xE1FDD398329C6b74C14cf19100316f0826a492d3" # Arbitration Council
33
governor: &governor "0x48301Fe520f72994d32eAd72E2B6A8447873CF50" # Graph Council
4-
authority: &authority "0x79fd74da4c906509862c8fe93e87a9602e370bc4" # Authority that signs payment vouchers
4+
authority: &authority "0x982D10c56b8BBbD6e09048F5c5f01b43C65D5aE0" # Authority that signs payment vouchers
55

66
contracts:
77
Controller:
@@ -35,10 +35,10 @@ contracts:
3535
proxy: true
3636
init:
3737
controller: "${{Controller.address}}"
38-
lengthInBlocks: 1108 # 4 hours (in 13 second blocks)
38+
lengthInBlocks: 6646 # length in hours = lengthInBlocks*13/60/60 (~13 second blocks)
3939
GraphToken:
4040
init:
41-
initialSupply: "10000000000000000000000000000" # 10,000,000,000 GRT
41+
initialSupply: "10000000000000000000000000000" # in wei
4242
calls:
4343
- fn: "addMinter"
4444
minter: "${{RewardsManager.address}}"
@@ -48,18 +48,18 @@ contracts:
4848
controller: "${{Controller.address}}"
4949
bondingCurve: "${{BancorFormula.address}}"
5050
curationTokenMaster: "${{GraphCurationToken.address}}"
51-
reserveRatio: 500000 # 50% (parts per million)
52-
curationTaxPercentage: 10000 # 1% (parts per million)
53-
minimumCurationDeposit: "1000000000000000000" # 1 GRT
51+
reserveRatio: 500000 # in parts per million
52+
curationTaxPercentage: 10000 # in parts per million
53+
minimumCurationDeposit: "1000000000000000000" # in wei
5454
DisputeManager:
5555
proxy: true
5656
init:
5757
controller: "${{Controller.address}}"
5858
arbitrator: *arbitrator
59-
minimumDeposit: "10000000000000000000000" # 10,000 GRT (in wei)
60-
fishermanRewardPercentage: 500000 # 50% (parts per million)
61-
idxSlashingPercentage: 25000 # 2.5% (parts per million)
62-
qrySlashingPercentage: 5000 # 0.5% (parts per million)
59+
minimumDeposit: "10000000000000000000000" # in wei
60+
fishermanRewardPercentage: 500000 # in parts per million
61+
idxSlashingPercentage: 25000 # in parts per million
62+
qrySlashingPercentage: 25000 # in parts per million
6363
GNS:
6464
proxy: true
6565
init:
@@ -80,19 +80,19 @@ contracts:
8080
proxy: true
8181
init:
8282
controller: "${{Controller.address}}"
83-
minimumIndexerStake: "100000000000000000000000" # 100,000 GRT (in wei)
84-
thawingPeriod: 6646 # 10 days (in blocks)
85-
protocolPercentage: 10000 # 1% (parts per million)
86-
curationPercentage: 100000 # 10% (parts per million)
87-
channelDisputeEpochs: 2 # (in epochs)
88-
maxAllocationEpochs: 6 # Based on epoch length this is 28 days (in epochs)
89-
delegationUnbondingPeriod: 6 # Based on epoch length this is 28 days (in epochs)
90-
delegationRatio: 16 # 16x (delegated stake to indexer stake multiplier)
83+
minimumIndexerStake: "100000000000000000000000" # in wei
84+
thawingPeriod: 186092 # in blocks
85+
protocolPercentage: 10000 # in parts per million
86+
curationPercentage: 100000 # in parts per million
87+
channelDisputeEpochs: 7 # in epochs
88+
maxAllocationEpochs: 28 # in epochs
89+
delegationUnbondingPeriod: 28 # in epochs
90+
delegationRatio: 16 # delegated stake to indexer stake multiplier
9191
rebateAlphaNumerator: 77 # rebateAlphaNumerator / rebateAlphaDenominator
9292
rebateAlphaDenominator: 100 # rebateAlphaNumerator / rebateAlphaDenominator
9393
calls:
9494
- fn: "setDelegationTaxPercentage"
95-
delegationTaxPercentage: 5000 # 0.5% (parts per million)
95+
delegationTaxPercentage: 5000 # parts per million
9696
- fn: "setSlasher"
9797
slasher: "${{DisputeManager.address}}"
9898
allowed: true
@@ -103,7 +103,7 @@ contracts:
103103
proxy: true
104104
init:
105105
controller: "${{Controller.address}}"
106-
issuanceRate: "1000000012184945188" # 3% annual rate (per block increase of total supply, blocks in a year = 365*60*60*24/13)
106+
issuanceRate: "1000000012184945188" # per block increase of total supply, blocks in a year = 365*60*60*24/13
107107
AllocationExchange:
108108
init:
109109
graphToken: "${{GraphToken.address}}"

config/graph.rinkeby.yml

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
general:
2+
arbitrator: &arbitrator "0x87D11BD744b882b7bc5A6b5450cbA8C35D90eb10" # Arbitration Council
3+
governor: &governor "0x1679A1D1caf1252BA43Fb8Fc17ebF914a0C725AE" # Graph Council
4+
authority: &authority "0xe1EC4339019eC9628438F8755f847e3023e4ff9c" # Authority that signs payment vouchers
5+
6+
contracts:
7+
Controller:
8+
calls:
9+
- fn: "setContractProxy"
10+
id: "0xe6876326c1291dfcbbd3864a6816d698cd591defc7aa2153d7f9c4c04016c89f" # keccak256('Curation')
11+
contractAddress: "${{Curation.address}}"
12+
- fn: "setContractProxy"
13+
id: "0x39605a6c26a173774ca666c67ef70cf491880e5d3d6d0ca66ec0a31034f15ea3" # keccak256('GNS')
14+
contractAddress: "${{GNS.address}}"
15+
- fn: "setContractProxy"
16+
id: "0xf942813d07d17b56de9a9afc8de0ced6e8c053bbfdcc87b7badea4ddcf27c307" # keccak256('DisputeManager')
17+
contractAddress: "${{DisputeManager.address}}"
18+
- fn: "setContractProxy"
19+
id: "0xc713c3df6d14cdf946460395d09af88993ee2b948b1a808161494e32c5f67063" # keccak256('EpochManager')
20+
contractAddress: "${{EpochManager.address}}"
21+
- fn: "setContractProxy"
22+
id: "0x966f1e8d8d8014e05f6ec4a57138da9be1f7c5a7f802928a18072f7c53180761" # keccak256('RewardsManager')
23+
contractAddress: "${{RewardsManager.address}}"
24+
- fn: "setContractProxy"
25+
id: "0x1df41cd916959d1163dc8f0671a666ea8a3e434c13e40faef527133b5d167034" # keccak256('Staking')
26+
contractAddress: "${{Staking.address}}"
27+
- fn: "setContractProxy"
28+
id: "0x45fc200c7e4544e457d3c5709bfe0d520442c30bbcbdaede89e8d4a4bbc19247" # keccak256('GraphToken')
29+
contractAddress: "${{GraphToken.address}}"
30+
ServiceRegistry:
31+
proxy: true
32+
init:
33+
controller: "${{Controller.address}}"
34+
EpochManager:
35+
proxy: true
36+
init:
37+
controller: "${{Controller.address}}"
38+
lengthInBlocks: 277 # length in hours = lengthInBlocks*13/60/60 (~13 second blocks)
39+
GraphToken:
40+
init:
41+
initialSupply: "10000000000000000000000000000" # in wei
42+
calls:
43+
- fn: "addMinter"
44+
minter: "${{RewardsManager.address}}"
45+
Curation:
46+
proxy: true
47+
init:
48+
controller: "${{Controller.address}}"
49+
bondingCurve: "${{BancorFormula.address}}"
50+
curationTokenMaster: "${{GraphCurationToken.address}}"
51+
reserveRatio: 500000 # in parts per million
52+
curationTaxPercentage: 10000 # in parts per million
53+
minimumCurationDeposit: "1000000000000000000" # in wei
54+
DisputeManager:
55+
proxy: true
56+
init:
57+
controller: "${{Controller.address}}"
58+
arbitrator: *arbitrator
59+
minimumDeposit: "10000000000000000000000" # in wei
60+
fishermanRewardPercentage: 500000 # in parts per million
61+
idxSlashingPercentage: 20000 # in parts per million
62+
qrySlashingPercentage: 5000 # in parts per million
63+
GNS:
64+
proxy: true
65+
init:
66+
controller: "${{Controller.address}}"
67+
bondingCurve: "${{BancorFormula.address}}"
68+
subgraphNFT: "${{SubgraphNFT.address}}"
69+
calls:
70+
- fn: "approveAll"
71+
SubgraphNFT:
72+
init:
73+
governor: "${{Env.deployer}}"
74+
calls:
75+
- fn: "setTokenDescriptor"
76+
tokenDescriptor: "${{SubgraphNFTDescriptor.address}}"
77+
- fn: "setMinter"
78+
minter: "${{GNS.address}}"
79+
Staking:
80+
proxy: true
81+
init:
82+
controller: "${{Controller.address}}"
83+
minimumIndexerStake: "100000000000000000000000" # in wei
84+
thawingPeriod: 6646 # in blocks
85+
protocolPercentage: 10000 # in parts per million
86+
curationPercentage: 100000 # in parts per million
87+
channelDisputeEpochs: 2 # in epochs
88+
maxAllocationEpochs: 2 # in epochs
89+
delegationUnbondingPeriod: 6 # in epochs
90+
delegationRatio: 16 # delegated stake to indexer stake multiplier
91+
rebateAlphaNumerator: 77 # rebateAlphaNumerator / rebateAlphaDenominator
92+
rebateAlphaDenominator: 100 # rebateAlphaNumerator / rebateAlphaDenominator
93+
calls:
94+
- fn: "setDelegationTaxPercentage"
95+
delegationTaxPercentage: 5000 # parts per million
96+
- fn: "setSlasher"
97+
slasher: "${{DisputeManager.address}}"
98+
allowed: true
99+
- fn: "setAssetHolder"
100+
assetHolder: "${{AllocationExchange.address}}"
101+
allowed: true
102+
RewardsManager:
103+
proxy: true
104+
init:
105+
controller: "${{Controller.address}}"
106+
issuanceRate: "1000000012184945188" # per block increase of total supply, blocks in a year = 365*60*60*24/13
107+
AllocationExchange:
108+
init:
109+
graphToken: "${{GraphToken.address}}"
110+
staking: "${{Staking.address}}"
111+
governor: *governor
112+
authority: *authority
113+
calls:
114+
- fn: "approveAll"

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@
8282
"compile": "hardhat compile",
8383
"deploy": "scripts/predeploy && hardhat migrate",
8484
"deploy-ganache": "yarn deploy -- --force",
85-
"deploy-ganache-manual": "yarn deploy -- --network ganache --force",
86-
"deploy-hardhat": "yarn deploy -- --network hardhat --force",
87-
"deploy-rinkeby": "yarn deploy -- --force --network rinkeby",
85+
"deploy-ganache-manual": "yarn deploy -- --force --network ganache",
86+
"deploy-hardhat": "yarn deploy -- --force --network hardhat",
87+
"deploy-rinkeby": "yarn deploy -- --force --network rinkeby --graph-config config/graph.rinkeby.yml",
8888
"predeploy": "scripts/predeploy",
8989
"test": "scripts/test",
9090
"test:gas": "RUN_EVM=true REPORT_GAS=true scripts/test",

0 commit comments

Comments
 (0)