Skip to content

Commit

Permalink
feat(protocol): proxy upgrade scripts (#13944)
Browse files Browse the repository at this point in the history
  • Loading branch information
cyberhorsey authored Jun 11, 2023
1 parent 66649bd commit ccef198
Show file tree
Hide file tree
Showing 10 changed files with 224 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/protocol/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"snapshot": "forge snapshot --match-path test/**/*.t.sol",
"test": "forge test -vvv --gas-report --fuzz-seed $(date +%s) --match-path test/**/*.t.sol",
"test:coverage": "forge coverage --report lcov",
"test:genesis": "./test/genesis/generate_genesis.test.sh"
"test:genesis": "./test/genesis/generate_genesis.test.sh",
"upgrade": "./script/upgrade_to.sh"
},
"keywords": [
"ZKP",
Expand Down
26 changes: 26 additions & 0 deletions packages/protocol/script/upgrade/UpgradeAddressManager.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// SPDX-License-Identifier: MIT
// _____ _ _ _ _
// |_ _|_ _(_) |_____ | | __ _| |__ ___
// | |/ _` | | / / _ \ | |__/ _` | '_ (_-<
// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/

pragma solidity ^0.8.18;

import "forge-std/Script.sol";
import "forge-std/console2.sol";
import
"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
import "@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol";
import "../../contracts/common/AddressManager.sol";
import "./UpgradeScript.s.sol";

contract UpgradeAddressManager is UpgradeScript {
function run() external setUp {
AddressManager newAddressManager = new ProxiedAddressManager();
proxy.upgradeTo(address(newAddressManager));
console2.log(
"proxy upgraded AddressManager implementation to",
address(newAddressManager)
);
}
}
25 changes: 25 additions & 0 deletions packages/protocol/script/upgrade/UpgradeBridge.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// SPDX-License-Identifier: MIT
// _____ _ _ _ _
// |_ _|_ _(_) |_____ | | __ _| |__ ___
// | |/ _` | | / / _ \ | |__/ _` | '_ (_-<
// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/

pragma solidity ^0.8.18;

import "forge-std/Script.sol";
import "forge-std/console2.sol";
import
"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
import "@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol";
import "../../contracts/bridge/Bridge.sol";
import "./UpgradeScript.s.sol";

contract UpgradeBridge is UpgradeScript {
function run() external setUp {
Bridge newBridge = new ProxiedBridge();
proxy.upgradeTo(address(newBridge));
console2.log(
"proxy upgraded Bridge implementation to", address(newBridge)
);
}
}
33 changes: 33 additions & 0 deletions packages/protocol/script/upgrade/UpgradeScript.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// SPDX-License-Identifier: MIT
// _____ _ _ _ _
// |_ _|_ _(_) |_____ | | __ _| |__ ___
// | |/ _` | | / / _ \ | |__/ _` | '_ (_-<
// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/

pragma solidity ^0.8.18;

import "forge-std/Script.sol";
import "forge-std/console2.sol";
import
"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
import "@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol";

contract UpgradeScript is Script {
uint256 public deployerPrivateKey = vm.envUint("PRIVATE_KEY");

address public proxyAddress = vm.envAddress("PROXY_ADDRESS");

TransparentUpgradeableProxy proxy;

modifier setUp() {
require(deployerPrivateKey != 0, "PRIVATE_KEY not set");
require(proxyAddress != address(0), "PROXY_ADDRESS not set");

vm.startBroadcast(deployerPrivateKey);

proxy = TransparentUpgradeableProxy(payable(proxyAddress));
_;

vm.stopBroadcast();
}
}
26 changes: 26 additions & 0 deletions packages/protocol/script/upgrade/UpgradeSignalService.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// SPDX-License-Identifier: MIT
// _____ _ _ _ _
// |_ _|_ _(_) |_____ | | __ _| |__ ___
// | |/ _` | | / / _ \ | |__/ _` | '_ (_-<
// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/

pragma solidity ^0.8.18;

import "forge-std/Script.sol";
import "forge-std/console2.sol";
import
"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
import "@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol";
import "../../contracts/signal/SignalService.sol";
import "./UpgradeScript.s.sol";

contract UpgradeSignalService is UpgradeScript {
function run() external setUp {
SignalService newSignalService = new ProxiedSignalService();
proxy.upgradeTo(address(newSignalService));
console2.log(
"proxy upgraded SignalService implementation to",
address(newSignalService)
);
}
}
25 changes: 25 additions & 0 deletions packages/protocol/script/upgrade/UpgradeTaikoL1.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// SPDX-License-Identifier: MIT
// _____ _ _ _ _
// |_ _|_ _(_) |_____ | | __ _| |__ ___
// | |/ _` | | / / _ \ | |__/ _` | '_ (_-<
// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/

pragma solidity ^0.8.18;

import "forge-std/Script.sol";
import "forge-std/console2.sol";
import
"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
import "@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol";
import "../../contracts/L1/TaikoL1.sol";
import "./UpgradeScript.s.sol";

contract UpgradeTaikoL1 is UpgradeScript {
function run() external setUp {
TaikoL1 newTaikoL1 = new ProxiedTaikoL1();
proxy.upgradeTo(address(newTaikoL1));
console2.log(
"proxy upgraded taiko L1 implementation to", address(newTaikoL1)
);
}
}
25 changes: 25 additions & 0 deletions packages/protocol/script/upgrade/UpgradeTaikoL2.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// SPDX-License-Identifier: MIT
// _____ _ _ _ _
// |_ _|_ _(_) |_____ | | __ _| |__ ___
// | |/ _` | | / / _ \ | |__/ _` | '_ (_-<
// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/

pragma solidity ^0.8.18;

import "forge-std/Script.sol";
import "forge-std/console2.sol";
import
"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
import "@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol";
import "../../contracts/L2/TaikoL2.sol";
import "./UpgradeScript.s.sol";

contract UpgradeTaikoL2 is UpgradeScript {
function run() external setUp {
TaikoL2 newTaikoL2 = new ProxiedTaikoL2();
proxy.upgradeTo(address(newTaikoL2));
console2.log(
"proxy upgraded TaikoL2 implementation to", address(newTaikoL2)
);
}
}
26 changes: 26 additions & 0 deletions packages/protocol/script/upgrade/UpgradeTaikoToken.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// SPDX-License-Identifier: MIT
// _____ _ _ _ _
// |_ _|_ _(_) |_____ | | __ _| |__ ___
// | |/ _` | | / / _ \ | |__/ _` | '_ (_-<
// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/

pragma solidity ^0.8.18;

import "forge-std/Script.sol";
import "forge-std/console2.sol";
import
"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
import "@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol";
import "../../contracts/L1/TaikoToken.sol";
import "./UpgradeScript.s.sol";

contract UpgradeTaikoToken is UpgradeScript {
function run() external setUp {
TaikoToken newTaikoToken = new ProxiedTaikoToken();
proxy.upgradeTo(address(newTaikoToken));
console2.log(
"proxy upgraded TaikoToken implementation to",
address(newTaikoToken)
);
}
}
26 changes: 26 additions & 0 deletions packages/protocol/script/upgrade/UpgradeTokenVault.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// SPDX-License-Identifier: MIT
// _____ _ _ _ _
// |_ _|_ _(_) |_____ | | __ _| |__ ___
// | |/ _` | | / / _ \ | |__/ _` | '_ (_-<
// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/

pragma solidity ^0.8.18;

import "forge-std/Script.sol";
import "forge-std/console2.sol";
import
"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
import "@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol";
import "../../contracts/bridge/TokenVault.sol";
import "./UpgradeScript.s.sol";

contract UpgradeTokenVault is UpgradeScript {
function run() external setUp {
TokenVault newTokenVault = new ProxiedTokenVault();
proxy.upgradeTo(address(newTokenVault));
console2.log(
"proxy upgraded TokenVault implementation to",
address(newTokenVault)
);
}
}
10 changes: 10 additions & 0 deletions packages/protocol/script/upgrade_to.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh

set -e
: "${FORK_URL:=http://localhost:8545}"

forge script script/upgrade/Upgrade$CONTRACT.s.sol:Upgrade$CONTRACT \
--fork-url $FORK_URL \
--broadcast \
--ffi \
-vvvv

0 comments on commit ccef198

Please sign in to comment.