-
Notifications
You must be signed in to change notification settings - Fork 0
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
Incorrect estimation and high gas costs on first call to deposit::topupDeposit()
#1991
Comments
deposit::topupDeposit()
deposit::topupDeposit()
@86667 If you look at the traces of the you will see that the only thing that makes a huge difference is the amount of gas used in the
|
@DrZoltanFazekas thanks. I understand where the cost is coming from and have reduced it here in this PR. Still would like to reduce it further if I can. Review request incoming |
Suggest you create a branch for this and other upcoming deposit contract changes (e.g. #2057 and fixes for audit findings) in the zq2 repo. We'll need another upgrade to deploy them on the proto-networks... |
When the deposit contract's
topupDeposit()
function is called for the very first time (in the example below from a proto-testnet delegation contract'sstake()
function) it uses a large amount of gas:When it's called for the second time by another staker's control address (i.e. in the example below by another delegation contract) it uses one order of magnitude less gas:
Finally, each time it's called by the same staker's control address again, it uses a constant amount of gas:
Most likely the first initialization of storage slots makes the very first call so expensive. Investigate how to make the distribution of gas costs across the calls more fair.
Another issue that was observed is that if the first call was in a transaction submitted from the Rabby wallet, the transaction ran out of gas i.e. the estimation delivered a gas limit that was too low to execute the transaction. If the transaction was submitted using a Forge script like above, the estimated gas limit was sufficient though.
The text was updated successfully, but these errors were encountered: