-
Notifications
You must be signed in to change notification settings - Fork 6
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
refactor: upgradeable adapters #122
Conversation
…pter * feat: add initialize and authorize upgrade function on universal adapter * refactor: update deployment flow on factory and l2 deploy contracts * chore: update unit tests setup to deploy proxy and implementation
OPT-168 Make adapters upgradeable (again)
Talked to circle and despite us following their process, they want the adapters to be upgradeable incase something related to their process was to ever change. 😞 |
@@ -42,15 +42,13 @@ contract L1OpUSDCBridgeAdapter is IL1OpUSDCBridgeAdapter, OpUSDCBridgeAdapter { | |||
* @param _usdc The address of the USDC Contract to be used by the adapter | |||
* @param _messenger The address of the L1 messenger | |||
* @param _linkedAdapter The address of the linked adapter | |||
* @param _owner The address of the owner of the contract | |||
* @dev The constructor is only used to initialize the OpUSDCBridgeAdapter immutable variables | |||
*/ | |||
constructor( | |||
address _usdc, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sure this contract inherits the UUPSUpgradeable from openzeppelin-upgradeable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or does it not need it because we inherit in the base contract?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah it is inherited on the base contract
@@ -30,7 +30,7 @@ contract L2OpUSDCBridgeAdapter is IL2OpUSDCBridgeAdapter, OpUSDCBridgeAdapter { | |||
bytes4 internal constant _UPGRADE_TO_AND_CALL_SELECTOR = 0x4f1ef286; | |||
|
|||
/// @inheritdoc IL2OpUSDCBridgeAdapter | |||
FallbackProxyAdmin public immutable FALLBACK_PROXY_ADMIN; | |||
FallbackProxyAdmin public FALLBACK_PROXY_ADMIN; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
linter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is no longer immutable, just change it to fallback_proxy_admin
, wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because it behaves as immutable, just that I need to set it on the initialize()
function instead of on constructor. I added a note and the ignore flag.
Wdyt?
FALLBACK_PROXY_ADMIN = new FallbackProxyAdmin(_usdc); | ||
} | ||
address _linkedAdapter | ||
) OpUSDCBridgeAdapter(_usdc, _messenger, _linkedAdapter) {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
be sure to add __gap
variable to reserve slots for new implementations on all three contracts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, good catch!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uint256[50] private __gap;
seems enough, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yea should be fine
* chore: polish tests and add missing ones
* fix: deploy all contracts integration test
address _owner | ||
) Ownable(_owner) EIP712('OpUSDCBridgeAdapter', '1.0.0') { | ||
// solhint-disable-next-line no-unused-vars | ||
constructor(address _usdc, address _messenger, address _linkedAdapter) EIP712('OpUSDCBridgeAdapter', '1.0.0') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very nice catch
* implementation contract | ||
*/ | ||
function initialize(address _owner) public virtual initializer { | ||
__Ownable_init(_owner); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/** | ||
* @notice Checks the caller is the owner to authorize the upgrade | ||
*/ | ||
function _authorizeUpgrade(address) internal virtual override onlyOwner {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
linter
@@ -1,17 +1,19 @@ | |||
pragma solidity ^0.8.25; | |||
|
|||
import {Ownable} from '@openzeppelin/contracts/access/Ownable.sol'; | |||
import {ERC1967Proxy} from '@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol'; | |||
import {IL1OpUSDCBridgeAdapter, L1OpUSDCBridgeAdapter} from 'contracts/L1OpUSDCBridgeAdapter.sol'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
linter
) OpUSDCBridgeAdapter(_usdc, _messenger, _linkedAdapter, _owner) {} | ||
address _linkedAdapter | ||
) OpUSDCBridgeAdapter(_usdc, _messenger, _linkedAdapter) {} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we add the __gap
to the L1 and L2 adapters as well, it will make maintanence should a chain op ever want to upgrade much easier
Deployments:
For OPL1 Adapter owner: L2 Adapter owner: Fallback proxy admin: USDC: USDC owner: USDC admin: |
// Deploy L2 Adapter implementation and proxy, initializing it with the owner | ||
address _l2AdapterImpl = address(new L2OpUSDCBridgeAdapter(_usdcProxy, _L2_MESSENGER, _l1Adapter)); | ||
address _l2Adapter = | ||
address(new ERC1967Proxy(_l2AdapterImpl, abi.encodeCall(OpUSDCBridgeAdapter.initialize, _l2AdapterOwner))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we arent changing anything lets leave it as is, circle uses custom location for their proxy, we dont, it will be easier to read since we dont change anything logic wise
🤖 Linear
Closes OPT-168