Skip to content

Commit e7b02ae

Browse files
committed
feat: ensure ignition deploy script handles contract ownership
Signed-off-by: Tomás Migone <[email protected]>
1 parent e8e2e9f commit e7b02ae

File tree

6 files changed

+31
-14
lines changed

6 files changed

+31
-14
lines changed

packages/horizon/ignition/configs/horizon.default.json5

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
{
22
"$global": {
3-
"governor": "0xFFcf8FDEE72ac11b5c542428B35EEF5769C409f0",
43
"pauseGuardian": "0x95cED938F7991cd0dFcb48F0a06a40FA1aF46EBC",
5-
"subgraphAvailabilityOracle": "0xd03ea8624C8C5987235048901fB614fDcA89b117",
64
// Placeholder address for a standalone Horizon deployment, see README.md for more details
75
"subgraphServiceAddress": "0x0000000000000000000000000000000000000000"
86
},
97
"RewardsManager": {
8+
"subgraphAvailabilityOracle": "0xd03ea8624C8C5987235048901fB614fDcA89b117",
109
"issuancePerBlock": "114155251141552511415n"
1110
},
1211
"EpochManager": {

packages/horizon/ignition/modules/core/core.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ import TAPCollectorModule, { MigrateTAPCollectorModule } from './TAPCollector'
77

88
export default buildModule('GraphHorizon_Core', (m) => {
99
const { HorizonStaking } = m.useModule(HorizonStakingModule)
10-
const { GraphPayments } = m.useModule(GraphPaymentsModule)
11-
const { PaymentsEscrow } = m.useModule(PaymentsEscrowModule)
10+
const { GraphPayments, GraphPaymentsProxyAdmin } = m.useModule(GraphPaymentsModule)
11+
const { PaymentsEscrow, PaymentsEscrowProxyAdmin } = m.useModule(PaymentsEscrowModule)
1212
const { TAPCollector } = m.useModule(TAPCollectorModule)
1313

14-
return { HorizonStaking, GraphPayments, PaymentsEscrow, TAPCollector }
14+
return { HorizonStaking, GraphPayments, PaymentsEscrow, TAPCollector, GraphPaymentsProxyAdmin, PaymentsEscrowProxyAdmin }
1515
})
1616

1717
export const MigrateHorizonCoreModule = buildModule('GraphHorizon_Core', (m) => {

packages/horizon/ignition/modules/deploy.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,23 @@ export default buildModule('GraphHorizon_Deploy', (m) => {
1818
GraphPayments,
1919
PaymentsEscrow,
2020
TAPCollector,
21+
GraphPaymentsProxyAdmin,
22+
PaymentsEscrowProxyAdmin,
2123
} = m.useModule(GraphHorizonCoreModule)
2224

25+
const governor = m.getAccount(1)
26+
27+
// Accept ownership of Graph Governed based contracts
28+
// BUG?: acceptOwnership should be called after everything in GraphHorizonCoreModule and GraphPeripheryModule is resolved
29+
// but it seems that it's not waiting for interal calls. Waiting on HorizonStaking seems to fix the issue for some reason
30+
// Removing HorizonStaking from the after list will trigger the bug
31+
m.call(Controller, 'acceptOwnership', [], { from: governor, after: [GraphPeripheryModule, GraphHorizonCoreModule, HorizonStaking] })
32+
m.call(GraphProxyAdmin, 'acceptOwnership', [], { from: governor, after: [GraphPeripheryModule, GraphHorizonCoreModule, HorizonStaking] })
33+
34+
// Transfer ownership of TransparentUpgradeableProxy based contracts
35+
m.call(GraphPaymentsProxyAdmin, 'transferOwnership', [governor], { after: [GraphHorizonCoreModule, HorizonStaking] })
36+
m.call(PaymentsEscrowProxyAdmin, 'transferOwnership', [governor], { after: [GraphHorizonCoreModule, HorizonStaking] })
37+
2338
return {
2439
Controller,
2540
L2Curation,

packages/horizon/ignition/modules/periphery/Controller.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ import { MigrateGraphProxyAdminModule } from './GraphProxyAdmin'
77
import ControllerArtifact from '@graphprotocol/contracts/build/contracts/contracts/governance/Controller.sol/Controller.json'
88

99
export default buildModule('Controller', (m) => {
10-
const governor = m.getParameter('governor')
10+
const governor = m.getAccount(1)
1111
const pauseGuardian = m.getParameter('pauseGuardian')
1212

1313
const Controller = m.contract('Controller', ControllerArtifact)
1414
m.call(Controller, 'setPauseGuardian', [pauseGuardian])
15-
m.call(Controller, 'transferOwnership', [governor])
1615
m.call(Controller, 'setPaused', [false])
16+
m.call(Controller, 'transferOwnership', [governor])
1717

1818
return { Controller }
1919
})

packages/horizon/ignition/modules/periphery/GraphProxyAdmin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { buildModule } from '@nomicfoundation/hardhat-ignition/modules'
33
import GraphProxyAdminArtifact from '@graphprotocol/contracts/build/contracts/contracts/upgrades/GraphProxyAdmin.sol/GraphProxyAdmin.json'
44

55
export default buildModule('GraphProxyAdmin', (m) => {
6-
const governor = m.getParameter('governor')
6+
const governor = m.getAccount(1)
77

88
const GraphProxyAdmin = m.contract('GraphProxyAdmin', GraphProxyAdminArtifact)
99
m.call(GraphProxyAdmin, 'transferOwnership', [governor])

packages/horizon/ignition/modules/periphery/GraphToken.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export default buildModule('L2GraphToken', (m) => {
1313
const { GraphTokenGateway } = m.useModule(GraphTokenGatewayModule)
1414

1515
const deployer = m.getAccount(0)
16-
const governor = m.getParameter('governor')
16+
const governor = m.getAccount(1)
1717
const initialSupply = m.getParameter('initialSupply')
1818

1919
const GraphToken = deployWithGraphProxy(m, GraphProxyAdmin, {
@@ -22,11 +22,14 @@ export default buildModule('L2GraphToken', (m) => {
2222
initArgs: [deployer],
2323
})
2424

25-
m.call(GraphToken, 'mint', [deployer, initialSupply])
26-
m.call(GraphToken, 'renounceMinter', [])
27-
m.call(GraphToken, 'addMinter', [RewardsManager], { id: 'addMinterRewardsManager' })
28-
m.call(GraphToken, 'addMinter', [GraphTokenGateway], { id: 'addMinterGateway' })
29-
m.call(GraphToken, 'transferOwnership', [governor])
25+
const mintCall = m.call(GraphToken, 'mint', [deployer, initialSupply])
26+
const renounceMinterCall = m.call(GraphToken, 'renounceMinter', [])
27+
const addMinterRewardsManagerCall = m.call(GraphToken, 'addMinter', [RewardsManager], { id: 'addMinterRewardsManager' })
28+
const addMinterGatewayCall = m.call(GraphToken, 'addMinter', [GraphTokenGateway], { id: 'addMinterGateway' })
29+
30+
// No further calls are needed so we can transfer ownership now
31+
const transferOwnershipCall = m.call(GraphToken, 'transferOwnership', [governor], { after: [mintCall, renounceMinterCall, addMinterRewardsManagerCall, addMinterGatewayCall] })
32+
m.call(GraphToken, 'acceptOwnership', [], { from: governor, after: [transferOwnershipCall] })
3033

3134
return { GraphToken }
3235
})

0 commit comments

Comments
 (0)