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

refactor: rework opcodes definitions and control flow #896

Merged
merged 1 commit into from
Dec 2, 2022

Conversation

Stebalien
Copy link
Member

My goal here was simplify the logic around "exiting" so that I could reason about it. Specifically, so I could fix some issues with SELFDESTRUCT. We had multiple error and success paths and that made me nervous.

In the process, I ended up changing a bunch of other things:

  1. Exit early by setting the PC.
  2. Go back to propagating the error through step() (makes things easier to read).
  3. Fix some rust unsafety things.
  4. Move all of the instruction specific logic into the instruction definitions. This will let us eventually remove one of these tables.
    • This means that instructions manage their own PCs.
  5. Aggressively inline.

@codecov-commenter
Copy link

codecov-commenter commented Dec 2, 2022

Codecov Report

Merging #896 (b76083c) into next (57d1054) will increase coverage by 0.02%.
The diff coverage is 85.18%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             next     #896      +/-   ##
==========================================
+ Coverage   86.87%   86.89%   +0.02%     
==========================================
  Files         127      127              
  Lines       23695    23714      +19     
==========================================
+ Hits        20585    20607      +22     
+ Misses       3110     3107       -3     
Impacted Files Coverage Δ
actors/evm/src/interpreter/output.rs 30.00% <66.66%> (+23.33%) ⬆️
actors/evm/src/lib.rs 86.48% <68.18%> (+4.30%) ⬆️
actors/evm/src/interpreter/instructions/control.rs 89.01% <84.61%> (-4.44%) ⬇️
actors/evm/src/interpreter/instructions/mod.rs 83.00% <91.30%> (+1.51%) ⬆️
actors/evm/src/interpreter/execution.rs 87.50% <100.00%> (-0.22%) ⬇️
...tors/evm/src/interpreter/instructions/lifecycle.rs 91.42% <100.00%> (+0.08%) ⬆️
...ors/evm/src/interpreter/instructions/arithmetic.rs 80.98% <0.00%> (-0.62%) ⬇️
actors/power/src/lib.rs 84.52% <0.00%> (-0.41%) ⬇️
actors/miner/src/lib.rs 83.13% <0.00%> (-0.13%) ⬇️

/// Indicates the "outcome" of the execution.
pub outcome: Outcome,
/// The return data.
pub return_data: Bytes,
}

/// Message status code.
#[must_use]
#[derive(Clone, Debug, Display, PartialEq, Eq)]
pub enum StatusCode {
Copy link
Member Author

Choose a reason for hiding this comment

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

Note: I'm planning on renaming this in a follow up PR (to Error), but I don't want that much churn in this PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

SGTM.

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.

LGTM.
This is becoming almost pretty :)

My goal here was simplify the logic around "exiting" so that I could
reason about it. Specifically, so I could fix some issues with
SELFDESTRUCT. We had multiple error and success paths and that made me
nervous.

In the process, I ended up changing a bunch of other things:

1. Exit early by setting the PC.
2. Go back to propagating the error through `step()` (makes things
easier to read).
3. Fix some rust unsafety things.
4. Move _all_ of the instruction specific logic into the instruction
definitions. This will let us eventually remove one of these tables.
   - This means that instructions manage their own PCs.
5. Aggressively inline.
@Stebalien Stebalien merged commit 07b3ddb into next Dec 2, 2022
@Stebalien Stebalien deleted the steb/refactor-table branch December 2, 2022 15:16
Stebalien added a commit that referenced this pull request Dec 2, 2022
My goal here was simplify the logic around "exiting" so that I could
reason about it. Specifically, so I could fix some issues with
SELFDESTRUCT. We had multiple error and success paths and that made me
nervous.

In the process, I ended up changing a bunch of other things:

1. Exit early by setting the PC.
2. Go back to propagating the error through `step()` (makes things
easier to read).
3. Fix some rust unsafety things.
4. Move _all_ of the instruction specific logic into the instruction
definitions. This will let us eventually remove one of these tables.
   - This means that instructions manage their own PCs.
5. Aggressively inline.
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.

3 participants