-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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(protocol): l1 and l2 implementation of Lido integration #17632
base: main
Are you sure you want to change the base?
Conversation
feat(protocol): l1 and l2 implementation of Lido integration
🚨 Report Summary
For more details view the full report in OpenZeppelin Code Inspector |
First, i'd have several remarks:
The contracts need to be hooked into our Bridging system somehow. So "something" has to call the |
@@ -0,0 +1,6 @@ | |||
[submodule "lib/forge-std"] | |||
path = lib/forge-std | |||
url = https://github.com/foundry-rs/forge-std |
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 have modules defined in packages/protocol
, do not make another sub-foundry project inside an existing one.
packages/protocol/contracts/thirdparty/lido/src/BridgeableTokens.sol
Outdated
Show resolved
Hide resolved
packages/protocol/contracts/thirdparty/lido/src/BridgeableTokens.sol
Outdated
Show resolved
Hide resolved
Given the GPL license, maybe adding a sub-project makes more sense. And we do need to mark our code to be MIT. |
Any update? |
yes, I understood to make it compatible to our bridge, in the following commit, it will be:
|
Ping me when this PR is ready. But I suggest we get this reviewed and approved by the end of this week. |
I have updated the contract as per the Bridge Implementation and also, made sure it is compatible with our bridge. L2 implementation is also added now |
It seems it is a custom Bridge architecture on the top of our Taiko native Bridge's cross-chain messaging - (which is good) - but i still lacking the bit of the context. For example i mean:
If you could provide some answers to the first 2 points - that would definitely shorten my learning curve and can help a bit more. |
|
* @param to The address from which the tokens will be burned | ||
* @param amount The number of tokens to be burned | ||
*/ | ||
function bridgeBurn(address to, uint256 amount) external onlyBridge { |
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.
function bridgeBurn(address to, uint256 amount) external onlyBridge { | |
function bridgeBurn(address from, uint256 amount) external onlyBridge { |
string memory symbol_, | ||
address l2bridge_ | ||
) | ||
ERC20(name_, symbol_) |
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.
lido's token decimal is 18?
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.
Lidos token decimals on L2 is 18.
_mint(to, amount); | ||
} | ||
|
||
/** |
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.
You can use /// @inheritdoc ITaiILidoBridgedToken
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.24; | ||
|
||
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.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.
maybe put all interfaces inside lido/interfaces
/// @author psirex | ||
/// @notice Contains the logic for validation of tokens used in the bridging process | ||
/// @dev Taken from https://github.com/lidofinance/lido-l2/blob/main/contracts/BridgeableTokens.sol | ||
contract BridgeableTokens { |
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.
So all these contracts are not upgradable?
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.
Currently not upgradable. Will make them upgradable
* (`false`) the contract. | ||
* @param amount_ The amount of tokens being transferred. | ||
*/ | ||
modifier transferL1Tokens(bool isTo, uint256 amount_) { |
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 the token is any arbitrary ERC20 token, then we need this diff-check, if we know it's a specific token implementaiton, we don't.
Is Lido token on L1 a regular ERC20 token?
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 regular erc20. Will remove check
* @param _message The message received from the L2 bridge | ||
* @param _proof The proof of the message | ||
*/ | ||
function receiveMessage(IBridge.Message calldata _message, bytes calldata _proof) external; |
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.
You have to implement the IMessageInvocable
interface in IBridge.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.
You will also need to check permission inside the onMessageInvocation
function, please checkout checkProcessMessageContext
in ERC20Vault.
* @notice Handles a failed message | ||
* @param _message The failed message received | ||
*/ | ||
function handleFailMessage(IBridge.Message calldata _message) external; |
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.
You probably want to implement IRecallableSender.onMessageRecalled
.
* @param _message The failed message | ||
* @param amount_to_receive The amount of tokens to be received as compensation | ||
*/ | ||
function handleFailMessage( |
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 function must be onMessageRecalled
This PR involves work regarding Taiko ~ Lido WstEth Bridge.