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

EVM: Make DelegateCall Generic

Open Stebalien opened this issue 2 years ago • 2 comments

Per @anorth's request, this is how we'd make DelegateCall "generic" to avoid any type checking:

  1. Export GetBytecode as an frc42 method. We'd call it something like GetEVMBytecode
  2. Blindly call this method to get the bytecode, or "nothing".
    1. If we receive bytecode, we load and execute it.
    2. If we receive nothing (block 0) but the call succeeds, we return success. This will cover the account, placeholder, etc. cases.
    3. If we receive an error, we return a revert to the user.

NOTE I would not make EXTCODEHASH or EXTCODECOPY generic (for now, at least) as users likely rely on those as trusted ways to determine the target actor's code type. However, if a user is blindly calling into some actor with DELEGATECALL, there really isn't any security risk in just doing what they ask.

Stebalien avatar Jan 31 '23 05:01 Stebalien

The big question is: timing. IMO:

  1. This is the right approach and is something we should do.
  2. This isn't critical now and can land in a future upgrade.

The important part, as far as I understand it, is to have a path to removing the special case.

Stebalien avatar Jan 31 '23 05:01 Stebalien

So long as we don't get locked in to the "wrong" way by deploying it and having people write smart contracts, I'm ok with it being deferred to FVM native. Perhaps describe this plan in the FIP.

anorth avatar Feb 02 '23 00:02 anorth