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

Gas optimizations for deposit process #82

Closed
vshvsh opened this issue Oct 21, 2020 · 2 comments
Closed

Gas optimizations for deposit process #82

vshvsh opened this issue Oct 21, 2020 · 2 comments
Assignees
Milestone

Comments

@vshvsh
Copy link
Contributor

vshvsh commented Oct 21, 2020

Currently, the submit function, compiled with 200 optimizer iterations, consumes around 577000 gas plus 107000 gas for each registered validator, so the default limit is set by deploy scripts to 16 validators to make the submit transaction occupy no more than 20% of a block. See this file for the related calculations; you can run them with yarn estimate-deposit-loop-gas.

That is on average 130k+ gas per validation key in a batch of 16, about twice as much as a simple deposit. We might find a way to make this number lower.

Note: Switching to the official Deposit contract #88 will impact the numbers mentioned above

@vshvsh vshvsh added this to the RC2 milestone Oct 21, 2020
@vshvsh vshvsh changed the title Gas. optimizations for deposit process Gas optimizations for deposit process Oct 22, 2020
Klyaus added a commit that referenced this issue Oct 23, 2020
Issue: #88
Related issue: #82

Add official deposit contract
Update tests with deposit
ongrid pushed a commit that referenced this issue Oct 26, 2020
Issue: #88
Related issue: #82

Add official deposit contract
Update tests with deposit
@ujenjt ujenjt self-assigned this Oct 31, 2020
@ujenjt
Copy link
Member

ujenjt commented Nov 2, 2020

I've set up an experiment and measure gas-consuming by different deposit transactions. Initially, I've added 16 Staking Providers (SP) and then measure how much gas consumes the call of pool.deposit with 33 ETH, 65ETH and 97ETH. Currently, I am using the mock instead of the real deposit contract. I've extracted the most gas-consuming stages from the deposit transactions. See the table below.

Description 33 ETH 65 ETH 97 ETH
tx total gas 862.6k 1161k 1459k
minting StETH 100k 100k 100k
load all SPs from storage 300k 300k 300k
load signing keys from storage 22k 45k 68k
perform stake to mock deposit 260k 516k 762k
save updated SPs to storage 30k 38k 48k
the rest of the code 150k 162k 181k

I've attached a row output of the profiling for that three transactions.

16sp_33eth_deposit.txt
16SP_65eth_deposit.txt
16SP_97eth_deposit.txt

@ujenjt
Copy link
Member

ujenjt commented Dec 15, 2020

Fixed in #107 and #225

@ujenjt ujenjt closed this as completed Dec 15, 2020
dechjo pushed a commit to dechjo/lido-dao that referenced this issue Jan 26, 2021
Issue: lidofinance#88
Related issue: lidofinance#82

Add official deposit contract
Update tests with deposit
tamtamchik pushed a commit that referenced this issue Sep 30, 2024
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

No branches or pull requests

2 participants