Skip to content

Expand getCode caching logic for SELFDESTRUCT via DELEGATECALL#1002

Merged
iamdefinitelyahuman merged 2 commits intomasterfrom
fix-getcode-caching
Mar 19, 2021
Merged

Expand getCode caching logic for SELFDESTRUCT via DELEGATECALL#1002
iamdefinitelyahuman merged 2 commits intomasterfrom
fix-getcode-caching

Conversation

@iamdefinitelyahuman
Copy link
Copy Markdown
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