Skip to content

Conversation

@mattsse
Copy link
Member

@mattsse mattsse commented Jun 23, 2022

Motivation

As highlighted here #1943 (comment) when impersonating contracts, calls from the impersonated contract get rejected due to EIP-3607.
So it's required to remove the code first manually.

Solution

revm checks eip3607 by looking at the account's code hash, and rejects the call if it is not empty.
this temporarily sets the code hash of a contract to KECCAK_EMPTY so the revm check passes.

The downside of this is that this messes with revm internals and renders the contract's code unusable for the time the contract is impersonated, but the same happens when removing the code manually. So temporarily setting it to empty is less invasive

@mattsse mattsse changed the title feat: bypass eip-3607 when impersonating contracts feat(anvil): bypass eip-3607 when impersonating contracts Jun 23, 2022
@mattsse mattsse added the C-anvil Command: anvil label Jun 23, 2022
Copy link
Member

@gakonst gakonst left a comment

Choose a reason for hiding this comment

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

Makes sense

@gakonst gakonst merged commit 66e8d8c into foundry-rs:master Jun 23, 2022
@Van0k
Copy link

Van0k commented Aug 5, 2022

It appears that on the latest release (0.1.0 (0dc266d 2022-08-05T00:08:59.907525Z)) the issue still persists. Attempting to call a contract from an impersonated account that is a contract results in EVM error RejectCallerWithCode.

@mattsse
Copy link
Member Author

mattsse commented Aug 5, 2022

can you please open a separate issue with a way to reproduce this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-anvil Command: anvil

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants