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

Hardcord state offset values to save gas and execution time #98

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mininny
Copy link
Collaborator

@mininny mininny commented Dec 10, 2024

Description

Multiple functions are implemented to calculate the state offset of a given field. However, the offset of a field depends on the offset of the previous field until reaching the first offset. As a given offset depends on the previous offset, the code consumes a lot of gas for values that will never change.

For example, calling stateOffsetPreimageKey would consume approximately 444 gas while stateSize consume 1096 gas. Both will always return the same value.

Note that Go slow and fast implementations do not need this type of optimization as computations are cheaper.

@codecov-commenter
Copy link

codecov-commenter commented Dec 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 61.89%. Comparing base (8ff9318) to head (f733dcd).

Additional details and impacted files
@@           Coverage Diff           @@
##           master      #98   +/-   ##
=======================================
  Coverage   61.89%   61.89%           
=======================================
  Files          27       27           
  Lines        4091     4091           
=======================================
  Hits         2532     2532           
  Misses       1427     1427           
  Partials      132      132           

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

@mininny mininny force-pushed the feature/mininny/audit-12 branch from fbc4730 to d68b514 Compare December 10, 2024 14:49
@mininny mininny force-pushed the feature/mininny/audit-12 branch from d68b514 to f733dcd Compare December 10, 2024 14:57
@mininny mininny requested review from clabby and ImTei December 13, 2024 06:55
@BlocksOnAChain BlocksOnAChain added the Audit finding grouping for our audit findings label Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Audit finding grouping for our audit findings
Projects
Development

Successfully merging this pull request may close these issues.

3 participants