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

Fix gas loop optimization in MerkleProof.sol (#5028) #5036

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

CarsonCase
Copy link

@CarsonCase CarsonCase commented May 9, 2024

Fixes #5028

Changes are made in 2 commits:

  • c9b7c9b8aa60c3cd45d76f31d89d73f4a1823b60 where i is left uninitialized in for loops, i is prepend incremented and incrementing is done in an unchecked block. This is NOT mentioned in the Loop gas optimisation #5028 issue however, I figured it would be relevant in for loop optimization as the only constraint this introduces is that proof length and totalHashes do not exceed 2^256-1 which is entirely unfeasible.
  • 9e2ba99dfcf5f145fd68c5eea42d899836d9571b includes the fix mentioned in the issue where the length of proof is cached to prevent an unnecessary DUP (3 gas per iteration)

PR Checklist

  • Tests
  • Documentation
  • Changeset entry (run npx changeset add)

Copy link

changeset-bot bot commented May 9, 2024

⚠️ No Changeset found

Latest commit: 9e2ba99

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

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.

Loop gas optimisation
1 participant