-
Notifications
You must be signed in to change notification settings - Fork 0
Custom USDC bridge #1
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
Conversation
ca62b13 to
3f38ad5
Compare
3f38ad5 to
a6c88ec
Compare
SOP-53 Create L1SharedBridge.sol
Create a custom L1SharedBridge.sol that works with the USDC implementation |
federava
left a comment
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 looks great! The implementation is clear, and the test coverage is thorough.
|
Look good overall I think, the main is a direct clone of one of era_contracts repo right? I would get rid of even more of the legacy code, I don't think you need it, modifying the interfaces is ok. But the approach/security/code looks good! |
Thanks for the comments! |
would you point me to which are the other legacy things that we are safe to remove? |
src/L1SharedBridge.sol
Outdated
| } | ||
| } | ||
|
|
||
| // TODO: do we need? |
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.
@kelemeno do we need this? or it's safe to be removed?
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 you can remove.
fcc50ac to
dc65224
Compare
this is the commit we've forked from https://github.com/matter-labs/era-contracts.git#bce4b2d0f34bd87f1aaadd291772935afb1c3bd6 |
Add utils to save deployed addresses
LSB-01S: sanitise constructor inputs
LSE-01S: sanitise constructor inputs
LSB-01M: add sanitisation of L2 Value
LSE-01M: add input validation on l1TokenAddress and l2TokenAddress functions
LSE-01C: gas opti
Omniscia Audit
We want to use the canonical zkSync Bridge with a custom bridge implementation that works only for USDC (since we want to use the native USDC and not the ERC20 that the zksync bridge deploys by default).
The PR is a little bit large but the key contracts to review are:
Bridge/Withdrawal flow
The flow to bridge and withdraw using custom bridges is the same as when bridging with any token except for the fact that when
Bridgehubis called, you need specify the address of the custom L1 bridge.To bridge USDC from L1 (Ethereum) -> L2 (Sophon):
bridgehub.requestL2TransactionTwoBridges(same as normally) but you set thesecondBridgeAddresswith the custom shared bridge deployed on L1. This way, the bridgehub contracts knows which contract to ping to.requestL2TransactionTwoBridgesmakes a call to the custom shared bridgecustomBridgeL1.bridgehubDepositfunction and transfersUSDCfrom the user to this contract and emits an event.customL2Bridge.finalizeDepositon the custom bridge deployed on L2 (on Sophon).finalizeDepositis the one that callsusdc.mint()to mintUSDCon L2 (note this custom bridge must haveMINTERrole on theUSDCcontract).To withdraw USDC from L2 (Sophon) -> L1 (Etheruem):
customBridgeL2.withdraw(same as normally except for the fact that you're calling the custom bridge contract)customL1Bridge.finalizeWithdrawalto finalise the withdrawalFixes #SOP-53
Fixes #SOP-54
Fixes #SOP-88
Fixes #SOP-89