-
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
feat: migrating usdc to native flow #24
Conversation
OPT-73 USDC Native Migration Flow
L1 Adapter:
L2 Adapter:
|
// TODO: Implement this in future PR | ||
function migrateToNative( | ||
address _messenger, | ||
address _circle, |
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.
Missing a check over _circle != address(0)
that could break the logic
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.
But maybe this check would fit better inside the prepareNativeMigration
function
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 is a check for this
opUSDC/src/contracts/UpgradeManager.sol
Line 127 in a0eb0dd
if (_migration.circle == address(0) || _migration.executor == address(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.
True 👍
* @dev This only starts the process, full migration cant finish until L1 receives the message for setting the burn amount | ||
* @param _newOwner The address to transfer ownerships to | ||
* @param _setBurnAmountMinGasLimit Minimum gas limit that the setBurnAmount message we are sending can be executed on L1 |
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.
style: linter warning
if (circle != address(0)) revert IOpUSDCBridgeAdapter_MigrationInProgress(); | ||
|
||
circle = _circle; | ||
messengerStatus[_messenger] = Status.Deprecated; |
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.
Is it worth to create a transitioned state for the 'in upgrade' state?
Because, what happens if the function args are bad and it fails on L2, or even the prepraed migration is wrong?
I think we should allow to re-send the native message while it's paused on L1.
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 i like this we can set it as Upgrading, and deptrcate it when we receive the setBurnAmount
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.
Exactly
); | ||
|
||
emit MigratingToNative(_messenger, _circle); | ||
emit CircleSet(_circle); |
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.
Why is this event needed if it only used in this function and also present in the event above?
@@ -78,25 +78,21 @@ contract L1OpUSDCBridgeAdapter is OpUSDCBridgeAdapter, UUPSUpgradeable, IL1OpUSD | |||
/** | |||
* @notice Sets the amount of USDC tokens that will be burned when the burnLockedUSDC function is called | |||
* @param _amount The amount of USDC tokens that will be burned | |||
* @dev Only callable by the UpgradeManager | |||
* @dev Only callable by a whitelisted messenger during its migration process |
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 change is not applied on the interface.
// Execute the L2 Adapter initialization transactions | ||
if (_l2AdapterInitTxs.length > 1) { | ||
if (_l2AdapterInitTxs.length > 0) { | ||
// Initialize L2 adapter | ||
for (uint256 i = 1; i < _l2AdapterInitTxs.length; i++) { | ||
for (uint256 i; i < _l2AdapterInitTxs.length; i++) { |
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.
It started from 1
because the item 0
of the array is already used on the initialize tx done when l2 adapter proxy is created
@@ -71,9 +70,9 @@ contract L1OpUSDCBridgeAdapter_Unit_Constructor is Base { | |||
|
|||
contract L1OpUSDCBridgeAdapter_Unit_SetBurnAmount is Base { | |||
/** | |||
* @notice Check that the function reverts if the sender is not in a deprecated state | |||
* @notice Check that the function reverts if the sender is not in a upgrading state |
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 Check that the function reverts if the sender is not in a upgrading state | |
* @notice Check that the function reverts if the messenger is not in an upgrading state |
@@ -99,7 +98,7 @@ contract L1OpUSDCBridgeAdapter_Unit_SetBurnAmount is Base { | |||
* @notice Check that the burn amount is set as expected | |||
*/ | |||
function test_setAmount(uint256 _burnAmount) external { | |||
adapter.forTest_setMessagerStatus(_messenger, IL1OpUSDCBridgeAdapter.Status.Deprecated); | |||
adapter.forTest_setMessagerStatus(_messenger, IL1OpUSDCBridgeAdapter.Status.Upgrading); |
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.
Would be nice to add the exact same test, but setting Active
as status so we also cover the first part of the conditional
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 the burn amount which can only be called when its upgrading, do you mean the other scenario? I believe we have both branches covered
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.
Ah true, I confused 🙏
if (messengerStatus[_messenger] != Status.Active && messengerStatus[_messenger] != Status.Upgrading) { | ||
revert IOpUSDCBridgeAdapter_MessagingDisabled(); | ||
} | ||
if (circle != address(0)) revert IOpUSDCBridgeAdapter_MigrationInProgress(); |
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.
We need to remove this check right? Otherwise if it's in Upgrading
state it will revert here
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.
Fantastic job ser! 🚀
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.
Outstanding as always!
🤖 Linear
Closes OPT-73