8000 fix(evm): Update the access list with the correct precompile by 0xstepit · Pull Request #3000 · evmos/evmos · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix(evm): Update the access list with the correct precompile #3000

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 3 commits into from
Nov 25, 2024

Conversation

0xstepit
Copy link
Contributor
@0xstepit 0xstepit commented Nov 25, 2024

Description

Currently, the access list is populated with all static precompiles. This logic does not take into consideration the new EVM type, which uses hooks to populate the precompiles field just in time if a precompile is a receiver of a Call.

For this reason:

  • all static precompiles are loaded even though they are not the target of the call
  • dynamic precompiles (ERC20) are never loaded.

This PR moves the logic to add precompiled addresses in the access list into the Call hook.

Considerations

If in the future, the Create EVM's method can use static precompiles, we should populate the access list with the target one. I'm not sure this is a possibility, but it is something we should keep in mind. If we don't want to think about it in the future, I could add again the logic to add to the access list all static preocmpiles.

Summary by CodeRabbit

  • New Features

    • Updated CHANGELOG.md with new entries detailing significant changes.
    • Introduced FeeMarketWrapper for managing EVM coins with varying decimal precision.
    • Added a slashing precompile and enhanced governance queries.
  • Bug Fixes

    • Resolved issues with default denomination in CLI commands.
  • Improvements

    • Refined handling of EVM coins and adjusted gas limits based on account balances.
    • Updated access list preparation for Ethereum transactions to enhance functionality.

Copy link
Contributor
coderabbitai bot commented Nov 25, 2024

Walkthrough

The changes in this pull request primarily involve updates to the CHANGELOG.md, reflecting various modifications to the Evmos project. Key alterations include the removal of the EthAccount type, the introduction of FeeMarketWrapper, and adjustments to the BaseFee type in the x/feemarket module. Additionally, enhancements to access list handling in the EVM context and the introduction of a slashing precompile are noted. Bug fixes and improvements across multiple modules are also documented, ensuring clarity in the project's ongoing development.

Changes

File Path Change Summary
CHANGELOG.md Updated to include new entries for unreleased changes, highlighting state machine breaking changes.
x/auth/types.go Removed EthAccount type.
x/feemarket/types.go Updated BaseFee to Decimal type.
x/evm/types.go Added FeeMarketWrapper.
x/slashing/types.go Added slashing precompile.
x/evm/keeper/precompiles.go Modified GetPrecompilesCallHook to add recipient's address to access list.
x/evm/keeper/state_transition.go Updated ApplyMessageWithConfig to refine access list preparation, removing precompiles.

Possibly related PRs

Suggested labels

precompile, CLI, tests

Suggested reviewers

  • hanchon
  • GAtom22
  • Vvaradinov

Poem

In the land of code where rabbits play,
Changes hop in, brightening the day.
With BaseAccount leading the way,
And FeeMarketWrapper here to stay.
Precompiles dance, access lists sway,
In Evmos' garden, we code and relay! 🐇✨


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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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.

@0xstepit 0xstepit marked this pull request as ready for review November 25, 2024 11:30
@0xstepit 0xstepit requested a review from a team as a code owner November 25, 2024 11:30
@0xstepit 0xstepit requested review from hanchon and ramacarlucho and removed request for a team November 25, 2024 11:30
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: 0

🧹 Outside diff range and nitpick comments (2)
x/evm/keeper/precompiles.go (1)

60-61: Consider documenting the Create hook consideration.

As mentioned in the PR objectives, there's uncertainty about whether the Create method could utilize static precompiles. Consider adding a comment to document this consideration for future reference.

 // If the precompile instance is created, we have to update the EVM with
 // only the recipient precompile and add it's address to the access list.
+// Note: If the Create method is found to utilize static precompiles in the future,
+// the access list population logic may need to be adjusted accordingly.
CHANGELOG.md (1)

48-48: LGTM with minor formatting suggestion

The changelog entry properly documents a state machine breaking change. Consider breaking the line into two for better readability:

-- (evm) [#3000](https://github.com/evmos/evmos/pull/3000) Move population of access list with precompile addresses into EVM hook.
++ (evm) [#3000](https://github.com/evmos/evmos/pull/3000) Move population of access list with precompile 
++ addresses into EVM hook.
🧰 Tools
🪛 Markdownlint (0.35.0)

48-48: Expected: 120; Actual: 129
Line length

(MD013, line-length)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 00d567a and fd1af13.

📒 Files selected for processing (3)
  • CHANGELOG.md (1 hunks)
  • x/evm/keeper/precompiles.go (1 hunks)
  • x/evm/keeper/state_transition.go (1 hunks)
🧰 Additional context used
🪛 Markdownlint (0.35.0)
CHANGELOG.md

48-48: Expected: 120; Actual: 129
Line length

(MD013, line-length)

🔇 Additional comments (4)
x/evm/keeper/precompiles.go (2)

60-66: LGTM! Implementation correctly addresses access list population.

The changes properly fix the access list population by:

  1. Only adding precompiles when they are actual call recipients
  2. Supporting both static and dynamic precompiles
  3. Avoiding unnecessary inclusion of all static precompiles

This aligns perfectly with the PR objectives.


64-64: Verify removal of other access list population code.

Let's verify that this is now the only place where precompile addresses are added to the access list, ensuring we've properly centralized this logic.

x/evm/keeper/state_transition.go (2)

311-314: Clarify handling of precompiles in Create operations.

As mentioned in the PR objectives, there's uncertainty about whether the Create method could utilize static precompiles. This needs clarification to ensure we're not breaking any edge cases.

Let's check if Create operations could interact with precompiles:


311-314: LGTM! Verify hook implementation for precompile access list.

The change correctly removes static precompiles from initial access list preparation, allowing dynamic population through the EVM hook during calls. This aligns with the PR objectives and fixes the issue of unnecessary precompile inclusion.

Let's verify the hook implementation that handles precompile access list population:

✅ Verification successful

Let me verify the hook implementation by searching for the precompile hook that adds addresses to the access list.


Let me check the full implementation of the precompile hook to verify how it handles the access list.


LGTM! The precompile access list handling is correctly implemented.

The changes to remove static precompiles from initial access list preparation are safe because:

  1. The precompile hook correctly adds the recipient precompile address to the access list when it's actually used in a call (evm.StateDB.AddAddressToAccessList(recipient))
  2. The hook is properly registered and called during EVM execution
  3. This approach is more efficient as it only adds precompiles to the access list when they are actually called, rather than including all static precompiles upfront
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the precompile hook implementation
# Expected: Find the hook implementation that adds precompiles to access list

# Search for the precompile hook implementation
ast-grep --pattern 'GetPrecompilesCallHook($$$)' 

# Search for access list modifications within the hook
rg -A 5 'PrepareAccessList|AccessList' 

Length of output: 104279


Script:

#!/bin/bash
# Search for precompile hook implementation that adds addresses to access list
ast-grep --pattern 'func $_($_, $_, $_, $_, $_, $_) vm.PrecompileCallHook {
  $$$
  AddAddressToAccessList($$$)
  $$$
}'

# Search for precompile hook registration
rg -A 5 'GetPrecompilesCallHook|RegisterPrecompileHooks'

Length of output: 1284


Script:

#!/bin/bash
# Get the full implementation of GetPrecompilesCallHook and surrounding context
rg -B 5 -A 15 'func \(k \*Keeper\) GetPrecompilesCallHook'

# Also check for any other access list modifications in precompiles.go
rg -A 3 'AddAddressToAccessList' x/evm/keeper/precompiles.go

Length of output: 1568

@0xstepit 0xstepit merged commit e598e72 into main Nov 25, 2024
51 of 52 checks passed
@0xstepit 0xstepit deleted the stepit/fix-access-list branch November 25, 2024 13:17
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