Skip to content
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
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion solidity/foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ test = 'test'
cache_path = 'forge-cache'
allow_paths = ["../node_modules"]
solc_version = '0.8.22'
evm_version= 'paris'
evm_version= 'shanghai'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

symbiotic contracts use PUSH0

optimizer = true
optimizer_runs = 999_999
fs_permissions = [
Expand Down
106 changes: 106 additions & 0 deletions solidity/script/avs/DeployNetwork.s.sol
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));
}
}
12 changes: 12 additions & 0 deletions solidity/script/avs/Network.sol
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);
}
}
3 changes: 3 additions & 0 deletions solidity/script/avs/mainnet.env
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
Loading