Skip to content

Commit 297b08d

Browse files
committed
feat: add script to patch ignition verification command
Signed-off-by: Tomás Migone <[email protected]>
1 parent c615fb0 commit 297b08d

File tree

7 files changed

+75
-11
lines changed

7 files changed

+75
-11
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// SPDX-License-Identifier: GPL-2.0-or-later
2+
3+
// We import these here to force Hardhat to compile them.
4+
// This ensures that their artifacts are available for Hardhat Ignition to use.
5+
pragma solidity 0.8.27;
6+
7+
import "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";

packages/horizon/ignition/configs/horizon.hardhat.json5

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
"EpochManager": {
1414
"epochLength": 60
1515
},
16-
"Curation": {
16+
"L2Curation": {
1717
"curationTaxPercentage": 10000,
1818
"minimumCurationDeposit": 1
1919
},
20-
"GraphToken": {
20+
"L2GraphToken": {
2121
"initialSupply": "10000000000000000000000000000n"
2222
},
2323
"HorizonStaking": {

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import CurationArtifact from '@graphprotocol/contracts/build/contracts/contracts
77
import GraphCurationTokenArtifact from '@graphprotocol/contracts/build/contracts/contracts/curation/GraphCurationToken.sol/GraphCurationToken.json'
88
import GraphProxyArtifact from '@graphprotocol/contracts/build/contracts/contracts/upgrades/GraphProxy.sol/GraphProxy.json'
99

10-
export default buildModule('Curation', (m) => {
10+
export default buildModule('L2Curation', (m) => {
1111
const isMigrate = m.getParameter('isMigrate')
1212

1313
if (isMigrate) {
@@ -25,7 +25,7 @@ function upgradeCuration(m: IgnitionModuleBuilder) {
2525

2626
const GraphProxy = m.contractAt('GraphProxy', GraphProxyArtifact, graphCurationProxyAddress)
2727
const { instance: Curation, implementation: CurationImplementation } = upgradeWithGraphProxy(m, {
28-
name: 'Curation',
28+
name: 'L2Curation',
2929
artifact: CurationArtifact,
3030
proxyContract: GraphProxy,
3131
}, { from: governor })
@@ -43,7 +43,7 @@ function deployCuration(m: IgnitionModuleBuilder) {
4343
const GraphCurationToken = m.contract('GraphCurationToken', GraphCurationTokenArtifact, [])
4444

4545
const { instance: Curation, implementation: CurationImplementation } = deployWithGraphProxy(m, {
46-
name: 'Curation',
46+
name: 'L2Curation',
4747
artifact: CurationArtifact,
4848
args: [Controller, GraphCurationToken, curationTaxPercentage, minimumCurationDeposit],
4949
})

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import RewardsManagerModule from '../periphery/RewardsManager'
77
import GraphTokenArtifact from '@graphprotocol/contracts/build/contracts/contracts/l2/token/L2GraphToken.sol/L2GraphToken.json'
88

99
// TODO: Ownership transfer is a two step process, the new owner needs to accept it by calling acceptOwnership
10-
export default buildModule('GraphToken', (m) => {
10+
export default buildModule('L2GraphToken', (m) => {
1111
const isMigrate = m.getParameter('isMigrate', false)
1212

1313
let GraphToken
@@ -23,7 +23,7 @@ export default buildModule('GraphToken', (m) => {
2323
const initialSupply = m.getParameter('initialSupply')
2424

2525
GraphToken = deployWithGraphProxy(m, {
26-
name: 'GraphToken',
26+
name: 'L2GraphToken',
2727
artifact: GraphTokenArtifact,
2828
args: [deployer],
2929
}).instance

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { deployWithGraphProxy } from '../proxy/GraphProxy'
55
import ControllerModule from '../periphery/Controller'
66
import GraphTokenGatewayArtifact from '@graphprotocol/contracts/build/contracts/contracts/l2/gateway/L2GraphTokenGateway.sol/L2GraphTokenGateway.json'
77

8-
export default buildModule('GraphTokenGateway', (m) => {
8+
export default buildModule('L2GraphTokenGateway', (m) => {
99
const isMigrate = m.getParameter('isMigrate', false)
1010

1111
let GraphTokenGateway
@@ -18,7 +18,7 @@ export default buildModule('GraphTokenGateway', (m) => {
1818
const pauseGuardian = m.getParameter('pauseGuardian')
1919

2020
GraphTokenGateway = deployWithGraphProxy(m, {
21-
name: 'GraphTokenGateway',
21+
name: 'L2GraphTokenGateway',
2222
artifact: GraphTokenGatewayArtifact,
2323
args: [Controller],
2424
}).instance

packages/horizon/ignition/modules/proxy/TransparentUpgradeableProxy.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { IgnitionModuleBuilder } from '@nomicfoundation/ignition-core'
22

33
import DummyArtifact from '../../../build/contracts/contracts/mocks/Dummy.sol/Dummy.json'
4-
import ProxyAdminArtifact from '@openzeppelin/contracts/build/contracts/ProxyAdmin.json'
5-
import TransparentUpgradeableProxyArtifact from '@openzeppelin/contracts/build/contracts/TransparentUpgradeableProxy.json'
4+
import ProxyAdminArtifact from '../../../build/contracts/@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol/ProxyAdmin.json'
5+
import TransparentUpgradeableProxyArtifact from '../../../build/contracts/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol/TransparentUpgradeableProxy.json'
66

77
// Deploy a TransparentUpgradeableProxy
88
// Note that this module uses a dummy contract as the implementation as the proxy requires a valid contract

packages/horizon/scripts/pre-verify

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/bin/bash
2+
3+
# Move external artifacts
4+
cp -r ../contracts/build/contracts/contracts/* build/contracts/contracts
5+
cp -r ../contracts/build/contracts/build-info/* build/contracts/build-info
6+
cp -r build/contracts/@openzeppelin/contracts/proxy/transparent/* build/contracts/contracts
7+
8+
# HardHat Ignition deployment ID
9+
DEPLOYMENT_ID="${1:-chain-421614}"
10+
11+
# .dbg.json files
12+
DBG_DIR_SRC="./build/contracts/contracts"
13+
DBG_DIR_DEST="./ignition/deployments/${DEPLOYMENT_ID}/artifacts"
14+
15+
# build-info files
16+
BUILD_INFO_DIR_SRC="./build/contracts/build-info"
17+
BUILD_INFO_DIR_DEST="./ignition/deployments/${DEPLOYMENT_ID}/build-info"
18+
19+
# Ensure the destination directories exist
20+
mkdir -p "$DBG_DIR_DEST"
21+
mkdir -p "$BUILD_INFO_DIR_DEST"
22+
23+
# Copy .dbg.json files
24+
echo "Searching for .dbg.json files in $DBG_DIR_SRC and copying them to $DBG_DIR_DEST..."
25+
find "$DBG_DIR_SRC" -type f -name "*.dbg.json" | while read -r file; do
26+
base_name=$(basename "$file" .dbg.json)
27+
new_name="${base_name}#${base_name}.dbg.json"
28+
29+
if [ ! -f "$DBG_DIR_DEST/$new_name" ]; then
30+
cp "$file" "$DBG_DIR_DEST/$new_name"
31+
fi
32+
33+
jq '.buildInfo |= sub("../../../../"; "../") | .buildInfo |= sub("../../../"; "../") | .buildInfo |= sub("../../"; "../")' "$DBG_DIR_DEST/$new_name" > "${DBG_DIR_DEST}/${new_name}.tmp" && mv "${DBG_DIR_DEST}/${new_name}.tmp" "$DBG_DIR_DEST/$new_name"
34+
done
35+
36+
# Copy build-info files
37+
echo "Searching for build-info files in $BUILD_INFO_DIR_SRC and copying them to $BUILD_INFO_DIR_DEST..."
38+
find "$BUILD_INFO_DIR_SRC" -type f -name "*.json" | while read -r file; do
39+
base_name=$(basename "$file" .json)
40+
if [ ! -f "$BUILD_INFO_DIR_DEST/$base_name.json" ]; then
41+
cp "$file" "$BUILD_INFO_DIR_DEST/$base_name.json"
42+
fi
43+
done
44+
45+
echo "All files have been processed."
46+
47+
# Patch proxy artifacts
48+
cp "$DBG_DIR_DEST/GraphProxy#GraphProxy.dbg.json" "$DBG_DIR_DEST/HorizonProxies#GraphProxy_HorizonStaking.dbg.json"
49+
cp "$DBG_DIR_DEST/GraphProxy#GraphProxy.dbg.json" "$DBG_DIR_DEST/L2Curation#GraphProxy.dbg.json"
50+
cp "$DBG_DIR_DEST/GraphProxy#GraphProxy.dbg.json" "$DBG_DIR_DEST/L2GraphToken#GraphProxy.dbg.json"
51+
cp "$DBG_DIR_DEST/GraphProxy#GraphProxy.dbg.json" "$DBG_DIR_DEST/L2GraphTokenGateway#GraphProxy.dbg.json"
52+
cp "$DBG_DIR_DEST/GraphProxy#GraphProxy.dbg.json" "$DBG_DIR_DEST/RewardsManager#GraphProxy.dbg.json"
53+
cp "$DBG_DIR_DEST/GraphProxy#GraphProxy.dbg.json" "$DBG_DIR_DEST/BridgeEscrow#GraphProxy.dbg.json"
54+
cp "$DBG_DIR_DEST/GraphProxy#GraphProxy.dbg.json" "$DBG_DIR_DEST/EpochManager#GraphProxy.dbg.json"
55+
56+
cp "$DBG_DIR_DEST/TransparentUpgradeableProxy#TransparentUpgradeableProxy.dbg.json" "$DBG_DIR_DEST/HorizonProxies#TransparentUpgradeableProxy_GraphPayments.dbg.json"
57+
cp "$DBG_DIR_DEST/TransparentUpgradeableProxy#TransparentUpgradeableProxy.dbg.json" "$DBG_DIR_DEST/HorizonProxies#TransparentUpgradeableProxy_PaymentsEscrow.dbg.json"

0 commit comments

Comments
 (0)