-
Notifications
You must be signed in to change notification settings - Fork 193
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
Conversation
WalkthroughThe recent updates to the Changes
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? TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Additionally, you can add CodeRabbit Configration File (
|
Codecov ReportAttention: Patch coverage is
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
|
There was a problem hiding this 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
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 forEthereumTx
function.Please ensure to replace the placeholder with the actual implementation in future updates.
20-25
: Placeholder implementation forUpdateParams
function.Please ensure to replace the placeholder with the actual implementation in future updates.
x/evm/keeper/hooks.go (2)
10-13
: Placeholder implementation forBeginBlock
function.Please ensure to replace the placeholder with the actual implementation in future updates.
15-21
: Placeholder implementation forEndBlock
function.Please ensure to replace the placeholder with the actual implementation in future updates.
x/evm/evmmodule/genesis.go (2)
12-21
: Placeholder implementation forInitGenesis
function.Please ensure to replace the placeholder with the actual implementation in future updates.
23-30
: Placeholder implementation forExportGenesis
function.Please ensure to replace the placeholder with the actual implementation in future updates.
x/evm/keeper/keeper.go (2)
11-20
: Well-definedKeeper
struct with appropriate comments.
22-36
: Well-implementedNewKeeper
constructor with appropriate error handling.x/evm/deps.go (3)
10-21
: Well-definedAccountKeeper
interface with comprehensive account management methods.
23-30
: Well-definedBankKeeper
interface with essential methods for balance and coin operations.
32-36
: Well-definedStakingKeeper
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-definedCallType
enum to distinguish between different types of EVM calls.x/evm/keeper/keeper_test.go (2)
13-21
: Well-set-up test suite for theKeeper
module.
23-99
: Comprehensive test cases checking forNotImplemented
errors in keeper methods.x/evm/evmmodule/module.go (1)
27-170
: Structure and implementation ofAppModule
andAppModuleBasic
look good.The
AppModule
andAppModuleBasic
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 ofEvmKeeper
toAppKeepers
struct.The
EvmKeeper
has been correctly added to theAppKeepers
struct. This is a necessary step to ensure that the EVM functionalities are accessible throughout the application.
233-233
: Addition ofevm.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 ofEvmKeeper
.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 ofEvmKeeper
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 ofevm.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 ofevmmodule.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 forevm.ModuleName
inModuleAccPerms
.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 |
There was a problem hiding this comment.
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.
- [#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 |
}, 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() | ||
} |
There was a problem hiding this comment.
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?
Summary
BaseApp
, using placeholder functions to satisfy theAppModule
interface methods.