-
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
Changes from all commits
e60e43e
1541ad2
e0e4e93
3e77b1d
954912c
4001a6e
2d5a201
523897d
d4d0ba0
5ae1002
d5d49aa
3d5efec
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,9 @@ contract L1OpUSDCBridgeAdapter is IL1OpUSDCBridgeAdapter, OpUSDCBridgeAdapter { | |
/// @inheritdoc IL1OpUSDCBridgeAdapter | ||
address public burnCaller; | ||
|
||
/// @notice Reserve 50 more storage slots to be safe on future upgrades | ||
uint256[50] private __gap; | ||
|
||
/** | ||
* @notice Modifier to check if the sender is the linked adapter through the messenger | ||
*/ | ||
|
@@ -39,15 +42,26 @@ 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, | ||
address _messenger, | ||
address _linkedAdapter, | ||
address _owner | ||
) OpUSDCBridgeAdapter(_usdc, _messenger, _linkedAdapter, _owner) {} | ||
address _linkedAdapter | ||
) OpUSDCBridgeAdapter(_usdc, _messenger, _linkedAdapter) {} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we add the |
||
/** | ||
* @notice Sets the owner of the contract | ||
* @param _owner The address of the owner | ||
* @dev This function needs only used during the deployment of the proxy contract, and it is disabled for the | ||
* implementation contract | ||
*/ | ||
function initialize(address _owner) external virtual override initializer { | ||
__Ownable_init(_owner); | ||
string memory _name = 'L1OpUSDCBridgeAdapter'; | ||
string memory _version = '1.0.0'; | ||
__EIP712_init(_name, _version); | ||
} | ||
|
||
/*/////////////////////////////////////////////////////////////// | ||
MIGRATION | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,11 +32,15 @@ contract L2OpUSDCBridgeAdapter is IL2OpUSDCBridgeAdapter, OpUSDCBridgeAdapter { | |
bytes4 internal constant _UPDATE_MASTER_MINTER_SELECTOR = 0xaa20e1e4; | ||
|
||
/// @inheritdoc IL2OpUSDCBridgeAdapter | ||
FallbackProxyAdmin public immutable FALLBACK_PROXY_ADMIN; | ||
// solhint-disable-next-line var-name-mixedcase | ||
FallbackProxyAdmin public FALLBACK_PROXY_ADMIN; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. This is no longer immutable, just change it to There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
|
||
/// @inheritdoc IL2OpUSDCBridgeAdapter | ||
address public roleCaller; | ||
|
||
/// @notice Reserve 50 more storage slots to be safe on future upgrades | ||
uint256[50] private __gap; | ||
|
||
/** | ||
* @notice Modifier to check if the sender is the linked adapter through the messenger | ||
*/ | ||
|
@@ -58,13 +62,24 @@ contract L2OpUSDCBridgeAdapter is IL2OpUSDCBridgeAdapter, OpUSDCBridgeAdapter { | |
constructor( | ||
address _usdc, | ||
address _messenger, | ||
address _linkedAdapter, | ||
address _owner | ||
) OpUSDCBridgeAdapter(_usdc, _messenger, _linkedAdapter, _owner) { | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. be sure to add There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. yea should be fine |
||
/* solhint-enable no-unused-vars */ | ||
|
||
/** | ||
* @notice Sets the owner of the contract | ||
* @param _owner The address of the owner | ||
* @dev This function needs only used during the deployment of the proxy contract, and it is disabled for the | ||
* implementation contract | ||
*/ | ||
function initialize(address _owner) external virtual override initializer { | ||
__Ownable_init(_owner); | ||
string memory _name = 'L1OpUSDCBridgeAdapter'; | ||
string memory _version = '1.0.0'; | ||
__EIP712_init(_name, _version); | ||
FALLBACK_PROXY_ADMIN = new FallbackProxyAdmin(USDC); | ||
} | ||
|
||
/*/////////////////////////////////////////////////////////////// | ||
MIGRATION | ||
///////////////////////////////////////////////////////////////*/ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.25; | ||
|
||
import {ERC1967Proxy} from '@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol'; | ||
import {L2OpUSDCBridgeAdapter} from 'contracts/L2OpUSDCBridgeAdapter.sol'; | ||
import {USDC_PROXY_CREATION_CODE} from 'contracts/utils/USDCProxyCreationCode.sol'; | ||
import {IL2OpUSDCDeploy} from 'interfaces/IL2OpUSDCDeploy.sol'; | ||
import {IUSDC} from 'interfaces/external/IUSDC.sol'; | ||
import {OpUSDCBridgeAdapter} from 'src/contracts/universal/OpUSDCBridgeAdapter.sol'; | ||
|
||
/** | ||
* @title L2OpUSDCDeploy | ||
|
@@ -37,13 +39,13 @@ contract L2OpUSDCDeploy is IL2OpUSDCDeploy { | |
// Deploy USDC proxy | ||
bytes memory _usdcProxyCArgs = abi.encode(_usdcImplAddr); | ||
bytes memory _usdcProxyInitCode = bytes.concat(USDC_PROXY_CREATION_CODE, _usdcProxyCArgs); | ||
(address _usdcProxy) = _deployCreate(_usdcProxyInitCode); | ||
address _usdcProxy = _deployCreate(_usdcProxyInitCode); | ||
emit USDCProxyDeployed(_usdcProxy); | ||
|
||
// Deploy L2 Adapter | ||
bytes memory _l2AdapterCArgs = abi.encode(_usdcProxy, _L2_MESSENGER, _l1Adapter, _l2AdapterOwner); | ||
bytes memory _l2AdapterInitCode = bytes.concat(type(L2OpUSDCBridgeAdapter).creationCode, _l2AdapterCArgs); | ||
(address _l2Adapter) = _deployCreate(_l2AdapterInitCode); | ||
// 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 commentThe 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 commentThe 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 |
||
emit L2AdapterDeployed(_l2Adapter); | ||
|
||
// Deploy the FallbackProxyAdmin internally in the L2 Adapter to keep it unique | ||
|
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