From 37e6b623474b93b5e350513261fb4d71ab00ea72 Mon Sep 17 00:00:00 2001 From: jeff <113397187+cyberhorsey@users.noreply.github.com> Date: Wed, 3 Jan 2024 20:16:40 -0800 Subject: [PATCH] feat(protocol): upgrade scripts for new proxies (#15452) Co-authored-by: David --- .../script/upgrade/UpgradeAddressManager.sol | 30 ++++++++++ .../upgrade/UpgradeAssignmentHook.s.sol | 30 ++++++++++ .../script/upgrade/UpgradeBridge.s.sol | 30 ++++++++++ .../script/upgrade/UpgradeERC1155Vault.s.sol | 30 ++++++++++ .../script/upgrade/UpgradeERC20Vault.s.sol | 30 ++++++++++ .../script/upgrade/UpgradeERC721Vault.s.sol | 30 ++++++++++ .../upgrade/UpgradeGuardianProver.s.sol | 30 ++++++++++ .../script/upgrade/UpgradeScript.s.sol | 56 +++++++++++++++++++ .../script/upgrade/UpgradeSignalService.sol | 30 ++++++++++ .../script/upgrade/UpgradeTaikoGovernor.sol | 30 ++++++++++ .../script/upgrade/UpgradeTaikoL1.sol | 30 ++++++++++ .../upgrade/UpgradeTimelockController.s.sol | 30 ++++++++++ packages/protocol/script/upgrade_to.sh | 4 +- 13 files changed, 388 insertions(+), 2 deletions(-) create mode 100644 packages/protocol/script/upgrade/UpgradeAddressManager.sol create mode 100644 packages/protocol/script/upgrade/UpgradeAssignmentHook.s.sol create mode 100644 packages/protocol/script/upgrade/UpgradeBridge.s.sol create mode 100644 packages/protocol/script/upgrade/UpgradeERC1155Vault.s.sol create mode 100644 packages/protocol/script/upgrade/UpgradeERC20Vault.s.sol create mode 100644 packages/protocol/script/upgrade/UpgradeERC721Vault.s.sol create mode 100644 packages/protocol/script/upgrade/UpgradeGuardianProver.s.sol create mode 100644 packages/protocol/script/upgrade/UpgradeScript.s.sol create mode 100644 packages/protocol/script/upgrade/UpgradeSignalService.sol create mode 100644 packages/protocol/script/upgrade/UpgradeTaikoGovernor.sol create mode 100644 packages/protocol/script/upgrade/UpgradeTaikoL1.sol create mode 100644 packages/protocol/script/upgrade/UpgradeTimelockController.s.sol diff --git a/packages/protocol/script/upgrade/UpgradeAddressManager.sol b/packages/protocol/script/upgrade/UpgradeAddressManager.sol new file mode 100644 index 00000000000..714ab15b630 --- /dev/null +++ b/packages/protocol/script/upgrade/UpgradeAddressManager.sol @@ -0,0 +1,30 @@ +// SPDX-License-Identifier: MIT +// _____ _ _ _ _ +// |_ _|_ _(_) |_____ | | __ _| |__ ___ +// | |/ _` | | / / _ \ | |__/ _` | '_ (_-< +// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/ +// +// Email: security@taiko.xyz +// Website: https://taiko.xyz +// GitHub: https://github.com/taikoxyz +// Discord: https://discord.gg/taikoxyz +// Twitter: https://twitter.com/taikoxyz +// Blog: https://mirror.xyz/labs.taiko.eth +// Youtube: https://www.youtube.com/@taikoxyz + +pragma solidity ^0.8.20; + +import "forge-std/Script.sol"; +import "forge-std/console2.sol"; +import "../../contracts/common/AddressManager.sol"; +import "./UpgradeScript.s.sol"; + +contract UpgradeAddressManager is UpgradeScript { + function run() external setUp { + console2.log("upgrading AddressManager"); + AddressManager newAddressManager = new AddressManager(); + upgrade(address(newAddressManager)); + + console2.log("upgraded AddressManager to", address(newAddressManager)); + } +} diff --git a/packages/protocol/script/upgrade/UpgradeAssignmentHook.s.sol b/packages/protocol/script/upgrade/UpgradeAssignmentHook.s.sol new file mode 100644 index 00000000000..e0eacb0b11e --- /dev/null +++ b/packages/protocol/script/upgrade/UpgradeAssignmentHook.s.sol @@ -0,0 +1,30 @@ +// SPDX-License-Identifier: MIT +// _____ _ _ _ _ +// |_ _|_ _(_) |_____ | | __ _| |__ ___ +// | |/ _` | | / / _ \ | |__/ _` | '_ (_-< +// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/ +// +// Email: security@taiko.xyz +// Website: https://taiko.xyz +// GitHub: https://github.com/taikoxyz +// Discord: https://discord.gg/taikoxyz +// Twitter: https://twitter.com/taikoxyz +// Blog: https://mirror.xyz/labs.taiko.eth +// Youtube: https://www.youtube.com/@taikoxyz + +pragma solidity ^0.8.20; + +import "forge-std/Script.sol"; +import "forge-std/console2.sol"; +import "../../contracts/L1/hooks/AssignmentHook.sol"; +import "./UpgradeScript.s.sol"; + +contract UpgradeAssignmentHook is UpgradeScript { + function run() external setUp { + console2.log("upgrading AssignmentHook"); + AssignmentHook newAssignmentHook = new AssignmentHook(); + upgrade(address(newAssignmentHook)); + + console2.log("upgraded AssignmentHook to", address(newAssignmentHook)); + } +} diff --git a/packages/protocol/script/upgrade/UpgradeBridge.s.sol b/packages/protocol/script/upgrade/UpgradeBridge.s.sol new file mode 100644 index 00000000000..15ce65cdcca --- /dev/null +++ b/packages/protocol/script/upgrade/UpgradeBridge.s.sol @@ -0,0 +1,30 @@ +// SPDX-License-Identifier: MIT +// _____ _ _ _ _ +// |_ _|_ _(_) |_____ | | __ _| |__ ___ +// | |/ _` | | / / _ \ | |__/ _` | '_ (_-< +// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/ +// +// Email: security@taiko.xyz +// Website: https://taiko.xyz +// GitHub: https://github.com/taikoxyz +// Discord: https://discord.gg/taikoxyz +// Twitter: https://twitter.com/taikoxyz +// Blog: https://mirror.xyz/labs.taiko.eth +// Youtube: https://www.youtube.com/@taikoxyz + +pragma solidity ^0.8.20; + +import "forge-std/Script.sol"; +import "forge-std/console2.sol"; +import "../../contracts/bridge/Bridge.sol"; +import "./UpgradeScript.s.sol"; + +contract UpgradeBridge is UpgradeScript { + function run() external setUp { + console2.log("upgrading bridge"); + Bridge newBridge = new Bridge(); + upgrade(address(newBridge)); + + console2.log("upgraded bridge to", address(newBridge)); + } +} diff --git a/packages/protocol/script/upgrade/UpgradeERC1155Vault.s.sol b/packages/protocol/script/upgrade/UpgradeERC1155Vault.s.sol new file mode 100644 index 00000000000..c6342e11aad --- /dev/null +++ b/packages/protocol/script/upgrade/UpgradeERC1155Vault.s.sol @@ -0,0 +1,30 @@ +// SPDX-License-Identifier: MIT +// _____ _ _ _ _ +// |_ _|_ _(_) |_____ | | __ _| |__ ___ +// | |/ _` | | / / _ \ | |__/ _` | '_ (_-< +// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/ +// +// Email: security@taiko.xyz +// Website: https://taiko.xyz +// GitHub: https://github.com/taikoxyz +// Discord: https://discord.gg/taikoxyz +// Twitter: https://twitter.com/taikoxyz +// Blog: https://mirror.xyz/labs.taiko.eth +// Youtube: https://www.youtube.com/@taikoxyz + +pragma solidity ^0.8.20; + +import "forge-std/Script.sol"; +import "forge-std/console2.sol"; +import "../../contracts/tokenvault/ERC1155Vault.sol"; +import "./UpgradeScript.s.sol"; + +contract UpgradeERC1155Vault is UpgradeScript { + function run() external setUp { + console2.log("upgrading ERC1155Vault"); + ERC1155Vault newERC1155Vault = new ERC1155Vault(); + upgrade(address(newERC1155Vault)); + + console2.log("upgraded ERC1155Vault to", address(newERC1155Vault)); + } +} diff --git a/packages/protocol/script/upgrade/UpgradeERC20Vault.s.sol b/packages/protocol/script/upgrade/UpgradeERC20Vault.s.sol new file mode 100644 index 00000000000..39c4316d2e7 --- /dev/null +++ b/packages/protocol/script/upgrade/UpgradeERC20Vault.s.sol @@ -0,0 +1,30 @@ +// SPDX-License-Identifier: MIT +// _____ _ _ _ _ +// |_ _|_ _(_) |_____ | | __ _| |__ ___ +// | |/ _` | | / / _ \ | |__/ _` | '_ (_-< +// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/ +// +// Email: security@taiko.xyz +// Website: https://taiko.xyz +// GitHub: https://github.com/taikoxyz +// Discord: https://discord.gg/taikoxyz +// Twitter: https://twitter.com/taikoxyz +// Blog: https://mirror.xyz/labs.taiko.eth +// Youtube: https://www.youtube.com/@taikoxyz + +pragma solidity ^0.8.20; + +import "forge-std/Script.sol"; +import "forge-std/console2.sol"; +import "../../contracts/tokenvault/ERC20Vault.sol"; +import "./UpgradeScript.s.sol"; + +contract UpgradeERC20Vault is UpgradeScript { + function run() external setUp { + console2.log("upgrading ERC20Vault"); + ERC20Vault newERC20Vault = new ERC20Vault(); + upgrade(address(newERC20Vault)); + + console2.log("upgraded ERC20Vault to", address(newERC20Vault)); + } +} diff --git a/packages/protocol/script/upgrade/UpgradeERC721Vault.s.sol b/packages/protocol/script/upgrade/UpgradeERC721Vault.s.sol new file mode 100644 index 00000000000..f778447af50 --- /dev/null +++ b/packages/protocol/script/upgrade/UpgradeERC721Vault.s.sol @@ -0,0 +1,30 @@ +// SPDX-License-Identifier: MIT +// _____ _ _ _ _ +// |_ _|_ _(_) |_____ | | __ _| |__ ___ +// | |/ _` | | / / _ \ | |__/ _` | '_ (_-< +// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/ +// +// Email: security@taiko.xyz +// Website: https://taiko.xyz +// GitHub: https://github.com/taikoxyz +// Discord: https://discord.gg/taikoxyz +// Twitter: https://twitter.com/taikoxyz +// Blog: https://mirror.xyz/labs.taiko.eth +// Youtube: https://www.youtube.com/@taikoxyz + +pragma solidity ^0.8.20; + +import "forge-std/Script.sol"; +import "forge-std/console2.sol"; +import "../../contracts/tokenvault/ERC721Vault.sol"; +import "./UpgradeScript.s.sol"; + +contract UpgradeERC721Vault is UpgradeScript { + function run() external setUp { + console2.log("upgrading ERC721Vault"); + ERC721Vault newERC721Vault = new ERC721Vault(); + upgrade(address(newERC721Vault)); + + console2.log("upgraded ERC721Vault to", address(newERC721Vault)); + } +} diff --git a/packages/protocol/script/upgrade/UpgradeGuardianProver.s.sol b/packages/protocol/script/upgrade/UpgradeGuardianProver.s.sol new file mode 100644 index 00000000000..af5ffc94ecf --- /dev/null +++ b/packages/protocol/script/upgrade/UpgradeGuardianProver.s.sol @@ -0,0 +1,30 @@ +// SPDX-License-Identifier: MIT +// _____ _ _ _ _ +// |_ _|_ _(_) |_____ | | __ _| |__ ___ +// | |/ _` | | / / _ \ | |__/ _` | '_ (_-< +// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/ +// +// Email: security@taiko.xyz +// Website: https://taiko.xyz +// GitHub: https://github.com/taikoxyz +// Discord: https://discord.gg/taikoxyz +// Twitter: https://twitter.com/taikoxyz +// Blog: https://mirror.xyz/labs.taiko.eth +// Youtube: https://www.youtube.com/@taikoxyz + +pragma solidity ^0.8.20; + +import "forge-std/Script.sol"; +import "forge-std/console2.sol"; +import "../../contracts/L1/provers/GuardianProver.sol"; +import "./UpgradeScript.s.sol"; + +contract UpgradeGuardianProver is UpgradeScript { + function run() external setUp { + console2.log("upgrading GuardianProver"); + GuardianProver newGuardianProver = new GuardianProver(); + upgrade(address(newGuardianProver)); + + console2.log("upgraded GuardianProver to", address(newGuardianProver)); + } +} diff --git a/packages/protocol/script/upgrade/UpgradeScript.s.sol b/packages/protocol/script/upgrade/UpgradeScript.s.sol new file mode 100644 index 00000000000..95b76e69899 --- /dev/null +++ b/packages/protocol/script/upgrade/UpgradeScript.s.sol @@ -0,0 +1,56 @@ +// SPDX-License-Identifier: MIT +// _____ _ _ _ _ +// |_ _|_ _(_) |_____ | | __ _| |__ ___ +// | |/ _` | | / / _ \ | |__/ _` | '_ (_-< +// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/ +// +// Email: security@taiko.xyz +// Website: https://taiko.xyz +// GitHub: https://github.com/taikoxyz +// Discord: https://discord.gg/taikoxyz +// Twitter: https://twitter.com/taikoxyz +// Blog: https://mirror.xyz/labs.taiko.eth +// Youtube: https://www.youtube.com/@taikoxyz + +pragma solidity 0.8.20; + +import "../../contracts/L1/gov/TaikoTimelockController.sol"; +import "lib/openzeppelin-contracts/contracts/proxy/utils/UUPSUpgradeable.sol"; + +import "forge-std/console2.sol"; +import "forge-std/Script.sol"; + +contract UpgradeScript is Script { + uint256 public privateKey = vm.envUint("PRIVATE_KEY"); + address public timelockAddress = vm.envAddress("TIMELOCK_ADDRESS"); + address public proxyAddress = vm.envAddress("PROXY_ADDRESS"); + + UUPSUpgradeable proxy; + TaikoTimelockController timelock; + + modifier setUp() { + require(privateKey != 0, "PRIVATE_KEY not set"); + require(proxyAddress != address(0), "PROXY_ADDRESS not set"); + require(timelockAddress != address(0), "TIMELOCK_ADDRESS not set"); + + proxy = UUPSUpgradeable(payable(proxyAddress)); + timelock = TaikoTimelockController(payable(timelockAddress)); + + vm.startBroadcast(privateKey); + + _; + + vm.stopBroadcast(); + } + + function upgrade(address newImpl) public { + bytes32 salt = bytes32(block.timestamp); + + bytes memory payload = + abi.encodeWithSelector(bytes4(keccak256("upgradeTo(address)")), newImpl); + + timelock.schedule(address(proxy), 0, payload, bytes32(0), salt, 0); + + timelock.execute(address(proxy), 0, payload, bytes32(0), salt); + } +} diff --git a/packages/protocol/script/upgrade/UpgradeSignalService.sol b/packages/protocol/script/upgrade/UpgradeSignalService.sol new file mode 100644 index 00000000000..6350235e979 --- /dev/null +++ b/packages/protocol/script/upgrade/UpgradeSignalService.sol @@ -0,0 +1,30 @@ +// SPDX-License-Identifier: MIT +// _____ _ _ _ _ +// |_ _|_ _(_) |_____ | | __ _| |__ ___ +// | |/ _` | | / / _ \ | |__/ _` | '_ (_-< +// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/ +// +// Email: security@taiko.xyz +// Website: https://taiko.xyz +// GitHub: https://github.com/taikoxyz +// Discord: https://discord.gg/taikoxyz +// Twitter: https://twitter.com/taikoxyz +// Blog: https://mirror.xyz/labs.taiko.eth +// Youtube: https://www.youtube.com/@taikoxyz + +pragma solidity ^0.8.20; + +import "forge-std/Script.sol"; +import "forge-std/console2.sol"; +import "../../contracts/signal/SignalService.sol"; +import "./UpgradeScript.s.sol"; + +contract UpgradeSignalService is UpgradeScript { + function run() external setUp { + console2.log("upgrading SignalService"); + SignalService newSignalService = new SignalService(); + upgrade(address(newSignalService)); + + console2.log("upgraded SignalService to", address(newSignalService)); + } +} diff --git a/packages/protocol/script/upgrade/UpgradeTaikoGovernor.sol b/packages/protocol/script/upgrade/UpgradeTaikoGovernor.sol new file mode 100644 index 00000000000..539ae3e1c25 --- /dev/null +++ b/packages/protocol/script/upgrade/UpgradeTaikoGovernor.sol @@ -0,0 +1,30 @@ +// SPDX-License-Identifier: MIT +// _____ _ _ _ _ +// |_ _|_ _(_) |_____ | | __ _| |__ ___ +// | |/ _` | | / / _ \ | |__/ _` | '_ (_-< +// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/ +// +// Email: security@taiko.xyz +// Website: https://taiko.xyz +// GitHub: https://github.com/taikoxyz +// Discord: https://discord.gg/taikoxyz +// Twitter: https://twitter.com/taikoxyz +// Blog: https://mirror.xyz/labs.taiko.eth +// Youtube: https://www.youtube.com/@taikoxyz + +pragma solidity ^0.8.20; + +import "forge-std/Script.sol"; +import "forge-std/console2.sol"; +import "../../contracts/L1/gov/TaikoGovernor.sol"; +import "./UpgradeScript.s.sol"; + +contract UpgradeTaikoGovernor is UpgradeScript { + function run() external setUp { + console2.log("upgrading TaikoGovernor"); + TaikoGovernor newTaikoGovernor = new TaikoGovernor(); + upgrade(address(newTaikoGovernor)); + + console2.log("upgraded TaikoGovernor to", address(newTaikoGovernor)); + } +} diff --git a/packages/protocol/script/upgrade/UpgradeTaikoL1.sol b/packages/protocol/script/upgrade/UpgradeTaikoL1.sol new file mode 100644 index 00000000000..c8ddc342a10 --- /dev/null +++ b/packages/protocol/script/upgrade/UpgradeTaikoL1.sol @@ -0,0 +1,30 @@ +// SPDX-License-Identifier: MIT +// _____ _ _ _ _ +// |_ _|_ _(_) |_____ | | __ _| |__ ___ +// | |/ _` | | / / _ \ | |__/ _` | '_ (_-< +// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/ +// +// Email: security@taiko.xyz +// Website: https://taiko.xyz +// GitHub: https://github.com/taikoxyz +// Discord: https://discord.gg/taikoxyz +// Twitter: https://twitter.com/taikoxyz +// Blog: https://mirror.xyz/labs.taiko.eth +// Youtube: https://www.youtube.com/@taikoxyz + +pragma solidity ^0.8.20; + +import "forge-std/Script.sol"; +import "forge-std/console2.sol"; +import "../../contracts/L1/TaikoL1.sol"; +import "./UpgradeScript.s.sol"; + +contract UpgradeTaikoL1 is UpgradeScript { + function run() external setUp { + console2.log("upgrading TaikoL1"); + TaikoL1 newTaikoL1 = new TaikoL1(); + upgrade(address(newTaikoL1)); + + console2.log("upgraded TaikoL1 to", address(newTaikoL1)); + } +} diff --git a/packages/protocol/script/upgrade/UpgradeTimelockController.s.sol b/packages/protocol/script/upgrade/UpgradeTimelockController.s.sol new file mode 100644 index 00000000000..fc909830dae --- /dev/null +++ b/packages/protocol/script/upgrade/UpgradeTimelockController.s.sol @@ -0,0 +1,30 @@ +// SPDX-License-Identifier: MIT +// _____ _ _ _ _ +// |_ _|_ _(_) |_____ | | __ _| |__ ___ +// | |/ _` | | / / _ \ | |__/ _` | '_ (_-< +// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/ +// +// Email: security@taiko.xyz +// Website: https://taiko.xyz +// GitHub: https://github.com/taikoxyz +// Discord: https://discord.gg/taikoxyz +// Twitter: https://twitter.com/taikoxyz +// Blog: https://mirror.xyz/labs.taiko.eth +// Youtube: https://www.youtube.com/@taikoxyz + +pragma solidity ^0.8.20; + +import "forge-std/Script.sol"; +import "forge-std/console2.sol"; +import "../../contracts/L1/gov/TaikoTimelockController.sol"; +import "./UpgradeScript.s.sol"; + +contract UpgradeTaikoTimelockController is UpgradeScript { + function run() external setUp { + console2.log("upgrading TaikoTimelockController"); + TaikoTimelockController newTaikoTimelockController = new TaikoTimelockController(); + upgrade(address(newTaikoTimelockController)); + + console2.log("upgraded TaikoTimelockController to", address(newTaikoTimelockController)); + } +} diff --git a/packages/protocol/script/upgrade_to.sh b/packages/protocol/script/upgrade_to.sh index 9f68e09dce9..acbfe0e0aaa 100755 --- a/packages/protocol/script/upgrade_to.sh +++ b/packages/protocol/script/upgrade_to.sh @@ -5,6 +5,6 @@ set -e forge script script/upgrade/Upgrade$CONTRACT.s.sol:Upgrade$CONTRACT \ --fork-url $FORK_URL \ + -vvvvv \ --broadcast \ - --ffi \ - -vvvv \ No newline at end of file + --ffi \ \ No newline at end of file