Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling Ethereum calls #718

Closed
raulk opened this issue Jun 29, 2022 · 3 comments
Closed

Handling Ethereum calls #718

raulk opened this issue Jun 29, 2022 · 3 comments

Comments

@raulk
Copy link
Member

raulk commented Jun 29, 2022

This are just some initial thoughts to kickstart a discussion.

Context

EVM smart contracts can call other code by performing CALL, CALLCODE, DELEGATECALL, STATICCALL opcodes. Let's specify the differences by working out through the following example.

Address A (externally owned account) calls address B (smart contract), and B performs a __________ to address C (smart contract), where _________ is...

Opcode Description msg.sender storage affected side effects
CALL Message-call into an account B C allowed
CALLCODE Message-call into this account with alternative account’s code B (*) B allowed
DELEGATECALL Message-call into this account with an alternative account’s code, but persisting the current values for sender and value A B allowed
STATICCALL Static message-call into an account B B disallowed (**)

(Descriptions from https://www.evm.codes/)

(*) This was deemed a bug and CALLCODE was eventually replaced with DELEGATECALL in EIP-7. .callcode() was removed from Solidity in 2018, and it is only accessible via EVM assembly.

(**) Side effects are listed in EIP-214. Performing side effects returns an exception (i.e. success output parameter is 0).

Discussion

Resolving addresses

All these operations can be called on two kinds of addresses:

  • Ethereum addresses (usually derived from cryptographic material, e.g. ecrecover)
  • f2 addresses (expected to be user input)

The Ethereum registry serves two purposes:

  • Holds mappings between Ethereum and Filecoin f2 addresses -- both of which are backed by the same secp256k1 key
  • Serves as a holding pen for funds sent counterfactually, concretely on sends to unmapped Ethereum addresses (both accounts and contract addresses). These funds can be claimed later by associating an f2 address.

❓ Question: how do the call handlers interact with the registry?

CALLCODE

Should we drop support for CALLCODE? Solidity no longer supports it and it's highly unlikely that we'll encounter this scenario. We could make usages of CALLCODE abort.

CALL

This is just a normal send.

DELEGATECALL

The FVM will need to cooperate here. We will need a mechanism to call other code within our own context / Kernel.

STATICCALL

Call the target actor with a special kernel that prohibits side effects?

@anorth
Copy link
Member

anorth commented Jun 30, 2022

Can I clarify that this is mostly about calling other EVM contracts? We're not talking about DELEGATECALL to a native actor or anything like that.

@Stebalien
Copy link
Member

Yes. But, specifically:

We will need a mechanism to call other code within our own context / Kernel.

We can implement this as either a native DELEGATECALL syscall, or as some form of dynamic library feature.

@raulk raulk transferred this issue from filecoin-project/fvm-specs Aug 18, 2022
@raulk raulk added this to the M2.1 Copper (r3) milestone Aug 18, 2022
This was referenced Sep 13, 2022
@maciejwitowski
Copy link
Contributor

Closing this one after splitting into:
#870
#871
#872

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

No branches or pull requests

4 participants