Skip to content

Commit

Permalink
chore: refactor config files naming
Browse files Browse the repository at this point in the history
Signed-off-by: Tomás Migone <tomas@edgeandnode.com>
  • Loading branch information
tmigone committed Feb 19, 2025
1 parent 5e09533 commit 1f065e4
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 10 deletions.
4 changes: 2 additions & 2 deletions packages/hardhat-graph-protocol/src/sdk/ignition/ignition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import path from 'path'

import type { AddressBook } from '../address-book'

export function loadConfig(configPath: string, prefix: string, networkName: string): any {
export function loadConfig(configPath: string, prefix: string, configName: string): any {
const configFileCandidates = [
path.resolve(process.cwd(), configPath, `${prefix}.${networkName}.json5`),
path.resolve(process.cwd(), configPath, `${prefix}.${configName}.json5`),
path.resolve(process.cwd(), configPath, `${prefix}.default.json5`),
]

Expand Down
8 changes: 5 additions & 3 deletions packages/horizon/tasks/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ import type { HardhatRuntimeEnvironment } from 'hardhat/types'
import DeployModule from '../ignition/modules/deploy'

task('deploy:protocol', 'Deploy a new version of the Graph Protocol Horizon contracts - no data services deployed')
.setAction(async (_, hre: HardhatRuntimeEnvironment) => {
.addOptionalParam('horizonConfig', 'Name of the Horizon configuration file to use. Format is "protocol.<name>.json5", file must be in the "ignition/configs/" directory. Defaults to network name.', undefined, types.string)
.setAction(async (args, hre: HardhatRuntimeEnvironment) => {
const graph = hre.graph()

// Load configuration for the deployment
console.log('\n========== ⚙️ Deployment configuration ==========')
const { config: HorizonConfig, file } = IgnitionHelper.loadConfig('./ignition/configs/', 'horizon', hre.network.name)
const { config: HorizonConfig, file } = IgnitionHelper.loadConfig('./ignition/configs/', 'protocol', args.horizonConfig ?? hre.network.name)
console.log(`Loaded migration configuration from ${file}`)

// Display the deployer -- this also triggers the secure accounts prompt if being used
Expand Down Expand Up @@ -44,6 +45,7 @@ task('deploy:protocol', 'Deploy a new version of the Graph Protocol Horizon cont
})

task('deploy:migrate', 'Upgrade an existing version of the Graph Protocol v1 to Horizon - no data services deployed')
.addOptionalParam('horizonConfig', 'Name of the Horizon configuration file to use. Format is "migrate.<name>.json5", file must be in the "ignition/configs/" directory. Defaults to network name.', undefined, types.string)
.addOptionalParam('step', 'Migration step to run (1, 2, 3 or 4)', undefined, types.int)
.addFlag('patchConfig', 'Patch configuration file using address book values - does not save changes')
.setAction(async (args, hre: HardhatRuntimeEnvironment) => {
Expand All @@ -66,7 +68,7 @@ task('deploy:migrate', 'Upgrade an existing version of the Graph Protocol v1 to

// Load configuration for the migration
console.log('\n========== ⚙️ Deployment configuration ==========')
const { config: HorizonMigrateConfig, file } = IgnitionHelper.loadConfig('./ignition/configs/', 'horizon-migrate', `horizon-${hre.network.name}`)
const { config: HorizonMigrateConfig, file } = IgnitionHelper.loadConfig('./ignition/configs/', 'migrate', args.horizonConfig ?? hre.network.name)
console.log(`Loaded migration configuration from ${file}`)

// Display the deployer -- this also triggers the secure accounts prompt if being used
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

{
"$global": {
"governor": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
"arbitrator": "0xFFcf8FDEE72ac11b5c542428B35EEF5769C409f0",

// Must be set for step 2 of the deployment
"controllerAddress": "",
"disputeManagerProxyAddress": "",
"curationAddress": "",
"curationImplementationAddress": ""
},
"DisputeManager": {
"disputePeriod": 2419200,
"disputeDeposit": "10000000000000000000000n",
"fishermanRewardCut": 500000,
"maxSlashingCut": 1000000,

// Must be set for step 2 of the deployment
"disputeManagerProxyAdminAddress": "",
},
"SubgraphService": {
"minimumProvisionTokens": "100000000000000000000000n",
"maximumDelegationRatio": 16,
"stakeToFeesRatio": 2,

// Must be set for step 2 of the deployment
"subgraphServiceProxyAddress": "",
"subgraphServiceProxyAdminAddress": "",
"graphTallyCollectorAddress": ""
}
}
11 changes: 7 additions & 4 deletions packages/subgraph-service/tasks/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ import HorizonModule from '@graphprotocol/horizon/ignition/modules/deploy'
// - Deploy Horizon
// - Deploy SubgraphService and DisputeManager implementations
task('deploy:protocol', 'Deploy a new version of the Graph Protocol Horizon contracts - with Subgraph Service')
.setAction(async (_, hre: HardhatRuntimeEnvironment) => {
.addOptionalParam('subgraphServiceConfig', 'Name of the Subgraph Service configuration file to use. Format is "protocol.<name>.json5", file must be in the "ignition/configs/" directory. Defaults to network name.', undefined, types.string)
.addOptionalParam('horizonConfig', 'Name of the Horizon configuration file to use. Format is "protocol.<name>.json5", file must be in the "ignition/configs/" directory in the horizon package. Defaults to network name.', undefined, types.string)
.setAction(async (args, hre: HardhatRuntimeEnvironment) => {
const graph = hre.graph()

// Load configuration files for the deployment
console.log('\n========== ⚙️ Deployment configuration ==========')
const { config: HorizonConfig, file: horizonFile } = IgnitionHelper.loadConfig('./node_modules/@graphprotocol/horizon/ignition/configs', 'horizon', hre.network.name)
const { config: SubgraphServiceConfig, file: subgraphServiceFile } = IgnitionHelper.loadConfig('./ignition/configs/', 'subgraph-service', hre.network.name)
const { config: HorizonConfig, file: horizonFile } = IgnitionHelper.loadConfig('./node_modules/@graphprotocol/horizon/ignition/configs', 'protocol', args.horizonConfig ?? hre.network.name)
const { config: SubgraphServiceConfig, file: subgraphServiceFile } = IgnitionHelper.loadConfig('./ignition/configs/', 'protocol', args.subgraphServiceConfig ?? hre.network.name)
console.log(`Loaded Horizon migration configuration from ${horizonFile}`)
console.log(`Loaded Subgraph Service migration configuration from ${subgraphServiceFile}`)

Expand Down Expand Up @@ -92,6 +94,7 @@ task('deploy:protocol', 'Deploy a new version of the Graph Protocol Horizon cont

task('deploy:migrate', 'Deploy the Subgraph Service on an existing Horizon deployment')
.addOptionalParam('step', 'Migration step to run (1, 2)', undefined, types.int)
.addOptionalParam('subgraphServiceConfig', 'Name of the Subgraph Service configuration file to use. Format is "migrate.<name>.json5", file must be in the "ignition/configs/" directory. Defaults to network name.', undefined, types.string)
.addFlag('patchConfig', 'Patch configuration file using address book values - does not save changes')
.setAction(async (args, hre: HardhatRuntimeEnvironment) => {
// Task parameters
Expand All @@ -113,7 +116,7 @@ task('deploy:migrate', 'Deploy the Subgraph Service on an existing Horizon deplo

// Load configuration for the migration
console.log('\n========== ⚙️ Deployment configuration ==========')
const { config: SubgraphServiceMigrateConfig, file } = IgnitionHelper.loadConfig('./ignition/configs/', 'subgraph-service-migrate', `subgraph-service-${hre.network.name}`)
const { config: SubgraphServiceMigrateConfig, file } = IgnitionHelper.loadConfig('./ignition/configs/', 'migrate', args.subgraphServiceConfig ?? hre.network.name)
console.log(`Loaded migration configuration from ${file}`)

// Display the deployer -- this also triggers the secure accounts prompt if being used
Expand Down
1 change: 0 additions & 1 deletion tsconfig.json

This file was deleted.

0 comments on commit 1f065e4

Please sign in to comment.