-
Notifications
You must be signed in to change notification settings - Fork 212
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
Merge StETH and Lido into the one contract #225
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This pull is still WIP since tests related to the |
f38b4c3
to
f3812cc
Compare
skozin
approved these changes
Dec 7, 2020
krogla
approved these changes
Dec 8, 2020
This was referenced Dec 14, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The changes are aimed to remove a lot of cross calls between the Lido and the StETH smart contracts and simplify the protocol's code.
The protocol code in the Lido contract is closely coupled with StETH token. Basic operations like deposits and reward distribution require multiple reads and writes between the Lido and the StETH contracts. This makes then costly, and doubly so because of the Aragon tax.
The pull request makes StETH a base contract for Lido, eliminating the need to the numerous cross calls. StETH is an abstract contract implementing ERC20 spec. It encapsulates the logic of share-based balances and methods like
_transferShares
,_mintShares
and_burnShares
. Note that the only virtual function is_getTotalPooledEther
, and the Lido as a subclass contract implements it.burnShares
is moved to the Lido code and is wrapped with ACL role checker. PublicmintShares
method was deleted since only the Lido protocol is authorized to mint tokens. It does it through the internal_mintShares
method.While the current result is bigger than what we have started from, it's still bellow the maximum ethereum contract size (24576 bytes) and the total amount of the code we're deploying to the blockchain is 7644 bytes less.
Lido contract before merge: 18973 bytes
StETH contract before merge: 9993 bytes
Lido contract after merge: 21322 bytes
The updated
submit
method is almost twice cheaper than the current one. As every protocol user bears the gas costs of calling it, optimizing the method is quite important for the Lido.First
submit
call from the address: current 158494 gas, pull version 86335 gasNext
submit
calls from the address: current 146494 gas, pull version 74335 gas