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

Minor transfer optimization #295

Merged
merged 3 commits into from
May 25, 2022

Conversation

Vectorized
Copy link
Collaborator

@Vectorized Vectorized commented May 25, 2022

Inspired by transmissions11/solmate#252.

It has been under our noses all these while!

Saves around 60 gas on its own.

Did some extra stuff like assembly casting of address to uint256 and comparing to zero to cut down 36 more gas.

To credit @rotcivegaf upon next release. :)

Before:

·-------------------------------------------|---------------------------|-------------|-----------------------------·
|           Solc version: 0.8.11            ·  Optimizer enabled: true  ·  Runs: 800  ·  Block limit: 30000000 gas  │
············································|···························|·············|······························
|  Methods                                                                                                          │
···························|················|·············|·············|·············|···············|··············
|  Contract                ·  Method        ·  Min        ·  Max        ·  Avg        ·  # calls      ·  usd (avg)  │
···························|················|·············|·············|·············|···············|··············
|  ERC721AGasReporterMock  ·  mintOne       ·      56213  ·      90413  ·      56897  ·           50  ·          -  │
···························|················|·············|·············|·············|···············|··············
|  ERC721AGasReporterMock  ·  mintTen       ·      73840  ·     108040  ·      75484  ·           52  ·          -  │
···························|················|·············|·············|·············|···············|··············
|  ERC721AGasReporterMock  ·  safeMintOne   ·      58943  ·      93143  ·      59627  ·           50  ·          -  │
···························|················|·············|·············|·············|···············|··············
|  ERC721AGasReporterMock  ·  safeMintTen   ·      76548  ·     110748  ·      77232  ·           50  ·          -  │
···························|················|·············|·············|·············|···············|··············
|  ERC721AGasReporterMock  ·  transferFrom  ·      44488  ·      86187  ·      46573  ·           20  ·          -  │
···························|················|·············|·············|·············|···············|··············
|  Deployments                              ·                                         ·  % of limit   ·             │
············································|·············|·············|·············|···············|··············
|  ERC721AGasReporterMock                   ·          -  ·          -  ·    1033019  ·        3.4 %  ·          -  │
·-------------------------------------------|-------------|-------------|-------------|---------------|-------------·

After:

·-------------------------------------------|---------------------------|-------------|-----------------------------·
|           Solc version: 0.8.11            ·  Optimizer enabled: true  ·  Runs: 800  ·  Block limit: 30000000 gas  │
············································|···························|·············|······························
|  Methods                                                                                                          │
···························|················|·············|·············|·············|···············|··············
|  Contract                ·  Method        ·  Min        ·  Max        ·  Avg        ·  # calls      ·  usd (avg)  │
···························|················|·············|·············|·············|···············|··············
|  ERC721AGasReporterMock  ·  mintOne       ·      56195  ·      90395  ·      56879  ·           50  ·          -  │
···························|················|·············|·············|·············|···············|··············
|  ERC721AGasReporterMock  ·  mintTen       ·      73822  ·     108022  ·      75466  ·           52  ·          -  │
···························|················|·············|·············|·············|···············|··············
|  ERC721AGasReporterMock  ·  safeMintOne   ·      58925  ·      93125  ·      59609  ·           50  ·          -  │
···························|················|·············|·············|·············|···············|··············
|  ERC721AGasReporterMock  ·  safeMintTen   ·      76530  ·     110730  ·      77214  ·           50  ·          -  │
···························|················|·············|·············|·············|···············|··············
|  ERC721AGasReporterMock  ·  transferFrom  ·      44392  ·      86091  ·      46477  ·           20  ·          -  │
···························|················|·············|·············|·············|···············|··············
|  Deployments                              ·                                         ·  % of limit   ·             │
············································|·············|·············|·············|···············|··············
|  ERC721AGasReporterMock                   ·          -  ·          -  ·    1031927  ·        3.4 %  ·          -  │
·-------------------------------------------|-------------|-------------|-------------|---------------|-------------·

@Vectorized Vectorized requested a review from cygaar May 25, 2022 11:07
contracts/ERC721A.sol Show resolved Hide resolved
@Vectorized Vectorized merged commit 37e7393 into chiru-labs:main May 25, 2022
@Vectorized Vectorized deleted the feature/transferOpt branch June 7, 2022 21:39
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.

None yet

2 participants