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

Replace excodesize assembly with address.code.length #3025

Merged
merged 1 commit into from
Dec 15, 2021

Conversation

k06a
Copy link
Contributor

@k06a k06a commented Dec 15, 2021

According to https://github.com/ethereum/solidity/releases/tag/v0.8.1:

Compiler Features:

  • Code Generator: Reduce the cost of <address>.code.length by using extcodesize directly.

Kudos to this tweet: https://twitter.com/transmissions11/status/1470943473335341059

PR Checklist

  • Tests
  • Documentation
  • Changelog entry

Copy link
Collaborator

@Amxx Amxx left a comment

Choose a reason for hiding this comment

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

Thank you @k06a for this PR

@Amxx Amxx merged commit d95cdaa into OpenZeppelin:master Dec 15, 2021
@axic
Copy link
Contributor

axic commented Dec 16, 2021

I was considering submitting such a PR back when 0.8.1 was released, but since the version pragma is unchanged from ^0.8.0, this change can cause grief for users of 0.8.0.

In 0.8.0 the above syntax is supported, but the compiler did not have the shortcut implemented. This means it will first extcodecopy the entire target contract and measure size afterwards.

@k06a
Copy link
Contributor Author

k06a commented Dec 16, 2021

@axic thanks for this clarification! But do you think it is still the case after 0.8.10 release? We could specify solidity version in this file as ^0.8.1.

@axic
Copy link
Contributor

axic commented Dec 16, 2021

You can certainly specify a different pragma, but I've found that the maintainers of OZ were reluctant to use different pragma versions in the code base.

@Amxx
Copy link
Collaborator

Amxx commented Dec 16, 2021

@axic You are right, I should have been more careful before merging this!

One thing that might have changed since last time, it the that repo now uses 0.8.3 for other features. Still, this file's pragma needs to be updated to 0.8.1, which is not currently the case.

@frangio should we revert that commit or update the pragma to ^0.8.1 ?

@koolamusic
Copy link

@Amxx New PR to update 😄 made it easier #3031

@frangio
Copy link
Contributor

frangio commented Dec 16, 2021

My vote in this particular case is to bump this pragma to 0.8.1.

  • It's always good to remove assembly.
  • 0.8.1 is already almost a year old, I expect most users on 0.8 are using newer versions.
  • 0.8.0 to 0.8.1 is unlikely to be very disruptive.

It should be noted as a breaking change in the changelog.

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.

5 participants