Skip to content

Rework graph config files #572

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ MNEMONIC=
ETHERSCAN_API_KEY=
INFURA_KEY=
ADDRESS_BOOK="addresses.json"
GRAPH_CONFIG=""graph.config.yml""
GRAPH_CONFIG=""config/graph.mainnet.yml""
PROVIDER_URL="http://localhost:8545"
6 changes: 3 additions & 3 deletions DEPLOYMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ To deploy using your own wallet add the HD Wallet Config to the `hardhat.config.

### Configuration

A configuration file called `graph.config.yml` contains the parameters needed to deploy the contracts. Please edit these params as you see fit.
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.

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

```
yarn deploy -- --graph-config another-graph.config.yml
yarn deploy -- --graph-config another-graph.mainnet.yml
```

Rules:
Expand All @@ -67,7 +67,7 @@ Rules:

Example:

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

### Address book

Expand Down
2 changes: 1 addition & 1 deletion cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ MNEMONIC=
ETHERSCAN_API_KEY=
INFURA_KEY=
ADDRESS_BOOK="addresses.json"
GRAPH_CONFIG=""graph.config.yml""
GRAPH_CONFIG=""config/graph.mainnet.yml""
PROVIDER_URL="http://localhost:8545"
```

Expand Down
8 changes: 6 additions & 2 deletions cli/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,13 @@ function parseAddressBookRef(addressBook: AddressBook, value: string, cli: CLIEn
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function readConfig(path: string): any {
export function readConfig(path: string, retainMetadata = false): any {
const file = fs.readFileSync(path, 'utf8')
return YAML.parse(file)
return retainMetadata ? YAML.parseDocument(file) : YAML.parse(file)
}

export function writeConfig(path: string, data: string): void {
fs.writeFileSync(path, data)
}

export function loadCallParams(
Expand Down
2 changes: 2 additions & 0 deletions cli/contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { BancorFormula } from '../build/types/BancorFormula'
import { IENS } from '../build/types/IENS'
import { IEthereumDIDRegistry } from '../build/types/IEthereumDIDRegistry'
import { GraphGovernance } from '../build/types/GraphGovernance'
import { AllocationExchange } from '../build/types/AllocationExchange'

export interface NetworkContracts {
EpochManager: EpochManager
Expand All @@ -34,6 +35,7 @@ export interface NetworkContracts {
IENS: IENS
IEthereumDIDRegistry: IEthereumDIDRegistry
GraphGovernance: GraphGovernance
AllocationExchange: AllocationExchange
}

export const loadContracts = (
Expand Down
2 changes: 1 addition & 1 deletion cli/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const local = {
mnemonic: 'myth like bonus scare over problem client lizard pioneer submit female collect',
providerUrl: 'http://localhost:8545',
addressBookPath: './addresses.json',
graphConfigPath: './graph.config.yml',
graphConfigPath: './config/graph.mainnet.yml',
accountNumber: '0',
}

Expand Down
40 changes: 20 additions & 20 deletions graph.config.yml → config/graph.mainnet.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
general:
arbitrator: &arbitrator "0xE1FDD398329C6b74C14cf19100316f0826a492d3" # Arbitration Council
governor: &governor "0x48301Fe520f72994d32eAd72E2B6A8447873CF50" # Graph Council
authority: &authority "0x79fd74da4c906509862c8fe93e87a9602e370bc4" # Authority that signs payment vouchers
authority: &authority "0x982D10c56b8BBbD6e09048F5c5f01b43C65D5aE0" # Authority that signs payment vouchers

contracts:
Controller:
Expand Down Expand Up @@ -35,10 +35,10 @@ contracts:
proxy: true
init:
controller: "${{Controller.address}}"
lengthInBlocks: 1108 # 4 hours (in 13 second blocks)
lengthInBlocks: 6646 # length in hours = lengthInBlocks*13/60/60 (~13 second blocks)
GraphToken:
init:
initialSupply: "10000000000000000000000000000" # 10,000,000,000 GRT
initialSupply: "10000000000000000000000000000" # in wei
calls:
- fn: "addMinter"
minter: "${{RewardsManager.address}}"
Expand All @@ -48,18 +48,18 @@ contracts:
controller: "${{Controller.address}}"
bondingCurve: "${{BancorFormula.address}}"
curationTokenMaster: "${{GraphCurationToken.address}}"
reserveRatio: 500000 # 50% (parts per million)
curationTaxPercentage: 10000 # 1% (parts per million)
minimumCurationDeposit: "1000000000000000000" # 1 GRT
reserveRatio: 500000 # in parts per million
curationTaxPercentage: 10000 # in parts per million
minimumCurationDeposit: "1000000000000000000" # in wei
DisputeManager:
proxy: true
init:
controller: "${{Controller.address}}"
arbitrator: *arbitrator
minimumDeposit: "10000000000000000000000" # 10,000 GRT (in wei)
fishermanRewardPercentage: 500000 # 50% (parts per million)
idxSlashingPercentage: 25000 # 2.5% (parts per million)
qrySlashingPercentage: 5000 # 0.5% (parts per million)
minimumDeposit: "10000000000000000000000" # in wei
fishermanRewardPercentage: 500000 # in parts per million
idxSlashingPercentage: 25000 # in parts per million
qrySlashingPercentage: 25000 # in parts per million
GNS:
proxy: true
init:
Expand All @@ -80,19 +80,19 @@ contracts:
proxy: true
init:
controller: "${{Controller.address}}"
minimumIndexerStake: "100000000000000000000000" # 100,000 GRT (in wei)
thawingPeriod: 6646 # 10 days (in blocks)
protocolPercentage: 10000 # 1% (parts per million)
curationPercentage: 100000 # 10% (parts per million)
channelDisputeEpochs: 2 # (in epochs)
maxAllocationEpochs: 6 # Based on epoch length this is 28 days (in epochs)
delegationUnbondingPeriod: 6 # Based on epoch length this is 28 days (in epochs)
delegationRatio: 16 # 16x (delegated stake to indexer stake multiplier)
minimumIndexerStake: "100000000000000000000000" # in wei
thawingPeriod: 186092 # in blocks
protocolPercentage: 10000 # in parts per million
curationPercentage: 100000 # in parts per million
channelDisputeEpochs: 7 # in epochs
maxAllocationEpochs: 28 # in epochs
delegationUnbondingPeriod: 28 # in epochs
delegationRatio: 16 # delegated stake to indexer stake multiplier
rebateAlphaNumerator: 77 # rebateAlphaNumerator / rebateAlphaDenominator
rebateAlphaDenominator: 100 # rebateAlphaNumerator / rebateAlphaDenominator
calls:
- fn: "setDelegationTaxPercentage"
delegationTaxPercentage: 5000 # 0.5% (parts per million)
delegationTaxPercentage: 5000 # parts per million
- fn: "setSlasher"
slasher: "${{DisputeManager.address}}"
allowed: true
Expand All @@ -103,7 +103,7 @@ contracts:
proxy: true
init:
controller: "${{Controller.address}}"
issuanceRate: "1000000012184945188" # 3% annual rate (per block increase of total supply, blocks in a year = 365*60*60*24/13)
issuanceRate: "1000000012184945188" # per block increase of total supply, blocks in a year = 365*60*60*24/13
AllocationExchange:
init:
graphToken: "${{GraphToken.address}}"
Expand Down
114 changes: 114 additions & 0 deletions config/graph.rinkeby.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
general:
arbitrator: &arbitrator "0x87D11BD744b882b7bc5A6b5450cbA8C35D90eb10" # Arbitration Council
governor: &governor "0x1679A1D1caf1252BA43Fb8Fc17ebF914a0C725AE" # Graph Council
authority: &authority "0xe1EC4339019eC9628438F8755f847e3023e4ff9c" # Authority that signs payment vouchers

contracts:
Controller:
calls:
- fn: "setContractProxy"
id: "0xe6876326c1291dfcbbd3864a6816d698cd591defc7aa2153d7f9c4c04016c89f" # keccak256('Curation')
contractAddress: "${{Curation.address}}"
- fn: "setContractProxy"
id: "0x39605a6c26a173774ca666c67ef70cf491880e5d3d6d0ca66ec0a31034f15ea3" # keccak256('GNS')
contractAddress: "${{GNS.address}}"
- fn: "setContractProxy"
id: "0xf942813d07d17b56de9a9afc8de0ced6e8c053bbfdcc87b7badea4ddcf27c307" # keccak256('DisputeManager')
contractAddress: "${{DisputeManager.address}}"
- fn: "setContractProxy"
id: "0xc713c3df6d14cdf946460395d09af88993ee2b948b1a808161494e32c5f67063" # keccak256('EpochManager')
contractAddress: "${{EpochManager.address}}"
- fn: "setContractProxy"
id: "0x966f1e8d8d8014e05f6ec4a57138da9be1f7c5a7f802928a18072f7c53180761" # keccak256('RewardsManager')
contractAddress: "${{RewardsManager.address}}"
- fn: "setContractProxy"
id: "0x1df41cd916959d1163dc8f0671a666ea8a3e434c13e40faef527133b5d167034" # keccak256('Staking')
contractAddress: "${{Staking.address}}"
- fn: "setContractProxy"
id: "0x45fc200c7e4544e457d3c5709bfe0d520442c30bbcbdaede89e8d4a4bbc19247" # keccak256('GraphToken')
contractAddress: "${{GraphToken.address}}"
ServiceRegistry:
proxy: true
init:
controller: "${{Controller.address}}"
EpochManager:
proxy: true
init:
controller: "${{Controller.address}}"
lengthInBlocks: 277 # length in hours = lengthInBlocks*13/60/60 (~13 second blocks)
GraphToken:
init:
initialSupply: "10000000000000000000000000000" # in wei
calls:
- fn: "addMinter"
minter: "${{RewardsManager.address}}"
Curation:
proxy: true
init:
controller: "${{Controller.address}}"
bondingCurve: "${{BancorFormula.address}}"
curationTokenMaster: "${{GraphCurationToken.address}}"
reserveRatio: 500000 # in parts per million
curationTaxPercentage: 10000 # in parts per million
minimumCurationDeposit: "1000000000000000000" # in wei
DisputeManager:
proxy: true
init:
controller: "${{Controller.address}}"
arbitrator: *arbitrator
minimumDeposit: "10000000000000000000000" # in wei
fishermanRewardPercentage: 500000 # in parts per million
idxSlashingPercentage: 20000 # in parts per million
qrySlashingPercentage: 5000 # in parts per million
GNS:
proxy: true
init:
controller: "${{Controller.address}}"
bondingCurve: "${{BancorFormula.address}}"
subgraphNFT: "${{SubgraphNFT.address}}"
calls:
- fn: "approveAll"
SubgraphNFT:
init:
governor: "${{Env.deployer}}"
calls:
- fn: "setTokenDescriptor"
tokenDescriptor: "${{SubgraphNFTDescriptor.address}}"
- fn: "setMinter"
minter: "${{GNS.address}}"
Staking:
proxy: true
init:
controller: "${{Controller.address}}"
minimumIndexerStake: "100000000000000000000000" # in wei
thawingPeriod: 6646 # in blocks
protocolPercentage: 10000 # in parts per million
curationPercentage: 100000 # in parts per million
channelDisputeEpochs: 2 # in epochs
maxAllocationEpochs: 2 # in epochs
delegationUnbondingPeriod: 6 # in epochs
delegationRatio: 16 # delegated stake to indexer stake multiplier
rebateAlphaNumerator: 77 # rebateAlphaNumerator / rebateAlphaDenominator
rebateAlphaDenominator: 100 # rebateAlphaNumerator / rebateAlphaDenominator
calls:
- fn: "setDelegationTaxPercentage"
delegationTaxPercentage: 5000 # parts per million
- fn: "setSlasher"
slasher: "${{DisputeManager.address}}"
allowed: true
- fn: "setAssetHolder"
assetHolder: "${{AllocationExchange.address}}"
allowed: true
RewardsManager:
proxy: true
init:
controller: "${{Controller.address}}"
issuanceRate: "1000000012184945188" # per block increase of total supply, blocks in a year = 365*60*60*24/13
AllocationExchange:
init:
graphToken: "${{GraphToken.address}}"
staking: "${{Staking.address}}"
governor: *governor
authority: *authority
calls:
- fn: "approveAll"
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@
"compile": "hardhat compile",
"deploy": "scripts/predeploy && hardhat migrate",
"deploy-ganache": "yarn deploy -- --force",
"deploy-ganache-manual": "yarn deploy -- --network ganache --force",
"deploy-hardhat": "yarn deploy -- --network hardhat --force",
"deploy-rinkeby": "yarn deploy -- --force --network rinkeby",
"deploy-ganache-manual": "yarn deploy -- --force --network ganache",
"deploy-hardhat": "yarn deploy -- --force --network hardhat",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if --graph-config is not passed? is it storing it in any place by default or just not storing it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will fallback to the CLI's default defined here: https://github.com/graphprotocol/contracts/blob/tmigone/update-config-task/cli/defaults.ts#L8. It currently points to mainnet config file

"deploy-rinkeby": "yarn deploy -- --force --network rinkeby --graph-config config/graph.rinkeby.yml",
"predeploy": "scripts/predeploy",
"test": "scripts/test",
"test:gas": "RUN_EVM=true REPORT_GAS=true scripts/test",
Expand Down
Loading