Skip to content

Commit

Permalink
fix: adjust gre, e2e and configs to account for reservoirs
Browse files Browse the repository at this point in the history
  • Loading branch information
pcarranzav committed Sep 28, 2022
1 parent 53e0a80 commit 559ea00
Show file tree
Hide file tree
Showing 12 changed files with 140 additions and 21 deletions.
4 changes: 4 additions & 0 deletions cli/contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import { L1GraphTokenGateway } from '../build/types/L1GraphTokenGateway'
import { L2GraphToken } from '../build/types/L2GraphToken'
import { L2GraphTokenGateway } from '../build/types/L2GraphTokenGateway'
import { BridgeEscrow } from '../build/types/BridgeEscrow'
import { L1Reservoir } from '../build/types/L1Reservoir'
import { L2Reservoir } from '../build/types/L2Reservoir'

export interface NetworkContracts {
EpochManager: EpochManager
Expand All @@ -49,6 +51,8 @@ export interface NetworkContracts {
BridgeEscrow: BridgeEscrow
L2GraphToken: L2GraphToken
L2GraphTokenGateway: L2GraphTokenGateway
L1Reservoir: L1Reservoir
L2Reservoir: L2Reservoir
}

export const loadAddressBookContract = (
Expand Down
10 changes: 10 additions & 0 deletions config/graph.arbitrum-goerli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ contracts:
- fn: "setContractProxy"
id: "0xd362cac9cb75c10d67bcc0b7eeb0b1ef48bb5420b556c092d4fd7f758816fcf0" # keccak256('GraphTokenGateway')
contractAddress: "${{L2GraphTokenGateway.address}}"
- fn: "setContractProxy"
id: "0x96ba401694892957e25e29c7a1e4171ae9945b5ee36339de79b199a530436e9e" # keccak256('Reservoir')
contractAddress: "${{L2Reservoir.address}}"
- fn: "setPauseGuardian"
pauseGuardian: *pauseGuardian
- fn: "transferOwnership"
Expand Down Expand Up @@ -149,3 +152,10 @@ contracts:
- fn: "syncAllContracts"
- fn: "setPauseGuardian"
pauseGuardian: *pauseGuardian
L2Reservoir:
proxy: true
init:
controller: "${{Controller.address}}"
calls:
- fn: "approveRewardsManager"
- fn: "syncAllContracts"
10 changes: 10 additions & 0 deletions config/graph.arbitrum-localhost.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ contracts:
- fn: "setContractProxy"
id: "0xd362cac9cb75c10d67bcc0b7eeb0b1ef48bb5420b556c092d4fd7f758816fcf0" # keccak256('GraphTokenGateway')
contractAddress: "${{L2GraphTokenGateway.address}}"
- fn: "setContractProxy"
id: "0x96ba401694892957e25e29c7a1e4171ae9945b5ee36339de79b199a530436e9e" # keccak256('Reservoir')
contractAddress: "${{L2Reservoir.address}}"
- fn: "setPauseGuardian"
pauseGuardian: *pauseGuardian
- fn: "transferOwnership"
Expand Down Expand Up @@ -149,3 +152,10 @@ contracts:
- fn: "syncAllContracts"
- fn: "setPauseGuardian"
pauseGuardian: *pauseGuardian
L2Reservoir:
proxy: true
init:
controller: "${{Controller.address}}"
calls:
- fn: "approveRewardsManager"
- fn: "syncAllContracts"
17 changes: 14 additions & 3 deletions config/graph.goerli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ contracts:
- fn: "setContractProxy"
id: "0xd362cac9cb75c10d67bcc0b7eeb0b1ef48bb5420b556c092d4fd7f758816fcf0" # keccak256('GraphTokenGateway')
contractAddress: "${{L1GraphTokenGateway.address}}"
- fn: "setContractProxy"
id: "0x96ba401694892957e25e29c7a1e4171ae9945b5ee36339de79b199a530436e9e" # keccak256('Reservoir')
contractAddress: "${{L1Reservoir.address}}"
- fn: "setPauseGuardian"
pauseGuardian: *pauseGuardian
- fn: "transferOwnership"
Expand All @@ -57,7 +60,7 @@ contracts:
initialSupply: "10000000000000000000000000000" # in wei
calls:
- fn: "addMinter"
minter: "${{RewardsManager.address}}"
minter: "${{L1Reservoir.address}}"
- fn: "renounceMinter"
- fn: "transferOwnership"
owner: *governor
Expand Down Expand Up @@ -131,8 +134,6 @@ contracts:
init:
controller: "${{Controller.address}}"
calls:
- fn: "setIssuanceRate"
issuanceRate: "1000000012184945188" # per block increase of total supply, blocks in a year = 365*60*60*24/13
- fn: "setSubgraphAvailabilityOracle"
subgraphAvailabilityOracle: *availabilityOracle
- fn: "syncAllContracts"
Expand All @@ -158,3 +159,13 @@ contracts:
controller: "${{Controller.address}}"
calls:
- fn: "syncAllContracts"
L1Reservoir:
proxy: true
init:
controller: "${{Controller.address}}"
dripInterval: 50400
calls:
- fn: "approveRewardsManager"
- fn: "initialSnapshot"
pendingRewards: "0"
- fn: "syncAllContracts"
17 changes: 14 additions & 3 deletions config/graph.localhost.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ contracts:
- fn: "setContractProxy"
id: "0xd362cac9cb75c10d67bcc0b7eeb0b1ef48bb5420b556c092d4fd7f758816fcf0" # keccak256('GraphTokenGateway')
contractAddress: "${{L1GraphTokenGateway.address}}"
- fn: "setContractProxy"
id: "0x96ba401694892957e25e29c7a1e4171ae9945b5ee36339de79b199a530436e9e" # keccak256('Reservoir')
contractAddress: "${{L1Reservoir.address}}"
- fn: "setPauseGuardian"
pauseGuardian: *pauseGuardian
- fn: "transferOwnership"
Expand All @@ -57,7 +60,7 @@ contracts:
initialSupply: "10000000000000000000000000000" # in wei
calls:
- fn: "addMinter"
minter: "${{RewardsManager.address}}"
minter: "${{L1Reservoir.address}}"
- fn: "renounceMinter"
- fn: "transferOwnership"
owner: *governor
Expand Down Expand Up @@ -131,8 +134,6 @@ contracts:
init:
controller: "${{Controller.address}}"
calls:
- fn: "setIssuanceRate"
issuanceRate: "1000000012184945188" # per block increase of total supply, blocks in a year = 365*60*60*24/13
- fn: "setSubgraphAvailabilityOracle"
subgraphAvailabilityOracle: *availabilityOracle
- fn: "syncAllContracts"
Expand All @@ -158,3 +159,13 @@ contracts:
controller: "${{Controller.address}}"
calls:
- fn: "syncAllContracts"
L1Reservoir:
proxy: true
init:
controller: "${{Controller.address}}"
dripInterval: 50400
calls:
- fn: "approveRewardsManager"
- fn: "initialSnapshot"
pendingRewards: "0"
- fn: "syncAllContracts"
1 change: 1 addition & 0 deletions config/graph.mainnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,5 @@ contracts:
calls:
- fn: "approveRewardsManager"
- fn: "initialSnapshot"
pendingRewards: "0"
- fn: "syncAllContracts"
11 changes: 8 additions & 3 deletions e2e/deployment/config/l1/graphToken.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import GraphChain from '../../../../gre/helpers/network'

describe('[L1] GraphToken', () => {
const graph = hre.graph()
const { GraphToken, RewardsManager } = graph.contracts
const { GraphToken, L1Reservoir, RewardsManager } = graph.contracts

let unauthorized: SignerWithAddress

Expand All @@ -23,9 +23,14 @@ describe('[L1] GraphToken', () => {
await expect(tx).revertedWith('Only minter can call')
})

it('RewardsManager should be minter', async function () {
it('L1Reservoir should be minter', async function () {
const reservoirIsMinter = await GraphToken.isMinter(L1Reservoir.address)
expect(reservoirIsMinter).eq(true)
})

it('RewardsManager should not be minter', async function () {
const rewardsMgrIsMinter = await GraphToken.isMinter(RewardsManager.address)
expect(rewardsMgrIsMinter).eq(true)
expect(rewardsMgrIsMinter).eq(false)
})
})
})
39 changes: 39 additions & 0 deletions e2e/deployment/config/l1/l1Reservoir.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { expect } from 'chai'
import hre from 'hardhat'
import GraphChain from '../../../../gre/helpers/network'
import { getItemValue } from '../../../../cli/config'

describe('[L1] L1Reservoir configuration', () => {
const graph = hre.graph()
const { graphConfig } = graph
const { L1Reservoir, Controller, GraphToken, RewardsManager } = graph.contracts

before(async function () {
if (GraphChain.isL2(graph.chainId)) this.skip()
})

it('should be controlled by Controller', async function () {
const controller = await L1Reservoir.controller()
expect(controller).eq(Controller.address)
})

it('should have a snapshot of the total supply', async function () {
expect(await L1Reservoir.issuanceBase()).eq(await GraphToken.totalSupply())
})

it('should have issuanceRate set to zero', async function () {
expect(await L1Reservoir.issuanceRate()).eq(0)
})

it('should have dripInterval set from config', async function () {
const value = await L1Reservoir.dripInterval()
const expected = getItemValue(graphConfig, 'contracts/L1Reservoir/init/dripInterval')
expect(value).eq(expected)
})

it('should have RewardsManager approved for the max GRT amount', async function () {
expect(await GraphToken.allowance(L1Reservoir.address, RewardsManager.address)).eq(
hre.ethers.constants.MaxUint256,
)
})
})
5 changes: 0 additions & 5 deletions e2e/deployment/config/l1/rewardsManager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,4 @@ describe('[L1] RewardsManager configuration', () => {
before(async function () {
if (GraphChain.isL2(graph.chainId)) this.skip()
})

it('issuanceRate should match "issuanceRate" in the config file', async function () {
const value = await RewardsManager.issuanceRate()
expect(value).eq('1000000012184945188') // hardcoded as it's set with a function call rather than init parameter
})
})
9 changes: 7 additions & 2 deletions e2e/deployment/config/l2/l2GraphToken.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import GraphChain from '../../../../gre/helpers/network'

describe('[L2] L2GraphToken', () => {
const graph = hre.graph()
const { L2GraphToken, RewardsManager } = graph.contracts
const { L2GraphToken, RewardsManager, L2Reservoir } = graph.contracts

let unauthorized: SignerWithAddress

Expand Down Expand Up @@ -36,9 +36,14 @@ describe('[L2] L2GraphToken', () => {
await expect(tx).revertedWith('Only Governor can call')
})

it('RewardsManager should not be minter (for now)', async function () {
it('RewardsManager should not be minter', async function () {
const rewardsMgrIsMinter = await L2GraphToken.isMinter(RewardsManager.address)
expect(rewardsMgrIsMinter).eq(false)
})

it('L2Reservoir should not be minter', async function () {
const reservoirIsMinter = await L2GraphToken.isMinter(L2Reservoir.address)
expect(reservoirIsMinter).eq(false)
})
})
})
33 changes: 33 additions & 0 deletions e2e/deployment/config/l2/l2Reservoir.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { expect } from 'chai'
import hre from 'hardhat'
import GraphChain from '../../../../gre/helpers/network'
import { getItemValue } from '../../../../cli/config'

describe('[L2] L2Reservoir configuration', () => {
const graph = hre.graph()
const { graphConfig } = graph
const { L2Reservoir, Controller, GraphToken, RewardsManager } = graph.contracts

before(async function () {
if (GraphChain.isL1(graph.chainId)) this.skip()
})

it('should be controlled by Controller', async function () {
const controller = await L2Reservoir.controller()
expect(controller).eq(Controller.address)
})

it('should have issuanceBase set to zero', async function () {
expect(await L2Reservoir.issuanceBase()).eq(0)
})

it('should have issuanceRate set to zero', async function () {
expect(await L2Reservoir.issuanceRate()).eq(0)
})

it('should have RewardsManager approved for the max GRT amount', async function () {
expect(await GraphToken.allowance(L2Reservoir.address, RewardsManager.address)).eq(
hre.ethers.constants.MaxUint256,
)
})
})
5 changes: 0 additions & 5 deletions e2e/deployment/config/l2/rewardsManager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,4 @@ describe('[L2] RewardsManager configuration', () => {
before(async function () {
if (GraphChain.isL1(graph.chainId)) this.skip()
})

it('issuanceRate should be zero', async function () {
const value = await RewardsManager.issuanceRate()
expect(value).eq('0')
})
})

0 comments on commit 559ea00

Please sign in to comment.