Skip to content

Commit

Permalink
OpenZeppelin Upgrade (ETH-1253) (#248)
Browse files Browse the repository at this point in the history
* forge install: openzeppelin-contracts-upgradeable

v4.9.0

* forge install: openzeppelin-contracts

v4.9.0

* fix: TUPProxy call fix

* forge install: openzeppelin-contracts

v4.9.3

* forge install: openzeppelin-contracts-upgradeable

v4.9.3
  • Loading branch information
iamsahu committed Dec 4, 2023
1 parent 9a9920a commit 0b15fbf
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 13 deletions.
2 changes: 1 addition & 1 deletion contracts/src/TLC.1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import "./interfaces/ITLC.1.sol";
/// @notice Upon deployment, all minted tokens are send to account provided at construction, in charge of creating the vesting schedules
/// @notice The contract is based on ERC20Votes by OpenZeppelin. Users need to delegate their voting power to someone or themselves to be able to vote.
/// @notice The contract contains vesting logics allowing vested users to still be able to delegate their voting power while their tokens are held in an escrow
contract TLCV1 is ERC20VestableVotesUpgradeableV1, ITLCV1 {
contract TLCV1 is ITLCV1, ERC20VestableVotesUpgradeableV1 {
// Token information
string internal constant NAME = "Liquid Collective";
string internal constant SYMBOL = "TLC";
Expand Down
4 changes: 2 additions & 2 deletions contracts/src/components/ERC20VestableVotesUpgradeable.1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ import "../libraries/LibUint256.sol";
/// @notice On Jan 1st 2024, lock period is over and Joe can release all tokens.
abstract contract ERC20VestableVotesUpgradeableV1 is
Initializable,
IERC20VestableVotesUpgradeableV1,
ERC20VotesUpgradeable
ERC20VotesUpgradeable,
IERC20VestableVotesUpgradeableV1
{
// internal used to compute the address of the escrow
bytes32 internal constant ESCROW = bytes32(uint256(keccak256("escrow")) - 1);
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/interfaces/ITLC.1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import "./components/IERC20VestableVotesUpgradeable.1.sol";
/// @title TLC Interface (v1)
/// @author Alluvial
/// @notice TLC token interface
interface ITLCV1 is IERC20VestableVotesUpgradeableV1, IVotesUpgradeable, IERC20Upgradeable {
interface ITLCV1 is IERC20Upgradeable, IVotesUpgradeable, IERC20VestableVotesUpgradeableV1 {
/// @notice Initializes the TLC Token
/// @param _account The initial account to grant all the minted tokens
function initTLCV1(address _account) external;
Expand Down
10 changes: 7 additions & 3 deletions contracts/test/TUPProxy.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import "./utils/LibRlp.sol";

import "../src/TUPProxy.sol";
import "../src/Firewall.sol";
import {ITransparentUpgradeableProxy} from
"openzeppelin-contracts/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";

contract DummyCounter {
error BigError(uint256);
Expand Down Expand Up @@ -95,7 +97,9 @@ contract TUPProxyTest is Test {
function testUpgradeToAndCall() public {
assert(DummyCounter(address(proxy)).i() == 0);
vm.startPrank(admin);
proxy.upgradeToAndCall(address(implemEvolved), abi.encodeWithSignature("initEvolved(uint256)", 5));
ITransparentUpgradeableProxy(address(proxy)).upgradeToAndCall(
address(implemEvolved), abi.encodeWithSignature("initEvolved(uint256)", 5)
);
vm.stopPrank();
assert(DummyCounterEvolved(address(proxy)).i() == 5);
DummyCounterEvolved(address(proxy)).superInc();
Expand Down Expand Up @@ -208,7 +212,7 @@ contract TUPProxyBehindFirewallTest is Test {
function testUpgradeToAndCallFromGovernor() public {
assert(DummyCounter(address(proxy)).i() == 0);
vm.prank(governor);
TUPProxy(payable(address(firewall))).upgradeToAndCall(
ITransparentUpgradeableProxy(payable(address(firewall))).upgradeToAndCall(
address(implemEvolved), abi.encodeWithSignature("initEvolved(uint256)", 5)
);
assert(DummyCounterEvolved(address(proxy)).i() == 5);
Expand All @@ -221,7 +225,7 @@ contract TUPProxyBehindFirewallTest is Test {
assert(DummyCounter(address(proxy)).i() == 0);
vm.prank(executor);
vm.expectRevert(abi.encodeWithSignature("Unauthorized(address)", executor));
TUPProxy(payable(address(firewall))).upgradeToAndCall(
ITransparentUpgradeableProxy(payable(address(firewall))).upgradeToAndCall(
address(implemEvolved), abi.encodeWithSignature("initEvolved(uint256)", 5)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import "forge-std/Test.sol";
import "../../../src/TUPProxy.sol";
import "../../../src/TLC.1.sol";
import "../../../src/state/tlc/VestingSchedules.2.sol";
import {ITransparentUpgradeableProxy} from
"openzeppelin-contracts/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";

contract VestingSchedulesMigrationV1ToV2 is Test {
bool internal _skip = false;
Expand Down Expand Up @@ -35,7 +37,7 @@ contract VestingSchedulesMigrationV1ToV2 is Test {
TLCV1 newImplementation = new TLCV1();

vm.prank(TLC_MAINNET_PROXY_ADMIN_ADDRESS);
tlcProxy.upgradeToAndCall(
ITransparentUpgradeableProxy(address(tlcProxy)).upgradeToAndCall(
address(newImplementation), abi.encodeWithSelector(TLCV1.migrateVestingSchedules.selector)
);

Expand Down
4 changes: 3 additions & 1 deletion contracts/test/fork/mainnet/2.operatorsMigrationV1toV2.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import "forge-std/Test.sol";

import "../../../src/TUPProxy.sol";
import "../../../src/OperatorsRegistry.1.sol";
import {ITransparentUpgradeableProxy} from
"openzeppelin-contracts/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";

contract OperatorsMigrationV1ToV2 is Test {
bool internal _skip = false;
Expand Down Expand Up @@ -35,7 +37,7 @@ contract OperatorsMigrationV1ToV2 is Test {
OperatorsRegistryV1 newImplementation = new OperatorsRegistryV1();

vm.prank(OPERATORS_REGISTRY_MAINNET_PROXY_ADMIN_ADDRESS);
orProxy.upgradeToAndCall(
ITransparentUpgradeableProxy(address(orProxy)).upgradeToAndCall(
address(newImplementation), abi.encodeWithSelector(OperatorsRegistryV1.initOperatorsRegistryV1_1.selector)
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import "forge-std/Test.sol";

import "../../../src/TUPProxy.sol";
import "../../../src/OperatorsRegistry.1.sol";
import {ITransparentUpgradeableProxy} from
"openzeppelin-contracts/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";

contract OperatorsEventsMigrationV1ToV2 is Test {
bool internal _skip = false;
Expand Down Expand Up @@ -37,7 +39,7 @@ contract OperatorsEventsMigrationV1ToV2 is Test {
OperatorsRegistryV1 newImplementation = new OperatorsRegistryV1();

vm.prank(OPERATORS_REGISTRY_MAINNET_PROXY_ADMIN_ADDRESS);
orProxy.upgradeToAndCall(
ITransparentUpgradeableProxy(address(orProxy)).upgradeToAndCall(
address(newImplementation), abi.encodeWithSelector(OperatorsRegistryV1.initOperatorsRegistryV1_1.selector)
);

Expand Down Expand Up @@ -93,7 +95,7 @@ contract OperatorsEventsMigrationV1ToV2 is Test {
OperatorsRegistryV1 newImplementation = new OperatorsRegistryV1();

vm.prank(OPERATORS_REGISTRY_MAINNET_PROXY_ADMIN_ADDRESS);
orProxy.upgradeToAndCall(
ITransparentUpgradeableProxy(address(orProxy)).upgradeToAndCall(
address(newImplementation), abi.encodeWithSelector(OperatorsRegistryV1.initOperatorsRegistryV1_1.selector)
);

Expand Down
2 changes: 1 addition & 1 deletion lib/openzeppelin-contracts
2 changes: 1 addition & 1 deletion lib/openzeppelin-contracts-upgradeable

0 comments on commit 0b15fbf

Please sign in to comment.