Skip to content

Commit

Permalink
chore: update ignition to v0.15.9
Browse files Browse the repository at this point in the history
Signed-off-by: Tomás Migone <[email protected]>
  • Loading branch information
tmigone committed Jan 14, 2025
1 parent 1d097de commit 3e4f2bc
Show file tree
Hide file tree
Showing 12 changed files with 229 additions and 120 deletions.
6 changes: 3 additions & 3 deletions packages/horizon/ignition/modules/core/GraphPayments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import GraphPaymentsArtifact from '../../../build/contracts/contracts/payments/G

// TODO: transfer ownership of ProxyAdmin???
export default buildModule('GraphPayments', (m) => {
const { Controller, PeripheryRegistered } = m.useModule(GraphPeripheryModule)
const { GraphPaymentsProxyAdmin, GraphPaymentsProxy, HorizonRegistered } = m.useModule(HorizonProxiesModule)
const { Controller } = m.useModule(GraphPeripheryModule)
const { GraphPaymentsProxyAdmin, GraphPaymentsProxy } = m.useModule(HorizonProxiesModule)

const protocolPaymentCut = m.getParameter('protocolPaymentCut')

Expand All @@ -17,7 +17,7 @@ export default buildModule('GraphPayments', (m) => {
GraphPaymentsArtifact,
[Controller, protocolPaymentCut],
{
after: [PeripheryRegistered, HorizonRegistered],
after: [GraphPeripheryModule, HorizonProxiesModule],
},
)

Expand Down
25 changes: 7 additions & 18 deletions packages/horizon/ignition/modules/core/HorizonProxies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,27 @@ import { ethers } from 'ethers'
import GraphPeripheryModule from '../periphery'
import GraphProxyAdminModule from '../periphery/GraphProxyAdmin'

import DummyArtifact from '../../../build/contracts/contracts/mocks/Dummy.sol/Dummy.json'
import GraphProxyArtifact from '@graphprotocol/contracts/build/contracts/contracts/upgrades/GraphProxy.sol/GraphProxy.json'

const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000'

// HorizonStaking, GraphPayments and PaymentsEscrow use GraphDirectory but they also in the directory.
// So we need to deploy their proxies, register them in the controller before being able to deploy the implementations
export default buildModule('HorizonProxies', (m) => {
const { Controller, PeripheryRegistered } = m.useModule(GraphPeripheryModule)
const { Controller } = m.useModule(GraphPeripheryModule)
const { GraphProxyAdmin } = m.useModule(GraphProxyAdminModule)

// Deploy HorizonStaking proxy without an implementation
const HorizonStakingProxy = m.contract('GraphProxy', GraphProxyArtifact, [ZERO_ADDRESS, GraphProxyAdmin], { after: [PeripheryRegistered], id: 'GraphProxy_HorizonStaking' })
const HorizonStakingProxy = m.contract('GraphProxy', GraphProxyArtifact, [ZERO_ADDRESS, GraphProxyAdmin], { after: [], id: 'GraphProxy_HorizonStaking' })

// Deploy proxies for payments contracts using OZ TransparentUpgradeableProxy
const { Proxy: GraphPaymentsProxy, ProxyAdmin: GraphPaymentsProxyAdmin } = deployWithOZProxy(m, 'GraphPayments')
const { Proxy: PaymentsEscrowProxy, ProxyAdmin: PaymentsEscrowProxyAdmin } = deployWithOZProxy(m, 'PaymentsEscrow')

// Register the proxies in the controller
const setProxyHorizonStaking = m.call(Controller, 'setContractProxy', [ethers.keccak256(ethers.toUtf8Bytes('Staking')), HorizonStakingProxy], { id: 'setContractProxy_HorizonStaking' })
const setProxyGraphPayments = m.call(Controller, 'setContractProxy', [ethers.keccak256(ethers.toUtf8Bytes('GraphPayments')), GraphPaymentsProxy], { id: 'setContractProxy_GraphPayments' })
const setProxyPaymentsEscrow = m.call(Controller, 'setContractProxy', [ethers.keccak256(ethers.toUtf8Bytes('PaymentsEscrow')), PaymentsEscrowProxy], { id: 'setContractProxy_PaymentsEscrow' })

// Deploy dummy contract to signal that all periphery contracts are registered
const HorizonRegistered = m.contract('Dummy', DummyArtifact, [], {
id: 'RegisteredDummy',
after: [
setProxyHorizonStaking,
setProxyGraphPayments,
setProxyPaymentsEscrow,
],
})

return { HorizonStakingProxy, GraphPaymentsProxy, PaymentsEscrowProxy, HorizonRegistered, GraphPaymentsProxyAdmin, PaymentsEscrowProxyAdmin }
m.call(Controller, 'setContractProxy', [ethers.keccak256(ethers.toUtf8Bytes('Staking')), HorizonStakingProxy], { id: 'setContractProxy_HorizonStaking' })
m.call(Controller, 'setContractProxy', [ethers.keccak256(ethers.toUtf8Bytes('GraphPayments')), GraphPaymentsProxy], { id: 'setContractProxy_GraphPayments' })
m.call(Controller, 'setContractProxy', [ethers.keccak256(ethers.toUtf8Bytes('PaymentsEscrow')), PaymentsEscrowProxy], { id: 'setContractProxy_PaymentsEscrow' })

return { HorizonStakingProxy, GraphPaymentsProxy, PaymentsEscrowProxy, GraphPaymentsProxyAdmin, PaymentsEscrowProxyAdmin }
})
6 changes: 3 additions & 3 deletions packages/horizon/ignition/modules/core/HorizonStaking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import HorizonStakingExtensionModule from './HorizonStakingExtension'
import HorizonStakingArtifact from '../../../build/contracts/contracts/staking/HorizonStaking.sol/HorizonStaking.json'

export default buildModule('HorizonStaking', (m) => {
const { Controller, GraphProxyAdmin, PeripheryRegistered } = m.useModule(GraphPeripheryModule)
const { HorizonStakingProxy, HorizonRegistered } = m.useModule(HorizonProxiesModule)
const { Controller, GraphProxyAdmin } = m.useModule(GraphPeripheryModule)
const { HorizonStakingProxy } = m.useModule(HorizonProxiesModule)
const { HorizonStakingExtension } = m.useModule(HorizonStakingExtensionModule)

const subgraphServiceAddress = m.getParameter('subgraphServiceAddress')
Expand All @@ -22,7 +22,7 @@ export default buildModule('HorizonStaking', (m) => {
subgraphServiceAddress,
],
{
after: [PeripheryRegistered, HorizonRegistered],
after: [GraphPeripheryModule, HorizonProxiesModule],
},
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import ExponentialRebatesArtifact from '../../../build/contracts/contracts/staki
import HorizonStakingExtensionArtifact from '../../../build/contracts/contracts/staking/HorizonStakingExtension.sol/HorizonStakingExtension.json'

export default buildModule('HorizonStakingExtension', (m) => {
const { Controller, PeripheryRegistered } = m.useModule(GraphPeripheryModule)
const { HorizonRegistered } = m.useModule(HorizonProxiesModule)
const { Controller } = m.useModule(GraphPeripheryModule)

const subgraphServiceAddress = m.getParameter('subgraphServiceAddress')

Expand All @@ -19,7 +18,7 @@ export default buildModule('HorizonStakingExtension', (m) => {
libraries: {
ExponentialRebates: ExponentialRebates,
},
after: [PeripheryRegistered, HorizonRegistered],
after: [GraphPeripheryModule, HorizonProxiesModule],
})

return { HorizonStakingExtension }
Expand Down
6 changes: 3 additions & 3 deletions packages/horizon/ignition/modules/core/PaymentsEscrow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import PaymentsEscrowArtifact from '../../../build/contracts/contracts/payments/

// TODO: transfer ownership of ProxyAdmin???
export default buildModule('PaymentsEscrow', (m) => {
const { Controller, PeripheryRegistered } = m.useModule(GraphPeripheryModule)
const { PaymentsEscrowProxyAdmin, PaymentsEscrowProxy, HorizonRegistered } = m.useModule(HorizonProxiesModule)
const { Controller } = m.useModule(GraphPeripheryModule)
const { PaymentsEscrowProxyAdmin, PaymentsEscrowProxy } = m.useModule(HorizonProxiesModule)

const withdrawEscrowThawingPeriod = m.getParameter('withdrawEscrowThawingPeriod')

Expand All @@ -17,7 +17,7 @@ export default buildModule('PaymentsEscrow', (m) => {
PaymentsEscrowArtifact,
[Controller, withdrawEscrowThawingPeriod],
{
after: [PeripheryRegistered, HorizonRegistered],
after: [GraphPeripheryModule, HorizonProxiesModule],
},
)

Expand Down
10 changes: 7 additions & 3 deletions packages/horizon/ignition/modules/core/TAPCollector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@ import HorizonProxiesModule from './HorizonProxies'
import TAPCollectorArtifact from '../../../build/contracts/contracts/payments/collectors/TAPCollector.sol/TAPCollector.json'

export default buildModule('TAPCollector', (m) => {
const { Controller, PeripheryRegistered } = m.useModule(GraphPeripheryModule)
const { HorizonRegistered } = m.useModule(HorizonProxiesModule)
const { Controller } = m.useModule(GraphPeripheryModule)

const name = m.getParameter('eip712Name')
const version = m.getParameter('eip712Version')
const revokeSignerThawingPeriod = m.getParameter('revokeSignerThawingPeriod')

const TAPCollector = m.contract('TAPCollector', TAPCollectorArtifact, [name, version, Controller, revokeSignerThawingPeriod], { after: [PeripheryRegistered, HorizonRegistered] })
const TAPCollector = m.contract(
'TAPCollector',
TAPCollectorArtifact,
[name, version, Controller, revokeSignerThawingPeriod],
{ after: [GraphPeripheryModule, HorizonProxiesModule] },
)

return { TAPCollector }
})
27 changes: 6 additions & 21 deletions packages/horizon/ignition/modules/periphery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import GraphTokenGatewayModule from './periphery/GraphTokenGateway'
import GraphTokenModule from './periphery/GraphToken'
import RewardsManagerModule from './periphery/RewardsManager'

import DummyArtifact from '../../build/contracts/contracts/mocks/Dummy.sol/Dummy.json'

export default buildModule('GraphHorizon_Periphery', (m) => {
const { BridgeEscrow } = m.useModule(BridgeEscrowModule)
const { Controller } = m.useModule(ControllerModule)
Expand All @@ -23,25 +21,13 @@ export default buildModule('GraphHorizon_Periphery', (m) => {
const { Curation } = m.useModule(CurationModule)

// Register contracts in the Controller
const setProxyEpochManager = m.call(Controller, 'setContractProxy', [ethers.keccak256(ethers.toUtf8Bytes('EpochManager')), EpochManager], { id: 'setContractProxy_EpochManager' })
const setProxyRewardsManager = m.call(Controller, 'setContractProxy', [ethers.keccak256(ethers.toUtf8Bytes('RewardsManager')), RewardsManager], { id: 'setContractProxy_RewardsManager' })
const setProxyGraphToken = m.call(Controller, 'setContractProxy', [ethers.keccak256(ethers.toUtf8Bytes('GraphToken')), GraphToken], { id: 'setContractProxy_GraphToken' })
const setProxyGraphTokenGateway = m.call(Controller, 'setContractProxy', [ethers.keccak256(ethers.toUtf8Bytes('GraphTokenGateway')), GraphTokenGateway], { id: 'setContractProxy_GraphTokenGateway' })
m.call(Controller, 'setContractProxy', [ethers.keccak256(ethers.toUtf8Bytes('EpochManager')), EpochManager], { id: 'setContractProxy_EpochManager' })
m.call(Controller, 'setContractProxy', [ethers.keccak256(ethers.toUtf8Bytes('RewardsManager')), RewardsManager], { id: 'setContractProxy_RewardsManager' })
m.call(Controller, 'setContractProxy', [ethers.keccak256(ethers.toUtf8Bytes('GraphToken')), GraphToken], { id: 'setContractProxy_GraphToken' })
m.call(Controller, 'setContractProxy', [ethers.keccak256(ethers.toUtf8Bytes('GraphTokenGateway')), GraphTokenGateway], { id: 'setContractProxy_GraphTokenGateway' })
// eslint-disable-next-line no-secrets/no-secrets
const setProxyGraphProxyAdmin = m.call(Controller, 'setContractProxy', [ethers.keccak256(ethers.toUtf8Bytes('GraphProxyAdmin')), GraphProxyAdmin], { id: 'setContractProxy_GraphProxyAdmin' })
const setProxyCuration = m.call(Controller, 'setContractProxy', [ethers.keccak256(ethers.toUtf8Bytes('Curation')), Curation], { id: 'setContractProxy_Curation' })

// Deploy dummy contract to signal that all periphery contracts are registered
const PeripheryRegistered = m.contract('Dummy', DummyArtifact, [], {
after: [
setProxyEpochManager,
setProxyRewardsManager,
setProxyGraphToken,
setProxyGraphTokenGateway,
setProxyGraphProxyAdmin,
setProxyCuration,
],
})
m.call(Controller, 'setContractProxy', [ethers.keccak256(ethers.toUtf8Bytes('GraphProxyAdmin')), GraphProxyAdmin], { id: 'setContractProxy_GraphProxyAdmin' })
m.call(Controller, 'setContractProxy', [ethers.keccak256(ethers.toUtf8Bytes('Curation')), Curation], { id: 'setContractProxy_Curation' })

return {
BridgeEscrow,
Expand All @@ -52,6 +38,5 @@ export default buildModule('GraphHorizon_Periphery', (m) => {
GraphToken,
GraphTokenGateway,
RewardsManager,
PeripheryRegistered,
}
})
8 changes: 4 additions & 4 deletions packages/horizon/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
"@nomicfoundation/hardhat-chai-matchers": "^2.0.0",
"@nomicfoundation/hardhat-ethers": "^3.0.8",
"@nomicfoundation/hardhat-foundry": "^1.1.1",
"@nomicfoundation/hardhat-ignition": "^0.15.8",
"@nomicfoundation/hardhat-ignition-ethers": "^0.15.8",
"@nomicfoundation/hardhat-ignition": "^0.15.9",
"@nomicfoundation/hardhat-ignition-ethers": "^0.15.9",
"@nomicfoundation/hardhat-network-helpers": "^1.0.0",
"@nomicfoundation/hardhat-toolbox": "^4.0.0",
"@nomicfoundation/hardhat-verify": "^2.0.10",
"@nomicfoundation/ignition-core": "^0.15.8",
"@nomicfoundation/ignition-core": "^0.15.9",
"@openzeppelin/contracts": "^5.0.2",
"@openzeppelin/contracts-upgradeable": "^5.0.2",
"@typechain/ethers-v6": "^0.5.0",
Expand All @@ -40,7 +40,7 @@
"eslint": "^8.56.0",
"eslint-graph-config": "workspace:^0.0.1",
"ethers": "^6.13.4",
"hardhat": "^2.22.0",
"hardhat": "^2.22.18",
"hardhat-contract-sizer": "^2.10.0",
"hardhat-gas-reporter": "^1.0.8",
"hardhat-graph-protocol": "workspace:^0.0.1",
Expand Down
1 change: 1 addition & 0 deletions packages/horizon/scripts/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ async function main() {

// Deploy Horizon
await ignition.deploy(HorizonModule, {
displayUi: true,
parameters: HorizonConfig,
})
}
Expand Down
10 changes: 5 additions & 5 deletions packages/subgraph-service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
"@nomicfoundation/hardhat-chai-matchers": "^2.0.0",
"@nomicfoundation/hardhat-ethers": "^3.0.8",
"@nomicfoundation/hardhat-foundry": "^1.1.1",
"@nomicfoundation/hardhat-ignition": "^0.15.8",
"@nomicfoundation/hardhat-ignition-ethers": "^0.15.8",
"@nomicfoundation/hardhat-ignition": "^0.15.9",
"@nomicfoundation/hardhat-ignition-ethers": "^0.15.9",
"@nomicfoundation/hardhat-network-helpers": "^1.0.0",
"@nomicfoundation/hardhat-toolbox": "^4.0.0",
"@nomicfoundation/hardhat-verify": "^2.0.10",
"@nomicfoundation/ignition-core": "^0.15.8",
"@nomicfoundation/ignition-core": "^0.15.9",
"@openzeppelin/contracts": "^5.0.2",
"@openzeppelin/contracts-upgradeable": "^5.0.2",
"@typechain/ethers-v6": "^0.5.0",
Expand All @@ -40,8 +40,8 @@
"chai": "^4.2.0",
"eslint": "^8.56.0",
"eslint-graph-config": "workspace:^0.0.1",
"ethers": "^6.13.2",
"hardhat": "^2.20.1",
"ethers": "^6.13.4",
"hardhat": "^2.22.18",
"hardhat-contract-sizer": "^2.10.0",
"hardhat-gas-reporter": "^1.0.8",
"hardhat-graph-protocol": "workspace:^0.0.1",
Expand Down
7 changes: 6 additions & 1 deletion packages/subgraph-service/scripts/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,19 @@ async function main() {
const SubgraphServiceConfig = removeNFromBigInts(require('../ignition/configs/subgraph-service.hardhat.json5'))

// Deploy proxies
const { DisputeManagerProxy, DisputeManagerProxyAdmin, SubgraphServiceProxy, SubgraphServiceProxyAdmin } = await ignition.deploy(SubgraphServiceProxiesModule)
const { DisputeManagerProxy, DisputeManagerProxyAdmin, SubgraphServiceProxy, SubgraphServiceProxyAdmin } = await ignition.deploy(SubgraphServiceProxiesModule, {
displayUi: true,
})

// Deploy Horizon
const { Controller, TAPCollector, Curation } = await ignition.deploy(HorizonModule, {
displayUi: true,
parameters: patchSubgraphServiceAddress(HorizonConfig, SubgraphServiceProxy.target as string),
})

// Deploy DisputeManager implementation
await ignition.deploy(DisputeManagerModule, {
displayUi: true,
parameters: deepMerge(SubgraphServiceConfig, {
DisputeManager: {
controllerAddress: Controller.target as string,
Expand All @@ -43,6 +47,7 @@ async function main() {

// Deploy SubgraphService implementation
await ignition.deploy(SubgraphServiceModule, {
displayUi: true,
parameters: deepMerge(SubgraphServiceConfig, {
SubgraphService: {
controllerAddress: Controller.target as string,
Expand Down
Loading

0 comments on commit 3e4f2bc

Please sign in to comment.