Skip to content

Commit

Permalink
add UpgradeExecutorUpgradeAction
Browse files Browse the repository at this point in the history
  • Loading branch information
godzillaba committed Oct 16, 2024
1 parent 51db9a3 commit d74a6d9
Show file tree
Hide file tree
Showing 2 changed files with 104 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.16;

import "@offchainlabs/upgrade-executor/src/UpgradeExecutor.sol";

import {
ProxyAdmin,
TransparentUpgradeableProxy
} from "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol";

contract UpgradeExecutorUpgradeAction {
address public immutable newUpgradeExecutorImplementation;
ProxyAdmin public immutable proxyAdmin;

constructor(ProxyAdmin _proxyAdmin) {
proxyAdmin = _proxyAdmin;
newUpgradeExecutorImplementation = address(new UpgradeExecutor());
}

function perform() external {
TransparentUpgradeableProxy proxy = TransparentUpgradeableProxy(payable(address(this)));

ProxyAdmin(proxyAdmin).upgrade(proxy, newUpgradeExecutorImplementation);

require(
ProxyAdmin(proxyAdmin).getProxyImplementation(proxy) == newUpgradeExecutorImplementation,
"UpgradeExecutorUpgradeAction: upgrade failed"
);
}
}

// Proxy Admins:
// Arb1: 0xdb216562328215E010F819B5aBe947bad4ca961e
// Nova: 0xf58eA15B20983116c21b05c876cc8e6CDAe5C2b9
// L1: 0x5613AF0474EB9c528A34701A5b1662E3C8FA0678

contract ArbOneUpgradeExecutorUpgradeAction is UpgradeExecutorUpgradeAction {
constructor()
UpgradeExecutorUpgradeAction(ProxyAdmin(0xdb216562328215E010F819B5aBe947bad4ca961e))
{}
}

contract NovaUpgradeExecutorUpgradeAction is UpgradeExecutorUpgradeAction {
constructor()
UpgradeExecutorUpgradeAction(ProxyAdmin(0xf58eA15B20983116c21b05c876cc8e6CDAe5C2b9))
{}
}

contract L1UpgradeExecutorUpgradeAction is UpgradeExecutorUpgradeAction {
constructor()
UpgradeExecutorUpgradeAction(ProxyAdmin(0x5613AF0474EB9c528A34701A5b1662E3C8FA0678))
{}
}
51 changes: 51 additions & 0 deletions test/gov-actions/UpgradeExecutorUpgradeAction.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.16;

import "forge-std/Test.sol";
import "@offchainlabs/upgrade-executor/src/UpgradeExecutor.sol";

import "src/gov-action-contracts/AIPs/upgrade-executor-upgrade/UpgradeExecutorUpgradeAction.sol";

contract UpgradeExecutorUpgradeActionTest is Test {
function testArbOne() external {
vm.createSelectFork(vm.envString("ARB_URL"));
_testUpgrade(
new ArbOneUpgradeExecutorUpgradeAction(),
UpgradeExecutor(0xCF57572261c7c2BCF21ffD220ea7d1a27D40A827),
0xf7951D92B0C345144506576eC13Ecf5103aC905a
);
}

function testNova() external {
vm.createSelectFork(vm.envString("NOVA_URL"));
_testUpgrade(
new NovaUpgradeExecutorUpgradeAction(),
UpgradeExecutor(0x86a02dD71363c440b21F4c0E5B2Ad01Ffe1A7482),
0xf7951D92B0C345144506576eC13Ecf5103aC905a
);
}

function testL1() external {
vm.createSelectFork(vm.envString("ETH_URL"));
_testUpgrade(
new L1UpgradeExecutorUpgradeAction(),
UpgradeExecutor(0x3ffFbAdAF827559da092217e474760E2b2c3CeDd),
0xE6841D92B0C345144506576eC13ECf5103aC7f49
);
}

function _testUpgrade(
UpgradeExecutorUpgradeAction action,
UpgradeExecutor ue,
address executor
) internal {
vm.prank(executor);
ue.execute(address(action), abi.encodeWithSignature("perform()"));

assertTrue(
ProxyAdmin(action.proxyAdmin()).getProxyImplementation(
TransparentUpgradeableProxy(payable(address(ue)))
) == action.newUpgradeExecutorImplementation()
);
}
}

0 comments on commit d74a6d9

Please sign in to comment.