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(contracts): lido gateway #988

Merged
merged 16 commits into from
Jan 16, 2024
Merged

feat(contracts): lido gateway #988

merged 16 commits into from
Jan 16, 2024

Conversation

zimpha
Copy link
Member

@zimpha zimpha commented Oct 12, 2023

Purpose or design rationale of this PR

This PR implements the Lido L1 and L2 Gateways.

PR title

Your PR title must follow conventional commits (as we are doing squash merge for each PR), so it must start with one of the following types:

  • feat: A new feature

Deployment tag versioning

Has tag in common/version.go been updated or have you added bump-version label to this PR?

  • No, this PR doesn't involve a new deployment, git tag, docker image tag

Breaking change label

Does this PR have the breaking-change label?

  • No, this PR is not a breaking change

@zimpha zimpha self-assigned this Oct 12, 2023
@zimpha zimpha marked this pull request as ready for review October 26, 2023 05:50
@zimpha zimpha requested review from Thegaram, iczc and icemelon October 26, 2023 05:51
@github-actions
Copy link

github-actions bot commented Oct 26, 2023

LCOV of commit f08e0d8 during Contracts #130

Summary coverage rate:
  lines......: 55.0% (1142 of 2077 lines)
  functions..: 69.1% (259 of 375 functions)
  branches...: no data found

Files changed coverage rate: n/a

Thegaram
Thegaram previously approved these changes Nov 8, 2023
contracts/src/lido/LidoGatewayManager.sol Show resolved Hide resolved
contracts/src/lido/L1LidoGateway.sol Show resolved Hide resolved
contracts/src/lido/README.md Show resolved Hide resolved
@Thegaram
Copy link
Contributor

Thegaram commented Nov 8, 2023

Storage layouts (for reference):

> forge inspect L1CustomERC20Gateway storage-layout --pretty
| Name          | Type                        | Slot | Offset | Bytes | Contract                                                      |
|---------------|-----------------------------|------|--------|-------|---------------------------------------------------------------|
| _initialized  | uint8                       | 0    | 0      | 1     | src/L1/gateways/L1CustomERC20Gateway.sol:L1CustomERC20Gateway |
| _initializing | bool                        | 0    | 1      | 1     | src/L1/gateways/L1CustomERC20Gateway.sol:L1CustomERC20Gateway |
| _status       | uint256                     | 1    | 0      | 32    | src/L1/gateways/L1CustomERC20Gateway.sol:L1CustomERC20Gateway |
| __gap         | uint256[49]                 | 2    | 0      | 1568  | src/L1/gateways/L1CustomERC20Gateway.sol:L1CustomERC20Gateway |
| __gap         | uint256[50]                 | 51   | 0      | 1600  | src/L1/gateways/L1CustomERC20Gateway.sol:L1CustomERC20Gateway |
| _owner        | address                     | 101  | 0      | 20    | src/L1/gateways/L1CustomERC20Gateway.sol:L1CustomERC20Gateway |
| __gap         | uint256[49]                 | 102  | 0      | 1568  | src/L1/gateways/L1CustomERC20Gateway.sol:L1CustomERC20Gateway |
| counterpart   | address                     | 151  | 0      | 20    | src/L1/gateways/L1CustomERC20Gateway.sol:L1CustomERC20Gateway |
| router        | address                     | 152  | 0      | 20    | src/L1/gateways/L1CustomERC20Gateway.sol:L1CustomERC20Gateway |
| messenger     | address                     | 153  | 0      | 20    | src/L1/gateways/L1CustomERC20Gateway.sol:L1CustomERC20Gateway |
| __rateLimiter | address                     | 154  | 0      | 20    | src/L1/gateways/L1CustomERC20Gateway.sol:L1CustomERC20Gateway |
| __gap         | uint256[46]                 | 155  | 0      | 1472  | src/L1/gateways/L1CustomERC20Gateway.sol:L1CustomERC20Gateway |
| __gap         | uint256[50]                 | 201  | 0      | 1600  | src/L1/gateways/L1CustomERC20Gateway.sol:L1CustomERC20Gateway |
| tokenMapping  | mapping(address => address) | 251  | 0      | 32    | src/L1/gateways/L1CustomERC20Gateway.sol:L1CustomERC20Gateway |

> forge inspect L1LidoGateway storage-layout --pretty 
| Name           | Type                        | Slot | Offset | Bytes | Contract                                 |
|----------------|-----------------------------|------|--------|-------|------------------------------------------|
| _initialized   | uint8                       | 0    | 0      | 1     | src/lido/L1LidoGateway.sol:L1LidoGateway |
| _initializing  | bool                        | 0    | 1      | 1     | src/lido/L1LidoGateway.sol:L1LidoGateway |
| _status        | uint256                     | 1    | 0      | 32    | src/lido/L1LidoGateway.sol:L1LidoGateway |
| __gap          | uint256[49]                 | 2    | 0      | 1568  | src/lido/L1LidoGateway.sol:L1LidoGateway |
| __gap          | uint256[50]                 | 51   | 0      | 1600  | src/lido/L1LidoGateway.sol:L1LidoGateway |
| _owner         | address                     | 101  | 0      | 20    | src/lido/L1LidoGateway.sol:L1LidoGateway |
| __gap          | uint256[49]                 | 102  | 0      | 1568  | src/lido/L1LidoGateway.sol:L1LidoGateway |
| counterpart    | address                     | 151  | 0      | 20    | src/lido/L1LidoGateway.sol:L1LidoGateway |
| router         | address                     | 152  | 0      | 20    | src/lido/L1LidoGateway.sol:L1LidoGateway |
| messenger      | address                     | 153  | 0      | 20    | src/lido/L1LidoGateway.sol:L1LidoGateway |
| __rateLimiter  | address                     | 154  | 0      | 20    | src/lido/L1LidoGateway.sol:L1LidoGateway |
| __gap          | uint256[46]                 | 155  | 0      | 1472  | src/lido/L1LidoGateway.sol:L1LidoGateway |
| __gap          | uint256[50]                 | 201  | 0      | 1600  | src/lido/L1LidoGateway.sol:L1LidoGateway |
| __tokenMapping | mapping(address => address) | 251  | 0      | 32    | src/lido/L1LidoGateway.sol:L1LidoGateway |

> forge inspect L2CustomERC20Gateway storage-layout --pretty
| Name          | Type                        | Slot | Offset | Bytes | Contract                                                      |
|---------------|-----------------------------|------|--------|-------|---------------------------------------------------------------|
| _initialized  | uint8                       | 0    | 0      | 1     | src/L2/gateways/L2CustomERC20Gateway.sol:L2CustomERC20Gateway |
| _initializing | bool                        | 0    | 1      | 1     | src/L2/gateways/L2CustomERC20Gateway.sol:L2CustomERC20Gateway |
| _status       | uint256                     | 1    | 0      | 32    | src/L2/gateways/L2CustomERC20Gateway.sol:L2CustomERC20Gateway |
| __gap         | uint256[49]                 | 2    | 0      | 1568  | src/L2/gateways/L2CustomERC20Gateway.sol:L2CustomERC20Gateway |
| __gap         | uint256[50]                 | 51   | 0      | 1600  | src/L2/gateways/L2CustomERC20Gateway.sol:L2CustomERC20Gateway |
| _owner        | address                     | 101  | 0      | 20    | src/L2/gateways/L2CustomERC20Gateway.sol:L2CustomERC20Gateway |
| __gap         | uint256[49]                 | 102  | 0      | 1568  | src/L2/gateways/L2CustomERC20Gateway.sol:L2CustomERC20Gateway |
| counterpart   | address                     | 151  | 0      | 20    | src/L2/gateways/L2CustomERC20Gateway.sol:L2CustomERC20Gateway |
| router        | address                     | 152  | 0      | 20    | src/L2/gateways/L2CustomERC20Gateway.sol:L2CustomERC20Gateway |
| messenger     | address                     | 153  | 0      | 20    | src/L2/gateways/L2CustomERC20Gateway.sol:L2CustomERC20Gateway |
| __rateLimiter | address                     | 154  | 0      | 20    | src/L2/gateways/L2CustomERC20Gateway.sol:L2CustomERC20Gateway |
| __gap         | uint256[46]                 | 155  | 0      | 1472  | src/L2/gateways/L2CustomERC20Gateway.sol:L2CustomERC20Gateway |
| __gap         | uint256[50]                 | 201  | 0      | 1600  | src/L2/gateways/L2CustomERC20Gateway.sol:L2CustomERC20Gateway |
| tokenMapping  | mapping(address => address) | 251  | 0      | 32    | src/L2/gateways/L2CustomERC20Gateway.sol:L2CustomERC20Gateway |

> forge inspect L2LidoGateway storage-layout --pretty      
| Name           | Type                        | Slot | Offset | Bytes | Contract                                 |
|----------------|-----------------------------|------|--------|-------|------------------------------------------|
| _initialized   | uint8                       | 0    | 0      | 1     | src/lido/L2LidoGateway.sol:L2LidoGateway |
| _initializing  | bool                        | 0    | 1      | 1     | src/lido/L2LidoGateway.sol:L2LidoGateway |
| _status        | uint256                     | 1    | 0      | 32    | src/lido/L2LidoGateway.sol:L2LidoGateway |
| __gap          | uint256[49]                 | 2    | 0      | 1568  | src/lido/L2LidoGateway.sol:L2LidoGateway |
| __gap          | uint256[50]                 | 51   | 0      | 1600  | src/lido/L2LidoGateway.sol:L2LidoGateway |
| _owner         | address                     | 101  | 0      | 20    | src/lido/L2LidoGateway.sol:L2LidoGateway |
| __gap          | uint256[49]                 | 102  | 0      | 1568  | src/lido/L2LidoGateway.sol:L2LidoGateway |
| counterpart    | address                     | 151  | 0      | 20    | src/lido/L2LidoGateway.sol:L2LidoGateway |
| router         | address                     | 152  | 0      | 20    | src/lido/L2LidoGateway.sol:L2LidoGateway |
| messenger      | address                     | 153  | 0      | 20    | src/lido/L2LidoGateway.sol:L2LidoGateway |
| __rateLimiter  | address                     | 154  | 0      | 20    | src/lido/L2LidoGateway.sol:L2LidoGateway |
| __gap          | uint256[46]                 | 155  | 0      | 1472  | src/lido/L2LidoGateway.sol:L2LidoGateway |
| __gap          | uint256[50]                 | 201  | 0      | 1600  | src/lido/L2LidoGateway.sol:L2LidoGateway |
| __tokenMapping | mapping(address => address) | 251  | 0      | 32    | src/lido/L2LidoGateway.sol:L2LidoGateway |

@zimpha zimpha changed the title feat(contracts): draft version of lido gateway feat(contracts): lido gateway Nov 27, 2023
contracts/src/lido/README.md Outdated Show resolved Hide resolved
contracts/src/lido/README.md Outdated Show resolved Hide resolved
contracts/src/lido/README.md Outdated Show resolved Hide resolved
contracts/src/lido/README.md Outdated Show resolved Hide resolved
@icemelon
Copy link
Member

could you benchmark the gas cost of lido bridge?

Copy link

@TheDZhon TheDZhon left a comment

Choose a reason for hiding this comment

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

Hello, thank you for all of the efforts, team 👍
Awesome work!

I want to add some input from the NEW tech wing side 🙏

Will get back to you by late Wednesday with more details; just decided to put forward major suggestions and proposals on the go to make things more agile

contracts/src/lido/README.md Outdated Show resolved Hide resolved
contracts/src/lido/README.md Outdated Show resolved Hide resolved
contracts/src/lido/README.md Outdated Show resolved Hide resolved
contracts/src/lido/README.md Show resolved Hide resolved
contracts/src/lido/README.md Outdated Show resolved Hide resolved
contracts/src/lido/README.md Show resolved Hide resolved
contracts/src/lido/LidoGatewayManager.sol Show resolved Hide resolved
Copy link

@TheDZhon TheDZhon left a comment

Choose a reason for hiding this comment

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

Left the follow-up review 🙏
Please consider addressing the provided concerns if possible 👀

contracts/src/lido/L1LidoGateway.sol Show resolved Hide resolved
contracts/src/lido/L1LidoGateway.sol Show resolved Hide resolved
contracts/src/lido/L1LidoGateway.sol Show resolved Hide resolved
contracts/src/lido/L1LidoGateway.sol Show resolved Hide resolved
contracts/src/lido/README.md Outdated Show resolved Hide resolved
contracts/src/lido/L2LidoGateway.sol Show resolved Hide resolved
contracts/src/lido/L2LidoGateway.sol Show resolved Hide resolved
contracts/src/lido/LidoGatewayManager.sol Outdated Show resolved Hide resolved
contracts/src/lido/README.md Show resolved Hide resolved
contracts/src/lido/README.md Show resolved Hide resolved
Copy link

codecov bot commented Dec 22, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (317ba26) 56.15% compared to head (b644d4e) 56.45%.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #988      +/-   ##
===========================================
+ Coverage    56.15%   56.45%   +0.29%     
===========================================
  Files          145      149       +4     
  Lines        11014    11087      +73     
===========================================
+ Hits          6185     6259      +74     
+ Misses        4407     4406       -1     
  Partials       422      422              
Flag Coverage Δ
contracts 56.96% <100.00%> (+1.68%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@zimpha
Copy link
Member Author

zimpha commented Dec 22, 2023

could you benchmark the gas cost of lido bridge?

will do after rebasing with #1011

@zimpha
Copy link
Member Author

zimpha commented Jan 8, 2024

could you benchmark the gas cost of lido bridge?

@icemelon

L1LidoGateway.depositERC20 wstETH before upgrade: GasUsed[318426]
L1GatewayRouter.depositERC20 wstETH before upgrade: GasUsed[344334]
L1LidoGateway.depositERC20 wstETH after upgrade: GasUsed[191018]
L1GatewayRouter.depositERC20 wstETH after upgrade: GasUsed[216926]

L2LidoGateway.withdrawERC20 wstETH before upgrade: GasUsed[209866]
L2GatewayRouter.withdrawERC20 wstETH before upgrade: GasUsed[219707]
L2LidoGateway.withdrawERC20 wstETH after upgrade: GasUsed[201687]
L2GatewayRouter.withdrawERC20 wstETH after upgrade: GasUsed[211483]

icemelon
icemelon previously approved these changes Jan 16, 2024
Thegaram
Thegaram previously approved these changes Jan 16, 2024
contracts/src/lido/LidoGatewayManager.sol Outdated Show resolved Hide resolved
contracts/src/lido/L1LidoGateway.sol Show resolved Hide resolved
contracts/scripts/foundry/DeployLidoGateway.s.sol Outdated Show resolved Hide resolved
@zimpha zimpha dismissed stale reviews from Thegaram and icemelon via b644d4e January 16, 2024 14:21
@icemelon icemelon merged commit 69224eb into develop Jan 16, 2024
11 checks passed
@icemelon icemelon deleted the feat/lido_gateway branch January 16, 2024 18:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants