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

FIP-0054: Filecoin EVM runtime (FEVM) #569

Merged
merged 37 commits into from
Jan 21, 2023
Merged

Conversation

raulk
Copy link
Member

@raulk raulk commented Dec 12, 2022

Simple Summary

We introduce a new built-in actor: the Filecoin EVM (FEVM) runtime actor, capable of running EVM smart contracts on top of the Filecoin Virtual Machine. We also introduce various changes to the Filecoin Virtual Machine and to client implementations, necessary to support the operation of this new actor.

Abstract

The Filecoin EVM (FEVM) runtime built-in actor runs EVM smart contracts compatible with the Ethereum Paris fork.

It achieves this by embedding a special-purpose EVM interpreter, implementing the integration logic with the Filecoin environment, translating environment-dependent opcodes into their corresponding Filecoin primitives, and mapping all state I/O to the underlying IPLD model.

The EVM interpreter strives for maximal as-is portability. To such avail, it The EVM interpreter supports all required opcodes and Ethereum precompiles to strive for maximal portability. Functional and technical departures from Ethereum's standard expectations are documented herein.

The FEVM runtime actor motivates some changes in the FVM. Syscalls are modified, syscalls are added, new environmental data is required, and new exit codes are created. The concept of a TipsetCID is also introduced formally, and is of required implementation by clients.

This FIP is dependent on FIP-0048 (f4 address class), FIP-0049 (Actor events), and FIP-0055 (Supporting Ethereum Accounts, Addresses, and Transactions).

@raulk raulk changed the title Collaborative FIP draft for EVM compatibility Collaborative FIP draft for EVM compatibility (FEVM) Dec 12, 2022
@kaitlin-beegle
Copy link
Collaborator

Hi @raulk - is there a timeline for completion of the initial draft?

@@ -0,0 +1,1079 @@
---
fip: <to be assigned>
Copy link
Member

@jennijuju jennijuju Dec 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0054

@jennijuju
Copy link
Member

jennijuju commented Dec 15, 2022

I am proactively assigned FIP number to this draft, FIP0054, for nv18 upgrade project management purposes. @filecoin-project/fips-editors

@jennijuju jennijuju changed the title Collaborative FIP draft for EVM compatibility (FEVM) FIP0053- Collaborative FIP draft for EVM compatibility (FEVM) Dec 15, 2022
@jennijuju jennijuju changed the title FIP0053- Collaborative FIP draft for EVM compatibility (FEVM) FIP0054- Collaborative FIP draft for EVM compatibility (FEVM) Dec 15, 2022
These addresses begin with `f410` in textual form.
EVM smart contracts deployed through the EAM acquire an `f410` address.

The **Ethereum Externally Owned Account (EEOA)** actor represents Ethereum identities backed by secp256k1 keys.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i thought we agreed on EthAccount (no more EEOA)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I learnt about the rename recently, and I agree with the motivation. It is already updated, but I think you added this comment before I pushed my latest changes.

@raulk raulk changed the title FIP0054- Collaborative FIP draft for EVM compatibility (FEVM) FIP0054: Filecoin EVM runtime Dec 27, 2022
@raulk raulk changed the title FIP0054: Filecoin EVM runtime FIP0054: Filecoin EVM runtime (FEVM) Dec 27, 2022
FIPS/fip-0054.md Outdated
// Values are encoded as DAG-CBOR byte strings.
ActorEvent {
entries: [
(0x03, "topic1", <first topic word>), // when LOG1, LOG2, LOG3, LOG4
Copy link
Contributor

@maciejwitowski maciejwitowski Jan 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the current code all entries have flag 0x02. Should FIP or code be changed?

@raulk raulk changed the title FIP0054: Filecoin EVM runtime (FEVM) FIP-0054: Filecoin EVM runtime (FEVM) Jan 3, 2023
FIPS/fip-0054.md Outdated
/// CID of the EVM bytecode to invoke under self's context.
pub code: Cid,
/// The contract invocation parameters
pub input: Vec<u8>, // encoded as a DAG-CBOR byte string
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@raulk raulk marked this pull request as ready for review January 10, 2023 00:50
Copy link
Member

@anorth anorth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I have a big discussion item to raise about the privileged treatment of built-in account actors, and assuming they are similar to Ethereum account actors. I will await resolution of which discussion thread to post this (I'm not sure #244 is appropriate).

FIPS/fip-0054.md Outdated Show resolved Hide resolved
FIPS/fip-0054.md Outdated

**Calls: `CALL`.**
Performs a call to another actor, behaving differently depending on the target's actor type.
If the target is another EVM smart contract or a non-account Wasm actor, it invokes its `InvokeContract` method (2).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you be more specific about how it is determined whether the target is an EVM smart contract or an account?

  • For EVM, I guess you check the code CID. Note that this won't work with user-deployed improved EVM actors in the future
  • For "non-account", this distinction will disappear with account abstraction. I strongly suggest not treating "account" actors specially, even now, lest we add friction.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, matching against the actor type for the code CID of the callee (actor::get_builtin_actor_type and actor::get_actor_code_cid syscalls).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussion continued in #592 (comment).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will specify how we do it today, but let's continue discussing potential changes in that thread?

FIPS/fip-0054.md Outdated Show resolved Hide resolved
FIPS/fip-0054.md Show resolved Hide resolved
FIPS/fip-0054.md Outdated Show resolved Hide resolved
Copy link
Member

@Stebalien Stebalien left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll make a pass at fixing these myself, just wanted to get them recorded.


This FIP is dependent on [FIP-0048] (f4 address class), [FIP-0049] (Actor events), and [FIP-0055] (Supporting Ethereum Accounts, Addresses, and Transactions).

## Change Motivation
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably comment on why the EVM first.

FIPS/fip-0054.md Outdated Show resolved Hide resolved
FIPS/fip-0054.md Outdated Show resolved Hide resolved
FIPS/fip-0054.md Outdated Show resolved Hide resolved
FIPS/fip-0054.md Outdated Show resolved Hide resolved
FIPS/fip-0054.md Outdated Show resolved Hide resolved
FIPS/fip-0054.md Show resolved Hide resolved
FIPS/fip-0054.md Show resolved Hide resolved
FIPS/fip-0054.md Show resolved Hide resolved
FIPS/fip-0054.md Outdated Show resolved Hide resolved
Copy link
Contributor

@vyzo vyzo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally looks pretty good to me, left some comments.

FIPS/fip-0054.md Outdated Show resolved Hide resolved
FIPS/fip-0054.md Outdated Show resolved Hide resolved
FIPS/fip-0054.md Outdated Show resolved Hide resolved
FIPS/fip-0054.md Outdated Show resolved Hide resolved
FIPS/fip-0054.md Outdated Show resolved Hide resolved
FIPS/fip-0054.md Outdated Show resolved Hide resolved
FIPS/fip-0054.md Outdated Show resolved Hide resolved
FIPS/fip-0054.md Outdated Show resolved Hide resolved
@kaitlin-beegle kaitlin-beegle merged commit 8d305be into master Jan 21, 2023
@kaitlin-beegle kaitlin-beegle deleted the evm-compatibility branch January 21, 2023 07:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants