-
Notifications
You must be signed in to change notification settings - Fork 422
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: implement network deploy script with fork test #5200
Open
yorhodes
wants to merge
8
commits into
main
Choose a base branch
from
symbiotic-network-deploy
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+321
−1
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
4d03e58
Implement network deploy script with fork test
yorhodes 404d47d
Use env vars for addresses
yorhodes 3a2e093
Use 3 days instead of 1 for min delay
yorhodes 4a6513f
Move network to new file
yorhodes 2597ed2
Add timelock for parse tx script
yorhodes a9a13e5
Build vault delegation safe proposal
yorhodes 4775020
Propose on safe
yorhodes e262cf8
Execute on timelock
yorhodes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
// SPDX-License-Identifier: MIT OR Apache-2.0 | ||
pragma solidity >=0.8.0; | ||
|
||
import "forge-std/Script.sol"; | ||
|
||
import {ProxyAdmin} from "../../contracts/upgrade/ProxyAdmin.sol"; | ||
import {TransparentUpgradeableProxy} from "../../contracts/upgrade/TransparentUpgradeableProxy.sol"; | ||
|
||
import {Network} from "./Network.sol"; | ||
|
||
contract DeployNetwork is Script { | ||
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); | ||
|
||
address networkRegistry = vm.envAddress("NETWORK_REGISTRY"); | ||
|
||
address proxyAdmin = vm.envAddress("PROXY_ADMIN"); | ||
address safe = vm.envAddress("SAFE"); | ||
|
||
uint256 constant MIN_DELAY = 3 days; | ||
|
||
function run() external { | ||
address deployer = vm.addr(deployerPrivateKey); | ||
|
||
vm.startBroadcast(deployerPrivateKey); | ||
|
||
Network timelockImplementation = new Network(); | ||
|
||
address[] memory proposers = new address[](2); | ||
proposers[0] = deployer; | ||
proposers[1] = safe; | ||
|
||
address[] memory executors = new address[](2); | ||
executors[0] = deployer; | ||
executors[1] = safe; | ||
|
||
address admin = safe; | ||
|
||
bytes memory initializeCall = abi.encodeCall( | ||
timelockImplementation.initialize, | ||
(0, proposers, executors, admin) | ||
); | ||
|
||
TransparentUpgradeableProxy timelockProxy = new TransparentUpgradeableProxy( | ||
address(timelockImplementation), | ||
proxyAdmin, | ||
initializeCall | ||
); | ||
|
||
Network timelock = Network(payable(timelockProxy)); | ||
|
||
timelock.hasRole(timelock.TIMELOCK_ADMIN_ROLE(), safe); | ||
|
||
bytes memory registerNetworkCall = abi.encodeWithSignature( | ||
"registerNetwork()" | ||
); | ||
|
||
uint256 numCalls = 3; | ||
|
||
address[] memory targets = new address[](numCalls); | ||
uint256[] memory values = new uint256[](numCalls); | ||
bytes[] memory payloads = new bytes[](numCalls); | ||
|
||
targets[0] = networkRegistry; | ||
values[0] = 0; | ||
payloads[0] = registerNetworkCall; | ||
|
||
targets[1] = address(timelock); | ||
values[1] = 0; | ||
payloads[1] = abi.encodeCall(timelock.updateDelay, (MIN_DELAY)); | ||
|
||
targets[2] = address(timelock); | ||
values[2] = 0; | ||
payloads[2] = abi.encodeCall( | ||
timelock.revokeRole, | ||
(timelock.PROPOSER_ROLE(), deployer) | ||
); | ||
|
||
timelock.scheduleBatch( | ||
targets, | ||
values, | ||
payloads, | ||
bytes32(0), | ||
bytes32(0), | ||
0 | ||
); | ||
|
||
timelock.executeBatch( | ||
targets, | ||
values, | ||
payloads, | ||
bytes32(0), | ||
bytes32(0) | ||
); | ||
|
||
vm.stopBroadcast(); | ||
|
||
assert(timelock.hasRole(timelock.TIMELOCK_ADMIN_ROLE(), safe)); | ||
assert(!timelock.hasRole(timelock.TIMELOCK_ADMIN_ROLE(), deployer)); | ||
|
||
assert(timelock.hasRole(timelock.PROPOSER_ROLE(), safe)); | ||
assert(!timelock.hasRole(timelock.PROPOSER_ROLE(), deployer)); | ||
|
||
assert(timelock.hasRole(timelock.EXECUTOR_ROLE(), safe)); | ||
assert(timelock.hasRole(timelock.EXECUTOR_ROLE(), deployer)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import {TimelockControllerUpgradeable} from "@openzeppelin/contracts-upgradeable/governance/TimelockControllerUpgradeable.sol"; | ||
|
||
contract Network is TimelockControllerUpgradeable { | ||
function initialize( | ||
uint256 minDelay, | ||
address[] memory proposers, | ||
address[] memory executors, | ||
address admin | ||
) public initializer { | ||
__TimelockController_init(minDelay, proposers, executors, admin); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export NETWORK_REGISTRY=0xC773b1011461e7314CF05f97d95aa8e92C1Fd8aA | ||
export PROXY_ADMIN=0x75EE15Ee1B4A75Fa3e2fDF5DF3253c25599cc659 | ||
export SAFE=0x3965AC3D295641E452E0ea896a086A9cD7C6C5b6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,198 @@ | ||
import { | ||
createPublicClient, | ||
encodeFunctionData, | ||
http, | ||
parseAbiItem, | ||
} from 'viem'; | ||
import { mainnet } from 'viem/chains'; | ||
import yargs from 'yargs'; | ||
|
||
import { assert } from '@hyperlane-xyz/utils'; | ||
|
||
import { safes } from '../../config/environments/mainnet3/owners.js'; | ||
import { SafeMultiSend } from '../../src/govern/multisend.js'; | ||
import { withChain } from '../agent-utils.js'; | ||
import { getEnvironmentConfig } from '../core-utils.js'; | ||
|
||
const VAULTS = [ | ||
{ | ||
name: 'EtherFi LBTC', | ||
vault: '0xd4E20ECA1f996Dab35883dC0AD5E3428AF888D45', | ||
}, | ||
{ | ||
name: 'EtherFi wstETH', | ||
vault: '0x450a90fdEa8B87a6448Ca1C87c88Ff65676aC45b', | ||
}, | ||
{ | ||
name: 'Renzo pzETH', | ||
vault: '0xa88e91cEF50b792f9449e2D4C699b6B3CcE1D19F', | ||
}, | ||
{ | ||
name: 'Swell swETH', | ||
vault: '0x65b560d887c010c4993c8f8b36e595c171d69d63', | ||
}, | ||
{ | ||
name: 'Swell WBTC', | ||
vault: '0x9e405601B645d3484baeEcf17bBF7aD87680f6e8', | ||
}, | ||
{ | ||
name: 'MEV Mellow wstETH', | ||
vault: '0x446970400e1787814CA050A4b45AE9d21B3f7EA7', | ||
}, | ||
{ | ||
name: 'MEV Symbiotic wstETH', | ||
vault: '0x4e0554959A631B3D3938ffC158e0a7b2124aF9c5', | ||
}, | ||
{ | ||
name: 'Gauntlet wstETH', | ||
vault: '0xc10A7f0AC6E3944F4860eE97a937C51572e3a1Da', | ||
}, | ||
{ | ||
name: 'Gauntlet cbETH', | ||
vault: '0xB8Fd82169a574eB97251bF43e443310D33FF056C', | ||
}, | ||
{ | ||
name: 'Gauntlet rETH', | ||
vault: '0xaF07131C497E06361dc2F75de63dc1d3e113f7cb', | ||
}, | ||
{ | ||
name: 'Gauntlet wBETH', | ||
vault: '0x81bb35c4152B605574BAbD320f8EABE2871CE8C6', | ||
}, | ||
{ | ||
name: 'P2P wstETH', | ||
vault: '0x7b276aAD6D2ebfD7e270C5a2697ac79182D9550E', | ||
}, | ||
{ | ||
name: 'Re7 wstETH', | ||
vault: '0x3D93b33f5E5fe74D54676720e70EA35210cdD46E', | ||
}, | ||
]; | ||
|
||
const NETWORK = '0x59cf937Ea9FA9D7398223E3aA33d92F7f5f986A2'; | ||
|
||
const SUBNETWORK_IDENTIFIER = BigInt(0); | ||
|
||
const SET_LIMIT_ABI = parseAbiItem( | ||
'function setMaxNetworkLimit(uint96 identifier, uint256 amount)', | ||
); | ||
|
||
const VAULT_DELEGATOR_ABI = parseAbiItem( | ||
'function delegator() returns (address)', | ||
); | ||
|
||
const SCHEDULE_BATCH_ABI = parseAbiItem( | ||
'function scheduleBatch(address[] calldata targets,uint256[] calldata values,bytes[] calldata payloads,bytes32 predecessor,bytes32 salt,uint256 delay)', | ||
); | ||
|
||
const EXECUTE_BATCH_ABI = parseAbiItem( | ||
'function executeBatch(address[] calldata targets,uint256[] calldata values,bytes[] calldata payloads,bytes32 predecessor,bytes32 salt)', | ||
); | ||
|
||
const ZERO_BYTES32 = '0x'.padEnd(64 + 2, '0') as `0x${string}`; | ||
|
||
async function main() { | ||
const client = createPublicClient({ | ||
chain: mainnet, | ||
transport: http(), | ||
}); | ||
|
||
const delegatorContracts = VAULTS.map(({ vault }) => ({ | ||
address: vault as `0x${string}`, | ||
abi: [VAULT_DELEGATOR_ABI], | ||
functionName: 'delegator', | ||
})); | ||
|
||
const delegatorResults = await client.multicall({ | ||
contracts: delegatorContracts, | ||
}); | ||
|
||
const delegators = delegatorResults.map(({ status, result }) => { | ||
assert(status === 'success', 'Multicall failed'); | ||
return result; | ||
}); | ||
|
||
const { chain } = await withChain(yargs(process.argv.slice(2))).demandOption( | ||
'chain', | ||
).argv; | ||
|
||
const envConfig = getEnvironmentConfig('mainnet3'); | ||
const multiProvider = await envConfig.getMultiProvider(); | ||
|
||
const multisend = new SafeMultiSend(multiProvider, chain, safes[chain]); | ||
|
||
const delegatorLimitCalls = VAULTS.map(({ name, vault }, index) => { | ||
let asset: 'ETH' | 'BTC'; | ||
if (name.endsWith('ETH')) { | ||
asset = 'ETH'; | ||
} else if (name.endsWith('BTC')) { | ||
asset = 'BTC'; | ||
} else { | ||
throw new Error(`Invalid vault name ${name}`); | ||
} | ||
|
||
const limit = asset === 'ETH' ? BigInt(3000e18) : BigInt(100e8); | ||
|
||
const delegator = delegators[index]; | ||
|
||
return { | ||
to: delegator, | ||
data: encodeFunctionData({ | ||
abi: [SET_LIMIT_ABI], | ||
args: [SUBNETWORK_IDENTIFIER, limit], | ||
}), | ||
description: `Set ${name} Hyperlane network delegation limit to ${limit} ${asset}`, | ||
}; | ||
}); | ||
|
||
const provider = multiProvider.getProvider(chain); | ||
for (const call of delegatorLimitCalls) { | ||
// simulate | ||
await provider.estimateGas({ | ||
from: NETWORK, | ||
to: call.to, | ||
data: call.data, | ||
}); | ||
} | ||
|
||
const targets = delegatorLimitCalls.map(({ to }) => to); | ||
assert(new Set(targets).size === targets.length, 'Duplicate targets'); | ||
|
||
const payloads = delegatorLimitCalls.map(({ data }) => data); | ||
const values = delegatorLimitCalls.map(() => BigInt(0)); | ||
|
||
const description = delegatorLimitCalls | ||
.map(({ description }) => description) | ||
.join('\n'); | ||
|
||
const scheduleTx = { | ||
to: NETWORK, | ||
data: encodeFunctionData({ | ||
abi: [SCHEDULE_BATCH_ABI], | ||
args: [targets, values, payloads, ZERO_BYTES32, ZERO_BYTES32, BigInt(0)], | ||
}), | ||
description: `Schedule batch:\n ${description}`, | ||
}; | ||
|
||
console.log(scheduleTx); | ||
|
||
const executeTx = { | ||
to: NETWORK, | ||
data: encodeFunctionData({ | ||
abi: [EXECUTE_BATCH_ABI], | ||
args: [targets, values, payloads, ZERO_BYTES32, ZERO_BYTES32], | ||
}), | ||
// description: `Execute batch:\n ${description}`, | ||
}; | ||
|
||
console.log(executeTx); | ||
|
||
await multiProvider.sendTransaction(chain, executeTx); | ||
return; | ||
await multisend.sendTransactions([scheduleTx]); | ||
} | ||
|
||
main().catch((error) => { | ||
console.error(error); | ||
process.exit(1); | ||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
symbiotic contracts use PUSH0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this imply a bytecode change for our contracts? If so, I would oppose this