Skip to content
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

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

swarna1101
Copy link

@swarna1101 swarna1101 commented Jun 20, 2024

This PR involves work regarding Taiko ~ Lido WstEth Bridge.

  • This PR includes L1 contracts implementation, which are responsible for handling actions like deposit, L1 -> L2, communication, and withdrawals, bridge pausing mechanisms etc.
  • Tests (incomplete)
  • This PR also contains the L2 contracts implementation

@swarna1101 swarna1101 changed the title feat: L1 implementation of Lido integration feat (protocol): L1 implementation of Lido integration Jun 20, 2024
@swarna1101 swarna1101 changed the title feat (protocol): L1 implementation of Lido integration feat(protocol): L1 implementation of Lido integration Jun 20, 2024
@swarna1101 swarna1101 changed the title feat(protocol): L1 implementation of Lido integration feat(protocol): l1 implementation of Lido integration Jun 20, 2024
Copy link

openzeppelin-code bot commented Jun 20, 2024

feat(protocol): l1 and l2 implementation of Lido integration

Generated at commit: 72f2fa9b5b38ca355ed40c57e2376b7dfd44006f

🚨 Report Summary

Severity Level Results
Contracts Critical
High
Medium
Low
Note
Total
2
2
0
9
42
55
Dependencies Critical
High
Medium
Low
Note
Total
0
0
0
0
0
0

For more details view the full report in OpenZeppelin Code Inspector

@adaki2004
Copy link
Contributor

First, i'd have several remarks:

  • I'm not sure if this is the right place for the files. Both file-system level in the repo (packages/protocol), or if this is the suitable repo itself, given it runs under GPL-3.0 license, while we have MIT. (Also pointed out by OpenZeppelin previously in their audit)
  • I dont really get which is the code copied over and which is custom made by @swarna1101 ? I guess all of the solidity code is a take-over, in which case it is not at all final, since we need to adjust/tailor it to our Bridge.
  • Would be good to have a concept, (a tiny/ugly diagram in excalidraw or paint would be enough) where the working mechanics of the whole bridging procedure is visible

The contracts need to be hooked into our Bridging system somehow. So "something" has to call the Bridge's sendMessage function.

@@ -0,0 +1,6 @@
[submodule "lib/forge-std"]
path = lib/forge-std
url = https://github.com/foundry-rs/forge-std
Copy link
Contributor

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.

@dantaik
Copy link
Contributor

dantaik commented Jun 21, 2024

First, i'd have several remarks:

  • I'm not sure if this is the right place for the files. Both file-system level in the repo (packages/protocol), or if this is the suitable repo itself, given it runs under GPL-3.0 license, while we have MIT. (Also pointed out by OpenZeppelin previously in their audit)
  • I dont really get which is the code copied over and which is custom made by @swarna1101 ? I guess all of the solidity code is a take-over, in which case it is not at all final, since we need to adjust/tailor it to our Bridge.
  • Would be good to have a concept, (a tiny/ugly diagram in excalidraw or paint would be enough) where the working mechanics of the whole bridging procedure is visible

The contracts need to be hooked into our Bridging system somehow. So "something" has to call the Bridge's sendMessage function.

Given the GPL license, maybe adding a sub-project makes more sense. And we do need to mark our code to be MIT.

@dantaik
Copy link
Contributor

dantaik commented Jun 24, 2024

Any update?

@swarna1101
Copy link
Author

Any update?

yes, I understood to make it compatible to our bridge, in the following commit, it will be:

  • Compatible bridge
  • Flow chart
  • Minor Fixes with proper licensing

@dantaik
Copy link
Contributor

dantaik commented Jun 25, 2024

Any update?

yes, I understood to make it compatible to our bridge, in the following commit, it will be:

  • Compatible bridge
  • Flow chart
  • Minor Fixes with proper licensing

Ping me when this PR is ready. But I suggest we get this reviewed and approved by the end of this week.

@swarna1101
Copy link
Author

swarna1101 commented Jun 28, 2024

Any update?

I have updated the contract as per the Bridge Implementation and also, made sure it is compatible with our bridge.
e90cf757-b107-4d00-8ab5-64baa7e16166
@adaki2004 added a flow chart as well

L2 implementation is also added now

@swarna1101 swarna1101 changed the title feat(protocol): l1 implementation of Lido integration feat(protocol): l1 and l2 implementation of Lido integration Jun 28, 2024
@adaki2004
Copy link
Contributor

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:

  • Who implemented which contract exactly ? Which is a complete take-over, 100% (which might not require audit) and which is developped completely by you ?
  • This is more of a component-kinda diagram than a flow chart. Would be cool to have a flow/sequence diagram to get to know the exact workflow (in order) to know what users and also reviews need to look and how.
  • I see no unit tests - which would be very helpful also to get the context + flow a bit more.

If you could provide some answers to the first 2 points - that would definitely shorten my learning curve and can help a bit more.

@swarna1101
Copy link
Author

swarna1101 commented Jun 28, 2024

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:

  • Who implemented which contract exactly ? Which is a complete take-over, 100% (which might not require audit) and which is developped completely by you ?
  • This is more of a component-kinda diagram than a flow chart. Would be cool to have a flow/sequence diagram to get to know the exact workflow (in order) to know what users and also reviews need to look and how.
  • I see no unit tests - which would be very helpful also to get the context + flow a bit more.

If you could provide some answers to the first 2 points - that would definitely shorten my learning curve and can help a bit more.

  • All the contracts in packages/protocol/contracts/thirdparty/lido is taken completely from the existing Lido implementation, and all the contracts in packages/protocol/contracts/partners/lido is implemented by me.
  • this is the deposit flow , this is Withdram Flow , and this is fail msg .
  • Yes, unit tests, I will add in next

* @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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
function bridgeBurn(address to, uint256 amount) external onlyBridge {
function bridgeBurn(address from, uint256 amount) external onlyBridge {

string memory symbol_,
address l2bridge_
)
ERC20(name_, symbol_)
Copy link
Contributor

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?

Copy link
Author

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);
}

/**
Copy link
Contributor

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";
Copy link
Contributor

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 {
Copy link
Contributor

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?

Copy link
Author

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_) {
Copy link
Contributor

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?

Copy link
Author

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;
Copy link
Contributor

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

Copy link
Contributor

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;
Copy link
Contributor

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(
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants