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

Expand getCode caching logic for SELFDESTRUCT via DELEGATECALL #1002

Merged
merged 2 commits into from
Mar 19, 2021

Conversation

iamdefinitelyahuman
Copy link
Member

What I did

Expand the logic when determining if bytecode may be cached. In particular, consider an indirect SELFDESTRUCT via DELEGATECALL.

Thanks to @banteg for pointing this one out. I am a bad devloper and I'm not sure why any of you use my code.

How I did it

The new implementation is fairly well commented, but the gist of it is:

  • remove the bytecode after PUSH instructions to avoid false positives
  • scan for DELEGATECALL and if it isn't preceded by PUSH20 [address] GAS assume it to be dynamic and thus not cacheable
  • where an address is hardcoded, also check if the target address is cachable

This isn't perfect but it should err on the side of caution.

How to verify it

I actually wrote tests on this! Good job, me.

@iamdefinitelyahuman iamdefinitelyahuman merged commit 94bf3bd into master Mar 19, 2021
@iamdefinitelyahuman iamdefinitelyahuman deleted the fix-getcode-caching branch March 19, 2021 22:05
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.

1 participant