8000 imp(core/vm): custom opcodes definition by fedekunze · Pull Request #2837 · evmos/evmos · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

imp(core/vm): custom opcodes definition #2837

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

Merged
merged 2 commits into from
Sep 10, 2024
Merged

Conversation

fedekunze
Copy link
Collaborator
@fedekunze fedekunze commented Sep 9, 2024

Description

Closes: #XXXX


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • tackled an existing issue or discussed with a team member
  • left instructions on how to review the changes
  • targeted the correct branch (see PR Targeting)

Reviewers Checklist

All items are required.
Please add a note if the item is not applicable
and please add your handle next to the items reviewed
if you only reviewed selected items.

I have...

  • added a relevant changelog entry to the Unreleased section in CHANGELOG.md
  • confirmed all author checklist items have been addressed
  • confirmed that this PR does not change production code
  • reviewed content
  • tested instructions (if applicable)
  • confirmed all CI checks have passed

Summary by CodeRabbit

  • New Features

    • Introduced support for custom Opcodes in the Interpreter interface, enhancing flexibility for developers.
    • Added new methods to the Interpreter interface, including EVM access, configuration retrieval, read-only checks, and return data management.
    • Implemented a method for calculating gas costs associated with memory expansion.
  • Bug Fixes

    • Various minor enhancements and bug fixes that improve overall system stability and performance.

Copy link
Contributor
coderabbitai bot commented Sep 9, 2024

Walkthrough

The changes introduce enhancements to the Interpreter interface and its associated methods, allowing support for custom Opcodes. New public functions are added to improve usability, including CalcMemSize64, and several methods for the EVMInterpreter struct to facilitate better interaction with the Ethereum Virtual Machine (EVM). Additionally, a GasCost method is introduced to the Memory struct for calculating gas costs related to memory expansion. Overall, these modifications aim to improve flexibility, clarity, and performance within the EVM context.

Changes

Files Change Summary
CHANGELOG.md Added entry for updates to the Interpreter interface to support custom Opcodes.
x/evm/core/vm/common.go Added CalcMemSize64 function to provide a public interface for memory size calculation.
x/evm/core/vm/interface.go Added methods to Interpreter: EVM(), Config(), ReadOnly(), ReturnData(), SetReturnData().
x/evm/core/vm/interpreter.go Added methods to EVMInterpreter: EVM(), Config(), ReadOnly(), ReturnData(), SetReturnData().
x/evm/core/vm/memory.go Added GasCost method to calculate gas costs for memory expansion.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant EVMInterpreter
    participant EVM
    participant Memory

    User->>EVMInterpreter: Call EVM()
    EVMInterpreter->>EVM: Retrieve EVM instance
    EVMInterpreter->>User: Return EVM instance

    User->>EVMInterpreter: Call Config()
    EVMInterpreter->>User: Return Config settings

    User->>EVMInterpreter: Call ReadOnly()
    EVMInterpreter->>User: Return read-only status

    User->>EVMInterpreter: Call ReturnData()
    EVMInterpreter->>User: Return last CALL return data

    User->>EVMInterpreter: Call SetReturnData(data)
    EVMInterpreter->>User: Set return data for next operations

    User->>Memory: Call GasCost(newMemSize)
    Memory->>User: Return gas cost for memory expansion
Loading

🐰 In a world of code, so bright and new,
Custom Opcodes hop, bringing joy to you!
With memory's cost now clear as day,
The EVM dances, in a clever way!
Let's celebrate these changes, oh so grand,
A rabbit's delight, in this coding land! 🐇✨

Tip

New features

Walkthrough comment now includes:

  • Possibly related PRs: A list of potentially related PRs to help you recall past context.
  • Suggested labels: CodeRabbit can now suggest labels by learning from your past PRs. You can also provide custom labeling instructions in the UI or configuration file.

Notes:

  • Please share any feedback in the discussion post on our Discord.
  • Possibly related PRs, automatic label suggestions based on past PRs, learnings, and possibly related issues require data opt-in (enabled by default).

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@fedekunze fedekunze marked this pull request as ready for review September 9, 2024 17:27
@fedekunze fedekunze requested a review from a team as a code owner September 9, 2024 17:27
@fedekunze fedekunze requested review from 0xstepit and GAtom22 and removed request for a team September 9, 2024 17:27
Copy link
Contributor
@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 4265aa3 and bdc96a3.

Files selected for processing (5)
  • CHANGELOG.md (2 hunks)
  • x/evm/core/vm/common.go (1 hunks)
  • x/evm/core/vm/interface.go (1 hunks)
  • x/evm/core/vm/interpreter.go (1 hunks)
  • x/evm/core/vm/memory.go (1 hunks)
Additional context used
Markdownlint
CHANGELOG.md

49-49: Expected: 120; Actual: 136
Line length

(MD013, line-length)

Additional comments not posted (6)
x/evm/core/vm/interpreter.go (5)

97-100: Review: Method EVM() in EVMInterpreter

The EVM() method correctly returns the EVM instance associated with the interpreter. This method is straightforward and appears to be implemented correctly, providing essential access to the EVM instance for further operations.


102-105: Review: Method Config() in EVMInterpreter

The Config() method properly returns the configuration of the interpreter. This method is crucial for accessing the configuration settings, which might be needed for various operations and checks within the EVM context.


107-110: Review: Method ReadOnly() in EVMInterpreter

The ReadOnly() method effectively checks if the interpreter is in read-only mode. This is important for ensuring that no state-modifying operations are performed when the interpreter is expected to operate in a read-only state.


112-115: Review: Method ReturnData() in EVMInterpreter

The ReturnData() method retrieves the return data from the last executed CALL. This functionality is essential for operations that need to reuse or inspect the return data from previous calls.


117-120: Review: Method SetReturnData(data []byte) in EVMInterpreter

The SetReturnData(data []byte) method allows setting the return data for the last CALL. This method is crucial for scenarios where the return data needs to be manipulated or set based on custom logic within the EVM operations.

CHANGELOG.md (1)

49-49: Ensure accurate and concise changelog entry for custom Opcodes.

The changelog entry at line 49 introduces support for custom Opcodes in the Interpreter interface and its public functions. This is a significant change as it enhances the flexibility and functionality of the EVM within the Evmos project. It's crucial to ensure that this entry is clear, concise, and accurately reflects the changes made. The entry should also include any potential impacts or benefits this change brings to the users or developers of the system.

Tools
Markdownlint

49-49: Expected: 120; Actual: 136
Line length

(MD013, line-length)

Copy link
Contributor
@GAtom22 GAtom22 left a comment

Choose a reason for hiding this comment

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

LGTM! Great work @fedekunze!

Copy link
Contributor
@Vvaradinov Vvaradinov left a comment

Choose a reason for hiding this comment

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

LGTM!

@fedekunze fedekunze merged commit 2ffe83e into main Sep 10, 2024
50 of 52 checks passed
@fedekunze fedekunze deleted the fedekunze/custom-opcode branch September 10, 2024 07:59
@GAtom22
Copy link
Contributor
GAtom22 commented Sep 10, 2024

https://github.com/Mergifyio backport rama/release-v20

Copy link
Contributor
mergify bot commented Sep 10, 2024

backport rama/release-v20

✅ Backports have been created

mergify bot pushed a commit that referenced this pull request Sep 10, 2024
* imp(core/vm): custom opcodes definition

* changelog

(cherry picked from commit 2ffe83e)
8000
GAtom22 pushed a commit that referenced this pull request Sep 10, 2024
imp(core/vm): custom opcodes definition (#2837)

* imp(core/vm): custom opcodes definition

* changelog

(cherry picked from commit 2ffe83e)

Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>
@coderabbitai coderabbitai bot mentioned this pull request Oct 31, 2024
9 tasks
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
0