You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The same error was reported with OpenZeppelin's ERC-1155 contract. In this case it was coming from a Solidity call to isContract(), which under the hood calls EXTCODESIZE to determine if the address has any code associated with it. I'm pretty sure the ERC-721 failure has the same root cause.
Our implementation of EXTCODESIZE errors if the supplied address is not an EVM smart contract. Instead, we should behave this way:
If the address is an EVM smart contract, return the length of its EVM bytecode (already implemented).
If the address is an EVM EOA, return 0.
If the address doesn't exist, return 0.
If the address is a secp256k1 or BLS account, return 0 (they are accounts with no associated code -- although this might change with account abstraction!).
If the address is an f2 actor or a built-in singleton => ?
The last case is hairier, as it's an interoperability rough edge. An f2 address or a singleton built-in is a contract, and for all intents and purposes we want an addr.isContract() call to return true, so the value needs to be non-zero.
However, EXTCODESIZE can also be used to size a buffer ahead of a call to EXTCODECOPY. If that's what the contract wants, if we return a non-zero, the caller may proceed with calling EXTCODECOPY and would receive an unexpected error. This is probably fine as the usage of EXTCODECOPY is very limited, and returning EVM code is absolutely impossible here.
The text was updated successfully, but these errors were encountered:
A user has reported this with an ERC-721 token contract:
https://fvm-forum.filecoin.io/t/cannot-invoke-extcodesize-for-non-evm-actor/115
The same error was reported with OpenZeppelin's ERC-1155 contract. In this case it was coming from a Solidity call to
isContract()
, which under the hood calls EXTCODESIZE to determine if the address has any code associated with it. I'm pretty sure the ERC-721 failure has the same root cause.Our implementation of EXTCODESIZE errors if the supplied address is not an EVM smart contract. Instead, we should behave this way:
The last case is hairier, as it's an interoperability rough edge. An f2 address or a singleton built-in is a contract, and for all intents and purposes we want an
addr.isContract()
call to returntrue
, so the value needs to be non-zero.However,
EXTCODESIZE
can also be used to size a buffer ahead of a call toEXTCODECOPY
. If that's what the contract wants, if we return a non-zero, the caller may proceed with callingEXTCODECOPY
and would receive an unexpected error. This is probably fine as the usage ofEXTCODECOPY
is very limited, and returning EVM code is absolutely impossible here.The text was updated successfully, but these errors were encountered: