Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(evm): module and keeper start #1869

Merged
merged 2 commits into from
May 13, 2024
Merged

feat(evm): module and keeper start #1869

merged 2 commits into from
May 13, 2024

Conversation

Unique-Divine
Copy link
Member

@Unique-Divine Unique-Divine commented May 10, 2024

Summary

Copy link
Contributor

coderabbitai bot commented May 10, 2024

Walkthrough

The recent updates to the NibiruChain/nibiru project focus on integrating Ethereum Virtual Machine (EVM) capabilities. This includes the addition of new keepers, CLI commands, error handling functions, and extensive updates to the EVM module. The changes enhance the blockchain's functionality by enabling Ethereum compatibility, improving module management, and refining developer tools and documentation.

Changes

Files Change Summary
app/keepers.go Introduced EVM functionality including imports, EvmKeeper additions, and module initializations.
eth/chain_id.go Improved comments for clarity in ParseChainID function.
x/common/error.go Added error functions for unimplemented features.
x/evm/cli/cli.go Introduced CLI commands for EVM transactions and queries.
x/evm/codec.go, x/evm/const.go Adjusted constants for EVM operations, adding and removing as needed.
x/evm/.../genesis.go, x/evm/.../module.go Enhanced EVM module management and initialization functions.
x/evm/keeper/... Expanded keeper functionalities including gRPC queries, hooks, and Ethereum transaction handling.

🐇🌟
In the land of code where the nibiru lies,
A rabbit hopped in with bright, wise eyes.
"Let's weave Ethereum's magic," it said,
With EVM's power, ahead we tread!
Through keeper's keep and CLI commands,
On blockchain fields, new features expand!
🥕🚀🌌


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.

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 a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

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

CodeRabbit Configration 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 May 10, 2024

Codecov Report

Attention: Patch coverage is 91.01124% with 8 lines in your changes are missing coverage. Please review.

Project coverage is 68.15%. Comparing base (e7ed442) to head (820f50e).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1869      +/-   ##
==========================================
+ Coverage   67.85%   68.15%   +0.29%     
==========================================
  Files         203      207       +4     
  Lines       13070    13159      +89     
==========================================
+ Hits         8869     8968      +99     
+ Misses       3561     3550      -11     
- Partials      640      641       +1     
Files Coverage Δ
app/keepers.go 99.15% <100.00%> (+0.01%) ⬆️
eth/chain_id.go 86.66% <ø> (ø)
x/evm/codec.go 84.21% <ø> (+47.36%) ⬆️
x/evm/const.go 0.00% <ø> (ø)
x/evm/keeper/grpc_query.go 100.00% <100.00%> (ø)
x/evm/keeper/msg_server.go 100.00% <100.00%> (ø)
x/evm/keeper/keeper.go 75.00% <75.00%> (ø)
x/common/error.go 64.70% <0.00%> (-1.97%) ⬇️
x/evm/keeper/hooks.go 0.00% <0.00%> (ø)

@Unique-Divine Unique-Divine marked this pull request as ready for review May 10, 2024 08:33
@Unique-Divine Unique-Divine requested a review from a team as a code owner May 10, 2024 08:33
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: 6

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between e7ed442 and 820f50e.
Files selected for processing (15)
  • CHANGELOG.md (1 hunks)
  • app/keepers.go (8 hunks)
  • eth/chain_id.go (1 hunks)
  • x/common/error.go (1 hunks)
  • x/evm/cli/cli.go (1 hunks)
  • x/evm/codec.go (1 hunks)
  • x/evm/const.go (1 hunks)
  • x/evm/deps.go (1 hunks)
  • x/evm/evmmodule/genesis.go (1 hunks)
  • x/evm/evmmodule/module.go (1 hunks)
  • x/evm/keeper/grpc_query.go (1 hunks)
  • x/evm/keeper/hooks.go (1 hunks)
  • x/evm/keeper/keeper.go (1 hunks)
  • x/evm/keeper/keeper_test.go (1 hunks)
  • x/evm/keeper/msg_server.go (1 hunks)
Files skipped from review due to trivial changes (2)
  • eth/chain_id.go
  • x/evm/codec.go
Additional Context Used
GitHub Check Runs (1)
codecov/patch success (6)

x/common/error.go: [warning] 192-192: x/common/error.go#L192
Added line #L192 was not covered by tests


x/common/error.go: [warning] 195-196: x/common/error.go#L195-L196
Added lines #L195 - L196 were not covered by tests


x/evm/keeper/hooks.go: [warning] 11-11: x/evm/keeper/hooks.go#L11
Added line #L11 was not covered by tests


x/evm/keeper/hooks.go: [warning] 18-18: x/evm/keeper/hooks.go#L18
Added line #L18 was not covered by tests


x/evm/keeper/hooks.go: [warning] 20-20: x/evm/keeper/hooks.go#L20
Added line #L20 was not covered by tests


x/evm/keeper/keeper.go: [warning] 28-28: x/evm/keeper/keeper.go#L28
Added line #L28 was not covered by tests

Additional comments not posted (24)
x/evm/keeper/msg_server.go (2)

13-18: Placeholder implementation for EthereumTx function.

Please ensure to replace the placeholder with the actual implementation in future updates.


20-25: Placeholder implementation for UpdateParams function.

Please ensure to replace the placeholder with the actual implementation in future updates.

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

10-13: Placeholder implementation for BeginBlock function.

Please ensure to replace the placeholder with the actual implementation in future updates.


15-21: Placeholder implementation for EndBlock function.

Please ensure to replace the placeholder with the actual implementation in future updates.

x/evm/evmmodule/genesis.go (2)

12-21: Placeholder implementation for InitGenesis function.

Please ensure to replace the placeholder with the actual implementation in future updates.


23-30: Placeholder implementation for ExportGenesis function.

Please ensure to replace the placeholder with the actual implementation in future updates.

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

11-20: Well-defined Keeper struct with appropriate comments.


22-36: Well-implemented NewKeeper constructor with appropriate error handling.

x/evm/deps.go (3)

10-21: Well-defined AccountKeeper interface with comprehensive account management methods.


23-30: Well-defined BankKeeper interface with essential methods for balance and coin operations.


32-36: Well-defined StakingKeeper interface with methods for retrieving staking information.

x/evm/const.go (2)

Line range hint 1-62: Well-defined constants for the EVM module with appropriate comments.


69-76: Well-defined CallType enum to distinguish between different types of EVM calls.

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

13-21: Well-set-up test suite for the Keeper module.


23-99: Comprehensive test cases checking for NotImplemented errors in keeper methods.

x/evm/evmmodule/module.go (1)

27-170: Structure and implementation of AppModule and AppModuleBasic look good.

The AppModule and AppModuleBasic classes are well-implemented according to the Cosmos SDK module pattern. Good job on maintaining clean and clear code structure.

app/keepers.go (8)

115-117: Integration of EVM module imports.

This change correctly imports the necessary packages for the EVM module, ensuring that the module's functionalities can be utilized within the application.


189-189: Addition of EvmKeeper to AppKeepers struct.

The EvmKeeper has been correctly added to the AppKeepers struct. This is a necessary step to ensure that the EVM functionalities are accessible throughout the application.


233-233: Addition of evm.StoreKey to the store keys initialization.

The addition of evm.StoreKey to the store keys initialization is crucial for the EVM module to function correctly, as it defines the storage key under which the EVM data will be stored.


394-399: Initialization of EvmKeeper.

The initialization of EvmKeeper is done correctly, with appropriate parameters passed, including the module address. This setup is essential for the EVM module's operations within the application.


651-651: Integration of EvmKeeper into the application modules.

The EvmKeeper is correctly integrated into the application modules, allowing it to participate in the application's lifecycle and interact with other modules.


723-723: Addition of evm.ModuleName to ordered module names.

Properly adding evm.ModuleName to the ordered module names ensures that the EVM module is considered during the application's lifecycle events, such as begin and end block operations.


828-828: Registration of evmmodule.AppModuleBasic.

The registration of evmmodule.AppModuleBasic is crucial for setting up non-dependent module elements like codec registration and genesis verification for the EVM module.


854-854: Addition of permissions for evm.ModuleName in ModuleAccPerms.

Correctly setting permissions for the EVM module in ModuleAccPerms is important for defining the access control and capabilities of the EVM module, particularly in terms of token minting and burning.

@@ -57,6 +57,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [#1855](https://github.com/NibiruChain/nibiru/pull/1855) - feat(eth-pubsub): Implement in-memory EventBus for real-time topic management and event distribution
- [#1856](https://github.com/NibiruChain/nibiru/pull/1856) - feat(eth-rpc): Conversion types and functions between Ethereum txs and blocks and Tendermint ones.
- [#1861](https://github.com/NibiruChain/nibiru/pull/1861) - feat(eth-rpc): RPC backend, Ethereum tracer, KV indexer, and RPC APIs
- [#1869](https://github.com/NibiruChain/nibiru/pull/1869) - feat(eth): Module and start of keeper tests
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove trailing space at the end of the line.

- - [#1869](https://github.com/NibiruChain/nibiru/pull/1869) - feat(eth): Module and start of keeper tests 
+ - [#1869](https://github.com/NibiruChain/nibiru/pull/1869) - feat(eth): Module and start of keeper tests

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.

Suggested change
- [#1869](https://github.com/NibiruChain/nibiru/pull/1869) - feat(eth): Module and start of keeper tests
- [#1869](https://github.com/NibiruChain/nibiru/pull/1869) - feat(eth): Module and start of keeper tests

x/common/error.go Show resolved Hide resolved
x/common/error.go Show resolved Hide resolved
Comment on lines +26 to +238
}, common.ErrNotImplementedGprc()
}

// Params: Implements the gRPC query for "/eth.evm.v1.Query/Params".
// Params retrieves the EVM module parameters.
//
// Parameters:
// - goCtx: The context.Context object representing the request context.
// - req: The QueryParamsRequest object (unused).
//
// Returns:
// - A pointer to the QueryParamsResponse object containing the EVM module parameters.
// - An error if the parameter retrieval process encounters any issues.
func (k Keeper) Params(goCtx context.Context, _ *evm.QueryParamsRequest) (*evm.QueryParamsResponse, error) {
// TODO: feat(evm): impl query Params
return &evm.QueryParamsResponse{
Params: evm.Params{},
}, common.ErrNotImplementedGprc()
}

// EthCall: Implements the gRPC query for "/eth.evm.v1.Query/EthCall".
// EthCall performs a smart contract call using the eth_call JSON-RPC method.
//
// Parameters:
// - goCtx: The context.Context object representing the request context.
// - req: The EthCallRequest object containing the call parameters.
//
// Returns:
// - A pointer to the MsgEthereumTxResponse object containing the result of the eth_call.
// - An error if the eth_call process encounters any issues.
func (k Keeper) EthCall(
goCtx context.Context, req *evm.EthCallRequest,
) (*evm.MsgEthereumTxResponse, error) {
// TODO: feat(evm): impl query EthCall
return &evm.MsgEthereumTxResponse{
Hash: "",
Logs: []*evm.Log{},
Ret: []byte{},
VmError: "",
GasUsed: 0,
}, common.ErrNotImplementedGprc()
}

// EstimateGas: Implements the gRPC query for "/eth.evm.v1.Query/EstimateGas".
// EstimateGas implements eth_estimateGas rpc api.
func (k Keeper) EstimateGas(
goCtx context.Context, req *evm.EthCallRequest,
) (*evm.EstimateGasResponse, error) {
// TODO: feat(evm): impl query EstimateGas
return k.EstimateGasForEvmCallType(goCtx, req, evm.CallTypeRPC)
}

// EstimateGas estimates the gas cost of a transaction. This can be called with
// the "eth_estimateGas" JSON-RPC method or an smart contract query.
//
// When [EstimateGas] is called from the JSON-RPC client, we need to reset the
// gas meter before simulating the transaction (tx) to have an accurate gas estimate
// txs using EVM extensions.
//
// Parameters:
// - goCtx: The context.Context object representing the request context.
// - req: The EthCallRequest object containing the transaction parameters.
//
// Returns:
// - A pointer to the EstimateGasResponse object containing the estimated gas cost.
// - An error if the gas estimation process encounters any issues.
func (k Keeper) EstimateGasForEvmCallType(
goCtx context.Context, req *evm.EthCallRequest, fromType evm.CallType,
) (*evm.EstimateGasResponse, error) {
// TODO: feat(evm): impl query EstimateGasForEvmCallType
return &evm.EstimateGasResponse{
Gas: 0,
}, common.ErrNotImplementedGprc()
}

// TraceTx configures a new tracer according to the provided configuration, and
// executes the given message in the provided environment. The return value will
// be tracer dependent.
func (k Keeper) TraceTx(
goCtx context.Context, req *evm.QueryTraceTxRequest,
) (*evm.QueryTraceTxResponse, error) {
// TODO: feat(evm): impl query TraceTx
return &evm.QueryTraceTxResponse{
Data: []byte{},
}, common.ErrNotImplementedGprc()
}

// TraceBlock: Implements the gRPC query for "/eth.evm.v1.Query/TraceBlock".
// Configures a Nibiru EVM tracer that is used to "trace" and analyze
// the execution of transactions within a given block. Block information is read
// from the context (goCtx). [TraceBlock] is responsible iterates over each Eth
// transacion message and calls [TraceEthTxMsg] on it.
func (k Keeper) TraceBlock(
goCtx context.Context, req *evm.QueryTraceBlockRequest,
) (*evm.QueryTraceBlockResponse, error) {
// TODO: feat(evm): impl query TraceBlock
return &evm.QueryTraceBlockResponse{
Data: []byte{},
}, common.ErrNotImplementedGprc()
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Implement the gRPC query functions or track them for future implementation.

All gRPC query functions in this file are marked with TODOs and are not yet implemented. It's crucial to either implement these functions or track them in your project management tool to ensure they are completed in the future. Would you like assistance in creating GitHub issues for each of these TODOs?

x/evm/cli/cli.go Show resolved Hide resolved
x/evm/cli/cli.go Show resolved Hide resolved
@Unique-Divine Unique-Divine merged commit 2342254 into main May 13, 2024
19 checks passed
@Unique-Divine Unique-Divine deleted the ud/eth branch May 13, 2024 15:40
@Unique-Divine Unique-Divine added the x: evm Relates to Nibiru EVM or the EVM Module label May 28, 2024
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
Development

Successfully merging this pull request may close these issues.

1 participant