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

OUSD gas improvements #2287

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

OUSD gas improvements #2287

wants to merge 6 commits into from

Conversation

naddison36
Copy link
Collaborator

@naddison36 naddison36 commented Oct 23, 2024

Contract Changes

  • Changes to the following OUSD functions
    • balanceOf
    • _creditsPerToken
    • _isNonRebasingAccount
    • _ensureRebasingMigration
    • _burn
    • _rebaseOptIn

The approach was to not change the storage structure. The improvements are from not re-reading storage slots or avoiding unnecessary storage reads.

Code Change Checklist

To be completed before internal review begins:

  • The contract code is complete
  • Executable deployment file
  • Fork tests that test after the deployment file runs
  • Unit tests *if needed
  • The owner has done a full checklist review of the code + tests

Internal review:

  • Two approvals by internal reviewers

Gas changes

balanceOf

Set .only in contracts/test/token/ousd.js

describe.only("Should measure gas of balanceOf from", async () => {

Before

Contract Method Min Max Avg # calls
ERC20 balanceOf 28950 34016 31688 3

After

Contract Method Min Max Avg # calls
ERC20 balanceOf 28967 33842 31515 3

transfer

Set .only in contracts/test/token/ousd.js

describe.only("Should transfer the correct amount from a", () => {

Before

Contract Method Min Max Avg # calls
ERC20 transfer 64385 119947 100621 11 │
MockNonRebasing transfer 60338 77545 66109 3 │

After

Contract Method Min Max Avg # calls
ERC20 transfer 58967 119432 98769 11 │
MockNonRebasing transfer 51929 74429 61229 3 │

changeSupply

Set .only in contracts/test/token/ousd.js

it.only("Should measure gas of changeSupply", async () => {

Before

Contract Method Min Max Avg # calls
Echidna changeSupply - - 48572 1 │

After

Contract Method Min Max Avg # calls
Echidna changeSupply - - 47883 1 │

Copy link

github-actions bot commented Oct 23, 2024

Warnings
⚠️ 👀 This PR needs at least 2 reviewers

Generated by 🚫 dangerJS against 5f54f83

Copy link

codecov bot commented Oct 23, 2024

Codecov Report

Attention: Patch coverage is 90.00000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 53.12%. Comparing base (1fb5af0) to head (5f54f83).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
contracts/contracts/token/OUSD.sol 90.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2287      +/-   ##
==========================================
- Coverage   53.26%   53.12%   -0.15%     
==========================================
  Files          79       79              
  Lines        4089     4098       +9     
  Branches     1074     1074              
==========================================
- Hits         2178     2177       -1     
- Misses       1908     1918      +10     
  Partials        3        3              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@naddison36 naddison36 marked this pull request as ready for review October 23, 2024 09:57
sparrowDom
sparrowDom previously approved these changes Oct 23, 2024
Copy link
Member

@sparrowDom sparrowDom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

The code is equivalent to the previous version of it, with slight differences in order which don't have functional impact

clement-ux
clement-ux previously approved these changes Oct 23, 2024
Copy link
Contributor

@clement-ux clement-ux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only a single comment about a scenario that is very unlikely to happen (but not 100% impossible), otherwise everything looks really good to me 👍

contracts/contracts/token/OUSD.sol Show resolved Hide resolved
@sparrowDom sparrowDom dismissed stale reviews from clement-ux and themself via 5f54f83 October 24, 2024 10:27
Copy link
Contributor

@clement-ux clement-ux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me 👍

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

Successfully merging this pull request may close these issues.

4 participants