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

fix(evm): gas prices #1982

Merged
merged 21 commits into from
Aug 6, 2024
Merged

fix(evm): gas prices #1982

merged 21 commits into from
Aug 6, 2024

Conversation

k-yang
Copy link
Member

@k-yang k-yang commented Jul 31, 2024

Overview

Closes #1902, #1916

  • fix the MempoolFeeDecorator to check local node min gas prices on CheckTx only
  • default baseFee to 1unibi
  • refactor variable names

Rationale

After looking at the implementation of EthMinGasPriceDecorator, I realized that we were conflating local gas prices with global gas prices. ctx.MinGasPrices() uses the gas price config from app.toml, which is local to every node and is only used to include transactions in the mempool, so it should only run on CheckTx, otherwise txs from a proposed block may succeed on some validators and fail on others, leading to a consensus failure.

I also defaulted baseFee to 1unibi.

The PR also renames a few variables for clarity/readability.

Summary by CodeRabbit

  • New Features

    • Introduced GlobalMinGasPrices to enhance gas pricing for Ethereum transactions.
    • Added functionality to enforce minimum gas price requirements through GlobalGasPriceDecorator and `MempoolGasPriceDecorator.
  • Bug Fixes

    • Corrected formatting issues in the CHANGELOG.md for improved documentation clarity.
  • Documentation

    • Updated CHANGELOG.md to reflect new features and changes.
  • Refactor

    • Improved code clarity by replacing K with EvmKeeper across various modules and tests.
  • Tests

    • Enhanced test coverage for the new gas price decorators and related functionalities.

Copy link
Contributor

coderabbitai bot commented Jul 31, 2024

Warning

Rate limit exceeded

@k-yang has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 1 minutes and 22 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

Commits

Files that changed from the base of the PR and between 3325a08 and 033dec4.

Walkthrough

The Nibiru project has implemented key enhancements to its Ethereum Virtual Machine (EVM) framework, focusing on gas pricing mechanisms. This includes the introduction of new decorators for enforcing global and mempool gas prices, improved transaction validation, and comprehensive testing of these features. Additionally, documentation and Protocol Buffers definitions were refined for consistency and clarity throughout the codebase.

Changes

Files Change Summary
CHANGELOG.md Added a new entry for the GlobalMinGasPrices feature; corrected minor formatting issues.
app/evmante/evmante_global_fees.go, app/evmante/evmante_mempool_fees.go Introduced GlobalGasPriceDecorator and MempoolGasPriceDecorator to enforce minimum gas prices.
app/evmante/evmante_global_fees_test.go, app/evmante/evmante_mempool_fees_test.go Created comprehensive tests for the new gas price decorators, covering various scenarios.
app/evmante/evmante_handler.go Updated NewAnteHandlerEVM to incorporate new decorators for gas price validation.
proto/eth/evm/v1/evm.proto Added a global_min_gas_price field to the Params message; made minor formatting adjustments.
x/evm/{evm_test.go, msg.go}, x/evm/{keeper, msg_server.go} Refactored code to consistently utilize EvmKeeper and updated related methods accordingly.
x/evm/keeper/{erc20_test.go, funtoken_state_test.go, grpc_query_test.go} Updated tests to use EvmKeeper, enhancing clarity and maintainability of the test suite.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant EVM
    participant GlobalGasPriceDecorator
    participant MempoolGasPriceDecorator

    User->>EVM: Submit Transaction
    EVM->>GlobalGasPriceDecorator: Check Global Minimum Gas Price
    GlobalGasPriceDecorator-->>EVM: Valid/Invalid
    EVM->>MempoolGasPriceDecorator: Check Mempool Minimum Gas Price
    MempoolGasPriceDecorator-->>EVM: Valid/Invalid
    EVM-->>User: Transaction Result
Loading

Poem

🐰 In fields of code, a rabbit hops,
With gas prices set, no need for stops.
New decorators bloom, like flowers in spring,
Transactions glide, oh, what joy they bring!
With tests so strong, the future is bright,
Hopping with glee, through day and night! 🌼✨


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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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.

@k-yang k-yang marked this pull request as ready for review July 31, 2024 18:39
@k-yang k-yang requested a review from a team as a code owner July 31, 2024 18:39
@k-yang k-yang changed the title fix(evm): gas prices feat(evm): add global min gas prices Jul 31, 2024
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

Outside diff range, codebase verification and nitpick comments (4)
app/evmante/evmante_global_fees.go (2)

1-2: Add a newline after the copyright notice.

For better readability, add a newline after the copyright notice.

- // Copyright (c) 2023-2024 Nibi, Inc.
+ // Copyright (c) 2023-2024 Nibi, Inc.
+

14-20: Improve the documentation for GlobalGasPriceDecorator.

The documentation for GlobalGasPriceDecorator can be improved for clarity. Specify that it is used for both CheckTx and DeliverTx.

- // GlobalGasPriceDecorator will check if the transaction's fee is at least as large
- // as the global MinGasPrices param. If fee is too low, decorator returns error and tx
- // is rejected. This applies to both CheckTx and DeliverTx.
- // If fee is high enough, then call next AnteHandler
+ // GlobalGasPriceDecorator checks if the transaction's fee is at least as large
+ // as the global MinGasPrices parameter. If the fee is too low, the decorator returns an error and the transaction
+ // is rejected. This applies to both CheckTx and DeliverTx.
+ // If the fee is high enough, it calls the next AnteHandler.
x/evm/keeper/msg_server.go (2)

254-254: Inconsistent Tracer configuration found.

The configuration of Tracer is not consistent throughout the codebase. Specifically:

  • In x/evm/keeper/msg_server.go, Tracer is configured using evmConfig.ChainConfig.
  • In x/evm/keeper/grpc_query.go, Tracer is sometimes configured using evm.NewNoOpTracer() and other times using tracers.New(traceConfig.Tracer, tCtx, tracerJSONConfig).
  • In x/evm/keeper/keeper.go, Tracer is configured using evm.NewTracer(k.tracer, msg, ethCfg, ctx.BlockHeight()).
  • In x/evm/keeper/erc20.go, Tracer is configured using evm.NewNoOpTracer().

Please ensure a consistent approach to configuring Tracer across the codebase.

Analysis chain

Ensure the Tracer configuration is consistent.

The configuration of Tracer using evmConfig.ChainConfig is a good change. Ensure that this is consistent throughout the codebase.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the `Tracer` configuration is consistent.

# Test: Search for `Tracer` configuration. Expect: Consistent usage throughout the codebase.
rg --type go $'Tracer'

Length of output: 6562


Script:

#!/bin/bash
# Extract lines around the Tracer instances in key files for further inspection

# Define the files of interest
files=(
  "x/evm/keeper/msg_server.go"
  "x/evm/keeper/grpc_query.go"
  "x/evm/keeper/keeper.go"
  "x/evm/keeper/erc20.go"
)

# Loop through the files and extract lines around Tracer instances
for file in "${files[@]}"; do
  echo "File: $file"
  rg --context 5 'Tracer' "$file"
  echo
done

Length of output: 4474


360-360: Inconsistent Parameter Naming in ApplyEvmMsg Calls

The parameter cfg is still being used in the following files and lines. Please update these instances to use evmConfig to maintain consistency and avoid potential issues:

  • x/evm/keeper/grpc_query.go

    • Line 1: cfg, err := k.GetEVMConfig(ctx, ParseProposerAddr(ctx, req.ProposerAddress), chainID)
    • Line 2: msg, err := args.ToMessage(req.GasCap, cfg.BaseFee)
    • Line 3: res, err := k.ApplyEvmMsg(ctx, msg, nil, false, cfg, txConfig)
    • Line 4: cfg.BaseFee = baseFee
    • Line 5: signer := gethcore.MakeSigner(cfg.ChainConfig, big.NewInt(ctx.BlockHeight()))
    • Line 6: msg, err := ethTx.AsMessage(signer, cfg.BaseFee)
    • Line 7: rsp, err := k.ApplyEvmMsg(ctx, msg, evm.NewNoOpTracer(), true, cfg, txConfig)
    • Line 8: result, _, err := k.TraceEthTxMsg(ctx, cfg, txConfig, signer, tx, req.TraceConfig, false, tracerConfig)
    • Line 9: traceResult, logIndex, err := k.TraceEthTxMsg(ctx, cfg, txConfig, signer, ethTx, req.TraceConfig, true, nil)
    • Line 10: msg, err := tx.AsMessage(signer, cfg.BaseFee)
    • Line 11: res, err := k.ApplyEvmMsg(ctx, msg, tracer, commitMessage, cfg, txConfig)
  • x/evm/keeper/erc20.go

    • Line 1: cfg, err := k.GetEVMConfig(ctx, sdk.ConsAddress(ctx.BlockHeader().ProposerAddress), k.EthChainID(ctx))
    • Line 2: evmResp, err = k.ApplyEvmMsg(ctx, evmMsg, evm.NewNoOpTracer(), commit, cfg, txConfig)

Please update these instances to use evmConfig instead of cfg.

Analysis chain

LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to ApplyEvmMsg are correctly updated if there are any dependencies on the previous implementation.


To ensure that all instances of ApplyEvmMsg are correctly updated with the new parameter name evmConfig, we need to verify the context around each call. Let's search for the usage of evmConfig in the relevant files and ensure it is correctly passed.


To confirm if the grpc_query.go and erc20.go files are still using the old cfg parameter, we need to search for instances of cfg in these files.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `ApplyEvmMsg` are correctly updated.

# Test: Search for the function usage. Expect: Only occurrences of the new implementation.
rg --type go -A 5 $'ApplyEvmMsg'

Length of output: 4052


Script:

#!/bin/bash
# Description: Verify that `evmConfig` is used correctly in all instances of `ApplyEvmMsg`.

# Search for `evmConfig` usage in relevant files and provide context around each instance.
rg --type go -A 5 'evmConfig' x/evm/keeper/grpc_query.go x/evm/keeper/msg_server.go x/evm/keeper/erc20.go

Length of output: 5182


Script:

#!/bin/bash
# Description: Verify if `cfg` is still used in `grpc_query.go` and `erc20.go`.

# Search for `cfg` usage in relevant files and provide context around each instance.
rg --type go -A 5 'cfg' x/evm/keeper/grpc_query.go x/evm/keeper/erc20.go

Length of output: 7239

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 3c73f03 and 20b2328.

Files ignored due to path filters (1)
  • x/evm/evm.pb.go is excluded by !**/*.pb.go
Files selected for processing (22)
  • CHANGELOG.md (1 hunks)
  • app/evmante/evmante_global_fees.go (1 hunks)
  • app/evmante/evmante_global_fees_test.go (1 hunks)
  • app/evmante/evmante_handler.go (1 hunks)
  • app/evmante/evmante_mempool_fees.go (1 hunks)
  • app/evmante/evmante_mempool_fees_test.go (2 hunks)
  • app/evmante/evmante_validate_basic_test.go (1 hunks)
  • proto/eth/evm/v1/evm.proto (8 hunks)
  • x/evm/evm_test.go (1 hunks)
  • x/evm/evmmodule/genesis_test.go (3 hunks)
  • x/evm/evmtest/erc20.go (4 hunks)
  • x/evm/evmtest/smart_contract_test.go (3 hunks)
  • x/evm/evmtest/test_deps.go (2 hunks)
  • x/evm/keeper/erc20_test.go (22 hunks)
  • x/evm/keeper/funtoken_state_test.go (6 hunks)
  • x/evm/keeper/grpc_query_test.go (16 hunks)
  • x/evm/keeper/keeper.go (2 hunks)
  • x/evm/keeper/msg_ethereum_tx_test.go (3 hunks)
  • x/evm/keeper/msg_server.go (9 hunks)
  • x/evm/msg.go (1 hunks)
  • x/evm/params.go (1 hunks)
  • x/evm/precompile/funtoken_test.go (5 hunks)
Files not reviewed due to server errors (2)
  • x/evm/keeper/erc20_test.go
  • x/evm/msg.go
Files skipped from review due to trivial changes (2)
  • CHANGELOG.md
  • x/evm/evmtest/test_deps.go
Additional comments not posted (64)
app/evmante/evmante_handler.go (1)

18-19: Ensure proper initialization of new decorators.

The new decorators NewMempoolGasPriceDecorator and NewGlobalGasPriceDecorator are added. Verify that these decorators are correctly initialized and integrated within the NewAnteHandlerEVM function.

Verification successful

To ensure the proper initialization and usage of the new decorators, we need to inspect their definitions and the relevant test cases. Let's proceed with the following steps:

  1. Extract the definitions of NewMempoolGasPriceDecorator and NewGlobalGasPriceDecorator to understand their implementations.
  2. Verify the integration of these decorators within the NewAnteHandlerEVM function.
  3. Check the test cases to ensure they are properly tested.

Ensure proper initialization of new decorators.

The new decorators NewMempoolGasPriceDecorator and NewGlobalGasPriceDecorator are correctly initialized and integrated within the NewAnteHandlerEVM function. Additionally, they are covered by test cases.

  • Definitions:
    • app/evmante/evmante_mempool_fees.go:24
    • app/evmante/evmante_global_fees.go:24
  • Integration:
    • app/evmante/evmante_handler.go:11-30
  • Test cases:
    • app/evmante/evmante_global_fees_test.go
    • app/evmante/evmante_mempool_fees_test.go
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the initialization and usage of the new decorators.

# Test: Search for the definitions and usages of the new decorators.
rg --type go 'NewMempoolGasPriceDecorator|NewGlobalGasPriceDecorator'

Length of output: 948


Script:

#!/bin/bash
# Extract the definitions of NewMempoolGasPriceDecorator and NewGlobalGasPriceDecorator
ast-grep --lang go --pattern 'func NewMempoolGasPriceDecorator($_) $_ { $$$ }'
ast-grep --lang go --pattern 'func NewGlobalGasPriceDecorator($_) $_ { $$$ }'

# Check the implementation of NewAnteHandlerEVM for integration of the decorators
ast-grep --lang go --pattern 'func NewAnteHandlerEVM($_) $_ { $$$ }'

# Verify the test cases for the new decorators
rg --type go 'NewMempoolGasPriceDecorator|NewGlobalGasPriceDecorator' -A 10

Length of output: 7050

x/evm/evmtest/smart_contract_test.go (3)

35-35: Verify the new method for obtaining the chain ID.

The chain ID is now retrieved from deps.EvmKeeper.EthChainID(deps.Ctx). Ensure this method is correctly implemented and consistent with the intended encapsulation of Ethereum-related logic within the EvmKeeper.


58-58: Verify the new method for obtaining the chain ID.

The chain ID is now retrieved from deps.EvmKeeper.EthChainID(deps.Ctx). Ensure this method is correctly implemented and consistent with the intended encapsulation of Ethereum-related logic within the EvmKeeper.


19-19: Verify the new method for obtaining the chain ID.

The chain ID is now retrieved from deps.EvmKeeper.EthChainID(deps.Ctx). Ensure this method is correctly implemented and consistent with the intended encapsulation of Ethereum-related logic within the EvmKeeper.

Verification successful

Verification successful.

The EthChainID method in EvmKeeper correctly retrieves the chain ID using GetEthChainID from appconst. This implementation ensures that the chain ID is accurately mapped based on the context's chain ID.

  • x/evm/keeper/keeper.go: Implementation of EthChainID.
  • app/appconst/appconst.go: Implementation of GetEthChainID.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation of the new method for obtaining the chain ID.

# Test: Search for the definition and usage of the `EthChainID` method within the `EvmKeeper`.
rg --type go 'func EthChainID' | rg 'EvmKeeper'

Length of output: 47


Script:

#!/bin/bash
# Description: Verify the implementation of the new method for obtaining the chain ID.

# Test: Search for the definition of the `EthChainID` method in the entire codebase.
rg --type go 'func EthChainID'

# Test: Search for the usage of the `EthChainID` method in the entire codebase.
rg --type go 'EthChainID'

Length of output: 5790


Script:

#!/bin/bash
# Description: Verify the implementation of the GetEthChainID method in appconst.

# Test: Search for the definition of the GetEthChainID method in the entire codebase.
rg --type go 'func GetEthChainID'

Length of output: 122


Script:

#!/bin/bash
# Description: Extract the implementation of the GetEthChainID method in appconst.

# Extract the implementation of the GetEthChainID method from app/appconst/appconst.go.
rg --type go --context 10 'func GetEthChainID' app/appconst/appconst.go

Length of output: 578

app/evmante/evmante_global_fees.go (2)

22-28: Ensure the NewGlobalGasPriceDecorator function is correctly used.

Verify that the NewGlobalGasPriceDecorator function is correctly used and integrated within the codebase.

Verification successful

The NewGlobalGasPriceDecorator function is correctly used and integrated within the codebase.

  • The function is part of a chain of AnteDecorators in app/evmante/evmante_handler.go, indicating it is used as intended in the middleware pipeline.
  • It is also used in test cases in app/evmante/evmante_global_fees_test.go, which is appropriate for its purpose.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of the `NewGlobalGasPriceDecorator` function.

# Test: Search for the definition and usage of the `NewGlobalGasPriceDecorator` function.
rg --type go 'NewGlobalGasPriceDecorator'

Length of output: 477


Script:

#!/bin/bash
# Extract lines around the usage of `NewGlobalGasPriceDecorator` in `app/evmante/evmante_handler.go`
rg --type go -A 5 -B 5 'NewGlobalGasPriceDecorator' app/evmante/evmante_handler.go

# Extract lines around the usage of `NewGlobalGasPriceDecorator` in `app/evmante/evmante_global_fees_test.go`
rg --type go -A 5 -B 5 'NewGlobalGasPriceDecorator' app/evmante/evmante_global_fees_test.go

Length of output: 1047


Script:

#!/bin/bash
# Extract more lines from `app/evmante/evmante_handler.go` to understand the complete setup of the AnteDecorators
rg --type go -A 20 -B 5 'NewGlobalGasPriceDecorator' app/evmante/evmante_handler.go

Length of output: 923


30-67: Ensure proper error handling in AnteHandle method.

The AnteHandle method should ensure proper error handling, especially when dealing with invalid message types and insufficient fees.

Verification successful

The AnteHandle method in app/evmante/evmante_global_fees.go already includes error handling for invalid message types and insufficient fees. To ensure comprehensive error handling, we need to verify if similar patterns are followed in other AnteHandle methods and if the tests cover these scenarios adequately.

Let's search for all AnteHandle method implementations and their corresponding test cases to verify the consistency and comprehensiveness of error handling.


Let's correct the regex error and re-run the search for test cases that call AnteHandle.


The AnteHandle method implementations in various files include error handling for invalid message types, insufficient fees, and other specific conditions. The corresponding test cases also seem to cover these scenarios.

Ensure proper error handling in AnteHandle method.

The AnteHandle method in app/evmante/evmante_global_fees.go and other similar implementations have proper error handling mechanisms. The test cases also appear to cover the necessary error scenarios.

  • app/evmante/evmante_global_fees.go
  • app/evmante/evmante_mempool_fees.go
  • app/evmante/evmante_verify_eth_acc.go
  • app/evmante/evmante_sigverify.go
  • app/evmante/evmante_setup_ctx.go
  • app/evmante/evmante_emit_event.go
  • app/ante/reject_ethereum_tx_msgs.go
  • app/ante/gas_wanted.go
  • app/ante/fixed_gas.go
  • app/ante/commission.go
  • x/devgas/v1/ante/ante.go

The test cases in the following files ensure that the error handling is adequately tested:

  • app/evmante/evmante_verify_eth_acc_test.go
  • app/evmante/evmante_sigverify_test.go
  • app/evmante/evmante_setup_ctx_test.go
  • app/evmante/evmante_validate_basic_test.go
  • app/evmante/evmante_global_fees_test.go
  • app/evmante/evmante_mempool_fees_test.go
  • app/evmante/evmante_emit_event_test.go
  • app/evmante/evmante_gas_consume_test.go
  • app/evmante/evmante_can_transfer_test.go
  • app/ante/commission_test.go
  • app/ante/reject_ethereum_tx_msgs_test.go
  • app/ante/gas_wanted_test.go
  • app/evmante/evmante_increment_sender_seq_test.go
  • x/devgas/v1/ante/ante_test.go
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify proper error handling in the `AnteHandle` method.

# Test: Search for the usage of the `AnteHandle` method and ensure proper error handling.
rg --type go 'AnteHandle'

Length of output: 9418


Script:

#!/bin/bash
# Description: Verify comprehensive error handling in all `AnteHandle` method implementations and their corresponding test cases.

# Search for all `AnteHandle` method implementations.
ast-grep --lang go --pattern 'func ($_ $_) AnteHandle($_, $_, $_, $_) ($_ $_, $_ error) { $$$ }'

# Search for test cases that call `AnteHandle`.
rg --type go 'AnteHandle(' --glob '*_test.go'

Length of output: 21869


Script:

#!/bin/bash
# Description: Verify comprehensive error handling in all `AnteHandle` method implementations and their corresponding test cases.

# Search for all `AnteHandle` method implementations.
ast-grep --lang go --pattern 'func ($_ $_) AnteHandle($_, $_, $_, $_) ($_ $_, $_ error) { $$$ }'

# Search for test cases that call `AnteHandle`.
rg --type go 'AnteHandle\(' --glob '*_test.go'

Length of output: 22817

app/evmante/evmante_mempool_fees.go (2)

22-28: LGTM!

The function correctly initializes the MempoolGasPriceDecorator with the provided EVMKeeper.


30-71: LGTM!

The function correctly handles the gas price checks and returns appropriate errors if the gas price is insufficient.

x/evm/evmtest/erc20.go (3)

20-20: LGTM!

The function correctly uses EvmKeeper to call the contract with input.


31-31: LGTM!

The function correctly uses EvmKeeper to check the ERC20 balance.


Line range hint 64-90:
LGTM!

The function correctly uses EvmKeeper for creating a FunToken and querying code.

x/evm/keeper/funtoken_state_test.go (3)

Line range hint 15-24:
LGTM!

The function correctly uses EvmKeeper for inserting and getting FunTokens.


Line range hint 38-56:
LGTM!

The function correctly uses EvmKeeper for collecting FunTokens.


Line range hint 67-80:
LGTM!

The function correctly uses EvmKeeper for deleting FunTokens.

app/evmante/evmante_mempool_fees_test.go (2)

85-85: Decorator Instantiation: Ensure Correctness

The decorator instantiation has been updated to NewMempoolGasPriceDecorator. Ensure that this change is correct and consistent with the new functionality.

Verification successful

Decorator Instantiation Verified: Correct and Consistent

The new decorator NewMempoolGasPriceDecorator is correctly implemented and consistently used across the codebase. The old decorator NewEthMinGasPriceDecorator is no longer present.

  • Implementation found in app/evmante/evmante_mempool_fees.go
  • Usage confirmed in app/evmante/evmante_mempool_fees_test.go and app/evmante/evmante_handler.go
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correctness of the decorator instantiation.

# Test: Search for the old decorator instantiation. Expect: No occurrences.
rg --type go 'NewEthMinGasPriceDecorator'

# Test: Search for the new decorator instantiation. Expect: Only occurrences of the new instantiation.
rg --type go 'NewMempoolGasPriceDecorator'

Length of output: 525


Script:

#!/bin/bash
# Description: Verify the implementation and usage of NewMempoolGasPriceDecorator

# Search for the implementation of NewMempoolGasPriceDecorator
ast-grep --lang go --pattern 'func NewMempoolGasPriceDecorator($_) $_ { $$$ }'

# Search for the usage of NewMempoolGasPriceDecorator in the codebase
rg 'NewMempoolGasPriceDecorator'

Length of output: 877


11-11: Function Name Change: Ensure Consistency

The function name has been changed to TestMempoolGasFeeDecorator. Ensure that this change is consistent across the test suite and documentation.

Verification successful

Function Name Change: Verified Consistency

The function name has been successfully changed to TestMempoolGasFeeDecorator and is consistent within the codebase.

  • The old function name TestEthMinGasPriceDecorator does not appear anywhere in the codebase.
  • The new function name TestMempoolGasFeeDecorator appears only in the expected test file.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the consistency of the function name change across the test suite.

# Test: Search for the old function name. Expect: No occurrences.
rg --type go 'TestEthMinGasPriceDecorator'

# Test: Search for the new function name. Expect: Only occurrences of the new name.
rg --type go 'TestMempoolGasFeeDecorator'

Length of output: 176


Script:

#!/bin/bash
# Description: Verify the consistency of the new function name across the entire codebase.

# Search for the new function name in all files to ensure consistency.
rg 'TestMempoolGasFeeDecorator'

Length of output: 123

app/evmante/evmante_global_fees_test.go (2)

1-9: New Test File: Ensure Proper Structure and Imports

The new test file evmante_global_fees_test.go has been added. Ensure that the structure and imports are correct and consistent with the project standards.


11-100: Test Cases: Ensure Comprehensive Coverage

The test cases for the GlobalFeeDecorator cover various scenarios, including happy and sad paths. Ensure that the test cases are comprehensive and correctly implemented.

x/evm/evm_test.go (2)

130-130: Update to Use EvmKeeper: Ensure Correctness

The call to retrieve the Ethereum account information has been updated to use EvmKeeper. Ensure that this change is correct and consistent with the new architecture.


136-136: Update to Use EvmKeeper: Ensure Correctness

The call to retrieve the Nibiru account information has been updated to use EvmKeeper. Ensure that this change is correct and consistent with the new architecture.

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

111-111: LGTM! Proper gas accounting and overflow handling.

The change ensures that the block gas used is correctly accumulated and prevents overflow errors.


122-122: LGTM! Base fee adjustment.

The change ensures that the base fee is set to a minimal positive value, aligning with the new fee structure.

x/evm/evmmodule/genesis_test.go (11)

51-51: LGTM! Refactored to use EvmKeeper.

The change ensures that the ERC20 functionality is accessed through EvmKeeper, improving clarity and maintainability.


57-57: LGTM! Refactored to use EvmKeeper.

The change ensures that the ERC20 transfer operation is accessed through EvmKeeper, improving clarity and maintainability.


61-61: LGTM! Refactored to use EvmKeeper.

The change ensures that the ERC20 transfer operation is accessed through EvmKeeper, improving clarity and maintainability.


79-79: LGTM! Refactored to use EvmKeeper.

The change ensures that the fungible token transfer operation is accessed through EvmKeeper, improving clarity and maintainability.


90-90: LGTM! Refactored to use EvmKeeper.

The change ensures that the genesis export operation is accessed through EvmKeeper, improving clarity and maintainability.


96-96: LGTM! Refactored to use EvmKeeper.

The change ensures that the genesis initialization operation is accessed through EvmKeeper, improving clarity and maintainability.


99-99: LGTM! Refactored to use EvmKeeper.

The change ensures that the ERC20 balance check is accessed through EvmKeeper, improving clarity and maintainability.


103-103: LGTM! Refactored to use EvmKeeper.

The change ensures that the ERC20 balance check is accessed through EvmKeeper, improving clarity and maintainability.


107-107: LGTM! Refactored to use EvmKeeper.

The change ensures that the ERC20 balance check is accessed through EvmKeeper, improving clarity and maintainability.


115-116: LGTM! Refactored to use EvmKeeper.

The change ensures that the fungible token mapping check is accessed through EvmKeeper, improving clarity and maintainability.


123-123: LGTM! Refactored to use EvmKeeper.

The change ensures that the fungible token balance check is accessed through EvmKeeper, improving clarity and maintainability.

x/evm/precompile/funtoken_test.go (5)

39-39: LGTM! Refactored to use EvmKeeper.

The change ensures that the contract code retrieval is accessed through EvmKeeper, improving clarity and maintainability.


48-48: LGTM! Refactored to use EvmKeeper.

The change ensures that the precompile set check is accessed through EvmKeeper, improving clarity and maintainability.


65-65: LGTM! Refactored to use EvmKeeper.

The change ensures that the contract call operation is accessed through EvmKeeper, improving clarity and maintainability.


80-80: LGTM! Refactored to use EvmKeeper.

The change ensures that the precompile set check is accessed through EvmKeeper, improving clarity and maintainability.


120-120: LGTM! Refactored to use EvmKeeper.

The change ensures that the ERC20 transfer operation is accessed through EvmKeeper, improving clarity and maintainability.

x/evm/params.go (1)

45-45: LGTM!

The addition of GlobalMinGasPrice with a default value of sdk.NewDec(1) aligns with the PR objectives and enhances the gas pricing mechanism.

x/evm/keeper/msg_ethereum_tx_test.go (3)

48-48: LGTM!

The change to access the Ethereum chain ID through EvmKeeper improves clarity and maintainability.


88-88: LGTM!

The change to access the Ethereum chain ID through EvmKeeper improves clarity and maintainability.


141-141: LGTM!

The change to access the Ethereum chain ID through EvmKeeper improves clarity and maintainability.

proto/eth/evm/v1/evm.proto (1)

64-68: LGTM!

The addition of global_min_gas_price with appropriate annotations enhances the functionality of the Params message.

app/evmante/evmante_validate_basic_test.go (1)

232-232: LGTM! But verify the usage of EvmKeeper in the codebase.

The code changes are approved.

However, ensure that EvmKeeper is correctly used throughout the codebase.

Verification successful

Verified: Consistent usage of EvmKeeper across the codebase.

The change from deps.K.SetParams to deps.EvmKeeper.SetParams is consistent with the existing usage patterns of EvmKeeper throughout the codebase.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of `EvmKeeper` in the codebase.

# Test: Search for the usage of `EvmKeeper`. Expect: Consistent usage across the codebase.
rg --type go 'EvmKeeper'

Length of output: 14870

x/evm/keeper/msg_server.go (14)

235-235: LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to NewEVM are correctly updated if there are any dependencies on the previous implementation.


104-104: LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to ApplyEvmTx are correctly updated if there are any dependencies on the previous implementation.

Verification successful

LGTM! But verify the function usage in the codebase.

The code changes are approved. However, ensure that all function calls to ApplyEvmTx are correctly updated if there are any dependencies on the previous implementation.

  • x/evm/keeper/msg_server.go: Confirmed usage of ApplyEvmTx aligns with the new implementation.
  • x/evm/keeper/msg_ethereum_tx_test.go: Verify if the test cases cover the new implementation indirectly.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `ApplyEvmTx` are correctly updated.

# Test: Search for the function usage. Expect: Only occurrences of the new implementation.
rg --type go -A 5 $'ApplyEvmTx'

Length of output: 1683


120-120: LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to ApplyEvmMsg are correctly updated if there are any dependencies on the previous implementation.


52-52: LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to EthereumTx are correctly updated if there are any dependencies on the previous implementation.


248-248: Ensure the BaseFee configuration is consistent.

The configuration of BaseFee using evmConfig.BaseFee is a good change. Ensure that this is consistent throughout the codebase.

Verification successful

The BaseFee configuration is consistent throughout the codebase.

  • The BaseFee is correctly referenced as evmConfig.BaseFee or derived from k.GetBaseFee(ctx) in all relevant files.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the `BaseFee` configuration is consistent.

# Test: Search for `BaseFee` configuration. Expect: Consistent usage throughout the codebase.
rg --type go $'BaseFee'

Length of output: 20552


Script:

#!/bin/bash
# Description: Extract context around `BaseFee` usage to verify consistency.

# Extract context around `BaseFee` in the identified files
rg --type go --context 5 'BaseFee' x/evm/keeper/msg_server.go x/evm/keeper/keeper.go x/evm/keeper/grpc_query.go x/evm/statedb/config.go

Length of output: 7801


407-407: Ensure the GetEthIntrinsicGas method is consistent.

The usage of GetEthIntrinsicGas with the updated evmConfig.ChainConfig parameter is a good change. Ensure that this is consistent throughout the codebase.

Verification successful

The usage of GetEthIntrinsicGas is consistent throughout the codebase.

  • The method is called only once in x/evm/keeper/msg_server.go, and it uses the evmConfig.ChainConfig parameter as expected.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the `GetEthIntrinsicGas` method is consistent.

# Test: Search for `GetEthIntrinsicGas` method usage. Expect: Consistent usage throughout the codebase.
rg --type go $'GetEthIntrinsicGas'

Length of output: 416


Script:

#!/bin/bash
# Description: Verify all usages of the `GetEthIntrinsicGas` method.

# Search for all instances where `GetEthIntrinsicGas` is called.
rg 'GetEthIntrinsicGas' --type go

Length of output: 416


93-93: Ensure the msg.From usage is consistent.

The usage of msg.From directly in the event attributes is a good change. Ensure that this is consistent throughout the codebase.

Verification successful

The search results show that msg.From and msg.From() are used in various contexts. To ensure consistency, we need to understand the context in which these different usages occur. Specifically, we should check if msg.From() is a method call and if it is appropriately used in places where msg.From is not directly accessible.

Let's inspect the context around these usages to verify consistency.


The usage of msg.From is consistent and context-appropriate.

The direct usage of msg.From and the method call msg.From() are context-dependent and used appropriately within the codebase.

  • Direct usage (msg.From) is found in struct contexts.
  • Method usage (msg.From()) is found in object contexts.

No inconsistencies were found in the usage of msg.From.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of `msg.From` is consistent.

# Test: Search for `msg.From` usage. Expect: Consistent usage throughout the codebase.
rg --type go $'msg.From'

Length of output: 1947


Script:

#!/bin/bash
# Inspect the context around the usage of `msg.From` and `msg.From()` to verify consistency.

# Extract lines around `msg.From` to understand its usage context.
rg --type go --context 5 'msg.From' > msg_from_context.txt

# Extract lines around `msg.From()` to understand its usage context.
rg --type go --context 5 'msg.From()' > msg_from_method_context.txt

# Output the gathered contexts for review.
cat msg_from_context.txt
cat msg_from_method_context.txt

Length of output: 24180


256-257: LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to VMConfig are correctly updated if there are any dependencies on the previous implementation.

Verification successful

Ensure all VMConfig function calls are correctly updated.

The VMConfig function and its usage appear consistent and correctly updated in the codebase. The following files were reviewed and confirmed to use the new implementation:

  • x/evm/keeper/msg_server.go
  • x/evm/keeper/grpc_query.go
  • x/evm/keeper/erc20.go
  • x/evm/keeper/vm_config.go
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `VMConfig` are correctly updated.

# Test: Search for the function usage. Expect: Only occurrences of the new implementation.
rg --type go -A 5 $'VMConfig'

Length of output: 9164


Script:

#!/bin/bash
# Description: Verify all function calls to `VMConfig` and `GetEVMConfig` are correctly updated.

# Search for all instances of VMConfig
rg --type go -A 5 $'VMConfig'

# Search for all instances of GetEVMConfig
rg --type go -A 5 $'GetEVMConfig'

Length of output: 12267


Line range hint 471-471:
Ensure the SetParams method is consistent.

The usage of SetParams with the updated evmConfig parameter is a good change. Ensure that this is consistent throughout the codebase.

Verification successful

The SetParams method is used consistently throughout the codebase.

  • The parameters passed to SetParams in all instances are consistent with the expected type.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the `SetParams` method is consistent.

# Test: Search for `SetParams` method usage. Expect: Consistent usage throughout the codebase.
rg --type go $'SetParams'

Length of output: 1161


Script:

#!/bin/bash
# Description: Extract lines around `SetParams` method calls to verify consistency.

# Extract lines around each `SetParams` call for context
rg --type go -A 3 -B 3 $'SetParams'

Length of output: 6604


369-371: Ensure the EnableCreate and EnableCall configurations are consistent.

The configurations for EnableCreate and EnableCall using evmConfig.Params are good changes. Ensure that these are consistent throughout the codebase.

Verification successful

The configurations for EnableCreate and EnableCall are consistently used throughout the codebase. The initialization, protobuf definitions, conditional logic, error handling, and validation logic all align with the intended configuration logic.

  • Initialization:

    • x/evm/params.go: EnableCreate and EnableCall are initialized to true.
  • Protobuf Definitions:

    • x/evm/evm.pb.go: EnableCreate and EnableCall are defined, and there are getter methods for these fields.
  • Conditional Logic:

    • x/evm/keeper/msg_server.go: The logic checks the values of EnableCreate and EnableCall to determine if contract creation or calls are allowed.
  • Error Handling:

    • x/evm/errors.go: Errors are defined for when EnableCreate or EnableCall are disabled.
  • Validation Logic:

    • app/evmante/evmante_validate_basic.go: The values of EnableCreate and EnableCall are retrieved and used in validation.
    • app/evmante/evmante_validate_basic_test.go: Tests modify EnableCreate and EnableCall to test different scenarios.

Conclusion: The EnableCreate and EnableCall configurations are consistent throughout the codebase.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the `EnableCreate` and `EnableCall` configurations are consistent.

# Test: Search for `EnableCreate` and `EnableCall` configurations. Expect: Consistent usage throughout the codebase.
rg --type go $'EnableCreate'
rg --type go $'EnableCall'

Length of output: 2078


184-184: Ensure the RefundGas method is consistent.

The usage of RefundGas with evmConfig.Params.EvmDenom is a good change. Ensure that this is consistent throughout the codebase.

Verification successful

The RefundGas method is used consistently with evmConfig.Params.EvmDenom in the x/evm/keeper directory.

  • x/evm/keeper/msg_server.go: Uses RefundGas with evmConfig.Params.EvmDenom.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the `RefundGas` method is consistent.

# Test: Search for `RefundGas` usage. Expect: Consistent usage throughout the codebase.
rg --type go $'RefundGas'

Length of output: 1334


Script:

#!/bin/bash
# Description: Verify the `RefundGas` method is consistent in the `x/evm/keeper` directory.

# Search for `RefundGas` usage in the `x/evm/keeper` directory.
rg --type go 'RefundGas' x/evm/keeper

Length of output: 519


243-243: Ensure the Coinbase configuration is consistent.

The configuration of Coinbase using evmConfig.CoinBase is a good change. Ensure that this is consistent throughout the codebase.

Verification successful

The Coinbase configuration is consistent throughout the codebase.

The Coinbase configuration using evmConfig.CoinBase is consistent with other instances where Coinbase is set using header.ProposerAddress or derived from proposerAddress.

  • x/evm/keeper/vm_config.go: coinbase is derived from GetCoinbaseAddress, which uses proposerAddress.
  • x/evm/keeper/msg_server.go: evmConfig is obtained using ctx.BlockHeader().ProposerAddress.
  • eth/rpc/rpc.go: Coinbase is set using header.ProposerAddress.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the `Coinbase` configuration is consistent.

# Test: Search for `Coinbase` configuration. Expect: Consistent usage throughout the codebase.
rg --type go $'Coinbase'

Length of output: 495


Script:

#!/bin/bash
# Extract context around the lines where `Coinbase` is mentioned in the identified files.

# Extract context from x/evm/keeper/vm_config.go
rg --type go -A 5 -B 5 'coinbase' x/evm/keeper/vm_config.go

# Extract context from x/evm/keeper/msg_server.go
rg --type go -A 5 -B 5 'Coinbase' x/evm/keeper/msg_server.go

# Extract context from eth/rpc/rpc.go
rg --type go -A 5 -B 5 'Coinbase' eth/rpc/rpc.go

Length of output: 1937


Script:

#!/bin/bash
# Check the definition and usage of `header.ProposerAddress` to verify if it aligns with the `CoinBase` configuration in the `x/evm/keeper` files.

# Search for the definition of `ProposerAddress` in the codebase
rg --type go 'ProposerAddress'

Length of output: 4910


111-111: Ensure the signer configuration is consistent.

The configuration of the signer using evmConfig.ChainConfig is a good change. Ensure that this is consistent throughout the codebase.

Verification successful

The MakeSigner function is used in multiple files across the codebase. To ensure the signer configuration is consistent, we need to verify that each instance uses the appropriate ChainConfig and BlockHeight (or equivalent) parameters.

Instances to review:

  • x/evm/keeper/grpc_query.go (twice)
  • x/evm/keeper/msg_server.go
  • x/evm/evmtest/smart_contract.go
  • eth/rpc/backend/sign_tx.go
  • app/evmante/evmante_sigverify.go
  • app/evmante/evmante_can_transfer.go

Let's gather the necessary information from these files to verify the consistency.


The signer configuration is consistent throughout the codebase. The MakeSigner function consistently uses the appropriate chain configuration and block height (or equivalent) parameters across different files.

  • x/evm/keeper/grpc_query.go: cfg.ChainConfig, big.NewInt(ctx.BlockHeight())
  • x/evm/keeper/msg_server.go: evmConfig.ChainConfig, big.NewInt(ctx.BlockHeight())
  • x/evm/evmtest/smart_contract.go: cfg, blockHeight
  • eth/rpc/backend/sign_tx.go: b.ChainConfig(), new(big.Int).SetUint64(uint64(bn))
  • app/evmante/evmante_sigverify.go: ethCfg, blockNum
  • app/evmante/evmante_can_transfer.go: ethCfg, big.NewInt(ctx.BlockHeight())
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the `signer` configuration is consistent.

# Test: Search for `signer` configuration. Expect: Consistent usage throughout the codebase.
rg --type go $'MakeSigner'

Length of output: 729


Script:

#!/bin/bash
# Extract lines around the usage of MakeSigner to verify consistency in configuration

# Extract context around MakeSigner in grpc_query.go
rg --type go -A 3 -B 3 'MakeSigner' x/evm/keeper/grpc_query.go

# Extract context around MakeSigner in msg_server.go
rg --type go -A 3 -B 3 'MakeSigner' x/evm/keeper/msg_server.go

# Extract context around MakeSigner in smart_contract.go
rg --type go -A 3 -B 3 'MakeSigner' x/evm/evmtest/smart_contract.go

# Extract context around MakeSigner in sign_tx.go
rg --type go -A 3 -B 3 'MakeSigner' eth/rpc/backend/sign_tx.go

# Extract context around MakeSigner in evmante_sigverify.go
rg --type go -A 3 -B 3 'MakeSigner' app/evmante/evmante_sigverify.go

# Extract context around MakeSigner in evmante_can_transfer.go
rg --type go -A 3 -B 3 'MakeSigner' app/evmante/evmante_can_transfer.go

Length of output: 2102


376-376: Ensure the NewEVM method is consistent.

The usage of NewEVM with the updated evmConfig parameter is a good change. Ensure that this is consistent throughout the codebase.

Verification successful

The NewEVM method is used consistently throughout the codebase.

  • x/evm/keeper/msg_server.go
  • app/evmante/interfaces.go
  • app/evmante/evmante_can_transfer.go
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the `NewEVM` method is consistent.

# Test: Search for `NewEVM` method usage. Expect: Consistent usage throughout the codebase.
rg --type go $'NewEVM'

Length of output: 1707


Script:

#!/bin/bash
# Description: Verify the `NewEVM` method is consistent in the specified files.

# Search for the `NewEVM` method definition and its usages in `x/evm/keeper/msg_server.go`.
echo "Searching in x/evm/keeper/msg_server.go"
rg --type go 'NewEVM' -A 5 x/evm/keeper/msg_server.go

# Search for the `NewEVM` method definition and its usages in `app/evmante/interfaces.go`.
echo "Searching in app/evmante/interfaces.go"
rg --type go 'NewEVM' -A 5 app/evmante/interfaces.go

# Search for the `NewEVM` method definition and its usages in `app/evmante/evmante_can_transfer.go`.
echo "Searching in app/evmante/evmante_can_transfer.go"
rg --type go 'NewEVM' -A 5 app/evmante/evmante_can_transfer.go

Length of output: 2169

x/evm/keeper/grpc_query_test.go (6)

Line range hint 459-471:
LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to Params are correctly updated if there are any dependencies on the previous implementation.


307-307: LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to ValidatorAccount are correctly updated if there are any dependencies on the previous implementation.


197-197: LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to EthAccount are correctly updated if there are any dependencies on the previous implementation.

Verification successful

The search results show multiple occurrences of the EthAccount function across different files, including x/evm/keeper/grpc_query_test.go, x/evm/query.pb.gw.go, x/evm/query.pb.go, and others. These occurrences indicate that the EthAccount function is widely used in the codebase.

The key points to verify are:

  1. The function calls in the test files (grpc_query_test.go and evm_test.go) are updated correctly.
  2. The function calls in the main implementation files (grpc_query.go, query.pb.gw.go, and query.pb.go) are consistent with the new implementation.

Given the extensive usage of the EthAccount function, it's important to ensure that all instances are correctly updated. The search results indicate that the new implementation is being used, but a detailed check of each occurrence is necessary to confirm this.

Let's proceed by generating a final response to confirm the updates and ensure no further action is needed.

LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to EthAccount are correctly updated if there are any dependencies on the previous implementation.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `EthAccount` are correctly updated.

# Test: Search for the function usage. Expect: Only occurrences of the new implementation.
rg --type go -A 5 $'EthAccount'

Length of output: 37062


130-130: LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to NibiruAccount are correctly updated if there are any dependencies on the previous implementation.

Verification successful

Function usage verified

All instances of NibiruAccount have been correctly updated to reflect the new implementation.

  • x/evm/keeper/grpc_query_test.go
  • x/evm/evm_test.go
  • x/evm/keeper/grpc_query.go
  • x/evm/query.go
  • x/evm/query.pb.gw.go
  • x/evm/query.pb.go
  • eth/rpc/backend/mocks/evm_query_client.go
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `NibiruAccount` are correctly updated.

# Test: Search for the function usage. Expect: Only occurrences of the new implementation.
rg --type go -A 5 $'NibiruAccount'

Length of output: 25293


383-383: LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to Storage are correctly updated if there are any dependencies on the previous implementation.

Verification successful

Verification successful!

The function calls to Storage have been correctly updated to use deps.EvmKeeper.Storage.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `Storage` are correctly updated.

# Test: Search for the function usage. Expect: Only occurrences of the new implementation.
rg --type go -A 5 $'Storage'

Length of output: 64142


442-442: LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to Code are correctly updated if there are any dependencies on the previous implementation.

"github.com/NibiruChain/nibiru/x/evm"
)

var _ sdk.AnteDecorator = GlobalGasPriceDecorator{}
Copy link
Contributor

Choose a reason for hiding this comment

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

Implement unit tests for GlobalGasPriceDecorator.

Ensure that unit tests are implemented to verify the functionality of GlobalGasPriceDecorator.

Do you want me to generate the unit testing code or open a GitHub issue to track this task?

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

Commits

Files that changed from the base of the PR and between 20b2328 and 3325a08.

Files selected for processing (2)
  • e2e/evm/test/basic_queries.test.ts (1 hunks)
  • e2e/evm/test/contract_send_nibi.test.ts (5 hunks)
Additional comments not posted (4)
e2e/evm/test/contract_send_nibi.test.ts (4)

2-2: LGTM!

The change to import Wallet directly from ethers streamlines the code.


13-13: LGTM!

The changes to handle the transaction receipt and account for gas fees enhance the accuracy of balance checks.

Also applies to: 23-23, 26-26


32-32: LGTM!

The changes to handle the transaction receipt and account for gas fees enhance the accuracy of balance checks.

Also applies to: 42-42, 45-45


51-51: LGTM!

The changes to handle the transaction receipt and account for gas fees enhance the accuracy of balance checks.

Also applies to: 61-61, 64-64

// TODO: https://github.com/NibiruChain/nibiru/issues/1902
// gas is not deducted regardless the gas limit, check this
const expectedSenderBalance = senderBalanceBefore - amountToSend
const expectedSenderBalance = senderBalanceBefore - amountToSend - 50000n // 50k gas for the transaction
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider verifying the gas fee dynamically.

The hardcoded gas fee of 50,000 units might not be accurate for all scenarios. It is better to retrieve the actual gas used from the transaction receipt.

-  const expectedSenderBalance = senderBalanceBefore - amountToSend - 50000n // 50k gas for the transaction
+  const gasUsed = (await txResponse.wait()).gasUsed;
+  const expectedSenderBalance = senderBalanceBefore - amountToSend - gasUsed;
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
const expectedSenderBalance = senderBalanceBefore - amountToSend - 50000n // 50k gas for the transaction
const gasUsed = (await txResponse.wait()).gasUsed;
const expectedSenderBalance = senderBalanceBefore - amountToSend - gasUsed;

Copy link

codecov bot commented Jul 31, 2024

Codecov Report

Attention: Patch coverage is 82.53968% with 11 lines in your changes missing coverage. Please review.

Project coverage is 65.65%. Comparing base (946bfbf) to head (033dec4).
Report is 2 commits behind head on main.

Files Patch % Lines
x/evm/msg.go 0.00% 5 Missing ⚠️
x/evm/keeper/msg_server.go 81.25% 0 Missing and 3 partials ⚠️
app/evmante/evmante_mempool_fees.go 92.85% 1 Missing and 1 partial ⚠️
x/evm/evmtest/erc20.go 80.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1982      +/-   ##
==========================================
- Coverage   65.68%   65.65%   -0.03%     
==========================================
  Files         262      262              
  Lines       16511    16502       -9     
==========================================
- Hits        10845    10835      -10     
- Misses       4852     4854       +2     
+ Partials      814      813       -1     
Files Coverage Δ
app/evmante/evmante_handler.go 100.00% <100.00%> (ø)
x/evm/evmtest/test_deps.go 88.46% <100.00%> (ø)
x/evm/keeper/gas_fees.go 27.39% <ø> (ø)
x/evm/keeper/keeper.go 78.94% <100.00%> (+3.94%) ⬆️
x/evm/evmtest/erc20.go 86.79% <80.00%> (ø)
app/evmante/evmante_mempool_fees.go 92.85% <92.85%> (ø)
x/evm/keeper/msg_server.go 72.11% <81.25%> (-0.27%) ⬇️
x/evm/msg.go 63.90% <0.00%> (-1.23%) ⬇️

@k-yang k-yang self-assigned this Aug 1, 2024
@k-yang k-yang added the x: evm Relates to Nibiru EVM or the EVM Module label Aug 1, 2024
@k-yang k-yang changed the title feat(evm): add global min gas prices fix(evm): gas prices Aug 1, 2024
@Unique-Divine Unique-Divine merged commit d7092f3 into main Aug 6, 2024
16 checks passed
@Unique-Divine Unique-Divine deleted the fix/evm/gas-prices branch August 6, 2024 10:16
@k-yang k-yang restored the fix/evm/gas-prices branch January 3, 2025 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
x: evm Relates to Nibiru EVM or the EVM Module
Projects
Status: ✅ Completed
3 participants