ref-fvm icon indicating copy to clipboard operation
ref-fvm copied to clipboard

EVM: EXTCODEHASH and SELFDESTRUCT

Open raulk opened this issue 2 years ago • 1 comments

When a contract self-destructs, it marks itself as dead. If a subsequent transaction calls EXTCODEHASH, we return whatever the EVM actor returned from GetBytecodeHash. For dead contracts, this is the EMPTY hash. I believe we modelled this after EIP-1052.

However, we have reports from the community saying that this behaviour diverges from Ethereum, who returns 0 when calling EXTCODEHASH on a self-destructed contract on a subsequent transaction.

Apprently this is the result of both https://eips.ethereum.org/EIPS/eip-161 and https://eips.ethereum.org/EIPS/eip-1052.

raulk avatar Mar 27 '23 21:03 raulk

Well, sort of. The EVM returns 0 until funds are first sent to the address, after which it returns EMPTY. We could introduce an "if dead and balance is 0" check, but any code relying on that fact is likely broken anyways.

Well, I guess it could be doing this as a short-cut to avoid calling the BALANCE instruction?

Stebalien avatar Mar 27 '23 22:03 Stebalien