Skip to content

Rewrite exponentiation to bitshift #794

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

Merged
merged 2 commits into from
Jul 16, 2025
Merged

Conversation

blishko
Copy link
Collaborator

@blishko blishko commented Jul 15, 2025

The legacy codegen of Solidity uses exponentiation to simulate bitshift. This was needed back when EVM did not have left bitshift instruction. See also ethereum/solidity#16117 This pattern occurs when storing a value smaller that a storage slot size, i.e., when Solidity packs multiple values into one storage slot.

We can detect this pattern and replace it with actual bitshift. This should remove one possible source of exponentiation and allow us to verify more contracts.

Description

Checklist

  • tested locally
  • added automated tests
  • updated the docs
  • updated the changelog

@blishko blishko marked this pull request as draft July 15, 2025 14:38
The legacy codegen of Solidity uses exponentiation to simulate bitshift.
This was needed back when EVM did not have left bitshift instruction.
See also ethereum/solidity#16117
This pattern occurs when storing a value smaller that a storage slot
size, i.e., when Solidity packs multiple values into one storage slot.

We can detect this pattern and replace it with actual bitshift.
This should remove one possible source of exponentiation and allow us to
verify more contracts.
@blishko blishko force-pushed the deal-with-exp-in-storage-write branch from 7c67aad to 2c0ee2c Compare July 15, 2025 15:32
@blishko blishko requested a review from msooseth July 15, 2025 15:33
@blishko blishko marked this pull request as ready for review July 15, 2025 15:37
Copy link
Collaborator

@msooseth msooseth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some confusion, sorry. Plus a minor ask to make the comment a bit shorter regarding Solidity.

@msooseth msooseth merged commit eb9a3f3 into main Jul 16, 2025
9 checks passed
@msooseth msooseth deleted the deal-with-exp-in-storage-write branch July 16, 2025 08:17
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.

2 participants