-
Notifications
You must be signed in to change notification settings - Fork 54
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
[lock/unlock] OP L1 finalization in bridge adapter #606
Conversation
LCOV of commit
|
contracts/src/v0.8/rebalancer/bridge-adapters/OptimismL1BridgeAdapter.sol
Outdated
Show resolved
Hide resolved
contracts/src/v0.8/rebalancer/bridge-adapters/OptimismL1BridgeAdapter.sol
Outdated
Show resolved
Hide resolved
contracts/src/v0.8/rebalancer/bridge-adapters/OptimismL1BridgeAdapter.sol
Show resolved
Hide resolved
contracts/src/v0.8/rebalancer/bridge-adapters/OptimismL1BridgeAdapter.sol
Outdated
Show resolved
Hide resolved
contracts/src/v0.8/rebalancer/bridge-adapters/OptimismL1BridgeAdapter.sol
Outdated
Show resolved
Hide resolved
@@ -45,7 +72,12 @@ contract OptimismL2BridgeAdapter is IBridgeAdapter { | |||
// If the token is the wrapped native, we unwrap it and deposit native | |||
if (localToken == address(i_wrappedNative)) { | |||
i_wrappedNative.withdraw(amount); | |||
i_L2Bridge.withdrawTo(Lib_PredeployAddresses.OVM_ETH, recipient, amount, 0, extraData); | |||
// XXX: Lib_PredeployAddresses.OVM_ETH is actually 0xDeadDeAddeAddEAddeadDEaDDEAdDeaDDeAD0000. |
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.
LMAO nice address
// This code path still works because the L2 bridge is hardcoded to handle this specific address. | ||
// The better approach might be to use the bridgeEthTo function, which is on the StandardBridge | ||
// abstract contract, inherited by both L1StandardBridge and L2StandardBridge. | ||
// This is also marked as legacy, so it might mean that this will be deprecated soon. |
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.
curious why not use bridgeEthTo
if it's better supported?
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.
I'm actually not sure what the difference is, it'd require a whole investigation. I should reach out to Optimism and ask them what's the dealio. I think changing this is better in another PR to keep this PR self-contained. The finalization process is the same either way.
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.
sounds good, please do confirm with them, OP team is kinda known for not being the best with compatibility
contracts/src/v0.8/rebalancer/bridge-adapters/OptimismL1BridgeAdapter.sol
Show resolved
Hide resolved
tests encoding and if logic
LCOV of commit
|
#613) ## Motivation PR #606 implements multi-stage finalization in the Optimism L1 bridge adapter, however this is not functional end-to-end because the Rebalancer assumes that finalization happens in a single step. ## Solution Change the bridge adapter interface to return a boolean from `finalizeWithdrawERC20` that indicates whether the funds are available for use by the rebalancer. The rest of the changes are to get test coverage for this new interface change.
Motivation
The Optimism L1 bridge adapter needs to be able to both prove withdrawals and finalize them on L1.
Solution
withdraw
on the WETH contract prior to bridging.withdrawTo
without actually sending the ETH along with the call. The Optimism contracts dependency we're using isn't bedrock so thewithdrawTo
function signature did not havepayable
. Instead we copy/paste thewithdrawTo
function signature directly fromL2StandardBridge.sol
, since we can't import it directly due to the exact 0.8.15 version specified in the contract's pragma.Follow ups
finalizeWithdrawERC20
will give it access to funds, however this is not the case for Optimism. This will be implemented in an upcoming PR to keep diffs small and manageable.bridgeETHTo
andbridgeERC20To
, which are onStandardBridge.sol
, vs.depositERC20To
andwithdrawTo
which are on L1StandardBridge.sol and L2StandardBridge.sol respectively.