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

Save gas for pow by using uncheck #93

Merged
merged 1 commit into from
Jun 19, 2024
Merged

Save gas for pow by using uncheck #93

merged 1 commit into from
Jun 19, 2024

Conversation

qzhodl
Copy link
Contributor

@qzhodl qzhodl commented Jun 14, 2024

We can use unchecked inside the for loop because we know that fp is in the range [0, 2^128), and it can save gas if n is large.

For the storage contract on Sepolia (fp = 340282366367469178095360967382638002176, n = 11043821), the gas cost before the change is 7145, and the cost after the change is 2829, according to the forge gas test report.

@qzhodl qzhodl requested review from qizhou, iteyelmp and syntrust June 14, 2024 11:32
@qzhodl qzhodl merged commit e0f9e8c into main Jun 19, 2024
1 check passed
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.

3 participants