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

chore: add checktx for AnteDecVerifyEthAcc #2171

Closed
wants to merge 4 commits into from

Conversation

expertdicer
Copy link
Contributor

@expertdicer expertdicer commented Jan 21, 2025

@expertdicer expertdicer requested a review from a team as a code owner January 21, 2025 04:01
Copy link
Contributor

coderabbitai bot commented Jan 21, 2025

📝 Walkthrough

Walkthrough

This pull request introduces a modification to the AnteDecVerifyEthAcc struct in the Nibiru EVM module. The primary change is adding a conditional check to return early from the AnteHandle method when the transaction is in a check transaction state. This allows the method to bypass validation logic during check transactions, optimizing the transaction processing flow for certain scenarios. Additionally, a new entry has been added to the changelog to document this change.

Changes

File Change Summary
CHANGELOG.md Added chore entry for PR #2171 about AnteDecVerifyEthAcc checktx
app/evmante/evmante_verify_eth_acc.go Added early return condition in AnteHandle method for check transactions

Possibly related PRs

Poem

🐰 In the land of code, where rabbits play,
Check transactions hop along the way.
With a swift return, they skip the fuss,
Leaving validations in a gentle hush.
EVM's dance, a joyous display! 🚀


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e1622e9 and 2e2cab3.

📒 Files selected for processing (1)
  • CHANGELOG.md (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • CHANGELOG.md
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: unit-tests
  • GitHub Check: build
  • GitHub Check: e2e-evm
  • GitHub Check: lint
  • GitHub Check: integration-tests

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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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.

Copy link

codecov bot commented Jan 21, 2025

Codecov Report

Attention: Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.

Project coverage is 64.86%. Comparing base (68d837f) to head (2e2cab3).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
app/evmante/evmante_verify_eth_acc.go 0.00% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2171      +/-   ##
==========================================
- Coverage   64.89%   64.86%   -0.03%     
==========================================
  Files         277      277              
  Lines       22302    22305       +3     
==========================================
- Hits        14472    14468       -4     
- Misses       6839     6847       +8     
+ Partials      991      990       -1     
Files with missing lines Coverage Δ
app/evmante/evmante_verify_eth_acc.go 84.61% <0.00%> (-7.06%) ⬇️

... and 1 file with indirect coverage changes

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: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0ef4099 and e1622e9.

📒 Files selected for processing (2)
  • CHANGELOG.md (1 hunks)
  • app/evmante/evmante_verify_eth_acc.go (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • CHANGELOG.md
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: integration-tests
  • GitHub Check: e2e-evm
🔇 Additional comments (1)
app/evmante/evmante_verify_eth_acc.go (1)

43-45: Verify test coverage and consistency with other AnteHandlers

Please ensure that:

  1. Test cases cover both CheckTx and DeliverTx scenarios
  2. This optimization pattern aligns with other AnteHandlers in the codebase

Let's verify the test coverage and similar patterns:

✅ Verification successful

Test coverage and AnteHandler consistency verified

The implementation has comprehensive test coverage and follows consistent patterns with other AnteHandlers in the codebase. The test suite includes both success and failure scenarios, with explicit CheckTx verification.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for test files covering this AnteHandler
fd -e go test.*evmante.*verify_eth_acc

# Look for similar CheckTx patterns in other AnteHandlers
rg -B 2 -A 2 "IsCheckTx\(\)" app/

Length of output: 1317


Script:

#!/bin/bash
# Search for test files in app directory containing verify_eth_acc
rg -l "verify_eth_acc" app/**/*_test.go

# Look for actual test implementations
rg -B 2 -A 5 "TestVerifyEthAcc|verify_eth_acc" app/

Length of output: 753


Script:

#!/bin/bash
# View the content of the test file
cat app/evmante/evmante_verify_eth_acc_test.go

Length of output: 2799

Comment on lines +43 to +45
if !ctx.IsCheckTx() {
return next(ctx, tx, simulate)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Critical: The CheckTx optimization logic is reversed

The current implementation skips validation during DeliverTx (actual block execution) and performs validation during CheckTx (mempool pre-screening). This is the opposite of the intended optimization and could allow invalid transactions to be processed during block execution.

Apply this diff to correct the logic:

-if !ctx.IsCheckTx() {
+if ctx.IsCheckTx() {
   return next(ctx, tx, simulate)
 }

This correction will:

  1. Skip expensive validation during CheckTx (mempool) as intended
  2. Ensure full validation during DeliverTx (block execution) for security
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if !ctx.IsCheckTx() {
return next(ctx, tx, simulate)
}
if ctx.IsCheckTx() {
return next(ctx, tx, simulate)
}

@expertdicer expertdicer enabled auto-merge (squash) January 21, 2025 08:29
@Unique-Divine
Copy link
Member

What is the URL for the original issue?

@expertdicer
Copy link
Contributor Author

Copy link
Member

@k-yang k-yang left a comment

Choose a reason for hiding this comment

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

I actually don't think this is a good idea to add in (the QA report and Ethermint did not think through this critically enough).

CheckTx is only called when a tx arrives at the local mempool, but not at block execution time. Only DeliverTx is called at block execution time.

That means a malicious validator could include a tx in the proposed block that doesn't pass this AnteHandler check, and we'd bypass through that check if we merge this PR. Essentially, we still want this check to run on DeliverTx.

@Unique-Divine
Copy link
Member

Agreed on this point from @k-yang (#2171 (review)). I think we should not include this change

auto-merge was automatically disabled January 21, 2025 21:09

Pull request was closed

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