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

Measure gas usage on L2 when adding synths - DebtCache Vs RealtimeDebtCache #1189

Open
3 tasks done
i-stam opened this issue Mar 31, 2021 · 1 comment
Open
3 tasks done
Assignees

Comments

@i-stam
Copy link
Contributor

i-stam commented Mar 31, 2021

Summary:
Given the 9mil tx gas limit that exists on L2, we would like to investigate the impact of adding new synths on exchanging costs (in terms of gas). For this reason, we want also to check whether the enabling of DebtCach on L2 alleviates the problem or not.

Relevant Info

RealtimeDebtCache OVM instance: https://github.com/Synthetixio/synthetix/tree/multisig-simulation-kova-ovm-test
DebtCache OVM instance: https://github.com/Synthetixio/synthetix/tree/debCache-l2
Note: the initial measurements show that DebtCache's `takeDebtSnapshot() is the real bottleneck.

`Dev Tasks:

  • Report gas costs: L2 (RealtimeDebtCache) for exchanging in Mainnet-ovm, Kovan-ovm(more synths) and Kovan-ovm-test (less synths).

Realtime Debt Cache
3 synths (sUSD, sETH, sBTC) - no fee reclamation
gas-used: sUSD-sBTC gasUsed: 5,947,547
gas-used: sBTC-sETH gasUsed: 5,028,973
gas-used: sUSD-sETH gasUsed: 4,509,600

4 synths (sUSD, sETH, sBTC, sLINK) - no fee reclamation
gas-used: sUSD-sLINK gasUsed: 5,947,601
gas-used: sUSD-sBTC gasUsed: 4,520,061
gas-used: sLINK-sETH gasUsed: 5,028,967

5 synths (sUSD, sETH, sBTC, sLINK, sUNI) - no fee reclamation
gas-used: sUSD-sUNI gasUsed: 5,947,589
gas-used: sUNI-sBTC gasUsed: 5,039,394
gas-used: sUSD-sUNI gasUsed: 4,509,606
gas-used: sUNI-sLINK gasUsed: 5,039,454

6 synths (sUSD, sETH, sBTC, sLINK, sUNI, sAAVE) - no fee reclamation
gas-used: sBTC-sAAVE gasUsed: 6,466,904
gas-used: sLINK-sAAVE gasUsed: 5,039,446
gas-used: sUSD-sBTC gasUsed: 4,509,624

6 synths (sUSD, sETH, sBTC, sLINK, sUNI, sAAVE) - no fee reclamation
gas-used: sUSD-sRUNE gasUsed: 5,947,575
gas-used: sRUNE-sLINK gasUsed: 5,039,442

13 synths (sUSD, sETH, sBTC, sLINK, sUNI, sAAVE...) - no fee reclamation
gas-used: sBTC-sREN gasUsed: 6,466,904
gas-used: sLINK-sXMR gasUsed: 6,466,962
gas-used: sXMR -sREN gasUsed: 5,039,468

  • Hand over measurements to Kevin for feedback.
  • Add DebtCache support on L2 and make new measurements.

Debt Cache
2 synths (sUSD, sETH) - no fee reclamation
gas-used: sUSD-sETH gasUsed: 6,642,322
gas-used: sUSD-sETH gasUsed: 5,024,044

3 synths (sUSD, sETH, sBTC) - no fee reclamation
gas-used: sUSD-sBTC gasUsed: 6,409,677
gas-used: sUSD-sBTC gasUsed: 4,971,740
gas-used: sBTC-sETH gasUsed: 5,691,923
gas-used: sUSD-sETH gasUsed: 5,024,062

6 synths (sUSD, sETH, sBTC, sLINK) - no fee reclamation
snapshot: gas used: 3,457,216
gas-used: sUSD-sLINK gasUsed: 6,409,753
gas-used: sUSD-sUNI gasUsed: 6,409,699
gas-used: sUNI-sAAVE gasUsed: 7,067,120
gas-used: sBTC-sAAVE gasUsed: 5,650,095
gas-used: sUNI-sAAVE gasUsed: 5,650,089

9 synths (sUSD, sETH, sBTC, sLINK) - no fee reclamation
snapshot: gas used: 4,874,795
gas-used: sLINK-sYFI gasUsed: 7,077,557
gas-used: sYFI-sSUSHI gasUsed: 7,077,563
gas-used: sYFI-sSUSHI gasUsed: 7,077,563
gas-used: sSUSHI-sYFI gasUsed: 5,650,101

12 synths (sUSD, sETH, sBTC, sLINK) - no fee reclamation
snapshot: gas used: 6,153,165
gas-used: sBTC-sBAL gasUsed: 7,077,581
gas-used: sBAL-sDOT gasUsed: 7,077,563
gas-used: sBAL-sDOT gasUsed: 4,982,203
gas-used: sUSD-sBTC gasUsed: 4,982,203

@i-stam i-stam created this issue from a note in West Synthetix (Next) Mar 31, 2021
@i-stam i-stam self-assigned this Mar 31, 2021
@i-stam i-stam changed the title Enable debt cache in L2 Enable DebtCache in L2 Mar 31, 2021
@gberg1 gberg1 moved this from Next to In Progress in West Synthetix Apr 1, 2021
@gberg1 gberg1 changed the title Enable DebtCache in L2 Measure gas usage with different synths on L2 Apr 7, 2021
@i-stam i-stam changed the title Measure gas usage with different synths on L2 Measure gas usage on L2 when adding synths - DebtCache Vs RealtimeDebtCache Apr 8, 2021
@i-stam i-stam moved this from In Progress to QA in West Synthetix Apr 8, 2021
@i-stam i-stam assigned jjgonecrypto and theethernaut and unassigned i-stam Apr 8, 2021
@theethernaut
Copy link
Contributor

This is great! Thanks @i-stam

So, what can we read from these measurements? I'll list a few that come to my mind immediately. Perhaps we can later validate/falsify them on a discussion:

  1. With realtime debt cache, gas is high, but it doesn't grow that fast.
  2. I can't see a much of a gas improvement with debt caching enabled. Even feels a little worse, which is a bit counterintuitive.
  3. What does increase very quickly is the call to take the snapshot. Why?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

No branches or pull requests

4 participants
@theethernaut @jjgonecrypto @i-stam and others