Skip to content

Commit 6db8d05

Browse files
committed
fix: couple fixes for migration scripts
Signed-off-by: Tomás Migone <[email protected]>
1 parent f2b120a commit 6db8d05

File tree

13 files changed

+116
-52
lines changed

13 files changed

+116
-52
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"rewardsManagerAddress": "0x1F49caE7669086c8ba53CC35d1E9f80176d67E79",
1414
"curationAddress": "0xDe761f075200E75485F4358978FB4d1dC8644FD5",
1515

16-
// Must be set for step 4 of the migration
16+
// Must be set for step 3 and 4 of the migration
1717
"subgraphServiceAddress": "",
1818

1919
// Parameters

packages/horizon/tasks/deploy.ts

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ task('deploy:migrate', 'Upgrade an existing version of the Graph Protocol v1 to
8888
MigrationModule,
8989
{
9090
displayUi: true,
91-
parameters: patchConfig ? _patchStepConfig(step, HorizonMigrateConfig, graph.horizon!.addressBook) : HorizonMigrateConfig,
91+
parameters: patchConfig ? _patchStepConfig(step, HorizonMigrateConfig, graph.horizon!.addressBook, graph.subgraphService!.addressBook) : HorizonMigrateConfig,
9292
deploymentId: `horizon-${hre.network.name}`,
9393
})
9494

@@ -103,25 +103,45 @@ task('deploy:migrate', 'Upgrade an existing version of the Graph Protocol v1 to
103103
// This function patches the Ignition configuration object using an address book to fill in the gaps
104104
// The resulting configuration is not saved back to the configuration file
105105
// eslint-disable-next-line @typescript-eslint/no-explicit-any
106-
function _patchStepConfig<ChainId extends number, ContractName extends string>(step: number, config: any, addressBook: AddressBook<ChainId, ContractName>): any {
106+
function _patchStepConfig<ChainId extends number, ContractName extends string, HorizonContractName extends string>(
107+
step: number,
108+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
109+
config: any,
110+
horizonAddressBook: AddressBook<ChainId, ContractName>,
111+
subgraphServiceAddressBook: AddressBook<ChainId, HorizonContractName>,
112+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
113+
): any {
107114
let patchedConfig = config
108115

109116
switch (step) {
110117
case 2:
111-
const GraphPayments = addressBook.getEntry('GraphPayments')
112-
const PaymentsEscrow = addressBook.getEntry('PaymentsEscrow')
118+
const GraphPayments = horizonAddressBook.getEntry('GraphPayments')
119+
const PaymentsEscrow = horizonAddressBook.getEntry('PaymentsEscrow')
113120
patchedConfig = IgnitionHelper.patchConfig(config, {
114121
HorizonProxiesGovernor: {
115122
graphPaymentsAddress: GraphPayments.address,
116123
paymentsEscrowAddress: PaymentsEscrow.address,
117124
},
118125
})
119126
break
127+
case 3:
128+
const SubgraphService3 = subgraphServiceAddressBook.getEntry('SubgraphService')
129+
patchedConfig = IgnitionHelper.patchConfig(patchedConfig, {
130+
$global: {
131+
subgraphServiceAddress: SubgraphService3.address,
132+
},
133+
})
134+
console.log(patchedConfig)
135+
break
120136
case 4:
121-
const HorizonStaking = addressBook.getEntry('HorizonStaking')
122-
const L2Curation = addressBook.getEntry('L2Curation')
123-
const RewardsManager = addressBook.getEntry('RewardsManager')
137+
const HorizonStaking = horizonAddressBook.getEntry('HorizonStaking')
138+
const L2Curation = horizonAddressBook.getEntry('L2Curation')
139+
const RewardsManager = horizonAddressBook.getEntry('RewardsManager')
140+
const SubgraphService4 = subgraphServiceAddressBook.getEntry('SubgraphService')
124141
patchedConfig = IgnitionHelper.patchConfig(patchedConfig, {
142+
$global: {
143+
subgraphServiceAddress: SubgraphService4.address,
144+
},
125145
HorizonStakingGovernor: {
126146
horizonStakingImplementationAddress: HorizonStaking.implementation,
127147
},

packages/subgraph-service/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ cd ../
4343
cd horizon && npx hardhat deploy:migrate --network hardhat --step 1 && cd ..
4444
cd subgraph-service && npx hardhat deploy:migrate --network hardhat --step 1 && cd ..
4545
cd horizon && npx hardhat deploy:migrate --network hardhat --step 2 && cd .. # Run with governor. Optionally add --patch-config
46-
cd horizon && npx hardhat deploy:migrate --network hardhat --step 3 && cd ..
46+
cd horizon && npx hardhat deploy:migrate --network hardhat --step 3 && cd .. # Optionally add --patch-config
4747
cd subgraph-service && npx hardhat deploy:migrate --network hardhat --step 2 && cd .. # Optionally add --patch-config
4848
cd horizon && npx hardhat deploy:migrate --network hardhat --step 4 && cd .. # Run with governor. Optionally add --patch-config
4949
```

packages/subgraph-service/ignition/configs/subgraph-service.default.json5

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55

66
// Must be set for step 2 of the deployment
77
"controllerAddress": "",
8-
"disputeManagerProxyAddress": ""
8+
"disputeManagerProxyAddress": "",
9+
"curationAddress": "",
10+
"curationImplementationAddress": ""
911
},
1012
"DisputeManager": {
1113
"disputePeriod": 2419200,
@@ -24,7 +26,6 @@
2426
// Must be set for step 2 of the deployment
2527
"subgraphServiceProxyAddress": "",
2628
"subgraphServiceProxyAdminAddress": "",
27-
"curationAddress": "",
2829
"graphTallyCollectorAddress": ""
2930
}
3031
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { buildModule } from '@nomicfoundation/ignition-core'
2+
3+
import CurationArtifact from '@graphprotocol/contracts/build/contracts/contracts/l2/curation/L2Curation.sol/L2Curation.json'
4+
5+
// Note that this module is a no-op, we only run it to get curation addresses into the address book.
6+
// Curation deployment should be managed by ignition scripts in subgraph-service package however
7+
// due to tight coupling with HorizonStakingExtension contract it's easier to do it on the horizon package.
8+
// Once the transition period is over we can migrate it.
9+
export default buildModule('L2Curation', (m) => {
10+
const curationAddress = m.getParameter('curationAddress')
11+
const curationImplementationAddress = m.getParameter('curationImplementationAddress')
12+
13+
const L2Curation = m.contractAt('L2Curation', CurationArtifact, curationAddress)
14+
const L2CurationImplementation = m.contractAt('L2CurationImplementation', CurationArtifact, curationImplementationAddress)
15+
16+
return { L2Curation, L2CurationImplementation }
17+
})

packages/subgraph-service/ignition/modules/DisputeManager.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export default buildModule('DisputeManager', (m) => {
4545
m.call(DisputeManagerProxyAdmin, 'transferOwnership', [governor], { after: [DisputeManager] })
4646

4747
return {
48-
Transparent_Proxy_DisputeManager: DisputeManager,
49-
Implementation_DisputeManager: DisputeManagerImplementation,
48+
DisputeManager,
49+
DisputeManagerImplementation,
5050
}
5151
})

packages/subgraph-service/ignition/modules/Proxies.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ export default buildModule('SubgraphServiceProxies', (m) => {
2222
})
2323

2424
return {
25-
Transparent_Proxy_SubgraphService: SubgraphServiceProxy,
26-
Transparent_ProxyAdmin_SubgraphService: SubgraphServiceProxyAdmin,
27-
Transparent_Proxy_DisputeManager: DisputeManagerProxy,
28-
Transparent_ProxyAdmin_DisputeManager: DisputeManagerProxyAdmin,
25+
SubgraphServiceProxy,
26+
SubgraphServiceProxyAdmin,
27+
DisputeManagerProxy,
28+
DisputeManagerProxyAdmin,
2929
}
3030
})

packages/subgraph-service/ignition/modules/SubgraphService.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export default buildModule('SubgraphService', (m) => {
4444
m.call(SubgraphServiceProxyAdmin, 'transferOwnership', [governor], { after: [SubgraphService] })
4545

4646
return {
47-
Transparent_Proxy_SubgraphService: SubgraphService,
48-
Implementation_SubgraphService: SubgraphServiceImplementation,
47+
SubgraphService,
48+
SubgraphServiceImplementation,
4949
}
5050
})
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { buildModule } from '@nomicfoundation/hardhat-ignition/modules'
2+
3+
import ProxiesModule from '../Proxies'
4+
5+
export default buildModule('SubgraphService_Deploy_1', (m) => {
6+
const {
7+
SubgraphServiceProxy,
8+
SubgraphServiceProxyAdmin,
9+
DisputeManagerProxy,
10+
DisputeManagerProxyAdmin,
11+
} = m.useModule(ProxiesModule)
12+
13+
return {
14+
Transparent_Proxy_SubgraphService: SubgraphServiceProxy,
15+
Transparent_ProxyAdmin_SubgraphService: SubgraphServiceProxyAdmin,
16+
Transparent_Proxy_DisputeManager: DisputeManagerProxy,
17+
Transparent_ProxyAdmin_DisputeManager: DisputeManagerProxyAdmin,
18+
}
19+
})
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { buildModule } from '@nomicfoundation/hardhat-ignition/modules'
2+
3+
import CurationModule from '../Curation'
4+
import DisputeManagerModule from '../DisputeManager'
5+
import SubgraphServiceModule from '../SubgraphService'
6+
7+
export default buildModule('SubgraphService_Deploy_2', (m) => {
8+
const { DisputeManager, DisputeManagerImplementation } = m.useModule(DisputeManagerModule)
9+
const { SubgraphService, SubgraphServiceImplementation } = m.useModule(SubgraphServiceModule)
10+
const { L2Curation, L2CurationImplementation } = m.useModule(CurationModule)
11+
return {
12+
Transparent_Proxy_DisputeManager: DisputeManager,
13+
Implementation_DisputeManager: DisputeManagerImplementation,
14+
Transparent_Proxy_SubgraphService: SubgraphService,
15+
Implementation_SubgraphService: SubgraphServiceImplementation,
16+
Graph_Proxy_L2Curation: L2Curation,
17+
Implementation_L2Curation: L2CurationImplementation,
18+
}
19+
})

0 commit comments

Comments
 (0)