Skip to content

Optimize precompiles to use STATICCALL#1930

Merged
fubuloubu merged 1 commit into
vyperlang:masterfrom
fubuloubu:1929-staticcall
Apr 22, 2020
Merged

Optimize precompiles to use STATICCALL#1930
fubuloubu merged 1 commit into
vyperlang:masterfrom
fubuloubu:1929-staticcall

Conversation

@fubuloubu

Copy link
Copy Markdown
Contributor

fixes: #1929

What I did

Our precompiled calls were using CALL instead of STATICCALL, overpaying by 660 gas per call. This change switches out how the call is made to cost less gas. No changes required for testing.

Description for the changelog

Optimize precompiles to use STATICCALL

Cute Animal Picture

cute aardvark

@codecov-io

codecov-io commented Apr 18, 2020

Copy link
Copy Markdown

Codecov Report

Merging #1930 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1930   +/-   ##
=======================================
  Coverage   87.07%   87.07%           
=======================================
  Files          55       55           
  Lines        6335     6335           
  Branches     1629     1629           
=======================================
  Hits         5516     5516           
  Misses        520      520           
  Partials      299      299           
Impacted Files Coverage Δ
vyper/functions/functions.py 95.44% <ø> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 08f2e94...af0200f. Read the comment docs.

@fubuloubu fubuloubu merged commit c73d061 into vyperlang:master Apr 22, 2020
@fubuloubu fubuloubu deleted the 1929-staticcall branch April 22, 2020 15:15
@charles-cooper

charles-cooper commented Apr 23, 2020

Copy link
Copy Markdown
Member

For some reason I thought I left a comment here but didn't .. github equivalent of not hitting reply I guess 🙃

My comment was that calls to the identity precompile (address 0x4) could probably also be optimized this way. They are mostly in parser_utils.py.

charles-cooper added a commit to charles-cooper/vyper that referenced this pull request Oct 17, 2021
If we use staticcall, we don't need to pass value=0, saving 2 bytes in
bytecode / 3 gas at runtime

Also, we do not need to have an assert after call to identity (the only
way failure can happen is OOG and by that time it is too late to do
anything anyway).

Related: vyperlang#1929, vyperlang#1930
charles-cooper added a commit that referenced this pull request Oct 19, 2021
If we use staticcall, we don't need to pass value=0, saving 2 bytes in
bytecode / 3 gas at runtime

Also, we do not need to have an assert after call to identity (the only
way failure can happen is OOG and by that time it is too late to do
anything anyway).

Related: #1929, #1930
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.

Vyper is not using staticcall for precompiles

4 participants