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

EVM runtime: implement some contextual opcodes + EVM Address type #586

Merged
merged 14 commits into from
Sep 1, 2022

Conversation

raulk
Copy link
Member

@raulk raulk commented Aug 29, 2022

  • Implements handlers for the following opcodes: NUMBER (epoch), DIFFICULTY (zero), COINBASE (zero), SELFBALANCE.
  • Adds an implementation to view and handle the Filecoin Address type from inside the EVM. It adds ID address masking functionality + unit tests. If the uint160 address as supplied by EVM bytecode begins with 0xff, and it continues with 11 zeros, it is interpreted as an ID address (this will be specified in the upcoming addressing spec). Unit tests are included. In the future this type can be extended to perform further conversions.
  • Cleans up the opcode organisation by grouping ext and state opcodes.
  • Adds a commented SELFDESTRUCT implementation, which is not possible as a result of borrow issues in the Runtime because it holds a HAMT (borrowing the blockstore owned by the Runtime) for the entirety of contract execution. We should redesign this.
  • Adds a small impl From<ActorError> for StatusCode error conversion.

Partly covers filecoin-project/ref-fvm#689.

Closes filecoin-project/ref-fvm#821.

actors/evm/src/interpreter/address.rs Show resolved Hide resolved
@maciejwitowski maciejwitowski added this to the M2.1 Selenium (r2) milestone Aug 30, 2022
use crate::U256;
use fvm_shared::address::Address as FilecoinAddress;

/// A Filecoin ad dress as represented in the FEVM runtime.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: unnecessary spaces in ad dress

Copy link
Member Author

Choose a reason for hiding this comment

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

Well spotted!

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed in 1cbcd64.

actors/evm/src/interpreter/address.rs Show resolved Hide resolved
actors/evm/src/interpreter/address.rs Outdated Show resolved Hide resolved
actors/evm/src/interpreter/address.rs Show resolved Hide resolved
@Stebalien Stebalien merged commit 10fae60 into next Sep 1, 2022
@Stebalien Stebalien deleted the raulk/contextual-opcodes branch September 1, 2022 14:51
shamb0 pushed a commit to shamb0/builtin-actors that referenced this pull request Oct 3, 2022
…lecoin-project#586)

* refactor: move opcode handlers to appropriate modules.

* implement BASEFEE opcode handler.

* implement SELFBALANCE opcode handler.

* EVM runtime: add an initial Address type that performs ID address masking.

* EVM runtime: convert EVM errors to ActorErrors.

* EVM runtime: commented selfdestruct.

* EVM runtime: implement DIFFICULTY, NUMBER, COINBASE opcodes.

* EVM runtime: add conversion from actor ID to masked address.

Make CALLER, ADDRESS, ORIGIN use masked ID addresses.

* remove TODO.

* add comment.

* fix clippy.

* adjust test for ID address flag.
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.

5 participants