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 metering of CRUD methods #10

Open
qizhou opened this issue Nov 3, 2022 · 4 comments
Open

Gas metering of CRUD methods #10

qizhou opened this issue Nov 3, 2022 · 4 comments
Assignees

Comments

@qizhou
Copy link
Contributor

qizhou commented Nov 3, 2022

We recently added merkle root commitment, and we should measure the gas cost and find out potential optimizations.

@LiuJiazheng
Copy link
Collaborator

Sorry for being late for generating a report.
That's report based on main branch contract and tests, about gas consumption (I didn't equip with a COINMARKETCAP_API_KEY, so no real time price in this report).

·-----------------------------------------------------------------------|---------------------------|-------------|-----------------------------·
|                         Solc version: 0.8.16                          ·  Optimizer enabled: true  ·  Runs: 200  ·  Block limit: 30000000 gas  │
········································································|···························|·············|······························
|  Methods                                                                                                                                      │
·······································|································|·············|·············|·············|···············|··············
|  Contract                            ·  Method                        ·  Min        ·  Max        ·  Avg        ·  # calls      ·  usd (avg)  │
·······································|································|·············|·············|·············|···············|··············
|  TestDecentralizedKV                 ·  put                           ·      30056  ·     120314  ·      98397  ·           24  ·          -  │
·······································|································|·············|·············|·············|···············|··············
|  TestDecentralizedKV                 ·  remove                        ·      39997  ·      52282  ·      50235  ·            6  ·          -  │
·······································|································|·············|·············|·············|···············|··············
|  TestDecentralizedKV                 ·  removeTo                      ·          -  ·          -  ·      86365  ·            1  ·          -  │
·······································|································|·············|·············|·············|···············|··············
|  TestDecentralizedKV                 ·  setTimestamp                  ·      26495  ·      43595  ·      35054  ·            4  ·          -  │
·······································|································|·············|·············|·············|···············|··············
|  TestDecentralizedKVDaggerHashimoto  ·  hashimotoKeccak256NonView     ·          -  ·          -  ·     279947  ·            1  ·          -  │
·······································|································|·············|·············|·············|···············|··············
|  TestDecentralizedKVDaggerHashimoto  ·  mine                          ·     141112  ·     219512  ·     180312  ·            2  ·          -  │
·······································|································|·············|·············|·············|···············|··············
|  TestDecentralizedKVDaggerHashimoto  ·  put                           ·     134290  ·    5982498  ·    1872078  ·          114  ·          -  │
·······································|································|·············|·············|·············|···············|··············
|  TestDecentralizedKVDaggerHashimoto  ·  setTimestamp                  ·          -  ·          -  ·      43684  ·            2  ·          -  │
·······································|································|·············|·············|·············|···············|··············
|  TestDecentralizedKVMinable          ·  put                           ·     112158  ·     139530  ·     115341  ·           32  ·          -  │
·······································|································|·············|·············|·············|···············|··············
|  TestDecentralizedKVMinable          ·  remove                        ·          -  ·          -  ·      46987  ·            1  ·          -  │
·······································|································|·············|·············|·············|···············|··············
|  TestDecentralizedKVMinable          ·  rewardMiner                   ·      71984  ·     170390  ·     102762  ·           15  ·          -  │
·······································|································|·············|·············|·············|···············|··············
|  TestDecentralizedKVMinable          ·  sendValue                     ·          -  ·          -  ·      21206  ·            4  ·          -  │
·······································|································|·············|·············|·············|···············|··············
|  TestDecentralizedKVMinable          ·  setTimestamp                  ·          -  ·          -  ·      43640  ·            1  ·          -  │
·······································|································|·············|·············|·············|···············|··············
|  TestKVWithDaggerHash                ·  checkDaggerHashDirectNonView  ·          -  ·          -  ·      91779  ·            1  ·          -  │
·······································|································|·············|·············|·············|···············|··············
|  TestKVWithDaggerHash                ·  checkDaggerHashNonView        ·          -  ·          -  ·      97760  ·            1  ·          -  │
·······································|································|·············|·············|·············|···············|··············
|  TestKVWithDaggerHash                ·  checkDaggerHashNormalNonView  ·          -  ·          -  ·     107863  ·            1  ·          -  │
·······································|································|·············|·············|·············|···············|··············
|  TestKVWithDaggerHash                ·  put                           ·     120509  ·    5973836  ·    3046712  ·            3  ·          -  │
·······································|································|·············|·············|·············|···············|··············
|  TestMerkleLib                       ·  keccak256NoView               ·          -  ·          -  ·     223187  ·            1  ·          -  │
·······································|································|·············|·············|·············|···············|··············
|  TestMerkleLib                       ·  merkleRootNoView              ·      96168  ·     231242  ·     163694  ·            3  ·          -  │
·······································|································|·············|·············|·············|···············|··············
|  Deployments                                                          ·                                         ·  % of limit   ·             │
········································································|·············|·············|·············|···············|··············
|  TestDaggerHashPrecompile                                             ·          -  ·          -  ·     138214  ·        0.5 %  ·          -  │
········································································|·············|·············|·············|···············|··············
|  TestDecentralizedKV                                                  ·    1222592  ·    1222856  ·    1222604  ·        4.1 %  ·          -  │
········································································|·············|·············|·············|···············|··············
|  TestDecentralizedKVDaggerHashimoto                                   ·    2847520  ·    2887407  ·    2853872  ·        9.5 %  ·          -  │
········································································|·············|·············|·············|···············|··············
|  TestDecentralizedKVMinable                                           ·    2581885  ·    2661857  ·    2626930  ·        8.8 %  ·          -  │
········································································|·············|·············|·············|···············|··············
|  TestKVWithDaggerHash                                                 ·    1583175  ·    1583187  ·    1583183  ·        5.3 %  ·          -  │
········································································|·············|·············|·············|···············|··············
|  TestMerkleLib                                                        ·          -  ·          -  ·     648159  ·        2.2 %  ·          -  │
········································································|·············|·············|·············|···············|··············
|  TestStorageManager                                                   ·          -  ·          -  ·     626984  ·        2.1 %  ·          -  │
········································································|·············|·············|·············|···············|··············
|  TestSystemContract                                                   ·          -  ·          -  ·     871593  ·        2.9 %  ·          -  │
········································································|·············|·············|·············|···············|··············
|  TestSystemContractDaggerHashimoto                                    ·          -  ·          -  ·     822631  ·        2.7 %  ·          -  │
·-----------------------------------------------------------------------|-------------|-------------|-------------|---------------|-------------·

@qizhou
Copy link
Contributor Author

qizhou commented Dec 14, 2022

Do you have a comparison with 4KB vs 128KB value size? This would help us to narrow down the optimization space for 128KB value.

@LiuJiazheng
Copy link
Collaborator

Got it. Right now we only have 4KB test case.
I was thinking, if we made a 128KB one, what is a fair comparison between two use cases?
Gas per KB uploaded?

@LiuJiazheng
Copy link
Collaborator

This discussion is obsolescent. The on-chain verification is changing. We will hold this for further discussion, but the data is subject to change.

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