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

EVM: Allow calling "native" methods through the CALL instruction

Open Stebalien opened this issue 2 years ago • 0 comments

Currently, calling a native method requires delegate-calling the "call actor" precompile. This:

  1. Is annoying for smart contract developers: requires delegate call, doesn't work with the normal calling convention.
  2. Makes it harder to port existing smart wallets and multisigs.

However, there's a solution: intercept outbound calls to EVM handle_filecoin_method and translate them to native calls.

  • For EVM to EVM calls, this translation will be invisible because the input parameters will be translated back into the solidity ABI format on the other side. (assuming we guarantee that the data always round-trips exactly).
  • For EVM to native calls, this provides a nice way to invoke native actors without having to explicitly support such capabilities.
  • We can (later) extend this feature to EthAccounts, allowing EthAccounts to invoke native methods.

The downsides are:

  1. This is an "implicit" conversion. It should be safe for the reasons above (should be transparent in EVM -> EVM calls), but it's still strange. Technically, the EVM doesn't specify the ABI...
  2. The solidity function name, handle_filecoin_method, is unfortunate. But it's a bit late to change it now.

Stebalien avatar Aug 10 '23 18:08 Stebalien