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: add tests for JUMP instruction #291

Merged
merged 1 commit into from
Sep 13, 2023
Merged

Conversation

lambda-0x
Copy link
Contributor

@lambda-0x lambda-0x commented Sep 6, 2023

Pull Request type

Please check the type of change your PR introduces:

  • Other (please describe): adding test before implementing instruction as mentioned in issue

What is the current behavior?

Resolves: #251

What is the new behavior?

  • evm.codes doesn't contain an example for this
  • i couldn't find test for this in geth or kakarot cairo0 (lmk if i missed something)
  • i think thats because there are only 2 cases, one in which location to which we need to jump is JUMPDEST (in that case its valid) else its invalid
  • actually there is one more case in which: 0x5B is part of data segment and is not an opcode (in an PUSHN) context.
    • kakarot 0 also doesn't handle this case, i will see geth's code and figure out how to implement this.

Does this introduce a breaking change?

  • No

@lambda-0x
Copy link
Contributor Author

(test failure due unrelated to PR)

@Eikix
Copy link
Member

Eikix commented Sep 6, 2023

There is a third case but that can't be covered here for now, which is:
kkrt-labs/kakarot#693

Example in the EVM spec:
https://github.com/ethereum/execution-specs/blob/fade6e95726c9c0b47b779fd8873b5737fbea3b3/src/ethereum/paris/vm/runtime.py#L58

@lambda-0x
Copy link
Contributor Author

haha yes! just realized that.

@Eikix
Copy link
Member

Eikix commented Sep 6, 2023

Will start advertising it but the best source of truth we got is:
https://github.com/ethereum/execution-specs/

@lambda-0x
Copy link
Contributor Author

(added the third case as test, and marked it ignored for now)

Copy link
Member

@Eikix Eikix left a comment

Choose a reason for hiding this comment

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

after that lgtm

crates/evm/src/errors.cairo Outdated Show resolved Hide resolved
@github-actions
Copy link

github-actions bot commented Sep 7, 2023

Snapshot Comparison Report:

No changes in gas consumption.

@lambda-0x lambda-0x requested a review from Eikix September 7, 2023 11:17
Copy link
Member

@ClementWalter ClementWalter left a comment

Choose a reason for hiding this comment

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

I'm fine with the logic of the tests, but prefer to have a named counter variable to clearly states that we push the input of the JUMP opcode

@lambda-0x
Copy link
Contributor Author

(rebased to main, incase it fixes snapshot CI)

crates/evm/src/errors.cairo Outdated Show resolved Hide resolved
enitrat
enitrat previously approved these changes Sep 8, 2023
Copy link
Collaborator

@enitrat enitrat left a comment

Choose a reason for hiding this comment

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

lgtm!

Eikix
Eikix previously approved these changes Sep 13, 2023
@Eikix
Copy link
Member

Eikix commented Sep 13, 2023

Approved, just rebase for conflicts

@Eikix Eikix added this pull request to the merge queue Sep 13, 2023
Merged via the queue into kkrt-labs:main with commit 25a093c Sep 13, 2023
2 checks passed
@lambda-0x lambda-0x deleted the fix-251 branch September 13, 2023 05:16
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.

feat: implement the test suite for 0x56 - JUMP opcode
4 participants