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

feat: EVM Interpreter in Yul #327

Closed
wants to merge 100 commits into from

Conversation

jrchatruc
Copy link
Contributor

What ❔

Why ❔

Checklist

  • PR title corresponds to the body of PR (we generate changelog entries from PRs).
  • Tests for the changes have been added / updated.
  • Documentation comments have been added / updated.

@jrchatruc jrchatruc changed the title [WIP] EVM Interpreter in Yul feat: EVM Interpreter in Yul Apr 8, 2024
jrchatruc and others added 24 commits April 8, 2024 17:31
This way it reflects the official docs
…king

Add gas tracking and properly return values instead of relying on the sstore instruction
[EVM-Equivalent-YUL] Add `or` and `push` implementation
[EVM-Equivalent-YUL] Add exp and signextend opcodes
[EVM-Equivalent-YUL] Add addmod and mulmod opcodes
With this change, the function will stop doing N (from pushN) `add`s,
but only one, whatever N be.
[EVM-Equivalent-YUL] Add div, sdiv, mod, smod opcodes
[EVM-Equivalent-YUL] Optimize readBytes function used by pushN opcodes
ManuelBilbao and others added 27 commits April 11, 2024 13:57
…xpansion

[EVM-Equivalent-Yul] Add memory expansion functions
[EVM-Equivalent-Yul] Add mload, mstore and mstore8 opcodes
[EVM-Equivalent-YUL] Stack/Memory instructions sload, sstore and msize
[EVM-Equivalent-Yul] Add some environment opcodes
[EVM-Equivalent-Yul] Add more environment opcodes
…odes

[EVM-Equivalent-YUL] Add block-environment opcodes
[EVM-Equivalent-Yul] Add gas charge to lacking opcodes

ip := add(ip, 1)

switch opcode

Choose a reason for hiding this comment

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

I believe YUL handling of switch statements is very inefficient. You may need to write this in BALLS instead.

}

function pushStackItem(sp, item) -> newSp {
if or(gt(sp, BYTECODE_OFFSET()), eq(sp, BYTECODE_OFFSET())) {

Choose a reason for hiding this comment

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

Do you have an off-by-one here? I think you might be able to write to BYTECODE_OFFSET().

opcode := and(mload(sub(ip, 31)), 0xff)
}

function readBytes(start, length) -> value {

Choose a reason for hiding this comment

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

length is a constant and this function will be specialized anyways -- maybe you should mask here instead of using a loop?

@vladbochok vladbochok closed this Apr 14, 2024
@vladbochok vladbochok deleted the evm-equivalence-yul branch April 14, 2024 13:53
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.

7 participants