Incorrect estimation and high gas costs on first call to deposit::topupDeposit()
#1991
Labels
Agate
Required for mainnet launch
deposit::topupDeposit()
#1991
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: