Skip to content

Commit fb7c116

Browse files
committed
chore: added pre horizon upgrade state setup scripts
1 parent 85b87a2 commit fb7c116

File tree

27 files changed

+1193
-222
lines changed

27 files changed

+1193
-222
lines changed

packages/hardhat-graph-protocol/src/sdk/hardhat.base.config.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,12 @@ export const networksUserConfig: BaseNetworksUserConfig = {
6060
secureAccounts: {
6161
enabled: true,
6262
},
63-
...(vars.has('LOCALHOST_ACCOUNTS_MNEMONIC') && {
64-
accounts: { mnemonic: vars.get('LOCALHOST_ACCOUNTS_MNEMONIC') },
65-
}),
63+
...(vars.has('FORK') && vars.get('FORK') === 'true'
64+
? { accounts: 'remote' }
65+
: vars.has('LOCALHOST_ACCOUNTS_MNEMONIC')
66+
? { accounts: { mnemonic: vars.get('LOCALHOST_ACCOUNTS_MNEMONIC') } }
67+
: {}
68+
),
6669
deployments: {
6770
horizon: resolveLocalAddressBook('@graphprotocol/horizon/addresses.json'),
6871
subgraphService: resolveLocalAddressBook('@graphprotocol/subgraph-service/addresses.json'),
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { loadConfig, patchConfig, saveToAddressBook } from './ignition/ignition'
22
import { hardhatBaseConfig } from './hardhat.base.config'
3+
import { mergeABIs } from './utils/abi'
34

45
const IgnitionHelper = { saveToAddressBook, loadConfig, patchConfig }
5-
export { hardhatBaseConfig, IgnitionHelper }
6+
export { hardhatBaseConfig, IgnitionHelper, mergeABIs }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
"$global": {
3+
// Accounts
4+
"governor": "0xFFcf8FDEE72ac11b5c542428B35EEF5769C409f0",
5+
6+
// Addresses for contracts deployed in the original Graph Protocol
7+
"graphProxyAdminAddress": "0x7474a6cc5fAeDEc620Db0fa8E4da6eD58477042C",
8+
"controllerAddress": "0x9DB3ee191681f092607035d9BDA6e59FbEaCa695",
9+
"horizonStakingAddress": "0x865365C425f3A593Ffe698D9c4E6707D14d51e08",
10+
"epochManagerAddress": "0x88b3C7f37253bAA1A9b95feAd69bD5320585826D",
11+
"graphTokenAddress": "0xf8c05dCF59E8B28BFD5eed176C562bEbcfc7Ac04",
12+
"graphTokenGatewayAddress": "0xB24Ce0f8c18c4DdDa584A7EeC132F49C966813bb",
13+
"rewardsManagerAddress": "0x1F49caE7669086c8ba53CC35d1E9f80176d67E79",
14+
"curationAddress": "0xDe761f075200E75485F4358978FB4d1dC8644FD5",
15+
16+
// Must be set for step 3 and 4 of the migration
17+
"subgraphServiceAddress": "",
18+
19+
// Parameters
20+
"maxThawingPeriod": 2419200
21+
},
22+
"GraphPayments": {
23+
"protocolPaymentCut": 10000
24+
},
25+
"PaymentsEscrow": {
26+
"withdrawEscrowThawingPeriod": 10000
27+
},
28+
"GraphTallyCollector": {
29+
"eip712Name": "GraphTallyCollector",
30+
"eip712Version": "1",
31+
"revokeSignerThawingPeriod": 10000
32+
},
33+
"HorizonProxiesGovernor": {
34+
// Must be set for step 2 of the migration
35+
"graphPaymentsAddress": "",
36+
"paymentsEscrowAddress": ""
37+
},
38+
"HorizonStakingGovernor": {
39+
// Must be set for step 4 of the migration
40+
"horizonStakingImplementationAddress": ""
41+
},
42+
"L2CurationGovernor": {
43+
// Must be set for step 4 of the migration
44+
"curationImplementationAddress": ""
45+
},
46+
"RewardsManagerGovernor": {
47+
// Must be set for step 4 of the migration
48+
"rewardsManagerImplementationAddress": ""
49+
}
50+
}

packages/horizon/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
"lint": "yarn lint:ts && yarn lint:sol",
1717
"clean": "rm -rf build dist cache cache_forge typechain-types",
1818
"build": "BUILD_RUN=true hardhat compile",
19-
"test": "forge test && hardhat test:integration --deploy-type deploy"
19+
"test": "forge test && hardhat test:integration --deploy-type deploy",
20+
"test:e2e": "./scripts/e2e/e2e"
2021
},
2122
"devDependencies": {
2223
"@graphprotocol/contracts": "workspace:^7.0.0",

packages/horizon/scripts/e2e

-79
This file was deleted.

packages/horizon/scripts/e2e/e2e

+106
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
#!/bin/bash
2+
3+
set -eo pipefail
4+
5+
# Save original environment variable values
6+
ORIGINAL_HARDHAT_FORK=${HARDHAT_FORK:-""}
7+
ORIGINAL_SECURE_ACCOUNTS_DISABLE_PROVIDER=${SECURE_ACCOUNTS_DISABLE_PROVIDER:-""}
8+
9+
# Set environment variables for this script
10+
export HARDHAT_FORK=true
11+
export SECURE_ACCOUNTS_DISABLE_PROVIDER=true
12+
13+
# Function to cleanup resources
14+
cleanup() {
15+
# Remove ignition deployment files
16+
echo "Removing ignition deployment files..."
17+
rm -rf ignition/deployments/horizon-localhost
18+
19+
# Kill hardhat node only if we started it
20+
if [ ! -z "$NODE_PID" ] && [ "$STARTED_NODE" = true ]; then
21+
echo "Cleaning up node process..."
22+
kill $NODE_PID 2>/dev/null || true
23+
fi
24+
25+
# Restore original environment variables
26+
echo "Restoring original environment variables..."
27+
if [ -z "$ORIGINAL_HARDHAT_FORK" ]; then
28+
unset HARDHAT_FORK
29+
else
30+
export HARDHAT_FORK="$ORIGINAL_HARDHAT_FORK"
31+
fi
32+
33+
if [ -z "$ORIGINAL_SECURE_ACCOUNTS_DISABLE_PROVIDER" ]; then
34+
unset SECURE_ACCOUNTS_DISABLE_PROVIDER
35+
else
36+
export SECURE_ACCOUNTS_DISABLE_PROVIDER="$ORIGINAL_SECURE_ACCOUNTS_DISABLE_PROVIDER"
37+
fi
38+
}
39+
40+
# Set trap to call cleanup function on script exit (normal or error)
41+
trap cleanup EXIT
42+
43+
# Check required env variables
44+
if [ -z "$ARBITRUM_SEPOLIA_RPC" ]; then
45+
echo "ARBITRUM_SEPOLIA_RPC environment variable is required"
46+
exit 1
47+
fi
48+
49+
echo "Starting e2e tests..."
50+
51+
# Check if hardhat node is already running on port 8545
52+
STARTED_NODE=false
53+
if lsof -i:8545 > /dev/null 2>&1; then
54+
echo "Hardhat node already running on port 8545, using existing node"
55+
# Get the PID of the process using port 8545
56+
NODE_PID=$(lsof -t -i:8545)
57+
else
58+
# Start local hardhat node forked from Arbitrum Sepolia
59+
echo "Starting local hardhat node..."
60+
npx hardhat node --fork $ARBITRUM_SEPOLIA_RPC > node.log 2>&1 &
61+
NODE_PID=$!
62+
STARTED_NODE=true
63+
64+
# Wait for node to start
65+
sleep 10
66+
fi
67+
68+
# Setup pre horizon migration state needed for the e2e tests
69+
npx hardhat run ./scripts/e2e/pre-upgrade.ts --network localhost
70+
71+
# Transfer ownership of protocol to hardhat signer 1
72+
npx hardhat run ./scripts/e2e/transfer-ownership.ts --network localhost
73+
74+
# Step 1 - Deployer
75+
npx hardhat deploy:migrate --network localhost --horizon-config e2e-test --step 1 --signer-index 0
76+
77+
# Step 2 - Governor
78+
npx hardhat deploy:migrate --network localhost --horizon-config e2e-test --step 2 --patch-config --signer-index 1 --hide-banner
79+
80+
# Step 3 - Deployer
81+
npx hardhat deploy:migrate --network localhost --horizon-config e2e-test --step 3 --patch-config --signer-index 0 --hide-banner
82+
83+
# Step 4 - Governor
84+
npx hardhat deploy:migrate --network localhost --horizon-config e2e-test --step 4 --patch-config --signer-index 1 --hide-banner
85+
86+
# Unset subgraph service
87+
npx hardhat transition:unset-subgraph-service --network localhost --governor-index 1
88+
89+
# Run integration tests - During transition period
90+
npx hardhat test:integration --phase during-transition-period --network localhost
91+
92+
# Clear thawing period
93+
npx hardhat transition:clear-thawing --network localhost --governor-index 1
94+
95+
# Run integration tests - After transition period
96+
npx hardhat test:integration --phase after-transition-period --network localhost
97+
98+
# Enable delegation slashing
99+
npx hardhat transition:enable-delegation-slashing --network localhost --governor-index 1
100+
101+
# Run integration tests - After delegation slashing enabled
102+
npx hardhat test:integration --phase after-delegation-slashing-enabled --network localhost
103+
104+
echo ""
105+
echo "🎉 ✨ 🚀 ✅ E2E tests completed successfully! 🎉 ✨ 🚀 ✅"
106+
echo ""
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import { parseEther } from 'ethers'
2+
import { indexers } from './indexers'
3+
4+
export interface Delegator {
5+
address: string
6+
delegations: {
7+
indexerAddress: string
8+
tokens: bigint
9+
}[]
10+
undelegate: boolean // Whether this delegator should undelegate at the end
11+
}
12+
13+
export const delegators: Delegator[] = [
14+
{
15+
address: '0x610Bb1573d1046FCb8A70Bbbd395754cD57C2b60', // Hardhat account #10
16+
delegations: [
17+
{
18+
indexerAddress: indexers[0].address,
19+
tokens: parseEther('50000'),
20+
},
21+
{
22+
indexerAddress: indexers[1].address,
23+
tokens: parseEther('25000'),
24+
}
25+
],
26+
undelegate: false,
27+
},
28+
{
29+
address: '0x855FA758c77D68a04990E992aA4dcdeF899F654A', // Hardhat account #11
30+
delegations: [
31+
{
32+
indexerAddress: indexers[1].address,
33+
tokens: parseEther('75000'),
34+
}
35+
],
36+
undelegate: false,
37+
},
38+
{
39+
address: '0xfA2435Eacf10Ca62ae6787ba2fB044f8733Ee843', // Hardhat account #12
40+
delegations: [
41+
{
42+
indexerAddress: indexers[0].address,
43+
tokens: parseEther('100000'),
44+
}
45+
],
46+
undelegate: true, // This delegator will undelegate
47+
},
48+
{
49+
address: '0x64E078A8Aa15A41B85890265648e965De686bAE6', // Hardhat account #13
50+
delegations: [],
51+
undelegate: false,
52+
},
53+
{
54+
address: '0x2F560290FEF1B3Ada194b6aA9c40aa71f8e95598', // Hardhat account #14
55+
delegations: [],
56+
undelegate: false,
57+
}
58+
]

0 commit comments

Comments
 (0)